@nyariv/sandboxjs 0.8.22 → 0.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/.eslintrc.js +22 -0
- package/.prettierrc +4 -0
- package/.vscode/settings.json +4 -0
- package/build/Sandbox.d.ts +11 -78
- package/build/Sandbox.js +21 -216
- package/build/SandboxExec.d.ts +25 -0
- package/build/SandboxExec.js +169 -0
- package/build/eval.d.ts +18 -0
- package/build/eval.js +43 -0
- package/build/executor.d.ts +56 -95
- package/build/executor.js +739 -815
- package/build/parser.d.ts +112 -74
- package/build/parser.js +504 -542
- package/build/unraw.js +13 -16
- package/build/utils.d.ts +242 -0
- package/build/utils.js +276 -0
- package/dist/Sandbox.d.ts +11 -78
- package/dist/Sandbox.js +106 -1
- package/dist/Sandbox.js.map +1 -1
- package/dist/Sandbox.min.js +1 -1
- package/dist/Sandbox.min.js.map +1 -1
- package/dist/SandboxExec.d.ts +25 -0
- package/dist/SandboxExec.js +173 -0
- package/dist/SandboxExec.js.map +1 -0
- package/dist/SandboxExec.min.js +2 -0
- package/dist/SandboxExec.min.js.map +1 -0
- package/dist/eval.d.ts +18 -0
- package/dist/executor.d.ts +56 -95
- package/dist/executor.js +1270 -0
- package/dist/executor.js.map +1 -0
- package/dist/node/Sandbox.d.ts +11 -78
- package/dist/node/Sandbox.js +37 -3091
- package/dist/node/SandboxExec.d.ts +25 -0
- package/dist/node/SandboxExec.js +176 -0
- package/dist/node/eval.d.ts +18 -0
- package/dist/node/executor.d.ts +56 -95
- package/dist/node/executor.js +1289 -0
- package/dist/node/parser.d.ts +112 -74
- package/dist/node/parser.js +1528 -0
- package/dist/node/utils.d.ts +242 -0
- package/dist/node/utils.js +290 -0
- package/dist/parser.d.ts +112 -74
- package/dist/parser.js +1514 -0
- package/dist/parser.js.map +1 -0
- package/dist/utils.d.ts +242 -0
- package/dist/utils.js +279 -0
- package/dist/utils.js.map +1 -0
- package/package.json +22 -14
- package/.github/workflows/npm-publish.yml +0 -34
package/build/executor.d.ts
CHANGED
|
@@ -1,140 +1,98 @@
|
|
|
1
|
-
import { LispItem, Lisp,
|
|
2
|
-
import { IExecContext, Ticks } from
|
|
3
|
-
export
|
|
4
|
-
export declare type sandboxedEval = (code: string) => any;
|
|
5
|
-
export declare type sandboxSetTimeout = (handler: TimerHandler, timeout?: any, ...args: any[]) => any;
|
|
6
|
-
export declare type sandboxSetInterval = (handler: TimerHandler, timeout?: any, ...args: any[]) => any;
|
|
7
|
-
export declare type Done = (err?: any, res?: any) => void;
|
|
1
|
+
import { LispItem, Lisp, LispFamily, ExtractLispOp } from './parser.js';
|
|
2
|
+
import { IAuditReport, IExecContext, IScope, LispType, Prop, Scope, Ticks } from './utils.js';
|
|
3
|
+
export type Done<T = any> = (err?: any, res?: T | typeof optional) => void;
|
|
8
4
|
export declare class ExecReturn<T> {
|
|
9
|
-
auditReport: IAuditReport;
|
|
5
|
+
auditReport: IAuditReport | undefined;
|
|
10
6
|
result: T;
|
|
11
7
|
returned: boolean;
|
|
12
8
|
breakLoop: boolean;
|
|
13
9
|
continueLoop: boolean;
|
|
14
|
-
constructor(auditReport: IAuditReport, result: T, returned: boolean, breakLoop?: boolean, continueLoop?: boolean);
|
|
15
|
-
}
|
|
16
|
-
export interface IAuditReport {
|
|
17
|
-
globalsAccess: Set<any>;
|
|
18
|
-
prototypeAccess: {
|
|
19
|
-
[name: string]: Set<string>;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface IGlobals {
|
|
23
|
-
[key: string]: any;
|
|
10
|
+
constructor(auditReport: IAuditReport | undefined, result: T, returned: boolean, breakLoop?: boolean, continueLoop?: boolean);
|
|
24
11
|
}
|
|
12
|
+
export type Unknown = undefined | null | Record<string | number, unknown>;
|
|
25
13
|
export interface IChange {
|
|
26
14
|
type: string;
|
|
27
15
|
}
|
|
28
16
|
export interface ICreate extends IChange {
|
|
29
|
-
type:
|
|
17
|
+
type: 'create';
|
|
30
18
|
prop: number | string;
|
|
31
19
|
}
|
|
32
20
|
export interface IReplace extends IChange {
|
|
33
|
-
type:
|
|
21
|
+
type: 'replace';
|
|
34
22
|
}
|
|
35
23
|
export interface IDelete extends IChange {
|
|
36
|
-
type:
|
|
24
|
+
type: 'delete';
|
|
37
25
|
prop: number | string;
|
|
38
26
|
}
|
|
39
27
|
export interface IReverse extends IChange {
|
|
40
|
-
type:
|
|
28
|
+
type: 'reverse';
|
|
41
29
|
}
|
|
42
30
|
export interface ISort extends IChange {
|
|
43
|
-
type:
|
|
31
|
+
type: 'sort';
|
|
44
32
|
}
|
|
45
33
|
export interface IPush extends IChange {
|
|
46
|
-
type:
|
|
34
|
+
type: 'push';
|
|
47
35
|
added: unknown[];
|
|
48
36
|
}
|
|
49
37
|
export interface IPop extends IChange {
|
|
50
|
-
type:
|
|
38
|
+
type: 'pop';
|
|
51
39
|
removed: unknown[];
|
|
52
40
|
}
|
|
53
41
|
export interface IShift extends IChange {
|
|
54
|
-
type:
|
|
42
|
+
type: 'shift';
|
|
55
43
|
removed: unknown[];
|
|
56
44
|
}
|
|
57
45
|
export interface IUnShift extends IChange {
|
|
58
|
-
type:
|
|
46
|
+
type: 'unshift';
|
|
59
47
|
added: unknown[];
|
|
60
48
|
}
|
|
61
49
|
export interface ISplice extends IChange {
|
|
62
|
-
type:
|
|
50
|
+
type: 'splice';
|
|
63
51
|
startIndex: number;
|
|
64
52
|
deleteCount: number;
|
|
65
53
|
added: unknown[];
|
|
66
54
|
removed: unknown[];
|
|
67
55
|
}
|
|
68
56
|
export interface ICopyWithin extends IChange {
|
|
69
|
-
type:
|
|
57
|
+
type: 'copyWithin';
|
|
70
58
|
startIndex: number;
|
|
71
59
|
endIndex: number;
|
|
72
60
|
added: unknown[];
|
|
73
61
|
removed: unknown[];
|
|
74
62
|
}
|
|
75
|
-
export
|
|
76
|
-
|
|
77
|
-
export declare
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
prop: string;
|
|
82
|
-
isConst: boolean;
|
|
83
|
-
isGlobal: boolean;
|
|
84
|
-
isVariable: boolean;
|
|
85
|
-
constructor(context: {
|
|
86
|
-
[key: string]: any;
|
|
87
|
-
}, prop: string, isConst?: boolean, isGlobal?: boolean, isVariable?: boolean);
|
|
88
|
-
get(context: IExecContext): any;
|
|
89
|
-
}
|
|
90
|
-
declare enum VarType {
|
|
91
|
-
let = "let",
|
|
92
|
-
const = "const",
|
|
93
|
-
var = "var"
|
|
94
|
-
}
|
|
95
|
-
export declare class Scope {
|
|
96
|
-
parent: Scope;
|
|
97
|
-
const: {
|
|
98
|
-
[key: string]: true;
|
|
99
|
-
};
|
|
100
|
-
let: {
|
|
101
|
-
[key: string]: true;
|
|
102
|
-
};
|
|
103
|
-
var: {
|
|
104
|
-
[key: string]: true;
|
|
105
|
-
};
|
|
106
|
-
globals: {
|
|
107
|
-
[key: string]: true;
|
|
108
|
-
};
|
|
109
|
-
allVars: {
|
|
110
|
-
[key: string]: any;
|
|
111
|
-
} & Object;
|
|
112
|
-
functionThis?: any;
|
|
113
|
-
constructor(parent: Scope, vars?: {}, functionThis?: any);
|
|
114
|
-
get(key: string, functionScope?: boolean): Prop;
|
|
115
|
-
set(key: string, val: any): Prop;
|
|
116
|
-
declare(key: string, type?: VarType, value?: any, isGlobal?: boolean): any;
|
|
117
|
-
}
|
|
118
|
-
export interface IScope {
|
|
119
|
-
[key: string]: any;
|
|
120
|
-
}
|
|
121
|
-
export declare class FunctionScope implements IScope {
|
|
122
|
-
}
|
|
123
|
-
export declare class LocalScope implements IScope {
|
|
124
|
-
}
|
|
125
|
-
export declare class SandboxError extends Error {
|
|
126
|
-
}
|
|
127
|
-
export declare function sandboxFunction(context: IExecContext, ticks?: Ticks): SandboxFunction;
|
|
128
|
-
export declare function createFunction(argNames: string[], parsed: LispItem, ticks: Ticks, context: IExecContext, scope?: Scope, name?: string): any;
|
|
129
|
-
export declare function createFunctionAsync(argNames: string[], parsed: LispItem, ticks: Ticks, context: IExecContext, scope?: Scope, name?: string): any;
|
|
130
|
-
export declare function sandboxedEval(func: SandboxFunction): sandboxedEval;
|
|
131
|
-
export declare function sandboxedSetTimeout(func: SandboxFunction): sandboxSetTimeout;
|
|
132
|
-
export declare function sandboxedSetInterval(func: SandboxFunction): sandboxSetInterval;
|
|
63
|
+
export type Change = ICreate | IReplace | IDelete | IReverse | ISort | IPush | IPop | IUnShift | IShift | ISplice | ICopyWithin;
|
|
64
|
+
declare const optional: {};
|
|
65
|
+
export declare const sandboxedFunctions: WeakSet<object>;
|
|
66
|
+
export declare function createFunction(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string): (...args: unknown[]) => unknown;
|
|
67
|
+
export declare function createFunctionAsync(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string): (...args: unknown[]) => Promise<unknown>;
|
|
133
68
|
export declare function assignCheck(obj: Prop, context: IExecContext, op?: string): void;
|
|
134
|
-
declare
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
69
|
+
export declare class KeyVal {
|
|
70
|
+
key: string | SpreadObject;
|
|
71
|
+
val: unknown;
|
|
72
|
+
constructor(key: string | SpreadObject, val: unknown);
|
|
73
|
+
}
|
|
74
|
+
export declare class SpreadObject {
|
|
75
|
+
item: {
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
};
|
|
78
|
+
constructor(item: {
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export declare class SpreadArray {
|
|
83
|
+
item: unknown[];
|
|
84
|
+
constructor(item: unknown[]);
|
|
85
|
+
}
|
|
86
|
+
export declare class If {
|
|
87
|
+
t: Lisp;
|
|
88
|
+
f: Lisp;
|
|
89
|
+
constructor(t: Lisp, f: Lisp);
|
|
90
|
+
}
|
|
91
|
+
type OpCallback = (exec: Execution, done: Done, ticks: Ticks, a: any, b: any, obj: any, context: IExecContext, scope: Scope, bobj?: any, inLoopOrSwitch?: string) => void;
|
|
92
|
+
export declare const ops: Map<LispType, OpCallback>;
|
|
93
|
+
export declare function addOps<Type extends LispFamily>(type: ExtractLispOp<Type>, cb: OpCallback): void;
|
|
94
|
+
export declare function execMany(ticks: Ticks, exec: Execution, tree: Lisp[], done: Done, scope: Scope, context: IExecContext, inLoopOrSwitch?: string): void;
|
|
95
|
+
type Execution = <T = any>(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done<T>, inLoopOrSwitch?: string) => void;
|
|
138
96
|
export interface AsyncDoneRet {
|
|
139
97
|
isInstant: boolean;
|
|
140
98
|
instant: any;
|
|
@@ -146,8 +104,11 @@ export declare function asyncDone(callback: (done: Done) => void): AsyncDoneRet;
|
|
|
146
104
|
export declare function syncDone(callback: (done: Done) => void): {
|
|
147
105
|
result: any;
|
|
148
106
|
};
|
|
149
|
-
export declare function execAsync(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, doneOriginal: Done
|
|
150
|
-
export declare function execSync(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done
|
|
151
|
-
export declare
|
|
152
|
-
|
|
107
|
+
export declare function execAsync<T = any>(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, doneOriginal: Done<T>, inLoopOrSwitch?: string): Promise<void>;
|
|
108
|
+
export declare function execSync<T = any>(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done<T>, inLoopOrSwitch?: string): void;
|
|
109
|
+
export declare const currentTicks: {
|
|
110
|
+
current: Ticks;
|
|
111
|
+
};
|
|
112
|
+
export declare function executeTree<T>(ticks: Ticks, context: IExecContext, executionTree: Lisp[], scopes?: IScope[], inLoopOrSwitch?: string): ExecReturn<T>;
|
|
113
|
+
export declare function executeTreeAsync<T>(ticks: Ticks, context: IExecContext, executionTree: Lisp[], scopes?: IScope[], inLoopOrSwitch?: string): Promise<ExecReturn<T>>;
|
|
153
114
|
export {};
|