aboutsummaryrefslogtreecommitdiff
path: root/src/fields/ScriptField.ts
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2025-05-30 03:30:12 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2025-05-30 03:30:12 -0400
commit29e5bbe68e02fe1d86e960a634d0580c37612254 (patch)
treee88585946a58feb988e3a3bb45dd2a9a09fea4c3 /src/fields/ScriptField.ts
parentf92a02ec5d676359cb268a35d30e5bf9886199c1 (diff)
parent49fb76f1c54fb8fc4e76bdcf675719d41bfc36aa (diff)
Merge branch 'master' into Template-Changes
Diffstat (limited to 'src/fields/ScriptField.ts')
-rw-r--r--src/fields/ScriptField.ts15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/fields/ScriptField.ts b/src/fields/ScriptField.ts
index b294ee8c6..37b65684b 100644
--- a/src/fields/ScriptField.ts
+++ b/src/fields/ScriptField.ts
@@ -149,7 +149,6 @@ export class ScriptField extends ObjectField {
...params,
},
transformer,
- typecheck: false,
editable: true,
addReturn: addReturn,
capturedVariables,
@@ -189,14 +188,12 @@ export class ScriptField extends ObjectField {
export class ComputedField extends ScriptField {
static undefined = '__undefined';
static useComputed = true;
- static DisableComputedFields() { this.useComputed = false; } // prettier-ignore
- static EnableComputedFields() { this.useComputed = true; } // prettier-ignore
- static WithoutComputed<T>(fn: () => T) {
- this.DisableComputedFields();
+ static DisableCompute<T>(fn: () => T) {
+ this.useComputed = false;
try {
return fn();
} finally {
- this.EnableComputedFields();
+ this.useComputed = true;
}
}
@@ -210,6 +207,7 @@ export class ComputedField extends ScriptField {
this._lastComputedResult =
this._cachedResult ??
computedFn(() =>
+ ((val) => val instanceof Array ? new List<number>(val) : val)(
this.script.compiled &&
this.script.run(
{
@@ -220,7 +218,7 @@ export class ComputedField extends ScriptField {
_readOnly_: true,
},
console.log
- ).result as FieldResult
+ ).result as FieldResult)
)(); // prettier-ignore
return this._lastComputedResult;
};
@@ -238,7 +236,8 @@ export class ComputedField extends ScriptField {
public static MakeInterpolatedNumber(fieldKey: string, interpolatorKey: string, doc: Doc, curTimecode: number, defaultVal: Opt<number>) {
if (!doc[`${fieldKey}_indexed`]) {
const flist = new List<number>(numberRange(curTimecode + 1).map(emptyFunction) as unknown as number[]);
- flist[curTimecode] = Cast(doc[fieldKey], 'number', null);
+ if (Cast(doc[fieldKey], 'number', null) === undefined) delete flist[curTimecode];
+ else flist[curTimecode] = Cast(doc[fieldKey], 'number', null)!;
doc[`${fieldKey}_indexed`] = flist;
}
const getField = ScriptField.CompileScript(`getIndexVal(this['${fieldKey}_indexed'], this.${interpolatorKey}, ${defaultVal})`, {}, true, {});