@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,35 @@
|
|
|
1
|
+
import * as vite1 from "vite";
|
|
2
|
+
import { LogLevel } from "vite";
|
|
3
|
+
import * as postcss0 from "postcss";
|
|
4
|
+
import autoprefixer from "autoprefixer";
|
|
5
|
+
import * as rolldown0 from "rolldown";
|
|
6
|
+
|
|
7
|
+
//#region src/server/vite/create-config.d.ts
|
|
8
|
+
declare function createConfig(): {
|
|
9
|
+
baseViteConfig: {
|
|
10
|
+
root: string;
|
|
11
|
+
base: string;
|
|
12
|
+
css: {
|
|
13
|
+
transformer: "postcss";
|
|
14
|
+
postcss: {
|
|
15
|
+
plugins: (postcss0.Plugin & autoprefixer.ExportedAPI)[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
appType: "custom";
|
|
19
|
+
logLevel: LogLevel;
|
|
20
|
+
customLogger: {
|
|
21
|
+
warn: (msg: string, options?: any) => void;
|
|
22
|
+
info(msg: string, options?: vite1.LogOptions): void;
|
|
23
|
+
warnOnce(msg: string, options?: vite1.LogOptions): void;
|
|
24
|
+
error(msg: string, options?: vite1.LogErrorOptions): void;
|
|
25
|
+
clearScreen(type: vite1.LogType): void;
|
|
26
|
+
hasErrorLogged(error: Error | rolldown0.RollupError): boolean;
|
|
27
|
+
hasWarned: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
frameworkPlugins: any[];
|
|
31
|
+
stylePlugins: (vite1.Plugin<any> | vite1.Plugin<any>[])[];
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { createConfig };
|
|
35
|
+
//# sourceMappingURL=create-config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-config.d.mts","names":[],"sources":["../../../src/server/vite/create-config.ts"],"sourcesContent":[],"mappings":";;;;;;;iBAkBgB,YAAA,CAAA;;;;;MAAA,WAAY,EAAA,SAAA;MAAA,OAAA,EAAA;kBAAA,QAAA,CAAA,MAAA;MA8EA,CAAA;IAAY,CAAA;;cAAZ;;;kCAAY,KAAA,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LogLevel as LogLevel$1 } from "../../shared/types/log.mjs";
|
|
2
|
+
import { getUserProjectDir } from "../project/user-project-dir.mjs";
|
|
3
|
+
import { SERVER_WATCH_IGNORE } from "../constants.mjs";
|
|
4
|
+
import { getLogLevel, logPrefix } from "../utils/log.mjs";
|
|
5
|
+
import "../utils/index.mjs";
|
|
6
|
+
import { compileState } from "../runtime-state.mjs";
|
|
7
|
+
import { htmlLoader } from "./plugins/html-loader.mjs";
|
|
8
|
+
import { createLogger } from "vite";
|
|
9
|
+
import vuePlugin from "@vitejs/plugin-vue";
|
|
10
|
+
import vueJsxPlugin from "@vitejs/plugin-vue-jsx";
|
|
11
|
+
import vueSvgPlugin from "vite-svg-loader";
|
|
12
|
+
import reactSvgPlugin from "vite-plugin-svgr";
|
|
13
|
+
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
|
14
|
+
import tailwindcssPlugin from "@tailwindcss/vite";
|
|
15
|
+
import wywPlugin from "@wyw-in-js/vite";
|
|
16
|
+
import autoprefixer from "autoprefixer";
|
|
17
|
+
|
|
18
|
+
//#region src/server/vite/create-config.ts
|
|
19
|
+
function createConfig() {
|
|
20
|
+
const { framework } = compileState.getConfig();
|
|
21
|
+
const frameworkPlugins = [];
|
|
22
|
+
const stylePlugins = [
|
|
23
|
+
vanillaExtractPlugin(),
|
|
24
|
+
tailwindcssPlugin(),
|
|
25
|
+
wywPlugin({ exclude: SERVER_WATCH_IGNORE })
|
|
26
|
+
];
|
|
27
|
+
if (framework === "html") frameworkPlugins.push(htmlLoader());
|
|
28
|
+
if (framework === "react") frameworkPlugins.push(reactSvgPlugin({ include: "**/*.svg" }));
|
|
29
|
+
if (framework === "vue") frameworkPlugins.push(vuePlugin({ template: { transformAssetUrls: { img: [] } } }), vueJsxPlugin(), vueSvgPlugin({ svgo: false }));
|
|
30
|
+
const viteLogLevel = getLogLevel() == LogLevel$1.DEBUG ? "info" : "silent";
|
|
31
|
+
const baseViteLogger = createLogger("info", { prefix: logPrefix });
|
|
32
|
+
const viteLogger = {
|
|
33
|
+
...baseViteLogger,
|
|
34
|
+
warn: (msg, options) => {
|
|
35
|
+
if (typeof msg === "string" && msg.includes("dynamic import cannot be analyzed") && msg.includes("fetchEnginePath")) return;
|
|
36
|
+
baseViteLogger.warn(msg, options);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
baseViteConfig: {
|
|
41
|
+
root: getUserProjectDir(),
|
|
42
|
+
base: "/",
|
|
43
|
+
css: {
|
|
44
|
+
transformer: "postcss",
|
|
45
|
+
postcss: { plugins: [autoprefixer({ overrideBrowserslist: [
|
|
46
|
+
"chrome >= 120",
|
|
47
|
+
"edge >= 120",
|
|
48
|
+
"firefox >= 115",
|
|
49
|
+
"safari >= 16.4",
|
|
50
|
+
"ios_saf >= 16.4"
|
|
51
|
+
] })] }
|
|
52
|
+
},
|
|
53
|
+
appType: "custom",
|
|
54
|
+
logLevel: viteLogLevel,
|
|
55
|
+
customLogger: viteLogger
|
|
56
|
+
},
|
|
57
|
+
frameworkPlugins,
|
|
58
|
+
stylePlugins
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { createConfig };
|
|
64
|
+
//# sourceMappingURL=create-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-config.mjs","names":["LogLevel"],"sources":["../../../src/server/vite/create-config.ts"],"sourcesContent":["import { createLogger, type LogLevel as ViteLogLevel } from 'vite'\n\nimport vuePlugin from '@vitejs/plugin-vue'\nimport vueJsxPlugin from '@vitejs/plugin-vue-jsx'\nimport vueSvgPlugin from 'vite-svg-loader'\nimport reactSvgPlugin from 'vite-plugin-svgr'\nimport { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'\nimport tailwindcssPlugin from '@tailwindcss/vite'\nimport wywPlugin from '@wyw-in-js/vite'\nimport autoprefixer from 'autoprefixer'\n\nimport { LogLevel } from '../../shared/types'\nimport { getLogLevel, logPrefix } from '../utils'\nimport { getUserProjectDir } from '../project/user-project-dir'\nimport { htmlLoader } from './plugins/html-loader'\nimport { SERVER_WATCH_IGNORE } from '../constants'\nimport { compileState } from '../runtime-state'\n\nexport function createConfig() {\n\tconst config = compileState.getConfig()\n\tconst { framework } = config\n\n\tconst frameworkPlugins = []\n\tconst stylePlugins = [\n\t\tvanillaExtractPlugin(),\n\t\ttailwindcssPlugin(),\n\t\twywPlugin({\n\t\t\texclude: SERVER_WATCH_IGNORE\n\t\t})\n\t]\n\n\tif (framework === 'html') {\n\t\tframeworkPlugins.push(htmlLoader())\n\t}\n\n\tif (framework === 'react') {\n\t\tframeworkPlugins.push(reactSvgPlugin({ include: '**/*.svg' }))\n\t}\n\n\tif (framework === 'vue') {\n\t\tframeworkPlugins.push(\n\t\t\tvuePlugin({\n\t\t\t\ttemplate: {\n\t\t\t\t\ttransformAssetUrls: {\n\t\t\t\t\t\timg: [] // Stops the vue plugin from automatically converting images to modules\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t\tvueJsxPlugin(),\n\t\t\tvueSvgPlugin({ svgo: false }) as any\n\t\t)\n\t}\n\n\t// Only show vite logs when FORMAT_LOG_LEVEL=3 (debug) or FORMAT_DEBUG is true\n\tconst viteLogLevel = getLogLevel() == LogLevel.DEBUG ? 'info' : 'silent'\n\tconst baseViteLogger = createLogger('info', { prefix: logPrefix })\n\tconst viteLogger = {\n\t\t...baseViteLogger,\n\t\twarn: (msg: string, options?: any) => {\n\t\t\t// Suppress dynamic import warnings for fetchEnginePath, as Bun always strips comments! So can't use /* vite-ignore */\n\t\t\t// This is a bit brittle, as it depends on the function name in the source code (client.ts). Oh well!\n\t\t\tif (\n\t\t\t\ttypeof msg === 'string' &&\n\t\t\t\tmsg.includes('dynamic import cannot be analyzed') &&\n\t\t\t\tmsg.includes('fetchEnginePath')\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tbaseViteLogger.warn(msg, options)\n\t\t}\n\t}\n\n\tconst baseViteConfig = {\n\t\troot: getUserProjectDir(),\n\t\tbase: '/',\n\t\tcss: {\n\t\t\ttransformer: 'postcss' as const,\n\t\t\tpostcss: {\n\t\t\t\tplugins: [\n\t\t\t\t\t// Pinned floors, not a rolling query: output stays identical whatever\n\t\t\t\t\t// caniuse-lite age a consumer's install carries. Format's renderer is\n\t\t\t\t\t// far above these; the floors serve preview and embed viewers.\n\t\t\t\t\tautoprefixer({\n\t\t\t\t\t\toverrideBrowserslist: [\n\t\t\t\t\t\t\t'chrome >= 120',\n\t\t\t\t\t\t\t'edge >= 120',\n\t\t\t\t\t\t\t'firefox >= 115',\n\t\t\t\t\t\t\t'safari >= 16.4',\n\t\t\t\t\t\t\t'ios_saf >= 16.4'\n\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t}\n\t\t},\n\t\tappType: 'custom' as const,\n\t\tlogLevel: viteLogLevel as ViteLogLevel,\n\t\tcustomLogger: viteLogger\n\t}\n\n\treturn { baseViteConfig, frameworkPlugins, stylePlugins }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAgB,eAAe;CAE9B,MAAM,EAAE,cADO,aAAa,WAAW;CAGvC,MAAM,mBAAmB,EAAE;CAC3B,MAAM,eAAe;EACpB,sBAAsB;EACtB,mBAAmB;EACnB,UAAU,EACT,SAAS,qBACT,CAAC;EACF;AAED,KAAI,cAAc,OACjB,kBAAiB,KAAK,YAAY,CAAC;AAGpC,KAAI,cAAc,QACjB,kBAAiB,KAAK,eAAe,EAAE,SAAS,YAAY,CAAC,CAAC;AAG/D,KAAI,cAAc,MACjB,kBAAiB,KAChB,UAAU,EACT,UAAU,EACT,oBAAoB,EACnB,KAAK,EAAE,EACP,EACD,EACD,CAAC,EACF,cAAc,EACd,aAAa,EAAE,MAAM,OAAO,CAAC,CAC7B;CAIF,MAAM,eAAe,aAAa,IAAIA,WAAS,QAAQ,SAAS;CAChE,MAAM,iBAAiB,aAAa,QAAQ,EAAE,QAAQ,WAAW,CAAC;CAClE,MAAM,aAAa;EAClB,GAAG;EACH,OAAO,KAAa,YAAkB;AAGrC,OACC,OAAO,QAAQ,YACf,IAAI,SAAS,oCAAoC,IACjD,IAAI,SAAS,kBAAkB,CAE/B;AAGD,kBAAe,KAAK,KAAK,QAAQ;;EAElC;AA6BD,QAAO;EAAE,gBA3Bc;GACtB,MAAM,mBAAmB;GACzB,MAAM;GACN,KAAK;IACJ,aAAa;IACb,SAAS,EACR,SAAS,CAIR,aAAa,EACZ,sBAAsB;KACrB;KACA;KACA;KACA;KACA;KACA,EACD,CAAC,CACF,EACD;IACD;GACD,SAAS;GACT,UAAU;GACV,cAAc;GACd;EAEwB;EAAkB;EAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect-css.d.mts","names":[],"sources":["../../../../src/server/vite/plugins/collect-css.ts"],"sourcesContent":[],"mappings":";iBAMgB,gBAAA,CAAA;EAAA,IAAA,EAAA,MAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { compileState } from "../../runtime-state.mjs";
|
|
2
|
+
import { getStyleIdInfo } from "./utils.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/server/vite/plugins/collect-css.ts
|
|
5
|
+
function collectCssPlugin() {
|
|
6
|
+
return {
|
|
7
|
+
name: "collect-css",
|
|
8
|
+
transform(code, id) {
|
|
9
|
+
const { isCssFile, isVueStyleRequest } = getStyleIdInfo(id, [
|
|
10
|
+
".css",
|
|
11
|
+
".scss",
|
|
12
|
+
".sass"
|
|
13
|
+
]);
|
|
14
|
+
if (isCssFile || isVueStyleRequest) compileState.getCss().set(id, code);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { collectCssPlugin };
|
|
21
|
+
//# sourceMappingURL=collect-css.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect-css.mjs","names":[],"sources":["../../../../src/server/vite/plugins/collect-css.ts"],"sourcesContent":["import { compileState } from '../../runtime-state'\nimport { getStyleIdInfo } from './utils'\n\n// Keep each style module's CSS from its latest transform. A render reads the\n// entries its document imports, because Vite skips the transform for modules\n// it has already loaded.\nexport function collectCssPlugin() {\n\treturn {\n\t\tname: 'collect-css',\n\t\ttransform(code: string, id: string) {\n\t\t\tconst { isCssFile, isVueStyleRequest } = getStyleIdInfo(id, ['.css', '.scss', '.sass'])\n\n\t\t\tif (isCssFile || isVueStyleRequest) {\n\t\t\t\tcompileState.getCss().set(id, code)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAMA,SAAgB,mBAAmB;AAClC,QAAO;EACN,MAAM;EACN,UAAU,MAAc,IAAY;GACnC,MAAM,EAAE,WAAW,sBAAsB,eAAe,IAAI;IAAC;IAAQ;IAAS;IAAQ,CAAC;AAEvF,OAAI,aAAa,kBAChB,cAAa,QAAQ,CAAC,IAAI,IAAI,KAAK;;EAGrC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OutputBundle } from "rolldown";
|
|
2
|
+
|
|
3
|
+
//#region src/server/vite/plugins/get-styles.d.ts
|
|
4
|
+
declare function getStyles(): {
|
|
5
|
+
name: string;
|
|
6
|
+
apply: string;
|
|
7
|
+
enforce: string;
|
|
8
|
+
generateBundle(_outputOptions: {
|
|
9
|
+
format?: string;
|
|
10
|
+
}, bundle: OutputBundle): void;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getStyles };
|
|
14
|
+
//# sourceMappingURL=get-styles.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-styles.d.mts","names":[],"sources":["../../../../src/server/vite/plugins/get-styles.ts"],"sourcesContent":[],"mappings":";;;iBA8EgB,SAAA,CAAA;;EAAA,KAAA,EAAA,MAAS;;;;aAQqC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ENTRY_CSS_FILES_REPLACEMENT, STYLES_BY_FILE_REPLACEMENT } from "../../compile/constants.mjs";
|
|
2
|
+
import { logger } from "../../utils/log.mjs";
|
|
3
|
+
import "../../utils/index.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/server/vite/plugins/get-styles.ts
|
|
6
|
+
function escapeRegExp(value) {
|
|
7
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8
|
+
}
|
|
9
|
+
function replacePlaceholder(code, placeholder, replacement) {
|
|
10
|
+
const literalRe = new RegExp("(['\"`])" + escapeRegExp(placeholder) + "\\1", "g");
|
|
11
|
+
return code.replace(literalRe, replacement);
|
|
12
|
+
}
|
|
13
|
+
function isAsset(item) {
|
|
14
|
+
return item.type === "asset";
|
|
15
|
+
}
|
|
16
|
+
function isChunk(item) {
|
|
17
|
+
return item.type === "chunk";
|
|
18
|
+
}
|
|
19
|
+
function collectCssForEntry(args) {
|
|
20
|
+
const { entry, chunksByFileName, stylesByFile } = args;
|
|
21
|
+
const orderedCss = [];
|
|
22
|
+
const seenCss = /* @__PURE__ */ new Set();
|
|
23
|
+
const seenChunks = /* @__PURE__ */ new Set();
|
|
24
|
+
const stack = [entry.fileName];
|
|
25
|
+
while (stack.length) {
|
|
26
|
+
const fileName = stack.pop();
|
|
27
|
+
if (seenChunks.has(fileName)) continue;
|
|
28
|
+
seenChunks.add(fileName);
|
|
29
|
+
const chunk = chunksByFileName.get(fileName);
|
|
30
|
+
if (!chunk) continue;
|
|
31
|
+
const importedCss = chunk?.viteMetadata?.importedCss;
|
|
32
|
+
if (importedCss) for (const cssFile of importedCss) {
|
|
33
|
+
if (!stylesByFile.has(cssFile)) continue;
|
|
34
|
+
if (seenCss.has(cssFile)) continue;
|
|
35
|
+
seenCss.add(cssFile);
|
|
36
|
+
orderedCss.push(cssFile);
|
|
37
|
+
}
|
|
38
|
+
for (const next of [...chunk.imports, ...chunk.dynamicImports]) stack.push(next);
|
|
39
|
+
}
|
|
40
|
+
if (orderedCss.length === 0) return [...stylesByFile.keys()];
|
|
41
|
+
return orderedCss;
|
|
42
|
+
}
|
|
43
|
+
function getStyles() {
|
|
44
|
+
const stylesByFile = /* @__PURE__ */ new Map();
|
|
45
|
+
return {
|
|
46
|
+
name: "get-styles",
|
|
47
|
+
apply: "build",
|
|
48
|
+
enforce: "post",
|
|
49
|
+
generateBundle(_outputOptions, bundle) {
|
|
50
|
+
stylesByFile.clear();
|
|
51
|
+
const entryCssFiles = /* @__PURE__ */ new Map();
|
|
52
|
+
for (const [fileName, item] of Object.entries(bundle)) if (isAsset(item) && fileName.endsWith(".css")) {
|
|
53
|
+
const cleanedSource = String(item.source ?? "").replace(/\/\*\$vite\$\:\d+\*\/\s*$/, "");
|
|
54
|
+
stylesByFile.set(fileName, cleanedSource);
|
|
55
|
+
}
|
|
56
|
+
const chunksByFileName = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const [fileName, item] of Object.entries(bundle)) if (isChunk(item)) chunksByFileName.set(fileName, item);
|
|
58
|
+
for (const item of Object.values(bundle)) if (isChunk(item) && item.isEntry) {
|
|
59
|
+
const cssFiles = collectCssForEntry({
|
|
60
|
+
entry: item,
|
|
61
|
+
chunksByFileName,
|
|
62
|
+
stylesByFile
|
|
63
|
+
});
|
|
64
|
+
entryCssFiles.set(item.name, cssFiles);
|
|
65
|
+
}
|
|
66
|
+
const stylesByFileObj = {};
|
|
67
|
+
const entryCssFilesObj = {};
|
|
68
|
+
for (const [fileName, styles] of stylesByFile) stylesByFileObj[fileName] = styles;
|
|
69
|
+
for (const [entryName, files] of entryCssFiles) entryCssFilesObj[entryName] = files;
|
|
70
|
+
const stylesByFileReplacement = JSON.stringify(stylesByFileObj);
|
|
71
|
+
const entryCssFilesReplacement = JSON.stringify(entryCssFilesObj);
|
|
72
|
+
for (const item of Object.values(bundle)) {
|
|
73
|
+
if (!isChunk(item) || typeof item.code !== "string") continue;
|
|
74
|
+
if (item.code.includes(STYLES_BY_FILE_REPLACEMENT)) item.code = replacePlaceholder(item.code, STYLES_BY_FILE_REPLACEMENT, stylesByFileReplacement);
|
|
75
|
+
if (item.code.includes(ENTRY_CSS_FILES_REPLACEMENT)) item.code = replacePlaceholder(item.code, ENTRY_CSS_FILES_REPLACEMENT, entryCssFilesReplacement);
|
|
76
|
+
}
|
|
77
|
+
logger.debug("Collected CSS assets", {
|
|
78
|
+
cssFiles: stylesByFile.size,
|
|
79
|
+
entries: entryCssFiles.size
|
|
80
|
+
});
|
|
81
|
+
for (const fileName of stylesByFile.keys()) delete bundle[fileName];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { getStyles };
|
|
88
|
+
//# sourceMappingURL=get-styles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-styles.mjs","names":["orderedCss: string[]","stylesByFileObj: Record<string, string>","entryCssFilesObj: Record<string, string[]>"],"sources":["../../../../src/server/vite/plugins/get-styles.ts"],"sourcesContent":["import type { OutputBundle, OutputChunk, OutputAsset } from 'rolldown'\nimport { ENTRY_CSS_FILES_REPLACEMENT, STYLES_BY_FILE_REPLACEMENT } from '../../compile/constants'\nimport { logger } from '../../utils'\n\nfunction escapeRegExp(value: string) {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\nfunction replacePlaceholder(code: string, placeholder: string, replacement: string) {\n\tconst literalRe = new RegExp('([\\'\"`])' + escapeRegExp(placeholder) + '\\\\1', 'g')\n\treturn code.replace(literalRe, replacement)\n}\n\nfunction isAsset(item: any): item is OutputAsset {\n\treturn item.type === 'asset'\n}\n\nfunction isChunk(item: any): item is OutputChunk {\n\treturn item.type === 'chunk'\n}\n\nfunction collectCssForEntry(args: {\n\tentry: OutputChunk\n\tchunksByFileName: Map<string, OutputChunk>\n\tstylesByFile: Map<string, string>\n}): string[] {\n\t// Walk the entry's chunk graph to include shared CSS from imported chunks.\n\tconst { entry, chunksByFileName, stylesByFile } = args\n\tconst orderedCss: string[] = []\n\tconst seenCss = new Set<string>()\n\tconst seenChunks = new Set<string>()\n\tconst stack = [entry.fileName]\n\n\twhile (stack.length) {\n\t\tconst fileName = stack.pop()!\n\t\tif (seenChunks.has(fileName)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tseenChunks.add(fileName)\n\n\t\tconst chunk = chunksByFileName.get(fileName)\n\t\tif (!chunk) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst importedCss = (chunk as any)?.viteMetadata?.importedCss as Set<string> | undefined\n\t\tif (importedCss) {\n\t\t\tfor (const cssFile of importedCss) {\n\t\t\t\t// Only include CSS we captured from the bundle output.\n\t\t\t\tif (!stylesByFile.has(cssFile)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (seenCss.has(cssFile)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tseenCss.add(cssFile)\n\t\t\t\torderedCss.push(cssFile)\n\t\t\t}\n\t\t}\n\n\t\tfor (const next of [...chunk.imports, ...chunk.dynamicImports]) {\n\t\t\tstack.push(next)\n\t\t}\n\t}\n\n\tif (orderedCss.length === 0) {\n\t\t// Fallback to all CSS when Vite doesn't report importedCss.\n\t\treturn [...stylesByFile.keys()]\n\t}\n\n\treturn orderedCss\n}\n\n/*\nPost-build, gather CSS assets and fill virtual styles placeholders.\n*/\n\nexport function getStyles() {\n\tconst stylesByFile = new Map<string, string>()\n\n\treturn {\n\t\tname: 'get-styles',\n\t\tapply: 'build',\n\t\tenforce: 'post',\n\n\t\tgenerateBundle(_outputOptions: { format?: string }, bundle: OutputBundle) {\n\t\t\tstylesByFile.clear()\n\t\t\tconst entryCssFiles = new Map<string, string[]>()\n\n\t\t\tfor (const [fileName, item] of Object.entries(bundle)) {\n\t\t\t\t// Should just be the generated style.css file from rollup\n\t\t\t\tconst isCssFile = isAsset(item) && fileName.endsWith('.css')\n\n\t\t\t\tif (isCssFile) {\n\t\t\t\t\tconst cleanedSource = String(item.source ?? '').replace(\n\t\t\t\t\t\t/\\/\\*\\$vite\\$\\:\\d+\\*\\/\\s*$/, // Targets the vite comment marker at the end of the file\n\t\t\t\t\t\t''\n\t\t\t\t\t)\n\n\t\t\t\t\tstylesByFile.set(fileName, cleanedSource)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst chunksByFileName = new Map<string, OutputChunk>()\n\n\t\t\tfor (const [fileName, item] of Object.entries(bundle)) {\n\t\t\t\tif (isChunk(item)) {\n\t\t\t\t\t// Map for fast graph traversal.\n\t\t\t\t\tchunksByFileName.set(fileName, item)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const item of Object.values(bundle)) {\n\t\t\t\tif (isChunk(item) && item.isEntry) {\n\t\t\t\t\tconst cssFiles = collectCssForEntry({ entry: item, chunksByFileName, stylesByFile })\n\t\t\t\t\tentryCssFiles.set(item.name, cssFiles)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst stylesByFileObj: Record<string, string> = {}\n\t\t\tconst entryCssFilesObj: Record<string, string[]> = {}\n\n\t\t\tfor (const [fileName, styles] of stylesByFile) {\n\t\t\t\tstylesByFileObj[fileName] = styles\n\t\t\t}\n\n\t\t\tfor (const [entryName, files] of entryCssFiles) {\n\t\t\t\tentryCssFilesObj[entryName] = files\n\t\t\t}\n\n\t\t\tconst stylesByFileReplacement = JSON.stringify(stylesByFileObj)\n\t\t\tconst entryCssFilesReplacement = JSON.stringify(entryCssFilesObj)\n\n\t\t\tfor (const item of Object.values(bundle)) {\n\t\t\t\tif (!isChunk(item) || typeof item.code !== 'string') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// Replace placeholders in the virtual:styles module chunk.\n\n\t\t\t\tif (item.code.includes(STYLES_BY_FILE_REPLACEMENT)) {\n\t\t\t\t\titem.code = replacePlaceholder(item.code, STYLES_BY_FILE_REPLACEMENT, stylesByFileReplacement)\n\t\t\t\t}\n\n\t\t\t\tif (item.code.includes(ENTRY_CSS_FILES_REPLACEMENT)) {\n\t\t\t\t\titem.code = replacePlaceholder(item.code, ENTRY_CSS_FILES_REPLACEMENT, entryCssFilesReplacement)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug('Collected CSS assets', {\n\t\t\t\tcssFiles: stylesByFile.size,\n\t\t\t\tentries: entryCssFiles.size\n\t\t\t})\n\n\t\t\tfor (const fileName of stylesByFile.keys()) {\n\t\t\t\tdelete bundle[fileName]\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAIA,SAAS,aAAa,OAAe;AACpC,QAAO,MAAM,QAAQ,uBAAuB,OAAO;;AAGpD,SAAS,mBAAmB,MAAc,aAAqB,aAAqB;CACnF,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
|
|
3
|
+
//#region src/server/vite/plugins/html-loader.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Emit the JS module for an .html import. A template with no `include()` stays
|
|
7
|
+
* a plain string export. A template with includes imports each included file
|
|
8
|
+
* (so partials are bundled, watched, and HMR-tracked like any module) and
|
|
9
|
+
* exports `{ template, partials }`, with partial keys resolved relative to
|
|
10
|
+
* this file — the shape `adaptors/html-partials.ts` resolves against at render
|
|
11
|
+
* time. The key-joining helpers are inlined because this code runs inside the
|
|
12
|
+
* user's bundle, where studio modules can't be imported.
|
|
13
|
+
*/
|
|
14
|
+
declare function buildHtmlModule(template: string): string;
|
|
15
|
+
declare function htmlLoader(): Plugin;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { buildHtmlModule, htmlLoader };
|
|
18
|
+
//# sourceMappingURL=html-loader.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-loader.d.mts","names":[],"sources":["../../../../src/server/vite/plugins/html-loader.ts"],"sourcesContent":[],"mappings":";;;;;;AA4BA;AA8CA;;;;;;iBA9CgB,eAAA;iBA8CA,UAAA,CAAA,GAAc"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { findIncludeSpecifiers, normalizePartialPath } from "../../compile/adaptors/html-partials.mjs";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region src/server/vite/plugins/html-loader.ts
|
|
5
|
+
function splitId(id) {
|
|
6
|
+
const [cleanId, query = ""] = id.split("?", 2);
|
|
7
|
+
return {
|
|
8
|
+
cleanId,
|
|
9
|
+
query
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function hasQueryParam(query, key) {
|
|
13
|
+
if (!query) return false;
|
|
14
|
+
return query.split("&").some((param) => {
|
|
15
|
+
const [name] = param.split("=", 1);
|
|
16
|
+
return name === key;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Emit the JS module for an .html import. A template with no `include()` stays
|
|
21
|
+
* a plain string export. A template with includes imports each included file
|
|
22
|
+
* (so partials are bundled, watched, and HMR-tracked like any module) and
|
|
23
|
+
* exports `{ template, partials }`, with partial keys resolved relative to
|
|
24
|
+
* this file — the shape `adaptors/html-partials.ts` resolves against at render
|
|
25
|
+
* time. The key-joining helpers are inlined because this code runs inside the
|
|
26
|
+
* user's bundle, where studio modules can't be imported.
|
|
27
|
+
*/
|
|
28
|
+
function buildHtmlModule(template) {
|
|
29
|
+
const specifiers = findIncludeSpecifiers(template);
|
|
30
|
+
if (specifiers.length === 0) return `export default ${JSON.stringify(template)};`;
|
|
31
|
+
return `${specifiers.map((specifier, index) => `import __partial${index} from ${JSON.stringify(specifier)};`).join("\n")}
|
|
32
|
+
const __partials = {};
|
|
33
|
+
const __normalize = (path) => {
|
|
34
|
+
const segments = [];
|
|
35
|
+
for (const segment of path.split('/')) {
|
|
36
|
+
if (!segment || segment === '.') continue;
|
|
37
|
+
if (segment === '..' && segments.length > 0 && segments[segments.length - 1] !== '..') {
|
|
38
|
+
segments.pop();
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
segments.push(segment);
|
|
42
|
+
}
|
|
43
|
+
return segments.join('/');
|
|
44
|
+
};
|
|
45
|
+
const __addPartial = (key, child) => {
|
|
46
|
+
if (typeof child === 'string') {
|
|
47
|
+
__partials[key] = child;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
__partials[key] = child.template;
|
|
51
|
+
const baseDir = key.split('/').slice(0, -1).join('/');
|
|
52
|
+
for (const childKey of Object.keys(child.partials || {})) {
|
|
53
|
+
__partials[__normalize(baseDir ? baseDir + '/' + childKey : childKey)] = child.partials[childKey];
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
${specifiers.map((specifier, index) => `__addPartial(${JSON.stringify(normalizePartialPath(specifier))}, __partial${index});`).join("\n")}
|
|
57
|
+
export default { template: ${JSON.stringify(template)}, partials: __partials };`;
|
|
58
|
+
}
|
|
59
|
+
const HTML_PROXY_RE = /\.html\?html-proxy\b/i;
|
|
60
|
+
function htmlLoader() {
|
|
61
|
+
return {
|
|
62
|
+
name: "format-html-loader",
|
|
63
|
+
enforce: "pre",
|
|
64
|
+
async resolveId(source, importer) {
|
|
65
|
+
if (HTML_PROXY_RE.test(source)) return source;
|
|
66
|
+
const { cleanId, query } = splitId(source);
|
|
67
|
+
if (cleanId.endsWith(".html") && !hasQueryParam(query, "raw")) {
|
|
68
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
69
|
+
if (resolved) {
|
|
70
|
+
const resolvedParts = splitId(resolved.id);
|
|
71
|
+
const rawQuery = [resolvedParts.query, "raw"].filter(Boolean).join("&");
|
|
72
|
+
return `${resolvedParts.cleanId}?${rawQuery}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
},
|
|
77
|
+
async load(id) {
|
|
78
|
+
if (HTML_PROXY_RE.test(id)) return "export default \"\";";
|
|
79
|
+
const { cleanId, query } = splitId(id);
|
|
80
|
+
if (cleanId.endsWith(".html") && hasQueryParam(query, "raw")) return buildHtmlModule(readFileSync(cleanId, "utf8"));
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { buildHtmlModule, htmlLoader };
|
|
88
|
+
//# sourceMappingURL=html-loader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-loader.mjs","names":[],"sources":["../../../../src/server/vite/plugins/html-loader.ts"],"sourcesContent":["import type { Plugin } from 'vite'\n\nimport { readFileSync } from 'node:fs'\nimport { findIncludeSpecifiers, normalizePartialPath } from '../../compile/adaptors/html-partials'\n\nfunction splitId(id: string) {\n\tconst [cleanId, query = ''] = id.split('?', 2)\n\treturn { cleanId, query }\n}\n\nfunction hasQueryParam(query: string, key: string) {\n\tif (!query) return false\n\n\treturn query.split('&').some(param => {\n\t\tconst [name] = param.split('=', 1)\n\t\treturn name === key\n\t})\n}\n\n/**\n * Emit the JS module for an .html import. A template with no `include()` stays\n * a plain string export. A template with includes imports each included file\n * (so partials are bundled, watched, and HMR-tracked like any module) and\n * exports `{ template, partials }`, with partial keys resolved relative to\n * this file — the shape `adaptors/html-partials.ts` resolves against at render\n * time. The key-joining helpers are inlined because this code runs inside the\n * user's bundle, where studio modules can't be imported.\n */\nexport function buildHtmlModule(template: string): string {\n\tconst specifiers = findIncludeSpecifiers(template)\n\n\tif (specifiers.length === 0) {\n\t\treturn `export default ${JSON.stringify(template)};`\n\t}\n\n\tconst imports = specifiers\n\t\t.map((specifier, index) => `import __partial${index} from ${JSON.stringify(specifier)};`)\n\t\t.join('\\n')\n\n\tconst registrations = specifiers\n\t\t.map((specifier, index) => `__addPartial(${JSON.stringify(normalizePartialPath(specifier))}, __partial${index});`)\n\t\t.join('\\n')\n\n\treturn `${imports}\nconst __partials = {};\nconst __normalize = (path) => {\n\tconst segments = [];\n\tfor (const segment of path.split('/')) {\n\t\tif (!segment || segment === '.') continue;\n\t\tif (segment === '..' && segments.length > 0 && segments[segments.length - 1] !== '..') {\n\t\t\tsegments.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tsegments.push(segment);\n\t}\n\treturn segments.join('/');\n};\nconst __addPartial = (key, child) => {\n\tif (typeof child === 'string') {\n\t\t__partials[key] = child;\n\t\treturn;\n\t}\n\t__partials[key] = child.template;\n\tconst baseDir = key.split('/').slice(0, -1).join('/');\n\tfor (const childKey of Object.keys(child.partials || {})) {\n\t\t__partials[__normalize(baseDir ? baseDir + '/' + childKey : childKey)] = child.partials[childKey];\n\t}\n};\n${registrations}\nexport default { template: ${JSON.stringify(template)}, partials: __partials };`\n}\n\nconst HTML_PROXY_RE = /\\.html\\?html-proxy\\b/i\n\nexport function htmlLoader(): Plugin {\n\treturn {\n\t\tname: 'format-html-loader',\n\t\tenforce: 'pre',\n\n\t\tasync resolveId(source, importer) {\n\t\t\t// Swallow Vite's internal HTML proxy ids for actual HTML files.\n\t\t\tif (HTML_PROXY_RE.test(source)) {\n\t\t\t\treturn source\n\t\t\t}\n\n\t\t\tconst { cleanId, query } = splitId(source)\n\n\t\t\t// Treat .html imports as raw string modules\n\t\t\tif (cleanId.endsWith('.html') && !hasQueryParam(query, 'raw')) {\n\t\t\t\tconst resolved = await this.resolve(source, importer, { skipSelf: true })\n\n\t\t\t\tif (resolved) {\n\t\t\t\t\tconst resolvedParts = splitId(resolved.id)\n\t\t\t\t\tconst rawQuery = [resolvedParts.query, 'raw'].filter(Boolean).join('&')\n\t\t\t\t\treturn `${resolvedParts.cleanId}?${rawQuery}`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\n\t\tasync load(id: string) {\n\t\t\t// Stub any .html?html-proxy requests so HTML files don't execute inline modules.\n\t\t\tif (HTML_PROXY_RE.test(id)) {\n\t\t\t\treturn 'export default \"\";'\n\t\t\t}\n\n\t\t\tconst { cleanId, query } = splitId(id)\n\t\t\tconst isRawHtmlRequest = cleanId.endsWith('.html') && hasQueryParam(query, 'raw')\n\n\t\t\t// Load the actual HTML as a JS string module\n\t\t\tif (isRawHtmlRequest) {\n\t\t\t\tconst code = readFileSync(cleanId, 'utf8')\n\t\t\t\treturn buildHtmlModule(code)\n\t\t\t}\n\n\t\t\treturn null\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAKA,SAAS,QAAQ,IAAY;CAC5B,MAAM,CAAC,SAAS,QAAQ,MAAM,GAAG,MAAM,KAAK,EAAE;AAC9C,QAAO;EAAE;EAAS;EAAO;;AAG1B,SAAS,cAAc,OAAe,KAAa;AAClD,KAAI,CAAC,MAAO,QAAO;AAEnB,QAAO,MAAM,MAAM,IAAI,CAAC,MAAK,UAAS;EACrC,MAAM,CAAC,QAAQ,MAAM,MAAM,KAAK,EAAE;AAClC,SAAO,SAAS;GACf;;;;;;;;;;;AAYH,SAAgB,gBAAgB,UAA0B;CACzD,M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
+
//#region src/server/vite/plugins/postcss/import-url.d.ts
|
|
4
|
+
|
|
5
|
+
interface ImportUrlOptions {
|
|
6
|
+
recursive?: boolean;
|
|
7
|
+
resolveUrls?: boolean;
|
|
8
|
+
userAgent?: string | null;
|
|
9
|
+
dataUrls?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function postcssImportUrl(options?: ImportUrlOptions): Plugin;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ImportUrlOptions, postcssImportUrl };
|
|
14
|
+
//# sourceMappingURL=import-url.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-url.d.mts","names":[],"sources":["../../../../../src/server/vite/plugins/postcss/import-url.ts"],"sourcesContent":[],"mappings":";;;;AA0DgB,UA9CC,gBAAA,CA8Ce;;;;;;iBAAhB,gBAAA,WAA2B,mBAAmB"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { CompileError } from "../../../errors.mjs";
|
|
2
|
+
import { http } from "../../../../shared/http.mjs";
|
|
3
|
+
import postcss from "postcss";
|
|
4
|
+
|
|
5
|
+
//#region src/server/vite/plugins/postcss/import-url.ts
|
|
6
|
+
/**
|
|
7
|
+
* A postcss plugin that inlines remote css imports.
|
|
8
|
+
*/
|
|
9
|
+
const { list: postcssList } = postcss;
|
|
10
|
+
const DEFAULT_OPTIONS = {
|
|
11
|
+
recursive: true,
|
|
12
|
+
resolveUrls: false,
|
|
13
|
+
userAgent: null,
|
|
14
|
+
dataUrls: false
|
|
15
|
+
};
|
|
16
|
+
const SPACE = postcssList.space;
|
|
17
|
+
const URL_FUNCTION_REGEX = /url\(["']?.+?['"]?\)/g;
|
|
18
|
+
const FETCH_CACHE = /* @__PURE__ */ new Map();
|
|
19
|
+
function postcssImportUrl(options) {
|
|
20
|
+
const resolvedOptions = {
|
|
21
|
+
...DEFAULT_OPTIONS,
|
|
22
|
+
...options ?? {}
|
|
23
|
+
};
|
|
24
|
+
async function inlineImports({ root, ctx, parentUrl }) {
|
|
25
|
+
const effectiveParentUrl = parentUrl || root.source?.input?.file;
|
|
26
|
+
const pendingImports = [];
|
|
27
|
+
root.walkAtRules("import", (atRule) => {
|
|
28
|
+
const importParams = SPACE(atRule.params);
|
|
29
|
+
let normalizedTarget = extractUrlFromImport(importParams[0]);
|
|
30
|
+
if (normalizedTarget.startsWith("//")) {
|
|
31
|
+
const httpsUrl = `https:${normalizedTarget}`;
|
|
32
|
+
atRule.warn(ctx.result, `Protocol-less @import '${normalizedTarget}' normalized to '${httpsUrl}'.`);
|
|
33
|
+
normalizedTarget = httpsUrl;
|
|
34
|
+
}
|
|
35
|
+
if (effectiveParentUrl) normalizedTarget = resolveRelative({
|
|
36
|
+
target: normalizedTarget,
|
|
37
|
+
baseUrl: effectiveParentUrl
|
|
38
|
+
});
|
|
39
|
+
if (!isHttpUrl(normalizedTarget)) return;
|
|
40
|
+
pendingImports.push(fetchCss({
|
|
41
|
+
absoluteUrl: normalizedTarget,
|
|
42
|
+
options: resolvedOptions,
|
|
43
|
+
ctx,
|
|
44
|
+
atRule
|
|
45
|
+
}).then(async (response) => {
|
|
46
|
+
let importedRoot = postcss.parse(response.body);
|
|
47
|
+
const hasLayerQualifier = importParams.some((p) => p.includes("layer"));
|
|
48
|
+
const hasSupportsQualifier = importParams.some((p) => p.includes("supports"));
|
|
49
|
+
const mediaStartIndex = hasLayerQualifier ? hasSupportsQualifier ? 3 : 2 : 1;
|
|
50
|
+
const mediaQuery = importParams.slice(mediaStartIndex).join(" ");
|
|
51
|
+
if (mediaQuery) {
|
|
52
|
+
const mediaWrapper = postcss.atRule({
|
|
53
|
+
name: "media",
|
|
54
|
+
params: mediaQuery,
|
|
55
|
+
source: atRule.source
|
|
56
|
+
});
|
|
57
|
+
mediaWrapper.append(importedRoot);
|
|
58
|
+
importedRoot = mediaWrapper;
|
|
59
|
+
} else importedRoot.source = atRule.source;
|
|
60
|
+
if (hasSupportsQualifier) {
|
|
61
|
+
const supportsToken = importParams.find((p) => p.includes("supports")) || "";
|
|
62
|
+
const open = supportsToken.indexOf("(");
|
|
63
|
+
const close = supportsToken.lastIndexOf(")");
|
|
64
|
+
const supportsQuery = open >= 0 && close > open ? supportsToken.slice(open + 1, close) : "";
|
|
65
|
+
const supportsWrapper = postcss.atRule({
|
|
66
|
+
name: "supports",
|
|
67
|
+
params: supportsQuery ? `(${supportsQuery})` : "",
|
|
68
|
+
source: atRule.source
|
|
69
|
+
});
|
|
70
|
+
supportsWrapper.append(importedRoot);
|
|
71
|
+
importedRoot = supportsWrapper;
|
|
72
|
+
} else importedRoot.source = atRule.source;
|
|
73
|
+
if (hasLayerQualifier) {
|
|
74
|
+
const layerToken = importParams.find((p) => p.includes("layer")) || "";
|
|
75
|
+
const open = layerToken.indexOf("(");
|
|
76
|
+
const close = layerToken.lastIndexOf(")");
|
|
77
|
+
const layerName = open >= 0 && close > open ? layerToken.slice(open + 1, close) : "";
|
|
78
|
+
const layerWrapper = postcss.atRule({
|
|
79
|
+
name: "layer",
|
|
80
|
+
params: layerName,
|
|
81
|
+
source: importedRoot.source
|
|
82
|
+
});
|
|
83
|
+
layerWrapper.append(importedRoot);
|
|
84
|
+
importedRoot = layerWrapper;
|
|
85
|
+
}
|
|
86
|
+
if (resolvedOptions.resolveUrls) importedRoot = importedRoot.replaceValues(URL_FUNCTION_REGEX, { fast: "url(" }, (val) => absolutizeUrlFunction({
|
|
87
|
+
cssUrlValue: val,
|
|
88
|
+
importedFromUrl: normalizedTarget
|
|
89
|
+
}));
|
|
90
|
+
if (resolvedOptions.recursive && "toResult" in importedRoot) await inlineImports({
|
|
91
|
+
root: importedRoot,
|
|
92
|
+
ctx,
|
|
93
|
+
parentUrl: response.parent
|
|
94
|
+
});
|
|
95
|
+
if (resolvedOptions.dataUrls) atRule.params = `url(data:text/css;base64,${Buffer.from(importedRoot.toString()).toString("base64")})`;
|
|
96
|
+
else atRule.replaceWith(importedRoot);
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
await Promise.all(pendingImports);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
postcssPlugin: "postcss-import-url",
|
|
103
|
+
Once: (root, helpers) => inlineImports({
|
|
104
|
+
root,
|
|
105
|
+
ctx: helpers
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function extractUrlFromImport(param) {
|
|
110
|
+
let value = param;
|
|
111
|
+
if (value.startsWith("url")) value = value.slice(3);
|
|
112
|
+
return value.trim().replace(/^['"(]+|['")]+$/g, "");
|
|
113
|
+
}
|
|
114
|
+
function isHttpUrl(candidate) {
|
|
115
|
+
try {
|
|
116
|
+
const u = new URL(candidate);
|
|
117
|
+
return u.protocol === "http:" || u.protocol === "https:";
|
|
118
|
+
} catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function resolveRelative({ target, baseUrl }) {
|
|
123
|
+
if (isHttpUrl(target)) return target;
|
|
124
|
+
if (!baseUrl || !isHttpUrl(baseUrl)) return target;
|
|
125
|
+
try {
|
|
126
|
+
return new URL(target, baseUrl).href;
|
|
127
|
+
} catch {
|
|
128
|
+
return target;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function absolutizeUrlFunction({ cssUrlValue, importedFromUrl }) {
|
|
132
|
+
return `url("${resolveRelative({
|
|
133
|
+
target: extractUrlFromImport(cssUrlValue),
|
|
134
|
+
baseUrl: importedFromUrl
|
|
135
|
+
})}")`;
|
|
136
|
+
}
|
|
137
|
+
async function fetchCss({ absoluteUrl, options, ctx, atRule }) {
|
|
138
|
+
const cached = FETCH_CACHE.get(absoluteUrl);
|
|
139
|
+
if (cached) return cached;
|
|
140
|
+
const headers = {
|
|
141
|
+
connection: "keep-alive",
|
|
142
|
+
"user-agent": options.userAgent || "Mozilla/5.0 AppleWebKit/538.0 Chrome/88.0.0.0 Safari/538",
|
|
143
|
+
accept: "text/css,*/*;q=0.1"
|
|
144
|
+
};
|
|
145
|
+
const promise = (async () => {
|
|
146
|
+
const { data, error } = await http(absoluteUrl, {
|
|
147
|
+
headers,
|
|
148
|
+
responseType: "text"
|
|
149
|
+
});
|
|
150
|
+
if (error) throw new CompileError(`Failed to fetch ${absoluteUrl}: ${error}`);
|
|
151
|
+
if (!data) throw new CompileError(`Failed to fetch ${absoluteUrl}: No data returned`);
|
|
152
|
+
return {
|
|
153
|
+
body: data,
|
|
154
|
+
parent: absoluteUrl
|
|
155
|
+
};
|
|
156
|
+
})();
|
|
157
|
+
FETCH_CACHE.set(absoluteUrl, promise);
|
|
158
|
+
return promise;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
export { postcssImportUrl };
|
|
163
|
+
//# sourceMappingURL=import-url.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-url.mjs","names":["DEFAULT_OPTIONS: Required<ImportUrlOptions>","resolvedOptions: Required<ImportUrlOptions>","effectiveParentUrl: string | undefined","pendingImports: Array<Promise<void>>","importedRoot: Root | AtRule","headers: Record<string, string>"],"sources":["../../../../../src/server/vite/plugins/postcss/import-url.ts"],"sourcesContent":["/**\n * A postcss plugin that inlines remote css imports.\n */\n\nimport postcss from 'postcss'\nimport type { Plugin, AtRule, Root, Result } from 'postcss'\n\nimport { http } from '../../../../shared/http'\nimport { CompileError } from '../../../errors'\n\nconst { list: postcssList } = postcss\n\nexport interface ImportUrlOptions {\n\trecursive?: boolean\n\tresolveUrls?: boolean\n\tuserAgent?: string | null\n\tdataUrls?: boolean\n}\n\ninterface RequestResult {\n\tbody: string\n\tparent: string\n}\n\ninterface InlineImportsArgs {\n\troot: Root\n\tctx: { result: Result }\n\tparentUrl?: string\n}\n\ninterface ResolveRelativeArgs {\n\ttarget: string\n\tbaseUrl?: string\n}\n\ninterface AbsolutizeUrlArgs {\n\tcssUrlValue: string\n\timportedFromUrl: string\n}\n\ninterface FetchCssArgs {\n\tabsoluteUrl: string\n\toptions: Required<ImportUrlOptions>\n\tctx: { result: Result }\n\tatRule: AtRule\n}\n\nconst DEFAULT_OPTIONS: Required<ImportUrlOptions> = {\n\trecursive: true,\n\tresolveUrls: false,\n\tuserAgent: null,\n\tdataUrls: false\n}\n\nconst SPACE = postcssList.space\nconst URL_FUNCTION_REGEX = /url\\([\"']?.+?['\"]?\\)/g\nconst FETCH_CACHE = new Map<string, Promise<RequestResult>>()\n\nexport function postcssImportUrl(options?: ImportUrlOptions): Plugin {\n\tconst resolvedOptions: Required<ImportUrlOptions> = { ...DEFAULT_OPTIONS, ...(options ?? {}) }\n\n\tasync function inlineImports({ root, ctx, parentUrl }: InlineImportsArgs): Promise<void> {\n\t\tconst effectiveParentUrl: string | undefined = parentUrl || root.source?.input?.file\n\t\tconst pendingImports: Array<Promise<void>> = []\n\n\t\troot.walkAtRules('import', (atRule: AtRule) => {\n\t\t\tconst importParams = SPACE(atRule.params)\n\t\t\tconst importTargetRaw = extractUrlFromImport(importParams[0])\n\n\t\t\tlet normalizedTarget = importTargetRaw\n\n\t\t\t// Handle protocol-less (//) URLs and just use https\n\t\t\tif (normalizedTarget.startsWith('//')) {\n\t\t\t\tconst httpsUrl = `https:${normalizedTarget}`\n\t\t\t\tatRule.warn(ctx.result, `Protocol-less @import '${normalizedTarget}' normalized to '${httpsUrl}'.`)\n\t\t\t\tnormalizedTarget = httpsUrl\n\t\t\t}\n\n\t\t\t// Resolve against parent (handles relative paths AND protocol-less)\n\t\t\tif (effectiveParentUrl) {\n\t\t\t\tnormalizedTarget = resolveRelative({ target: normalizedTarget, baseUrl: effectiveParentUrl })\n\t\t\t}\n\n\t\t\tif (!isHttpUrl(normalizedTarget)) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tpendingImports.push(\n\t\t\t\tfetchCss({ absoluteUrl: normalizedTarget, options: resolvedOptions, ctx, atRule }).then(\n\t\t\t\t\tasync (response: RequestResult) => {\n\t\t\t\t\t\tlet importedRoot: Root | AtRule = postcss.parse(response.body)\n\n\t\t\t\t\t\tconst hasLayerQualifier = importParams.some(p => p.includes('layer'))\n\t\t\t\t\t\tconst hasSupportsQualifier = importParams.some(p => p.includes('supports'))\n\n\t\t\t\t\t\tconst mediaStartIndex = hasLayerQualifier ? (hasSupportsQualifier ? 3 : 2) : 1\n\t\t\t\t\t\tconst mediaQuery = importParams.slice(mediaStartIndex).join(' ')\n\n\t\t\t\t\t\tif (mediaQuery) {\n\t\t\t\t\t\t\tconst mediaWrapper = postcss.atRule({ name: 'media', params: mediaQuery, source: atRule.source })\n\t\t\t\t\t\t\tmediaWrapper.append(importedRoot)\n\t\t\t\t\t\t\timportedRoot = mediaWrapper\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timportedRoot.source = atRule.source\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (hasSupportsQualifier) {\n\t\t\t\t\t\t\tconst supportsToken = importParams.find(p => p.includes('supports')) || ''\n\t\t\t\t\t\t\tconst open = supportsToken.indexOf('(')\n\t\t\t\t\t\t\tconst close = supportsToken.lastIndexOf(')')\n\t\t\t\t\t\t\tconst supportsQuery = open >= 0 && close > open ? supportsToken.slice(open + 1, close) : ''\n\n\t\t\t\t\t\t\tconst supportsWrapper = postcss.atRule({\n\t\t\t\t\t\t\t\tname: 'supports',\n\t\t\t\t\t\t\t\tparams: supportsQuery ? `(${supportsQuery})` : '',\n\t\t\t\t\t\t\t\tsource: atRule.source\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\tsupportsWrapper.append(importedRoot)\n\t\t\t\t\t\t\timportedRoot = supportsWrapper\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timportedRoot.source = atRule.source\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (hasLayerQualifier) {\n\t\t\t\t\t\t\tconst layerToken = importParams.find(p => p.includes('layer')) || ''\n\t\t\t\t\t\t\tconst open = layerToken.indexOf('(')\n\t\t\t\t\t\t\tconst close = layerToken.lastIndexOf(')')\n\t\t\t\t\t\t\tconst layerName = open >= 0 && close > open ? layerToken.slice(open + 1, close) : ''\n\n\t\t\t\t\t\t\tconst layerWrapper = postcss.atRule({\n\t\t\t\t\t\t\t\tname: 'layer',\n\t\t\t\t\t\t\t\tparams: layerName,\n\t\t\t\t\t\t\t\tsource: importedRoot.source\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\tlayerWrapper.append(importedRoot)\n\t\t\t\t\t\t\timportedRoot = layerWrapper\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Optional: Resolve any url(...) references to absolute URLs\n\t\t\t\t\t\tif (resolvedOptions.resolveUrls) {\n\t\t\t\t\t\t\timportedRoot = importedRoot.replaceValues(URL_FUNCTION_REGEX, { fast: 'url(' }, (val: string) =>\n\t\t\t\t\t\t\t\tabsolutizeUrlFunction({ cssUrlValue: val, importedFromUrl: normalizedTarget })\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Optional: If there are any @imports in the imported CSS, recursively import them\n\t\t\t\t\t\tif (resolvedOptions.recursive && 'toResult' in importedRoot) {\n\t\t\t\t\t\t\tawait inlineImports({ root: importedRoot, ctx, parentUrl: response.parent })\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Optional: Convert the imported CSS to a base64-encoded data URL\n\t\t\t\t\t\tif (resolvedOptions.dataUrls) {\n\t\t\t\t\t\t\tconst base64 = Buffer.from(importedRoot.toString()).toString('base64')\n\t\t\t\t\t\t\tatRule.params = `url(data:text/css;base64,${base64})`\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tatRule.replaceWith(importedRoot)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t)\n\t\t})\n\n\t\tawait Promise.all(pendingImports)\n\t}\n\n\treturn {\n\t\tpostcssPlugin: 'postcss-import-url',\n\t\tOnce: (root: Root, helpers: { result: Result }) => inlineImports({ root, ctx: helpers })\n\t}\n}\n\nfunction extractUrlFromImport(param: string): string {\n\tlet value = param\n\tif (value.startsWith('url')) value = value.slice(3)\n\treturn value.trim().replace(/^['\"(]+|['\")]+$/g, '')\n}\n\nfunction isHttpUrl(candidate: string): boolean {\n\ttry {\n\t\tconst u = new URL(candidate)\n\t\treturn u.protocol === 'http:' || u.protocol === 'https:'\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction resolveRelative({ target, baseUrl }: ResolveRelativeArgs): string {\n\tif (isHttpUrl(target)) return target\n\tif (!baseUrl || !isHttpUrl(baseUrl)) return target\n\n\ttry {\n\t\treturn new URL(target, baseUrl).href\n\t} catch {\n\t\treturn target\n\t}\n}\n\nfunction absolutizeUrlFunction({ cssUrlValue, importedFromUrl }: AbsolutizeUrlArgs): string {\n\tconst cleaned = extractUrlFromImport(cssUrlValue)\n\tconst absolute = resolveRelative({ target: cleaned, baseUrl: importedFromUrl })\n\treturn `url(\"${absolute}\")`\n}\n\nasync function fetchCss({ absoluteUrl, options, ctx, atRule }: FetchCssArgs): Promise<RequestResult> {\n\tconst cached = FETCH_CACHE.get(absoluteUrl)\n\tif (cached) return cached\n\n\tconst headers: Record<string, string> = {\n\t\tconnection: 'keep-alive',\n\t\t'user-agent': options.userAgent || 'Mozilla/5.0 AppleWebKit/538.0 Chrome/88.0.0.0 Safari/538',\n\t\taccept: 'text/css,*/*;q=0.1'\n\t}\n\n\tconst promise = (async () => {\n\t\tconst { data, error } = await http<string>(absoluteUrl, {\n\t\t\theaders,\n\t\t\tresponseType: 'text'\n\t\t})\n\n\t\tif (error) {\n\t\t\tthrow new CompileError(`Failed to fetch ${absoluteUrl}: ${error}`)\n\t\t}\n\n\t\tif (!data) {\n\t\t\tthrow new CompileError(`Failed to fetch ${absoluteUrl}: No data returned`)\n\t\t}\n\n\t\treturn { body: data, parent: absoluteUrl }\n\t})()\n\n\tFETCH_CACHE.set(absoluteUrl, promise)\n\treturn promise\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,EAAE,MAAM,gBAAgB;AAqC9B,MAAMA,kBAA8C;CACnD,WAAW;CACX,aAAa;CACb,WAAW;CACX,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|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/server/vite/plugins/styles-pre-processor.d.ts
|
|
4
|
+
declare function stylesPreProcessor(inlineRemoteCss?: boolean): Promise<Plugin>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { stylesPreProcessor };
|
|
7
|
+
//# sourceMappingURL=styles-pre-processor.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles-pre-processor.d.mts","names":[],"sources":["../../../../src/server/vite/plugins/styles-pre-processor.ts"],"sourcesContent":[],"mappings":";;;iBAgCsB,kBAAA,6BAA6C,QAAQ"}
|