@poe-platform/safe-js 0.1.802 → 0.1.804

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +4 -4
  2. package/dist/safe-js/bundled-yaml/LICENSE +13 -0
  3. package/dist/safe-js/bundled-yaml/index.js +6601 -0
  4. package/dist/safe-js/chunks/{chunk-HFRBLE6Y.js → chunk-36PBWSDR.js} +23 -11
  5. package/dist/safe-js/chunks/{chunk-CK3YK2EC.js → chunk-6AO2T2VZ.js} +1 -1
  6. package/dist/safe-js/chunks/{chunk-5RLD4TVI.js → chunk-BKNQTNHP.js} +36 -23
  7. package/dist/safe-js/chunks/{chunk-YCFOANSU.js → chunk-BYDDUKS3.js} +3 -3
  8. package/dist/safe-js/chunks/{chunk-6H5VC5W5.js → chunk-CKOGIOB3.js} +470 -464
  9. package/dist/safe-js/chunks/{chunk-XOMGWE37.js → chunk-CVPZFRCC.js} +3 -3
  10. package/dist/safe-js/chunks/{chunk-4KMUWNZD.js → chunk-ECMGBHAB.js} +13 -137
  11. package/dist/safe-js/chunks/{chunk-A3LXCGMJ.js → chunk-EQUBWQJN.js} +57 -34
  12. package/dist/safe-js/chunks/{chunk-QRWRR6IA.js → chunk-JMDWLOJV.js} +26 -3
  13. package/dist/safe-js/chunks/{chunk-3NFTBEZR.js → chunk-JQ5QJV5Q.js} +2 -2
  14. package/dist/safe-js/chunks/{chunk-MMN3IESA.js → chunk-KMBCLXER.js} +1 -1
  15. package/dist/safe-js/chunks/{chunk-PMOXSLM5.js → chunk-MJH73KJI.js} +2 -2
  16. package/dist/safe-js/chunks/{chunk-IB6WAQAE.js → chunk-P66QKVQC.js} +3 -3
  17. package/dist/safe-js/chunks/{chunk-HPHCQNFV.js → chunk-RPGCF4KE.js} +130 -3
  18. package/dist/safe-js/chunks/{chunk-F6Y734YA.js → chunk-SIR35W6T.js} +5 -5
  19. package/dist/safe-js/chunks/{chunk-7THYP46K.js → chunk-SMGNJNDU.js} +1 -1
  20. package/dist/safe-js/chunks/{chunk-XV5OYKND.js → chunk-VLRTLEDI.js} +2 -2
  21. package/dist/safe-js/chunks/{chunk-JCHJGIQA.js → chunk-VVOPJZRG.js} +2 -0
  22. package/dist/safe-js/chunks/{cli-runtime-L4IABN2W.js → cli-runtime-A353G7DR.js} +15 -15
  23. package/dist/safe-js/chunks/{dump-KUPBSXSL.js → dump-KQZFULX2.js} +4 -4
  24. package/dist/safe-js/chunks/harness-XT6K6X67.js +10 -0
  25. package/dist/safe-js/chunks/mcp-VWE444VD.js +11 -0
  26. package/dist/safe-js/chunks/migration-file-NSKXOMAO.js +14 -0
  27. package/dist/safe-js/chunks/restore-SHPORPY4.js +13 -0
  28. package/dist/safe-js/chunks/run-FQOSICOT.js +19 -0
  29. package/dist/safe-js/chunks/{runtime-modules-MGSXY4BN.js → runtime-modules-DBRXXRND.js} +4 -4
  30. package/dist/safe-js/chunks/{source-files-BSDM22Y2.js → source-files-A2WSOO6G.js} +3 -3
  31. package/dist/safe-js/cli.js +2 -2
  32. package/dist/safe-js/core.d.ts +19 -0
  33. package/dist/safe-js/core.js +39 -15
  34. package/dist/safe-js/error/format.d.ts +3 -0
  35. package/dist/safe-js/index.d.ts +1 -12
  36. package/dist/safe-js/index.js +30 -39
  37. package/dist/safe-js/interp/host-call.d.ts +1 -0
  38. package/dist/safe-js/interp/interpreter.d.ts +1 -3
  39. package/dist/safe-js/modules/fs.js +5 -5
  40. package/dist/safe-js/platform/node.d.ts +1 -0
  41. package/dist/safe-js/platform/node.js +1 -0
  42. package/dist/safe-js/platform/workerd.d.ts +1 -0
  43. package/dist/safe-js/platform/workerd.js +2 -0
  44. package/dist/safe-js/portable/chunks/{chunk-XCTU25SU.js → chunk-NLGXLZCK.js} +1 -1
  45. package/dist/safe-js/portable/chunks/{chunk-2FNMGWDK.js → chunk-SRMMDXD3.js} +127 -91
  46. package/dist/safe-js/portable/chunks/{chunk-H5X3T5VP.js → chunk-W6MZOTYR.js} +2 -0
  47. package/dist/safe-js/portable/chunks/{source-files-CVU252FB.js → source-files-AEDWESAJ.js} +2 -2
  48. package/dist/safe-js/portable/core.js +467 -249
  49. package/dist/safe-js/portable/modules/fs.js +2 -2
  50. package/dist/safe-js/workerd.js +57987 -57738
  51. package/package.json +6 -5
  52. package/dist/safe-js/chunks/harness-3DDUS3RY.js +0 -10
  53. package/dist/safe-js/chunks/mcp-5TMFK3UE.js +0 -11
  54. package/dist/safe-js/chunks/migration-file-4CYSJ6LO.js +0 -14
  55. package/dist/safe-js/chunks/restore-GDHBT5ZD.js +0 -13
  56. package/dist/safe-js/chunks/run-M6N5KCPF.js +0 -19
  57. package/dist/safe-js/node-unavailable.d.ts +0 -1
@@ -33,7 +33,7 @@ import {
33
33
  templateRealms,
34
34
  types,
35
35
  yieldToHost
36
- } from "./chunk-H5X3T5VP.js";
36
+ } from "./chunk-W6MZOTYR.js";
37
37
 
38
38
  // packages/safe-js/src/modules/fs.ts
39
39
  import { createFsBridge } from "@poe-platform/safe-fs/core";
@@ -8772,49 +8772,72 @@ var Parser = class {
8772
8772
  }
8773
8773
  parseIfStatement() {
8774
8774
  const pending = [];
8775
- let entered = 0;
8775
+ const initialDepth = this.ifStatementDepth;
8776
+ const initialScopes = this.scopes.length;
8777
+ let result;
8776
8778
  try {
8777
8779
  for (; ; ) {
8778
- if (this.ifStatementDepth >= (this.compilation?.owner?.budget.limits.maxCallDepth ?? Infinity)) {
8779
- const token2 = this.currentToken();
8780
- throw new Error(
8781
- `If statement nesting limit exceeded at line ${token2.start.line}, column ${token2.start.column}.`
8782
- );
8780
+ if (result === void 0) {
8781
+ const token = this.currentToken();
8782
+ if (token.type === "keyword" && token.value === "if") {
8783
+ if (this.ifStatementDepth >= (this.compilation?.owner?.budget.limits.maxCallDepth ?? Infinity))
8784
+ throw new Error(`If statement nesting limit exceeded at line ${token.start.line}, column ${token.start.column}.`);
8785
+ this.ifStatementDepth++;
8786
+ this.index++;
8787
+ this.expectPunctuator("(");
8788
+ const test = this.parseExpression({ allowSequence: true }).node;
8789
+ this.expectPunctuator(")");
8790
+ pending.push({ kind: "if", token, test });
8791
+ continue;
8792
+ }
8793
+ if (token.type === "punctuator" && token.value === "{") {
8794
+ this.index++;
8795
+ this.scopes.push(/* @__PURE__ */ new Map());
8796
+ pending.push({ kind: "block", token, body: [] });
8797
+ } else {
8798
+ result = pending.at(-1)?.kind === "block" ? this.parseStatement() : this.parseIfClause();
8799
+ }
8783
8800
  }
8784
- this.ifStatementDepth++;
8785
- entered++;
8786
- const token = this.expectKeyword("if");
8787
- this.expectPunctuator("(");
8788
- const test = this.parseExpression({ allowSequence: true }).node;
8789
- this.expectPunctuator(")");
8790
- const consequent = this.parseIfClause();
8791
- const hasElse = this.consumeKeyword("else") !== void 0;
8792
- if (hasElse && this.currentToken().type === "keyword" && this.currentToken().value === "if") {
8793
- pending.push({ token, test, consequent });
8801
+ const frame = pending.at(-1);
8802
+ if (frame === void 0) return result;
8803
+ if (frame.kind === "block") {
8804
+ if (result !== void 0) {
8805
+ frame.body.push(result);
8806
+ while (result.type !== "EmptyStatement" && this.consumePunctuator(";") !== void 0) {
8807
+ }
8808
+ result = void 0;
8809
+ }
8810
+ if (this.consumePunctuator("}") === void 0) {
8811
+ if (this.currentToken().type === "eof")
8812
+ throw new Error(`Unterminated block at line ${frame.token.start.line}, column ${frame.token.start.column}.`);
8813
+ continue;
8814
+ }
8815
+ pending.pop();
8816
+ this.scopes.pop();
8817
+ result = { type: "BlockStatement", body: frame.body, span: createSpan2(frame.token.start, this.previousToken().end) };
8794
8818
  continue;
8795
8819
  }
8796
- const alternate = hasElse ? this.parseIfClause() : void 0;
8797
- let result = {
8820
+ if (frame.consequent === void 0) {
8821
+ frame.consequent = result;
8822
+ if (this.consumeKeyword("else") !== void 0) {
8823
+ result = void 0;
8824
+ continue;
8825
+ }
8826
+ result = void 0;
8827
+ }
8828
+ pending.pop();
8829
+ this.ifStatementDepth--;
8830
+ result = {
8798
8831
  type: "IfStatement",
8799
- test,
8800
- consequent,
8801
- alternate,
8802
- span: createSpan2(token.start, alternate?.span.end ?? consequent.span.end)
8832
+ test: frame.test,
8833
+ consequent: frame.consequent,
8834
+ alternate: result,
8835
+ span: createSpan2(frame.token.start, result?.span.end ?? frame.consequent.span.end)
8803
8836
  };
8804
- while (pending.length > 0) {
8805
- const parent = pending.pop();
8806
- result = {
8807
- type: "IfStatement",
8808
- test: parent.test,
8809
- consequent: parent.consequent,
8810
- alternate: result,
8811
- span: createSpan2(parent.token.start, result.span.end)
8812
- };
8813
- }
8814
- return result;
8815
8837
  }
8816
8838
  } finally {
8817
- this.ifStatementDepth -= entered;
8839
+ this.ifStatementDepth = initialDepth;
8840
+ this.scopes.length = initialScopes;
8818
8841
  }
8819
8842
  }
8820
8843
  parseSwitchStatement() {
@@ -16341,7 +16364,9 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
16341
16364
  }
16342
16365
  });
16343
16366
  const value = "hasValue" in result && result.hasValue ? result.value : void 0;
16344
- reconcileCompiledValues(context.budget, [...scope.retainedDataRoots(), value], compilation, parent, [value]);
16367
+ if (context.budget.limits.dataSize !== void 0 || compilation.tickets.size > 0) {
16368
+ reconcileCompiledValues(context.budget, [...scope.retainedDataRoots(), value], compilation, parent, [value]);
16369
+ }
16345
16370
  if (result.kind === "error") throw result.error;
16346
16371
  if (result.kind === "throw") throw result.value;
16347
16372
  return value;
@@ -16590,13 +16615,15 @@ async function executeClosure(node, args, thisValue, context, evaluateNode2) {
16590
16615
  scope
16591
16616
  });
16592
16617
  const value = "hasValue" in result && result.hasValue ? result.value : void 0;
16593
- reconcileCompiledValues(
16594
- context.budget,
16595
- [...scope.retainedDataRoots(), value],
16596
- compilation,
16597
- parent,
16598
- [value]
16599
- );
16618
+ if (context.budget.limits.dataSize !== void 0 || compilation.tickets.size > 0) {
16619
+ reconcileCompiledValues(
16620
+ context.budget,
16621
+ [...scope.retainedDataRoots(), value],
16622
+ compilation,
16623
+ parent,
16624
+ [value]
16625
+ );
16626
+ }
16600
16627
  if (result.kind === "error") {
16601
16628
  throw result.error;
16602
16629
  }
@@ -29488,7 +29515,6 @@ async function evaluateNode(node, context, onReference) {
29488
29515
  const evaluationContext = compilation === void 0 ? context : {
29489
29516
  ...context,
29490
29517
  compilation,
29491
- deferDataScans: context.deferDataScans || node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement",
29492
29518
  get generatorResume() {
29493
29519
  return context.generatorResume;
29494
29520
  },
@@ -29498,16 +29524,17 @@ async function evaluateNode(node, context, onReference) {
29498
29524
  };
29499
29525
  try {
29500
29526
  const result = node.type === "Identifier" && onReference !== void 0 ? await evaluateIdentifier(node, evaluationContext, onReference) : await handler(node, evaluationContext);
29501
- if (!context.deferDataScans || context.budget.limits.dataSize !== void 0 || (compilation?.tickets.size ?? 0) > 0) {
29502
- reconcileDataBudget(
29503
- context.budget,
29504
- context.stats,
29505
- context.scope,
29506
- "hasValue" in result && result.hasValue ? result.value : void 0,
29507
- compilation,
29508
- context.compilation
29509
- );
29510
- }
29527
+ const transient = "hasValue" in result && result.hasValue ? result.value : void 0;
29528
+ reconcileDataBudget(
29529
+ context.budget,
29530
+ context.stats,
29531
+ context.scope,
29532
+ transient,
29533
+ compilation,
29534
+ context.compilation,
29535
+ true,
29536
+ handler === evaluatePrimitiveLiteral ? typeof transient === "string" ? transient.length : 8 : void 0
29537
+ );
29511
29538
  if (result.kind === "break" && result.label !== void 0 && "labels" in node && node.labels?.includes(result.label))
29512
29539
  return { kind: "normal", hasValue: context.evalCompletion === true && result.hasValue, value: context.evalCompletion ? result.value : void 0 };
29513
29540
  return result;
@@ -29532,14 +29559,20 @@ async function evaluateNode(node, context, onReference) {
29532
29559
  context.scope,
29533
29560
  completion.value,
29534
29561
  compilation,
29535
- context.compilation
29562
+ context.compilation,
29563
+ true
29536
29564
  );
29537
29565
  return completion;
29538
29566
  } finally {
29539
29567
  compilation?.dispose();
29540
29568
  }
29541
29569
  }
29542
- function reconcileDataBudget(budget, stats, scope, transient, compilation, parent) {
29570
+ function reconcileDataBudget(budget, stats, scope, transient, compilation, parent, nodeCheckpoint = false, growth) {
29571
+ if (nodeCheckpoint && (compilation?.tickets.size ?? 0) === 0) {
29572
+ const limit = budget.limits.dataSize;
29573
+ if (limit === void 0 || limit === Infinity) return;
29574
+ if (growth !== void 0 && budget.currentDataSize + growth <= limit) return;
29575
+ }
29543
29576
  reconcileCompiledValues(
29544
29577
  budget,
29545
29578
  [...scope.retainedDataRoots(), transient],
@@ -51275,6 +51308,9 @@ var HostCallJournal = class {
51275
51308
  ...outcome === void 0 ? {} : { outcome: copyOutcome(outcome) }
51276
51309
  }));
51277
51310
  }
51311
+ inputPromiseOrder() {
51312
+ return this.records.filter((record5) => record5.moduleId === "<inputs>").map((record5) => record5.operation);
51313
+ }
51278
51314
  dispose() {
51279
51315
  this.disposed = true;
51280
51316
  for (const cancel of this.pendingReconciliations) cancel();
@@ -58512,30 +58548,20 @@ function isObjectLike2(value) {
58512
58548
  }
58513
58549
 
58514
58550
  export {
58515
- admitNativePromiseProperties,
58516
- ParseError,
58517
- formatParseError,
58518
58551
  functionSources,
58519
58552
  hoistedVarDeclarations,
58520
58553
  CompileScope,
58521
58554
  tokenize,
58522
58555
  collectComments,
58556
+ ParseError,
58557
+ formatParseError,
58523
58558
  DisallowedSyntaxError,
58524
58559
  parse,
58525
58560
  parseModule,
58526
58561
  parseSourceModule,
58527
58562
  parseExecutableModule,
58528
58563
  findRegexLiteral,
58529
- numericTypedArrayConstructors,
58530
- SandboxJobQueue,
58531
- attachExecutionControl,
58532
- runAsyncPrefix,
58533
- suspendJob,
58534
- denyGuestStringCompilation,
58535
- isSandboxArrayBuffer,
58536
- arrayBufferLength,
58537
- arrayBufferDetached,
58538
- arrayBufferOptions,
58564
+ createEvalSource,
58539
58565
  getActiveOtelSpan,
58540
58566
  activateOtelSink,
58541
58567
  safeAddEvent,
@@ -58548,7 +58574,6 @@ export {
58548
58574
  runResources,
58549
58575
  retainValues,
58550
58576
  withRunResources,
58551
- getRealmGlobalObject,
58552
58577
  readDataRecord,
58553
58578
  readStringList,
58554
58579
  defineExtension,
@@ -58565,27 +58590,33 @@ export {
58565
58590
  setHostObjectPrototype,
58566
58591
  hostObjectPrototypeRoot,
58567
58592
  hostObjectGuestRoot,
58593
+ isSandboxArrayBuffer,
58594
+ arrayBufferLength,
58595
+ arrayBufferDetached,
58596
+ arrayBufferOptions,
58597
+ numericTypedArrayConstructors,
58568
58598
  releaseObjectPrototype,
58569
58599
  setSandboxPrototype,
58570
58600
  isSandboxModuleNamespace,
58571
58601
  createModuleNamespace,
58572
58602
  callGuestProxy,
58573
58603
  invokeBuiltinClosure,
58604
+ SandboxJobQueue,
58605
+ attachExecutionControl,
58606
+ runAsyncPrefix,
58607
+ suspendJob,
58574
58608
  createSandboxPromiseRejectionTracker,
58575
58609
  observeSandboxPromise,
58576
58610
  withSandboxPromiseRejectionTracker,
58577
- ownSerializableSymbolKeys,
58578
- createEvalSource,
58579
- sandboxGetProperty,
58611
+ PromiseReplay,
58612
+ promiseReplayContext,
58613
+ denyGuestStringCompilation,
58580
58614
  enterRunningState,
58581
58615
  enterSnapshotRun,
58582
58616
  assertSnapshotInactive,
58583
- withCancellationSignal,
58584
- wrapCancelableBindings,
58585
- awaitSandboxValue,
58586
- awaitWithSignal,
58587
- consumeSettledHostCall,
58588
58617
  Scope,
58618
+ admitNativePromiseProperties,
58619
+ ownSerializableSymbolKeys,
58589
58620
  SnapshotNotReadyError,
58590
58621
  MissingReplayCapabilityError,
58591
58622
  createReplayEncodingContext,
@@ -58602,19 +58633,12 @@ export {
58602
58633
  resolveModuleImports,
58603
58634
  attachSourceLoader,
58604
58635
  interpret,
58605
- createSeededRandom,
58606
- createBuiltinBindings,
58607
- validateGuestHeapSource,
58608
- DUMP_FORMAT_VERSION,
58609
- inMemoryRunSnapshots,
58610
- EXECUTION_SEMANTICS,
58611
- serializeSafeJSSnapshot,
58612
- SnapshotValidationError,
58613
- validateSnapshotData,
58614
- validateDumpEnvelope,
58615
- validateRuntimeSnapshotDescriptors,
58616
- PromiseReplay,
58617
- promiseReplayContext,
58636
+ sandboxGetProperty,
58637
+ consumeSettledHostCall,
58638
+ withCancellationSignal,
58639
+ wrapCancelableBindings,
58640
+ awaitSandboxValue,
58641
+ awaitWithSignal,
58618
58642
  HostCallJournal,
58619
58643
  promiseProperties,
58620
58644
  createSandboxClosure,
@@ -58627,6 +58651,18 @@ export {
58627
58651
  reconcileCompiledValues,
58628
58652
  deepCopyFromSandbox,
58629
58653
  guestProxyStates,
58654
+ getRealmGlobalObject,
58655
+ DUMP_FORMAT_VERSION,
58656
+ inMemoryRunSnapshots,
58657
+ EXECUTION_SEMANTICS,
58658
+ serializeSafeJSSnapshot,
58659
+ createSeededRandom,
58660
+ createBuiltinBindings,
58661
+ SnapshotValidationError,
58662
+ validateSnapshotData,
58663
+ validateDumpEnvelope,
58664
+ validateRuntimeSnapshotDescriptors,
58665
+ validateGuestHeapSource,
58630
58666
  fsCodec,
58631
58667
  getOwnErrorCode,
58632
58668
  hasOwnErrorCode,
@@ -845,6 +845,7 @@ var accessDeniedSystemError = [-13, "permission denied"];
845
845
  var yieldToHost = () => new Promise((resolve2) => setTimeout(resolve2, 0));
846
846
  var hostCwd = () => "/";
847
847
  var hostPlatform = "workerd";
848
+ var hostEnv = () => ({});
848
849
  var fsConstants = { F_OK: 0, R_OK: 4, W_OK: 2, X_OK: 1, COPYFILE_EXCL: 1 };
849
850
  var hostFs = new Proxy({}, {
850
851
  get() {
@@ -896,6 +897,7 @@ export {
896
897
  accessDeniedSystemError,
897
898
  yieldToHost,
898
899
  hostPlatform,
900
+ hostEnv,
899
901
  fsConstants,
900
902
  hostFs,
901
903
  inspect,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createRootedSourceResolver
3
- } from "./chunk-XCTU25SU.js";
4
- import "./chunk-H5X3T5VP.js";
3
+ } from "./chunk-NLGXLZCK.js";
4
+ import "./chunk-W6MZOTYR.js";
5
5
  export {
6
6
  createRootedSourceResolver
7
7
  };