From ff2602bb598b6e82330a9a0b2453e44d70c94c39 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 4 Mar 2022 15:19:09 -0500 Subject: removed pseudo Doc type system. playing with hot reloading. --- src/client/util/Scripting.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/client/util/Scripting.ts') diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts index 40b94024e..ffe60c72e 100644 --- a/src/client/util/Scripting.ts +++ b/src/client/util/Scripting.ts @@ -10,7 +10,6 @@ export { ts }; // @ts-ignore import * as typescriptlib from '!!raw-loader!./type_decls.d'; -import { Doc, Field } from '../../fields/Doc'; export interface ScriptSuccess { success: true; @@ -169,19 +168,19 @@ function Run(script: string | undefined, customParams: string[], diagnostics: an let batch: { end(): void } | undefined = undefined; try { if (!options.editable) { - batch = Doc.MakeReadOnly(); + // batch = Doc.MakeReadOnly(); } const result = compiledFunction.apply(thisParam, params).apply(thisParam, argsArray); if (batch) { - batch.end(); + //batch.end(); } return { success: true, result }; } catch (error) { if (batch) { - batch.end(); + //batch.end(); } onError?.(script + " " + error); return { success: false, error, result: errorVal }; @@ -247,13 +246,13 @@ export type Traverser = (node: ts.Node, indentation: string) => boolean | void; export type TraverserParam = Traverser | { onEnter: Traverser, onLeave: Traverser }; export type Transformer = { transformer: ts.TransformerFactory, - getVars?: () => { capturedVariables: { [name: string]: Field } } + getVars?: () => { capturedVariables: { [name: string]: any /* Field*/ } } }; export interface ScriptOptions { requiredType?: string; // does function required a typed return value addReturn?: boolean; // does the compiler automatically add a return statement params?: { [name: string]: string }; // list of function parameters and their types - capturedVariables?: { [name: string]: Field }; // list of captured variables + capturedVariables?: { [name: string]: any /* Field */ }; // list of captured variables typecheck?: boolean; // should the compiler perform typechecking editable?: boolean; // can the script edit Docs traverser?: TraverserParam; @@ -270,8 +269,8 @@ function forEachNode(node: ts.Node, onEnter: Traverser, onExit?: Traverser, inde export function CompileScript(script: string, options: ScriptOptions = {}): CompileResult { const { requiredType = "", addReturn = false, params = {}, capturedVariables = {}, typecheck = true } = options; - if (options.params && !options.params.this) options.params.this = Doc.name; - if (options.params && !options.params.self) options.params.self = Doc.name; + if (options.params && !options.params.this) options.params.this = "Doc";//Doc.name; + if (options.params && !options.params.self) options.params.self = "Doc";//Doc.name; if (options.globals) { Scripting.setScriptingGlobals(options.globals); } -- cgit v1.2.3-70-g09d2