aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/Scripting.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-03-04 15:19:09 -0500
committerbobzel <zzzman@gmail.com>2022-03-04 15:19:09 -0500
commitff2602bb598b6e82330a9a0b2453e44d70c94c39 (patch)
tree37a0106c1c23c1bd1c0509cc1e2ebe4e9f703b2b /src/client/util/Scripting.ts
parentc015dc3b76ec30e9d7057ee558787e59033af270 (diff)
removed pseudo Doc type system. playing with hot reloading.
Diffstat (limited to 'src/client/util/Scripting.ts')
-rw-r--r--src/client/util/Scripting.ts15
1 files changed, 7 insertions, 8 deletions
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<ts.SourceFile>,
- 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);
}