poe-code 12.0.6 → 12.0.8
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/README.md +37 -5
- package/dist/cli/commands/harness.js +1 -1
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +325 -259
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +79 -13
- package/packages/agent-harness/dist/loader/extract-schema.js +1 -1
- package/packages/agent-harness/dist/loader/run.d.ts +1 -1
- package/packages/agent-harness/dist/loader/run.js +1 -1
- package/packages/package-lint/dist/bundle-policy.d.ts +145 -2
- package/packages/package-lint/dist/bundle-policy.js +293 -61
- package/packages/package-lint/dist/model.d.ts +2 -1
- package/packages/package-lint/dist/model.js +8 -1
- package/packages/safe-fs/dist/bridge/filesystem.d.ts +88 -0
- package/packages/safe-fs/dist/bridge/index.d.ts +6 -0
- package/packages/safe-fs/dist/bridge/stats.d.ts +4 -0
- package/packages/safe-fs/dist/bridge/types.d.ts +75 -0
- package/packages/safe-fs/dist/bridge/values.d.ts +6 -0
- package/packages/safe-fs/dist/contracts/errors.d.ts +3 -2
- package/packages/safe-fs/dist/contracts/path.d.ts +1 -6
- package/packages/safe-fs/dist/contracts/virtual-path.d.ts +7 -0
- package/packages/safe-fs/dist/core.d.ts +11 -0
- package/packages/safe-fs/dist/fs/mount/comparison.d.ts +1 -0
- package/packages/safe-fs/dist/fs/overlay/index.d.ts +2 -1
- package/packages/safe-fs/dist/fs/readonly/index.d.ts +2 -1
- package/packages/safe-fs/dist/fs/s3/authority.d.ts +3 -9
- package/packages/safe-fs/dist/fs/s3/registry.d.ts +10 -0
- package/packages/safe-fs/dist/fs/webdav/webdav.d.ts +2 -1
- package/packages/safe-fs/dist/node/stats.d.ts +1 -4
- package/packages/safe-fs/dist/node/values.d.ts +1 -6
- package/packages/safe-fs/dist/node-host.d.ts +1 -0
- package/packages/safe-fs/dist/node-unavailable.d.ts +1 -0
- package/packages/safe-fs/dist/platform/browser.d.ts +12 -0
- package/packages/safe-fs/dist/platform/node.d.ts +13 -0
- package/packages/safe-js/dist/browser/chunks/chunk-MUKMA7ZY.js +4053 -0
- package/packages/safe-js/dist/browser/chunks/chunk-MUKMA7ZY.js.map +7 -0
- package/packages/safe-js/dist/browser/safe-fs-core.js +55 -0
- package/packages/safe-js/dist/browser/safe-fs.js +55 -0
- package/packages/safe-js/dist/chunks/chunk-F7NY24BF.js +2603 -0
- package/packages/safe-js/dist/chunks/chunk-F7NY24BF.js.map +7 -0
- package/packages/{safejs/dist/chunks/chunk-NDHGDM46.js → safe-js/dist/chunks/chunk-JGTN4U7F.js} +103 -103
- package/packages/{safejs/dist/chunks/chunk-KJSS53IH.js → safe-js/dist/chunks/chunk-PY5NKSTP.js} +28 -26
- package/packages/{safejs/dist/chunks/chunk-KJSS53IH.js.map → safe-js/dist/chunks/chunk-PY5NKSTP.js.map} +1 -1
- package/packages/{safejs/dist/chunks/chunk-B3G3JVCW.js → safe-js/dist/chunks/chunk-YBQUQPZV.js} +637 -3120
- package/packages/safe-js/dist/chunks/chunk-YBQUQPZV.js.map +7 -0
- package/packages/{safejs → safe-js}/dist/cli.js +10 -7
- package/packages/{safejs → safe-js}/dist/cli.js.map +2 -2
- package/packages/{safejs → safe-js}/dist/core.js +1 -1
- package/packages/safe-js/dist/core.js.map +7 -0
- package/packages/{safejs → safe-js}/dist/index.js +8 -7
- package/packages/{safejs → safe-js}/dist/index.js.map +1 -1
- package/packages/safe-js/dist/safe-fs-core.js +80 -0
- package/packages/safe-js/dist/safe-fs-core.js.map +7 -0
- package/packages/safe-js/dist/safe-fs-node.js +94 -0
- package/packages/safe-js/dist/safe-fs-node.js.map +7 -0
- package/packages/{safejs → safe-js}/dist/safe-fs.js +20 -18
- package/packages/safe-js/dist/safe-fs.js.map +7 -0
- package/packages/terminal-pilot/dist/commands/index.d.ts +2 -2
- package/packages/terminal-pilot/dist/commands/installer.d.ts +1 -1
- package/packages/tiny-mcp-client/dist/index.d.ts +1 -1
- package/packages/toolcraft/dist/mcp.d.ts +3 -3
- package/packages/toolcraft-codemode/dist/execute.d.ts +1 -1
- package/packages/toolcraft-codemode/dist/execute.js +1 -1
- package/packages/safejs/dist/chunks/chunk-B3G3JVCW.js.map +0 -7
- /package/packages/{safejs/dist/chunks/chunk-4YIDX44G.js.map → safe-js/dist/browser/safe-fs-core.js.map} +0 -0
- /package/packages/{safejs/dist → safe-js/dist/browser}/safe-fs.js.map +0 -0
- /package/packages/{safejs → safe-js}/dist/chunks/chunk-4YIDX44G.js +0 -0
- /package/packages/{safejs/dist/core.js.map → safe-js/dist/chunks/chunk-4YIDX44G.js.map} +0 -0
- /package/packages/{safejs/dist/chunks/chunk-NDHGDM46.js.map → safe-js/dist/chunks/chunk-JGTN4U7F.js.map} +0 -0
- /package/packages/{safejs → safe-js}/dist/cli.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/core.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/dump.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/dump.js +0 -0
- /package/packages/{safejs → safe-js}/dist/error/format.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/error/format.js +0 -0
- /package/packages/{safejs → safe-js}/dist/error/shape.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/error/shape.js +0 -0
- /package/packages/{safejs → safe-js}/dist/error-codes.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/error-codes.js +0 -0
- /package/packages/{safejs → safe-js}/dist/example-runner.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/example-runner.js +0 -0
- /package/packages/{safejs → safe-js}/dist/graph-depth.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/graph-depth.js +0 -0
- /package/packages/{safejs → safe-js}/dist/index.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/arguments.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/arguments.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/async.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/async.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/budget.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/budget.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/cancel.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/cancel.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/exceptions.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/exceptions.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/float32.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/float32.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/generator.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/generator.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/collections.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/collections.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/console-json.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/console-json.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/error.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/error.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/float32array.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/float32array.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/math.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/math.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/misc.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/misc.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/object-array.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/object-array.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/regex.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/globals/regex.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/host-bridge.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/host-bridge.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/host-call.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/host-call.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/interpreter.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/interpreter.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/iteration.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/iteration.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/jobs.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/jobs.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/array.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/array.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/collection-callback.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/collection-callback.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/function.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/function.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/generator.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/generator.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/map.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/map.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/number.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/number.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/regex.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/regex.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/set.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/set.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/string.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/methods/string.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/patterns.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/patterns.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/promise-replay.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/promise-replay.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/promise-tracker.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/promise-tracker.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/promise.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/promise.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/regex/engine.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/regex/engine.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/regex/parse.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/regex/parse.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/resources.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/resources.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/running-state.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/running-state.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/scope.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/scope.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/values.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/values.js +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/var-hoist.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/interp/var-hoist.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/index.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/index.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-async-not-needed.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-async-not-needed.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-destructure-null-default.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-destructure-null-default.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-export-import-meta.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-export-import-meta.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-floating-promise.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-floating-promise.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-frontmatter-field-unused.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-frontmatter-field-unused.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-import-cycle.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-import-cycle.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-jsdoc-type.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-jsdoc-type.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-large-literal.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-large-literal.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-missing-async.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-missing-async.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-mutating-frozen.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-mutating-frozen.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-needless-template.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-needless-template.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-shadow-global.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-shadow-global.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-unbounded-loop.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-unbounded-loop.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-unreachable.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-unreachable.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-unused-import.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS-unused-import.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS001.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS001.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS003.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS003.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS004.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS004.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS005.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS005.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS006-007.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS006-007.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS009.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS009.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS010.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS010.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS011.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS011.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS013.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS013.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS014.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS014.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS015.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/AS015.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/known-globals.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/known-globals.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/module-registry.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/rules/module-registry.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/runtime-modules.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint/runtime-modules.js +0 -0
- /package/packages/{safejs → safe-js}/dist/lint.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/lint.js +0 -0
- /package/packages/{safejs → safe-js}/dist/loader/extract-block.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/loader/extract-block.js +0 -0
- /package/packages/{safejs → safe-js}/dist/loader/find-exported.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/loader/find-exported.js +0 -0
- /package/packages/{safejs → safe-js}/dist/loader/frontmatter.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/loader/frontmatter.js +0 -0
- /package/packages/{safejs → safe-js}/dist/migrate.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/migrate.js +0 -0
- /package/packages/{safejs → safe-js}/dist/migration-file.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/migration-file.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/agent.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/agent.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/canonical-path.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/canonical-path.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/env.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/env.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fail.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fail.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fs-config.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fs-config.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fs.conformance-cases.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fs.conformance-cases.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fs.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/fs.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/git.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/git.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/harness.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/harness.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/log.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/log.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/mcp-transport.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/mcp-transport.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/mcp.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/mcp.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/metric.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/metric.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/registry.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/registry.js +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/time.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/modules/time.js +0 -0
- /package/packages/{safejs → safe-js}/dist/observability/otel.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/observability/otel.js +0 -0
- /package/packages/{safejs → safe-js}/dist/output-stream.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/output-stream.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/assign-ids.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/assign-ids.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/bindings.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/bindings.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/format-error.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/format-error.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/hash.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/hash.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/parse-export.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/parse-export.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/parse-import-meta.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/parse-import-meta.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/parser.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/parser.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/tokenizer.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse/tokenizer.js +0 -0
- /package/packages/{safejs → safe-js}/dist/parse.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/parse.js +0 -0
- /package/packages/{safejs → safe-js}/dist/random.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/random.js +0 -0
- /package/packages/{safejs → safe-js}/dist/restore.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/restore.js +0 -0
- /package/packages/{safejs → safe-js}/dist/run.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/run.js +0 -0
- /package/packages/{safejs → safe-js}/dist/runner/run-harness.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/runner/run-harness.js +0 -0
- /package/packages/{safejs → safe-js}/dist/runner/signal-dump.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/runner/signal-dump.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/arguments.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/arguments.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/arrays.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/arrays.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/backend.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/backend.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/dump-format.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/dump-format.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/dump.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/dump.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/float32array.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/float32array.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/migration.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/migration.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/policy.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/policy.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/replay-data.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/replay-data.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/replay-inputs.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/replay-inputs.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/restore.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/restore.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/scheduler.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/scheduler.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/serialize.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/serialize.js +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/validation.d.ts +0 -0
- /package/packages/{safejs → safe-js}/dist/snapshot/validation.js +0 -0
|
@@ -1,11 +1,94 @@
|
|
|
1
1
|
import { isBuiltin } from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
export const canonicalFsRoutes = [
|
|
4
|
+
{
|
|
5
|
+
workspace: "@poe-code/safe-fs",
|
|
6
|
+
specifier: "poe-code/safe-fs",
|
|
7
|
+
key: "./safe-fs",
|
|
8
|
+
source: { node: "packages/safe-fs/src/index.ts", browser: "packages/safe-fs/src/core.ts" },
|
|
9
|
+
runtime: {
|
|
10
|
+
node: "packages/safe-js/dist/safe-fs.js",
|
|
11
|
+
browser: "packages/safe-js/dist/browser/safe-fs.js"
|
|
12
|
+
},
|
|
13
|
+
types: { node: "packages/safe-fs/dist/index.d.ts", browser: "packages/safe-fs/dist/core.d.ts" }
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
workspace: "@poe-code/safe-fs/core",
|
|
17
|
+
specifier: "poe-code/safe-fs/core",
|
|
18
|
+
key: "./safe-fs/core",
|
|
19
|
+
source: { node: "packages/safe-fs/src/core.ts", browser: "packages/safe-fs/src/core.ts" },
|
|
20
|
+
runtime: {
|
|
21
|
+
node: "packages/safe-js/dist/safe-fs-core.js",
|
|
22
|
+
browser: "packages/safe-js/dist/browser/safe-fs-core.js"
|
|
23
|
+
},
|
|
24
|
+
types: { node: "packages/safe-fs/dist/core.d.ts", browser: "packages/safe-fs/dist/core.d.ts" }
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
workspace: "@poe-code/safe-fs/node",
|
|
28
|
+
specifier: "poe-code/safe-fs/node",
|
|
29
|
+
key: "./safe-fs/node",
|
|
30
|
+
source: { node: "packages/safe-fs/src/node-host.ts", browser: null },
|
|
31
|
+
runtime: { node: "packages/safe-js/dist/safe-fs-node.js", browser: null },
|
|
32
|
+
types: {
|
|
33
|
+
node: "packages/safe-fs/dist/node-host.d.ts",
|
|
34
|
+
browser: "packages/safe-fs/dist/node-unavailable.d.ts"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
export const canonicalFsProfiles = {
|
|
39
|
+
node: {
|
|
40
|
+
outdir: "packages/safe-js/dist",
|
|
41
|
+
policy: "packages/safe-fs/src/platform/node.ts",
|
|
42
|
+
types: "packages/safe-fs/dist/platform/node.d.ts"
|
|
43
|
+
},
|
|
44
|
+
browser: {
|
|
45
|
+
outdir: "packages/safe-js/dist/browser",
|
|
46
|
+
policy: "packages/safe-fs/src/platform/browser.ts",
|
|
47
|
+
types: "packages/safe-fs/dist/platform/browser.d.ts"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const canonicalFsExports = Object.fromEntries(canonicalFsRoutes.map((route) => [
|
|
51
|
+
route.key,
|
|
52
|
+
{
|
|
53
|
+
types: { browser: `./${route.types.browser}`, default: `./${route.types.node}` },
|
|
54
|
+
browser: route.runtime.browser === null ? null : `./${route.runtime.browser}`,
|
|
55
|
+
import: `./${route.runtime.node}`
|
|
56
|
+
}
|
|
57
|
+
]));
|
|
58
|
+
const nodeOnlySafeJsExports = Object.fromEntries([
|
|
59
|
+
["./safe-js", "index"],
|
|
60
|
+
["./safe-js/core", "core"],
|
|
61
|
+
["./safe-js/cli", "cli"],
|
|
62
|
+
["./safejs", "index"],
|
|
63
|
+
["./safejs/core", "core"],
|
|
64
|
+
["./safejs/cli", "cli"]
|
|
65
|
+
].map(([route, entry]) => [
|
|
66
|
+
route,
|
|
67
|
+
{
|
|
68
|
+
types: {
|
|
69
|
+
browser: "./packages/safe-fs/dist/node-unavailable.d.ts",
|
|
70
|
+
default: `./packages/safe-js/dist/${entry}.d.ts`
|
|
71
|
+
},
|
|
72
|
+
browser: null,
|
|
73
|
+
import: `./packages/safe-js/dist/${entry}.js`
|
|
74
|
+
}
|
|
75
|
+
]));
|
|
76
|
+
export const canonicalFsTypeImports = {
|
|
77
|
+
"#safe-fs-platform": {
|
|
78
|
+
types: {
|
|
79
|
+
browser: `./${canonicalFsProfiles.browser.types}`,
|
|
80
|
+
default: `./${canonicalFsProfiles.node.types}`
|
|
81
|
+
},
|
|
82
|
+
default: null
|
|
83
|
+
}
|
|
84
|
+
};
|
|
3
85
|
export const canonicalFs = {
|
|
4
86
|
workspace: "@poe-code/safe-fs",
|
|
5
87
|
specifier: "poe-code/safe-fs",
|
|
6
88
|
source: "packages/safe-fs/src/index.ts",
|
|
7
|
-
runtime: "packages/
|
|
8
|
-
types: "packages/safe-fs/dist/index.d.ts"
|
|
89
|
+
runtime: "packages/safe-js/dist/safe-fs.js",
|
|
90
|
+
types: "packages/safe-fs/dist/index.d.ts",
|
|
91
|
+
routes: canonicalFsRoutes
|
|
9
92
|
};
|
|
10
93
|
function record(value) {
|
|
11
94
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
@@ -31,7 +114,8 @@ function packageName(specifier) {
|
|
|
31
114
|
}
|
|
32
115
|
export function findBundleIssues(manifest, workspaceNames, metafile, packedFiles) {
|
|
33
116
|
const issues = [];
|
|
34
|
-
const exported = record(
|
|
117
|
+
const exported = record(manifest.exports);
|
|
118
|
+
const routes = new Set(canonicalFsRoutes.map((route) => route.specifier));
|
|
35
119
|
const imports = new Set(Object.values(metafile.outputs ?? {}).flatMap((output) => (output.imports ?? [])
|
|
36
120
|
.filter((dependency) => dependency.external)
|
|
37
121
|
.map((dependency) => dependency.path ?? "")));
|
|
@@ -42,7 +126,7 @@ export function findBundleIssues(manifest, workspaceNames, metafile, packedFiles
|
|
|
42
126
|
for (const specifier of [...imports].sort()) {
|
|
43
127
|
if (isBuiltin(specifier))
|
|
44
128
|
continue;
|
|
45
|
-
if (
|
|
129
|
+
if (routes.has(specifier) && manifest.name === "poe-code")
|
|
46
130
|
continue;
|
|
47
131
|
const dependency = packageName(specifier);
|
|
48
132
|
const reason = !dependency
|
|
@@ -55,79 +139,227 @@ export function findBundleIssues(manifest, workspaceNames, metafile, packedFiles
|
|
|
55
139
|
if (reason)
|
|
56
140
|
issues.push({ external: specifier, reason });
|
|
57
141
|
}
|
|
142
|
+
const exportKeys = Object.keys(exported).filter((key) => key === "./safe-fs" || key.startsWith("./safe-fs/"));
|
|
58
143
|
if (!metafile.canonicalBundle &&
|
|
59
|
-
!
|
|
60
|
-
!
|
|
144
|
+
!metafile.browserCanonicalBundle &&
|
|
145
|
+
!exportKeys.length &&
|
|
146
|
+
![...imports].some((specifier) => routes.has(specifier)))
|
|
61
147
|
return issues;
|
|
62
|
-
const fail = (reason
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
148
|
+
const fail = (reason, external = canonicalFs.specifier) => {
|
|
149
|
+
if (!issues.some((issue) => issue.external === external && issue.reason === reason))
|
|
150
|
+
issues.push({ external, reason });
|
|
151
|
+
};
|
|
152
|
+
for (const route of canonicalFsRoutes) {
|
|
153
|
+
if (manifest.name !== "poe-code" ||
|
|
154
|
+
JSON.stringify(exported[route.key]) !== JSON.stringify(canonicalFsExports[route.key]))
|
|
155
|
+
fail("invalid-canonical-export", route.specifier);
|
|
156
|
+
}
|
|
157
|
+
if (exportKeys.some((key) => !canonicalFsRoutes.some((route) => route.key === key)))
|
|
67
158
|
fail("invalid-canonical-export");
|
|
159
|
+
for (const [key, expected] of Object.entries(nodeOnlySafeJsExports)) {
|
|
160
|
+
if (JSON.stringify(exported[key]) !== JSON.stringify(expected))
|
|
161
|
+
fail("invalid-node-only-safejs-export", `poe-code${key.slice(1)}`);
|
|
162
|
+
}
|
|
163
|
+
if (JSON.stringify(record(manifest.imports)["#safe-fs-platform"]) !==
|
|
164
|
+
JSON.stringify(canonicalFsTypeImports["#safe-fs-platform"]))
|
|
165
|
+
fail("invalid-canonical-type-import");
|
|
166
|
+
const canonicalPaths = canonicalFsRoutes
|
|
167
|
+
.flatMap((route) => [...Object.values(route.runtime), ...Object.values(route.types)])
|
|
168
|
+
.filter((filename) => filename !== null);
|
|
169
|
+
for (const filename of canonicalPaths) {
|
|
170
|
+
let directory = path.posix.dirname(filename);
|
|
171
|
+
while (directory !== ".") {
|
|
172
|
+
if (packedFiles.has(`${directory}/package.json`))
|
|
173
|
+
fail("nested-canonical-package-scope");
|
|
174
|
+
directory = path.posix.dirname(directory);
|
|
175
|
+
}
|
|
68
176
|
}
|
|
69
|
-
if (!packedFiles.has(canonicalFs.types))
|
|
70
|
-
fail("unpacked-canonical-types");
|
|
71
177
|
if ([...packedFiles].some((filename) => filename.startsWith("packages/safe-fs/dist/") &&
|
|
72
178
|
[".js", ".mjs", ".cjs"].some((extension) => filename.endsWith(extension))))
|
|
73
179
|
fail("duplicate-packed-runtime");
|
|
74
|
-
if (Object.keys(metafile.inputs ?? {}).some((input) => input.startsWith("packages/safe-fs/src/")))
|
|
180
|
+
if (Object.keys(metafile.inputs ?? {}).some((input) => input.startsWith("packages/safe-fs/src/")))
|
|
75
181
|
fail("duplicate-canonical-runtime");
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const outputs = canonical.metafile.outputs ?? {};
|
|
85
|
-
if (!Object.hasOwn(canonical.metafile.inputs ?? {}, canonicalFs.source))
|
|
86
|
-
fail("missing-canonical-source");
|
|
87
|
-
if (outputs[canonicalFs.runtime]?.entryPoint !== canonicalFs.source)
|
|
88
|
-
fail("invalid-canonical-root");
|
|
89
|
-
for (const entry of canonical.entryPoints) {
|
|
90
|
-
if (!Object.values(outputs).some((output) => output.entryPoint === entry))
|
|
91
|
-
fail("missing-declared-root");
|
|
92
|
-
}
|
|
93
|
-
const pending = [canonicalFs.runtime];
|
|
94
|
-
const visited = new Set();
|
|
95
|
-
while (pending.length) {
|
|
96
|
-
const filename = pending.pop();
|
|
97
|
-
if (visited.has(filename))
|
|
98
|
-
continue;
|
|
99
|
-
visited.add(filename);
|
|
100
|
-
if (!filename.startsWith("packages/safejs/dist/") ||
|
|
101
|
-
path.posix.normalize(filename) !== filename) {
|
|
102
|
-
fail("invalid-canonical-path");
|
|
182
|
+
const emptyTypes = "packages/safe-fs/dist/node-unavailable.d.ts";
|
|
183
|
+
if (!metafile.canonicalEmptyTypes?.includes(emptyTypes))
|
|
184
|
+
fail("nonempty-browser-node-types", "poe-code/safe-fs/node");
|
|
185
|
+
for (const profile of ["node", "browser"]) {
|
|
186
|
+
const settings = canonicalFsProfiles[profile];
|
|
187
|
+
const canonical = profile === "node" ? metafile.canonicalBundle : metafile.browserCanonicalBundle;
|
|
188
|
+
if (!canonical || !Array.isArray(canonical.entryPoints)) {
|
|
189
|
+
fail("missing-canonical-root");
|
|
103
190
|
continue;
|
|
104
191
|
}
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
107
|
-
|
|
108
|
-
|
|
192
|
+
const inputs = canonical.metafile.inputs ?? {};
|
|
193
|
+
if (!Object.hasOwn(inputs, settings.policy) ||
|
|
194
|
+
Object.hasOwn(inputs, canonicalFsProfiles[profile === "node" ? "browser" : "node"].policy))
|
|
195
|
+
fail("wrong-canonical-policy");
|
|
196
|
+
const outputs = canonical.metafile.outputs ?? {};
|
|
197
|
+
for (const singleton of [
|
|
198
|
+
"contracts/errors.ts",
|
|
199
|
+
"bridge/filesystem.ts",
|
|
200
|
+
"fs/memory/index.ts",
|
|
201
|
+
"fs/mount/comparison.ts",
|
|
202
|
+
"fs/s3/registry.ts",
|
|
203
|
+
"fs/s3/authority.ts",
|
|
204
|
+
`platform/${profile}.ts`
|
|
205
|
+
]) {
|
|
206
|
+
const source = `packages/safe-fs/src/${singleton}`;
|
|
207
|
+
if (!Object.hasOwn(inputs, source))
|
|
208
|
+
continue;
|
|
209
|
+
const copies = Object.entries(outputs).filter(([filename, output]) => packedFiles.has(filename) && Object.hasOwn(output.inputs ?? {}, source));
|
|
210
|
+
if (copies.length > 1)
|
|
211
|
+
fail("duplicate-canonical-singleton");
|
|
212
|
+
}
|
|
213
|
+
const pending = [];
|
|
214
|
+
for (const route of canonicalFsRoutes) {
|
|
215
|
+
const source = route.source[profile];
|
|
216
|
+
const runtime = route.runtime[profile];
|
|
217
|
+
if (source === null || runtime === null)
|
|
218
|
+
continue;
|
|
219
|
+
if (!canonical.entryPoints.includes(source))
|
|
220
|
+
fail("missing-canonical-root", route.specifier);
|
|
221
|
+
if (!Object.hasOwn(inputs, source))
|
|
222
|
+
fail("missing-canonical-source", route.specifier);
|
|
223
|
+
if (outputs[runtime]?.entryPoint !== source)
|
|
224
|
+
fail("invalid-canonical-root", route.specifier);
|
|
225
|
+
pending.push(runtime);
|
|
226
|
+
}
|
|
227
|
+
for (const entry of canonical.entryPoints) {
|
|
228
|
+
if (!Object.values(outputs).some((output) => output.entryPoint === entry))
|
|
229
|
+
fail("missing-declared-root");
|
|
109
230
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (!dependency.
|
|
121
|
-
|
|
231
|
+
const rootedOutputs = new Set();
|
|
232
|
+
const rootedPending = Object.entries(outputs)
|
|
233
|
+
.filter(([, output]) => output.entryPoint && canonical.entryPoints.includes(output.entryPoint))
|
|
234
|
+
.map(([filename]) => filename);
|
|
235
|
+
while (rootedPending.length) {
|
|
236
|
+
const filename = rootedPending.pop();
|
|
237
|
+
if (rootedOutputs.has(filename))
|
|
238
|
+
continue;
|
|
239
|
+
rootedOutputs.add(filename);
|
|
240
|
+
for (const dependency of outputs[filename]?.imports ?? []) {
|
|
241
|
+
if (!dependency.external && dependency.path)
|
|
242
|
+
rootedPending.push(dependency.path);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
for (const [filename, output] of Object.entries(outputs)) {
|
|
246
|
+
if (output.entryPoint && !rootedOutputs.has(filename) && packedFiles.has(filename))
|
|
247
|
+
fail("undeclared-canonical-root");
|
|
248
|
+
}
|
|
249
|
+
const visited = new Set();
|
|
250
|
+
while (pending.length) {
|
|
251
|
+
const filename = pending.pop();
|
|
252
|
+
if (visited.has(filename))
|
|
253
|
+
continue;
|
|
254
|
+
visited.add(filename);
|
|
255
|
+
if (!filename.startsWith(`${settings.outdir}/`) ||
|
|
256
|
+
path.posix.normalize(filename) !== filename ||
|
|
257
|
+
(profile === "node" && filename.startsWith(`${canonicalFsProfiles.browser.outdir}/`))) {
|
|
258
|
+
fail("invalid-canonical-path");
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const output = outputs[filename];
|
|
262
|
+
if (!output) {
|
|
263
|
+
fail("missing-canonical-output");
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (!packedFiles.has(filename))
|
|
267
|
+
fail("unpacked-canonical-output");
|
|
268
|
+
if (filename.endsWith(".js"))
|
|
269
|
+
pending.push(`${filename}.map`);
|
|
270
|
+
if (Object.keys(output.inputs ?? {}).some((input) => !input.startsWith("packages/safe-fs/src/")))
|
|
271
|
+
fail("foreign-canonical-input");
|
|
272
|
+
if (output.cssBundle)
|
|
273
|
+
pending.push(output.cssBundle);
|
|
274
|
+
for (const dependency of output.imports ?? []) {
|
|
275
|
+
if (dependency.external) {
|
|
276
|
+
if (profile === "browser" || !dependency.path || !isBuiltin(dependency.path))
|
|
277
|
+
fail("external-canonical-dependency");
|
|
278
|
+
}
|
|
279
|
+
else if (dependency.path)
|
|
280
|
+
pending.push(dependency.path);
|
|
281
|
+
else
|
|
282
|
+
fail("missing-canonical-edge");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const typeQueue = canonicalFsRoutes.map((route) => route.types[profile]);
|
|
286
|
+
typeQueue.push(settings.types);
|
|
287
|
+
const seenTypes = new Set();
|
|
288
|
+
while (typeQueue.length) {
|
|
289
|
+
const filename = typeQueue.pop();
|
|
290
|
+
if (seenTypes.has(filename))
|
|
291
|
+
continue;
|
|
292
|
+
seenTypes.add(filename);
|
|
293
|
+
if (!filename.startsWith("packages/safe-fs/dist/") ||
|
|
294
|
+
path.posix.normalize(filename) !== filename ||
|
|
295
|
+
!filename.endsWith(".d.ts")) {
|
|
296
|
+
fail("invalid-canonical-types-path");
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (!packedFiles.has(filename))
|
|
300
|
+
fail("unpacked-canonical-types");
|
|
301
|
+
const edges = metafile.canonicalTypes?.[filename];
|
|
302
|
+
if (!Array.isArray(edges)) {
|
|
303
|
+
fail("missing-canonical-types");
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
for (const edge of edges) {
|
|
307
|
+
if (edge === "#safe-fs-platform")
|
|
308
|
+
typeQueue.push(settings.types);
|
|
309
|
+
else if (isBuiltin(edge)) {
|
|
310
|
+
if (profile === "browser")
|
|
311
|
+
fail("external-canonical-types");
|
|
312
|
+
}
|
|
313
|
+
else if (edge.startsWith(".") &&
|
|
314
|
+
!["?", "#", "%", "\\", ":"].some((character) => edge.includes(character)) &&
|
|
315
|
+
(edge.endsWith(".js") || edge.endsWith(".d.ts"))) {
|
|
316
|
+
const target = edge.endsWith(".js") ? `${edge.slice(0, -3)}.d.ts` : edge;
|
|
317
|
+
typeQueue.push(path.posix.normalize(path.posix.join(path.posix.dirname(filename), target)));
|
|
318
|
+
}
|
|
319
|
+
else
|
|
320
|
+
fail("external-canonical-types");
|
|
122
321
|
}
|
|
123
|
-
else if (dependency.path)
|
|
124
|
-
pending.push(dependency.path);
|
|
125
|
-
else
|
|
126
|
-
fail("missing-canonical-edge");
|
|
127
322
|
}
|
|
128
323
|
}
|
|
129
324
|
return issues;
|
|
130
325
|
}
|
|
326
|
+
export async function collectCanonicalDeclarations(rootDir, files) {
|
|
327
|
+
const { default: ts } = await import("typescript");
|
|
328
|
+
const declarations = await collectPackageFiles(rootDir, ["packages/safe-fs/dist/**/*.d.ts"], files);
|
|
329
|
+
const canonicalTypes = {};
|
|
330
|
+
const canonicalEmptyTypes = [];
|
|
331
|
+
for (const filename of declarations) {
|
|
332
|
+
const source = ts.createSourceFile(filename, await files.readFile(path.join(rootDir, filename)), ts.ScriptTarget.Latest, true);
|
|
333
|
+
const imports = new Set(source.referencedFiles.map((reference) => reference.fileName));
|
|
334
|
+
const visit = (node) => {
|
|
335
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) &&
|
|
336
|
+
node.moduleSpecifier &&
|
|
337
|
+
ts.isStringLiteral(node.moduleSpecifier))
|
|
338
|
+
imports.add(node.moduleSpecifier.text);
|
|
339
|
+
if (ts.isImportTypeNode(node) &&
|
|
340
|
+
ts.isLiteralTypeNode(node.argument) &&
|
|
341
|
+
ts.isStringLiteral(node.argument.literal))
|
|
342
|
+
imports.add(node.argument.literal.text);
|
|
343
|
+
if (ts.isExternalModuleReference(node) &&
|
|
344
|
+
node.expression &&
|
|
345
|
+
ts.isStringLiteral(node.expression))
|
|
346
|
+
imports.add(node.expression.text);
|
|
347
|
+
ts.forEachChild(node, visit);
|
|
348
|
+
};
|
|
349
|
+
visit(source);
|
|
350
|
+
for (const reference of source.typeReferenceDirectives)
|
|
351
|
+
imports.add(`types:${reference.fileName}`);
|
|
352
|
+
canonicalTypes[filename] = [...imports];
|
|
353
|
+
if (source.statements.length === 1 &&
|
|
354
|
+
source.statements.every((statement) => ts.isExportDeclaration(statement) &&
|
|
355
|
+
!statement.moduleSpecifier &&
|
|
356
|
+
statement.exportClause &&
|
|
357
|
+
ts.isNamedExports(statement.exportClause) &&
|
|
358
|
+
statement.exportClause.elements.length === 0))
|
|
359
|
+
canonicalEmptyTypes.push(filename);
|
|
360
|
+
}
|
|
361
|
+
return { canonicalTypes, canonicalEmptyTypes };
|
|
362
|
+
}
|
|
131
363
|
export async function collectPackageFiles(rootDir, entries, files) {
|
|
132
364
|
const packed = new Set();
|
|
133
365
|
async function visit(filename, declarationsOnly) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BundleMetafile } from "./bundle-policy.js";
|
|
2
2
|
import { type PackageFileView, type PacklistProvider } from "./packlist.js";
|
|
3
3
|
import { type RuntimeAssetDeclaration, type RuntimeFileAssetView } from "./runtime-files.js";
|
|
4
4
|
import { type SourceImportView } from "./source-imports.js";
|
|
@@ -40,6 +40,7 @@ export interface PackageInfo {
|
|
|
40
40
|
ecosystem: Ecosystem;
|
|
41
41
|
main: string | undefined;
|
|
42
42
|
exports: unknown;
|
|
43
|
+
imports?: unknown;
|
|
43
44
|
bin: Record<string, string>;
|
|
44
45
|
files: string[];
|
|
45
46
|
scripts: Record<string, string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { collectCanonicalDeclarations } from "./bundle-policy.js";
|
|
2
3
|
import { parse as parseYaml } from "yaml";
|
|
3
4
|
import { createNpmPacklistProvider, loadPackageFileView } from "./packlist.js";
|
|
4
5
|
import { scanRuntimeFileAssets } from "./runtime-files.js";
|
|
@@ -107,6 +108,7 @@ async function loadPackage(fs, rootDir, relDir, isRoot) {
|
|
|
107
108
|
ecosystem,
|
|
108
109
|
main: typeof pkg.main === "string" ? pkg.main : undefined,
|
|
109
110
|
exports: pkg.exports,
|
|
111
|
+
imports: pkg.imports,
|
|
110
112
|
bin: toBinRecord(pkg.bin, typeof pkg.name === "string" ? pkg.name : relDir),
|
|
111
113
|
files: Array.isArray(pkg.files)
|
|
112
114
|
? pkg.files.filter((f) => typeof f === "string")
|
|
@@ -448,12 +450,17 @@ export async function loadBuildView(fs, rootDir) {
|
|
|
448
450
|
catch {
|
|
449
451
|
return undefined;
|
|
450
452
|
}
|
|
453
|
+
let metafile;
|
|
451
454
|
try {
|
|
452
|
-
|
|
455
|
+
metafile = JSON.parse(raw);
|
|
453
456
|
}
|
|
454
457
|
catch {
|
|
455
458
|
return undefined;
|
|
456
459
|
}
|
|
460
|
+
if (metafile.canonicalBundle || metafile.browserCanonicalBundle) {
|
|
461
|
+
Object.assign(metafile, await collectCanonicalDeclarations(rootDir, fs));
|
|
462
|
+
}
|
|
463
|
+
return parseMetafile(metafile);
|
|
457
464
|
}
|
|
458
465
|
/** All workspace packages plus the root package. */
|
|
459
466
|
export function allPackages(model) {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { FileSystem } from "../contracts/filesystem.js";
|
|
2
|
+
import type { BridgePrimitives, BufferEncodingOption, FsBridgeDirent, FsBridgeEncoding, FsBridgeStats, MakeDirectoryOptions, Mode, ObjectEncodingOptions, StatOptions } from "./types.js";
|
|
3
|
+
type Encoding = FsBridgeEncoding | "buffer";
|
|
4
|
+
type ReadOptions = ObjectEncodingOptions & {
|
|
5
|
+
flag?: string | number | undefined;
|
|
6
|
+
signal?: AbortSignal | undefined;
|
|
7
|
+
};
|
|
8
|
+
type DirectoryOptions = {
|
|
9
|
+
encoding?: Encoding | null | undefined;
|
|
10
|
+
recursive?: boolean | undefined;
|
|
11
|
+
withFileTypes?: boolean | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare class FileSystemBridge<Binary extends Uint8Array> {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(fs: FileSystem, options: {
|
|
16
|
+
readonly cwd?: string;
|
|
17
|
+
readonly signal?: AbortSignal;
|
|
18
|
+
}, primitives: BridgePrimitives<Binary>);
|
|
19
|
+
readFile(path: unknown, options?: {
|
|
20
|
+
encoding?: null | undefined;
|
|
21
|
+
flag?: string | number | undefined;
|
|
22
|
+
signal?: AbortSignal | undefined;
|
|
23
|
+
} | null): Promise<Binary>;
|
|
24
|
+
readFile(path: unknown, options: FsBridgeEncoding | (ReadOptions & {
|
|
25
|
+
encoding: FsBridgeEncoding;
|
|
26
|
+
})): Promise<string>;
|
|
27
|
+
readFile(path: unknown, options?: ReadOptions | FsBridgeEncoding | null): Promise<string | Binary>;
|
|
28
|
+
writeFile(path: unknown, data: unknown, options?: unknown): Promise<void>;
|
|
29
|
+
appendFile(path: unknown, data: unknown, options?: unknown): Promise<void>;
|
|
30
|
+
stat(path: unknown, options?: StatOptions & {
|
|
31
|
+
bigint?: false | undefined;
|
|
32
|
+
}): Promise<FsBridgeStats>;
|
|
33
|
+
stat(path: unknown, options: StatOptions & {
|
|
34
|
+
bigint: true;
|
|
35
|
+
}): Promise<never>;
|
|
36
|
+
stat(path: unknown, options?: StatOptions): Promise<FsBridgeStats>;
|
|
37
|
+
lstat(path: unknown, options?: StatOptions & {
|
|
38
|
+
bigint?: false | undefined;
|
|
39
|
+
}): Promise<FsBridgeStats>;
|
|
40
|
+
lstat(path: unknown, options: StatOptions & {
|
|
41
|
+
bigint: true;
|
|
42
|
+
}): Promise<never>;
|
|
43
|
+
lstat(path: unknown, options?: StatOptions): Promise<FsBridgeStats>;
|
|
44
|
+
readdir(path: unknown, options?: FsBridgeEncoding | (ObjectEncodingOptions & {
|
|
45
|
+
withFileTypes?: false | undefined;
|
|
46
|
+
recursive?: boolean | undefined;
|
|
47
|
+
}) | null): Promise<string[]>;
|
|
48
|
+
readdir(path: unknown, options: "buffer" | (DirectoryOptions & {
|
|
49
|
+
encoding: "buffer";
|
|
50
|
+
withFileTypes?: false | undefined;
|
|
51
|
+
})): Promise<Binary[]>;
|
|
52
|
+
readdir(path: unknown, options: ObjectEncodingOptions & {
|
|
53
|
+
withFileTypes: true;
|
|
54
|
+
recursive?: boolean | undefined;
|
|
55
|
+
}): Promise<FsBridgeDirent[]>;
|
|
56
|
+
readdir(path: unknown, options: DirectoryOptions & {
|
|
57
|
+
encoding: "buffer";
|
|
58
|
+
withFileTypes: true;
|
|
59
|
+
}): Promise<FsBridgeDirent<Binary>[]>;
|
|
60
|
+
mkdir(path: unknown, options: MakeDirectoryOptions & {
|
|
61
|
+
recursive: true;
|
|
62
|
+
}): Promise<string | undefined>;
|
|
63
|
+
mkdir(path: unknown, options?: Mode | (MakeDirectoryOptions & {
|
|
64
|
+
recursive?: false | undefined;
|
|
65
|
+
}) | null): Promise<void>;
|
|
66
|
+
mkdir(path: unknown, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
|
|
67
|
+
access(path: unknown, mode?: number): Promise<void>;
|
|
68
|
+
rm(path: unknown, value?: unknown): Promise<void>;
|
|
69
|
+
rmdir(path: unknown, value?: unknown): Promise<void>;
|
|
70
|
+
rename(source: unknown, destination: unknown): Promise<void>;
|
|
71
|
+
copyFile(source: unknown, destination: unknown, mode?: number): Promise<void>;
|
|
72
|
+
cp(source: unknown, destination: unknown, value?: unknown): Promise<void>;
|
|
73
|
+
readlink(path: unknown, options?: ObjectEncodingOptions | FsBridgeEncoding | null): Promise<string>;
|
|
74
|
+
readlink(path: unknown, options: BufferEncodingOption): Promise<Binary>;
|
|
75
|
+
readlink(path: unknown, options?: ObjectEncodingOptions | BufferEncodingOption | string | null): Promise<string | Binary>;
|
|
76
|
+
realpath(path: unknown, options?: ObjectEncodingOptions | FsBridgeEncoding | null): Promise<string>;
|
|
77
|
+
realpath(path: unknown, options: BufferEncodingOption): Promise<Binary>;
|
|
78
|
+
realpath(path: unknown, options?: ObjectEncodingOptions | BufferEncodingOption | string | null): Promise<string | Binary>;
|
|
79
|
+
mkdtemp(prefix: string, options?: ObjectEncodingOptions | FsBridgeEncoding | null): Promise<string>;
|
|
80
|
+
mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Binary>;
|
|
81
|
+
mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncodingOption | string | null): Promise<string | Binary>;
|
|
82
|
+
symlink(target: unknown, path: unknown, type?: unknown): Promise<void>;
|
|
83
|
+
link(existing: unknown, path: unknown): Promise<void>;
|
|
84
|
+
chmod(path: unknown, value: unknown): Promise<void>;
|
|
85
|
+
utimes(path: unknown, atime: unknown, mtime: unknown): Promise<void>;
|
|
86
|
+
truncate(path: unknown, length?: number): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileSystem } from "../contracts/filesystem.js";
|
|
2
|
+
import { FileSystemBridge } from "./filesystem.js";
|
|
3
|
+
import type { FsBridgeOptions } from "./types.js";
|
|
4
|
+
export type { FsBridgeCodec, FsBridgeDirent, FsBridgeEncoding, FsBridgeFileSystem, FsBridgeOptions, FsBridgeStats } from "./types.js";
|
|
5
|
+
export type FsBridge = FileSystemBridge<Uint8Array<ArrayBuffer>>;
|
|
6
|
+
export declare function createFsBridge(fs: FileSystem, options: FsBridgeOptions): FsBridge;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FsBridgeDirent, FsBridgeStats } from "./types.js";
|
|
2
|
+
import type { FileStat, FileType } from "../contracts/filesystem.js";
|
|
3
|
+
export declare function bridgeStats(stat: FileStat): FsBridgeStats;
|
|
4
|
+
export declare function bridgeDirent<Name extends string | Uint8Array>(name: Name, parentPath: string, type: FileType): FsBridgeDirent<Name>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { FileSystem, FsOptions } from "../contracts/filesystem.js";
|
|
2
|
+
export interface FsBridgeCodec {
|
|
3
|
+
isEncoding(encoding: string): boolean;
|
|
4
|
+
encode(text: string, encoding: string): Uint8Array;
|
|
5
|
+
decode(bytes: Uint8Array, encoding: string): string;
|
|
6
|
+
}
|
|
7
|
+
export interface FsBridgeOptions {
|
|
8
|
+
readonly codec: FsBridgeCodec;
|
|
9
|
+
readonly cwd?: string;
|
|
10
|
+
readonly signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface FsBridgeFileSystem extends FileSystem {
|
|
13
|
+
rmdir?(path: string, options?: FsOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type FsBridgeEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
16
|
+
export interface ObjectEncodingOptions {
|
|
17
|
+
encoding?: FsBridgeEncoding | null | undefined;
|
|
18
|
+
}
|
|
19
|
+
export type BufferEncodingOption = "buffer" | {
|
|
20
|
+
encoding: "buffer";
|
|
21
|
+
};
|
|
22
|
+
export type Mode = number | string;
|
|
23
|
+
export interface MakeDirectoryOptions {
|
|
24
|
+
recursive?: boolean | undefined;
|
|
25
|
+
mode?: Mode | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface StatOptions {
|
|
28
|
+
bigint?: boolean | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface FsBridgePredicates {
|
|
31
|
+
isFile(): boolean;
|
|
32
|
+
isDirectory(): boolean;
|
|
33
|
+
isSymbolicLink(): boolean;
|
|
34
|
+
isBlockDevice(): boolean;
|
|
35
|
+
isCharacterDevice(): boolean;
|
|
36
|
+
isFIFO(): boolean;
|
|
37
|
+
isSocket(): boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface FsBridgeStats extends FsBridgePredicates {
|
|
40
|
+
dev: number;
|
|
41
|
+
ino: number;
|
|
42
|
+
mode: number;
|
|
43
|
+
nlink: number;
|
|
44
|
+
uid: number;
|
|
45
|
+
gid: number;
|
|
46
|
+
rdev: number;
|
|
47
|
+
size: number;
|
|
48
|
+
blksize: number;
|
|
49
|
+
blocks: number;
|
|
50
|
+
atimeMs: number;
|
|
51
|
+
mtimeMs: number;
|
|
52
|
+
ctimeMs: number;
|
|
53
|
+
birthtimeMs: number;
|
|
54
|
+
atime: Date;
|
|
55
|
+
mtime: Date;
|
|
56
|
+
ctime: Date;
|
|
57
|
+
birthtime: Date;
|
|
58
|
+
}
|
|
59
|
+
export interface FsBridgeDirent<Name extends string | Uint8Array = string> extends FsBridgePredicates {
|
|
60
|
+
name: Name;
|
|
61
|
+
parentPath: string;
|
|
62
|
+
path: string;
|
|
63
|
+
}
|
|
64
|
+
export interface BridgePrimitives<Binary extends Uint8Array> {
|
|
65
|
+
readonly codec: FsBridgeCodec;
|
|
66
|
+
copyBytes(bytes: Uint8Array): Binary;
|
|
67
|
+
pathValue?(value: unknown): unknown;
|
|
68
|
+
randomSuffix(): string;
|
|
69
|
+
readonly paths: {
|
|
70
|
+
isAbsolute(path: string): boolean;
|
|
71
|
+
dirname(path: string): string;
|
|
72
|
+
relative(from: string, to: string): string;
|
|
73
|
+
resolve(cwd: string, ...paths: string[]): string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function record(value: unknown, name: string): Record<string, unknown>;
|
|
2
|
+
export declare function onlyKeys(value: Record<string, unknown>, allowed: readonly string[]): void;
|
|
3
|
+
export declare function booleanValue(value: unknown, fallback?: boolean): boolean;
|
|
4
|
+
export declare function abortError(): Error;
|
|
5
|
+
export declare function checkSignal(signal: AbortSignal | undefined): void;
|
|
6
|
+
export declare function withSignal<Value>(signal: AbortSignal | undefined, operation: () => Promise<Value>): Promise<Value>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { PlatformErrno } from "#safe-fs-platform";
|
|
2
|
+
export type { PlatformErrno } from "#safe-fs-platform";
|
|
1
3
|
declare const descriptions: {
|
|
2
4
|
readonly EACCES: "permission denied";
|
|
3
5
|
readonly EAGAIN: "resource temporarily unavailable";
|
|
@@ -37,7 +39,7 @@ export interface FsErrorOptions extends ErrorOptions {
|
|
|
37
39
|
}
|
|
38
40
|
export declare class FsError extends Error {
|
|
39
41
|
readonly code: ErrnoCode;
|
|
40
|
-
readonly errno:
|
|
42
|
+
readonly errno: PlatformErrno;
|
|
41
43
|
readonly syscall?: string;
|
|
42
44
|
readonly path?: string;
|
|
43
45
|
readonly dest?: string;
|
|
@@ -46,4 +48,3 @@ export declare class FsError extends Error {
|
|
|
46
48
|
export declare function isErrnoCode(code: unknown): code is ErrnoCode;
|
|
47
49
|
export declare function isFsError(error: unknown, code?: ErrnoCode): error is FsError;
|
|
48
50
|
export declare function toFsError(error: unknown, options?: FsErrorOptions): FsError;
|
|
49
|
-
export {};
|