From d818ef151ca65008e5c6bb5e92b709decb3026d8 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 14 Apr 2025 18:35:49 -0400 Subject: fixed how templates are expanded to avoid template sub-component conflicts by changing how field keys are named. fixed various Cast functions to be more typesafe by including undefined as part of return type. overhaul of Doc.MakeClone, MakeCopy, FindRefernces - makeClone is no longer async. fixed inlined docs in text docs. --- src/fields/ScriptField.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/fields/ScriptField.ts') diff --git a/src/fields/ScriptField.ts b/src/fields/ScriptField.ts index 6e2d7eb78..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(fn: () => T) { - this.DisableComputedFields(); + static DisableCompute(fn: () => T) { + this.useComputed = false; try { return fn(); } finally { - this.EnableComputedFields(); + this.useComputed = true; } } @@ -239,7 +236,8 @@ export class ComputedField extends ScriptField { public static MakeInterpolatedNumber(fieldKey: string, interpolatorKey: string, doc: Doc, curTimecode: number, defaultVal: Opt) { if (!doc[`${fieldKey}_indexed`]) { const flist = new List(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, {}); -- cgit v1.2.3-70-g09d2