@nyariv/sandboxjs 0.8.23 → 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 -79
- 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 +29 -90
- package/build/executor.js +249 -328
- package/build/parser.d.ts +8 -239
- package/build/parser.js +342 -440
- 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 -79
- package/dist/Sandbox.js +106 -1
- package/dist/Sandbox.js.map +1 -1
- package/dist/Sandbox.min.js +2 -0
- package/dist/Sandbox.min.js.map +1 -0
- 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 +29 -90
- package/dist/executor.js +1270 -0
- package/dist/executor.js.map +1 -0
- package/dist/node/Sandbox.d.ts +11 -79
- package/dist/node/Sandbox.js +36 -3150
- 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 +29 -90
- package/dist/node/executor.js +1289 -0
- package/dist/node/parser.d.ts +8 -239
- 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 +8 -239
- 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 +11 -3
- package/.github/workflows/npm-publish.yml +0 -34
- package/rollup.config.mjs +0 -33
package/dist/executor.d.ts
CHANGED
|
@@ -1,134 +1,70 @@
|
|
|
1
|
-
import { LispItem, Lisp,
|
|
2
|
-
import { IExecContext, Ticks } from
|
|
3
|
-
export type
|
|
4
|
-
export type sandboxedEval = (code: string) => unknown;
|
|
5
|
-
export type sandboxSetTimeout = (handler: TimerHandler, timeout?: number, ...args: unknown[]) => any;
|
|
6
|
-
export type sandboxSetInterval = (handler: TimerHandler, timeout?: number, ...args: unknown[]) => any;
|
|
7
|
-
export type Done = (err?: unknown, res?: unknown) => 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<unknown>;
|
|
18
|
-
prototypeAccess: {
|
|
19
|
-
[name: string]: Set<string>;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface IGlobals {
|
|
23
|
-
[key: string]: unknown;
|
|
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
63
|
export type Change = ICreate | IReplace | IDelete | IReverse | ISort | IPush | IPop | IUnShift | IShift | ISplice | ICopyWithin;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
prop: string;
|
|
81
|
-
isConst: boolean;
|
|
82
|
-
isGlobal: boolean;
|
|
83
|
-
isVariable: boolean;
|
|
84
|
-
constructor(context: {
|
|
85
|
-
[key: string]: any;
|
|
86
|
-
}, prop: string, isConst?: boolean, isGlobal?: boolean, isVariable?: boolean);
|
|
87
|
-
get<T = unknown>(context: IExecContext): T;
|
|
88
|
-
}
|
|
89
|
-
declare enum VarType {
|
|
90
|
-
let = "let",
|
|
91
|
-
const = "const",
|
|
92
|
-
var = "var"
|
|
93
|
-
}
|
|
94
|
-
export declare class Scope {
|
|
95
|
-
parent: Scope;
|
|
96
|
-
const: {
|
|
97
|
-
[key: string]: true;
|
|
98
|
-
};
|
|
99
|
-
let: {
|
|
100
|
-
[key: string]: true;
|
|
101
|
-
};
|
|
102
|
-
var: {
|
|
103
|
-
[key: string]: true;
|
|
104
|
-
};
|
|
105
|
-
globals: {
|
|
106
|
-
[key: string]: true;
|
|
107
|
-
};
|
|
108
|
-
allVars: {
|
|
109
|
-
[key: string]: unknown;
|
|
110
|
-
} & Object;
|
|
111
|
-
functionThis?: unknown;
|
|
112
|
-
constructor(parent: Scope, vars?: {}, functionThis?: unknown);
|
|
113
|
-
get(key: string, functionScope?: boolean): Prop;
|
|
114
|
-
set(key: string, val: unknown): Prop;
|
|
115
|
-
declare(key: string, type?: VarType, value?: unknown, isGlobal?: boolean): Prop;
|
|
116
|
-
}
|
|
117
|
-
export interface IScope {
|
|
118
|
-
[key: string]: any;
|
|
119
|
-
}
|
|
120
|
-
export declare class FunctionScope implements IScope {
|
|
121
|
-
}
|
|
122
|
-
export declare class LocalScope implements IScope {
|
|
123
|
-
}
|
|
124
|
-
export declare class SandboxError extends Error {
|
|
125
|
-
}
|
|
126
|
-
export declare function sandboxFunction(context: IExecContext, ticks?: Ticks): SandboxFunction;
|
|
127
|
-
export declare function createFunction(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string): any;
|
|
128
|
-
export declare function createFunctionAsync(argNames: string[], parsed: Lisp[], ticks: Ticks, context: IExecContext, scope?: Scope, name?: string): any;
|
|
129
|
-
export declare function sandboxedEval(func: SandboxFunction): sandboxedEval;
|
|
130
|
-
export declare function sandboxedSetTimeout(func: SandboxFunction): sandboxSetTimeout;
|
|
131
|
-
export declare function sandboxedSetInterval(func: SandboxFunction): sandboxSetInterval;
|
|
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>;
|
|
132
68
|
export declare function assignCheck(obj: Prop, context: IExecContext, op?: string): void;
|
|
133
69
|
export declare class KeyVal {
|
|
134
70
|
key: string | SpreadObject;
|
|
@@ -156,7 +92,7 @@ type OpCallback = (exec: Execution, done: Done, ticks: Ticks, a: any, b: any, ob
|
|
|
156
92
|
export declare const ops: Map<LispType, OpCallback>;
|
|
157
93
|
export declare function addOps<Type extends LispFamily>(type: ExtractLispOp<Type>, cb: OpCallback): void;
|
|
158
94
|
export declare function execMany(ticks: Ticks, exec: Execution, tree: Lisp[], done: Done, scope: Scope, context: IExecContext, inLoopOrSwitch?: string): void;
|
|
159
|
-
type Execution = (ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done
|
|
95
|
+
type Execution = <T = any>(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done<T>, inLoopOrSwitch?: string) => void;
|
|
160
96
|
export interface AsyncDoneRet {
|
|
161
97
|
isInstant: boolean;
|
|
162
98
|
instant: any;
|
|
@@ -168,8 +104,11 @@ export declare function asyncDone(callback: (done: Done) => void): AsyncDoneRet;
|
|
|
168
104
|
export declare function syncDone(callback: (done: Done) => void): {
|
|
169
105
|
result: any;
|
|
170
106
|
};
|
|
171
|
-
export declare function execAsync(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, doneOriginal: Done
|
|
172
|
-
export declare function execSync(ticks: Ticks, tree: LispItem, scope: Scope, context: IExecContext, done: Done
|
|
173
|
-
export declare
|
|
174
|
-
|
|
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>>;
|
|
175
114
|
export {};
|