@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.
Files changed (51) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.js +22 -0
  3. package/.prettierrc +4 -0
  4. package/.vscode/settings.json +4 -0
  5. package/build/Sandbox.d.ts +11 -79
  6. package/build/Sandbox.js +21 -216
  7. package/build/SandboxExec.d.ts +25 -0
  8. package/build/SandboxExec.js +169 -0
  9. package/build/eval.d.ts +18 -0
  10. package/build/eval.js +43 -0
  11. package/build/executor.d.ts +29 -90
  12. package/build/executor.js +249 -328
  13. package/build/parser.d.ts +8 -239
  14. package/build/parser.js +342 -440
  15. package/build/unraw.js +13 -16
  16. package/build/utils.d.ts +242 -0
  17. package/build/utils.js +276 -0
  18. package/dist/Sandbox.d.ts +11 -79
  19. package/dist/Sandbox.js +106 -1
  20. package/dist/Sandbox.js.map +1 -1
  21. package/dist/Sandbox.min.js +2 -0
  22. package/dist/Sandbox.min.js.map +1 -0
  23. package/dist/SandboxExec.d.ts +25 -0
  24. package/dist/SandboxExec.js +173 -0
  25. package/dist/SandboxExec.js.map +1 -0
  26. package/dist/SandboxExec.min.js +2 -0
  27. package/dist/SandboxExec.min.js.map +1 -0
  28. package/dist/eval.d.ts +18 -0
  29. package/dist/executor.d.ts +29 -90
  30. package/dist/executor.js +1270 -0
  31. package/dist/executor.js.map +1 -0
  32. package/dist/node/Sandbox.d.ts +11 -79
  33. package/dist/node/Sandbox.js +36 -3150
  34. package/dist/node/SandboxExec.d.ts +25 -0
  35. package/dist/node/SandboxExec.js +176 -0
  36. package/dist/node/eval.d.ts +18 -0
  37. package/dist/node/executor.d.ts +29 -90
  38. package/dist/node/executor.js +1289 -0
  39. package/dist/node/parser.d.ts +8 -239
  40. package/dist/node/parser.js +1528 -0
  41. package/dist/node/utils.d.ts +242 -0
  42. package/dist/node/utils.js +290 -0
  43. package/dist/parser.d.ts +8 -239
  44. package/dist/parser.js +1514 -0
  45. package/dist/parser.js.map +1 -0
  46. package/dist/utils.d.ts +242 -0
  47. package/dist/utils.js +279 -0
  48. package/dist/utils.js.map +1 -0
  49. package/package.json +11 -3
  50. package/.github/workflows/npm-publish.yml +0 -34
  51. package/rollup.config.mjs +0 -33
@@ -1,94 +1,4 @@
1
- export declare const enum LispType {
2
- None = 0,
3
- Prop = 1,
4
- StringIndex = 2,
5
- Let = 3,
6
- Const = 4,
7
- Call = 5,
8
- KeyVal = 6,
9
- Number = 7,
10
- Return = 8,
11
- Assign = 9,
12
- InlineFunction = 10,
13
- ArrowFunction = 11,
14
- CreateArray = 12,
15
- If = 13,
16
- IfCase = 14,
17
- InlineIf = 15,
18
- InlineIfCase = 16,
19
- SpreadObject = 17,
20
- SpreadArray = 18,
21
- ArrayProp = 19,
22
- PropOptional = 20,
23
- CallOptional = 21,
24
- CreateObject = 22,
25
- Group = 23,
26
- Not = 24,
27
- IncrementBefore = 25,
28
- IncrementAfter = 26,
29
- DecrementBefore = 27,
30
- DecrementAfter = 28,
31
- And = 29,
32
- Or = 30,
33
- StrictNotEqual = 31,
34
- StrictEqual = 32,
35
- Plus = 33,
36
- Var = 34,
37
- GlobalSymbol = 35,
38
- Literal = 36,
39
- Function = 37,
40
- Loop = 38,
41
- Try = 39,
42
- Switch = 40,
43
- SwitchCase = 41,
44
- Block = 42,
45
- Expression = 43,
46
- Await = 44,
47
- New = 45,
48
- Throw = 46,
49
- Minus = 47,
50
- Divide = 48,
51
- Power = 49,
52
- Multiply = 50,
53
- Modulus = 51,
54
- Equal = 52,
55
- NotEqual = 53,
56
- SmallerEqualThan = 54,
57
- LargerEqualThan = 55,
58
- SmallerThan = 56,
59
- LargerThan = 57,
60
- Negative = 58,
61
- Positive = 59,
62
- Typeof = 60,
63
- Delete = 61,
64
- Instanceof = 62,
65
- In = 63,
66
- Inverse = 64,
67
- SubractEquals = 65,
68
- AddEquals = 66,
69
- DivideEquals = 67,
70
- PowerEquals = 68,
71
- MultiplyEquals = 69,
72
- ModulusEquals = 70,
73
- BitNegateEquals = 71,
74
- BitAndEquals = 72,
75
- BitOrEquals = 73,
76
- UnsignedShiftRightEquals = 74,
77
- ShiftRightEquals = 75,
78
- ShiftLeftEquals = 76,
79
- BitAnd = 77,
80
- BitOr = 78,
81
- BitNegate = 79,
82
- BitShiftLeft = 80,
83
- BitShiftRight = 81,
84
- BitUnsignedShiftRight = 82,
85
- BigInt = 83,
86
- LiteralIndex = 84,
87
- RegexIndex = 85,
88
- LoopAction = 86,
89
- Void = 87,
90
- True = 88
91
- }
1
+ import { CodeString, LispType } from './utils.js';
92
2
  export type DefineLisp<op extends LispType, a extends LispItem | LispItem, b extends LispItem | LispItem> = [op, a, b];
93
3
  export type ExtractLispOp<L> = L extends DefineLisp<infer i, any, any> ? i : never;
94
4
  export type ExtractLispA<L> = L extends DefineLisp<any, infer i, any> ? i : never;
@@ -103,7 +13,7 @@ export type If = DefineLisp<LispType.If, Lisp, IfCase>;
103
13
  export type InlineIf = DefineLisp<LispType.InlineIf, Lisp, InlineIfCase>;
104
14
  export type IfCase = DefineLisp<LispType.IfCase, Lisp[], Lisp[]>;
105
15
  export type InlineIfCase = DefineLisp<LispType.InlineIfCase, Lisp, Lisp>;
106
- export type KeyVal = DefineLisp<LispType.KeyVal, string | Lisp, Lisp[]>;
16
+ export type KeyVal = DefineLisp<LispType.KeyVal, string | Lisp, Lisp>;
107
17
  export type SpreadObject = DefineLisp<LispType.SpreadObject, LispType.None, Lisp>;
108
18
  export type SpreadArray = DefineLisp<LispType.SpreadArray, LispType.None, Lisp>;
109
19
  export type ArrayProp = DefineLisp<LispType.ArrayProp, Lisp, Lisp>;
@@ -209,151 +119,11 @@ export declare class ParseError extends Error {
209
119
  code: string;
210
120
  constructor(message: string, code: string);
211
121
  }
212
- export declare let expectTypes: {
213
- readonly splitter: {
214
- readonly types: {
215
- readonly opHigh: RegExp;
216
- readonly op: RegExp;
217
- readonly comparitor: RegExp;
218
- readonly boolOp: RegExp;
219
- readonly bitwise: RegExp;
220
- };
221
- readonly next: readonly ["modifier", "value", "prop", "incrementerBefore"];
222
- };
223
- readonly inlineIf: {
224
- readonly types: {
225
- readonly inlineIf: RegExp;
226
- };
227
- readonly next: readonly ["expEnd"];
228
- };
229
- readonly assignment: {
230
- readonly types: {
231
- readonly assignModify: RegExp;
232
- readonly assign: RegExp;
233
- };
234
- readonly next: readonly ["modifier", "value", "prop", "incrementerBefore"];
235
- };
236
- readonly incrementerBefore: {
237
- readonly types: {
238
- readonly incrementerBefore: RegExp;
239
- };
240
- readonly next: readonly ["prop"];
241
- };
242
- readonly expEdge: {
243
- readonly types: {
244
- readonly call: RegExp;
245
- readonly incrementerAfter: RegExp;
246
- };
247
- readonly next: readonly ["splitter", "expEdge", "dot", "inlineIf", "expEnd"];
248
- };
249
- readonly modifier: {
250
- readonly types: {
251
- readonly not: RegExp;
252
- readonly inverse: RegExp;
253
- readonly negative: RegExp;
254
- readonly positive: RegExp;
255
- readonly typeof: RegExp;
256
- readonly delete: RegExp;
257
- };
258
- readonly next: readonly ["modifier", "value", "prop", "incrementerBefore"];
259
- };
260
- readonly dot: {
261
- readonly types: {
262
- readonly arrayProp: RegExp;
263
- readonly dot: RegExp;
264
- };
265
- readonly next: readonly ["splitter", "assignment", "expEdge", "dot", "inlineIf", "expEnd"];
266
- };
267
- readonly prop: {
268
- readonly types: {
269
- readonly prop: RegExp;
270
- };
271
- readonly next: readonly ["splitter", "assignment", "expEdge", "dot", "inlineIf", "expEnd"];
272
- };
273
- readonly value: {
274
- readonly types: {
275
- readonly createObject: RegExp;
276
- readonly createArray: RegExp;
277
- readonly number: RegExp;
278
- readonly string: RegExp;
279
- readonly literal: RegExp;
280
- readonly regex: RegExp;
281
- readonly boolean: RegExp;
282
- readonly null: RegExp;
283
- readonly und: RegExp;
284
- readonly arrowFunctionSingle: RegExp;
285
- readonly arrowFunction: RegExp;
286
- readonly inlineFunction: RegExp;
287
- readonly group: RegExp;
288
- readonly NaN: RegExp;
289
- readonly Infinity: RegExp;
290
- readonly void: RegExp;
291
- readonly await: RegExp;
292
- readonly new: RegExp;
293
- };
294
- readonly next: readonly ["splitter", "expEdge", "dot", "inlineIf", "expEnd"];
295
- };
296
- readonly initialize: {
297
- readonly types: {
298
- readonly initialize: RegExp;
299
- readonly return: RegExp;
300
- readonly throw: RegExp;
301
- };
302
- readonly next: readonly ["modifier", "value", "prop", "incrementerBefore", "expEnd"];
303
- };
304
- readonly spreadObject: {
305
- readonly types: {
306
- readonly spreadObject: RegExp;
307
- };
308
- readonly next: readonly ["value", "prop"];
309
- };
310
- readonly spreadArray: {
311
- readonly types: {
312
- readonly spreadArray: RegExp;
313
- };
314
- readonly next: readonly ["value", "prop"];
315
- };
316
- readonly expEnd: {
317
- readonly types: {};
318
- readonly next: readonly [];
319
- };
320
- readonly expFunction: {
321
- readonly types: {
322
- readonly function: RegExp;
323
- };
324
- readonly next: readonly ["expEdge", "expEnd"];
325
- };
326
- readonly expSingle: {
327
- readonly types: {
328
- readonly for: RegExp;
329
- readonly do: RegExp;
330
- readonly while: RegExp;
331
- readonly loopAction: RegExp;
332
- readonly if: RegExp;
333
- readonly try: RegExp;
334
- readonly block: RegExp;
335
- readonly switch: RegExp;
336
- };
337
- readonly next: readonly ["expEnd"];
338
- };
339
- };
340
- export declare function testMultiple(str: string, tests: RegExp[]): RegExpExecArray;
341
- export declare class CodeString {
342
- start: number;
343
- end: number;
344
- ref: {
345
- str: string;
346
- };
347
- constructor(str: string | CodeString);
348
- substring(start: number, end?: number): CodeString;
349
- get length(): number;
350
- char(i: number): string;
351
- toString(): string;
352
- trimStart(): CodeString;
353
- slice(start: number, end?: number): CodeString;
354
- trim(): CodeString;
355
- valueOf(): string;
356
- }
122
+ export declare const expectTypes: Record<string, {
123
+ types: Record<string, RegExp>;
124
+ next: string[];
125
+ }>;
126
+ export declare function testMultiple(str: string, tests: RegExp[]): RegExpExecArray | null;
357
127
  export interface restDetails {
358
128
  oneliner?: boolean;
359
129
  words?: string[];
@@ -369,12 +139,11 @@ export declare const setLispType: <T extends readonly string[]>(types: T, fn: Li
369
139
  export declare function lispifyReturnExpr(constants: IConstants, str: CodeString): Return;
370
140
  export declare function lispifyBlock(str: CodeString, constants: IConstants, expression?: boolean): Lisp[];
371
141
  export declare function lispifyFunction(str: CodeString, constants: IConstants, expression?: boolean): Lisp[];
372
- export declare function isLisp<Type extends Lisp = Lisp>(item: LispItem | LispItem): item is Type;
373
142
  export declare function insertSemicolons(constants: IConstants, str: CodeString): CodeString;
374
143
  export declare function checkRegex(str: string): IRegEx | null;
375
144
  export declare function extractConstants(constants: IConstants, str: string, currentEnclosure?: string): {
376
145
  str: string;
377
146
  length: number;
378
147
  };
379
- export declare function parse(code: string, eager?: boolean, expression?: boolean): IExecutionTree;
148
+ export default function parse(code: string, eager?: boolean, expression?: boolean): IExecutionTree;
380
149
  export {};