poe-code 10.0.4 → 11.0.0

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/dist/index.js CHANGED
@@ -136587,7 +136587,7 @@ var init_dump_format = __esm({
136587
136587
  init_arguments();
136588
136588
  init_arguments2();
136589
136589
  DUMP_FORMAT_VERSION = 1;
136590
- EXECUTION_SEMANTICS = "jobs-v5";
136590
+ EXECUTION_SEMANTICS = "jobs-v6";
136591
136591
  SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
136592
136592
  }
136593
136593
  });
@@ -136862,9 +136862,6 @@ function validateGenericValue(value, path191, depth, state) {
136862
136862
  if (typeof value === "string") {
136863
136863
  requireString2(value, path191, state.limits);
136864
136864
  state.dataSize += value.length;
136865
- } else if (typeof value === "number") {
136866
- if (Number.isInteger(value) && !Number.isSafeInteger(value))
136867
- fail2("invalidValue", path191, "integer must be safe");
136868
136865
  } else if (Array.isArray(value)) {
136869
136866
  if (value.length > state.limits.maxEntries) fail2("budgetExceeded", path191, "array is too large");
136870
136867
  if (state.dataPropertiesOnly) {
@@ -140603,9 +140600,9 @@ var init_random = __esm({
140603
140600
 
140604
140601
  // packages/safejs/src/snapshot/migration.ts
140605
140602
  function validateMigrationSemantics(value) {
140606
- if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5"].includes(value))
140603
+ if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6"].includes(value))
140607
140604
  throw new TypeError(
140608
- "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v5)."
140605
+ "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v6)."
140609
140606
  );
140610
140607
  }
140611
140608
  function validateMigrationJournal(sourceHash, replay, hostCalls = []) {
@@ -144629,15 +144626,15 @@ var init_scope = __esm({
144629
144626
  throw new ReferenceError(`Cannot assign to undeclared binding '${name}'.`);
144630
144627
  }
144631
144628
  const binding = scope.#bindings.get(name);
144632
- if (binding?.kind === "const") {
144633
- throw new TypeError(`Cannot assign to const binding '${name}'.`);
144634
- }
144635
144629
  if (binding === void 0) {
144636
144630
  throw new ReferenceError(`Cannot assign to undeclared binding '${name}'.`);
144637
144631
  }
144638
144632
  if (binding.value === uninitialized) {
144639
144633
  throw new ReferenceError(`Cannot access '${name}' before initialization.`);
144640
144634
  }
144635
+ if (binding.kind === "const") {
144636
+ throw new TypeError(`Cannot assign to const binding '${name}'.`);
144637
+ }
144641
144638
  scope.#bindings.set(name, {
144642
144639
  kind: binding.kind,
144643
144640
  value
@@ -145102,39 +145099,37 @@ async function evaluateAssignmentExpression(node, context) {
145102
145099
  )
145103
145100
  };
145104
145101
  }
145105
- const binding = context.scope.lookup(node.left.name);
145106
- if (!binding.found) {
145102
+ const binding = node.operator === "=" ? void 0 : context.scope.lookup(node.left.name);
145103
+ if (binding?.found === false) {
145107
145104
  throw new ReferenceError(`Cannot assign to undeclared binding '${node.left.name}'.`);
145108
145105
  }
145109
- if (binding.kind === "const") {
145110
- throw new TypeError(`Cannot assign to const '${node.left.name}'`);
145111
- }
145112
- if (node.operator === "&&=" && !isTruthy(binding.value)) {
145106
+ const current = binding?.value;
145107
+ if (node.operator === "&&=" && !isTruthy(current)) {
145113
145108
  return {
145114
145109
  kind: "normal",
145115
145110
  hasValue: true,
145116
- value: binding.value
145111
+ value: current
145117
145112
  };
145118
145113
  }
145119
- if (node.operator === "||=" && isTruthy(binding.value)) {
145114
+ if (node.operator === "||=" && isTruthy(current)) {
145120
145115
  return {
145121
145116
  kind: "normal",
145122
145117
  hasValue: true,
145123
- value: binding.value
145118
+ value: current
145124
145119
  };
145125
145120
  }
145126
- if (node.operator === "??=" && binding.value !== null && binding.value !== void 0) {
145121
+ if (node.operator === "??=" && current !== null && current !== void 0) {
145127
145122
  return {
145128
145123
  kind: "normal",
145129
145124
  hasValue: true,
145130
- value: binding.value
145125
+ value: current
145131
145126
  };
145132
145127
  }
145133
145128
  const right = await evaluateNode2(node.right, context);
145134
145129
  if (right.kind !== "normal") {
145135
145130
  return right;
145136
145131
  }
145137
- const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : applyCompoundAssignmentOperator(node.operator, binding.value, right.value, context);
145132
+ const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
145138
145133
  context.scope.assign(node.left.name, value);
145139
145134
  return {
145140
145135
  kind: "normal",
@@ -145156,45 +145151,33 @@ async function evaluateMemberAssignmentExpression(node, context) {
145156
145151
  if (member.kind === "nullish") {
145157
145152
  throw new TypeError("Cannot assign properties of null or undefined.");
145158
145153
  }
145159
- if (isSandboxRegex(member.object)) {
145160
- if (node.operator !== "=") {
145161
- throw new TypeError("RegExp properties only support direct assignment.");
145162
- }
145163
- const right2 = await evaluateNode2(node.right, context);
145164
- if (right2.kind !== "normal") return right2;
145165
- setRegexMember(member.object, member.property, right2.value);
145166
- return { kind: "normal", hasValue: true, value: right2.value };
145167
- }
145168
- if (!isIndexableSandboxValue(member.object)) {
145169
- throw new TypeError("Assignment expressions require a sandbox object property.");
145170
- }
145171
- if (node.operator === "&&=" && !isTruthy(getMemberValue(member.object, member.property, context))) {
145154
+ const current = node.operator === "=" ? void 0 : getPropertyValue(member.object, member.property, context);
145155
+ if (node.operator === "&&=" && !isTruthy(current)) {
145172
145156
  return {
145173
145157
  kind: "normal",
145174
145158
  hasValue: true,
145175
- value: getMemberValue(member.object, member.property, context)
145159
+ value: current
145176
145160
  };
145177
145161
  }
145178
- if (node.operator === "||=" && isTruthy(getMemberValue(member.object, member.property, context))) {
145162
+ if (node.operator === "||=" && isTruthy(current)) {
145179
145163
  return {
145180
145164
  kind: "normal",
145181
145165
  hasValue: true,
145182
- value: getMemberValue(member.object, member.property, context)
145166
+ value: current
145183
145167
  };
145184
145168
  }
145185
- if (node.operator === "??=" && getMemberValue(member.object, member.property, context) !== null && getMemberValue(member.object, member.property, context) !== void 0) {
145169
+ if (node.operator === "??=" && current !== null && current !== void 0) {
145186
145170
  return {
145187
145171
  kind: "normal",
145188
145172
  hasValue: true,
145189
- value: getMemberValue(member.object, member.property, context)
145173
+ value: current
145190
145174
  };
145191
145175
  }
145192
145176
  const right = await evaluateNode2(node.right, context);
145193
145177
  if (right.kind !== "normal") {
145194
145178
  return right;
145195
145179
  }
145196
- const current = getMemberValue(member.object, member.property, context);
145197
- const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : applyCompoundAssignmentOperator(node.operator, current, right.value, context);
145180
+ const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
145198
145181
  setSandboxProperty(member.object, member.property, value);
145199
145182
  return {
145200
145183
  kind: "normal",
@@ -146161,10 +146144,7 @@ async function evaluateIdentifierUpdateExpression(node, context) {
146161
146144
  )
146162
146145
  };
146163
146146
  }
146164
- if (binding.kind === "const") {
146165
- throw new TypeError(`Cannot assign to const '${node.argument.name}'`);
146166
- }
146167
- const current = Number(binding.value);
146147
+ const current = toNumber(await toNumericPrimitive(binding.value, context));
146168
146148
  const next = node.operator === "++" ? current + 1 : current - 1;
146169
146149
  context.scope.assign(node.argument.name, next);
146170
146150
  return {
@@ -146187,10 +146167,9 @@ async function evaluateMemberUpdateExpression(node, context) {
146187
146167
  if (member.kind === "nullish") {
146188
146168
  throw new TypeError("Cannot update properties of null or undefined.");
146189
146169
  }
146190
- if (!isIndexableSandboxValue(member.object)) {
146191
- throw new TypeError("Update expressions require a sandbox object property.");
146192
- }
146193
- const current = Number(getMemberValue(member.object, member.property, context));
146170
+ const current = toNumber(
146171
+ await toNumericPrimitive(getPropertyValue(member.object, member.property, context), context)
146172
+ );
146194
146173
  const next = node.operator === "++" ? current + 1 : current - 1;
146195
146174
  setSandboxProperty(member.object, member.property, next);
146196
146175
  return {
@@ -146201,93 +146180,32 @@ async function evaluateMemberUpdateExpression(node, context) {
146201
146180
  }
146202
146181
  async function evaluateMemberExpression(node, context) {
146203
146182
  const member = await evaluateMemberAccess(node, context);
146204
- if (member.kind === "error") {
146205
- return member;
146206
- }
146207
- if (member.kind === "completion") {
146208
- return member.result;
146209
- }
146183
+ if (member.kind === "error") return member;
146184
+ if (member.kind === "completion") return member.result;
146210
146185
  if (member.kind === "nullish") {
146211
- if (node.optional) {
146212
- return {
146213
- kind: "normal",
146214
- hasValue: true,
146215
- value: void 0
146216
- };
146217
- }
146186
+ if (node.optional) return { kind: "normal", hasValue: true, value: void 0 };
146218
146187
  throw new TypeError("Cannot read properties of null or undefined.");
146219
146188
  }
146220
- if (typeof member.object === "string") {
146221
- return {
146222
- kind: "normal",
146223
- hasValue: true,
146224
- value: getStringMember(member.object, member.property, context.budget)
146225
- };
146226
- }
146227
- if (typeof member.object === "number") {
146228
- return {
146229
- kind: "normal",
146230
- hasValue: true,
146231
- value: getNumberMember(member.object, member.property, context.budget)
146232
- };
146233
- }
146234
- if (Array.isArray(member.object)) {
146235
- return {
146236
- kind: "normal",
146237
- hasValue: true,
146238
- value: getArrayMemberValue(member.object, member.property, context)
146239
- };
146240
- }
146241
- if (isSandboxMap(member.object)) {
146242
- return {
146243
- kind: "normal",
146244
- hasValue: true,
146245
- value: getMapMember(member.object, member.property, createMapMethodOptions(context))
146246
- };
146247
- }
146248
- if (isSandboxSet(member.object)) {
146249
- return {
146250
- kind: "normal",
146251
- hasValue: true,
146252
- value: getSetMember(member.object, member.property, createSetMethodOptions(context))
146253
- };
146254
- }
146255
- if (isSandboxGenerator(member.object)) {
146256
- return {
146257
- kind: "normal",
146258
- hasValue: true,
146259
- value: getGeneratorMember(member.object, member.property, context.budget)
146260
- };
146261
- }
146262
- if (isSandboxClosure(member.object)) {
146263
- return {
146264
- kind: "normal",
146265
- hasValue: true,
146266
- value: getClosureMemberValue(member.object, member.property, context)
146267
- };
146268
- }
146269
- if (isSandboxPromise(member.object)) {
146270
- return {
146271
- kind: "normal",
146272
- hasValue: true,
146273
- value: getPromiseMember(member.property, context.budget)
146274
- };
146275
- }
146276
- if (isSandboxRegex(member.object)) {
146277
- return {
146278
- kind: "normal",
146279
- hasValue: true,
146280
- value: getRegexMember(member.object, member.property)
146281
- };
146282
- }
146283
- if (!isIndexableSandboxValue(member.object)) {
146284
- throw new TypeError("Attempted to read a property from a non-object value.");
146285
- }
146286
146189
  return {
146287
146190
  kind: "normal",
146288
146191
  hasValue: true,
146289
- value: getMemberValue(member.object, member.property, context)
146290
- };
146192
+ value: getPropertyValue(member.object, member.property, context)
146193
+ };
146194
+ }
146195
+ function getPropertyValue(target, property, context) {
146196
+ if (typeof target === "string") return getStringMember(target, property, context.budget);
146197
+ if (typeof target === "number") return getNumberMember(target, property, context.budget);
146198
+ if (typeof target === "boolean") return void 0;
146199
+ if (isSandboxMap(target)) return getMapMember(target, property, createMapMethodOptions(context));
146200
+ if (isSandboxSet(target)) return getSetMember(target, property, createSetMethodOptions(context));
146201
+ if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
146202
+ if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
146203
+ if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
146204
+ if (isSandboxRegex(target)) return getRegexMember(target, property);
146205
+ if (!isIndexableSandboxValue(target)) {
146206
+ throw new TypeError("Attempted to read a property from a non-object value.");
146207
+ }
146208
+ return getMemberValue(target, property, context);
146291
146209
  }
146292
146210
  async function evaluateCallExpression(node, context) {
146293
146211
  if (node.callee.type === "MemberExpression") {
@@ -146764,7 +146682,9 @@ function applyBinaryOperator(node, left, right, context) {
146764
146682
  throw createError("UNSUPPORTED_NODE", node, "Binary operator 'in' is not supported.");
146765
146683
  }
146766
146684
  }
146767
- function applyCompoundAssignmentOperator(operator, left, right, context) {
146685
+ async function applyCompoundAssignmentOperator(operator, left, right, context) {
146686
+ left = await toNumericPrimitive(left, context);
146687
+ right = await toNumericPrimitive(right, context);
146768
146688
  switch (operator) {
146769
146689
  case "+=":
146770
146690
  return applyAdditionOperator(left, right, context);
@@ -146891,6 +146811,9 @@ async function toNumericPrimitive(value, context) {
146891
146811
  if (isIndexableSandboxValue(value)) {
146892
146812
  for (const methodName of ["valueOf", "toString"]) {
146893
146813
  const method = getMemberValue(value, methodName, context);
146814
+ if (methodName === "toString" && method === void 0 && !Object.hasOwn(value, methodName)) {
146815
+ return toString(value);
146816
+ }
146894
146817
  if (!isSandboxClosure(method)) {
146895
146818
  continue;
146896
146819
  }
@@ -146906,6 +146829,7 @@ async function toNumericPrimitive(value, context) {
146906
146829
  return result;
146907
146830
  }
146908
146831
  }
146832
+ throw new TypeError("Cannot convert object to primitive value.");
146909
146833
  }
146910
146834
  return toString(value);
146911
146835
  }
@@ -146960,17 +146884,30 @@ function getArrayMemberValue(target, property, context) {
146960
146884
  return getArrayMember(target, property, createArrayMethodOptions(context));
146961
146885
  }
146962
146886
  function setSandboxProperty(target, property, value) {
146887
+ if (isSandboxRegex(target)) {
146888
+ setRegexMember(target, property, value);
146889
+ return;
146890
+ }
146891
+ if (!isIndexableSandboxValue(target)) {
146892
+ throw new TypeError("Assignment expressions require a sandbox object property.");
146893
+ }
146894
+ const key3 = String(property);
146963
146895
  if (Array.isArray(target)) {
146964
146896
  assertCollectionMutable(target);
146965
- const key3 = String(property);
146966
146897
  if (key3 === "length" || isArrayIndexKey3(key3)) {
146967
146898
  target[key3] = value;
146968
146899
  return;
146969
146900
  }
146901
+ }
146902
+ const descriptor = Object.getOwnPropertyDescriptor(target, key3);
146903
+ if (descriptor !== void 0) {
146904
+ if (descriptor.writable !== true) {
146905
+ throw new TypeError(`Cannot assign to read only property '${key3}'.`);
146906
+ }
146907
+ Object.defineProperty(target, key3, { value });
146908
+ } else {
146970
146909
  defineSandboxProperty(target, key3, value);
146971
- return;
146972
146910
  }
146973
- defineSandboxProperty(target, String(property), value);
146974
146911
  }
146975
146912
  function deleteSandboxProperty(target, property) {
146976
146913
  if (Array.isArray(target)) {
@@ -155517,7 +155454,7 @@ var init_package2 = __esm({
155517
155454
  "package.json"() {
155518
155455
  package_default2 = {
155519
155456
  name: "poe-code",
155520
- version: "10.0.4",
155457
+ version: "11.0.0",
155521
155458
  description: "CLI tool to configure Poe API for developer workflows.",
155522
155459
  license: "MIT",
155523
155460
  type: "module",