aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/ScriptingGlobals.ts
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2022-03-20 10:29:42 -0400
committermehekj <mehek.jethani@gmail.com>2022-03-20 10:29:42 -0400
commit0a5e02a87fdabff5ff8399829ff857cae90fc1e2 (patch)
treeb7c05080dac66366768f23e59a43f62533a22415 /src/client/util/ScriptingGlobals.ts
parent1f7cf7babc76ecff5aef5fe663c48e067e85dd26 (diff)
Revert "Merge remote-tracking branch 'origin/speedups2' into temporalmedia-mehek"
This reverts commit 1f7cf7babc76ecff5aef5fe663c48e067e85dd26, reversing changes made to 1e3ad4de06f83eab54628de660529fefb9a0dc63.
Diffstat (limited to 'src/client/util/ScriptingGlobals.ts')
-rw-r--r--src/client/util/ScriptingGlobals.ts81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/client/util/ScriptingGlobals.ts b/src/client/util/ScriptingGlobals.ts
deleted file mode 100644
index f151acd81..000000000
--- a/src/client/util/ScriptingGlobals.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-
-import * as ts from "typescript";
-export { ts };
-
-export namespace ScriptingGlobals {
- export function add(global: { name: string }): void;
- export function add(name: string, global: any): void;
- export function add(global: { name: string }, decription?: string, params?: string): void;
- export function add(first: any, second?: any, third?: string) {
- let n: any;
- let obj: any;
-
- if (second !== undefined) {
- if (typeof first === "string") {
- n = first;
- obj = second;
- } else {
- obj = first;
- n = first.name;
- _scriptingDescriptions[n] = second;
- if (third !== undefined) {
- _scriptingParams[n] = third;
- }
- }
- } else if (first && typeof first.name === "string") {
- n = first.name;
- obj = first;
- } else {
- throw new Error("Must either register an object with a name, or give a name and an object");
- }
- if (n === undefined || n === "undefined") {
- return false;
- } else if (_scriptingGlobals.hasOwnProperty(n)) {
- throw new Error(`Global with name ${n} is already registered, choose another name`);
- }
- _scriptingGlobals[n] = obj;
- }
- export function makeMutableGlobalsCopy(globals?: { [name: string]: any }) {
- return { ..._scriptingGlobals, ...(globals || {}) };
- }
-
- export function setScriptingGlobals(globals: { [key: string]: any }) {
- scriptingGlobals = globals;
- }
-
- export function removeGlobal(name: string) {
- if (getGlobals().includes(name)) {
- delete _scriptingGlobals[name];
- if (_scriptingDescriptions[name]) {
- delete _scriptingDescriptions[name];
- }
- if (_scriptingParams[name]) {
- delete _scriptingParams[name];
- }
- return true;
- }
- return false;
- }
-
- export function resetScriptingGlobals() { scriptingGlobals = _scriptingGlobals; }
-
- // const types = Object.keys(ts.SyntaxKind).map(kind => ts.SyntaxKind[kind]);
- export function printNodeType(node: any, indentation = "") { console.log(indentation + ts.SyntaxKind[node.kind]); }
-
- export function getGlobals() { return Object.keys(_scriptingGlobals); }
-
- export function getGlobalObj() { return _scriptingGlobals; }
-
- export function getDescriptions() { return _scriptingDescriptions; }
-
- export function getParameters() { return _scriptingParams; }
-}
-
-export function scriptingGlobal(constructor: { new(...args: any[]): any }) {
- ScriptingGlobals.add(constructor);
-}
-
-const _scriptingGlobals: { [name: string]: any } = {};
-export let scriptingGlobals: { [name: string]: any } = _scriptingGlobals;
-const _scriptingDescriptions: { [name: string]: any } = {};
-const _scriptingParams: { [name: string]: any } = {}; \ No newline at end of file