@probelabs/probe 0.6.0-rc233 → 0.6.0-rc235

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/cjs/index.cjs CHANGED
@@ -35678,7 +35678,7 @@ Manage tasks for tracking progress during code exploration and problem-solving.
35678
35678
 
35679
35679
  Parameters:
35680
35680
  - action: (required) The action to perform: create, update, complete, delete, list
35681
- - tasks: (optional) JSON array for batch operations - alternative to single-task params
35681
+ - tasks: (optional) Array of task objects for batch operations. Place raw JSON array directly between tags.
35682
35682
  - id: (optional) Task ID for single operations (e.g., "task-1")
35683
35683
  - title: (optional) Task title for create/update
35684
35684
  - description: (optional) Task description for create/update
@@ -35687,6 +35687,11 @@ Parameters:
35687
35687
  - dependencies: (optional) JSON array of task IDs that must be completed first
35688
35688
  - after: (optional) Task ID to insert the new task after (for ordering). By default, new tasks are appended to the end
35689
35689
 
35690
+ IMPORTANT - JSON Format:
35691
+ Place raw JSON arrays directly between tags without quotes or escaping:
35692
+ CORRECT: <tasks>[{"title": "Do X"}]</tasks>
35693
+ INCORRECT: <tasks>"[{"title": "Do X"}]"</tasks>
35694
+
35690
35695
  Usage Examples:
35691
35696
 
35692
35697
  Creating a single task:
@@ -81050,9 +81055,11 @@ __export(schemaUtils_exports, {
81050
81055
  isJsonSchema: () => isJsonSchema,
81051
81056
  isJsonSchemaDefinition: () => isJsonSchemaDefinition,
81052
81057
  isMermaidSchema: () => isMermaidSchema,
81058
+ isSimpleTextWrapperSchema: () => isSimpleTextWrapperSchema,
81053
81059
  processSchemaResponse: () => processSchemaResponse,
81054
81060
  replaceMermaidDiagramsInJson: () => replaceMermaidDiagramsInJson,
81055
81061
  replaceMermaidDiagramsInMarkdown: () => replaceMermaidDiagramsInMarkdown,
81062
+ tryAutoWrapForSimpleSchema: () => tryAutoWrapForSimpleSchema,
81056
81063
  tryMaidAutoFix: () => tryMaidAutoFix,
81057
81064
  validateAndFixMermaidResponse: () => validateAndFixMermaidResponse,
81058
81065
  validateJsonResponse: () => validateJsonResponse,
@@ -81570,6 +81577,46 @@ function isJsonSchemaDefinition(jsonString, options = {}) {
81570
81577
  return false;
81571
81578
  }
81572
81579
  }
81580
+ function isSimpleTextWrapperSchema(schema) {
81581
+ if (!schema || typeof schema !== "string") {
81582
+ return null;
81583
+ }
81584
+ const trimmed = schema.trim();
81585
+ const simplePatterns = [
81586
+ /^\{\s*["']?(\w+)["']?\s*:\s*["']?string["']?\s*\}$/i,
81587
+ /^\{\s*["']?type["']?\s*:\s*["']?object["']?\s*,\s*["']?properties["']?\s*:\s*\{\s*["']?(\w+)["']?\s*:\s*\{\s*["']?type["']?\s*:\s*["']?string["']?\s*\}\s*\}\s*\}$/i
81588
+ ];
81589
+ for (const pattern of simplePatterns) {
81590
+ const match2 = trimmed.match(pattern);
81591
+ if (match2) {
81592
+ return { fieldName: match2[1] };
81593
+ }
81594
+ }
81595
+ return null;
81596
+ }
81597
+ function tryAutoWrapForSimpleSchema(response, schema, options = {}) {
81598
+ const { debug = false } = options;
81599
+ const wrapperInfo = isSimpleTextWrapperSchema(schema);
81600
+ if (!wrapperInfo) {
81601
+ if (debug) {
81602
+ console.log(`[DEBUG] Auto-wrap: Schema is not a simple text wrapper`);
81603
+ }
81604
+ return null;
81605
+ }
81606
+ try {
81607
+ JSON.parse(response);
81608
+ if (debug) {
81609
+ console.log(`[DEBUG] Auto-wrap: Response is already valid JSON, skipping`);
81610
+ }
81611
+ return null;
81612
+ } catch {
81613
+ }
81614
+ const wrapped = JSON.stringify({ [wrapperInfo.fieldName]: response });
81615
+ if (debug) {
81616
+ console.log(`[DEBUG] Auto-wrap: Wrapped plain text in {"${wrapperInfo.fieldName}": ...} (${response.length} chars)`);
81617
+ }
81618
+ return wrapped;
81619
+ }
81573
81620
  function createJsonCorrectionPrompt(invalidResponse, schema, errorOrValidation, retryCount = 0) {
81574
81621
  let errorMessage;
81575
81622
  let enhancedError;
@@ -81601,7 +81648,7 @@ function createJsonCorrectionPrompt(invalidResponse, schema, errorOrValidation,
81601
81648
  const currentLevel = strengthLevels[level];
81602
81649
  let prompt = `${currentLevel.prefix} Your previous response is not valid JSON and cannot be parsed. Here's what you returned:
81603
81650
 
81604
- ${invalidResponse.substring(0, 500)}${invalidResponse.length > 500 ? "..." : ""}
81651
+ ${invalidResponse}
81605
81652
 
81606
81653
  Error: ${enhancedError}
81607
81654
 
@@ -96638,6 +96685,14 @@ ${errorXml}
96638
96685
  });
96639
96686
  const executeToolCall = async () => {
96640
96687
  if (toolName === "delegate") {
96688
+ let allowedToolsForDelegate = null;
96689
+ if (this.allowedTools.mode === "whitelist") {
96690
+ allowedToolsForDelegate = [...this.allowedTools.allowed];
96691
+ } else if (this.allowedTools.mode === "none") {
96692
+ allowedToolsForDelegate = [];
96693
+ } else if (this.allowedTools.mode === "all" && this.allowedTools.exclusions?.length > 0) {
96694
+ allowedToolsForDelegate = ["*", ...this.allowedTools.exclusions.map((t4) => "!" + t4)];
96695
+ }
96641
96696
  const enhancedParams = {
96642
96697
  ...toolParams,
96643
96698
  currentIteration,
@@ -96653,6 +96708,18 @@ ${errorXml}
96653
96708
  searchDelegate: this.searchDelegate,
96654
96709
  enableTasks: this.enableTasks,
96655
96710
  // Inherit task management (subagent gets isolated TaskManager)
96711
+ enableMcp: !!this.mcpBridge,
96712
+ // Inherit MCP enablement
96713
+ mcpConfig: this.mcpConfig,
96714
+ // Inherit MCP configuration
96715
+ mcpConfigPath: this.mcpConfigPath,
96716
+ // Inherit MCP config path
96717
+ enableBash: this.enableBash,
96718
+ // Inherit bash enablement
96719
+ bashConfig: this.bashConfig,
96720
+ // Inherit bash configuration
96721
+ allowedTools: allowedToolsForDelegate,
96722
+ // Inherit allowed tools from parent
96656
96723
  debug: this.debug,
96657
96724
  tracer: this.tracer
96658
96725
  };
@@ -97271,6 +97338,16 @@ Convert your previous response content into actual JSON data that follows this s
97271
97338
  validation = validateJsonResponse(finalResult);
97272
97339
  retryCount = 1;
97273
97340
  }
97341
+ if (!validation.isValid) {
97342
+ const autoWrapped = tryAutoWrapForSimpleSchema(finalResult, options.schema, { debug: this.debug });
97343
+ if (autoWrapped) {
97344
+ if (this.debug) {
97345
+ console.log(`[DEBUG] JSON validation: Auto-wrapped plain text for simple schema`);
97346
+ }
97347
+ finalResult = autoWrapped;
97348
+ validation = validateJsonResponse(finalResult, { debug: this.debug });
97349
+ }
97350
+ }
97274
97351
  while (!validation.isValid && retryCount < maxRetries) {
97275
97352
  if (this.debug) {
97276
97353
  console.log(`[DEBUG] JSON validation: attempt_completion validation failed (attempt ${retryCount + 1}/${maxRetries}):`, validation.error);
@@ -100807,6 +100884,8 @@ var require_utils2 = __commonJS({
100807
100884
  var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {
100808
100885
  }).constructor;
100809
100886
  var SandboxGlobal = function SandboxGlobal2(globals) {
100887
+ if (globals === globalThis)
100888
+ return globalThis;
100810
100889
  for (const i4 in globals) {
100811
100890
  this[i4] = globals[i4];
100812
100891
  }
@@ -100835,9 +100914,7 @@ var require_utils2 = __commonJS({
100835
100914
  prototypeWhitelist: new Map([...options.prototypeWhitelist].map((a4) => [a4[0].prototype, a4[1]])),
100836
100915
  options,
100837
100916
  globalScope: new Scope3(null, options.globals, sandboxGlobal),
100838
- sandboxGlobal,
100839
- ticks: { ticks: 0n, tickLimit: options.executionQuota },
100840
- sandboxedFunctions: /* @__PURE__ */ new WeakSet()
100917
+ sandboxGlobal
100841
100918
  };
100842
100919
  context.prototypeWhitelist.set(Object.getPrototypeOf([][Symbol.iterator]()), /* @__PURE__ */ new Set());
100843
100920
  return context;
@@ -100852,15 +100929,9 @@ var require_utils2 = __commonJS({
100852
100929
  evals.set(AsyncFunction, asyncFunc);
100853
100930
  evals.set(GeneratorFunction, func);
100854
100931
  evals.set(AsyncGeneratorFunction, asyncFunc);
100855
- evals.set(eval, evalContext.sandboxedEval(func, execContext));
100856
- evals.set(setTimeout, evalContext.sandboxedSetTimeout(func, execContext));
100857
- evals.set(setInterval, evalContext.sandboxedSetInterval(func, execContext));
100858
- evals.set(clearTimeout, evalContext.sandboxedClearTimeout(execContext));
100859
- evals.set(clearInterval, evalContext.sandboxedClearInterval(execContext));
100860
- for (const [key, value] of evals) {
100861
- sandbox.context.prototypeWhitelist.set(value.prototype, /* @__PURE__ */ new Set());
100862
- sandbox.context.prototypeWhitelist.set(key.prototype, /* @__PURE__ */ new Set());
100863
- }
100932
+ evals.set(eval, evalContext.sandboxedEval(func));
100933
+ evals.set(setTimeout, evalContext.sandboxedSetTimeout(func));
100934
+ evals.set(setInterval, evalContext.sandboxedSetInterval(func));
100864
100935
  }
100865
100936
  return execContext;
100866
100937
  }
@@ -100957,45 +101028,34 @@ var require_utils2 = __commonJS({
100957
101028
  return ret;
100958
101029
  }
100959
101030
  var reservedWords2 = /* @__PURE__ */ new Set([
100960
- "await",
100961
- "break",
100962
- "case",
100963
- "catch",
100964
- "class",
100965
- "const",
100966
- "continue",
100967
- "debugger",
100968
- "default",
100969
- "delete",
100970
- "do",
100971
- "else",
100972
- "enum",
100973
- "export",
100974
- "extends",
100975
- "false",
100976
- "finally",
100977
- "for",
100978
- "function",
100979
- "if",
100980
- "implements",
100981
- "import",
100982
- "in",
100983
101031
  "instanceof",
100984
- "let",
100985
- "new",
100986
- "null",
101032
+ "typeof",
100987
101033
  "return",
100988
- "super",
100989
- "switch",
100990
- "this",
100991
101034
  "throw",
100992
- "true",
100993
101035
  "try",
100994
- "typeof",
101036
+ "catch",
101037
+ "if",
101038
+ "finally",
101039
+ "else",
101040
+ "in",
101041
+ "of",
100995
101042
  "var",
100996
- "void",
101043
+ "let",
101044
+ "const",
101045
+ "for",
101046
+ "delete",
101047
+ "false",
101048
+ "true",
100997
101049
  "while",
100998
- "with"
101050
+ "do",
101051
+ "break",
101052
+ "continue",
101053
+ "new",
101054
+ "function",
101055
+ "async",
101056
+ "await",
101057
+ "switch",
101058
+ "case"
100999
101059
  ]);
101000
101060
  var Scope3 = class {
101001
101061
  constructor(parent, vars = {}, functionThis) {
@@ -101010,16 +101070,25 @@ var require_utils2 = __commonJS({
101010
101070
  this.globals = parent === null ? keysOnly(vars) : {};
101011
101071
  this.functionThis = functionThis;
101012
101072
  }
101013
- get(key) {
101014
- const isThis = key === "this";
101015
- const scope = this.getWhereValScope(key, isThis);
101016
- if (scope && isThis) {
101017
- return new Prop({ this: scope.functionThis }, key, false, false, true);
101073
+ get(key, functionScope = false) {
101074
+ const functionThis = this.functionThis;
101075
+ if (key === "this" && functionThis !== void 0) {
101076
+ return new Prop({ this: functionThis }, key, true, false, true);
101018
101077
  }
101019
- if (!scope) {
101020
- return new Prop(void 0, key);
101078
+ if (reservedWords2.has(key))
101079
+ throw new SyntaxError("Unexepected token '" + key + "'");
101080
+ if (this.parent === null || !functionScope || functionThis !== void 0) {
101081
+ if (this.globals.hasOwnProperty(key)) {
101082
+ return new Prop(functionThis, key, false, true, true);
101083
+ }
101084
+ if (key in this.allVars && (!(key in {}) || this.allVars.hasOwnProperty(key))) {
101085
+ return new Prop(this.allVars, key, this.const.hasOwnProperty(key), this.globals.hasOwnProperty(key), true);
101086
+ }
101087
+ if (this.parent === null) {
101088
+ return new Prop(void 0, key);
101089
+ }
101021
101090
  }
101022
- return new Prop(scope.allVars, key, key in scope.const, key in scope.globals, true);
101091
+ return this.parent.get(key, functionScope);
101023
101092
  }
101024
101093
  set(key, val) {
101025
101094
  if (key === "this")
@@ -101030,72 +101099,34 @@ var require_utils2 = __commonJS({
101030
101099
  if (prop.context === void 0) {
101031
101100
  throw new ReferenceError(`Variable '${key}' was not declared.`);
101032
101101
  }
101033
- if (prop.context === null) {
101034
- throw new TypeError(`Cannot set properties of null, (setting '${key}')`);
101035
- }
101036
101102
  if (prop.isConst) {
101037
101103
  throw new TypeError(`Cannot assign to const variable '${key}'`);
101038
101104
  }
101039
101105
  if (prop.isGlobal) {
101040
101106
  throw new SandboxError(`Cannot override global variable '${key}'`);
101041
101107
  }
101108
+ if (!(prop.context instanceof Object))
101109
+ throw new SandboxError("Scope is not an object");
101042
101110
  prop.context[prop.prop] = val;
101043
101111
  return prop;
101044
101112
  }
101045
- getWhereValScope(key, isThis) {
101046
- if (isThis) {
101047
- if (this.functionThis !== void 0) {
101048
- return this;
101049
- } else {
101050
- return this.parent?.getWhereValScope(key, isThis) || null;
101051
- }
101052
- }
101053
- if (key in this.allVars && !(key in {} && !hasOwnProperty19(this.allVars, key))) {
101054
- return this;
101055
- }
101056
- return this.parent?.getWhereValScope(key, isThis) || null;
101057
- }
101058
- getWhereVarScope(key, localScope = false) {
101059
- if (key in this.allVars && !(key in {} && !hasOwnProperty19(this.allVars, key))) {
101060
- return this;
101061
- }
101062
- if (this.parent === null || localScope || this.functionThis !== void 0) {
101063
- return this;
101064
- }
101065
- return this.parent.getWhereVarScope(key, localScope);
101066
- }
101067
101113
  declare(key, type, value = void 0, isGlobal = false) {
101068
101114
  if (key === "this")
101069
101115
  throw new SyntaxError('"this" cannot be declared');
101070
101116
  if (reservedWords2.has(key))
101071
101117
  throw new SyntaxError("Unexepected token '" + key + "'");
101072
- const existingScope = this.getWhereVarScope(
101073
- key,
101074
- type !== "var"
101075
- /* VarType.var */
101076
- );
101077
- if (type === "var") {
101078
- if (existingScope.var[key]) {
101079
- existingScope.allVars[key] = value;
101080
- if (!isGlobal) {
101081
- delete existingScope.globals[key];
101082
- } else {
101083
- existingScope.globals[key] = true;
101084
- }
101085
- return new Prop(existingScope.allVars, key, false, existingScope.globals[key], true);
101086
- } else if (key in existingScope.allVars) {
101087
- throw new SyntaxError(`Identifier '${key}' has already been declared`);
101088
- }
101089
- }
101090
- if (key in existingScope.allVars) {
101091
- throw new SyntaxError(`Identifier '${key}' has already been declared`);
101092
- }
101093
- if (isGlobal) {
101094
- existingScope.globals[key] = true;
101118
+ if (type === "var" && this.functionThis === void 0 && this.parent !== null) {
101119
+ return this.parent.declare(key, type, value, isGlobal);
101120
+ } else if (this[type].hasOwnProperty(key) && type !== "const" && !this.globals.hasOwnProperty(key) || !(key in this.allVars)) {
101121
+ if (isGlobal) {
101122
+ this.globals[key] = true;
101123
+ }
101124
+ this[type][key] = true;
101125
+ this.allVars[key] = value;
101126
+ } else {
101127
+ throw new SandboxError(`Identifier '${key}' has already been declared`);
101095
101128
  }
101096
- existingScope[type][key] = true;
101097
- existingScope.allVars[key] = value;
101098
- return new Prop(this.allVars, key, type === "const", isGlobal, true);
101129
+ return new Prop(this.allVars, key, this.const.hasOwnProperty(key), isGlobal);
101099
101130
  }
101100
101131
  };
101101
101132
  var FunctionScope = class {
@@ -101104,16 +101135,8 @@ var require_utils2 = __commonJS({
101104
101135
  };
101105
101136
  var SandboxError = class extends Error {
101106
101137
  };
101107
- var SandboxExecutionQuotaExceededError = class extends SandboxError {
101108
- };
101109
- var SandboxExecutionTreeError = class extends SandboxError {
101110
- };
101111
- var SandboxCapabilityError = class extends SandboxError {
101112
- };
101113
- var SandboxAccessError = class extends SandboxError {
101114
- };
101115
101138
  function isLisp(item) {
101116
- return Array.isArray(item) && typeof item[0] === "number" && item[0] !== 0 && item[0] !== 88;
101139
+ return Array.isArray(item) && typeof item[0] === "number" && item[0] !== 0 && item[0] !== 89;
101117
101140
  }
101118
101141
  var Prop = class {
101119
101142
  constructor(context, prop, isConst = false, isGlobal = false, isVariable = false) {
@@ -101126,16 +101149,13 @@ var require_utils2 = __commonJS({
101126
101149
  get(context) {
101127
101150
  const ctx = this.context;
101128
101151
  if (ctx === void 0)
101129
- throw new ReferenceError(`${this.prop.toString()} is not defined`);
101152
+ throw new ReferenceError(`${this.prop} is not defined`);
101130
101153
  if (ctx === null)
101131
- throw new TypeError(`Cannot read properties of null, (reading '${this.prop.toString()}')`);
101132
- context.getSubscriptions.forEach((cb) => cb(ctx, this.prop.toString()));
101154
+ throw new TypeError(`Cannot read properties of null, (reading '${this.prop}')`);
101155
+ context.getSubscriptions.forEach((cb) => cb(ctx, this.prop));
101133
101156
  return ctx[this.prop];
101134
101157
  }
101135
101158
  };
101136
- function hasOwnProperty19(obj, prop) {
101137
- return Object.prototype.hasOwnProperty.call(obj, prop);
101138
- }
101139
101159
  exports2.AsyncFunction = AsyncFunction;
101140
101160
  exports2.AsyncGeneratorFunction = AsyncGeneratorFunction;
101141
101161
  exports2.CodeString = CodeString;
@@ -101144,18 +101164,12 @@ var require_utils2 = __commonJS({
101144
101164
  exports2.GeneratorFunction = GeneratorFunction;
101145
101165
  exports2.LocalScope = LocalScope;
101146
101166
  exports2.Prop = Prop;
101147
- exports2.SandboxAccessError = SandboxAccessError;
101148
- exports2.SandboxCapabilityError = SandboxCapabilityError;
101149
101167
  exports2.SandboxError = SandboxError;
101150
- exports2.SandboxExecutionQuotaExceededError = SandboxExecutionQuotaExceededError;
101151
- exports2.SandboxExecutionTreeError = SandboxExecutionTreeError;
101152
101168
  exports2.SandboxGlobal = SandboxGlobal;
101153
101169
  exports2.Scope = Scope3;
101154
101170
  exports2.createContext = createContext;
101155
101171
  exports2.createExecContext = createExecContext;
101156
- exports2.hasOwnProperty = hasOwnProperty19;
101157
101172
  exports2.isLisp = isLisp;
101158
- exports2.reservedWords = reservedWords2;
101159
101173
  }
101160
101174
  });
101161
101175
 
@@ -101185,9 +101199,10 @@ var require_executor = __commonJS({
101185
101199
  });
101186
101200
  return vars;
101187
101201
  }
101202
+ var sandboxedFunctions = /* @__PURE__ */ new WeakSet();
101188
101203
  function createFunction(argNames, parsed, ticks, context, scope, name14) {
101189
101204
  if (context.ctx.options.forbidFunctionCreation) {
101190
- throw new utils.SandboxCapabilityError("Function creation is forbidden");
101205
+ throw new utils.SandboxError("Function creation is forbidden");
101191
101206
  }
101192
101207
  let func;
101193
101208
  if (name14 === void 0) {
@@ -101204,15 +101219,15 @@ var require_executor = __commonJS({
101204
101219
  };
101205
101220
  }
101206
101221
  context.registerSandboxFunction(func);
101207
- context.ctx.sandboxedFunctions.add(func);
101222
+ sandboxedFunctions.add(func);
101208
101223
  return func;
101209
101224
  }
101210
101225
  function createFunctionAsync(argNames, parsed, ticks, context, scope, name14) {
101211
101226
  if (context.ctx.options.forbidFunctionCreation) {
101212
- throw new utils.SandboxCapabilityError("Function creation is forbidden");
101227
+ throw new utils.SandboxError("Function creation is forbidden");
101213
101228
  }
101214
101229
  if (!context.ctx.prototypeWhitelist?.has(Promise.prototype)) {
101215
- throw new utils.SandboxCapabilityError("Async/await not permitted");
101230
+ throw new utils.SandboxError("Async/await not permitted");
101216
101231
  }
101217
101232
  let func;
101218
101233
  if (name14 === void 0) {
@@ -101229,40 +101244,43 @@ var require_executor = __commonJS({
101229
101244
  };
101230
101245
  }
101231
101246
  context.registerSandboxFunction(func);
101232
- context.ctx.sandboxedFunctions.add(func);
101247
+ sandboxedFunctions.add(func);
101233
101248
  return func;
101234
101249
  }
101235
101250
  function assignCheck(obj, context, op2 = "assign") {
101236
101251
  if (obj.context === void 0) {
101237
101252
  throw new ReferenceError(`Cannot ${op2} value to undefined.`);
101238
101253
  }
101254
+ if (typeof obj.context !== "object" && typeof obj.context !== "function") {
101255
+ throw new SyntaxError(`Cannot ${op2} value to a primitive.`);
101256
+ }
101239
101257
  if (obj.isConst) {
101240
- throw new TypeError(`Assignment to constant variable.`);
101258
+ throw new TypeError(`Cannot set value to const variable '${obj.prop}'`);
101241
101259
  }
101242
101260
  if (obj.isGlobal) {
101243
- throw new utils.SandboxAccessError(`Cannot ${op2} property '${obj.prop.toString()}' of a global object`);
101261
+ throw new utils.SandboxError(`Cannot ${op2} property '${obj.prop}' of a global object`);
101244
101262
  }
101245
101263
  if (obj.context === null) {
101246
101264
  throw new TypeError("Cannot set properties of null");
101247
101265
  }
101248
- if (typeof obj.context[obj.prop] === "function" && !utils.hasOwnProperty(obj.context, obj.prop)) {
101249
- throw new utils.SandboxAccessError(`Override prototype property '${obj.prop.toString()}' not allowed`);
101266
+ if (typeof obj.context[obj.prop] === "function" && !obj.context.hasOwnProperty(obj.prop)) {
101267
+ throw new utils.SandboxError(`Override prototype property '${obj.prop}' not allowed`);
101250
101268
  }
101251
101269
  if (op2 === "delete") {
101252
- if (utils.hasOwnProperty(obj.context, obj.prop)) {
101253
- context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop.toString() }));
101254
- context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop.toString() }));
101270
+ if (obj.context.hasOwnProperty(obj.prop)) {
101271
+ context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop }));
101272
+ context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop }));
101255
101273
  }
101256
- } else if (utils.hasOwnProperty(obj.context, obj.prop)) {
101257
- context.setSubscriptions.get(obj.context)?.get(obj.prop.toString())?.forEach((cb) => cb({
101274
+ } else if (obj.context.hasOwnProperty(obj.prop)) {
101275
+ context.setSubscriptions.get(obj.context)?.get(obj.prop)?.forEach((cb) => cb({
101258
101276
  type: "replace"
101259
101277
  }));
101260
- context.setSubscriptionsGlobal.get(obj.context)?.get(obj.prop.toString())?.forEach((cb) => cb({
101278
+ context.setSubscriptionsGlobal.get(obj.context)?.get(obj.prop)?.forEach((cb) => cb({
101261
101279
  type: "replace"
101262
101280
  }));
101263
101281
  } else {
101264
- context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop.toString() }));
101265
- context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop.toString() }));
101282
+ context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop }));
101283
+ context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop }));
101266
101284
  }
101267
101285
  }
101268
101286
  var arrayChange = /* @__PURE__ */ new Set([
@@ -101302,128 +101320,107 @@ var require_executor = __commonJS({
101302
101320
  function addOps(type, cb) {
101303
101321
  ops.set(type, cb);
101304
101322
  }
101305
- var prorptyKeyTypes = ["string", "number", "symbol"];
101306
- function isPropertyKey(val) {
101307
- return prorptyKeyTypes.includes(typeof val);
101308
- }
101309
- function hasPossibleProperties(val) {
101310
- return val !== null && val !== void 0;
101311
- }
101312
- addOps(1, ({ done, a: a4, b: b4, obj, context, scope }) => {
101323
+ addOps(1, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101313
101324
  if (a4 === null) {
101314
- throw new TypeError(`Cannot read properties of null (reading '${b4?.toString()}')`);
101315
- }
101316
- if (!isPropertyKey(b4)) {
101317
- b4 = `${b4}`;
101325
+ throw new TypeError(`Cannot get property ${b4} of null`);
101318
101326
  }
101319
- if (a4 === void 0 && obj === void 0 && typeof b4 === "string") {
101327
+ const type = typeof a4;
101328
+ if (type === "undefined" && obj === void 0) {
101320
101329
  const prop = scope.get(b4);
101321
101330
  if (prop.context === context.ctx.sandboxGlobal) {
101322
101331
  if (context.ctx.options.audit) {
101323
101332
  context.ctx.auditReport?.globalsAccess.add(b4);
101324
101333
  }
101334
+ const rep = context.ctx.globalsWhitelist.has(context.ctx.sandboxGlobal[b4]) ? context.evals.get(context.ctx.sandboxGlobal[b4]) : void 0;
101335
+ if (rep) {
101336
+ done(void 0, rep);
101337
+ return;
101338
+ }
101339
+ }
101340
+ if (prop.context && prop.context[b4] === globalThis) {
101341
+ done(void 0, context.ctx.globalScope.get("this"));
101342
+ return;
101325
101343
  }
101326
- const val2 = prop.context ? prop.context[prop.prop] : void 0;
101327
- const p5 = getGlobalProp(val2, context, prop) || prop;
101328
- done(void 0, p5);
101344
+ done(void 0, prop);
101329
101345
  return;
101330
101346
  } else if (a4 === void 0) {
101331
- throw new TypeError(`Cannot read properties of undefined (reading '${b4.toString()}')`);
101347
+ throw new utils.SandboxError("Cannot get property '" + b4 + "' of undefined");
101332
101348
  }
101333
- if (!hasPossibleProperties(a4)) {
101349
+ if (type !== "object") {
101350
+ if (type === "number") {
101351
+ a4 = new Number(a4);
101352
+ } else if (type === "string") {
101353
+ a4 = new String(a4);
101354
+ } else if (type === "boolean") {
101355
+ a4 = new Boolean(a4);
101356
+ }
101357
+ } else if (typeof a4.hasOwnProperty === "undefined") {
101334
101358
  done(void 0, new utils.Prop(void 0, b4));
101335
101359
  return;
101336
101360
  }
101337
- const prototypeAccess = typeof a4 === "function" || !utils.hasOwnProperty(a4, b4);
101361
+ const isFunction2 = type === "function";
101362
+ const prototypeAccess = isFunction2 || !(a4.hasOwnProperty(b4) || typeof b4 === "number");
101338
101363
  if (context.ctx.options.audit && prototypeAccess) {
101339
- let prot = Object.getPrototypeOf(a4);
101340
- do {
101341
- if (utils.hasOwnProperty(prot, b4)) {
101342
- if (context.ctx.auditReport && !context.ctx.auditReport.prototypeAccess[prot.constructor.name]) {
101343
- context.ctx.auditReport.prototypeAccess[prot.constructor.name] = /* @__PURE__ */ new Set();
101364
+ if (typeof b4 === "string") {
101365
+ let prot = Object.getPrototypeOf(a4);
101366
+ do {
101367
+ if (prot.hasOwnProperty(b4)) {
101368
+ if (context.ctx.auditReport && !context.ctx.auditReport.prototypeAccess[prot.constructor.name]) {
101369
+ context.ctx.auditReport.prototypeAccess[prot.constructor.name] = /* @__PURE__ */ new Set();
101370
+ }
101371
+ context.ctx.auditReport?.prototypeAccess[prot.constructor.name].add(b4);
101344
101372
  }
101345
- context.ctx.auditReport?.prototypeAccess[prot.constructor.name].add(b4);
101346
- }
101347
- } while (prot = Object.getPrototypeOf(prot));
101373
+ } while (prot = Object.getPrototypeOf(prot));
101374
+ }
101348
101375
  }
101349
101376
  if (prototypeAccess) {
101350
- if (typeof a4 === "function") {
101351
- if (utils.hasOwnProperty(a4, b4)) {
101377
+ if (isFunction2) {
101378
+ if (!["name", "length", "constructor"].includes(b4) && a4.hasOwnProperty(b4)) {
101352
101379
  const whitelist = context.ctx.prototypeWhitelist.get(a4.prototype);
101353
101380
  const replace = context.ctx.options.prototypeReplacements.get(a4);
101354
101381
  if (replace) {
101355
101382
  done(void 0, new utils.Prop(replace(a4, true), b4));
101356
101383
  return;
101357
101384
  }
101358
- if (!(whitelist && (!whitelist.size || whitelist.has(b4))) && !context.ctx.sandboxedFunctions.has(a4)) {
101359
- throw new utils.SandboxAccessError(`Static method or property access not permitted: ${a4.name}.${b4.toString()}`);
101385
+ if (!(whitelist && (!whitelist.size || whitelist.has(b4)))) {
101386
+ throw new utils.SandboxError(`Static method or property access not permitted: ${a4.name}.${b4}`);
101360
101387
  }
101361
101388
  }
101362
101389
  }
101363
- let prot = a4;
101364
- while (prot = Object.getPrototypeOf(prot)) {
101365
- if (utils.hasOwnProperty(prot, b4) || b4 === "__proto__") {
101366
- const whitelist = context.ctx.prototypeWhitelist.get(prot);
101367
- const replace = context.ctx.options.prototypeReplacements.get(prot.constructor);
101368
- if (replace) {
101369
- done(void 0, new utils.Prop(replace(a4, false), b4));
101370
- return;
101371
- }
101372
- if (whitelist && (!whitelist.size || whitelist.has(b4)) || context.ctx.sandboxedFunctions.has(prot.constructor)) {
101373
- break;
101374
- }
101375
- if (b4 === "__proto__") {
101376
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
101390
+ if (b4 !== "constructor") {
101391
+ let prot = a4;
101392
+ while (prot = Object.getPrototypeOf(prot)) {
101393
+ if (prot.hasOwnProperty(b4)) {
101394
+ const whitelist = context.ctx.prototypeWhitelist.get(prot);
101395
+ const replace = context.ctx.options.prototypeReplacements.get(prot.constuctor);
101396
+ if (replace) {
101397
+ done(void 0, new utils.Prop(replace(a4, false), b4));
101398
+ return;
101399
+ }
101400
+ if (whitelist && (!whitelist.size || whitelist.has(b4))) {
101401
+ break;
101402
+ }
101403
+ throw new utils.SandboxError(`Method or property access not permitted: ${prot.constructor.name}.${b4}`);
101377
101404
  }
101378
- throw new utils.SandboxAccessError(`Method or property access not permitted: ${prot.constructor.name}.${b4.toString()}`);
101379
101405
  }
101380
101406
  }
101381
101407
  }
101382
- const val = a4[b4];
101383
- if (typeof a4 === "function") {
101384
- if (b4 === "prototype" && !context.ctx.sandboxedFunctions.has(a4)) {
101385
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
101386
- }
101387
- }
101388
- if (b4 === "__proto__" && !context.ctx.sandboxedFunctions.has(val?.constructor)) {
101389
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
101390
- }
101391
- const p4 = getGlobalProp(val, context);
101392
- if (p4) {
101393
- done(void 0, p4);
101408
+ if (context.evals.has(a4[b4])) {
101409
+ done(void 0, context.evals.get(a4[b4]));
101394
101410
  return;
101395
101411
  }
101396
- const g4 = obj instanceof utils.Prop && obj.isGlobal || typeof a4 === "function" && !context.ctx.sandboxedFunctions.has(a4) || context.ctx.globalsWhitelist.has(a4);
101397
- done(void 0, new utils.Prop(a4, b4, false, g4, false));
101398
- });
101399
- function getGlobalProp(val, context, prop) {
101400
- if (!val)
101412
+ if (a4[b4] === globalThis) {
101413
+ done(void 0, context.ctx.globalScope.get("this"));
101401
101414
  return;
101402
- const isFunc = typeof val === "function";
101403
- if (val instanceof utils.Prop) {
101404
- if (!prop) {
101405
- prop = val;
101406
- }
101407
- val = val.get(context);
101408
- }
101409
- const p4 = prop?.prop || "prop";
101410
- if (val === globalThis) {
101411
- return new utils.Prop({
101412
- [p4]: context.ctx.sandboxGlobal
101413
- }, p4, prop?.isConst || false, false, prop?.isVariable || false);
101414
- }
101415
- const evl = isFunc && context.evals.get(val);
101416
- if (evl) {
101417
- return new utils.Prop({
101418
- [p4]: evl
101419
- }, p4, prop?.isConst || false, true, prop?.isVariable || false);
101420
101415
  }
101421
- }
101422
- addOps(5, ({ done, a: a4, b: b4, obj, context }) => {
101416
+ const g4 = obj.isGlobal || isFunction2 && !sandboxedFunctions.has(a4) || context.ctx.globalsWhitelist.has(a4);
101417
+ done(void 0, new utils.Prop(a4, b4, false, g4));
101418
+ });
101419
+ addOps(5, (exec6, done, ticks, a4, b4, obj, context) => {
101423
101420
  if (context.ctx.options.forbidFunctionCalls)
101424
- throw new utils.SandboxCapabilityError("Function invocations are not allowed");
101421
+ throw new utils.SandboxError("Function invocations are not allowed");
101425
101422
  if (typeof a4 !== "function") {
101426
- throw new TypeError(`${typeof obj?.prop === "symbol" ? "Symbol" : obj?.prop} is not a function`);
101423
+ throw new TypeError(`${typeof obj.prop === "symbol" ? "Symbol" : obj.prop} is not a function`);
101427
101424
  }
101428
101425
  const vals = b4.map((item) => {
101429
101426
  if (item instanceof SpreadArray) {
@@ -101433,9 +101430,7 @@ var require_executor = __commonJS({
101433
101430
  }
101434
101431
  }).flat().map((item) => valueOrProp(item, context));
101435
101432
  if (typeof obj === "function") {
101436
- let ret2 = obj(...vals);
101437
- ret2 = getGlobalProp(ret2, context) || ret2;
101438
- done(void 0, ret2);
101433
+ done(void 0, obj(...vals));
101439
101434
  return;
101440
101435
  }
101441
101436
  if (obj.context[obj.prop] === JSON.stringify && context.getSubscriptions.size) {
@@ -101507,11 +101502,9 @@ var require_executor = __commonJS({
101507
101502
  }
101508
101503
  }
101509
101504
  obj.get(context);
101510
- let ret = obj.context[obj.prop](...vals);
101511
- ret = getGlobalProp(ret, context) || ret;
101512
- done(void 0, ret);
101505
+ done(void 0, obj.context[obj.prop](...vals));
101513
101506
  });
101514
- addOps(22, ({ done, b: b4 }) => {
101507
+ addOps(22, (exec6, done, ticks, a4, b4) => {
101515
101508
  let res = {};
101516
101509
  for (const item of b4) {
101517
101510
  if (item.key instanceof SpreadObject) {
@@ -101522,8 +101515,8 @@ var require_executor = __commonJS({
101522
101515
  }
101523
101516
  done(void 0, res);
101524
101517
  });
101525
- addOps(6, ({ done, a: a4, b: b4 }) => done(void 0, new KeyVal(a4, b4)));
101526
- addOps(12, ({ done, b: b4, context }) => {
101518
+ addOps(6, (exec6, done, ticks, a4, b4) => done(void 0, new KeyVal(a4, b4)));
101519
+ addOps(12, (exec6, done, ticks, a4, b4, obj, context) => {
101527
101520
  const items = b4.map((item) => {
101528
101521
  if (item instanceof SpreadArray) {
101529
101522
  return [...item.item];
@@ -101533,8 +101526,8 @@ var require_executor = __commonJS({
101533
101526
  }).flat().map((item) => valueOrProp(item, context));
101534
101527
  done(void 0, items);
101535
101528
  });
101536
- addOps(23, ({ done, b: b4 }) => done(void 0, b4));
101537
- addOps(35, ({ done, b: b4 }) => {
101529
+ addOps(23, (exec6, done, ticks, a4, b4) => done(void 0, b4));
101530
+ addOps(35, (exec6, done, ticks, a4, b4) => {
101538
101531
  switch (b4) {
101539
101532
  case "true":
101540
101533
  return done(void 0, true);
@@ -101551,18 +101544,18 @@ var require_executor = __commonJS({
101551
101544
  }
101552
101545
  done(new Error("Unknown symbol: " + b4));
101553
101546
  });
101554
- addOps(7, ({ done, b: b4 }) => done(void 0, Number(b4.replace(/_/g, ""))));
101555
- addOps(83, ({ done, b: b4 }) => done(void 0, BigInt(b4.replace(/_/g, ""))));
101556
- addOps(2, ({ done, b: b4, context }) => done(void 0, context.constants.strings[parseInt(b4)]));
101557
- addOps(85, ({ done, b: b4, context }) => {
101547
+ addOps(7, (exec6, done, ticks, a4, b4) => done(void 0, Number(b4)));
101548
+ addOps(83, (exec6, done, ticks, a4, b4) => done(void 0, BigInt(b4)));
101549
+ addOps(2, (exec6, done, ticks, a4, b4, obj, context) => done(void 0, context.constants.strings[parseInt(b4)]));
101550
+ addOps(86, (exec6, done, ticks, a4, b4, obj, context) => {
101558
101551
  const reg = context.constants.regexes[parseInt(b4)];
101559
101552
  if (!context.ctx.globalsWhitelist.has(RegExp)) {
101560
- throw new utils.SandboxCapabilityError("Regex not permitted");
101553
+ throw new utils.SandboxError("Regex not permitted");
101561
101554
  } else {
101562
101555
  done(void 0, new RegExp(reg.regex, reg.flags));
101563
101556
  }
101564
101557
  });
101565
- addOps(84, ({ exec: exec6, done, ticks, b: b4, context, scope }) => {
101558
+ addOps(84, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101566
101559
  const item = context.constants.literals[parseInt(b4)];
101567
101560
  const [, name14, js] = item;
101568
101561
  const found = [];
@@ -101574,13 +101567,12 @@ var require_executor = __commonJS({
101574
101567
  resnums.push(f4[3]);
101575
101568
  }
101576
101569
  }
101577
- exec6(ticks, found, scope, context, (...args) => {
101570
+ exec6(ticks, found, scope, context, (err, processed) => {
101578
101571
  const reses = {};
101579
- if (args.length === 1) {
101580
- done(args[0]);
101572
+ if (err) {
101573
+ done(err);
101581
101574
  return;
101582
101575
  }
101583
- const processed = args[1];
101584
101576
  for (const i4 of Object.keys(processed)) {
101585
101577
  const num = resnums[i4];
101586
101578
  reses[num] = processed[i4];
@@ -101593,146 +101585,115 @@ var require_executor = __commonJS({
101593
101585
  }));
101594
101586
  });
101595
101587
  });
101596
- addOps(18, ({ done, b: b4 }) => {
101588
+ addOps(18, (exec6, done, ticks, a4, b4) => {
101597
101589
  done(void 0, new SpreadArray(b4));
101598
101590
  });
101599
- addOps(17, ({ done, b: b4 }) => {
101591
+ addOps(17, (exec6, done, ticks, a4, b4) => {
101600
101592
  done(void 0, new SpreadObject(b4));
101601
101593
  });
101602
- addOps(24, ({ done, b: b4 }) => done(void 0, !b4));
101603
- addOps(64, ({ done, b: b4 }) => done(void 0, ~b4));
101604
- addOps(25, ({ done, obj, context }) => {
101594
+ addOps(24, (exec6, done, ticks, a4, b4) => done(void 0, !b4));
101595
+ addOps(64, (exec6, done, ticks, a4, b4) => done(void 0, ~b4));
101596
+ addOps(25, (exec6, done, ticks, a4, b4, obj, context) => {
101605
101597
  assignCheck(obj, context);
101606
101598
  done(void 0, ++obj.context[obj.prop]);
101607
101599
  });
101608
- addOps(26, ({ done, obj, context }) => {
101600
+ addOps(26, (exec6, done, ticks, a4, b4, obj, context) => {
101609
101601
  assignCheck(obj, context);
101610
101602
  done(void 0, obj.context[obj.prop]++);
101611
101603
  });
101612
- addOps(27, ({ done, obj, context }) => {
101604
+ addOps(27, (exec6, done, ticks, a4, b4, obj, context) => {
101613
101605
  assignCheck(obj, context);
101614
101606
  done(void 0, --obj.context[obj.prop]);
101615
101607
  });
101616
- addOps(28, ({ done, obj, context }) => {
101608
+ addOps(28, (exec6, done, ticks, a4, b4, obj, context) => {
101617
101609
  assignCheck(obj, context);
101618
101610
  done(void 0, obj.context[obj.prop]--);
101619
101611
  });
101620
- addOps(9, ({ done, b: b4, obj, context, scope, bobj }) => {
101612
+ addOps(9, (exec6, done, ticks, a4, b4, obj, context) => {
101621
101613
  assignCheck(obj, context);
101622
- obj.isGlobal = bobj?.isGlobal || false;
101623
- if (obj.isVariable) {
101624
- const s4 = scope.getWhereValScope(obj.prop, obj.prop === "this");
101625
- if (s4 === null) {
101626
- throw new ReferenceError(`Cannot assign to undeclared variable '${obj.prop.toString()}'`);
101627
- }
101628
- s4.set(obj.prop, b4);
101629
- if (obj.isGlobal) {
101630
- s4.globals[obj.prop.toString()] = true;
101631
- } else {
101632
- delete s4.globals[obj.prop.toString()];
101633
- }
101634
- done(void 0, b4);
101635
- return;
101636
- }
101637
101614
  done(void 0, obj.context[obj.prop] = b4);
101638
101615
  });
101639
- addOps(66, ({ done, b: b4, obj, context }) => {
101616
+ addOps(66, (exec6, done, ticks, a4, b4, obj, context) => {
101640
101617
  assignCheck(obj, context);
101641
101618
  done(void 0, obj.context[obj.prop] += b4);
101642
101619
  });
101643
- addOps(65, ({ done, b: b4, obj, context }) => {
101620
+ addOps(65, (exec6, done, ticks, a4, b4, obj, context) => {
101644
101621
  assignCheck(obj, context);
101645
101622
  done(void 0, obj.context[obj.prop] -= b4);
101646
101623
  });
101647
- addOps(67, ({ done, b: b4, obj, context }) => {
101624
+ addOps(67, (exec6, done, ticks, a4, b4, obj, context) => {
101648
101625
  assignCheck(obj, context);
101649
101626
  done(void 0, obj.context[obj.prop] /= b4);
101650
101627
  });
101651
- addOps(69, ({ done, b: b4, obj, context }) => {
101628
+ addOps(69, (exec6, done, ticks, a4, b4, obj, context) => {
101652
101629
  assignCheck(obj, context);
101653
101630
  done(void 0, obj.context[obj.prop] *= b4);
101654
101631
  });
101655
- addOps(68, ({ done, b: b4, obj, context }) => {
101632
+ addOps(68, (exec6, done, ticks, a4, b4, obj, context) => {
101656
101633
  assignCheck(obj, context);
101657
101634
  done(void 0, obj.context[obj.prop] **= b4);
101658
101635
  });
101659
- addOps(70, ({ done, b: b4, obj, context }) => {
101636
+ addOps(70, (exec6, done, ticks, a4, b4, obj, context) => {
101660
101637
  assignCheck(obj, context);
101661
101638
  done(void 0, obj.context[obj.prop] %= b4);
101662
101639
  });
101663
- addOps(71, ({ done, b: b4, obj, context }) => {
101640
+ addOps(71, (exec6, done, ticks, a4, b4, obj, context) => {
101664
101641
  assignCheck(obj, context);
101665
101642
  done(void 0, obj.context[obj.prop] ^= b4);
101666
101643
  });
101667
- addOps(72, ({ done, b: b4, obj, context }) => {
101644
+ addOps(72, (exec6, done, ticks, a4, b4, obj, context) => {
101668
101645
  assignCheck(obj, context);
101669
101646
  done(void 0, obj.context[obj.prop] &= b4);
101670
101647
  });
101671
- addOps(73, ({ done, b: b4, obj, context }) => {
101648
+ addOps(73, (exec6, done, ticks, a4, b4, obj, context) => {
101672
101649
  assignCheck(obj, context);
101673
101650
  done(void 0, obj.context[obj.prop] |= b4);
101674
101651
  });
101675
- addOps(76, ({ done, b: b4, obj, context }) => {
101652
+ addOps(76, (exec6, done, ticks, a4, b4, obj, context) => {
101676
101653
  assignCheck(obj, context);
101677
101654
  done(void 0, obj.context[obj.prop] <<= b4);
101678
101655
  });
101679
- addOps(75, ({ done, b: b4, obj, context }) => {
101656
+ addOps(75, (exec6, done, ticks, a4, b4, obj, context) => {
101680
101657
  assignCheck(obj, context);
101681
101658
  done(void 0, obj.context[obj.prop] >>= b4);
101682
101659
  });
101683
- addOps(74, ({ done, b: b4, obj, context }) => {
101684
- assignCheck(obj, context);
101685
- done(void 0, obj.context[obj.prop] >>>= b4);
101686
- });
101687
- addOps(90, ({ done, b: b4, obj, context }) => {
101688
- var _a16, _b;
101689
- assignCheck(obj, context);
101690
- done(void 0, (_a16 = obj.context)[_b = obj.prop] && (_a16[_b] = b4));
101691
- });
101692
- addOps(91, ({ done, b: b4, obj, context }) => {
101693
- var _a16, _b;
101694
- assignCheck(obj, context);
101695
- done(void 0, (_a16 = obj.context)[_b = obj.prop] || (_a16[_b] = b4));
101696
- });
101697
- addOps(92, ({ done, b: b4, obj, context }) => {
101698
- var _a16, _b;
101660
+ addOps(74, (exec6, done, ticks, a4, b4, obj, context) => {
101699
101661
  assignCheck(obj, context);
101700
- done(void 0, (_a16 = obj.context)[_b = obj.prop] ?? (_a16[_b] = b4));
101662
+ done(void 0, obj.context[obj.prop] >>= b4);
101701
101663
  });
101702
- addOps(57, ({ done, a: a4, b: b4 }) => done(void 0, a4 > b4));
101703
- addOps(56, ({ done, a: a4, b: b4 }) => done(void 0, a4 < b4));
101704
- addOps(55, ({ done, a: a4, b: b4 }) => done(void 0, a4 >= b4));
101705
- addOps(54, ({ done, a: a4, b: b4 }) => done(void 0, a4 <= b4));
101706
- addOps(52, ({ done, a: a4, b: b4 }) => done(void 0, a4 == b4));
101707
- addOps(32, ({ done, a: a4, b: b4 }) => done(void 0, a4 === b4));
101708
- addOps(53, ({ done, a: a4, b: b4 }) => done(void 0, a4 != b4));
101709
- addOps(31, ({ done, a: a4, b: b4 }) => done(void 0, a4 !== b4));
101710
- addOps(29, ({ done, a: a4, b: b4 }) => done(void 0, a4 && b4));
101711
- addOps(30, ({ done, a: a4, b: b4 }) => done(void 0, a4 || b4));
101712
- addOps(89, ({ done, a: a4, b: b4 }) => done(void 0, a4 ?? b4));
101713
- addOps(77, ({ done, a: a4, b: b4 }) => done(void 0, a4 & b4));
101714
- addOps(78, ({ done, a: a4, b: b4 }) => done(void 0, a4 | b4));
101715
- addOps(33, ({ done, a: a4, b: b4 }) => done(void 0, a4 + b4));
101716
- addOps(47, ({ done, a: a4, b: b4 }) => done(void 0, a4 - b4));
101717
- addOps(59, ({ done, b: b4 }) => done(void 0, +b4));
101718
- addOps(58, ({ done, b: b4 }) => done(void 0, -b4));
101719
- addOps(48, ({ done, a: a4, b: b4 }) => done(void 0, a4 / b4));
101720
- addOps(49, ({ done, a: a4, b: b4 }) => done(void 0, a4 ** b4));
101721
- addOps(79, ({ done, a: a4, b: b4 }) => done(void 0, a4 ^ b4));
101722
- addOps(50, ({ done, a: a4, b: b4 }) => done(void 0, a4 * b4));
101723
- addOps(51, ({ done, a: a4, b: b4 }) => done(void 0, a4 % b4));
101724
- addOps(80, ({ done, a: a4, b: b4 }) => done(void 0, a4 << b4));
101725
- addOps(81, ({ done, a: a4, b: b4 }) => done(void 0, a4 >> b4));
101726
- addOps(82, ({ done, a: a4, b: b4 }) => done(void 0, a4 >>> b4));
101727
- addOps(60, ({ exec: exec6, done, ticks, b: b4, context, scope }) => {
101664
+ addOps(57, (exec6, done, ticks, a4, b4) => done(void 0, a4 > b4));
101665
+ addOps(56, (exec6, done, ticks, a4, b4) => done(void 0, a4 < b4));
101666
+ addOps(55, (exec6, done, ticks, a4, b4) => done(void 0, a4 >= b4));
101667
+ addOps(54, (exec6, done, ticks, a4, b4) => done(void 0, a4 <= b4));
101668
+ addOps(52, (exec6, done, ticks, a4, b4) => done(void 0, a4 == b4));
101669
+ addOps(32, (exec6, done, ticks, a4, b4) => done(void 0, a4 === b4));
101670
+ addOps(53, (exec6, done, ticks, a4, b4) => done(void 0, a4 != b4));
101671
+ addOps(31, (exec6, done, ticks, a4, b4) => done(void 0, a4 !== b4));
101672
+ addOps(29, (exec6, done, ticks, a4, b4) => done(void 0, a4 && b4));
101673
+ addOps(30, (exec6, done, ticks, a4, b4) => done(void 0, a4 || b4));
101674
+ addOps(85, (exec6, done, ticks, a4, b4) => done(void 0, a4 ?? b4));
101675
+ addOps(77, (exec6, done, ticks, a4, b4) => done(void 0, a4 & b4));
101676
+ addOps(78, (exec6, done, ticks, a4, b4) => done(void 0, a4 | b4));
101677
+ addOps(33, (exec6, done, ticks, a4, b4) => done(void 0, a4 + b4));
101678
+ addOps(47, (exec6, done, ticks, a4, b4) => done(void 0, a4 - b4));
101679
+ addOps(59, (exec6, done, ticks, a4, b4) => done(void 0, +b4));
101680
+ addOps(58, (exec6, done, ticks, a4, b4) => done(void 0, -b4));
101681
+ addOps(48, (exec6, done, ticks, a4, b4) => done(void 0, a4 / b4));
101682
+ addOps(79, (exec6, done, ticks, a4, b4) => done(void 0, a4 ^ b4));
101683
+ addOps(50, (exec6, done, ticks, a4, b4) => done(void 0, a4 * b4));
101684
+ addOps(51, (exec6, done, ticks, a4, b4) => done(void 0, a4 % b4));
101685
+ addOps(80, (exec6, done, ticks, a4, b4) => done(void 0, a4 << b4));
101686
+ addOps(81, (exec6, done, ticks, a4, b4) => done(void 0, a4 >> b4));
101687
+ addOps(82, (exec6, done, ticks, a4, b4) => done(void 0, a4 >>> b4));
101688
+ addOps(60, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101728
101689
  exec6(ticks, b4, scope, context, (e4, prop) => {
101729
101690
  done(void 0, typeof valueOrProp(prop, context));
101730
101691
  });
101731
101692
  });
101732
- addOps(62, ({ done, a: a4, b: b4 }) => done(void 0, a4 instanceof b4));
101733
- addOps(63, ({ done, a: a4, b: b4 }) => done(void 0, a4 in b4));
101734
- addOps(61, ({ done, context, bobj }) => {
101735
- if (!(bobj instanceof utils.Prop)) {
101693
+ addOps(62, (exec6, done, ticks, a4, b4) => done(void 0, a4 instanceof b4));
101694
+ addOps(63, (exec6, done, ticks, a4, b4) => done(void 0, a4 in b4));
101695
+ addOps(61, (exec6, done, ticks, a4, b4, obj, context, scope, bobj) => {
101696
+ if (bobj.context === void 0) {
101736
101697
  done(void 0, true);
101737
101698
  return;
101738
101699
  }
@@ -101743,23 +101704,23 @@ var require_executor = __commonJS({
101743
101704
  }
101744
101705
  done(void 0, delete bobj.context?.[bobj.prop]);
101745
101706
  });
101746
- addOps(8, ({ done, b: b4 }) => done(void 0, b4));
101747
- addOps(34, ({ done, a: a4, b: b4, scope, bobj }) => {
101748
- done(void 0, scope.declare(a4, "var", b4, bobj?.isGlobal || false));
101707
+ addOps(8, (exec6, done, ticks, a4, b4) => done(void 0, b4));
101708
+ addOps(34, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101709
+ done(void 0, scope.declare(a4, "var", b4));
101749
101710
  });
101750
- addOps(3, ({ done, a: a4, b: b4, scope, bobj }) => {
101751
- done(void 0, scope.declare(a4, "let", b4, bobj?.isGlobal || false));
101711
+ addOps(3, (exec6, done, ticks, a4, b4, obj, context, scope, bobj) => {
101712
+ done(void 0, scope.declare(a4, "let", b4, bobj && bobj.isGlobal));
101752
101713
  });
101753
- addOps(4, ({ done, a: a4, b: b4, scope, bobj }) => {
101754
- done(void 0, scope.declare(a4, "const", b4, bobj?.isGlobal || false));
101714
+ addOps(4, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101715
+ done(void 0, scope.declare(a4, "const", b4));
101755
101716
  });
101756
- addOps(11, ({ done, ticks, a: a4, b: b4, obj, context, scope }) => {
101717
+ addOps(11, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101757
101718
  a4 = [...a4];
101758
101719
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
101759
101720
  if (context.allowJit && context.evalContext) {
101760
101721
  obj[2] = b4 = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
101761
101722
  } else {
101762
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
101723
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
101763
101724
  }
101764
101725
  }
101765
101726
  if (a4.shift()) {
@@ -101768,18 +101729,18 @@ var require_executor = __commonJS({
101768
101729
  done(void 0, createFunction(a4, b4, ticks, context, scope));
101769
101730
  }
101770
101731
  });
101771
- addOps(37, ({ done, ticks, a: a4, b: b4, obj, context, scope }) => {
101732
+ addOps(37, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101772
101733
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
101773
101734
  if (context.allowJit && context.evalContext) {
101774
101735
  obj[2] = b4 = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
101775
101736
  } else {
101776
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
101737
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
101777
101738
  }
101778
101739
  }
101779
101740
  const isAsync2 = a4.shift();
101780
101741
  const name14 = a4.shift();
101781
101742
  let func;
101782
- if (isAsync2 === 88) {
101743
+ if (isAsync2 === 89) {
101783
101744
  func = createFunctionAsync(a4, b4, ticks, context, scope, name14);
101784
101745
  } else {
101785
101746
  func = createFunction(a4, b4, ticks, context, scope, name14);
@@ -101789,12 +101750,12 @@ var require_executor = __commonJS({
101789
101750
  }
101790
101751
  done(void 0, func);
101791
101752
  });
101792
- addOps(10, ({ done, ticks, a: a4, b: b4, obj, context, scope }) => {
101753
+ addOps(10, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101793
101754
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
101794
101755
  if (context.allowJit && context.evalContext) {
101795
101756
  obj[2] = b4 = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
101796
101757
  } else {
101797
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
101758
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
101798
101759
  }
101799
101760
  }
101800
101761
  const isAsync2 = a4.shift();
@@ -101803,7 +101764,7 @@ var require_executor = __commonJS({
101803
101764
  scope = new utils.Scope(scope, {});
101804
101765
  }
101805
101766
  let func;
101806
- if (isAsync2 === 88) {
101767
+ if (isAsync2 === 89) {
101807
101768
  func = createFunctionAsync(a4, b4, ticks, context, scope, name14);
101808
101769
  } else {
101809
101770
  func = createFunction(a4, b4, ticks, context, scope, name14);
@@ -101813,7 +101774,7 @@ var require_executor = __commonJS({
101813
101774
  }
101814
101775
  done(void 0, func);
101815
101776
  });
101816
- addOps(38, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope }) => {
101777
+ addOps(38, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101817
101778
  const [checkFirst, startInternal, getIterator, startStep, step, condition, beforeStep] = a4;
101818
101779
  let loop = true;
101819
101780
  const loopScope = new utils.Scope(scope, {});
@@ -101869,27 +101830,26 @@ var require_executor = __commonJS({
101869
101830
  done();
101870
101831
  }
101871
101832
  });
101872
- addOps(86, ({ done, a: a4, context, inLoopOrSwitch }) => {
101833
+ addOps(87, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
101873
101834
  if (inLoopOrSwitch === "switch" && a4 === "continue" || !inLoopOrSwitch) {
101874
- throw new TypeError("Illegal " + a4 + " statement");
101835
+ throw new utils.SandboxError("Illegal " + a4 + " statement");
101875
101836
  }
101876
101837
  done(void 0, new ExecReturn(context.ctx.auditReport, void 0, false, a4 === "break", a4 === "continue"));
101877
101838
  });
101878
- addOps(13, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope, inLoopOrSwitch }) => {
101839
+ addOps(13, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
101879
101840
  exec6(ticks, valueOrProp(a4, context) ? b4.t : b4.f, scope, context, done, inLoopOrSwitch);
101880
101841
  });
101881
- addOps(15, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope }) => {
101882
- exec6(ticks, valueOrProp(a4, context) ? b4.t : b4.f, scope, context, done, void 0);
101842
+ addOps(15, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
101843
+ exec6(ticks, valueOrProp(a4, context) ? b4.t : b4.f, scope, context, done, inLoopOrSwitch);
101883
101844
  });
101884
- addOps(16, ({ done, a: a4, b: b4 }) => done(void 0, new If(a4, b4)));
101885
- addOps(14, ({ done, a: a4, b: b4 }) => done(void 0, new If(a4, b4)));
101886
- addOps(40, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope }) => {
101887
- exec6(ticks, a4, scope, context, (...args) => {
101888
- if (args.length === 1) {
101889
- done(args[0]);
101845
+ addOps(16, (exec6, done, ticks, a4, b4) => done(void 0, new If(a4, b4)));
101846
+ addOps(14, (exec6, done, ticks, a4, b4) => done(void 0, new If(a4, b4)));
101847
+ addOps(40, (exec6, done, ticks, a4, b4, obj, context, scope) => {
101848
+ exec6(ticks, a4, scope, context, (err, toTest) => {
101849
+ if (err) {
101850
+ done(err);
101890
101851
  return;
101891
101852
  }
101892
- let toTest = args[1];
101893
101853
  toTest = valueOrProp(toTest, context);
101894
101854
  if (exec6 === execSync) {
101895
101855
  let res;
@@ -101937,79 +101897,34 @@ var require_executor = __commonJS({
101937
101897
  }
101938
101898
  });
101939
101899
  });
101940
- addOps(39, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope, inLoopOrSwitch }) => {
101900
+ addOps(39, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
101941
101901
  const [exception, catchBody, finallyBody] = b4;
101942
- executeTreeWithDone(exec6, (...tryArgs) => {
101943
- const tryHadError = tryArgs.length === 1;
101944
- const tryError = tryHadError ? tryArgs[0] : void 0;
101945
- const tryResult = !tryHadError && tryArgs.length > 1 ? tryArgs[1] : void 0;
101946
- const executeFinallyAndComplete = (hadError, errorOrResult) => {
101947
- if (finallyBody && finallyBody.length > 0) {
101948
- executeTreeWithDone(exec6, (...finallyArgs) => {
101949
- const finallyHadError = finallyArgs.length === 1;
101950
- const finallyResult = !finallyHadError && finallyArgs.length > 1 ? finallyArgs[1] : void 0;
101951
- if (finallyHadError) {
101952
- done(finallyArgs[0]);
101953
- return;
101954
- }
101955
- if (finallyResult instanceof ExecReturn && (finallyResult.returned || finallyResult.breakLoop || finallyResult.continueLoop)) {
101956
- done(void 0, finallyResult);
101957
- return;
101958
- }
101959
- if (hadError) {
101960
- done(errorOrResult);
101961
- } else if (errorOrResult instanceof ExecReturn) {
101962
- if (errorOrResult.returned || errorOrResult.breakLoop || errorOrResult.continueLoop) {
101963
- done(void 0, errorOrResult);
101964
- } else {
101965
- done();
101966
- }
101967
- } else {
101968
- done();
101969
- }
101970
- }, ticks, context, finallyBody, [new utils.Scope(scope, {})], inLoopOrSwitch);
101902
+ executeTreeWithDone(exec6, (err, res) => {
101903
+ executeTreeWithDone(exec6, (e4) => {
101904
+ if (e4)
101905
+ done(e4);
101906
+ else if (err) {
101907
+ executeTreeWithDone(exec6, done, ticks, context, catchBody, [new utils.Scope(scope)], inLoopOrSwitch);
101971
101908
  } else {
101972
- if (hadError) {
101973
- done(errorOrResult);
101974
- } else if (errorOrResult instanceof ExecReturn) {
101975
- if (errorOrResult.returned || errorOrResult.breakLoop || errorOrResult.continueLoop) {
101976
- done(void 0, errorOrResult);
101977
- } else {
101978
- done();
101979
- }
101980
- } else {
101981
- done();
101982
- }
101909
+ done(void 0, res);
101983
101910
  }
101984
- };
101985
- if (tryHadError && catchBody && catchBody.length > 0) {
101986
- const sc = {};
101987
- if (exception)
101988
- sc[exception] = tryError;
101989
- executeTreeWithDone(exec6, (...catchArgs) => {
101990
- const catchHadError = catchArgs.length === 1;
101991
- const catchErrorOrResult = catchHadError ? catchArgs[0] : catchArgs.length > 1 ? catchArgs[1] : void 0;
101992
- executeFinallyAndComplete(catchHadError, catchErrorOrResult);
101993
- }, ticks, context, catchBody, [new utils.Scope(scope, sc)], inLoopOrSwitch);
101994
- } else {
101995
- executeFinallyAndComplete(tryHadError, tryHadError ? tryError : tryResult);
101996
- }
101911
+ }, ticks, context, finallyBody, [new utils.Scope(scope, {})]);
101997
101912
  }, ticks, context, a4, [new utils.Scope(scope)], inLoopOrSwitch);
101998
101913
  });
101999
- addOps(87, ({ done }) => {
101914
+ addOps(88, (exec6, done) => {
102000
101915
  done();
102001
101916
  });
102002
- addOps(45, ({ done, a: a4, b: b4, context }) => {
102003
- if (!context.ctx.globalsWhitelist.has(a4) && !context.ctx.sandboxedFunctions.has(a4)) {
102004
- throw new utils.SandboxAccessError(`Object construction not allowed: ${a4.constructor.name}`);
101917
+ addOps(45, (exec6, done, ticks, a4, b4, obj, context) => {
101918
+ if (!context.ctx.globalsWhitelist.has(a4) && !sandboxedFunctions.has(a4)) {
101919
+ throw new utils.SandboxError(`Object construction not allowed: ${a4.constructor.name}`);
102005
101920
  }
102006
101921
  done(void 0, new a4(...b4));
102007
101922
  });
102008
- addOps(46, ({ done, b: b4 }) => {
101923
+ addOps(46, (exec6, done, ticks, a4, b4) => {
102009
101924
  done(b4);
102010
101925
  });
102011
- addOps(43, ({ done, a: a4 }) => done(void 0, a4.pop()));
102012
- addOps(0, ({ done }) => done());
101926
+ addOps(43, (exec6, done, ticks, a4) => done(void 0, a4.pop()));
101927
+ addOps(0, (exec6, done) => done());
102013
101928
  function valueOrProp(a4, context) {
102014
101929
  if (a4 instanceof utils.Prop)
102015
101930
  return a4.get(context);
@@ -102027,7 +101942,13 @@ var require_executor = __commonJS({
102027
101942
  function _execManySync(ticks, tree, done, scope, context, inLoopOrSwitch) {
102028
101943
  const ret = [];
102029
101944
  for (let i4 = 0; i4 < tree.length; i4++) {
102030
- let res = syncDone((d4) => execSync(ticks, tree[i4], scope, context, d4, inLoopOrSwitch)).result;
101945
+ let res;
101946
+ try {
101947
+ res = syncDone((d4) => execSync(ticks, tree[i4], scope, context, d4, inLoopOrSwitch)).result;
101948
+ } catch (e4) {
101949
+ done(e4);
101950
+ return;
101951
+ }
102031
101952
  if (res instanceof ExecReturn && (res.returned || res.breakLoop || res.continueLoop)) {
102032
101953
  done(void 0, res);
102033
101954
  return;
@@ -102067,13 +101988,13 @@ var require_executor = __commonJS({
102067
101988
  let isInstant = false;
102068
101989
  let instant;
102069
101990
  const p4 = new Promise((resolve7, reject2) => {
102070
- callback((...args) => {
102071
- if (args.length === 1)
102072
- reject2(args[0]);
101991
+ callback((err, result) => {
101992
+ if (err)
101993
+ reject2(err);
102073
101994
  else {
102074
101995
  isInstant = true;
102075
- instant = args[1];
102076
- resolve7({ result: args[1] });
101996
+ instant = result;
101997
+ resolve7({ result });
102077
101998
  }
102078
101999
  });
102079
102000
  });
@@ -102086,19 +102007,19 @@ var require_executor = __commonJS({
102086
102007
  function syncDone(callback) {
102087
102008
  let result;
102088
102009
  let err;
102089
- callback((...args) => {
102090
- err = args.length === 1 ? { error: args[0] } : void 0;
102091
- result = args[1];
102010
+ callback((e4, r4) => {
102011
+ err = e4;
102012
+ result = r4;
102092
102013
  });
102093
102014
  if (err)
102094
- throw err.error;
102015
+ throw err;
102095
102016
  return { result };
102096
102017
  }
102097
102018
  async function execAsync4(ticks, tree, scope, context, doneOriginal, inLoopOrSwitch) {
102098
102019
  let done = doneOriginal;
102099
102020
  const p4 = new Promise((resolve7) => {
102100
- done = (...args) => {
102101
- doneOriginal(...args);
102021
+ done = (e4, r4) => {
102022
+ doneOriginal(e4, r4);
102102
102023
  resolve7();
102103
102024
  };
102104
102025
  });
@@ -102134,10 +102055,6 @@ var require_executor = __commonJS({
102134
102055
  a4 = void 0;
102135
102056
  }
102136
102057
  }
102137
- if (op2 === 89 && a4 !== void 0 && a4 !== null) {
102138
- done(void 0, a4);
102139
- return;
102140
- }
102141
102058
  let bobj;
102142
102059
  try {
102143
102060
  let ad;
@@ -102156,28 +102073,35 @@ var require_executor = __commonJS({
102156
102073
  if (b4 === optional) {
102157
102074
  b4 = void 0;
102158
102075
  }
102159
- performOp({
102160
- op: op2,
102161
- exec: execAsync4,
102162
- done,
102163
- ticks,
102164
- a: a4,
102165
- b: b4,
102166
- obj,
102167
- context,
102168
- scope,
102169
- bobj,
102170
- inLoopOrSwitch,
102171
- tree
102172
- });
102076
+ if (ops.has(op2)) {
102077
+ try {
102078
+ ops.get(op2)?.(execAsync4, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch);
102079
+ } catch (err) {
102080
+ done(err);
102081
+ }
102082
+ } else {
102083
+ done(new SyntaxError("Unknown operator: " + op2));
102084
+ }
102173
102085
  }
102174
102086
  await p4;
102175
102087
  }
102176
102088
  function execSync(ticks, tree, scope, context, done, inLoopOrSwitch) {
102177
102089
  if (!_execNoneRecurse(ticks, tree, scope, context, done, false, inLoopOrSwitch) && utils.isLisp(tree)) {
102178
102090
  let op2 = tree[0];
102179
- let obj = syncDone((d4) => execSync(ticks, tree[1], scope, context, d4, inLoopOrSwitch)).result;
102180
- let a4 = obj instanceof utils.Prop ? obj.get(context) : obj;
102091
+ let obj;
102092
+ try {
102093
+ obj = syncDone((d4) => execSync(ticks, tree[1], scope, context, d4, inLoopOrSwitch)).result;
102094
+ } catch (e4) {
102095
+ done(e4);
102096
+ return;
102097
+ }
102098
+ let a4 = obj;
102099
+ try {
102100
+ a4 = obj instanceof utils.Prop ? obj.get(context) : obj;
102101
+ } catch (e4) {
102102
+ done(e4);
102103
+ return;
102104
+ }
102181
102105
  if (op2 === 20 || op2 === 21) {
102182
102106
  if (a4 === void 0 || a4 === null) {
102183
102107
  done(void 0, optional);
@@ -102193,129 +102117,31 @@ var require_executor = __commonJS({
102193
102117
  a4 = void 0;
102194
102118
  }
102195
102119
  }
102196
- if (op2 === 89 && a4 !== void 0 && a4 !== null) {
102197
- done(void 0, a4);
102120
+ let bobj;
102121
+ try {
102122
+ bobj = syncDone((d4) => execSync(ticks, tree[2], scope, context, d4, inLoopOrSwitch)).result;
102123
+ } catch (e4) {
102124
+ done(e4);
102125
+ return;
102126
+ }
102127
+ let b4 = bobj;
102128
+ try {
102129
+ b4 = bobj instanceof utils.Prop ? bobj.get(context) : bobj;
102130
+ } catch (e4) {
102131
+ done(e4);
102198
102132
  return;
102199
102133
  }
102200
- let bobj = syncDone((d4) => execSync(ticks, tree[2], scope, context, d4, inLoopOrSwitch)).result;
102201
- let b4 = bobj instanceof utils.Prop ? bobj.get(context) : bobj;
102202
102134
  if (b4 === optional) {
102203
102135
  b4 = void 0;
102204
102136
  }
102205
- performOp({
102206
- op: op2,
102207
- exec: execSync,
102208
- done,
102209
- ticks,
102210
- a: a4,
102211
- b: b4,
102212
- obj,
102213
- context,
102214
- scope,
102215
- bobj,
102216
- inLoopOrSwitch,
102217
- tree
102218
- });
102219
- }
102220
- }
102221
- function checkHaltExpectedTicks(params, expectTicks = 0) {
102222
- const sandbox = params.context.ctx.sandbox;
102223
- const options = params.context.ctx.options;
102224
- const { ticks, scope, context, done, op: op2 } = params;
102225
- if (sandbox.halted) {
102226
- const sub = sandbox.subscribeResume(() => {
102227
- sub.unsubscribe();
102137
+ if (ops.has(op2)) {
102228
102138
  try {
102229
- const o4 = ops.get(op2);
102230
- if (!o4) {
102231
- done(new SyntaxError("Unknown operator: " + op2));
102232
- return;
102233
- }
102234
- o4(params);
102235
- } catch (err) {
102236
- if (options.haltOnSandboxError && err instanceof utils.SandboxError) {
102237
- const sub2 = sandbox.subscribeResume(() => {
102238
- sub2.unsubscribe();
102239
- done(err);
102240
- });
102241
- sandbox.haltExecution({
102242
- error: err,
102243
- ticks,
102244
- scope,
102245
- context
102246
- });
102247
- } else {
102248
- done(err);
102249
- }
102250
- }
102251
- });
102252
- return true;
102253
- } else if (ticks.tickLimit && ticks.tickLimit <= ticks.ticks + BigInt(expectTicks)) {
102254
- const sub = sandbox.subscribeResume(() => {
102255
- sub.unsubscribe();
102256
- try {
102257
- const o4 = ops.get(op2);
102258
- if (!o4) {
102259
- done(new SyntaxError("Unknown operator: " + op2));
102260
- return;
102261
- }
102262
- o4(params);
102139
+ ops.get(op2)?.(execSync, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch);
102263
102140
  } catch (err) {
102264
- if (context.ctx.options.haltOnSandboxError && err instanceof utils.SandboxError) {
102265
- const sub2 = sandbox.subscribeResume(() => {
102266
- sub2.unsubscribe();
102267
- done(err);
102268
- });
102269
- sandbox.haltExecution({
102270
- error: err,
102271
- ticks,
102272
- scope,
102273
- context
102274
- });
102275
- } else {
102276
- done(err);
102277
- }
102278
- }
102279
- });
102280
- const error2 = new utils.SandboxExecutionQuotaExceededError("Execution quota exceeded");
102281
- sandbox.haltExecution({
102282
- error: error2,
102283
- ticks,
102284
- scope,
102285
- context
102286
- });
102287
- return true;
102288
- }
102289
- return false;
102290
- }
102291
- function performOp(params) {
102292
- const { done, op: op2, ticks, context, scope } = params;
102293
- ticks.ticks++;
102294
- const sandbox = context.ctx.sandbox;
102295
- if (checkHaltExpectedTicks(params)) {
102296
- return;
102297
- }
102298
- try {
102299
- const o4 = ops.get(op2);
102300
- if (!o4) {
102301
- done(new utils.SandboxExecutionTreeError("Unknown operator: " + op2));
102302
- return;
102303
- }
102304
- o4(params);
102305
- } catch (err) {
102306
- if (context.ctx.options.haltOnSandboxError && err instanceof utils.SandboxError) {
102307
- const sub = sandbox.subscribeResume(() => {
102308
- sub.unsubscribe();
102309
102141
  done(err);
102310
- });
102311
- sandbox.haltExecution({
102312
- error: err,
102313
- ticks,
102314
- scope,
102315
- context
102316
- });
102142
+ }
102317
102143
  } else {
102318
- done(err);
102144
+ done(new SyntaxError("Unknown operator: " + op2));
102319
102145
  }
102320
102146
  }
102321
102147
  }
@@ -102333,9 +102159,20 @@ var require_executor = __commonJS({
102333
102159
  var currentTicks = { current: { ticks: BigInt(0) } };
102334
102160
  function _execNoneRecurse(ticks, tree, scope, context, done, isAsync2, inLoopOrSwitch) {
102335
102161
  const exec6 = isAsync2 ? execAsync4 : execSync;
102162
+ if (context.ctx.options.executionQuota && context.ctx.options.executionQuota <= ticks.ticks) {
102163
+ if (!(typeof context.ctx.options.onExecutionQuotaReached === "function" && context.ctx.options.onExecutionQuotaReached(ticks, scope, context, tree))) {
102164
+ done(new utils.SandboxError("Execution quota exceeded"));
102165
+ return true;
102166
+ }
102167
+ }
102168
+ ticks.ticks++;
102336
102169
  currentTicks.current = ticks;
102337
102170
  if (tree instanceof utils.Prop) {
102338
- done(void 0, tree.get(context));
102171
+ try {
102172
+ done(void 0, tree.get(context));
102173
+ } catch (err) {
102174
+ done(err);
102175
+ }
102339
102176
  } else if (tree === optional) {
102340
102177
  done();
102341
102178
  } else if (Array.isArray(tree) && !utils.isLisp(tree)) {
@@ -102350,36 +102187,27 @@ var require_executor = __commonJS({
102350
102187
  execMany(ticks, exec6, tree[1], done, scope, context, inLoopOrSwitch);
102351
102188
  } else if (tree[0] === 44) {
102352
102189
  if (!isAsync2) {
102353
- done(new SyntaxError("Illegal use of 'await', must be inside async function"));
102190
+ done(new utils.SandboxError("Illegal use of 'await', must be inside async function"));
102354
102191
  } else if (context.ctx.prototypeWhitelist?.has(Promise.prototype)) {
102355
- execAsync4(ticks, tree[1], scope, context, async (...args) => {
102356
- if (args.length === 1)
102357
- done(args[0]);
102192
+ execAsync4(ticks, tree[1], scope, context, async (e4, r4) => {
102193
+ if (e4)
102194
+ done(e4);
102358
102195
  else
102359
102196
  try {
102360
- done(void 0, await valueOrProp(args[1], context));
102197
+ done(void 0, await valueOrProp(r4, context));
102361
102198
  } catch (err) {
102362
102199
  done(err);
102363
102200
  }
102364
102201
  }, inLoopOrSwitch).catch(done);
102365
102202
  } else {
102366
- done(new utils.SandboxCapabilityError("Async/await is not permitted"));
102203
+ done(new utils.SandboxError("Async/await is not permitted"));
102367
102204
  }
102368
102205
  } else if (unexecTypes.has(tree[0])) {
102369
- performOp({
102370
- op: tree[0],
102371
- exec: exec6,
102372
- done,
102373
- ticks,
102374
- a: tree[1],
102375
- b: tree[2],
102376
- obj: tree,
102377
- tree,
102378
- context,
102379
- scope,
102380
- bobj: void 0,
102381
- inLoopOrSwitch
102382
- });
102206
+ try {
102207
+ ops.get(tree[0])?.(exec6, done, ticks, tree[1], tree[2], tree, context, scope, void 0, inLoopOrSwitch);
102208
+ } catch (err) {
102209
+ done(err);
102210
+ }
102383
102211
  } else {
102384
102212
  return false;
102385
102213
  }
@@ -102432,17 +102260,15 @@ var require_executor = __commonJS({
102432
102260
  let err;
102433
102261
  const current2 = executionTree[i4];
102434
102262
  try {
102435
- execSync(ticks, current2, scope, context, (...args) => {
102436
- if (args.length === 1)
102437
- err = { error: args[0] };
102438
- else
102439
- res = args[1];
102263
+ execSync(ticks, current2, scope, context, (e4, r4) => {
102264
+ err = e4;
102265
+ res = r4;
102440
102266
  }, inLoopOrSwitch);
102441
102267
  } catch (e4) {
102442
- err = { error: e4 };
102268
+ err = e4;
102443
102269
  }
102444
102270
  if (err) {
102445
- done(err.error);
102271
+ done(err);
102446
102272
  return;
102447
102273
  }
102448
102274
  if (res instanceof ExecReturn) {
@@ -102465,17 +102291,15 @@ var require_executor = __commonJS({
102465
102291
  let err;
102466
102292
  const current2 = executionTree[i4];
102467
102293
  try {
102468
- await execAsync4(ticks, current2, scope, context, (...args) => {
102469
- if (args.length === 1)
102470
- err = { error: args[0] };
102471
- else
102472
- res = args[1];
102294
+ await execAsync4(ticks, current2, scope, context, (e4, r4) => {
102295
+ err = e4;
102296
+ res = r4;
102473
102297
  }, inLoopOrSwitch);
102474
102298
  } catch (e4) {
102475
- err = { error: e4 };
102299
+ err = e4;
102476
102300
  }
102477
102301
  if (err) {
102478
- done(err.error);
102302
+ done(err);
102479
102303
  return;
102480
102304
  }
102481
102305
  if (res instanceof ExecReturn) {
@@ -102506,6 +102330,7 @@ var require_executor = __commonJS({
102506
102330
  exports2.executeTree = executeTree;
102507
102331
  exports2.executeTreeAsync = executeTreeAsync;
102508
102332
  exports2.ops = ops;
102333
+ exports2.sandboxedFunctions = sandboxedFunctions;
102509
102334
  exports2.syncDone = syncDone;
102510
102335
  }
102511
102336
  });
@@ -102620,29 +102445,23 @@ var require_parser2 = __commonJS({
102620
102445
  var expectTypes = {
102621
102446
  splitter: {
102622
102447
  types: {
102623
- power: /^(\*\*)(?!=)/,
102624
- opHigh: /^(\/|\*(?!\*)|%)(?!=)/,
102448
+ opHigh: /^(\/|\*\*|\*(?!\*)|%)(?!=)/,
102625
102449
  op: /^(\+(?!(\+))|-(?!(-)))(?!=)/,
102626
102450
  comparitor: /^(<=|>=|<(?!<)|>(?!>)|!==|!=(?!=)|===|==)/,
102627
- bitwiseShift: /^(<<|>>(?!>)|>>>)(?!=)/,
102628
- bitwiseAnd: /^(&(?!&))(?!=)/,
102629
- bitwiseXor: /^(\^)(?!=)/,
102630
- bitwiseOr: /^(\|(?!\|))(?!=)/,
102631
- boolOpAnd: /^(&&)(?!=)/,
102632
- boolOpOr: /^(\|\|(?!=)|instanceof(?![\w$])|in(?![\w$]))/,
102633
- nullishCoalescing: /^\?\?(?!=)/
102451
+ boolOp: /^(&&|\|\||\?\?|instanceof(?![\w$])|in(?![\w$]))/,
102452
+ bitwise: /^(&(?!&)|\|(?!\|)|\^|<<|>>(?!>)|>>>)(?!=)/
102634
102453
  },
102635
102454
  next: ["modifier", "value", "prop", "incrementerBefore"]
102636
102455
  },
102637
102456
  inlineIf: {
102638
102457
  types: {
102639
- inlineIf: /^\?(?!\.(?!\d))/
102458
+ inlineIf: /^\?(?!\?|\.(?!\d))/
102640
102459
  },
102641
102460
  next: ["expEnd"]
102642
102461
  },
102643
102462
  assignment: {
102644
102463
  types: {
102645
- assignModify: /^(-=|\+=|\/=|\*\*=|\*=|%=|\^=|&=|\|=|>>>=|>>=|<<=|&&=|\|\|=|\?\?=)/,
102464
+ assignModify: /^(-=|\+=|\/=|\*\*=|\*=|%=|\^=|&=|\|=|>>>=|>>=|<<=)/,
102646
102465
  assign: /^(=)(?!=)/
102647
102466
  },
102648
102467
  next: ["modifier", "value", "prop", "incrementerBefore"]
@@ -102654,8 +102473,7 @@ var require_parser2 = __commonJS({
102654
102473
  expEdge: {
102655
102474
  types: {
102656
102475
  call: /^(\?\.)?[(]/,
102657
- incrementerAfter: /^(\+\+|--)/,
102658
- taggedTemplate: /^`(\d+)`/
102476
+ incrementerAfter: /^(\+\+|--)/
102659
102477
  },
102660
102478
  next: ["splitter", "expEdge", "dot", "inlineIf", "expEnd"]
102661
102479
  },
@@ -102687,7 +102505,7 @@ var require_parser2 = __commonJS({
102687
102505
  types: {
102688
102506
  createObject: /^\{/,
102689
102507
  createArray: /^\[/,
102690
- number: /^(0b[01]+(_[01]+)*|0o[0-7]+(_[0-7]+)*|0x[\da-f]+(_[\da-f]+)*|(\d+(_\d+)*(\.\d+(_\d+)*)?|\.\d+(_\d+)*))(e[+-]?\d+(_\d+)*)?(n)?(?!\d)/i,
102508
+ number: /^(0x[\da-f]+(_[\da-f]+)*|(\d+(_\d+)*(\.\d+(_\d+)*)?|\.\d+(_\d+)*))(e[+-]?\d+(_\d+)*)?(n)?(?!\d)/i,
102691
102509
  string: /^"(\d+)"/,
102692
102510
  literal: /^`(\d+)`/,
102693
102511
  regex: /^\/(\d+)\/r(?![\w$])/,
@@ -102795,8 +102613,6 @@ var require_parser2 = __commonJS({
102795
102613
  let isOneLiner = false;
102796
102614
  let i4;
102797
102615
  let lastInertedSemi = false;
102798
- let seenKeyword = false;
102799
- let skipNextWord = false;
102800
102616
  for (i4 = 0; i4 < part.length && !done; i4++) {
102801
102617
  let char = part.char(i4);
102802
102618
  if (quote === '"' || quote === "'" || quote === "`") {
@@ -102853,15 +102669,6 @@ var require_parser2 = __commonJS({
102853
102669
  if (foundNumber = aNumber.exec(sub)) {
102854
102670
  i4 += foundNumber[0].length - 1;
102855
102671
  sub = part.substring(i4).toString();
102856
- if (closingsTests) {
102857
- let found;
102858
- if (found = testMultiple(sub, closingsTests)) {
102859
- details.regRes = found;
102860
- i4++;
102861
- done = true;
102862
- break;
102863
- }
102864
- }
102865
102672
  } else if (lastChar != char) {
102866
102673
  let found = null;
102867
102674
  if (char === ";" || insertedSemis[i4 + part.start] && !isStart && !lastInertedSemi) {
@@ -102885,16 +102692,6 @@ var require_parser2 = __commonJS({
102885
102692
  }
102886
102693
  if (!done && (foundWord = wordReg.exec(sub))) {
102887
102694
  isOneLiner = true;
102888
- if (foundWord[2]) {
102889
- seenKeyword = true;
102890
- skipNextWord = true;
102891
- } else if (seenKeyword) {
102892
- if (skipNextWord) {
102893
- skipNextWord = false;
102894
- } else {
102895
- details.bodyContentAfterKeyword = true;
102896
- }
102897
- }
102898
102695
  if (foundWord[0].length > 1) {
102899
102696
  details.words.push(foundWord[1]);
102900
102697
  details.lastAnyWord = foundWord[1];
@@ -103004,18 +102801,10 @@ var require_parser2 = __commonJS({
103004
102801
  } else {
103005
102802
  const extract3 = restOfExp(constants, str, [/^:/]);
103006
102803
  key = lispify(constants, extract3, [...next, "spreadObject"]);
103007
- if (utils.isLisp(key) && key[0] === 17) {
103008
- value = NullLisp;
103009
- } else {
103010
- if (key[0] === 1) {
103011
- key = key[2];
103012
- }
103013
- if (str.length > extract3.length && str.char(extract3.length) === ":") {
103014
- value = lispify(constants, str.substring(extract3.length + 1));
103015
- } else {
103016
- value = lispify(constants, extract3, next);
103017
- }
102804
+ if (key[0] === 1) {
102805
+ key = key[2];
103018
102806
  }
102807
+ value = lispify(constants, str.substring(extract3.length + 1));
103019
102808
  }
103020
102809
  return createLisp({
103021
102810
  op: 6,
@@ -103042,72 +102831,12 @@ var require_parser2 = __commonJS({
103042
102831
  };
103043
102832
  setLispType(["inverse", "not", "negative", "positive", "typeof", "delete"], (constants, type, part, res, expect, ctx) => {
103044
102833
  const extract2 = restOfExp(constants, part.substring(res[0].length), [/^([^\s.?\w$]|\?[^.])/]);
103045
- const remainingAfterOperand = part.substring(extract2.length + res[0].length);
103046
- const remainingStr = remainingAfterOperand.trim().toString();
103047
- if (remainingStr.startsWith("**")) {
103048
- throw new SyntaxError("Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence");
103049
- }
103050
102834
  ctx.lispTree = lispify(constants, part.substring(extract2.length + res[0].length), restOfExp.next, createLisp({
103051
102835
  op: modifierTypes[type],
103052
102836
  a: ctx.lispTree,
103053
102837
  b: lispify(constants, extract2, expectTypes[expect].next)
103054
102838
  }));
103055
102839
  });
103056
- setLispType(["taggedTemplate"], (constants, type, part, res, expect, ctx) => {
103057
- const literalIndex = res[1];
103058
- const literal2 = constants.literals[parseInt(literalIndex)];
103059
- const [, templateStr, jsExprs] = literal2;
103060
- const stringParts = [];
103061
- const expressions = [];
103062
- let currentStr = "";
103063
- let i4 = 0;
103064
- while (i4 < templateStr.length) {
103065
- if (templateStr.substring(i4, i4 + 2) === "${") {
103066
- let j4 = i4 + 2;
103067
- let exprIndex = "";
103068
- let isValidPlaceholder = false;
103069
- while (j4 < templateStr.length && templateStr[j4] !== "}") {
103070
- exprIndex += templateStr[j4];
103071
- j4++;
103072
- }
103073
- if (j4 < templateStr.length && templateStr[j4] === "}" && /^\d+$/.test(exprIndex)) {
103074
- isValidPlaceholder = true;
103075
- }
103076
- if (isValidPlaceholder) {
103077
- stringParts.push(currentStr);
103078
- currentStr = "";
103079
- expressions.push(jsExprs[parseInt(exprIndex)]);
103080
- i4 = j4 + 1;
103081
- } else {
103082
- currentStr += templateStr[i4];
103083
- i4++;
103084
- }
103085
- } else {
103086
- currentStr += templateStr[i4];
103087
- i4++;
103088
- }
103089
- }
103090
- stringParts.push(currentStr);
103091
- const stringsArray = stringParts.map((str) => createLisp({
103092
- op: 2,
103093
- a: 0,
103094
- b: String(constants.strings.push(str) - 1)
103095
- }));
103096
- const stringsArrayLisp = createLisp({
103097
- op: 12,
103098
- a: createLisp({
103099
- op: 0,
103100
- a: 0,
103101
- b: 0
103102
- }),
103103
- b: stringsArray
103104
- });
103105
- ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
103106
- op: 5,
103107
- a: ctx.lispTree,
103108
- b: [stringsArrayLisp, ...expressions]
103109
- }));
103110
- });
103111
102840
  var incrementTypes = {
103112
102841
  "++$": 25,
103113
102842
  "--$": 27,
@@ -103132,7 +102861,7 @@ var require_parser2 = __commonJS({
103132
102861
  var adderTypes = {
103133
102862
  "&&": 29,
103134
102863
  "||": 30,
103135
- "??": 89,
102864
+ "??": 85,
103136
102865
  instanceof: 62,
103137
102866
  in: 63,
103138
102867
  "=": 9,
@@ -103147,12 +102876,9 @@ var require_parser2 = __commonJS({
103147
102876
  "|=": 73,
103148
102877
  ">>>=": 74,
103149
102878
  "<<=": 76,
103150
- ">>=": 75,
103151
- "&&=": 90,
103152
- "||=": 91,
103153
- "??=": 92
102879
+ ">>=": 75
103154
102880
  };
103155
- setLispType(["assign", "assignModify", "nullishCoalescing"], (constants, type, part, res, expect, ctx) => {
102881
+ setLispType(["assign", "assignModify", "boolOp"], (constants, type, part, res, expect, ctx) => {
103156
102882
  ctx.lispTree = createLisp({
103157
102883
  op: adderTypes[res[0]],
103158
102884
  a: ctx.lispTree,
@@ -103179,46 +102905,20 @@ var require_parser2 = __commonJS({
103179
102905
  "/": 48,
103180
102906
  "**": 49,
103181
102907
  "*": 50,
103182
- "%": 51,
103183
- "&&": 29,
103184
- "||": 30,
103185
- instanceof: 62,
103186
- in: 63
103187
- };
103188
- setLispType([
103189
- "power",
103190
- "opHigh",
103191
- "op",
103192
- "comparitor",
103193
- "bitwiseShift",
103194
- "bitwiseAnd",
103195
- "bitwiseXor",
103196
- "bitwiseOr",
103197
- "boolOpAnd",
103198
- "boolOpOr"
103199
- ], (constants, type, part, res, expect, ctx) => {
102908
+ "%": 51
102909
+ };
102910
+ setLispType(["opHigh", "op", "comparitor", "bitwise"], (constants, type, part, res, expect, ctx) => {
103200
102911
  const next = [expectTypes.inlineIf.types.inlineIf, inlineIfElse];
103201
102912
  switch (type) {
103202
- case "power":
103203
- break;
103204
102913
  case "opHigh":
103205
102914
  next.push(expectTypes.splitter.types.opHigh);
103206
102915
  case "op":
103207
102916
  next.push(expectTypes.splitter.types.op);
103208
102917
  case "comparitor":
103209
102918
  next.push(expectTypes.splitter.types.comparitor);
103210
- case "bitwiseShift":
103211
- next.push(expectTypes.splitter.types.bitwiseShift);
103212
- case "bitwiseAnd":
103213
- next.push(expectTypes.splitter.types.bitwiseAnd);
103214
- case "bitwiseXor":
103215
- next.push(expectTypes.splitter.types.bitwiseXor);
103216
- case "bitwiseOr":
103217
- next.push(expectTypes.splitter.types.bitwiseOr);
103218
- case "boolOpAnd":
103219
- next.push(expectTypes.splitter.types.boolOpAnd);
103220
- case "boolOpOr":
103221
- next.push(expectTypes.splitter.types.boolOpOr);
102919
+ case "bitwise":
102920
+ next.push(expectTypes.splitter.types.bitwise);
102921
+ next.push(expectTypes.splitter.types.boolOp);
103222
102922
  }
103223
102923
  const extract2 = restOfExp(constants, part.substring(res[0].length), next);
103224
102924
  ctx.lispTree = lispify(constants, part.substring(extract2.length + res[0].length), restOfExp.next, createLisp({
@@ -103392,11 +103092,7 @@ var require_parser2 = __commonJS({
103392
103092
  prop = matches[0];
103393
103093
  index = prop.length + res[0].length;
103394
103094
  } else {
103395
- throw new SyntaxError("Hanging dot");
103396
- }
103397
- } else {
103398
- if (utils.reservedWords.has(prop) && prop !== "this") {
103399
- throw new SyntaxError(`Unexpected token '${prop}'`);
103095
+ throw new SyntaxError("Hanging dot");
103400
103096
  }
103401
103097
  }
103402
103098
  ctx.lispTree = lispify(constants, part.substring(index), expectTypes[expect].next, createLisp({
@@ -103421,14 +103117,14 @@ var require_parser2 = __commonJS({
103421
103117
  });
103422
103118
  setLispType(["number", "boolean", "null", "und", "NaN", "Infinity"], (constants, type, part, res, expect, ctx) => {
103423
103119
  ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
103424
- op: type === "number" ? res[12] ? 83 : 7 : 35,
103120
+ op: type === "number" ? res[10] ? 83 : 7 : 35,
103425
103121
  a: 0,
103426
- b: res[12] ? res[1] : res[0]
103122
+ b: res[10] ? res[1] : res[0]
103427
103123
  }));
103428
103124
  });
103429
103125
  setLispType(["string", "literal", "regex"], (constants, type, part, res, expect, ctx) => {
103430
103126
  ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
103431
- op: type === "string" ? 2 : type === "literal" ? 84 : 85,
103127
+ op: type === "string" ? 2 : type === "literal" ? 84 : 86,
103432
103128
  a: 0,
103433
103129
  b: res[1]
103434
103130
  }));
@@ -103453,7 +103149,7 @@ var require_parser2 = __commonJS({
103453
103149
  const isArrow = type !== "function" && type !== "inlineFunction";
103454
103150
  const isReturn = isArrow && !res[res.length - 1];
103455
103151
  const argPos = isArrow ? 2 : 3;
103456
- const isAsync2 = res[1] ? 88 : 0;
103152
+ const isAsync2 = res[1] ? 89 : 0;
103457
103153
  const args = res[argPos] ? res[argPos].replace(/\s+/g, "").split(/,/g) : [];
103458
103154
  if (!isArrow) {
103459
103155
  args.unshift((res[2] || "").trimStart());
@@ -103467,11 +103163,6 @@ var require_parser2 = __commonJS({
103467
103163
  });
103468
103164
  const f4 = restOfExp(constants, part.substring(res[0].length), !isReturn ? [/^}/] : [/^[,)}\]]/, semiColon]);
103469
103165
  const func = isReturn ? "return " + f4 : f4.toString();
103470
- args.forEach((arg) => {
103471
- if (utils.reservedWords.has(arg.replace(/^\.\.\./, ""))) {
103472
- throw new SyntaxError(`Unexpected token '${arg}'`);
103473
- }
103474
- });
103475
103166
  ctx.lispTree = lispify(constants, part.substring(res[0].length + func.length + 1), expectTypes[expect].next, createLisp({
103476
103167
  op: isArrow ? 11 : type === "function" ? 37 : 10,
103477
103168
  a: [isAsync2, ...args],
@@ -103481,13 +103172,13 @@ var require_parser2 = __commonJS({
103481
103172
  var iteratorRegex = /^((let|var|const)\s+)?\s*([a-zA-Z$_][a-zA-Z\d$_]*)\s+(in|of)(?![\w$])/;
103482
103173
  setLispType(["for", "do", "while"], (constants, type, part, res, expect, ctx) => {
103483
103174
  let i4 = 0;
103484
- let startStep = 88;
103175
+ let startStep = 89;
103485
103176
  let startInternal = [];
103486
103177
  let getIterator = 0;
103487
103178
  let beforeStep = 0;
103488
- let checkFirst = 88;
103179
+ let checkFirst = 89;
103489
103180
  let condition;
103490
- let step = 88;
103181
+ let step = 89;
103491
103182
  let body;
103492
103183
  switch (type) {
103493
103184
  case "while": {
@@ -103567,7 +103258,7 @@ var require_parser2 = __commonJS({
103567
103258
  });
103568
103259
  setLispType(["loopAction"], (constants, type, part, res, expect, ctx) => {
103569
103260
  ctx.lispTree = createLisp({
103570
- op: 86,
103261
+ op: 87,
103571
103262
  a: res[1],
103572
103263
  b: 0
103573
103264
  });
@@ -103582,7 +103273,7 @@ var require_parser2 = __commonJS({
103582
103273
  let offset2 = 0;
103583
103274
  if (catchRes[1].startsWith("catch")) {
103584
103275
  catchRes = catchReg.exec(part.substring(res[0].length + body.length + 1).toString());
103585
- exception = catchRes[3] || "";
103276
+ exception = catchRes[2];
103586
103277
  catchBody = restOfExp(constants, part.substring(res[0].length + body.length + 1 + catchRes[0].length), [], "{");
103587
103278
  offset2 = res[0].length + body.length + 1 + catchRes[0].length + catchBody.length + 1;
103588
103279
  if ((catchRes = catchReg.exec(part.substring(offset2).toString())) && catchRes[1].startsWith("finally")) {
@@ -103605,7 +103296,7 @@ var require_parser2 = __commonJS({
103605
103296
  setLispType(["void", "await"], (constants, type, part, res, expect, ctx) => {
103606
103297
  const extract2 = restOfExp(constants, part.substring(res[0].length), [/^([^\s.?\w$]|\?[^.])/]);
103607
103298
  ctx.lispTree = lispify(constants, part.substring(res[0].length + extract2.length), expectTypes[expect].next, createLisp({
103608
- op: type === "void" ? 87 : 44,
103299
+ op: type === "void" ? 88 : 44,
103609
103300
  a: lispify(constants, extract2),
103610
103301
  b: 0
103611
103302
  }));
@@ -103822,7 +103513,6 @@ var require_parser2 = __commonJS({
103822
103513
  let rest = str;
103823
103514
  let sub = emptyString;
103824
103515
  let details = {};
103825
- let pendingDoWhile = false;
103826
103516
  const inserted = insertedSemicolons.get(str.ref) || new Array(str.ref.str.length);
103827
103517
  while ((sub = restOfExp(constants, rest, [], void 0, void 0, [colonsRegex], details)).length) {
103828
103518
  let valid = false;
@@ -103837,12 +103527,7 @@ var require_parser2 = __commonJS({
103837
103527
  const res = closingsNoInsertion.exec(rest.substring(sub.length - 1).toString());
103838
103528
  if (res) {
103839
103529
  if (res[2] === "while") {
103840
- if (details.lastWord === "do") {
103841
- valid = false;
103842
- pendingDoWhile = true;
103843
- } else {
103844
- valid = true;
103845
- }
103530
+ valid = details.lastWord !== "do";
103846
103531
  } else {
103847
103532
  valid = false;
103848
103533
  }
@@ -103850,11 +103535,8 @@ var require_parser2 = __commonJS({
103850
103535
  valid = false;
103851
103536
  }
103852
103537
  } else if (a4) {
103853
- if (pendingDoWhile && details.lastWord === "while") {
103854
- valid = true;
103855
- pendingDoWhile = false;
103856
- } else if (details.lastWord === "if" || details.lastWord === "while" || details.lastWord === "for" || details.lastWord === "else") {
103857
- valid = !!details.bodyContentAfterKeyword;
103538
+ if (details.lastWord === "if" || details.lastWord === "while" || details.lastWord === "for" || details.lastWord === "else") {
103539
+ valid = false;
103858
103540
  }
103859
103541
  }
103860
103542
  }
@@ -103916,7 +103598,6 @@ var require_parser2 = __commonJS({
103916
103598
  i4++;
103917
103599
  } else if (comment === "\n") {
103918
103600
  comment = "";
103919
- strRes.push("\n");
103920
103601
  }
103921
103602
  }
103922
103603
  } else {
@@ -104025,6 +103706,8 @@ var require_SandboxExec = __commonJS({
104025
103706
  var executor = require_executor();
104026
103707
  var utils = require_utils2();
104027
103708
  function subscribeSet(obj, name14, callback, context) {
103709
+ if (!(obj instanceof Object))
103710
+ throw new Error("Invalid subscription object, got " + (typeof obj === "object" ? "null" : typeof obj));
104028
103711
  const names = context.setSubscriptions.get(obj) || /* @__PURE__ */ new Map();
104029
103712
  context.setSubscriptions.set(obj, names);
104030
103713
  const callbacks = names.get(name14) || /* @__PURE__ */ new Set();
@@ -104050,12 +103733,6 @@ var require_SandboxExec = __commonJS({
104050
103733
  this.setSubscriptions = /* @__PURE__ */ new WeakMap();
104051
103734
  this.changeSubscriptions = /* @__PURE__ */ new WeakMap();
104052
103735
  this.sandboxFunctions = /* @__PURE__ */ new WeakMap();
104053
- this.haltSubscriptions = /* @__PURE__ */ new Set();
104054
- this.resumeSubscriptions = /* @__PURE__ */ new Set();
104055
- this.halted = false;
104056
- this.timeoutHandleCounter = 0;
104057
- this.setTimeoutHandles = /* @__PURE__ */ new Map();
104058
- this.setIntervalHandles = /* @__PURE__ */ new Map();
104059
103736
  const opt = Object.assign({
104060
103737
  audit: false,
104061
103738
  forbidFunctionCalls: false,
@@ -104068,9 +103745,7 @@ var require_SandboxExec = __commonJS({
104068
103745
  }
104069
103746
  static get SAFE_GLOBALS() {
104070
103747
  return {
104071
- globalThis,
104072
103748
  Function,
104073
- eval,
104074
103749
  console: {
104075
103750
  debug: console.debug,
104076
103751
  error: console.error,
@@ -104158,8 +103833,6 @@ var require_SandboxExec = __commonJS({
104158
103833
  map3.set(proto, /* @__PURE__ */ new Set());
104159
103834
  });
104160
103835
  map3.set(Object, /* @__PURE__ */ new Set([
104161
- "constructor",
104162
- "name",
104163
103836
  "entries",
104164
103837
  "fromEntries",
104165
103838
  "getOwnPropertyNames",
@@ -104185,56 +103858,20 @@ var require_SandboxExec = __commonJS({
104185
103858
  subscribeSetGlobal(obj, name14, callback) {
104186
103859
  return subscribeSet(obj, name14, callback, this);
104187
103860
  }
104188
- subscribeHalt(cb) {
104189
- this.haltSubscriptions.add(cb);
104190
- return {
104191
- unsubscribe: () => {
104192
- this.haltSubscriptions.delete(cb);
104193
- }
104194
- };
104195
- }
104196
- subscribeResume(cb) {
104197
- this.resumeSubscriptions.add(cb);
104198
- return {
104199
- unsubscribe: () => {
104200
- this.resumeSubscriptions.delete(cb);
104201
- }
104202
- };
104203
- }
104204
- haltExecution(haltContext) {
104205
- if (this.halted)
104206
- return;
104207
- this.halted = true;
104208
- for (const cb of this.haltSubscriptions) {
104209
- cb(haltContext);
104210
- }
104211
- }
104212
- resumeExecution() {
104213
- if (!this.halted)
104214
- return;
104215
- if (this.context.ticks.tickLimit && this.context.ticks.ticks >= this.context.ticks.tickLimit) {
104216
- throw new utils.SandboxExecutionQuotaExceededError("Cannot resume execution: tick limit exceeded");
104217
- }
104218
- this.halted = false;
104219
- for (const cb of this.resumeSubscriptions) {
104220
- cb();
104221
- }
104222
- }
104223
103861
  getContext(fn) {
104224
103862
  return this.sandboxFunctions.get(fn);
104225
103863
  }
104226
103864
  executeTree(context, scopes = []) {
104227
- return executor.executeTree(context.ctx.ticks, context, context.tree, scopes);
103865
+ return executor.executeTree({
103866
+ ticks: BigInt(0)
103867
+ }, context, context.tree, scopes);
104228
103868
  }
104229
103869
  executeTreeAsync(context, scopes = []) {
104230
- return executor.executeTreeAsync(context.ctx.ticks, context, context.tree, scopes);
103870
+ return executor.executeTreeAsync({
103871
+ ticks: BigInt(0)
103872
+ }, context, context.tree, scopes);
104231
103873
  }
104232
103874
  };
104233
- exports2.LocalScope = utils.LocalScope;
104234
- exports2.SandboxAccessError = utils.SandboxAccessError;
104235
- exports2.SandboxCapabilityError = utils.SandboxCapabilityError;
104236
- exports2.SandboxError = utils.SandboxError;
104237
- exports2.SandboxExecutionTreeError = utils.SandboxExecutionTreeError;
104238
103875
  exports2.default = SandboxExec;
104239
103876
  }
104240
103877
  });
@@ -104255,15 +103892,10 @@ var require_Sandbox = __commonJS({
104255
103892
  sandboxedEval,
104256
103893
  sandboxedSetTimeout,
104257
103894
  sandboxedSetInterval,
104258
- sandboxedClearTimeout,
104259
- sandboxedClearInterval,
104260
103895
  lispifyFunction: parser.lispifyFunction
104261
103896
  };
104262
103897
  }
104263
- function SB() {
104264
- }
104265
103898
  function sandboxFunction(context, ticks) {
104266
- SandboxFunction.prototype = SB.prototype;
104267
103899
  return SandboxFunction;
104268
103900
  function SandboxFunction(...params) {
104269
103901
  const code = params.pop() || "";
@@ -104275,10 +103907,7 @@ var require_Sandbox = __commonJS({
104275
103907
  }, void 0, "anonymous");
104276
103908
  }
104277
103909
  }
104278
- function SAF() {
104279
- }
104280
103910
  function sandboxAsyncFunction(context, ticks) {
104281
- SandboxAsyncFunction.prototype = SAF.prototype;
104282
103911
  return SandboxAsyncFunction;
104283
103912
  function SandboxAsyncFunction(...params) {
104284
103913
  const code = params.pop() || "";
@@ -104290,172 +103919,25 @@ var require_Sandbox = __commonJS({
104290
103919
  }, void 0, "anonymous");
104291
103920
  }
104292
103921
  }
104293
- function SE() {
104294
- }
104295
- function sandboxedEval(func, context) {
104296
- sandboxEval.prototype = SE.prototype;
103922
+ function sandboxedEval(func) {
104297
103923
  return sandboxEval;
104298
103924
  function sandboxEval(code) {
104299
- const parsed = parser.default(code);
104300
- const tree = wrapLastStatementInReturn(parsed.tree);
104301
- return executor.createFunction([], tree, executor.currentTicks.current, {
104302
- ...context,
104303
- constants: parsed.constants,
104304
- tree
104305
- }, void 0, "anonymous")();
104306
- }
104307
- }
104308
- function wrapLastStatementInReturn(tree) {
104309
- if (tree.length === 0)
104310
- return tree;
104311
- const newTree = [...tree];
104312
- const lastIndex = newTree.length - 1;
104313
- const lastStmt = newTree[lastIndex];
104314
- if (Array.isArray(lastStmt) && lastStmt.length >= 1) {
104315
- const op2 = lastStmt[0];
104316
- if (op2 === 8 || op2 === 46) {
104317
- return newTree;
104318
- }
104319
- const statementTypes = [
104320
- 3,
104321
- // 3
104322
- 4,
104323
- // 4
104324
- 34,
104325
- // 35
104326
- 37,
104327
- // 38
104328
- 13,
104329
- // 14
104330
- 38,
104331
- // 39
104332
- 39,
104333
- // 40
104334
- 40,
104335
- // 41
104336
- 42,
104337
- // 43
104338
- 43
104339
- // 44
104340
- ];
104341
- if (statementTypes.includes(op2)) {
104342
- return newTree;
104343
- }
104344
- newTree[lastIndex] = [8, 0, lastStmt];
104345
- }
104346
- return newTree;
104347
- }
104348
- function sST() {
104349
- }
104350
- function sandboxedSetTimeout(func, context) {
104351
- sandboxSetTimeout.prototype = sST.prototype;
104352
- return sandboxSetTimeout;
104353
- function sandboxSetTimeout(handler, timeout, ...args) {
104354
- const sandbox = context.ctx.sandbox;
104355
- const exec6 = (...a4) => {
104356
- const h4 = typeof handler === "string" ? func(handler) : handler;
104357
- haltsub.unsubscribe();
104358
- contsub.unsubscribe();
104359
- sandbox.setTimeoutHandles.delete(sandBoxhandle);
104360
- return h4(...a4);
104361
- };
104362
- const sandBoxhandle = ++sandbox.timeoutHandleCounter;
104363
- let start = Date.now();
104364
- let handle = setTimeout(exec6, timeout, ...args);
104365
- let elapsed = 0;
104366
- const haltsub = sandbox.subscribeHalt(() => {
104367
- elapsed = Date.now() - start + elapsed;
104368
- clearTimeout(handle);
104369
- });
104370
- const contsub = sandbox.subscribeResume(() => {
104371
- start = Date.now();
104372
- const remaining = Math.floor((timeout || 0) - elapsed);
104373
- handle = setTimeout(exec6, remaining, ...args);
104374
- sandbox.setTimeoutHandles.set(sandBoxhandle, {
104375
- handle,
104376
- haltsub,
104377
- contsub
104378
- });
104379
- });
104380
- sandbox.setTimeoutHandles.set(sandBoxhandle, {
104381
- handle,
104382
- haltsub,
104383
- contsub
104384
- });
104385
- return sandBoxhandle;
104386
- }
104387
- }
104388
- function sCT() {
104389
- }
104390
- function sandboxedClearTimeout(context) {
104391
- sandboxClearTimeout.prototype = sCT.prototype;
104392
- return sandboxClearTimeout;
104393
- function sandboxClearTimeout(handle) {
104394
- const sandbox = context.ctx.sandbox;
104395
- const timeoutHandle = sandbox.setTimeoutHandles.get(handle);
104396
- if (timeoutHandle) {
104397
- clearTimeout(timeoutHandle.handle);
104398
- timeoutHandle.haltsub.unsubscribe();
104399
- timeoutHandle.contsub.unsubscribe();
104400
- sandbox.setTimeoutHandles.delete(handle);
104401
- }
103925
+ return func(code)();
104402
103926
  }
104403
103927
  }
104404
- function sCI() {
104405
- }
104406
- function sandboxedClearInterval(context) {
104407
- sandboxClearInterval.prototype = sCI.prototype;
104408
- return sandboxClearInterval;
104409
- function sandboxClearInterval(handle) {
104410
- const sandbox = context.ctx.sandbox;
104411
- const intervalHandle = sandbox.setIntervalHandles.get(handle);
104412
- if (intervalHandle) {
104413
- clearInterval(intervalHandle.handle);
104414
- intervalHandle.haltsub.unsubscribe();
104415
- intervalHandle.contsub.unsubscribe();
104416
- sandbox.setIntervalHandles.delete(handle);
104417
- }
104418
- }
104419
- }
104420
- function sSI() {
103928
+ function sandboxedSetTimeout(func) {
103929
+ return function sandboxSetTimeout(handler, ...args) {
103930
+ if (typeof handler !== "string")
103931
+ return setTimeout(handler, ...args);
103932
+ return setTimeout(func(handler), ...args);
103933
+ };
104421
103934
  }
104422
- function sandboxedSetInterval(func, context) {
104423
- sandboxSetInterval.prototype = sSI.prototype;
104424
- return sandboxSetInterval;
104425
- function sandboxSetInterval(handler, timeout, ...args) {
104426
- const sandbox = context.ctx.sandbox;
104427
- const h4 = typeof handler === "string" ? func(handler) : handler;
104428
- const exec6 = (...a4) => {
104429
- start = Date.now();
104430
- elapsed = 0;
104431
- return h4(...a4);
104432
- };
104433
- const sandBoxhandle = ++sandbox.timeoutHandleCounter;
104434
- let start = Date.now();
104435
- let handle = setInterval(exec6, timeout, ...args);
104436
- let elapsed = 0;
104437
- const haltsub = sandbox.subscribeHalt(() => {
104438
- elapsed = Date.now() - start + elapsed;
104439
- clearInterval(handle);
104440
- });
104441
- const contsub = sandbox.subscribeResume(() => {
104442
- start = Date.now();
104443
- handle = setTimeout(() => {
104444
- start = Date.now();
104445
- elapsed = 0;
104446
- handle = setInterval(exec6, timeout, ...args);
104447
- exec6(...args);
104448
- }, Math.floor((timeout || 0) - elapsed), ...args);
104449
- handlObj.handle = handle;
104450
- });
104451
- const handlObj = {
104452
- handle,
104453
- haltsub,
104454
- contsub
104455
- };
104456
- sandbox.setIntervalHandles.set(sandBoxhandle, handlObj);
104457
- return sandBoxhandle;
104458
- }
103935
+ function sandboxedSetInterval(func) {
103936
+ return function sandboxSetInterval(handler, ...args) {
103937
+ if (typeof handler !== "string")
103938
+ return setInterval(handler, ...args);
103939
+ return setInterval(func(handler), ...args);
103940
+ };
104459
103941
  }
104460
103942
  var Sandbox2 = class extends SandboxExec.default {
104461
103943
  constructor(options) {
@@ -104514,11 +103996,6 @@ var require_Sandbox = __commonJS({
104514
103996
  return exec6;
104515
103997
  }
104516
103998
  };
104517
- exports2.LocalScope = utils.LocalScope;
104518
- exports2.SandboxAccessError = utils.SandboxAccessError;
104519
- exports2.SandboxCapabilityError = utils.SandboxCapabilityError;
104520
- exports2.SandboxError = utils.SandboxError;
104521
- exports2.SandboxExecutionTreeError = utils.SandboxExecutionTreeError;
104522
103999
  exports2.default = Sandbox2;
104523
104000
  }
104524
104001
  });