poe-code 13.0.0 → 13.0.2

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 (134) hide show
  1. package/README.md +26 -5
  2. package/dist/index.js +96 -7
  3. package/dist/index.js.map +4 -4
  4. package/dist/metafile.json +1 -1
  5. package/node_modules/esprima/LICENSE.BSD +21 -0
  6. package/node_modules/esprima/README.md +46 -0
  7. package/node_modules/esprima/bin/esparse.js +139 -0
  8. package/node_modules/esprima/bin/esvalidate.js +236 -0
  9. package/node_modules/esprima/dist/esprima.js +6709 -0
  10. package/node_modules/esprima/package.json +112 -0
  11. package/node_modules/extend-shallow/LICENSE +21 -0
  12. package/node_modules/extend-shallow/README.md +61 -0
  13. package/node_modules/extend-shallow/index.js +33 -0
  14. package/node_modules/extend-shallow/package.json +56 -0
  15. package/node_modules/gray-matter/LICENSE +21 -0
  16. package/node_modules/gray-matter/README.md +565 -0
  17. package/node_modules/gray-matter/gray-matter.d.ts +114 -0
  18. package/node_modules/gray-matter/index.js +228 -0
  19. package/node_modules/gray-matter/lib/defaults.js +18 -0
  20. package/node_modules/gray-matter/lib/engine.js +30 -0
  21. package/node_modules/gray-matter/lib/engines.js +54 -0
  22. package/node_modules/gray-matter/lib/excerpt.js +32 -0
  23. package/node_modules/gray-matter/lib/parse.js +13 -0
  24. package/node_modules/gray-matter/lib/stringify.js +56 -0
  25. package/node_modules/gray-matter/lib/to-file.js +43 -0
  26. package/node_modules/gray-matter/lib/utils.js +66 -0
  27. package/node_modules/gray-matter/node_modules/argparse/LICENSE +21 -0
  28. package/node_modules/gray-matter/node_modules/argparse/README.md +257 -0
  29. package/node_modules/gray-matter/node_modules/argparse/index.js +3 -0
  30. package/node_modules/gray-matter/node_modules/argparse/lib/action/append/constant.js +47 -0
  31. package/node_modules/gray-matter/node_modules/argparse/lib/action/append.js +53 -0
  32. package/node_modules/gray-matter/node_modules/argparse/lib/action/count.js +40 -0
  33. package/node_modules/gray-matter/node_modules/argparse/lib/action/help.js +47 -0
  34. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/constant.js +43 -0
  35. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/false.js +27 -0
  36. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/true.js +26 -0
  37. package/node_modules/gray-matter/node_modules/argparse/lib/action/store.js +50 -0
  38. package/node_modules/gray-matter/node_modules/argparse/lib/action/subparsers.js +149 -0
  39. package/node_modules/gray-matter/node_modules/argparse/lib/action/version.js +47 -0
  40. package/node_modules/gray-matter/node_modules/argparse/lib/action.js +146 -0
  41. package/node_modules/gray-matter/node_modules/argparse/lib/action_container.js +482 -0
  42. package/node_modules/gray-matter/node_modules/argparse/lib/argparse.js +14 -0
  43. package/node_modules/gray-matter/node_modules/argparse/lib/argument/error.js +50 -0
  44. package/node_modules/gray-matter/node_modules/argparse/lib/argument/exclusive.js +54 -0
  45. package/node_modules/gray-matter/node_modules/argparse/lib/argument/group.js +75 -0
  46. package/node_modules/gray-matter/node_modules/argparse/lib/argument_parser.js +1161 -0
  47. package/node_modules/gray-matter/node_modules/argparse/lib/const.js +21 -0
  48. package/node_modules/gray-matter/node_modules/argparse/lib/help/added_formatters.js +87 -0
  49. package/node_modules/gray-matter/node_modules/argparse/lib/help/formatter.js +795 -0
  50. package/node_modules/gray-matter/node_modules/argparse/lib/namespace.js +76 -0
  51. package/node_modules/gray-matter/node_modules/argparse/lib/utils.js +57 -0
  52. package/node_modules/gray-matter/node_modules/argparse/package.json +34 -0
  53. package/node_modules/gray-matter/node_modules/js-yaml/LICENSE +21 -0
  54. package/node_modules/gray-matter/node_modules/js-yaml/README.md +302 -0
  55. package/node_modules/gray-matter/node_modules/js-yaml/bin/js-yaml.js +132 -0
  56. package/node_modules/gray-matter/node_modules/js-yaml/dist/js-yaml.js +4011 -0
  57. package/node_modules/gray-matter/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  58. package/node_modules/gray-matter/node_modules/js-yaml/index.js +7 -0
  59. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  60. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  61. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  62. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js +1666 -0
  63. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  64. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  65. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  66. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  67. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  68. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  69. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  70. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  71. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  72. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  73. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  74. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  75. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  76. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  77. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  78. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  79. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  80. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  81. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  82. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  83. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  84. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  85. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  86. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  87. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml.js +39 -0
  88. package/node_modules/gray-matter/node_modules/js-yaml/package.json +52 -0
  89. package/node_modules/gray-matter/package.json +127 -0
  90. package/node_modules/is-extendable/LICENSE +21 -0
  91. package/node_modules/is-extendable/README.md +72 -0
  92. package/node_modules/is-extendable/index.js +13 -0
  93. package/node_modules/is-extendable/package.json +51 -0
  94. package/node_modules/kind-of/LICENSE +21 -0
  95. package/node_modules/kind-of/README.md +367 -0
  96. package/node_modules/kind-of/index.js +129 -0
  97. package/node_modules/kind-of/package.json +88 -0
  98. package/node_modules/section-matter/LICENSE +21 -0
  99. package/node_modules/section-matter/README.md +236 -0
  100. package/node_modules/section-matter/index.js +136 -0
  101. package/node_modules/section-matter/package.json +55 -0
  102. package/node_modules/sprintf-js/.npmignore +1 -0
  103. package/node_modules/sprintf-js/LICENSE +24 -0
  104. package/node_modules/sprintf-js/README.md +88 -0
  105. package/node_modules/sprintf-js/bower.json +14 -0
  106. package/node_modules/sprintf-js/demo/angular.html +20 -0
  107. package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  108. package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  109. package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  110. package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  111. package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  112. package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  113. package/node_modules/sprintf-js/gruntfile.js +36 -0
  114. package/node_modules/sprintf-js/package.json +22 -0
  115. package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  116. package/node_modules/sprintf-js/src/sprintf.js +208 -0
  117. package/node_modules/sprintf-js/test/test.js +82 -0
  118. package/node_modules/strip-bom-string/LICENSE +21 -0
  119. package/node_modules/strip-bom-string/README.md +66 -0
  120. package/node_modules/strip-bom-string/index.js +15 -0
  121. package/node_modules/strip-bom-string/package.json +60 -0
  122. package/package.json +6 -3
  123. package/packages/safe-js/dist/chunks/{chunk-EL23VF23.js → chunk-JP474LP7.js} +2 -2
  124. package/packages/safe-js/dist/chunks/{chunk-DALBPQDZ.js → chunk-RIQRHKCB.js} +82 -4
  125. package/packages/safe-js/dist/chunks/{chunk-DALBPQDZ.js.map → chunk-RIQRHKCB.js.map} +4 -4
  126. package/packages/safe-js/dist/cli.js +2 -2
  127. package/packages/safe-js/dist/core.js +1 -1
  128. package/packages/safe-js/dist/index.js +2 -2
  129. package/packages/safe-js/dist/interp/globals/object-array.js +2 -7
  130. package/packages/safe-js/dist/interp/interpreter.js +1 -0
  131. package/packages/safe-js/dist/interp/string-coercion.d.ts +3 -0
  132. package/packages/safe-js/dist/interp/string-coercion.js +89 -0
  133. package/packages/safe-js/dist/interp/values.d.ts +1 -0
  134. /package/packages/safe-js/dist/chunks/{chunk-EL23VF23.js.map → chunk-JP474LP7.js.map} +0 -0
@@ -22,7 +22,7 @@ import {
22
22
  resolveFsConfig,
23
23
  splitFrontmatter,
24
24
  withBrokenPipeGuard
25
- } from "./chunks/chunk-EL23VF23.js";
25
+ } from "./chunks/chunk-JP474LP7.js";
26
26
  import {
27
27
  Budget,
28
28
  SandboxError,
@@ -34,7 +34,7 @@ import {
34
34
  replaceErrorStack,
35
35
  restore,
36
36
  run
37
- } from "./chunks/chunk-DALBPQDZ.js";
37
+ } from "./chunks/chunk-RIQRHKCB.js";
38
38
  import "./chunks/chunk-ZRX5HT5L.js";
39
39
  import "./chunks/chunk-WVN5MMDR.js";
40
40
  import "./chunks/chunk-4YIDX44G.js";
@@ -3,7 +3,7 @@ import {
3
3
  createReplayableRandom,
4
4
  lint,
5
5
  run
6
- } from "./chunks/chunk-DALBPQDZ.js";
6
+ } from "./chunks/chunk-RIQRHKCB.js";
7
7
  import "./chunks/chunk-4YIDX44G.js";
8
8
  export {
9
9
  Budget,
@@ -29,7 +29,7 @@ import {
29
29
  runWithSpawnUsageAccumulator,
30
30
  splitFrontmatter,
31
31
  supportsSpawnMode
32
- } from "./chunks/chunk-EL23VF23.js";
32
+ } from "./chunks/chunk-JP474LP7.js";
33
33
  import {
34
34
  Budget,
35
35
  FileSnapshotBackend,
@@ -51,7 +51,7 @@ import {
51
51
  registerPendingHostCallPolicy,
52
52
  restore,
53
53
  run
54
- } from "./chunks/chunk-DALBPQDZ.js";
54
+ } from "./chunks/chunk-RIQRHKCB.js";
55
55
  import "./chunks/chunk-ZRX5HT5L.js";
56
56
  import "./chunks/chunk-WVN5MMDR.js";
57
57
  import "./chunks/chunk-4YIDX44G.js";
@@ -1,7 +1,7 @@
1
- import { sandboxErrorTypes } from "../../error/shape.js";
2
1
  import { isFloat32Array } from "../float32.js";
3
2
  import { setFloat32Member } from "./float32array.js";
4
3
  import { getSandboxIterator } from "../iteration.js";
4
+ import { sandboxString } from "../string-coercion.js";
5
5
  import { allocateProducedSandboxValue, createSandboxClosure, deepCopyToSandbox, isSandboxClosure, isSandboxMap, isSandboxPromise, isSandboxRegex, isSandboxSet } from "../values.js";
6
6
  export function createObjectArrayGlobals(options) {
7
7
  return {
@@ -91,12 +91,7 @@ export function createObjectArrayGlobals(options) {
91
91
  }),
92
92
  String: createSandboxClosure({
93
93
  sandbox: true,
94
- call: ([value]) => options.budget.allocateString(typeof value === "object" &&
95
- value !== null &&
96
- sandboxErrorTypes.has(value) &&
97
- !Object.hasOwn(value, "toString")
98
- ? Error.prototype.toString.call(value)
99
- : String(value)),
94
+ call: (args, context) => sandboxString(args.length === 0 ? "" : args[0], options.budget, context),
100
95
  name: "String",
101
96
  properties: {
102
97
  raw: createSandboxClosure({
@@ -2333,6 +2333,7 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
2333
2333
  {
2334
2334
  stack,
2335
2335
  thisValue,
2336
+ invokeClosure: (closure, argumentsList, receiver) => invokeSandboxClosure(closure, argumentsList, context, stack, span, receiver),
2336
2337
  ...(span === undefined ? {} : { span })
2337
2338
  }
2338
2339
  ]);
@@ -0,0 +1,3 @@
1
+ import type { Budget } from "./budget.js";
2
+ import { type SandboxCallContext, type SandboxValue } from "./values.js";
3
+ export declare function sandboxString(value: SandboxValue, budget: Budget, context?: SandboxCallContext, joining?: Set<object>): string | Promise<string>;
@@ -0,0 +1,89 @@
1
+ import { sandboxErrorTypes } from "../error/shape.js";
2
+ import { float32Storage, isFloat32Array } from "./float32.js";
3
+ import { isSandboxClosure, isSandboxPromise } from "./values.js";
4
+ export function sandboxString(value, budget, context, joining = new Set()) {
5
+ if (value === null || typeof value !== "object") {
6
+ if (typeof value === "function")
7
+ throw new TypeError("Expected a sandbox value.");
8
+ return budget.allocateString(String(value));
9
+ }
10
+ return stringifyObject(value, budget, context, joining);
11
+ }
12
+ async function stringifyObject(value, budget, context, joining) {
13
+ const leaveCall = budget.enterCall();
14
+ try {
15
+ budget.visitNode();
16
+ for (const name of ["toString", "valueOf"]) {
17
+ const descriptor = Object.getOwnPropertyDescriptor(value, name);
18
+ let result;
19
+ if (descriptor === undefined) {
20
+ if (name === "valueOf")
21
+ continue;
22
+ result = await defaultToString(value, budget, context, joining);
23
+ }
24
+ else {
25
+ const hook = ownDataValue(value, name);
26
+ if (!isSandboxClosure(hook))
27
+ continue;
28
+ if (context?.invokeClosure === undefined) {
29
+ throw new TypeError("String hooks require a sandbox call context.");
30
+ }
31
+ result = await context.invokeClosure(hook, [], value);
32
+ }
33
+ if (result === null || typeof result !== "object") {
34
+ return sandboxString(result, budget, context, joining);
35
+ }
36
+ }
37
+ throw new TypeError("Cannot convert object to primitive value");
38
+ }
39
+ finally {
40
+ leaveCall();
41
+ }
42
+ }
43
+ async function defaultToString(value, budget, context, joining) {
44
+ if (Array.isArray(value) || isFloat32Array(value)) {
45
+ if (Object.hasOwn(value, "join")) {
46
+ const join = ownDataValue(value, "join");
47
+ if (!isSandboxClosure(join))
48
+ return isFloat32Array(value) ? "[object Float32Array]" : "[object Array]";
49
+ if (context?.invokeClosure === undefined) {
50
+ throw new TypeError("String hooks require a sandbox call context.");
51
+ }
52
+ return context.invokeClosure(join, [], value);
53
+ }
54
+ if (joining.has(value))
55
+ return "";
56
+ joining.add(value);
57
+ try {
58
+ const length = isFloat32Array(value) ? float32Storage(value).length : value.length;
59
+ let text = "";
60
+ for (let index = 0; index < length; index++) {
61
+ budget.visitNode();
62
+ const element = ownDataValue(value, String(index));
63
+ const part = element === null || element === undefined
64
+ ? ""
65
+ : await sandboxString(element, budget, context, joining);
66
+ text = budget.allocateString(text + (index === 0 ? "" : ",") + part);
67
+ }
68
+ return text;
69
+ }
70
+ finally {
71
+ joining.delete(value);
72
+ }
73
+ }
74
+ if (sandboxErrorTypes.has(value)) {
75
+ const nameValue = ownDataValue(value, "name");
76
+ const name = nameValue === undefined ? "Error" : await sandboxString(nameValue, budget, context, joining);
77
+ const messageValue = ownDataValue(value, "message");
78
+ const message = messageValue === undefined ? "" : await sandboxString(messageValue, budget, context, joining);
79
+ return name === "" ? message : message === "" ? name : `${name}: ${message}`;
80
+ }
81
+ return isSandboxPromise(value) ? "[object Promise]" : "[object Object]";
82
+ }
83
+ function ownDataValue(value, name) {
84
+ const descriptor = Object.getOwnPropertyDescriptor(value, name);
85
+ if (descriptor !== undefined && !Object.hasOwn(descriptor, "value")) {
86
+ throw new TypeError("String conversion requires sandbox data properties.");
87
+ }
88
+ return descriptor?.value;
89
+ }
@@ -49,6 +49,7 @@ export type SandboxCallContext = {
49
49
  };
50
50
  readonly stack: readonly string[];
51
51
  readonly thisValue: SandboxValue;
52
+ readonly invokeClosure?: (closure: SandboxClosure, args: readonly SandboxValue[], thisValue: SandboxValue) => Promise<SandboxValue>;
52
53
  };
53
54
  export type SandboxClosure = {
54
55
  readonly async?: true;