@format.dev/compile 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -20
- package/bin/format-compile +3 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.mjs +46 -0
- package/dist/node_modules/.pnpm/@babel_parser@7.29.8/node_modules/@babel/parser/lib/index.mjs +12606 -0
- package/dist/node_modules/.pnpm/@babel_parser@7.29.8/node_modules/@babel/parser/lib/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/dist/compiler-core.cjs.mjs +4866 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/dist/compiler-core.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.mjs +663 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-ssr@3.5.41/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.mjs +846 -0
- package/dist/node_modules/.pnpm/@vue_compiler-ssr@3.5.41/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/dist/reactivity.cjs.mjs +1600 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/dist/reactivity.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/dist/runtime-core.cjs.mjs +5619 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/dist/runtime-core.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.mjs +1479 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/dist/server-renderer.cjs.mjs +510 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/dist/server-renderer.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/dist/shared.cjs.mjs +499 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/dist/shared.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode-codepoint.mjs +79 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode-codepoint.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode.mjs +471 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-html.mjs +16 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-html.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-xml.mjs +16 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-xml.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/bin-trie-flags.mjs +30 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/bin-trie-flags.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/decode-shared.mjs +24 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/decode-shared.mjs.map +1 -0
- package/dist/node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs +253 -0
- package/dist/node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.mjs +5246 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server.node.development.mjs +5616 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server.node.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom.development.mjs +183 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/index.mjs +13 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/server.node.mjs +21 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/server.node.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react.development.mjs +766 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/index.mjs +13 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.mjs +100 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.mjs +73 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.mjs +41 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.mjs +68 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.mjs +77 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.mjs +89 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.mjs +788 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.mjs +295 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.mjs +293 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/util.mjs +352 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/util.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs +17 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/dist/vue.cjs.mjs +67 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/dist/vue.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index.mjs +13 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index2.mjs +10 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index2.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/server-renderer/index.mjs +10 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/server-renderer/index.mjs.map +1 -0
- package/dist/server/cli/bin.d.mts +1 -0
- package/dist/server/cli/bin.mjs +8 -0
- package/dist/server/cli/bin.mjs.map +1 -0
- package/dist/server/cli/cli-spec.mjs +150 -0
- package/dist/server/cli/cli-spec.mjs.map +1 -0
- package/dist/server/cli/index.d.mts +16 -0
- package/dist/server/cli/index.d.mts.map +1 -0
- package/dist/server/cli/index.mjs +64 -0
- package/dist/server/cli/index.mjs.map +1 -0
- package/dist/server/compile/adaptors/html-partials.d.mts +24 -0
- package/dist/server/compile/adaptors/html-partials.d.mts.map +1 -0
- package/dist/server/compile/adaptors/html-partials.mjs +50 -0
- package/dist/server/compile/adaptors/html-partials.mjs.map +1 -0
- package/dist/server/compile/adaptors/html.d.mts +15 -0
- package/dist/server/compile/adaptors/html.d.mts.map +1 -0
- package/dist/server/compile/adaptors/html.mjs +39 -0
- package/dist/server/compile/adaptors/html.mjs.map +1 -0
- package/dist/server/compile/adaptors/node-require.d.mts +6 -0
- package/dist/server/compile/adaptors/node-require.d.mts.map +1 -0
- package/dist/server/compile/adaptors/node-require.mjs +35 -0
- package/dist/server/compile/adaptors/node-require.mjs.map +1 -0
- package/dist/server/compile/adaptors/react-browser.d.mts +20 -0
- package/dist/server/compile/adaptors/react-browser.d.mts.map +1 -0
- package/dist/server/compile/adaptors/react-browser.mjs +19 -0
- package/dist/server/compile/adaptors/react-browser.mjs.map +1 -0
- package/dist/server/compile/adaptors/react-node.d.mts +17 -0
- package/dist/server/compile/adaptors/react-node.d.mts.map +1 -0
- package/dist/server/compile/adaptors/react-node.mjs +50 -0
- package/dist/server/compile/adaptors/react-node.mjs.map +1 -0
- package/dist/server/compile/adaptors/types.d.mts +14 -0
- package/dist/server/compile/adaptors/types.d.mts.map +1 -0
- package/dist/server/compile/adaptors/types.mjs +1 -0
- package/dist/server/compile/adaptors/vue-browser.d.mts +16 -0
- package/dist/server/compile/adaptors/vue-browser.d.mts.map +1 -0
- package/dist/server/compile/adaptors/vue-browser.mjs +16 -0
- package/dist/server/compile/adaptors/vue-browser.mjs.map +1 -0
- package/dist/server/compile/adaptors/vue-node.d.mts +17 -0
- package/dist/server/compile/adaptors/vue-node.d.mts.map +1 -0
- package/dist/server/compile/adaptors/vue-node.mjs +50 -0
- package/dist/server/compile/adaptors/vue-node.mjs.map +1 -0
- package/dist/server/compile/build-entry-module.d.mts +20 -0
- package/dist/server/compile/build-entry-module.d.mts.map +1 -0
- package/dist/server/compile/build-entry-module.mjs +56 -0
- package/dist/server/compile/build-entry-module.mjs.map +1 -0
- package/dist/server/compile/bundle-name.d.mts +5 -0
- package/dist/server/compile/bundle-name.d.mts.map +1 -0
- package/dist/server/compile/bundle-name.mjs +13 -0
- package/dist/server/compile/bundle-name.mjs.map +1 -0
- package/dist/server/compile/compile-cache.d.mts +23 -0
- package/dist/server/compile/compile-cache.d.mts.map +1 -0
- package/dist/server/compile/compile-cache.mjs +102 -0
- package/dist/server/compile/compile-cache.mjs.map +1 -0
- package/dist/server/compile/compile.d.mts +100 -0
- package/dist/server/compile/compile.d.mts.map +1 -0
- package/dist/server/compile/compile.mjs +735 -0
- package/dist/server/compile/compile.mjs.map +1 -0
- package/dist/server/compile/constants.d.mts +11 -0
- package/dist/server/compile/constants.d.mts.map +1 -0
- package/dist/server/compile/constants.mjs +12 -0
- package/dist/server/compile/constants.mjs.map +1 -0
- package/dist/server/compile/create-renderer.d.mts +16 -0
- package/dist/server/compile/create-renderer.d.mts.map +1 -0
- package/dist/server/compile/create-renderer.mjs +59 -0
- package/dist/server/compile/create-renderer.mjs.map +1 -0
- package/dist/server/compile/decode-style-entities.d.mts +12 -0
- package/dist/server/compile/decode-style-entities.d.mts.map +1 -0
- package/dist/server/compile/decode-style-entities.mjs +32 -0
- package/dist/server/compile/decode-style-entities.mjs.map +1 -0
- package/dist/server/compile/defaults.d.mts +18 -0
- package/dist/server/compile/defaults.d.mts.map +1 -0
- package/dist/server/compile/defaults.mjs +128 -0
- package/dist/server/compile/defaults.mjs.map +1 -0
- package/dist/server/compile/dependency-closure.d.mts +10 -0
- package/dist/server/compile/dependency-closure.d.mts.map +1 -0
- package/dist/server/compile/dependency-closure.mjs +79 -0
- package/dist/server/compile/dependency-closure.mjs.map +1 -0
- package/dist/server/compile/document-assets.d.mts +103 -0
- package/dist/server/compile/document-assets.d.mts.map +1 -0
- package/dist/server/compile/document-assets.mjs +184 -0
- package/dist/server/compile/document-assets.mjs.map +1 -0
- package/dist/server/compile/finalize-document-html.d.mts +53 -0
- package/dist/server/compile/finalize-document-html.d.mts.map +1 -0
- package/dist/server/compile/finalize-document-html.mjs +132 -0
- package/dist/server/compile/finalize-document-html.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorHtml.mjs +6 -0
- package/dist/server/compile/generated/adaptorHtml.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorReactBrowser.mjs +6 -0
- package/dist/server/compile/generated/adaptorReactBrowser.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorReactNode.mjs +6 -0
- package/dist/server/compile/generated/adaptorReactNode.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorVueBrowser.mjs +6 -0
- package/dist/server/compile/generated/adaptorVueBrowser.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorVueNode.mjs +6 -0
- package/dist/server/compile/generated/adaptorVueNode.mjs.map +1 -0
- package/dist/server/compile/generated/createRenderer.mjs +6 -0
- package/dist/server/compile/generated/createRenderer.mjs.map +1 -0
- package/dist/server/compile/generated/decodeStyleEntities.mjs +6 -0
- package/dist/server/compile/generated/decodeStyleEntities.mjs.map +1 -0
- package/dist/server/compile/generated/sanitizeHtml.mjs +6 -0
- package/dist/server/compile/generated/sanitizeHtml.mjs.map +1 -0
- package/dist/server/compile/generated/validate.mjs +6 -0
- package/dist/server/compile/generated/validate.mjs.map +1 -0
- package/dist/server/compile/generated/virtualStyles.mjs +6 -0
- package/dist/server/compile/generated/virtualStyles.mjs.map +1 -0
- package/dist/server/compile/get-renderer.d.mts +18 -0
- package/dist/server/compile/get-renderer.d.mts.map +1 -0
- package/dist/server/compile/get-renderer.mjs +31 -0
- package/dist/server/compile/get-renderer.mjs.map +1 -0
- package/dist/server/compile/index.d.mts +2 -0
- package/dist/server/compile/index.mjs +3 -0
- package/dist/server/compile/make-config.d.mts +39 -0
- package/dist/server/compile/make-config.d.mts.map +1 -0
- package/dist/server/compile/make-config.mjs +272 -0
- package/dist/server/compile/make-config.mjs.map +1 -0
- package/dist/server/compile/package-json.d.mts +5 -0
- package/dist/server/compile/package-json.d.mts.map +1 -0
- package/dist/server/compile/package-json.mjs +33 -0
- package/dist/server/compile/package-json.mjs.map +1 -0
- package/dist/server/compile/producer-agreement.d.mts +82 -0
- package/dist/server/compile/producer-agreement.d.mts.map +1 -0
- package/dist/server/compile/producer-agreement.mjs +143 -0
- package/dist/server/compile/producer-agreement.mjs.map +1 -0
- package/dist/server/compile/producer-release.d.mts +19 -0
- package/dist/server/compile/producer-release.d.mts.map +1 -0
- package/dist/server/compile/producer-release.mjs +27 -0
- package/dist/server/compile/producer-release.mjs.map +1 -0
- package/dist/server/compile/render-error.d.mts +37 -0
- package/dist/server/compile/render-error.d.mts.map +1 -0
- package/dist/server/compile/render-error.mjs +55 -0
- package/dist/server/compile/render-error.mjs.map +1 -0
- package/dist/server/compile/sanitize/shared.d.mts +19 -0
- package/dist/server/compile/sanitize/shared.d.mts.map +1 -0
- package/dist/server/compile/sanitize/shared.mjs +131 -0
- package/dist/server/compile/sanitize/shared.mjs.map +1 -0
- package/dist/server/compile/sanitize-html.d.mts +5 -0
- package/dist/server/compile/sanitize-html.d.mts.map +1 -0
- package/dist/server/compile/sanitize-html.mjs +65 -0
- package/dist/server/compile/sanitize-html.mjs.map +1 -0
- package/dist/server/compile/structured-log.d.mts +22 -0
- package/dist/server/compile/structured-log.d.mts.map +1 -0
- package/dist/server/compile/structured-log.mjs +31 -0
- package/dist/server/compile/structured-log.mjs.map +1 -0
- package/dist/server/compile/virtual-styles.d.mts +5 -0
- package/dist/server/compile/virtual-styles.d.mts.map +1 -0
- package/dist/server/compile/virtual-styles.mjs +19 -0
- package/dist/server/compile/virtual-styles.mjs.map +1 -0
- package/dist/server/compile/wrapper-source.d.mts +55 -0
- package/dist/server/compile/wrapper-source.d.mts.map +1 -0
- package/dist/server/compile/wrapper-source.mjs +187 -0
- package/dist/server/compile/wrapper-source.mjs.map +1 -0
- package/dist/server/constants.d.mts +17 -0
- package/dist/server/constants.d.mts.map +1 -0
- package/dist/server/constants.mjs +41 -0
- package/dist/server/constants.mjs.map +1 -0
- package/dist/server/errors.d.mts +21 -0
- package/dist/server/errors.d.mts.map +1 -0
- package/dist/server/errors.mjs +24 -0
- package/dist/server/errors.mjs.map +1 -0
- package/dist/server/index.d.mts +4 -0
- package/dist/server/index.mjs +4 -0
- package/dist/server/integrations/nextjs/generate-entry.d.mts +19 -0
- package/dist/server/integrations/nextjs/generate-entry.d.mts.map +1 -0
- package/dist/server/integrations/nextjs/generate-entry.mjs +246 -0
- package/dist/server/integrations/nextjs/generate-entry.mjs.map +1 -0
- package/dist/server/integrations/nextjs/index.d.mts +8 -0
- package/dist/server/integrations/nextjs/index.d.mts.map +1 -0
- package/dist/server/integrations/nextjs/index.mjs +90 -0
- package/dist/server/integrations/nextjs/index.mjs.map +1 -0
- package/dist/server/integrations/nextjs/watcher.d.mts +9 -0
- package/dist/server/integrations/nextjs/watcher.d.mts.map +1 -0
- package/dist/server/integrations/nextjs/watcher.mjs +45 -0
- package/dist/server/integrations/nextjs/watcher.mjs.map +1 -0
- package/dist/server/integrations/unplugin/esbuild.d.mts +2 -0
- package/dist/server/integrations/unplugin/esbuild.mjs +3 -0
- package/dist/server/integrations/unplugin/index.d.mts +69 -0
- package/dist/server/integrations/unplugin/index.d.mts.map +1 -0
- package/dist/server/integrations/unplugin/index.mjs +539 -0
- package/dist/server/integrations/unplugin/index.mjs.map +1 -0
- package/dist/server/integrations/unplugin/rollup.d.mts +2 -0
- package/dist/server/integrations/unplugin/rollup.mjs +3 -0
- package/dist/server/integrations/unplugin/utils.d.mts +12 -0
- package/dist/server/integrations/unplugin/utils.d.mts.map +1 -0
- package/dist/server/integrations/unplugin/utils.mjs +46 -0
- package/dist/server/integrations/unplugin/utils.mjs.map +1 -0
- package/dist/server/integrations/unplugin/vite.d.mts +2 -0
- package/dist/server/integrations/unplugin/vite.mjs +3 -0
- package/dist/server/integrations/unplugin/webpack.d.mts +2 -0
- package/dist/server/integrations/unplugin/webpack.mjs +3 -0
- package/dist/server/project/documents.d.mts +21 -0
- package/dist/server/project/documents.d.mts.map +1 -0
- package/dist/server/project/documents.mjs +114 -0
- package/dist/server/project/documents.mjs.map +1 -0
- package/dist/server/project/format-env-types.d.mts +19 -0
- package/dist/server/project/format-env-types.d.mts.map +1 -0
- package/dist/server/project/format-env-types.mjs +64 -0
- package/dist/server/project/format-env-types.mjs.map +1 -0
- package/dist/server/project/paths.d.mts +21 -0
- package/dist/server/project/paths.d.mts.map +1 -0
- package/dist/server/project/paths.mjs +31 -0
- package/dist/server/project/paths.mjs.map +1 -0
- package/dist/server/project/user-project-dir.d.mts +7 -0
- package/dist/server/project/user-project-dir.d.mts.map +1 -0
- package/dist/server/project/user-project-dir.mjs +16 -0
- package/dist/server/project/user-project-dir.mjs.map +1 -0
- package/dist/server/render-worker/client.d.mts +83 -0
- package/dist/server/render-worker/client.d.mts.map +1 -0
- package/dist/server/render-worker/client.mjs +359 -0
- package/dist/server/render-worker/client.mjs.map +1 -0
- package/dist/server/render-worker/document-css.d.mts +27 -0
- package/dist/server/render-worker/document-css.d.mts.map +1 -0
- package/dist/server/render-worker/document-css.mjs +37 -0
- package/dist/server/render-worker/document-css.mjs.map +1 -0
- package/dist/server/render-worker/env.d.mts +11 -0
- package/dist/server/render-worker/env.d.mts.map +1 -0
- package/dist/server/render-worker/env.mjs +26 -0
- package/dist/server/render-worker/env.mjs.map +1 -0
- package/dist/server/render-worker/error.d.mts +17 -0
- package/dist/server/render-worker/error.d.mts.map +1 -0
- package/dist/server/render-worker/error.mjs +40 -0
- package/dist/server/render-worker/error.mjs.map +1 -0
- package/dist/server/render-worker/host.d.mts +1 -0
- package/dist/server/render-worker/host.mjs +181 -0
- package/dist/server/render-worker/host.mjs.map +1 -0
- package/dist/server/render-worker/index.d.mts +4 -0
- package/dist/server/render-worker/index.mjs +4 -0
- package/dist/server/render-worker/sandbox.d.mts +25 -0
- package/dist/server/render-worker/sandbox.d.mts.map +1 -0
- package/dist/server/render-worker/sandbox.mjs +60 -0
- package/dist/server/render-worker/sandbox.mjs.map +1 -0
- package/dist/server/render-worker/types.d.mts +59 -0
- package/dist/server/render-worker/types.d.mts.map +1 -0
- package/dist/server/render-worker/types.mjs +1 -0
- package/dist/server/runtime-state.d.mts +12 -0
- package/dist/server/runtime-state.d.mts.map +1 -0
- package/dist/server/runtime-state.mjs +24 -0
- package/dist/server/runtime-state.mjs.map +1 -0
- package/dist/server/utils/check-dir.d.mts +12 -0
- package/dist/server/utils/check-dir.d.mts.map +1 -0
- package/dist/server/utils/check-dir.mjs +30 -0
- package/dist/server/utils/check-dir.mjs.map +1 -0
- package/dist/server/utils/dependencies.d.mts +11 -0
- package/dist/server/utils/dependencies.d.mts.map +1 -0
- package/dist/server/utils/dependencies.mjs +34 -0
- package/dist/server/utils/dependencies.mjs.map +1 -0
- package/dist/server/utils/env-var.d.mts +6 -0
- package/dist/server/utils/env-var.d.mts.map +1 -0
- package/dist/server/utils/env-var.mjs +28 -0
- package/dist/server/utils/env-var.mjs.map +1 -0
- package/dist/server/utils/format-for-log.d.mts +5 -0
- package/dist/server/utils/format-for-log.d.mts.map +1 -0
- package/dist/server/utils/format-for-log.mjs +17 -0
- package/dist/server/utils/format-for-log.mjs.map +1 -0
- package/dist/server/utils/index.d.mts +8 -0
- package/dist/server/utils/index.mjs +9 -0
- package/dist/server/utils/load-config.d.mts +13 -0
- package/dist/server/utils/load-config.d.mts.map +1 -0
- package/dist/server/utils/load-config.mjs +65 -0
- package/dist/server/utils/load-config.mjs.map +1 -0
- package/dist/server/utils/log.d.mts +36 -0
- package/dist/server/utils/log.d.mts.map +1 -0
- package/dist/server/utils/log.mjs +125 -0
- package/dist/server/utils/log.mjs.map +1 -0
- package/dist/server/utils/read-file.d.mts +5 -0
- package/dist/server/utils/read-file.d.mts.map +1 -0
- package/dist/server/utils/read-file.mjs +14 -0
- package/dist/server/utils/read-file.mjs.map +1 -0
- package/dist/server/utils/resolve-path-with-extensions.d.mts +21 -0
- package/dist/server/utils/resolve-path-with-extensions.d.mts.map +1 -0
- package/dist/server/utils/resolve-path-with-extensions.mjs +39 -0
- package/dist/server/utils/resolve-path-with-extensions.mjs.map +1 -0
- package/dist/server/utils/schema.d.mts +7 -0
- package/dist/server/utils/schema.d.mts.map +1 -0
- package/dist/server/utils/schema.mjs +21 -0
- package/dist/server/utils/schema.mjs.map +1 -0
- package/dist/server/utils/standard-schema-validate.d.mts +13 -0
- package/dist/server/utils/standard-schema-validate.d.mts.map +1 -0
- package/dist/server/utils/standard-schema-validate.mjs +21 -0
- package/dist/server/utils/standard-schema-validate.mjs.map +1 -0
- package/dist/server/utils/suggest-similar.d.mts +9 -0
- package/dist/server/utils/suggest-similar.d.mts.map +1 -0
- package/dist/server/utils/suggest-similar.mjs +39 -0
- package/dist/server/utils/suggest-similar.mjs.map +1 -0
- package/dist/server/utils/warn-lockstep.d.mts +13 -0
- package/dist/server/utils/warn-lockstep.d.mts.map +1 -0
- package/dist/server/utils/warn-lockstep.mjs +23 -0
- package/dist/server/utils/warn-lockstep.mjs.map +1 -0
- package/dist/server/vite/create-config.d.mts +35 -0
- package/dist/server/vite/create-config.d.mts.map +1 -0
- package/dist/server/vite/create-config.mjs +64 -0
- package/dist/server/vite/create-config.mjs.map +1 -0
- package/dist/server/vite/plugins/collect-css.d.mts +8 -0
- package/dist/server/vite/plugins/collect-css.d.mts.map +1 -0
- package/dist/server/vite/plugins/collect-css.mjs +21 -0
- package/dist/server/vite/plugins/collect-css.mjs.map +1 -0
- package/dist/server/vite/plugins/get-styles.d.mts +14 -0
- package/dist/server/vite/plugins/get-styles.d.mts.map +1 -0
- package/dist/server/vite/plugins/get-styles.mjs +88 -0
- package/dist/server/vite/plugins/get-styles.mjs.map +1 -0
- package/dist/server/vite/plugins/html-loader.d.mts +18 -0
- package/dist/server/vite/plugins/html-loader.d.mts.map +1 -0
- package/dist/server/vite/plugins/html-loader.mjs +88 -0
- package/dist/server/vite/plugins/html-loader.mjs.map +1 -0
- package/dist/server/vite/plugins/postcss/import-url.d.mts +14 -0
- package/dist/server/vite/plugins/postcss/import-url.d.mts.map +1 -0
- package/dist/server/vite/plugins/postcss/import-url.mjs +163 -0
- package/dist/server/vite/plugins/postcss/import-url.mjs.map +1 -0
- package/dist/server/vite/plugins/styles-pre-processor.d.mts +7 -0
- package/dist/server/vite/plugins/styles-pre-processor.d.mts.map +1 -0
- package/dist/server/vite/plugins/styles-pre-processor.mjs +64 -0
- package/dist/server/vite/plugins/styles-pre-processor.mjs.map +1 -0
- package/dist/server/vite/plugins/utils.d.mts +9 -0
- package/dist/server/vite/plugins/utils.d.mts.map +1 -0
- package/dist/server/vite/plugins/utils.mjs +14 -0
- package/dist/server/vite/plugins/utils.mjs.map +1 -0
- package/dist/shared/constants.d.mts +11 -0
- package/dist/shared/constants.d.mts.map +1 -0
- package/dist/shared/constants.mjs +12 -0
- package/dist/shared/constants.mjs.map +1 -0
- package/dist/shared/env.d.mts +6 -0
- package/dist/shared/env.d.mts.map +1 -0
- package/dist/shared/env.mjs +11 -0
- package/dist/shared/env.mjs.map +1 -0
- package/dist/shared/http.d.mts +15 -0
- package/dist/shared/http.d.mts.map +1 -0
- package/dist/shared/http.mjs +54 -0
- package/dist/shared/http.mjs.map +1 -0
- package/dist/shared/types/document.d.mts +17 -0
- package/dist/shared/types/document.d.mts.map +1 -0
- package/dist/shared/types/document.mjs +1 -0
- package/dist/shared/types/index.d.mts +7 -0
- package/dist/shared/types/index.mjs +4 -0
- package/dist/shared/types/log.d.mts +10 -0
- package/dist/shared/types/log.d.mts.map +1 -0
- package/dist/shared/types/log.mjs +12 -0
- package/dist/shared/types/log.mjs.map +1 -0
- package/dist/shared/types/public/cli.d.mts +33 -0
- package/dist/shared/types/public/cli.d.mts.map +1 -0
- package/dist/shared/types/public/cli.mjs +1 -0
- package/dist/shared/types/public/compile.d.mts +45 -0
- package/dist/shared/types/public/compile.d.mts.map +1 -0
- package/dist/shared/types/public/compile.mjs +29 -0
- package/dist/shared/types/public/compile.mjs.map +1 -0
- package/dist/shared/types/public/config.d.mts +94 -0
- package/dist/shared/types/public/config.d.mts.map +1 -0
- package/dist/shared/types/public/config.mjs +20 -0
- package/dist/shared/types/public/config.mjs.map +1 -0
- package/dist/shared/types/public/index.d.mts +6 -0
- package/dist/shared/types/public/index.mjs +4 -0
- package/dist/shared/types/public/nextjs.d.mts +111 -0
- package/dist/shared/types/public/nextjs.d.mts.map +1 -0
- package/dist/shared/types/public/nextjs.mjs +1 -0
- package/dist/shared/types/public/renderer.d.mts +2 -0
- package/dist/shared/types/public/renderer.mjs +1 -0
- package/dist/shared/types/public/unplugin.d.mts +65 -0
- package/dist/shared/types/public/unplugin.d.mts.map +1 -0
- package/dist/shared/types/public/unplugin.mjs +1 -0
- package/dist/shared/types/server.d.mts +5 -0
- package/dist/shared/types/server.d.mts.map +1 -0
- package/dist/shared/types/server.mjs +1 -0
- package/dist/shared/types/state.d.mts +15 -0
- package/dist/shared/types/state.d.mts.map +1 -0
- package/dist/shared/types/state.mjs +1 -0
- package/dist/shared/types/system.d.mts +18 -0
- package/dist/shared/types/system.d.mts.map +1 -0
- package/dist/shared/types/system.mjs +1 -0
- package/package.json +146 -34
- package/types/next.d.ts +6 -0
- package/index.d.ts +0 -2
- package/index.js +0 -3
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
import { getUserProjectDir } from "../../project/user-project-dir.mjs";
|
|
2
|
+
import { DEFAULT_OUT_DIR_NAME } from "../../project/paths.mjs";
|
|
3
|
+
import { BUNDLE_ENTRY_POINT_FILE_NAME } from "../../compile/constants.mjs";
|
|
4
|
+
import { logger, setLogLevel } from "../../utils/log.mjs";
|
|
5
|
+
import { parseLogLevelFromEnv } from "../../utils/env-var.mjs";
|
|
6
|
+
import { loadConfig } from "../../utils/load-config.mjs";
|
|
7
|
+
import "../../utils/index.mjs";
|
|
8
|
+
import { resolveBundleName } from "../../compile/bundle-name.mjs";
|
|
9
|
+
import { buildWrapperFactorySource } from "../../compile/wrapper-source.mjs";
|
|
10
|
+
import { resolveZipModulePath } from "../../compile/make-config.mjs";
|
|
11
|
+
import { warnOnLockstepDrift } from "../../utils/warn-lockstep.mjs";
|
|
12
|
+
import { dynamicAssetEmitEntries } from "../../compile/document-assets.mjs";
|
|
13
|
+
import { getDocuments, getUserDocumentIndex } from "../../project/documents.mjs";
|
|
14
|
+
import { compileForUnplugin, getBundleOutDir } from "../../compile/compile.mjs";
|
|
15
|
+
import "../../compile/index.mjs";
|
|
16
|
+
import { writeFormatEnvTypes } from "../../project/format-env-types.mjs";
|
|
17
|
+
import { addZeroPrefix, cleanId, safeRelPath, sanitiseSubdir, stripPrefix } from "./utils.mjs";
|
|
18
|
+
import { dirname, resolve } from "node:path";
|
|
19
|
+
import { pathToFileURL } from "node:url";
|
|
20
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
21
|
+
import { listZipEntries } from "@format.dev/zip";
|
|
22
|
+
import { createHash } from "node:crypto";
|
|
23
|
+
import { buildDocumentExportMap } from "@format.dev/cli/scaffold";
|
|
24
|
+
import { createUnplugin } from "unplugin";
|
|
25
|
+
|
|
26
|
+
//#region src/server/integrations/unplugin/index.ts
|
|
27
|
+
function resolveAssetMode(options, config) {
|
|
28
|
+
return options.assets ?? "static";
|
|
29
|
+
}
|
|
30
|
+
const PLUGIN_NAME = "format-unplugin";
|
|
31
|
+
const DEFAULT_TARGET = "node";
|
|
32
|
+
const VIRTUAL_MODULE_PREFIX = "@format:";
|
|
33
|
+
function escapeRegExp(value) {
|
|
34
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
35
|
+
}
|
|
36
|
+
const RENDERER_MODULE = `${VIRTUAL_MODULE_PREFIX}renderer/`;
|
|
37
|
+
const memoryAssets = /* @__PURE__ */ new Map();
|
|
38
|
+
function buildRendererModuleSource(outDir, documents) {
|
|
39
|
+
const importLines = documents.map((document) => {
|
|
40
|
+
const importPath = `./${document.documentName}/${BUNDLE_ENTRY_POINT_FILE_NAME}`.replace(/\\/g, "/");
|
|
41
|
+
return `import { ${document.exportName} } from ${JSON.stringify(importPath)};`;
|
|
42
|
+
});
|
|
43
|
+
const exportNames = documents.map((document) => document.exportName);
|
|
44
|
+
return [
|
|
45
|
+
...importLines,
|
|
46
|
+
"",
|
|
47
|
+
`export { ${exportNames.join(", ")} };`,
|
|
48
|
+
`export default { ${exportNames.join(", ")} };`,
|
|
49
|
+
""
|
|
50
|
+
].join("\n");
|
|
51
|
+
}
|
|
52
|
+
async function getDocumentHash(documentName, config) {
|
|
53
|
+
const hash = createHash("sha256");
|
|
54
|
+
const documentIndexPath = await getUserDocumentIndex({
|
|
55
|
+
documentName,
|
|
56
|
+
config
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
const content = await readFile(documentIndexPath, "utf-8");
|
|
60
|
+
hash.update(content);
|
|
61
|
+
return hash.digest("hex").substring(0, 8);
|
|
62
|
+
} catch {
|
|
63
|
+
return "initial";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const compileBundle = async (args) => {
|
|
67
|
+
const { config, options, compiledDocuments, compiledBundle, bundler } = args;
|
|
68
|
+
const documentNames = (await getDocuments(config)).map((doc) => doc.name).sort((a, b) => a.localeCompare(b));
|
|
69
|
+
if (documentNames.length === 0) throw new Error("No documents found to compile.");
|
|
70
|
+
const exportNames = buildDocumentExportMap(documentNames);
|
|
71
|
+
await writeFormatEnvTypes({
|
|
72
|
+
projectRoot: getUserProjectDir(),
|
|
73
|
+
aliases: [`${VIRTUAL_MODULE_PREFIX}${resolveBundleName(options.bundleName)}`],
|
|
74
|
+
documents: documentNames.map((name) => ({ exportName: exportNames.get(name) }))
|
|
75
|
+
});
|
|
76
|
+
const documentHashes = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const documentName of documentNames) {
|
|
78
|
+
const hash = await getDocumentHash(documentName, config);
|
|
79
|
+
documentHashes.set(documentName, hash);
|
|
80
|
+
}
|
|
81
|
+
const bundleHashInput = documentNames.map((name) => `${name}:${documentHashes.get(name)}`).join("|");
|
|
82
|
+
const bundleHash = createHash("sha256").update(bundleHashInput).digest("hex").substring(0, 8);
|
|
83
|
+
if (compiledBundle?.hash === bundleHash && compiledDocuments.size === documentNames.length) {
|
|
84
|
+
logger.debug("Format bundle already compiled");
|
|
85
|
+
return compiledBundle;
|
|
86
|
+
}
|
|
87
|
+
logger.debug(`Compiling Format bundle: ${documentNames.join(", ")}`);
|
|
88
|
+
const { assets, validateSchema, inlineRemoteCss, target, outDir: outDirOverride, configPath, bundleName, clean } = options;
|
|
89
|
+
const compileOptions = {
|
|
90
|
+
documents: documentNames,
|
|
91
|
+
assets,
|
|
92
|
+
validateSchema,
|
|
93
|
+
inlineRemoteCss,
|
|
94
|
+
target,
|
|
95
|
+
configPath,
|
|
96
|
+
outDir: outDirOverride,
|
|
97
|
+
bundleName,
|
|
98
|
+
clean,
|
|
99
|
+
userBundler: bundler
|
|
100
|
+
};
|
|
101
|
+
logger.debug("Passing compile context from unplugin", {
|
|
102
|
+
userBundler: bundler,
|
|
103
|
+
target
|
|
104
|
+
});
|
|
105
|
+
const assetState = /* @__PURE__ */ new Map();
|
|
106
|
+
await compileForUnplugin(compileOptions, { capturedAssetState: assetState });
|
|
107
|
+
const outDir = getBundleOutDir(config, outDirOverride);
|
|
108
|
+
logger.debug(`Format bundle outDir: ${outDir}`);
|
|
109
|
+
const assetMode = resolveAssetMode(options, config);
|
|
110
|
+
compiledDocuments.clear();
|
|
111
|
+
for (const documentName of documentNames) compiledDocuments.set(documentName, {
|
|
112
|
+
documentName,
|
|
113
|
+
exportName: exportNames.get(documentName),
|
|
114
|
+
hash: documentHashes.get(documentName),
|
|
115
|
+
assetsPath: assetMode === "static" ? resolve(outDir, documentName, "assets.zip") : null
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
outDir,
|
|
119
|
+
hash: bundleHash,
|
|
120
|
+
compiledAt: Date.now(),
|
|
121
|
+
assetState
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Emit one asset file into the consumer's bundle output. Returns the emitted
|
|
126
|
+
* path relative to the bundler's out dir, or the already-emitted path when a
|
|
127
|
+
* previous document emitted the same file (shared `_imported/` files, fonts).
|
|
128
|
+
*/
|
|
129
|
+
async function emitAssetFile(args) {
|
|
130
|
+
const { emitFile, buffer, relName, outRoot, assetsSubdir, emittedAssetNames, bundler } = args;
|
|
131
|
+
const root = outRoot || process.cwd();
|
|
132
|
+
const { rel: assetFileName } = safeRelPath(root, assetsSubdir, relName);
|
|
133
|
+
if (emittedAssetNames.has(assetFileName)) {
|
|
134
|
+
logger.debug(`Skip duplicate asset emit: ${assetFileName}`);
|
|
135
|
+
return assetFileName;
|
|
136
|
+
}
|
|
137
|
+
if (bundler === "esbuild") {
|
|
138
|
+
const assetAbsPath = resolve(root, assetFileName);
|
|
139
|
+
await mkdir(dirname(assetAbsPath), { recursive: true });
|
|
140
|
+
await writeFile(assetAbsPath, buffer);
|
|
141
|
+
emittedAssetNames.add(assetFileName);
|
|
142
|
+
return assetFileName;
|
|
143
|
+
}
|
|
144
|
+
emitFile({
|
|
145
|
+
type: "asset",
|
|
146
|
+
fileName: assetFileName,
|
|
147
|
+
source: buffer
|
|
148
|
+
});
|
|
149
|
+
emittedAssetNames.add(assetFileName);
|
|
150
|
+
return assetFileName;
|
|
151
|
+
}
|
|
152
|
+
function getRegisteredRendererSource(rendererName, rendererSourceMap) {
|
|
153
|
+
const source = rendererSourceMap.get(rendererName);
|
|
154
|
+
if (!source) throw new Error(`Renderer source not registered for "${rendererName}"`);
|
|
155
|
+
return source;
|
|
156
|
+
}
|
|
157
|
+
async function buildVirtualModuleCode(args) {
|
|
158
|
+
const { target, useZeroPrefix, virtualModuleName, options, config, compiledDocuments, compiledBundle, rendererSourceMap, outRoot, assetsSubdir, emittedAssetNames, bundler, emitFile, isDevServer, bundleName } = args;
|
|
159
|
+
try {
|
|
160
|
+
if (virtualModuleName !== bundleName) throw new Error(`Unsupported Format virtual module "${virtualModuleName}". Use "${VIRTUAL_MODULE_PREFIX}${bundleName}".`);
|
|
161
|
+
if (!compiledBundle) throw new Error("Format bundle not compiled.");
|
|
162
|
+
const assetMode = resolveAssetMode(options, config);
|
|
163
|
+
const rendererVirtualId = `${RENDERER_MODULE}${bundleName}`;
|
|
164
|
+
const documents = [...compiledDocuments.values()].sort((a, b) => a.documentName.localeCompare(b.documentName));
|
|
165
|
+
const rendererSource = buildRendererModuleSource(compiledBundle.outDir, documents);
|
|
166
|
+
rendererSourceMap.set(bundleName, rendererSource);
|
|
167
|
+
const isViteDev = bundler === "vite" && isDevServer;
|
|
168
|
+
const emitRoot = outRoot || process.cwd();
|
|
169
|
+
const emitSubdir = assetsSubdir || "";
|
|
170
|
+
const wrapperLines = [];
|
|
171
|
+
for (const document of documents) {
|
|
172
|
+
const init = {
|
|
173
|
+
knownAssets: [],
|
|
174
|
+
assetUrls: null,
|
|
175
|
+
assetsPath: null,
|
|
176
|
+
assetsUrl: null
|
|
177
|
+
};
|
|
178
|
+
if (assetMode === "static") {
|
|
179
|
+
let zipBuffer = null;
|
|
180
|
+
try {
|
|
181
|
+
zipBuffer = await readFile(document.assetsPath);
|
|
182
|
+
} catch {
|
|
183
|
+
logger.debug(`No assets found for document: ${document.documentName}`);
|
|
184
|
+
}
|
|
185
|
+
if (zipBuffer) {
|
|
186
|
+
init.knownAssets = listZipEntries(new Uint8Array(zipBuffer));
|
|
187
|
+
if (isViteDev && target === "node") init.assetsUrl = pathToFileURL(document.assetsPath).href;
|
|
188
|
+
else if (isViteDev) {
|
|
189
|
+
memoryAssets.set(`${document.documentName}.zip`, zipBuffer);
|
|
190
|
+
init.assetsUrl = `/__format-assets/${document.documentName}.zip`;
|
|
191
|
+
} else {
|
|
192
|
+
const emitted = await emitAssetFile({
|
|
193
|
+
emitFile,
|
|
194
|
+
buffer: zipBuffer,
|
|
195
|
+
relName: `${document.documentName}/assets.zip`,
|
|
196
|
+
outRoot: emitRoot,
|
|
197
|
+
assetsSubdir: emitSubdir,
|
|
198
|
+
emittedAssetNames,
|
|
199
|
+
bundler
|
|
200
|
+
});
|
|
201
|
+
init.assetsPath = emitted.startsWith("./") ? emitted : `./${emitted}`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
} else if (assetMode === "dynamic") {
|
|
205
|
+
const compiledUrlMap = compiledBundle.assetState.get(document.documentName)?.urlMap ?? {};
|
|
206
|
+
const entries = dynamicAssetEmitEntries({
|
|
207
|
+
outDir: compiledBundle.outDir,
|
|
208
|
+
documentName: document.documentName,
|
|
209
|
+
urlMap: compiledUrlMap
|
|
210
|
+
});
|
|
211
|
+
const urlMap = {};
|
|
212
|
+
for (const entry of entries) {
|
|
213
|
+
if (isViteDev && target === "node") {
|
|
214
|
+
urlMap[entry.knownPath] = pathToFileURL(entry.sourcePath).href;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (isViteDev) {
|
|
218
|
+
urlMap[entry.knownPath] = `/__format-assets/${entry.emitPath}`;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const emitted = await emitAssetFile({
|
|
222
|
+
emitFile,
|
|
223
|
+
buffer: await readFile(entry.sourcePath),
|
|
224
|
+
relName: entry.emitPath,
|
|
225
|
+
outRoot: emitRoot,
|
|
226
|
+
assetsSubdir: emitSubdir,
|
|
227
|
+
emittedAssetNames,
|
|
228
|
+
bundler
|
|
229
|
+
});
|
|
230
|
+
urlMap[entry.knownPath] = emitted.startsWith("./") ? emitted : `./${emitted}`;
|
|
231
|
+
}
|
|
232
|
+
init.assetUrls = urlMap;
|
|
233
|
+
init.knownAssets = Object.keys(urlMap).sort();
|
|
234
|
+
}
|
|
235
|
+
wrapperLines.push(`const ${document.exportName} = createRendererWrapper(${JSON.stringify(document.documentName)}, resolveRenderer(${JSON.stringify(document.exportName)}), ${JSON.stringify(init)});`);
|
|
236
|
+
}
|
|
237
|
+
const exportList = documents.map((doc) => doc.exportName).join(", ");
|
|
238
|
+
const rendererPath = useZeroPrefix ? addZeroPrefix(rendererVirtualId) : rendererVirtualId;
|
|
239
|
+
const factory = buildWrapperFactorySource({
|
|
240
|
+
mode: assetMode,
|
|
241
|
+
target,
|
|
242
|
+
zipModulePath: resolveZipModulePath(assetMode)
|
|
243
|
+
});
|
|
244
|
+
return [
|
|
245
|
+
`import * as rendererModule from ${JSON.stringify(rendererPath)};`,
|
|
246
|
+
factory,
|
|
247
|
+
[
|
|
248
|
+
`function resolveRenderer(name) {`,
|
|
249
|
+
` const renderer = rendererModule?.[name] ?? rendererModule?.default?.[name] ?? rendererModule?.default?.default?.[name];`,
|
|
250
|
+
` if (!renderer) {`,
|
|
251
|
+
` throw new Error('Renderer export "' + name + '" not found');`,
|
|
252
|
+
` }`,
|
|
253
|
+
` return renderer;`,
|
|
254
|
+
`}`
|
|
255
|
+
].join("\n"),
|
|
256
|
+
wrapperLines.join("\n"),
|
|
257
|
+
`export { ${exportList} };`,
|
|
258
|
+
`export default { ${exportList} };`,
|
|
259
|
+
""
|
|
260
|
+
].join("\n\n");
|
|
261
|
+
} catch (error) {
|
|
262
|
+
logger.error("Virtual module build failure", {
|
|
263
|
+
assetsSubdir,
|
|
264
|
+
outRoot,
|
|
265
|
+
bundler,
|
|
266
|
+
virtualModuleName
|
|
267
|
+
});
|
|
268
|
+
logger.error(error);
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const universalBundlerPlugin = createUnplugin((options) => {
|
|
273
|
+
setLogLevel(parseLogLevelFromEnv());
|
|
274
|
+
logger.debug(`${PLUGIN_NAME} options`, options);
|
|
275
|
+
const target = options.target || DEFAULT_TARGET;
|
|
276
|
+
const userBundleName = resolveBundleName(options.bundleName);
|
|
277
|
+
const userBundleNamePattern = escapeRegExp(userBundleName);
|
|
278
|
+
let config;
|
|
279
|
+
let outRoot;
|
|
280
|
+
let assetsSubdir;
|
|
281
|
+
let compiledDocuments = /* @__PURE__ */ new Map();
|
|
282
|
+
let emittedAssetNames = /* @__PURE__ */ new Set();
|
|
283
|
+
let useZeroPrefix = true;
|
|
284
|
+
let bundler = "rollup";
|
|
285
|
+
let isDevServer = false;
|
|
286
|
+
let compiledBundle = null;
|
|
287
|
+
const rendererSourceMap = /* @__PURE__ */ new Map();
|
|
288
|
+
function reset() {
|
|
289
|
+
assetsSubdir = sanitiseSubdir(options.assetsOutDir);
|
|
290
|
+
emittedAssetNames.clear();
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
name: PLUGIN_NAME,
|
|
294
|
+
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX,
|
|
295
|
+
async buildStart() {
|
|
296
|
+
logger.debug("Getting Format config");
|
|
297
|
+
config = (await loadConfig(options.configPath)).config;
|
|
298
|
+
await warnOnLockstepDrift(options.configPath ? dirname(options.configPath) : process.cwd());
|
|
299
|
+
reset();
|
|
300
|
+
},
|
|
301
|
+
resolveId(id, importer) {
|
|
302
|
+
if ((importer ? stripPrefix(importer, RENDERER_MODULE) : null) !== null && id.startsWith(".")) {
|
|
303
|
+
if (!compiledBundle) return null;
|
|
304
|
+
return resolve(compiledBundle.outDir, id);
|
|
305
|
+
}
|
|
306
|
+
const virtualName = stripPrefix(id, VIRTUAL_MODULE_PREFIX);
|
|
307
|
+
if (virtualName !== null) {
|
|
308
|
+
if (virtualName !== userBundleName && virtualName !== `renderer/${userBundleName}`) throw new Error(`Unknown Format virtual module "${virtualName}". Use "${VIRTUAL_MODULE_PREFIX}${userBundleName}".`);
|
|
309
|
+
const clean = cleanId(id);
|
|
310
|
+
return useZeroPrefix ? addZeroPrefix(clean) : clean;
|
|
311
|
+
}
|
|
312
|
+
return null;
|
|
313
|
+
},
|
|
314
|
+
vite: {
|
|
315
|
+
configResolved(viteConfig) {
|
|
316
|
+
bundler = "vite";
|
|
317
|
+
useZeroPrefix = true;
|
|
318
|
+
isDevServer = viteConfig.command === "serve";
|
|
319
|
+
outRoot = resolve(viteConfig.root || process.cwd(), viteConfig.build.outDir);
|
|
320
|
+
reset();
|
|
321
|
+
},
|
|
322
|
+
configureServer(server) {
|
|
323
|
+
server.middlewares.use("/__format-assets", async (req, res, next) => {
|
|
324
|
+
const urlPath = decodeURIComponent((req.url || "").replace(/^\//, "").split("?")[0]);
|
|
325
|
+
const sendBuffer = (buffer) => {
|
|
326
|
+
res.statusCode = 200;
|
|
327
|
+
res.setHeader("Content-Type", urlPath.endsWith(".zip") ? "application/zip" : "application/octet-stream");
|
|
328
|
+
res.setHeader("Cache-Control", "no-store");
|
|
329
|
+
res.end(buffer);
|
|
330
|
+
};
|
|
331
|
+
const memoryBuffer = memoryAssets.get(urlPath);
|
|
332
|
+
if (memoryBuffer) {
|
|
333
|
+
sendBuffer(memoryBuffer);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (!compiledBundle) {
|
|
337
|
+
next();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const outDirRoot = resolve(compiledBundle.outDir);
|
|
341
|
+
const filePath = resolve(outDirRoot, urlPath);
|
|
342
|
+
if (filePath !== outDirRoot && !filePath.startsWith(outDirRoot + "/")) {
|
|
343
|
+
next();
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
sendBuffer(await readFile(filePath));
|
|
348
|
+
} catch {
|
|
349
|
+
next();
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
async handleHotUpdate(ctx) {
|
|
354
|
+
const file = ctx.file;
|
|
355
|
+
const root = ctx.server.config.root;
|
|
356
|
+
if (file.includes(`/${DEFAULT_OUT_DIR_NAME}/`)) {
|
|
357
|
+
logger.debug(`[HMR] Ignored ${DEFAULT_OUT_DIR_NAME} output:`, file);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (options.outDir && file.startsWith(resolve(root, options.outDir))) {
|
|
361
|
+
logger.debug("[HMR] Ignored outDir output:", file);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
for (const [documentName] of compiledDocuments) {
|
|
365
|
+
const documentDir = dirname(await getUserDocumentIndex({
|
|
366
|
+
documentName,
|
|
367
|
+
config
|
|
368
|
+
}));
|
|
369
|
+
if (file.startsWith(documentDir)) {
|
|
370
|
+
logger.debug(`[HMR] File affects document "${documentName}"`);
|
|
371
|
+
compiledDocuments.clear();
|
|
372
|
+
rendererSourceMap.clear();
|
|
373
|
+
compiledBundle = null;
|
|
374
|
+
logger.debug("[HMR] Recompiling Format bundle");
|
|
375
|
+
compiledBundle = await compileBundle({
|
|
376
|
+
config,
|
|
377
|
+
options,
|
|
378
|
+
compiledDocuments,
|
|
379
|
+
compiledBundle,
|
|
380
|
+
bundler
|
|
381
|
+
});
|
|
382
|
+
const mainId = useZeroPrefix ? addZeroPrefix(`${VIRTUAL_MODULE_PREFIX}${userBundleName}`) : `${VIRTUAL_MODULE_PREFIX}${userBundleName}`;
|
|
383
|
+
const mainModule = ctx.server.moduleGraph.getModuleById(mainId);
|
|
384
|
+
if (mainModule) {
|
|
385
|
+
logger.debug(`[HMR] Invalidating Vite module: ${mainId}`);
|
|
386
|
+
ctx.server.moduleGraph.invalidateModule(mainModule);
|
|
387
|
+
} else logger.debug(`[HMR] Main module not in graph yet: ${mainId}`);
|
|
388
|
+
const rendererVirtualId = `${RENDERER_MODULE}${userBundleName}`;
|
|
389
|
+
const rendererId = useZeroPrefix ? addZeroPrefix(rendererVirtualId) : rendererVirtualId;
|
|
390
|
+
const rendererModule = ctx.server.moduleGraph.getModuleById(rendererId);
|
|
391
|
+
if (rendererModule) {
|
|
392
|
+
logger.debug(`[HMR] Invalidating renderer module: ${rendererId}`);
|
|
393
|
+
ctx.server.moduleGraph.invalidateModule(rendererModule);
|
|
394
|
+
} else logger.debug(`[HMR] Renderer module not in graph yet: ${rendererId}`);
|
|
395
|
+
const modules = [mainModule, rendererModule].filter((m) => m !== void 0);
|
|
396
|
+
return modules.length > 0 ? modules : void 0;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
rollup: { outputOptions(rollupOut) {
|
|
402
|
+
bundler = "rollup";
|
|
403
|
+
useZeroPrefix = true;
|
|
404
|
+
outRoot = rollupOut.dir ?? (rollupOut.file ? dirname(rollupOut.file) : process.cwd());
|
|
405
|
+
reset();
|
|
406
|
+
return rollupOut;
|
|
407
|
+
} },
|
|
408
|
+
webpack(compiler) {
|
|
409
|
+
var _compiler$options$mod;
|
|
410
|
+
bundler = "webpack";
|
|
411
|
+
useZeroPrefix = true;
|
|
412
|
+
outRoot = compiler.options.output?.path ?? process.cwd();
|
|
413
|
+
const formatVirtualModule = /(?:@|%40)format(?::|%3a)/i;
|
|
414
|
+
(_compiler$options$mod = compiler.options.module).rules ?? (_compiler$options$mod.rules = []);
|
|
415
|
+
compiler.options.module.rules.push({
|
|
416
|
+
test: formatVirtualModule,
|
|
417
|
+
parser: {
|
|
418
|
+
url: false,
|
|
419
|
+
importMeta: false
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
reset();
|
|
423
|
+
},
|
|
424
|
+
esbuild: { setup(build) {
|
|
425
|
+
bundler = "esbuild";
|
|
426
|
+
useZeroPrefix = false;
|
|
427
|
+
outRoot = build.initialOptions.outdir ?? (build.initialOptions.outfile ? dirname(build.initialOptions.outfile) : process.cwd());
|
|
428
|
+
reset();
|
|
429
|
+
const namespace = PLUGIN_NAME;
|
|
430
|
+
const VIRTUAL_RE = /* @__PURE__ */ new RegExp(`^format:(?:renderer\\/)?${userBundleNamePattern}$`);
|
|
431
|
+
build.onResolve({ filter: VIRTUAL_RE }, (args) => {
|
|
432
|
+
return {
|
|
433
|
+
path: args.path,
|
|
434
|
+
namespace
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
build.onLoad({
|
|
438
|
+
filter: /.*/,
|
|
439
|
+
namespace
|
|
440
|
+
}, async (args) => {
|
|
441
|
+
const id = cleanId(args.path);
|
|
442
|
+
const rendererName = stripPrefix(id, RENDERER_MODULE);
|
|
443
|
+
if (rendererName !== null) return {
|
|
444
|
+
contents: getRegisteredRendererSource(rendererName, rendererSourceMap),
|
|
445
|
+
loader: "js",
|
|
446
|
+
resolveDir: compiledBundle?.outDir ?? process.cwd()
|
|
447
|
+
};
|
|
448
|
+
const virtualModuleName = stripPrefix(id, VIRTUAL_MODULE_PREFIX);
|
|
449
|
+
if (virtualModuleName === null) return null;
|
|
450
|
+
if (virtualModuleName !== userBundleName) throw new Error(`Unknown Format virtual module "${virtualModuleName}". Use "${VIRTUAL_MODULE_PREFIX}${userBundleName}".`);
|
|
451
|
+
logger.debug(`Format virtual module loaded: ${id}`);
|
|
452
|
+
compiledBundle = await compileBundle({
|
|
453
|
+
config,
|
|
454
|
+
options,
|
|
455
|
+
compiledDocuments,
|
|
456
|
+
compiledBundle,
|
|
457
|
+
bundler
|
|
458
|
+
});
|
|
459
|
+
const code = await buildVirtualModuleCode({
|
|
460
|
+
target,
|
|
461
|
+
useZeroPrefix,
|
|
462
|
+
options,
|
|
463
|
+
config,
|
|
464
|
+
compiledDocuments,
|
|
465
|
+
compiledBundle,
|
|
466
|
+
rendererSourceMap,
|
|
467
|
+
outRoot,
|
|
468
|
+
assetsSubdir,
|
|
469
|
+
emittedAssetNames,
|
|
470
|
+
bundler,
|
|
471
|
+
emitFile: () => {},
|
|
472
|
+
virtualModuleName,
|
|
473
|
+
isDevServer: false,
|
|
474
|
+
bundleName: userBundleName
|
|
475
|
+
});
|
|
476
|
+
if (code === null) return null;
|
|
477
|
+
return {
|
|
478
|
+
contents: code,
|
|
479
|
+
loader: "js",
|
|
480
|
+
resolveDir: process.cwd()
|
|
481
|
+
};
|
|
482
|
+
});
|
|
483
|
+
} },
|
|
484
|
+
transformInclude(id) {
|
|
485
|
+
const cid = cleanId(id);
|
|
486
|
+
return /\.(m?[jt]sx?|cjs|mts|cts|vue|svelte)$/.test(cid);
|
|
487
|
+
},
|
|
488
|
+
transform(code) {
|
|
489
|
+
if (!useZeroPrefix) return null;
|
|
490
|
+
const rewritten = code.replace(/(import\s+[^'"]*from\s*|import\s*\(\s*|require\s*\(\s*)['"]format:/g, ($0) => $0.replace("format:", "\0format:"));
|
|
491
|
+
return rewritten === code ? null : {
|
|
492
|
+
code: rewritten,
|
|
493
|
+
map: null
|
|
494
|
+
};
|
|
495
|
+
},
|
|
496
|
+
async load(id) {
|
|
497
|
+
const rendererName = stripPrefix(id, RENDERER_MODULE);
|
|
498
|
+
if (rendererName !== null) return getRegisteredRendererSource(rendererName, rendererSourceMap);
|
|
499
|
+
const virtualModuleName = stripPrefix(id, VIRTUAL_MODULE_PREFIX);
|
|
500
|
+
if (virtualModuleName === null) return null;
|
|
501
|
+
if (virtualModuleName !== userBundleName) throw new Error(`Unknown Format virtual module "${virtualModuleName}". Use "${VIRTUAL_MODULE_PREFIX}${userBundleName}".`);
|
|
502
|
+
logger.debug(`Format virtual module loaded: ${id}`);
|
|
503
|
+
const emitFile = this.emitFile ? this.emitFile.bind(this) : () => {};
|
|
504
|
+
compiledBundle = await compileBundle({
|
|
505
|
+
config,
|
|
506
|
+
options,
|
|
507
|
+
compiledDocuments,
|
|
508
|
+
compiledBundle,
|
|
509
|
+
bundler
|
|
510
|
+
});
|
|
511
|
+
return buildVirtualModuleCode({
|
|
512
|
+
target,
|
|
513
|
+
useZeroPrefix,
|
|
514
|
+
options,
|
|
515
|
+
config,
|
|
516
|
+
compiledDocuments,
|
|
517
|
+
compiledBundle,
|
|
518
|
+
rendererSourceMap,
|
|
519
|
+
outRoot,
|
|
520
|
+
assetsSubdir,
|
|
521
|
+
emittedAssetNames,
|
|
522
|
+
bundler,
|
|
523
|
+
emitFile,
|
|
524
|
+
virtualModuleName,
|
|
525
|
+
isDevServer,
|
|
526
|
+
bundleName: userBundleName
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
});
|
|
531
|
+
const formatVitePlugin = universalBundlerPlugin.vite;
|
|
532
|
+
const formatRollupPlugin = universalBundlerPlugin.rollup;
|
|
533
|
+
const formatRolldownPlugin = universalBundlerPlugin.rollup;
|
|
534
|
+
const formatWebpackPlugin = universalBundlerPlugin.webpack;
|
|
535
|
+
const formatEsbuildPlugin = universalBundlerPlugin.esbuild;
|
|
536
|
+
|
|
537
|
+
//#endregion
|
|
538
|
+
export { buildRendererModuleSource, buildVirtualModuleCode, emitAssetFile, formatEsbuildPlugin, formatRolldownPlugin, formatRollupPlugin, formatVitePlugin, formatWebpackPlugin, universalBundlerPlugin };
|
|
539
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["wrapperLines: string[]","init: {\n\t\t\t\tknownAssets: string[]\n\t\t\t\tassetUrls: Record<string, string> | null\n\t\t\t\tassetsPath: string | null\n\t\t\t\tassetsUrl: string | null\n\t\t\t}","zipBuffer: Buffer | null","urlMap: Record<string, string>","target: Target","config: FormatConfig","outRoot: string | undefined","assetsSubdir: string | undefined","compiledDocuments: Map<string, CompiledDocument>","emittedAssetNames: Set<string>","bundler: Bundler","compiledBundle: CompiledBundle | null"],"sources":["../../../../src/server/integrations/unplugin/index.ts"],"sourcesContent":["import type { FormatConfig } from '../../../shared/types'\nimport type { AssetMode, FormatUnpluginOptions, Target } from '../../../shared/types/public'\nimport type { DocumentAssetState } from '../../compile/compile'\n\nimport { dirname, resolve } from 'node:path'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { pathToFileURL } from 'node:url'\nimport { createUnplugin } from 'unplugin'\nimport { listZipEntries } from '@format.dev/zip'\nimport { loadConfig } from '../../utils'\nimport { buildDocumentExportMap } from '@format.dev/cli/scaffold'\nimport { readFile } from 'node:fs/promises'\nimport { getDocuments, getUserDocumentIndex } from '../../project/documents'\nimport { createHash } from 'node:crypto'\nimport { compileForUnplugin } from '../../compile/compile'\nimport { logger, setLogLevel } from '../../utils/log'\nimport { parseLogLevelFromEnv } from '../../utils/env-var'\nimport { warnOnLockstepDrift } from '../../utils/warn-lockstep'\nimport { getBundleOutDir } from '../../compile'\nimport { resolveBundleName } from '../../compile/bundle-name'\nimport { writeFormatEnvTypes } from '../../project/format-env-types'\nimport { getUserProjectDir } from '../../project/user-project-dir'\nimport { BUNDLE_ENTRY_POINT_FILE_NAME } from '../../compile/constants'\nimport { dynamicAssetEmitEntries } from '../../compile/document-assets'\nimport { buildWrapperFactorySource } from '../../compile/wrapper-source'\nimport { resolveZipModulePath } from '../../compile/make-config'\nimport { DEFAULT_OUT_DIR_NAME } from '../../project/paths'\nimport { sanitiseSubdir, safeRelPath, cleanId, addZeroPrefix, stripPrefix } from './utils'\n\nexport interface CompiledDocument {\n\tdocumentName: string\n\texportName: string\n\tassetsPath: string | null\n\thash: string\n}\n\nfunction resolveAssetMode(options: FormatUnpluginOptions, config: FormatConfig): AssetMode {\n\treturn options.assets ?? 'static'\n}\n\nexport interface CompiledBundle {\n\toutDir: string\n\thash: string\n\tcompiledAt: number\n\t/** Each document's compiled asset state, keyed by name. Empty for static/none. */\n\tassetState: Map<string, DocumentAssetState>\n}\n\nconst PLUGIN_NAME = 'format-unplugin'\n\nconst DEFAULT_TARGET = 'node'\n\n// User virtual module prefix\n// Example: import renderers from 'format:documents'\nconst VIRTUAL_MODULE_PREFIX = '@format:'\n\nfunction escapeRegExp(value: string) {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n// Internal virtual module, turns into:\n// import renderer from 'format:renderer/documents'\n// User does not need this\nconst RENDERER_MODULE = `${VIRTUAL_MODULE_PREFIX}renderer/`\n\nconst memoryAssets = new Map<string, Buffer>()\n\nexport function buildRendererModuleSource(outDir: string, documents: CompiledDocument[]): string {\n\tconst importLines = documents.map(document => {\n\t\tconst importPath = `./${document.documentName}/${BUNDLE_ENTRY_POINT_FILE_NAME}`.replace(/\\\\/g, '/')\n\t\treturn `import { ${document.exportName} } from ${JSON.stringify(importPath)};`\n\t})\n\tconst exportNames = documents.map(document => document.exportName)\n\n\treturn [\n\t\t...importLines,\n\t\t'',\n\t\t`export { ${exportNames.join(', ')} };`,\n\t\t`export default { ${exportNames.join(', ')} };`,\n\t\t''\n\t].join('\\n')\n}\n\nasync function getDocumentHash(documentName: string, config: FormatConfig): Promise<string> {\n\tconst hash = createHash('sha256')\n\tconst documentIndexPath = await getUserDocumentIndex({ documentName, config })\n\n\ttry {\n\t\tconst content = await readFile(documentIndexPath, 'utf-8')\n\n\t\thash.update(content)\n\n\t\treturn hash.digest('hex').substring(0, 8)\n\t} catch {\n\t\treturn 'initial'\n\t}\n}\n\ninterface CompileBundleArgs {\n\tconfig: FormatConfig\n\toptions: FormatUnpluginOptions\n\tcompiledDocuments: Map<string, CompiledDocument>\n\tcompiledBundle: CompiledBundle | null\n\tbundler: Bundler\n}\n\ntype Bundler = 'vite' | 'rollup' | 'esbuild' | 'webpack' | 'rspack'\n\nconst compileBundle = async (args: CompileBundleArgs): Promise<CompiledBundle> => {\n\tconst { config, options, compiledDocuments, compiledBundle, bundler } = args\n\n\tconst documents = await getDocuments(config)\n\tconst documentNames = documents.map(doc => doc.name).sort((a, b) => a.localeCompare(b))\n\n\tif (documentNames.length === 0) {\n\t\tthrow new Error('No documents found to compile.')\n\t}\n\n\tconst exportNames = buildDocumentExportMap(documentNames)\n\n\t// Keep the project's format-env.d.ts in sync with the current documents.\n\t// Depends only on the document set, so it runs regardless of the bundle\n\t// cache below, and no-ops when the contents are unchanged.\n\tawait writeFormatEnvTypes({\n\t\tprojectRoot: getUserProjectDir(),\n\t\taliases: [`${VIRTUAL_MODULE_PREFIX}${resolveBundleName(options.bundleName)}`],\n\t\tdocuments: documentNames.map(name => ({ exportName: exportNames.get(name)! }))\n\t})\n\n\tconst documentHashes = new Map<string, string>()\n\tfor (const documentName of documentNames) {\n\t\tconst hash = await getDocumentHash(documentName, config)\n\t\tdocumentHashes.set(documentName, hash)\n\t}\n\n\tconst bundleHashInput = documentNames.map(name => `${name}:${documentHashes.get(name)}`).join('|')\n\tconst bundleHash = createHash('sha256').update(bundleHashInput).digest('hex').substring(0, 8)\n\n\tif (compiledBundle?.hash === bundleHash && compiledDocuments.size === documentNames.length) {\n\t\tlogger.debug('Format bundle already compiled')\n\t\treturn compiledBundle\n\t}\n\n\tlogger.debug(`Compiling Format bundle: ${documentNames.join(', ')}`)\n\n\tconst {\n\t\tassets,\n\t\tvalidateSchema,\n\t\tinlineRemoteCss,\n\t\ttarget,\n\t\toutDir: outDirOverride,\n\t\tconfigPath,\n\t\tbundleName,\n\t\tclean\n\t} = options\n\n\tconst compileOptions = {\n\t\tdocuments: documentNames,\n\t\tassets,\n\t\tvalidateSchema,\n\t\tinlineRemoteCss,\n\t\ttarget,\n\t\tconfigPath,\n\t\toutDir: outDirOverride,\n\t\tbundleName,\n\t\tclean,\n\t\tuserBundler: bundler\n\t}\n\n\tlogger.debug('Passing compile context from unplugin', {\n\t\tuserBundler: bundler,\n\t\ttarget\n\t})\n\n\tconst assetState = new Map<string, DocumentAssetState>()\n\tawait compileForUnplugin(compileOptions, { capturedAssetState: assetState })\n\n\tconst outDir = getBundleOutDir(config, outDirOverride)\n\n\tlogger.debug(`Format bundle outDir: ${outDir}`)\n\n\tconst assetMode = resolveAssetMode(options, config)\n\n\tcompiledDocuments.clear()\n\tfor (const documentName of documentNames) {\n\t\tcompiledDocuments.set(documentName, {\n\t\t\tdocumentName,\n\t\t\texportName: exportNames.get(documentName)!,\n\t\t\thash: documentHashes.get(documentName)!,\n\t\t\tassetsPath: assetMode === 'static' ? resolve(outDir, documentName, 'assets.zip') : null\n\t\t})\n\t}\n\n\treturn {\n\t\toutDir,\n\t\thash: bundleHash,\n\t\tcompiledAt: Date.now(),\n\t\tassetState\n\t}\n}\n\nexport interface EmitAssetFileArgs {\n\temitFile: (asset: { type: 'asset'; fileName: string; source: Buffer }) => void\n\tbuffer: Buffer\n\trelName: string\n\toutRoot: string\n\tassetsSubdir: string\n\temittedAssetNames: Set<string>\n\tbundler: Bundler\n}\n\n/**\n * Emit one asset file into the consumer's bundle output. Returns the emitted\n * path relative to the bundler's out dir, or the already-emitted path when a\n * previous document emitted the same file (shared `_imported/` files, fonts).\n */\nexport async function emitAssetFile(args: EmitAssetFileArgs): Promise<string> {\n\tconst { emitFile, buffer, relName, outRoot, assetsSubdir, emittedAssetNames, bundler } = args\n\n\tconst root = outRoot || process.cwd()\n\tconst { rel: assetFileName } = safeRelPath(root, assetsSubdir, relName)\n\n\tif (emittedAssetNames.has(assetFileName)) {\n\t\tlogger.debug(`Skip duplicate asset emit: ${assetFileName}`)\n\t\treturn assetFileName\n\t}\n\n\tif (bundler === 'esbuild') {\n\t\t// ESBuild doesn't support emitFile\n\t\tconst assetAbsPath = resolve(root, assetFileName)\n\t\tawait mkdir(dirname(assetAbsPath), { recursive: true })\n\t\tawait writeFile(assetAbsPath, buffer)\n\t\temittedAssetNames.add(assetFileName)\n\t\treturn assetFileName\n\t}\n\n\temitFile({\n\t\ttype: 'asset',\n\t\tfileName: assetFileName, // always relative to bundler out dir\n\t\tsource: buffer\n\t})\n\n\temittedAssetNames.add(assetFileName)\n\treturn assetFileName\n}\n\nfunction getRegisteredRendererSource(rendererName: string, rendererSourceMap: Map<string, string>): string {\n\tconst source = rendererSourceMap.get(rendererName)\n\n\tif (!source) {\n\t\tthrow new Error(`Renderer source not registered for \"${rendererName}\"`)\n\t}\n\n\treturn source\n}\n\nexport interface BuildVirtualModuleArgs {\n\ttarget: Target\n\tuseZeroPrefix: boolean\n\toptions: FormatUnpluginOptions\n\tconfig: FormatConfig\n\tcompiledDocuments: Map<string, CompiledDocument>\n\tcompiledBundle: CompiledBundle | null\n\trendererSourceMap: Map<string, string>\n\toutRoot?: string\n\tassetsSubdir?: string\n\temittedAssetNames: Set<string>\n\tbundler: Bundler\n\tvirtualModuleName: string\n\temitFile: (x: any) => void\n\tisDevServer: boolean\n\tbundleName: string\n}\n\nexport async function buildVirtualModuleCode(args: BuildVirtualModuleArgs): Promise<string | null> {\n\tconst {\n\t\ttarget,\n\t\tuseZeroPrefix,\n\t\tvirtualModuleName,\n\t\toptions,\n\t\tconfig,\n\t\tcompiledDocuments,\n\t\tcompiledBundle,\n\t\trendererSourceMap,\n\t\toutRoot,\n\t\tassetsSubdir,\n\t\temittedAssetNames,\n\t\tbundler,\n\t\temitFile,\n\t\tisDevServer,\n\t\tbundleName\n\t} = args\n\n\ttry {\n\t\tif (virtualModuleName !== bundleName) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unsupported Format virtual module \"${virtualModuleName}\". Use \"${VIRTUAL_MODULE_PREFIX}${bundleName}\".`\n\t\t\t)\n\t\t}\n\n\t\tif (!compiledBundle) {\n\t\t\tthrow new Error('Format bundle not compiled.')\n\t\t}\n\n\t\tconst assetMode = resolveAssetMode(options, config)\n\t\tconst rendererVirtualId = `${RENDERER_MODULE}${bundleName}`\n\t\tconst documents = [...compiledDocuments.values()].sort((a, b) => a.documentName.localeCompare(b.documentName))\n\t\tconst rendererSource = buildRendererModuleSource(compiledBundle.outDir, documents)\n\n\t\trendererSourceMap.set(bundleName, rendererSource)\n\n\t\tconst isViteDev = bundler === 'vite' && isDevServer\n\t\tconst emitRoot = outRoot || process.cwd()\n\t\tconst emitSubdir = assetsSubdir || ''\n\t\tconst wrapperLines: string[] = []\n\n\t\tfor (const document of documents) {\n\t\t\tconst init: {\n\t\t\t\tknownAssets: string[]\n\t\t\t\tassetUrls: Record<string, string> | null\n\t\t\t\tassetsPath: string | null\n\t\t\t\tassetsUrl: string | null\n\t\t\t} = { knownAssets: [], assetUrls: null, assetsPath: null, assetsUrl: null }\n\n\t\t\tif (assetMode === 'static') {\n\t\t\t\tlet zipBuffer: Buffer | null = null\n\n\t\t\t\ttry {\n\t\t\t\t\tzipBuffer = await readFile(document.assetsPath!)\n\t\t\t\t} catch {\n\t\t\t\t\tlogger.debug(`No assets found for document: ${document.documentName}`)\n\t\t\t\t}\n\n\t\t\t\tif (zipBuffer) {\n\t\t\t\t\tinit.knownAssets = listZipEntries(new Uint8Array(zipBuffer))\n\n\t\t\t\t\tif (isViteDev && target === 'node') {\n\t\t\t\t\t\tinit.assetsUrl = pathToFileURL(document.assetsPath!).href\n\t\t\t\t\t} else if (isViteDev) {\n\t\t\t\t\t\tmemoryAssets.set(`${document.documentName}.zip`, zipBuffer)\n\t\t\t\t\t\tinit.assetsUrl = `/__format-assets/${document.documentName}.zip`\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst emitted = await emitAssetFile({\n\t\t\t\t\t\t\temitFile,\n\t\t\t\t\t\t\tbuffer: zipBuffer,\n\t\t\t\t\t\t\trelName: `${document.documentName}/assets.zip`,\n\t\t\t\t\t\t\toutRoot: emitRoot,\n\t\t\t\t\t\t\tassetsSubdir: emitSubdir,\n\t\t\t\t\t\t\temittedAssetNames,\n\t\t\t\t\t\t\tbundler\n\t\t\t\t\t\t})\n\t\t\t\t\t\tinit.assetsPath = emitted.startsWith('./') ? emitted : `./${emitted}`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (assetMode === 'dynamic') {\n\t\t\t\tconst compiledUrlMap = compiledBundle.assetState.get(document.documentName)?.urlMap ?? {}\n\t\t\t\tconst entries = dynamicAssetEmitEntries({\n\t\t\t\t\toutDir: compiledBundle.outDir,\n\t\t\t\t\tdocumentName: document.documentName,\n\t\t\t\t\turlMap: compiledUrlMap\n\t\t\t\t})\n\n\t\t\t\tconst urlMap: Record<string, string> = {}\n\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tif (isViteDev && target === 'node') {\n\t\t\t\t\t\turlMap[entry.knownPath] = pathToFileURL(entry.sourcePath).href\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isViteDev) {\n\t\t\t\t\t\turlMap[entry.knownPath] = `/__format-assets/${entry.emitPath}`\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tconst emitted = await emitAssetFile({\n\t\t\t\t\t\temitFile,\n\t\t\t\t\t\tbuffer: await readFile(entry.sourcePath),\n\t\t\t\t\t\trelName: entry.emitPath,\n\t\t\t\t\t\toutRoot: emitRoot,\n\t\t\t\t\t\tassetsSubdir: emitSubdir,\n\t\t\t\t\t\temittedAssetNames,\n\t\t\t\t\t\tbundler\n\t\t\t\t\t})\n\t\t\t\t\turlMap[entry.knownPath] = emitted.startsWith('./') ? emitted : `./${emitted}`\n\t\t\t\t}\n\n\t\t\t\tinit.assetUrls = urlMap\n\t\t\t\tinit.knownAssets = Object.keys(urlMap).sort()\n\t\t\t}\n\n\t\t\twrapperLines.push(\n\t\t\t\t`const ${document.exportName} = createRendererWrapper(${JSON.stringify(document.documentName)}, resolveRenderer(${JSON.stringify(document.exportName)}), ${JSON.stringify(init)});`\n\t\t\t)\n\t\t}\n\n\t\tconst exportList = documents.map(doc => doc.exportName).join(', ')\n\t\tconst rendererPath = useZeroPrefix ? addZeroPrefix(rendererVirtualId) : rendererVirtualId\n\t\tconst factory = buildWrapperFactorySource({\n\t\t\tmode: assetMode,\n\t\t\ttarget,\n\t\t\tzipModulePath: resolveZipModulePath(assetMode)\n\t\t})\n\n\t\treturn [\n\t\t\t`import * as rendererModule from ${JSON.stringify(rendererPath)};`,\n\t\t\tfactory,\n\t\t\t[\n\t\t\t\t`function resolveRenderer(name) {`,\n\t\t\t\t`\tconst renderer = rendererModule?.[name] ?? rendererModule?.default?.[name] ?? rendererModule?.default?.default?.[name];`,\n\t\t\t\t`\tif (!renderer) {`,\n\t\t\t\t`\t\tthrow new Error('Renderer export \"' + name + '\" not found');`,\n\t\t\t\t`\t}`,\n\t\t\t\t`\treturn renderer;`,\n\t\t\t\t`}`\n\t\t\t].join('\\n'),\n\t\t\twrapperLines.join('\\n'),\n\t\t\t`export { ${exportList} };`,\n\t\t\t`export default { ${exportList} };`,\n\t\t\t''\n\t\t].join('\\n\\n')\n\t} catch (error) {\n\t\tlogger.error('Virtual module build failure', {\n\t\t\tassetsSubdir,\n\t\t\toutRoot,\n\t\t\tbundler,\n\t\t\tvirtualModuleName\n\t\t})\n\n\t\tlogger.error(error)\n\n\t\treturn null\n\t}\n}\n\nexport const universalBundlerPlugin = createUnplugin<FormatUnpluginOptions>((options: FormatUnpluginOptions) => {\n\tsetLogLevel(parseLogLevelFromEnv())\n\n\tlogger.debug(`${PLUGIN_NAME} options`, options)\n\n\tconst target: Target = options.target || DEFAULT_TARGET\n\tconst userBundleName = resolveBundleName(options.bundleName)\n\tconst userBundleNamePattern = escapeRegExp(userBundleName)\n\n\tlet config: FormatConfig\n\tlet outRoot: string | undefined\n\tlet assetsSubdir: string | undefined\n\tlet compiledDocuments: Map<string, CompiledDocument> = new Map()\n\tlet emittedAssetNames: Set<string> = new Set()\n\tlet useZeroPrefix = true\n\tlet bundler: Bundler = 'rollup'\n\tlet isDevServer = false\n\tlet compiledBundle: CompiledBundle | null = null\n\n\tconst rendererSourceMap = new Map<string, string>()\n\n\tfunction reset() {\n\t\tassetsSubdir = sanitiseSubdir(options.assetsOutDir)\n\t\temittedAssetNames.clear()\n\t}\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\n\t\t__virtualModulePrefix: VIRTUAL_MODULE_PREFIX,\n\n\t\tasync buildStart() {\n\t\t\tlogger.debug('Getting Format config')\n\t\t\tconst result = await loadConfig(options.configPath)\n\t\t\tconfig = result.config\n\t\t\tawait warnOnLockstepDrift(options.configPath ? dirname(options.configPath) : process.cwd())\n\t\t\treset()\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tconst rendererImporter = importer ? stripPrefix(importer, RENDERER_MODULE) : null\n\t\t\tif (rendererImporter !== null && id.startsWith('.')) {\n\t\t\t\tif (!compiledBundle) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn resolve(compiledBundle.outDir, id)\n\t\t\t}\n\n\t\t\tconst virtualName = stripPrefix(id, VIRTUAL_MODULE_PREFIX)\n\t\t\tif (virtualName !== null) {\n\t\t\t\tif (virtualName !== userBundleName && virtualName !== `renderer/${userBundleName}`) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unknown Format virtual module \"${virtualName}\". Use \"${VIRTUAL_MODULE_PREFIX}${userBundleName}\".`\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst clean = cleanId(id)\n\t\t\t\treturn useZeroPrefix ? addZeroPrefix(clean) : clean\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\n\t\tvite: {\n\t\t\tconfigResolved(viteConfig) {\n\t\t\t\tbundler = 'vite'\n\t\t\t\tuseZeroPrefix = true\n\t\t\t\tisDevServer = viteConfig.command === 'serve'\n\t\t\t\toutRoot = resolve(viteConfig.root || process.cwd(), viteConfig.build.outDir)\n\t\t\t\treset()\n\t\t\t},\n\n\t\t\tconfigureServer(server) {\n\t\t\t\tserver.middlewares.use('/__format-assets', async (req, res, next) => {\n\t\t\t\t\tconst urlPath = decodeURIComponent((req.url || '').replace(/^\\//, '').split('?')[0]!)\n\n\t\t\t\t\tconst sendBuffer = (buffer: Buffer) => {\n\t\t\t\t\t\tres.statusCode = 200\n\t\t\t\t\t\tres.setHeader('Content-Type', urlPath.endsWith('.zip') ? 'application/zip' : 'application/octet-stream')\n\t\t\t\t\t\tres.setHeader('Cache-Control', 'no-store')\n\t\t\t\t\t\tres.end(buffer)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst memoryBuffer = memoryAssets.get(urlPath)\n\n\t\t\t\t\tif (memoryBuffer) {\n\t\t\t\t\t\tsendBuffer(memoryBuffer)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// Dynamic-mode dev: mapped asset files are served straight from\n\t\t\t\t\t// the compiled outDir, mirroring its layout.\n\t\t\t\t\tif (!compiledBundle) {\n\t\t\t\t\t\tnext()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst outDirRoot = resolve(compiledBundle.outDir)\n\t\t\t\t\tconst filePath = resolve(outDirRoot, urlPath)\n\t\t\t\t\tconst escapesOutDir = filePath !== outDirRoot && !filePath.startsWith(outDirRoot + '/')\n\n\t\t\t\t\tif (escapesOutDir) {\n\t\t\t\t\t\tnext()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsendBuffer(await readFile(filePath))\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tnext()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\n\t\t\tasync handleHotUpdate(ctx) {\n\t\t\t\tconst file = ctx.file\n\t\t\t\tconst root = ctx.server.config.root\n\n\t\t\t\tif (file.includes(`/${DEFAULT_OUT_DIR_NAME}/`)) {\n\t\t\t\t\tlogger.debug(`[HMR] Ignored ${DEFAULT_OUT_DIR_NAME} output:`, file)\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\n\t\t\t\tif (options.outDir && file.startsWith(resolve(root, options.outDir))) {\n\t\t\t\t\tlogger.debug('[HMR] Ignored outDir output:', file)\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\n\t\t\t\t// Does this update belong to a format document?\n\t\t\t\tfor (const [documentName] of compiledDocuments) {\n\t\t\t\t\tconst indexPath = await getUserDocumentIndex({ documentName, config })\n\t\t\t\t\tconst documentDir = dirname(indexPath)\n\n\t\t\t\t\tif (file.startsWith(documentDir)) {\n\t\t\t\t\t\tlogger.debug(`[HMR] File affects document \"${documentName}\"`)\n\n\t\t\t\t\t\tcompiledDocuments.clear()\n\t\t\t\t\t\trendererSourceMap.clear()\n\t\t\t\t\t\tcompiledBundle = null\n\n\t\t\t\t\t\tlogger.debug('[HMR] Recompiling Format bundle')\n\t\t\t\t\t\tcompiledBundle = await compileBundle({\n\t\t\t\t\t\t\tconfig,\n\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\tcompiledDocuments,\n\t\t\t\t\t\t\tcompiledBundle,\n\t\t\t\t\t\t\tbundler\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\t// Invalidate the user's virtual module import tree\n\t\t\t\t\t\tconst mainId = useZeroPrefix\n\t\t\t\t\t\t\t? addZeroPrefix(`${VIRTUAL_MODULE_PREFIX}${userBundleName}`)\n\t\t\t\t\t\t\t: `${VIRTUAL_MODULE_PREFIX}${userBundleName}`\n\t\t\t\t\t\tconst mainModule = ctx.server.moduleGraph.getModuleById(mainId)\n\n\t\t\t\t\t\tif (mainModule) {\n\t\t\t\t\t\t\tlogger.debug(`[HMR] Invalidating Vite module: ${mainId}`)\n\t\t\t\t\t\t\tctx.server.moduleGraph.invalidateModule(mainModule)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlogger.debug(`[HMR] Main module not in graph yet: ${mainId}`)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Invalidate the renderer virtual module import tree\n\t\t\t\t\t\tconst rendererVirtualId = `${RENDERER_MODULE}${userBundleName}`\n\t\t\t\t\t\tconst rendererId = useZeroPrefix ? addZeroPrefix(rendererVirtualId) : rendererVirtualId\n\t\t\t\t\t\tconst rendererModule = ctx.server.moduleGraph.getModuleById(rendererId)\n\n\t\t\t\t\t\tif (rendererModule) {\n\t\t\t\t\t\t\tlogger.debug(`[HMR] Invalidating renderer module: ${rendererId}`)\n\t\t\t\t\t\t\tctx.server.moduleGraph.invalidateModule(rendererModule)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlogger.debug(`[HMR] Renderer module not in graph yet: ${rendererId}`)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trigger HMR for both (main + renderer)\n\t\t\t\t\t\tconst modules = [mainModule, rendererModule].filter((m): m is NonNullable<typeof m> => m !== undefined)\n\t\t\t\t\t\treturn modules.length > 0 ? modules : undefined\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Not related to any document → normal Vite handling\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t},\n\n\t\trollup: {\n\t\t\toutputOptions(rollupOut) {\n\t\t\t\tbundler = 'rollup'\n\t\t\t\tuseZeroPrefix = true\n\t\t\t\toutRoot = rollupOut.dir ?? (rollupOut.file ? dirname(rollupOut.file) : process.cwd())\n\t\t\t\treset()\n\t\t\t\treturn rollupOut\n\t\t\t}\n\t\t},\n\n\t\twebpack(compiler) {\n\t\t\tbundler = 'webpack'\n\t\t\tuseZeroPrefix = true\n\t\t\toutRoot = compiler.options.output?.path ?? process.cwd()\n\n\t\t\t// Keep `import.meta.url` native inside Format's virtual modules so the\n\t\t\t// emitted `assets.zip` URL resolves against the bundle's runtime\n\t\t\t// location. Webpack otherwise rewrites a bare `import.meta.url` to a\n\t\t\t// build-time `file:` URL, and turns `new URL(dynamicPath,\n\t\t\t// import.meta.url)` into an empty context module that throws at\n\t\t\t// runtime. `url: false` disables the latter; `importMeta: false` keeps\n\t\t\t// the former native. The rule is scoped to the encoded virtual-module\n\t\t\t// resource (`\\0@format:` arrives as `%00%40format%3A`) so the\n\t\t\t// consumer's own `import.meta` and `new URL` usage is left alone.\n\t\t\tconst formatVirtualModule = /(?:@|%40)format(?::|%3a)/i\n\n\t\t\t// webpack always provides normalized `module.rules`; guard only the array.\n\t\t\tcompiler.options.module.rules ??= []\n\t\t\tcompiler.options.module.rules.push({\n\t\t\t\ttest: formatVirtualModule,\n\t\t\t\tparser: { url: false, importMeta: false }\n\t\t\t})\n\n\t\t\treset()\n\t\t},\n\n\t\tesbuild: {\n\t\t\tsetup(build) {\n\t\t\t\tbundler = 'esbuild'\n\t\t\t\tuseZeroPrefix = false\n\t\t\t\toutRoot =\n\t\t\t\t\tbuild.initialOptions.outdir ??\n\t\t\t\t\t(build.initialOptions.outfile ? dirname(build.initialOptions.outfile) : process.cwd())\n\t\t\t\treset()\n\n\t\t\t\tconst namespace = PLUGIN_NAME\n\t\t\t\tconst VIRTUAL_RE = new RegExp(`^format:(?:renderer\\\\/)?${userBundleNamePattern}$`)\n\n\t\t\t\tbuild.onResolve({ filter: VIRTUAL_RE }, args => {\n\t\t\t\t\treturn { path: args.path, namespace }\n\t\t\t\t})\n\n\t\t\t\tbuild.onLoad({ filter: /.*/, namespace }, async args => {\n\t\t\t\t\tconst id = cleanId(args.path)\n\n\t\t\t\t\t// Serve renderer source\n\t\t\t\t\tconst rendererName = stripPrefix(id, RENDERER_MODULE)\n\t\t\t\t\tif (rendererName !== null) {\n\t\t\t\t\t\tconst source = getRegisteredRendererSource(rendererName, rendererSourceMap)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontents: source,\n\t\t\t\t\t\t\tloader: 'js',\n\t\t\t\t\t\t\tresolveDir: compiledBundle?.outDir ?? process.cwd()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Serve main virtual doc module\n\t\t\t\t\tconst virtualModuleName = stripPrefix(id, VIRTUAL_MODULE_PREFIX)\n\t\t\t\t\tif (virtualModuleName === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\n\t\t\t\t\tif (virtualModuleName !== userBundleName) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unknown Format virtual module \"${virtualModuleName}\". Use \"${VIRTUAL_MODULE_PREFIX}${userBundleName}\".`\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tlogger.debug(`Format virtual module loaded: ${id}`)\n\n\t\t\t\t\tcompiledBundle = await compileBundle({\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tcompiledDocuments,\n\t\t\t\t\t\tcompiledBundle,\n\t\t\t\t\t\tbundler\n\t\t\t\t\t})\n\n\t\t\t\t\tconst code = await buildVirtualModuleCode({\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\tuseZeroPrefix,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tcompiledDocuments,\n\t\t\t\t\t\tcompiledBundle,\n\t\t\t\t\t\trendererSourceMap,\n\t\t\t\t\t\toutRoot,\n\t\t\t\t\t\tassetsSubdir,\n\t\t\t\t\t\temittedAssetNames,\n\t\t\t\t\t\tbundler,\n\t\t\t\t\t\temitFile: () => {},\n\t\t\t\t\t\tvirtualModuleName,\n\t\t\t\t\t\tisDevServer: false,\n\t\t\t\t\t\tbundleName: userBundleName\n\t\t\t\t\t})\n\n\t\t\t\t\tif (code === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontents: code,\n\t\t\t\t\t\tloader: 'js',\n\t\t\t\t\t\tresolveDir: process.cwd()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\n\t\ttransformInclude(id) {\n\t\t\tconst cid = cleanId(id)\n\t\t\treturn /\\.(m?[jt]sx?|cjs|mts|cts|vue|svelte)$/.test(cid)\n\t\t},\n\n\t\ttransform(code) {\n\t\t\tif (!useZeroPrefix) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst rewritten = code.replace(/(import\\s+[^'\"]*from\\s*|import\\s*\\(\\s*|require\\s*\\(\\s*)['\"]format:/g, $0 =>\n\t\t\t\t$0.replace('format:', '\\0format:')\n\t\t\t)\n\n\t\t\treturn rewritten === code ? null : { code: rewritten, map: null }\n\t\t},\n\n\t\tasync load(id: string) {\n\t\t\t// Serve the renderer source for our virtual renderer module\n\t\t\tconst rendererName = stripPrefix(id, RENDERER_MODULE)\n\n\t\t\tif (rendererName !== null) {\n\t\t\t\treturn getRegisteredRendererSource(rendererName, rendererSourceMap)\n\t\t\t}\n\n\t\t\t// Serve the main virtual doc module\n\t\t\tconst virtualModuleName = stripPrefix(id, VIRTUAL_MODULE_PREFIX)\n\n\t\t\tif (virtualModuleName === null) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tif (virtualModuleName !== userBundleName) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unknown Format virtual module \"${virtualModuleName}\". Use \"${VIRTUAL_MODULE_PREFIX}${userBundleName}\".`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlogger.debug(`Format virtual module loaded: ${id}`)\n\n\t\t\tconst emitFile = this.emitFile ? this.emitFile.bind(this) : () => {}\n\n\t\t\tcompiledBundle = await compileBundle({\n\t\t\t\tconfig,\n\t\t\t\toptions,\n\t\t\t\tcompiledDocuments,\n\t\t\t\tcompiledBundle,\n\t\t\t\tbundler\n\t\t\t})\n\n\t\t\treturn buildVirtualModuleCode({\n\t\t\t\ttarget,\n\t\t\t\tuseZeroPrefix,\n\t\t\t\toptions,\n\t\t\t\tconfig,\n\t\t\t\tcompiledDocuments,\n\t\t\t\tcompiledBundle,\n\t\t\t\trendererSourceMap,\n\t\t\t\toutRoot,\n\t\t\t\tassetsSubdir,\n\t\t\t\temittedAssetNames,\n\t\t\t\tbundler,\n\t\t\t\temitFile,\n\t\t\t\tvirtualModuleName,\n\t\t\t\tisDevServer,\n\t\t\t\tbundleName: userBundleName\n\t\t\t})\n\t\t}\n\t}\n})\n\nexport const formatVitePlugin = universalBundlerPlugin.vite\nexport const formatRollupPlugin = universalBundlerPlugin.rollup\nexport const formatRolldownPlugin = universalBundlerPlugin.rollup\nexport const formatWebpackPlugin = universalBundlerPlugin.webpack\nexport const formatEsbuildPlugin = universalBundlerPlugin.esbuild\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,iBAAiB,SAAgC,QAAiC;AAC1F,QAAO,QAAQ,UAAU;;AAW1B,MAAM,cAAc;AAEpB,MAAM,iBAAiB;AAIvB,MAAM,wBAAwB;AAE9B,SAAS,aAAa,OAAe;AACpC,QAAO,MAAM,QAAQ,uBAAuB,OAAO;;AAMpD,MAAM,kBAAkB,GAAG,sBAAsB;AAEjD,MAAM,+BAAe,IAAI,KAAqB;AAE9C,SAAgB,0BAA0B,QAAgB,WAAuC;CAChG,MAAM,cAAc,UAAU,KAAI,aAAY;EAC7C,MAAM,aAAa,KAAK,SAAS,aAAa,GAAG,+BAA+B,QAAQ,OAAO,IAAI;AACnG,SAAO,YAAY,SAAS,WAAW,UAAU,KAAK,UAAU,WAAW,CAAC;GAC3E;CACF,MAAM,cAAc,UAAU,KAAI,aAAY,SAAS,WAAW;AAElE,QAAO;EACN,GAAG;EACH;EACA,YAAY,YAAY,KAAK,KAAK,CAAC;EACnC,oBAAoB,YAAY,KAAK,KAAK,CAAC;EAC3C;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;AACzD,MAAa,uBAAuB,uBAAuB;AAC3D,MAAa,sBAAsB,uBAAuB;AAC1D,MAAa,sBAAsB,uBAAuB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/server/integrations/unplugin/utils.d.ts
|
|
2
|
+
declare function sanitiseSubdir(input?: string): string | undefined;
|
|
3
|
+
declare function safeRelPath(outRootAbs: string, subdir: string | undefined, file: string): {
|
|
4
|
+
rel: string;
|
|
5
|
+
abs: string;
|
|
6
|
+
};
|
|
7
|
+
declare function cleanId(id: string): string;
|
|
8
|
+
declare function addZeroPrefix(id: string): string;
|
|
9
|
+
declare function stripPrefix(id: string, prefix: string): string | null;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { addZeroPrefix, cleanId, safeRelPath, sanitiseSubdir, stripPrefix };
|
|
12
|
+
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../../../src/server/integrations/unplugin/utils.ts"],"sourcesContent":[],"mappings":";iBAEgB,cAAA;AAAA,iBA2BA,WAAA,CA3Bc,UAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,GAAA,SAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA;EA2Bd,GAAA,EAAA,MAAA;EAiBA,GAAA,EAAA,MAAO;AAUvB,CAAA;AAIgB,iBAdA,OAAA,CAcW,EAAA,EAAA,MAAA,CAAA,EAAA,MAAA;iBAJX,aAAA;iBAIA,WAAA"}
|