@unbrained/pm-cli 2026.11.16 → 2026.11.18
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/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/main.js +2 -2
- package/dist/cli/register-mutation.js +3 -2
- package/dist/cli/runtime/invocation-rewrites.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2VH6COJE.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-NHNM3GIP.js → chunk-5OFMWP3Q.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-7ETRLLK3.js +31 -0
- package/dist/cli-bundle/chunks/chunk-7LCJA54R.js +2 -0
- package/dist/cli-bundle/chunks/chunk-7UUPLMCU.js +115 -0
- package/dist/cli-bundle/chunks/chunk-AGU7632B.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-J257NZRD.js → chunk-CGTVDSAR.js} +11 -11
- package/dist/cli-bundle/chunks/chunk-CR5GC3VO.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-KGOGLKL2.js → chunk-FJQCORYR.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-H64BNM4A.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-2D26HRXB.js → chunk-HQYIKAC6.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-JBPXNG6P.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-4I7YG3VZ.js → chunk-L2ZLH3LZ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LGWP5D7V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-I3T2FVUA.js → chunk-MUGGRKK3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FZ4XWWLO.js → chunk-OD2I3SFQ.js} +43 -43
- package/dist/cli-bundle/chunks/chunk-QK7RAN7R.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-2WNORBVN.js → chunk-S3RMFLEG.js} +83 -83
- package/dist/cli-bundle/chunks/chunk-SSZBVRIN.js +6 -0
- package/dist/cli-bundle/chunks/chunk-T3E3WNHO.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-DZWRNL6R.js → chunk-TA5VN4ME.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-TS2CZE3O.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-F7P42FL5.js → chunk-VETSGCF4.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-VJLZHOTP.js → chunk-WKHS4QC6.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-XDIJK6VW.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-NYN5OR2T.js → chunk-Y4LXVPA5.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-YJI2Y5N6.js +2 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-HNLN6UXH.js → indexed-receipt-blobs-ELEMA7IW.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-PSOL5I4H.js → item-revision-BV5BUBCR.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-E2ST3A3X.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-BDBBH3ZS.js → mutation-actor-DDYJW5B4.js} +2 -2
- package/dist/cli-bundle/chunks/mutation-admission-5AWMXMCB.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-AESCVO6H.js → register-list-query-RJT7YBRF.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-6KTMJGYF.js +21 -0
- package/dist/cli-bundle/chunks/register-operations-W24TA3HZ.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-QK67WUX6.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-MVVVUIVZ.js → settlement-hook-E5LHZ4RD.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-RMU3JAWM.js → stage-XGWW3T64.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3H3SVHAT.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DFBHW7HP.js → chunk-5JVB42Z7.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-ONM2R32I.js → chunk-6OZ7BKWJ.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-HHMMIHZP.js → chunk-7RF2YPZ5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7Z2NYAK4.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-A2CLYPDA.js +102 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7SEPCQV2.js → chunk-DH4DHL6V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UBBTBNUY.js → chunk-DWCFZVT2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DZMP3VYQ.js → chunk-EO4XM3XJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EZXLY6S4.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KRNF3WTC.js → chunk-FPPYE6CY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-HO2YUD4P.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-BEHIMEV2.js → chunk-ICEHI4SN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-IGMFXB5W.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-PDXSMSO5.js → chunk-IXYBN6D2.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-PEL4SQXV.js → chunk-LZR3JKYT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MTBC32ZR.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-OAIAZHRG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-SFATIM77.js → chunk-ONHUG7IL.js} +9 -9
- package/dist/cli-bundle/focused-chunks/chunk-OPY43DNJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-PNCCTZKI.js +44 -0
- package/dist/cli-bundle/focused-chunks/chunk-T3NMYMW4.js +27 -0
- package/dist/cli-bundle/focused-chunks/chunk-XS2YZCT5.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZFUZ4YYN.js +8 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-ADMQXF3N.js → indexed-receipt-blobs-ZTRFCPH7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-NS2V4WON.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-NENC4HYI.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-2SVBO324.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-DZIBDJAE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-5U2M75BY.js → settlement-hook-OUBUN45C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/stage-LVAGKCEE.js +2 -0
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +58 -58
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +4 -4
- package/dist/core/extensions/extension-hook-runtime.d.ts +14 -2
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-types.d.ts +14 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/fs/file-glob.js +2 -0
- package/dist/core/policy/workflow-policy-store.js +1 -1
- package/dist/core/shared/secret-rules.d.ts +83 -4
- package/dist/core/shared/secret-rules.js +5 -4
- package/dist/core/store/item-mutation-precondition.d.ts +32 -1
- package/dist/core/store/item-mutation-precondition.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/transaction-coordinator-scope.js +2 -0
- package/dist/sdk/authoring.d.ts +1 -1
- package/dist/sdk/authoring.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/lifecycle/copy.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/linked-artifacts.js +2 -2
- package/dist/sdk/mutation-guard.d.ts +25 -4
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/package-import-adapters.d.ts +14 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/testing.d.ts +21 -3
- package/dist/sdk/testing.js +2 -2
- package/dist/sdk/workspace-transaction.js +2 -2
- package/docs/COMMANDS.md +33 -0
- package/docs/DEFECT_RECURRENCE.md +3 -2
- package/docs/EXTENSIONS.md +1 -1
- package/docs/MIGRATION_CLI_SIMPLIFICATION.md +1 -1
- package/docs/MUTATION_INTEGRITY.md +187 -7
- package/docs/SDK.md +40 -3
- package/docs/WORKFLOW_POLICIES.md +23 -0
- package/marketplace.json +1 -1
- package/node_modules/@opentelemetry/core/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/core/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/core/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/core/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/core/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/core/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/core/package.json +2 -2
- package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
- package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.js +1 -0
- package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-bsd.js +3 -2
- package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-darwin.js +3 -2
- package/node_modules/@opentelemetry/resources/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/resources/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
- package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/execAsync.js +1 -0
- package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/getMachineId-bsd.js +3 -2
- package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/getMachineId-darwin.js +3 -2
- package/node_modules/@opentelemetry/resources/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/resources/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
- package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js +2 -1
- package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js +2 -1
- package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js +2 -1
- package/node_modules/@opentelemetry/resources/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/resources/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/resources/package.json +3 -3
- package/node_modules/@opentelemetry/sdk-trace/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/sdk-trace/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/sdk-trace/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/sdk-trace/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/sdk-trace/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/sdk-trace/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/sdk-trace/package.json +5 -5
- package/node_modules/@opentelemetry/sdk-trace-base/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/sdk-trace-base/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/sdk-trace-base/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/sdk-trace-base/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/sdk-trace-base/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/sdk-trace-base/package.json +7 -7
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.cjs +18202 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/src/experimental_attributes.js → dist/experimental_attributes.d.cts} +3328 -1993
- package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_attributes.js → dist/experimental_attributes.d.mts} +3328 -1935
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.mjs +16385 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.cjs +325 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_events.js → dist/experimental_events.d.cts} +37 -41
- package/node_modules/@opentelemetry/semantic-conventions/{build/esm/experimental_events.js → dist/experimental_events.d.mts} +37 -41
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.mjs +295 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.cjs +4929 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_metrics.js → dist/experimental_metrics.d.cts} +955 -597
- package/node_modules/@opentelemetry/semantic-conventions/{build/esm/experimental_metrics.js → dist/experimental_metrics.d.mts} +955 -597
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.mjs +4419 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.cjs +2619 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.d.cts +7 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.d.mts +7 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.mjs +7 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.cjs +670 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.d.cts +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.d.mts +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.mjs +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.cjs +20 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.mjs +20 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.cjs +1326 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/resource/SemanticResourceAttributes.d.ts → dist/resource/SemanticResourceAttributes.d.cts} +600 -597
- package/node_modules/@opentelemetry/semantic-conventions/{build/src/resource/SemanticResourceAttributes.d.ts → dist/resource/SemanticResourceAttributes.d.mts} +600 -597
- package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.mjs +1188 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.cjs +2038 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/esm/stable_attributes.js → dist/stable_attributes.d.cts} +327 -220
- package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/stable_attributes.js → dist/stable_attributes.d.mts} +327 -220
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.mjs +1841 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.cjs +9 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.d.cts +8 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.d.mts +8 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.mjs +9 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.cjs +378 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/src/stable_metrics.js → dist/stable_metrics.d.cts} +69 -63
- package/node_modules/@opentelemetry/semantic-conventions/{build/esm/stable_metrics.js → dist/stable_metrics.d.mts} +69 -59
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.mjs +326 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.cjs +2508 -0
- package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/trace/SemanticAttributes.d.ts → dist/trace/SemanticAttributes.d.cts} +1097 -1094
- package/node_modules/@opentelemetry/semantic-conventions/{build/src/trace/SemanticAttributes.d.ts → dist/trace/SemanticAttributes.d.mts} +1097 -1094
- package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.mjs +2236 -0
- package/node_modules/@opentelemetry/semantic-conventions/package.json +27 -42
- package/node_modules/@sentry/core/build/cjs/client.js +14 -5
- package/node_modules/@sentry/core/build/cjs/integrations/express/patch-layer.js +15 -1
- package/node_modules/@sentry/core/build/cjs/integrations/http/client-subscriptions.js +10 -1
- package/node_modules/@sentry/core/build/cjs/scope.js +0 -1
- package/node_modules/@sentry/core/build/cjs/tracing/openai/utils.js +1 -7
- package/node_modules/@sentry/core/build/cjs/tracing/sentrySpan.js +11 -0
- package/node_modules/@sentry/core/build/cjs/utils/envelope.js +1 -1
- package/node_modules/@sentry/core/build/cjs/utils/sql.js +1 -1
- package/node_modules/@sentry/core/build/cjs/utils/tunnel.js +9 -0
- package/node_modules/@sentry/core/build/cjs/utils/version.js +1 -1
- package/node_modules/@sentry/core/build/esm/client.js +14 -5
- package/node_modules/@sentry/core/build/esm/integrations/express/patch-layer.js +15 -1
- package/node_modules/@sentry/core/build/esm/integrations/http/client-subscriptions.js +10 -1
- package/node_modules/@sentry/core/build/esm/package.json +1 -1
- package/node_modules/@sentry/core/build/esm/scope.js +0 -1
- package/node_modules/@sentry/core/build/esm/tracing/openai/utils.js +1 -7
- package/node_modules/@sentry/core/build/esm/tracing/sentrySpan.js +11 -0
- package/node_modules/@sentry/core/build/esm/utils/envelope.js +1 -1
- package/node_modules/@sentry/core/build/esm/utils/sql.js +1 -1
- package/node_modules/@sentry/core/build/esm/utils/tunnel.js +9 -1
- package/node_modules/@sentry/core/build/esm/utils/version.js +1 -1
- package/node_modules/@sentry/core/build/types/types/datacategory.d.ts +1 -1
- package/node_modules/@sentry/core/build/types/utils/tunnel.d.ts +1 -0
- package/node_modules/@sentry/core/build/types-ts3.8/types/datacategory.d.ts +1 -1
- package/node_modules/@sentry/core/build/types-ts3.8/utils/tunnel.d.ts +1 -0
- package/node_modules/@sentry/core/package.json +1 -1
- package/node_modules/@sentry/node/build/cjs/integrations/tracing/redis/index.js +1 -1
- package/node_modules/@sentry/node/build/esm/package.json +1 -1
- package/node_modules/@sentry/node/package.json +6 -6
- package/node_modules/@sentry/node-core/build/cjs/integrations/anr/index.js +1 -1
- package/node_modules/@sentry/node-core/build/cjs/integrations/contextlines.js +6 -4
- package/node_modules/@sentry/node-core/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/node_modules/@sentry/node-core/build/cjs/integrations/modules.js +21 -2
- package/node_modules/@sentry/node-core/build/cjs/integrations/node-fetch/undici-instrumentation.js +8 -0
- package/node_modules/@sentry/node-core/build/esm/integrations/anr/index.js +1 -1
- package/node_modules/@sentry/node-core/build/esm/integrations/anr/worker-script.js +2 -2
- package/node_modules/@sentry/node-core/build/esm/integrations/contextlines.js +7 -5
- package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/worker-script.js +1 -1
- package/node_modules/@sentry/node-core/build/esm/integrations/node-fetch/undici-instrumentation.js +8 -0
- package/node_modules/@sentry/node-core/build/esm/package.json +1 -1
- package/node_modules/@sentry/node-core/package.json +9 -9
- package/node_modules/@sentry/opentelemetry/build/esm/package.json +1 -1
- package/node_modules/@sentry/opentelemetry/package.json +6 -6
- package/node_modules/@sentry/server-utils/build/THIRD-PARTY-LICENSES.txt +32 -32
- package/node_modules/@sentry/server-utils/build/cjs/integrations/tracing-channel/express/instrumentation.js +12 -1
- package/node_modules/@sentry/server-utils/build/esm/integrations/tracing-channel/express/instrumentation.js +13 -2
- package/node_modules/@sentry/server-utils/build/esm/package.json +1 -1
- package/node_modules/@sentry/server-utils/build/types/integrations/tracing-channel/express/types.d.ts +1 -1
- package/node_modules/@sentry/server-utils/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +1 -1
- package/node_modules/@sentry/server-utils/package.json +2 -2
- package/node_modules/debug/package.json +1 -1
- package/node_modules/es-module-lexer/dist/lexer.asm.js +2 -2
- package/node_modules/es-module-lexer/dist/lexer.cjs +1 -1
- package/node_modules/es-module-lexer/dist/lexer.js +2 -2
- package/node_modules/es-module-lexer/dist/lexer.minimal.asm.js +2 -2
- package/node_modules/es-module-lexer/dist/lexer.minimal.cjs +1 -1
- package/node_modules/es-module-lexer/dist/lexer.minimal.js +2 -2
- package/node_modules/es-module-lexer/package.json +1 -1
- package/node_modules/import-in-the-middle/CHANGELOG.md +35 -0
- package/node_modules/import-in-the-middle/README.md +15 -1
- package/node_modules/import-in-the-middle/create-hook.mjs +370 -155
- package/node_modules/import-in-the-middle/index.d.ts +8 -2
- package/node_modules/import-in-the-middle/index.js +80 -53
- package/node_modules/import-in-the-middle/lib/get-esm-exports.mjs +37 -3
- package/node_modules/import-in-the-middle/lib/get-exports.mjs +33 -40
- package/node_modules/import-in-the-middle/lib/register.js +81 -16
- package/node_modules/import-in-the-middle/package.json +9 -5
- package/node_modules/supports-color/browser.js +21 -2
- package/node_modules/supports-color/index.js +41 -24
- package/node_modules/supports-color/license +1 -1
- package/node_modules/supports-color/package.json +11 -6
- package/node_modules/supports-color/readme.md +8 -7
- package/package.json +4 -6
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-4WIVCOA7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-A3WCP4TU.js +0 -6
- package/dist/cli-bundle/chunks/chunk-AB5S6TWE.js +0 -124
- package/dist/cli-bundle/chunks/chunk-BV7J3LRH.js +0 -114
- package/dist/cli-bundle/chunks/chunk-E4BQRZF2.js +0 -10
- package/dist/cli-bundle/chunks/chunk-ERD2RYWM.js +0 -31
- package/dist/cli-bundle/chunks/chunk-IGEBFNWE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IYICNCK2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-JD3XWF66.js +0 -3
- package/dist/cli-bundle/chunks/chunk-JLHD7OQ2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-LC4DJVXR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OFZQEQ6X.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QGL5IAP4.js +0 -8
- package/dist/cli-bundle/chunks/chunk-R24NZ2TB.js +0 -8
- package/dist/cli-bundle/chunks/chunk-VO2HSB5F.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-55QTCU2M.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-WUN7JYVJ.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-SKCEP5QU.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-ZT4OYCF3.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-JVWNS2TY.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3WVMEA2A.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-5UVJOAUP.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-5WQ3LNUK.js +0 -78
- package/dist/cli-bundle/focused-chunks/chunk-6E4X7MQA.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-7XHE335U.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CZFZCSOX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HPC2M6JD.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-HR5FEUUL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-J7ESCE7M.js +0 -24
- package/dist/cli-bundle/focused-chunks/chunk-KWZLY35A.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-M4IA4LC6.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-NASE6JC2.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QJ647CQE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZCN35TCK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZSQ2FT22.js +0 -44
- package/dist/cli-bundle/focused-chunks/item-revision-GNKYO6GZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-AUUQHR5Z.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-OBRD7HFZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-6TX3EOJX.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-LERF2YJU.js +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +0 -14984
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +0 -14991
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.d.ts +0 -291
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +0 -4053
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.d.ts +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.js +0 -13
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.d.ts +0 -6
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js +0 -16
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.d.ts +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js +0 -23
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.d.ts +0 -1453
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js +0 -1250
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +0 -1726
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.d.ts +0 -5
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.js +0 -12
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.d.ts +0 -308
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.d.ts +0 -2664
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js +0 -2360
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +0 -14984
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.d.ts +0 -291
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +0 -4053
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.d.ts +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.js +0 -13
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.d.ts +0 -6
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.js +0 -16
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.d.ts +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.js +0 -23
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/SemanticResourceAttributes.js +0 -1250
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +0 -1726
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.d.ts +0 -5
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.js +0 -12
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.d.ts +0 -308
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.js +0 -315
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/SemanticAttributes.js +0 -2360
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +0 -14984
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.d.ts +0 -291
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.js +0 -301
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +0 -4053
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +0 -4072
- package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.d.ts +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.js +0 -29
- package/node_modules/@opentelemetry/semantic-conventions/build/src/index.d.ts +0 -6
- package/node_modules/@opentelemetry/semantic-conventions/build/src/index.js +0 -32
- package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.d.ts +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.js +0 -27
- package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/SemanticResourceAttributes.js +0 -1255
- package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.js +0 -26
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +0 -1726
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +0 -1759
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.d.ts +0 -5
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.js +0 -15
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_metrics.d.ts +0 -308
- package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/SemanticAttributes.js +0 -2368
- package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.js +0 -26
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +0 -2
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +0 -10
- package/node_modules/fdir/LICENSE +0 -7
- package/node_modules/fdir/README.md +0 -91
- package/node_modules/fdir/dist/index.cjs +0 -588
- package/node_modules/fdir/dist/index.d.cts +0 -155
- package/node_modules/fdir/dist/index.d.mts +0 -155
- package/node_modules/fdir/dist/index.mjs +0 -570
- package/node_modules/fdir/package.json +0 -106
- package/node_modules/picomatch/LICENSE +0 -21
- package/node_modules/picomatch/README.md +0 -743
- package/node_modules/picomatch/index.js +0 -17
- package/node_modules/picomatch/lib/constants.js +0 -184
- package/node_modules/picomatch/lib/parse.js +0 -1425
- package/node_modules/picomatch/lib/picomatch.js +0 -361
- package/node_modules/picomatch/lib/scan.js +0 -403
- package/node_modules/picomatch/lib/utils.js +0 -72
- package/node_modules/picomatch/package.json +0 -83
- package/node_modules/picomatch/posix.js +0 -3
- package/node_modules/tinyglobby/LICENSE +0 -21
- package/node_modules/tinyglobby/README.md +0 -25
- package/node_modules/tinyglobby/dist/index.cjs +0 -335
- package/node_modules/tinyglobby/dist/index.d.cts +0 -148
- package/node_modules/tinyglobby/dist/index.d.mts +0 -148
- package/node_modules/tinyglobby/dist/index.mjs +0 -307
- package/node_modules/tinyglobby/package.json +0 -70
- /package/node_modules/import-in-the-middle/{register-hooks.d.ts → register-hooks.d.mts} +0 -0
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import { URL, fileURLToPath } from 'url'
|
|
6
6
|
import { inspect } from 'util'
|
|
7
7
|
import { builtinModules } from 'module'
|
|
8
|
+
import { isAbsolute } from 'path'
|
|
8
9
|
import { getModuleExports } from './lib/get-exports.mjs'
|
|
10
|
+
import { sourceToString } from './lib/get-esm-exports.mjs'
|
|
9
11
|
import { RESOLVE, driveSync, driveAsync } from './lib/io.mjs'
|
|
10
12
|
import { supportsSyncHooks } from './supports-sync-hooks.mjs'
|
|
11
13
|
|
|
@@ -34,54 +36,47 @@ const HANDLED_FORMATS = new Set([
|
|
|
34
36
|
const TRACE_WARNINGS = process.execArgv.includes('--trace-warnings')
|
|
35
37
|
|
|
36
38
|
/** @typedef {import('node:module').LoadHookContext} LoadContext */
|
|
39
|
+
/** @typedef {import('node:module').ResolveHookContext} ResolveContext */
|
|
40
|
+
/** @typedef {import('node:module').ResolveFnOutput} ResolveResult */
|
|
37
41
|
/** @typedef {import('node:module').LoadFnOutput} LoadResult */
|
|
38
42
|
/** @typedef {string | { specifier: string, format: 'module-typescript' | 'commonjs-typescript' }} SpecifierData */
|
|
39
43
|
/** @typedef {{ name: string, origin: string }} StarBinding */
|
|
44
|
+
/** @typedef {{ url: string, format?: string, importAttributes: Record<string, string>, graph?: ModuleImportGraph }} ModuleImportTarget */
|
|
45
|
+
/** @typedef {{ targets: ModuleImportTarget[], acyclic: boolean }} ModuleImportGraph */
|
|
46
|
+
/** @typedef {(url: string, context: LoadContext) => Generator<Array, ModuleImportGraph>} ResolveImports */
|
|
40
47
|
/**
|
|
41
48
|
* @typedef {object} ProcessResult
|
|
42
49
|
* @property {string[] | Map<string, string | StarBinding>} bindings
|
|
43
50
|
* @property {Map<string, string> | undefined} origins
|
|
51
|
+
* @property {string | undefined} format
|
|
52
|
+
* @property {Set<string> | undefined} [cyclicImports]
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {object} CycleState
|
|
56
|
+
* @property {string} rootUrl
|
|
57
|
+
* @property {Set<string> | undefined} imports
|
|
44
58
|
*/
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
60
|
+
/** @param {string} url The module URL or specifier. */
|
|
61
|
+
function parseIitm (url) {
|
|
62
|
+
const queryIndex = url.indexOf('?')
|
|
63
|
+
if (queryIndex === -1 || url.indexOf('iitm', queryIndex) === -1) return
|
|
51
64
|
try {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
65
|
+
const parsed = new URL(url)
|
|
66
|
+
if (parsed.searchParams.has('iitm')) return parsed
|
|
67
|
+
} catch {}
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
/** @param {string} url The module URL or specifier. */
|
|
71
|
+
function hasIitm (url) {
|
|
72
|
+
return parseIitm(url) !== undefined
|
|
60
73
|
}
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let resultUrl
|
|
68
|
-
const stackTraceLimit = Error.stackTraceLimit
|
|
69
|
-
try {
|
|
70
|
-
Error.stackTraceLimit = 0
|
|
71
|
-
const urlObj = new URL(url)
|
|
72
|
-
if (urlObj.searchParams.has('iitm')) {
|
|
73
|
-
urlObj.searchParams.delete('iitm')
|
|
74
|
-
resultUrl = urlObj.href
|
|
75
|
-
if (resultUrl.startsWith('file:///node:')) {
|
|
76
|
-
resultUrl = resultUrl.replace('file:///', '')
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
resultUrl = urlObj.href
|
|
80
|
-
}
|
|
81
|
-
} catch {
|
|
82
|
-
resultUrl = url
|
|
83
|
-
}
|
|
84
|
-
Error.stackTraceLimit = stackTraceLimit
|
|
75
|
+
/** @param {URL} parsedURL The parsed wrapper URL. */
|
|
76
|
+
function deleteIitm (parsedURL) {
|
|
77
|
+
parsedURL.searchParams.delete('iitm')
|
|
78
|
+
const resultUrl = parsedURL.href
|
|
79
|
+
if (resultUrl.startsWith('file:///node:')) return resultUrl.slice('file:///'.length)
|
|
85
80
|
return resultUrl
|
|
86
81
|
}
|
|
87
82
|
|
|
@@ -212,6 +207,7 @@ function shouldExcludeExport (name, sourceUrl) {
|
|
|
212
207
|
* @param {object} params
|
|
213
208
|
* @param {string} params.srcUrl The full URL to the module to process.
|
|
214
209
|
* @param {LoadContext} params.context Provided by the loaders API.
|
|
210
|
+
* @param {ResolveImports} params.resolveImports The cached static-import resolver.
|
|
215
211
|
* @param {boolean} [params.excludeDefault = false] Exclude the default export.
|
|
216
212
|
* @param {number} [params.depth = 0] Star-re-export recursion depth. Used to
|
|
217
213
|
* detect `export *` cycles (`a` re-exports `b`, `b` re-exports `a`) cheaply:
|
|
@@ -221,20 +217,28 @@ function shouldExcludeExport (name, sourceUrl) {
|
|
|
221
217
|
* created lazily once `depth` crosses {@link STAR_CYCLE_DEPTH}. A URL is added
|
|
222
218
|
* before descending into its subtree and removed once that subtree finishes, so
|
|
223
219
|
* it tracks the active path rather than every URL ever visited.
|
|
220
|
+
* @param {CycleState} [params.cycleState] The wrapper root and detected cycle edges.
|
|
224
221
|
* @returns {Generator<Array, ProcessResult>}
|
|
225
222
|
* A generator that yields I/O operations and ultimately returns the shimmed
|
|
226
223
|
* bindings for all the exports from the module and any transitive export all
|
|
227
224
|
* modules. `origins` (the defining module per `*`-sourced name) is `undefined`
|
|
228
225
|
* for a module with no `export *`.
|
|
229
226
|
*/
|
|
230
|
-
function * processModule ({ srcUrl, context, excludeDefault = false, depth = 0, seen }) {
|
|
231
|
-
|
|
227
|
+
function * processModule ({ srcUrl, context, resolveImports, excludeDefault = false, depth = 0, seen, cycleState }) {
|
|
228
|
+
let isCycleRoot = false
|
|
229
|
+
const moduleExports = yield * getModuleExports(srcUrl, context, cycleState !== undefined)
|
|
230
|
+
const { exportNames, starReexports, format } = moduleExports
|
|
231
|
+
|
|
232
|
+
if (cycleState !== undefined && moduleExports.hasModuleImports) {
|
|
233
|
+
cycleState.imports ??= new Set()
|
|
234
|
+
cycleState.imports.add(srcUrl)
|
|
235
|
+
}
|
|
232
236
|
|
|
233
237
|
// Most modules have no export star. Keep that path array-backed so it pays
|
|
234
238
|
// neither merge bookkeeping nor a Map lookup for each direct export.
|
|
235
239
|
if (starReexports === undefined) {
|
|
236
240
|
if (!excludeDefault) {
|
|
237
|
-
return { bindings: exportNames, origins: undefined }
|
|
241
|
+
return { bindings: exportNames, origins: undefined, format }
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
const bindings = []
|
|
@@ -242,7 +246,12 @@ function * processModule ({ srcUrl, context, excludeDefault = false, depth = 0,
|
|
|
242
246
|
if (shouldExcludeExport(name, srcUrl)) continue
|
|
243
247
|
bindings.push(name)
|
|
244
248
|
}
|
|
245
|
-
return { bindings, origins: undefined }
|
|
249
|
+
return { bindings, origins: undefined, format }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (cycleState === undefined) {
|
|
253
|
+
cycleState = { rootUrl: srcUrl, imports: undefined }
|
|
254
|
+
isCycleRoot = true
|
|
246
255
|
}
|
|
247
256
|
|
|
248
257
|
const bindings = new Map()
|
|
@@ -306,9 +315,11 @@ function * processModule ({ srcUrl, context, excludeDefault = false, depth = 0,
|
|
|
306
315
|
const sub = yield * processModule({
|
|
307
316
|
srcUrl: result.url,
|
|
308
317
|
context: { ...context, format: result.format },
|
|
318
|
+
resolveImports,
|
|
309
319
|
excludeDefault: true,
|
|
310
320
|
depth: depth + 1,
|
|
311
|
-
seen
|
|
321
|
+
seen,
|
|
322
|
+
cycleState
|
|
312
323
|
})
|
|
313
324
|
|
|
314
325
|
for (const binding of sub.bindings.values()) {
|
|
@@ -341,12 +352,66 @@ function * processModule ({ srcUrl, context, excludeDefault = false, depth = 0,
|
|
|
341
352
|
}
|
|
342
353
|
}
|
|
343
354
|
|
|
344
|
-
|
|
355
|
+
if (isCycleRoot && cycleState.imports !== undefined) {
|
|
356
|
+
const candidates = cycleState.imports
|
|
357
|
+
cycleState.imports = undefined
|
|
358
|
+
const seenImports = new Set()
|
|
359
|
+
for (const candidate of candidates) {
|
|
360
|
+
yield * findCyclicImports(candidate, context, cycleState, seenImports, resolveImports)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (isCycleRoot && cycleState.imports !== undefined) {
|
|
365
|
+
return { bindings, origins: starOrigins, format, cyclicImports: cycleState.imports }
|
|
366
|
+
}
|
|
367
|
+
return { bindings, origins: starOrigins, format }
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @param {string} url The module whose static requests can close the cycle.
|
|
372
|
+
* @param {LoadContext} context The metadata load context.
|
|
373
|
+
* @param {CycleState} cycleState The wrapper root and its closing importers.
|
|
374
|
+
* @param {Set<string>} seen Modules already inspected for this wrapper.
|
|
375
|
+
* @param {ResolveImports} resolveImports The cached static-import resolver.
|
|
376
|
+
* @param {ModuleImportGraph} [graph] The resolved target graph, if already available.
|
|
377
|
+
*/
|
|
378
|
+
function * findCyclicImports (url, context, cycleState, seen, resolveImports, graph) {
|
|
379
|
+
graph ??= yield * resolveImports(url, context)
|
|
380
|
+
if (graph.acyclic) return true
|
|
381
|
+
if (seen.has(url)) return false
|
|
382
|
+
seen.add(url)
|
|
383
|
+
let acyclic = true
|
|
384
|
+
for (const imported of graph.targets) {
|
|
385
|
+
const { url: target, format, importAttributes } = imported
|
|
386
|
+
if (target === cycleState.rootUrl) {
|
|
387
|
+
cycleState.imports ??= new Set()
|
|
388
|
+
cycleState.imports.add(url)
|
|
389
|
+
acyclic = false
|
|
390
|
+
} else if (format === 'module' || format === 'module-typescript' || format === undefined) {
|
|
391
|
+
if (imported.graph?.acyclic) continue
|
|
392
|
+
const targetContext = { ...context, format, importAttributes }
|
|
393
|
+
imported.graph ??= yield * resolveImports(target, targetContext)
|
|
394
|
+
if (!(yield * findCyclicImports(target, targetContext, cycleState, seen, resolveImports, imported.graph))) {
|
|
395
|
+
acyclic = false
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (acyclic) graph.acyclic = true
|
|
400
|
+
return acyclic
|
|
345
401
|
}
|
|
346
402
|
|
|
347
|
-
|
|
403
|
+
/**
|
|
404
|
+
* @param {string} url
|
|
405
|
+
* @param {'true' | 'bindings'} [kind]
|
|
406
|
+
*/
|
|
407
|
+
function addIitm (url, kind = 'true') {
|
|
408
|
+
if (url.indexOf('?') === -1) {
|
|
409
|
+
const hashIndex = url.indexOf('#')
|
|
410
|
+
if (hashIndex === -1) return `${url}?iitm=${kind}`
|
|
411
|
+
return `${url.slice(0, hashIndex)}?iitm=${kind}${url.slice(hashIndex)}`
|
|
412
|
+
}
|
|
348
413
|
const urlObj = new URL(url)
|
|
349
|
-
urlObj.searchParams.set('iitm',
|
|
414
|
+
urlObj.searchParams.set('iitm', kind)
|
|
350
415
|
return urlObj.href
|
|
351
416
|
}
|
|
352
417
|
|
|
@@ -358,9 +423,79 @@ export function createHook (meta) {
|
|
|
358
423
|
const specifiers = new Map()
|
|
359
424
|
let cachedResolve
|
|
360
425
|
const iitmURL = new URL('lib/register.js', meta.url).toString()
|
|
426
|
+
const createHookURL = meta.url.replace('hook.mjs', 'create-hook.mjs')
|
|
361
427
|
let includeModules, excludeModules
|
|
362
428
|
let shouldInclude = defaultShouldInclude
|
|
363
429
|
let disableCjsSourceStripping = false
|
|
430
|
+
/** @type {Map<string, Set<string>> | undefined} */
|
|
431
|
+
let cyclicImportTargets
|
|
432
|
+
/** @type {Map<string, string> | undefined} */
|
|
433
|
+
let cyclicSources
|
|
434
|
+
/** @type {Map<string, ModuleImportGraph> | undefined} */
|
|
435
|
+
let moduleImportTargets
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @param {string} url The module whose static imports are resolved.
|
|
439
|
+
* @param {LoadContext} context Its metadata load context.
|
|
440
|
+
*/
|
|
441
|
+
function * resolveImports (url, context) {
|
|
442
|
+
const cached = moduleImportTargets?.get(url)
|
|
443
|
+
if (cached !== undefined) return cached
|
|
444
|
+
const { moduleImports } = yield * getModuleExports(url, context, true)
|
|
445
|
+
const targets = []
|
|
446
|
+
if (moduleImports !== undefined) {
|
|
447
|
+
for (const imported of moduleImports) {
|
|
448
|
+
const specifier = typeof imported === 'string' ? imported : imported.specifier
|
|
449
|
+
const importAttributes = typeof imported === 'string' ? {} : Object.fromEntries(imported.attributes)
|
|
450
|
+
const { url: target, format } = yield [RESOLVE, specifier, { parentURL: url, importAttributes }]
|
|
451
|
+
targets.push({ url: target, format, importAttributes, graph: undefined })
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
moduleImportTargets ??= new Map()
|
|
455
|
+
const graph = { targets, acyclic: false }
|
|
456
|
+
moduleImportTargets.set(url, graph)
|
|
457
|
+
return graph
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @param {string} url The native module URL.
|
|
462
|
+
* @param {LoadResult} result The actual native load result.
|
|
463
|
+
*/
|
|
464
|
+
function prepareNativeSource (url, result) {
|
|
465
|
+
const targets = cyclicImportTargets?.get(url)
|
|
466
|
+
if (targets === undefined || targets.size === 0 ||
|
|
467
|
+
(result.format !== 'module' && result.format !== 'module-typescript')) return result
|
|
468
|
+
|
|
469
|
+
let bindingImports = ''
|
|
470
|
+
if (result.source != null) {
|
|
471
|
+
for (const target of targets) {
|
|
472
|
+
bindingImports += `\nimport ${JSON.stringify(addIitm(target, 'bindings'))}\n`
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
// A consumed target must not be queued again by a later barrel.
|
|
476
|
+
targets.clear()
|
|
477
|
+
if (bindingImports === '') return result
|
|
478
|
+
// Original dependencies must initialize before the cycle's shared bindings.
|
|
479
|
+
return { ...result, source: sourceToString(result.source) + bindingImports }
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* @param {Set<string>} imports The cycle's closing importers.
|
|
484
|
+
* @param {string} targetURL The wrapper root URL.
|
|
485
|
+
*/
|
|
486
|
+
function mergeCyclicImports (imports, targetURL) {
|
|
487
|
+
for (const parentURL of imports) {
|
|
488
|
+
cyclicImportTargets ??= new Map()
|
|
489
|
+
let targets = cyclicImportTargets.get(parentURL)
|
|
490
|
+
if (targets === undefined) {
|
|
491
|
+
targets = new Set()
|
|
492
|
+
cyclicImportTargets.set(parentURL, targets)
|
|
493
|
+
} else if (targets.size === 0) {
|
|
494
|
+
continue
|
|
495
|
+
}
|
|
496
|
+
targets.add(targetURL)
|
|
497
|
+
}
|
|
498
|
+
}
|
|
364
499
|
|
|
365
500
|
// Track CJS module URLs that IITM has wrapped. On Node 24+, CJS modules loaded
|
|
366
501
|
// via loadCJSModule (in an ESM import chain) have their require() calls for
|
|
@@ -378,33 +513,36 @@ export function createHook (meta) {
|
|
|
378
513
|
// node_modules, and the full file URL for non-bare specifier imports (relative
|
|
379
514
|
// paths would be error prone). An absolute path entry added via Hook over the
|
|
380
515
|
// message port matches the resolved file path, so it is resolved here.
|
|
516
|
+
/**
|
|
517
|
+
* @param {string} url The resolved module URL.
|
|
518
|
+
* @param {string} specifier The original import specifier.
|
|
519
|
+
*/
|
|
381
520
|
function defaultShouldInclude (url, specifier) {
|
|
521
|
+
if (includeModules === undefined && excludeModules === undefined) return true
|
|
522
|
+
|
|
382
523
|
let resultPath
|
|
383
|
-
|
|
384
|
-
const stackTraceLimit = Error.stackTraceLimit
|
|
385
|
-
Error.stackTraceLimit = 0
|
|
386
|
-
try {
|
|
387
|
-
resultPath = fileURLToPath(url)
|
|
388
|
-
} catch {}
|
|
389
|
-
Error.stackTraceLimit = stackTraceLimit
|
|
390
|
-
}
|
|
524
|
+
/** @param {string | RegExp} each The module filter. */
|
|
391
525
|
function match (each) {
|
|
392
|
-
if (each instanceof RegExp)
|
|
393
|
-
|
|
526
|
+
if (each instanceof RegExp) return each.test(url)
|
|
527
|
+
if (each === specifier || each === url) return true
|
|
528
|
+
if (!isAbsolute(each)) return false
|
|
529
|
+
|
|
530
|
+
if (resultPath === undefined) {
|
|
531
|
+
resultPath = ''
|
|
532
|
+
if (url.startsWith('file:')) {
|
|
533
|
+
const stackTraceLimit = Error.stackTraceLimit
|
|
534
|
+
Error.stackTraceLimit = 0
|
|
535
|
+
try {
|
|
536
|
+
resultPath = fileURLToPath(url)
|
|
537
|
+
} catch {}
|
|
538
|
+
Error.stackTraceLimit = stackTraceLimit
|
|
539
|
+
}
|
|
394
540
|
}
|
|
395
|
-
|
|
396
|
-
return each === specifier || each === url || (resultPath && each === resultPath)
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (includeModules && !includeModules.some(match)) {
|
|
400
|
-
return false
|
|
541
|
+
return each === resultPath
|
|
401
542
|
}
|
|
402
543
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return true
|
|
544
|
+
return (includeModules === undefined || includeModules.some(match)) &&
|
|
545
|
+
(excludeModules === undefined || !excludeModules.some(match))
|
|
408
546
|
}
|
|
409
547
|
|
|
410
548
|
// Applies the include/exclude/message-port configuration. Shared by the
|
|
@@ -462,13 +600,21 @@ export function createHook (meta) {
|
|
|
462
600
|
// once the parent loader has turned the specifier into a resolved URL. The
|
|
463
601
|
// only difference between the asynchronous and synchronous hooks is whether
|
|
464
602
|
// that resolution was awaited, so all the wrapping decisions live here.
|
|
465
|
-
|
|
603
|
+
/**
|
|
604
|
+
* @param {{ url: string, format?: string }} result The resolved module.
|
|
605
|
+
* @param {string} specifier The original module specifier.
|
|
606
|
+
* @param {ResolveContext} context The resolve context.
|
|
607
|
+
* @param {string} parentURL The importing module URL.
|
|
608
|
+
* @param {boolean} binding Whether the request is for a cycle binding module.
|
|
609
|
+
*/
|
|
610
|
+
function finishResolve (result, specifier, context, parentURL, binding) {
|
|
466
611
|
// Do not wrap the entrypoint module. Many CLIs check whether they are the
|
|
467
612
|
// "main" module (e.g. require.main === module). Wrapping changes how they
|
|
468
613
|
// are evaluated, and can make them exit without doing anything.
|
|
469
614
|
if (parentURL === '') {
|
|
470
615
|
if (!EXTENSION_RE.test(result.url) && !hasIitm(result.url)) {
|
|
471
|
-
|
|
616
|
+
// Extensionless CLIs can be ESM; preserve the format resolved by Node or an upstream loader.
|
|
617
|
+
return { url: result.url, format: result.format ?? 'commonjs' }
|
|
472
618
|
}
|
|
473
619
|
return result
|
|
474
620
|
}
|
|
@@ -492,13 +638,17 @@ export function createHook (meta) {
|
|
|
492
638
|
return result
|
|
493
639
|
}
|
|
494
640
|
|
|
641
|
+
if (binding) {
|
|
642
|
+
return { ...result, url: addIitm(result.url, 'bindings'), shortCircuit: true, format: 'module' }
|
|
643
|
+
}
|
|
644
|
+
|
|
495
645
|
// `shouldInclude` is always set (the include/exclude list matcher by default,
|
|
496
646
|
// a consumer-provided predicate otherwise), so no nullish check is needed.
|
|
497
647
|
if (!shouldInclude(result.url, specifier)) {
|
|
498
648
|
return result
|
|
499
649
|
}
|
|
500
650
|
|
|
501
|
-
if (
|
|
651
|
+
if (parentURL === meta.url || parentURL === createHookURL || (parentURL && hasIitm(parentURL))) {
|
|
502
652
|
return result
|
|
503
653
|
}
|
|
504
654
|
|
|
@@ -534,10 +684,11 @@ export function createHook (meta) {
|
|
|
534
684
|
}
|
|
535
685
|
|
|
536
686
|
// Preserve the format before an outer loader can normalize it.
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
687
|
+
if (result.format === 'module-typescript' || result.format === 'commonjs-typescript') {
|
|
688
|
+
specifiers.set(result.url, { specifier, format: result.format })
|
|
689
|
+
} else {
|
|
690
|
+
specifiers.set(result.url, specifier)
|
|
691
|
+
}
|
|
541
692
|
|
|
542
693
|
return {
|
|
543
694
|
url: addIitm(result.url),
|
|
@@ -549,9 +700,16 @@ export function createHook (meta) {
|
|
|
549
700
|
}
|
|
550
701
|
}
|
|
551
702
|
|
|
703
|
+
/**
|
|
704
|
+
* @param {string} specifier
|
|
705
|
+
* @param {ResolveContext} context
|
|
706
|
+
* @param {(specifier: string, context?: Partial<ResolveContext>) => ResolveResult | Promise<ResolveResult>} parentResolve
|
|
707
|
+
*/
|
|
552
708
|
async function resolve (specifier, context, parentResolve) {
|
|
553
709
|
cachedResolve = parentResolve
|
|
554
710
|
|
|
711
|
+
const { parentURL = '' } = context
|
|
712
|
+
|
|
555
713
|
// See https://github.com/nodejs/import-in-the-middle/pull/76.
|
|
556
714
|
if (specifier === iitmURL) {
|
|
557
715
|
return {
|
|
@@ -560,22 +718,29 @@ export function createHook (meta) {
|
|
|
560
718
|
}
|
|
561
719
|
}
|
|
562
720
|
|
|
563
|
-
const
|
|
564
|
-
const
|
|
721
|
+
const parsedURL = parseIitm(specifier)
|
|
722
|
+
const binding = parsedURL?.searchParams.get('iitm') === 'bindings'
|
|
723
|
+
const newSpecifier = parsedURL === undefined ? specifier : deleteIitm(parsedURL)
|
|
565
724
|
if (isWin && parentURL.indexOf('file:node') === 0) {
|
|
566
725
|
context.parentURL = ''
|
|
567
726
|
}
|
|
568
727
|
const result = await parentResolve(newSpecifier, context)
|
|
569
728
|
|
|
570
|
-
return finishResolve(result, specifier, context, parentURL)
|
|
729
|
+
return finishResolve(result, specifier, context, parentURL, binding)
|
|
571
730
|
}
|
|
572
731
|
|
|
573
732
|
// Synchronous counterpart to `resolve`, for `module.registerHooks`. The
|
|
574
733
|
// synchronous `nextResolve` returns its result directly. We stash it so the
|
|
575
734
|
// synchronous `load` hook can resolve star re-exports later, mirroring how
|
|
576
735
|
// `resolve` caches `parentResolve`.
|
|
736
|
+
/**
|
|
737
|
+
* @param {string} specifier
|
|
738
|
+
* @param {ResolveContext} context
|
|
739
|
+
* @param {(specifier: string, context?: Partial<ResolveContext>) => ResolveResult} nextResolve
|
|
740
|
+
*/
|
|
577
741
|
function resolveSync (specifier, context, nextResolve) {
|
|
578
742
|
cachedResolve = nextResolve
|
|
743
|
+
const { parentURL = '' } = context
|
|
579
744
|
|
|
580
745
|
if (specifier === iitmURL) {
|
|
581
746
|
return {
|
|
@@ -584,14 +749,15 @@ export function createHook (meta) {
|
|
|
584
749
|
}
|
|
585
750
|
}
|
|
586
751
|
|
|
587
|
-
const
|
|
588
|
-
const
|
|
752
|
+
const parsedURL = parseIitm(specifier)
|
|
753
|
+
const binding = parsedURL?.searchParams.get('iitm') === 'bindings'
|
|
754
|
+
const newSpecifier = parsedURL === undefined ? specifier : deleteIitm(parsedURL)
|
|
589
755
|
if (isWin && parentURL.indexOf('file:node') === 0) {
|
|
590
756
|
context.parentURL = ''
|
|
591
757
|
}
|
|
592
758
|
const result = nextResolve(newSpecifier, context)
|
|
593
759
|
|
|
594
|
-
return finishResolve(result, specifier, context, parentURL)
|
|
760
|
+
return finishResolve(result, specifier, context, parentURL, binding)
|
|
595
761
|
}
|
|
596
762
|
|
|
597
763
|
/**
|
|
@@ -600,8 +766,10 @@ export function createHook (meta) {
|
|
|
600
766
|
* @param {string} realUrl The URL of the wrapped module.
|
|
601
767
|
* @param {string[] | Map<string, string | StarBinding>} bindings Its exported bindings.
|
|
602
768
|
* @param {string} originalSpecifier The specifier used to import the module.
|
|
769
|
+
* @param {string | undefined} format The wrapped module's loader format.
|
|
770
|
+
* @param {boolean} [staged] Defer Hook invocation until the native root finishes.
|
|
603
771
|
*/
|
|
604
|
-
function buildWrapperSource (realUrl, bindings, originalSpecifier) {
|
|
772
|
+
function buildWrapperSource (realUrl, bindings, originalSpecifier, format, staged = false) {
|
|
605
773
|
// The wrapped module imports its namespace as `namespace`, which serves
|
|
606
774
|
// every export but the ones a same-origin `export *` collision forced onto
|
|
607
775
|
// their defining module (#171): the aggregate namespace drops those as
|
|
@@ -613,6 +781,7 @@ export function createHook (meta) {
|
|
|
613
781
|
let bindingNames = ''
|
|
614
782
|
let bindingSources
|
|
615
783
|
let exportSpecifiers = ''
|
|
784
|
+
let facadeSpecifiers = ''
|
|
616
785
|
let writeCases = ''
|
|
617
786
|
let index = 0
|
|
618
787
|
for (const binding of bindings.values()) {
|
|
@@ -641,53 +810,77 @@ export function createHook (meta) {
|
|
|
641
810
|
}
|
|
642
811
|
writeCases += ` case ${index++}: ${variableName} = value; break\n`
|
|
643
812
|
if (shouldReexport(name, realUrl)) {
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
813
|
+
const exportSpecifier = staged ? variableName : `${variableName} as ${name === 'default' ? name : objectKey}`
|
|
814
|
+
if (staged) {
|
|
815
|
+
if (facadeSpecifiers !== '') facadeSpecifiers += ', '
|
|
816
|
+
facadeSpecifiers += `${variableName} as ${objectKey}`
|
|
817
|
+
}
|
|
818
|
+
if (exportSpecifiers !== '') exportSpecifiers += ', '
|
|
819
|
+
exportSpecifiers += exportSpecifier
|
|
648
820
|
}
|
|
649
821
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
822
|
+
let binder = 'const __binder = new ModuleBinder(namespace)\n'
|
|
823
|
+
if (declarationNames !== '') {
|
|
824
|
+
let sources = ''
|
|
825
|
+
if (bindingSources !== undefined) {
|
|
826
|
+
sources = `, [${bindingSources}]`
|
|
827
|
+
} else if (staged) {
|
|
828
|
+
sources = ', undefined'
|
|
829
|
+
}
|
|
830
|
+
binder = `let ${declarationNames}
|
|
653
831
|
function __write (index, value) {
|
|
654
832
|
switch (index) {
|
|
655
833
|
${writeCases} }
|
|
656
834
|
}
|
|
657
|
-
const __binder = new ModuleBinder(namespace, [${bindingNames}], __write${
|
|
658
|
-
? ''
|
|
659
|
-
: `, [${bindingSources}]`})
|
|
835
|
+
const __binder = new ModuleBinder(namespace, [${bindingNames}], __write${sources}${staged ? ', true' : ''})
|
|
660
836
|
`
|
|
837
|
+
}
|
|
661
838
|
const reexports = exportSpecifiers === '' ? '' : `export { ${exportSpecifiers} }\n`
|
|
662
839
|
|
|
663
|
-
|
|
664
|
-
|
|
840
|
+
let registration = 'export default __binder'
|
|
841
|
+
if (!staged) {
|
|
842
|
+
registration = `__binder.flush()\n\nregister(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifier)}, ${JSON.stringify(format)})`
|
|
843
|
+
}
|
|
844
|
+
const source = `
|
|
845
|
+
import { ${staged ? '' : 'register, '}ModuleBinder } from ${JSON.stringify(iitmURL)}
|
|
665
846
|
import * as namespace from ${JSON.stringify(realUrl)}
|
|
666
847
|
${originImports}
|
|
667
848
|
${binder}
|
|
668
849
|
${reexports}
|
|
669
850
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifier)})
|
|
851
|
+
${registration}
|
|
673
852
|
`
|
|
853
|
+
return staged ? { source, facadeSpecifiers } : source
|
|
674
854
|
}
|
|
675
855
|
|
|
676
856
|
/**
|
|
677
857
|
* Finalizes a successful wrap and builds its module source.
|
|
678
858
|
*
|
|
679
859
|
* @param {string} realUrl The URL of the wrapped module.
|
|
680
|
-
* @param {
|
|
860
|
+
* @param {string | undefined} format The wrapped module's loader format.
|
|
681
861
|
* @param {string} originalSpecifier The original import specifier.
|
|
682
|
-
* @param {
|
|
862
|
+
* @param {ProcessResult} result The processed export bindings and cycle candidates.
|
|
683
863
|
*/
|
|
684
|
-
function onWrapSuccess (realUrl,
|
|
864
|
+
function onWrapSuccess (realUrl, format, originalSpecifier, { bindings, cyclicImports }) {
|
|
685
865
|
specifiers.delete(realUrl)
|
|
686
|
-
|
|
687
|
-
if (context.format === 'commonjs') {
|
|
866
|
+
if (format === 'commonjs') {
|
|
688
867
|
cjsInIitmChain.add(realUrl)
|
|
689
868
|
}
|
|
690
|
-
return buildWrapperSource(realUrl, bindings, originalSpecifier)
|
|
869
|
+
if (cyclicImports === undefined) return buildWrapperSource(realUrl, bindings, originalSpecifier, format)
|
|
870
|
+
|
|
871
|
+
const bindingURL = addIitm(realUrl, 'bindings')
|
|
872
|
+
const { source, facadeSpecifiers } = buildWrapperSource(realUrl, bindings, originalSpecifier, format, true)
|
|
873
|
+
cyclicSources ??= new Map()
|
|
874
|
+
cyclicSources.set(bindingURL, source)
|
|
875
|
+
mergeCyclicImports(cyclicImports, realUrl)
|
|
876
|
+
return `
|
|
877
|
+
import ${JSON.stringify(realUrl)}
|
|
878
|
+
import __binder from ${JSON.stringify(bindingURL)}
|
|
879
|
+
export { ${facadeSpecifiers} } from ${JSON.stringify(bindingURL)}
|
|
880
|
+
import { register } from ${JSON.stringify(iitmURL)}
|
|
881
|
+
__binder.flushSync()
|
|
882
|
+
register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifier)}, ${JSON.stringify(format)})
|
|
883
|
+
`
|
|
691
884
|
}
|
|
692
885
|
|
|
693
886
|
// Bookkeeping shared by the async and sync wrap paths when `processModule`
|
|
@@ -710,34 +903,33 @@ register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifie
|
|
|
710
903
|
* @param {string} url
|
|
711
904
|
* @param {LoadContext} context
|
|
712
905
|
* @param {(url: string, context?: Partial<LoadContext>) => LoadResult | Promise<LoadResult>} parentGetSource
|
|
906
|
+
* @param {string} realUrl The original module URL.
|
|
713
907
|
*/
|
|
714
|
-
async function getSource (url, context, parentGetSource) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
return parentGetSource(url, context)
|
|
721
|
-
}
|
|
908
|
+
async function getSource (url, context, parentGetSource, realUrl) {
|
|
909
|
+
const specifierData = specifiers.get(realUrl)
|
|
910
|
+
if (specifierData === undefined) {
|
|
911
|
+
specifiers.delete(url)
|
|
912
|
+
return parentGetSource(url, context)
|
|
913
|
+
}
|
|
722
914
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
915
|
+
let originalSpecifier = specifierData
|
|
916
|
+
let processContext = context
|
|
917
|
+
if (typeof specifierData !== 'string') {
|
|
918
|
+
originalSpecifier = specifierData.specifier
|
|
919
|
+
processContext = { ...context, format: specifierData.format }
|
|
920
|
+
}
|
|
729
921
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
922
|
+
try {
|
|
923
|
+
const result = await driveAsync(
|
|
924
|
+
processModule({ srcUrl: realUrl, context: processContext, resolveImports }),
|
|
925
|
+
{ resolve: cachedResolve, load: parentGetSource }
|
|
926
|
+
)
|
|
927
|
+
const source = onWrapSuccess(realUrl, result.format, originalSpecifier, result)
|
|
928
|
+
return { source }
|
|
929
|
+
} catch (cause) {
|
|
930
|
+
onWrapFailure(realUrl, cause)
|
|
931
|
+
// Revert back to the non-iitm URL
|
|
932
|
+
url = realUrl
|
|
741
933
|
}
|
|
742
934
|
|
|
743
935
|
return parentGetSource(url, context)
|
|
@@ -750,41 +942,52 @@ register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifie
|
|
|
750
942
|
* @param {string} url
|
|
751
943
|
* @param {LoadContext} context
|
|
752
944
|
* @param {(url: string, context?: Partial<LoadContext>) => LoadResult} nextLoad
|
|
945
|
+
* @param {string} realUrl The original module URL.
|
|
753
946
|
*/
|
|
754
|
-
function getSourceSync (url, context, nextLoad) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return nextLoad(url, context)
|
|
761
|
-
}
|
|
947
|
+
function getSourceSync (url, context, nextLoad, realUrl) {
|
|
948
|
+
const specifierData = specifiers.get(realUrl)
|
|
949
|
+
if (specifierData === undefined) {
|
|
950
|
+
specifiers.delete(url)
|
|
951
|
+
return nextLoad(url, context)
|
|
952
|
+
}
|
|
762
953
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
954
|
+
let originalSpecifier = specifierData
|
|
955
|
+
let processContext = context
|
|
956
|
+
if (typeof specifierData !== 'string') {
|
|
957
|
+
originalSpecifier = specifierData.specifier
|
|
958
|
+
processContext = { ...context, format: specifierData.format }
|
|
959
|
+
}
|
|
769
960
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
961
|
+
try {
|
|
962
|
+
const result = driveSync(
|
|
963
|
+
processModule({ srcUrl: realUrl, context: processContext, resolveImports }),
|
|
964
|
+
{ resolve: cachedResolve, load: nextLoad }
|
|
965
|
+
)
|
|
966
|
+
const source = onWrapSuccess(realUrl, result.format, originalSpecifier, result)
|
|
967
|
+
return { source }
|
|
968
|
+
} catch (cause) {
|
|
969
|
+
onWrapFailure(realUrl, cause)
|
|
970
|
+
url = realUrl
|
|
780
971
|
}
|
|
781
972
|
|
|
782
973
|
return nextLoad(url, context)
|
|
783
974
|
}
|
|
784
975
|
|
|
976
|
+
/**
|
|
977
|
+
* @param {string} url
|
|
978
|
+
* @param {LoadContext} context
|
|
979
|
+
* @param {(url: string, context?: Partial<LoadContext>) => LoadResult | Promise<LoadResult>} parentLoad
|
|
980
|
+
*/
|
|
785
981
|
async function load (url, context, parentLoad) {
|
|
786
|
-
|
|
787
|
-
|
|
982
|
+
const parsedURL = parseIitm(url)
|
|
983
|
+
if (parsedURL !== undefined) {
|
|
984
|
+
if (parsedURL.searchParams.get('iitm') === 'bindings') {
|
|
985
|
+
const source = cyclicSources?.get(url)
|
|
986
|
+
if (source === undefined) return parentLoad(url, context)
|
|
987
|
+
return { source, shortCircuit: true, format: 'module' }
|
|
988
|
+
}
|
|
989
|
+
const realUrl = deleteIitm(parsedURL)
|
|
990
|
+
const result = await getSource(url, context, parentLoad, realUrl)
|
|
788
991
|
// If wrapping failed, `getSource()` may have fallen back to `parentLoad`,
|
|
789
992
|
// which can legally return `source: null` (e.g. for non-JS formats).
|
|
790
993
|
if (result && typeof result === 'object' && result.source != null) {
|
|
@@ -796,7 +999,7 @@ register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifie
|
|
|
796
999
|
}
|
|
797
1000
|
|
|
798
1001
|
// Fall back to the parent loader with the original (non-iitm) URL.
|
|
799
|
-
return parentLoad(
|
|
1002
|
+
return parentLoad(realUrl, context)
|
|
800
1003
|
}
|
|
801
1004
|
|
|
802
1005
|
// On Node 22+, when a CJS module is loaded through the ESM translator and
|
|
@@ -817,15 +1020,27 @@ register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifie
|
|
|
817
1020
|
return result
|
|
818
1021
|
}
|
|
819
1022
|
|
|
820
|
-
return parentLoad(url, context)
|
|
1023
|
+
return prepareNativeSource(url, await parentLoad(url, context))
|
|
821
1024
|
}
|
|
822
1025
|
|
|
823
1026
|
// Synchronous counterpart to `load`, for `module.registerHooks`. Mirrors the
|
|
824
1027
|
// async `load` exactly — wrapping via `getSourceSync` and applying the same
|
|
825
1028
|
// CJS-in-iitm-chain source stripping — only without awaiting.
|
|
1029
|
+
/**
|
|
1030
|
+
* @param {string} url
|
|
1031
|
+
* @param {LoadContext} context
|
|
1032
|
+
* @param {(url: string, context?: Partial<LoadContext>) => LoadResult} nextLoad
|
|
1033
|
+
*/
|
|
826
1034
|
function loadSync (url, context, nextLoad) {
|
|
827
|
-
|
|
828
|
-
|
|
1035
|
+
const parsedURL = parseIitm(url)
|
|
1036
|
+
if (parsedURL !== undefined) {
|
|
1037
|
+
if (parsedURL.searchParams.get('iitm') === 'bindings') {
|
|
1038
|
+
const source = cyclicSources?.get(url)
|
|
1039
|
+
if (source === undefined) return nextLoad(url, context)
|
|
1040
|
+
return { source, shortCircuit: true, format: 'module' }
|
|
1041
|
+
}
|
|
1042
|
+
const realUrl = deleteIitm(parsedURL)
|
|
1043
|
+
const result = getSourceSync(url, context, nextLoad, realUrl)
|
|
829
1044
|
// If wrapping failed, `getSourceSync()` may have fallen back to `nextLoad`,
|
|
830
1045
|
// which can legally return `source: null` (e.g. for non-JS formats).
|
|
831
1046
|
if (result && typeof result === 'object' && result.source != null) {
|
|
@@ -837,7 +1052,7 @@ register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifie
|
|
|
837
1052
|
}
|
|
838
1053
|
|
|
839
1054
|
// Fall back to the parent loader with the original (non-iitm) URL.
|
|
840
|
-
return nextLoad(
|
|
1055
|
+
return nextLoad(realUrl, context)
|
|
841
1056
|
}
|
|
842
1057
|
|
|
843
1058
|
if (cjsInIitmChain.has(url) && !disableCjsSourceStripping) {
|
|
@@ -851,7 +1066,7 @@ register(${JSON.stringify(realUrl)}, __binder, ${JSON.stringify(originalSpecifie
|
|
|
851
1066
|
return result
|
|
852
1067
|
}
|
|
853
1068
|
|
|
854
|
-
return nextLoad(url, context)
|
|
1069
|
+
return prepareNativeSource(url, nextLoad(url, context))
|
|
855
1070
|
}
|
|
856
1071
|
|
|
857
1072
|
return { initialize, load, resolve, resolveSync, loadSync, applyOptions }
|