@poe-platform/safe-js 0.1.803 → 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 (56) 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-FUXGXSZC.js → chunk-36PBWSDR.js} +8 -8
  5. package/dist/safe-js/chunks/{chunk-SN4G557J.js → chunk-6AO2T2VZ.js} +1 -1
  6. package/dist/safe-js/chunks/{chunk-ZXDUALDQ.js → chunk-BKNQTNHP.js} +33 -23
  7. package/dist/safe-js/chunks/{chunk-WEPHHJMR.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-D36FRVNN.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-ZAOSXSKI.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-WRGATIKL.js → chunk-MJH73KJI.js} +2 -2
  16. package/dist/safe-js/chunks/{chunk-UQYM4GXB.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-J565YTXP.js → chunk-SIR35W6T.js} +5 -5
  19. package/dist/safe-js/chunks/{chunk-LVTYTUF5.js → chunk-SMGNJNDU.js} +1 -1
  20. package/dist/safe-js/chunks/{chunk-6NCYOKZQ.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-QIA3QMTP.js → cli-runtime-A353G7DR.js} +15 -15
  23. package/dist/safe-js/chunks/{dump-TGI6PZKL.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-HWTUIY5J.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/interpreter.d.ts +1 -3
  38. package/dist/safe-js/modules/fs.js +5 -5
  39. package/dist/safe-js/platform/node.d.ts +1 -0
  40. package/dist/safe-js/platform/node.js +1 -0
  41. package/dist/safe-js/platform/workerd.d.ts +1 -0
  42. package/dist/safe-js/platform/workerd.js +2 -0
  43. package/dist/safe-js/portable/chunks/{chunk-XCTU25SU.js → chunk-NLGXLZCK.js} +1 -1
  44. package/dist/safe-js/portable/chunks/{chunk-BIHLWVUU.js → chunk-SRMMDXD3.js} +124 -91
  45. package/dist/safe-js/portable/chunks/{chunk-H5X3T5VP.js → chunk-W6MZOTYR.js} +2 -0
  46. package/dist/safe-js/portable/chunks/{source-files-CVU252FB.js → source-files-AEDWESAJ.js} +2 -2
  47. package/dist/safe-js/portable/core.js +452 -246
  48. package/dist/safe-js/portable/modules/fs.js +2 -2
  49. package/dist/safe-js/workerd.js +57970 -57736
  50. package/package.json +6 -5
  51. package/dist/safe-js/chunks/harness-EE3ISLJP.js +0 -10
  52. package/dist/safe-js/chunks/mcp-F5MMOZNP.js +0 -11
  53. package/dist/safe-js/chunks/migration-file-W3HZOGXV.js +0 -14
  54. package/dist/safe-js/chunks/restore-MMM4A46M.js +0 -13
  55. package/dist/safe-js/chunks/run-TKX3IFNH.js +0 -19
  56. 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],
@@ -58515,30 +58548,20 @@ function isObjectLike2(value) {
58515
58548
  }
58516
58549
 
58517
58550
  export {
58518
- admitNativePromiseProperties,
58519
- ParseError,
58520
- formatParseError,
58521
58551
  functionSources,
58522
58552
  hoistedVarDeclarations,
58523
58553
  CompileScope,
58524
58554
  tokenize,
58525
58555
  collectComments,
58556
+ ParseError,
58557
+ formatParseError,
58526
58558
  DisallowedSyntaxError,
58527
58559
  parse,
58528
58560
  parseModule,
58529
58561
  parseSourceModule,
58530
58562
  parseExecutableModule,
58531
58563
  findRegexLiteral,
58532
- numericTypedArrayConstructors,
58533
- SandboxJobQueue,
58534
- attachExecutionControl,
58535
- runAsyncPrefix,
58536
- suspendJob,
58537
- denyGuestStringCompilation,
58538
- isSandboxArrayBuffer,
58539
- arrayBufferLength,
58540
- arrayBufferDetached,
58541
- arrayBufferOptions,
58564
+ createEvalSource,
58542
58565
  getActiveOtelSpan,
58543
58566
  activateOtelSink,
58544
58567
  safeAddEvent,
@@ -58551,7 +58574,6 @@ export {
58551
58574
  runResources,
58552
58575
  retainValues,
58553
58576
  withRunResources,
58554
- getRealmGlobalObject,
58555
58577
  readDataRecord,
58556
58578
  readStringList,
58557
58579
  defineExtension,
@@ -58568,27 +58590,33 @@ export {
58568
58590
  setHostObjectPrototype,
58569
58591
  hostObjectPrototypeRoot,
58570
58592
  hostObjectGuestRoot,
58593
+ isSandboxArrayBuffer,
58594
+ arrayBufferLength,
58595
+ arrayBufferDetached,
58596
+ arrayBufferOptions,
58597
+ numericTypedArrayConstructors,
58571
58598
  releaseObjectPrototype,
58572
58599
  setSandboxPrototype,
58573
58600
  isSandboxModuleNamespace,
58574
58601
  createModuleNamespace,
58575
58602
  callGuestProxy,
58576
58603
  invokeBuiltinClosure,
58604
+ SandboxJobQueue,
58605
+ attachExecutionControl,
58606
+ runAsyncPrefix,
58607
+ suspendJob,
58577
58608
  createSandboxPromiseRejectionTracker,
58578
58609
  observeSandboxPromise,
58579
58610
  withSandboxPromiseRejectionTracker,
58580
- ownSerializableSymbolKeys,
58581
- createEvalSource,
58582
- sandboxGetProperty,
58611
+ PromiseReplay,
58612
+ promiseReplayContext,
58613
+ denyGuestStringCompilation,
58583
58614
  enterRunningState,
58584
58615
  enterSnapshotRun,
58585
58616
  assertSnapshotInactive,
58586
- withCancellationSignal,
58587
- wrapCancelableBindings,
58588
- awaitSandboxValue,
58589
- awaitWithSignal,
58590
- consumeSettledHostCall,
58591
58617
  Scope,
58618
+ admitNativePromiseProperties,
58619
+ ownSerializableSymbolKeys,
58592
58620
  SnapshotNotReadyError,
58593
58621
  MissingReplayCapabilityError,
58594
58622
  createReplayEncodingContext,
@@ -58605,19 +58633,12 @@ export {
58605
58633
  resolveModuleImports,
58606
58634
  attachSourceLoader,
58607
58635
  interpret,
58608
- createSeededRandom,
58609
- createBuiltinBindings,
58610
- validateGuestHeapSource,
58611
- DUMP_FORMAT_VERSION,
58612
- inMemoryRunSnapshots,
58613
- EXECUTION_SEMANTICS,
58614
- serializeSafeJSSnapshot,
58615
- SnapshotValidationError,
58616
- validateSnapshotData,
58617
- validateDumpEnvelope,
58618
- validateRuntimeSnapshotDescriptors,
58619
- PromiseReplay,
58620
- promiseReplayContext,
58636
+ sandboxGetProperty,
58637
+ consumeSettledHostCall,
58638
+ withCancellationSignal,
58639
+ wrapCancelableBindings,
58640
+ awaitSandboxValue,
58641
+ awaitWithSignal,
58621
58642
  HostCallJournal,
58622
58643
  promiseProperties,
58623
58644
  createSandboxClosure,
@@ -58630,6 +58651,18 @@ export {
58630
58651
  reconcileCompiledValues,
58631
58652
  deepCopyFromSandbox,
58632
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,
58633
58666
  fsCodec,
58634
58667
  getOwnErrorCode,
58635
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
  };