@format.dev/compile 0.0.0 → 0.1.1
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 +278 -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,8 @@
|
|
|
1
|
+
import { checkDir } from "./check-dir.mjs";
|
|
2
|
+
import { parseEnvVarAsBool, parseLogLevelFromEnv } from "./env-var.mjs";
|
|
3
|
+
import { formatForLog } from "./format-for-log.mjs";
|
|
4
|
+
import { findFormatConfigPath, getUnknownConfigKeyWarnings, loadConfig } from "./load-config.mjs";
|
|
5
|
+
import { defaultLogLevel, getLogLevel, logPrefix, logger, setLogFilter, setLogLevel, withPrefixedConsole } from "./log.mjs";
|
|
6
|
+
import { readFile } from "./read-file.mjs";
|
|
7
|
+
import { resolvePathWithExtensions } from "./resolve-path-with-extensions.mjs";
|
|
8
|
+
export { checkDir, defaultLogLevel, findFormatConfigPath, formatForLog, getLogLevel, getUnknownConfigKeyWarnings, loadConfig, logPrefix, logger, parseEnvVarAsBool, parseLogLevelFromEnv, readFile, resolvePathWithExtensions, setLogFilter, setLogLevel, withPrefixedConsole };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultLogLevel, getLogLevel, logPrefix, logger, setLogFilter, setLogLevel, withPrefixedConsole } from "./log.mjs";
|
|
2
|
+
import { parseEnvVarAsBool, parseLogLevelFromEnv } from "./env-var.mjs";
|
|
3
|
+
import { formatForLog } from "./format-for-log.mjs";
|
|
4
|
+
import { findFormatConfigPath, getUnknownConfigKeyWarnings, loadConfig } from "./load-config.mjs";
|
|
5
|
+
import { readFile } from "./read-file.mjs";
|
|
6
|
+
import { checkDir } from "./check-dir.mjs";
|
|
7
|
+
import { resolvePathWithExtensions } from "./resolve-path-with-extensions.mjs";
|
|
8
|
+
|
|
9
|
+
export { checkDir, defaultLogLevel, findFormatConfigPath, formatForLog, getLogLevel, getUnknownConfigKeyWarnings, loadConfig, logPrefix, logger, parseEnvVarAsBool, parseLogLevelFromEnv, readFile, resolvePathWithExtensions, setLogFilter, setLogLevel, withPrefixedConsole };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormatConfig } from "../../shared/types/public/config.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/server/utils/load-config.d.ts
|
|
4
|
+
interface FormatConfigResult {
|
|
5
|
+
config: FormatConfig;
|
|
6
|
+
filepath: string;
|
|
7
|
+
}
|
|
8
|
+
declare function getUnknownConfigKeyWarnings(config: FormatConfig): string[];
|
|
9
|
+
declare function loadConfig(configPath?: string | null): Promise<FormatConfigResult>;
|
|
10
|
+
declare function findFormatConfigPath(projectRoot: string): string | null;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { findFormatConfigPath, getUnknownConfigKeyWarnings, loadConfig };
|
|
13
|
+
//# sourceMappingURL=load-config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.d.mts","names":[],"sources":["../../../src/server/utils/load-config.ts"],"sourcesContent":[],"mappings":";;;UAaU,kBAAA;UACD;EADC,QAAA,EAAA,MAAA;AA8CV;AAoBsB,iBApBN,2BAAA,CAoB8C,MAAO,EApBjB,YAoBiB,CAAA,EAAA,MAAA,EAAA;AAuCrD,iBAvCM,UAAA,CAuCc,UAAA,CAAA,EAAA,MAAA,GAAA,IAAA,CAAA,EAvC0B,OAuC1B,CAvCkC,kBAuClC,CAAA;iBAApB,oBAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { KNOWN_CONFIG_KEYS, SUPPORTED_FRAMEWORKS } from "../../shared/types/public/config.mjs";
|
|
2
|
+
import { setUserProjectDir } from "../project/user-project-dir.mjs";
|
|
3
|
+
import { CONFIG_DOCS_URL, CONFIG_FILE_NAME, INVALID_FRAMEWORK_MESSAGE, NO_CONFIG_FILE_MESSAGE } from "../constants.mjs";
|
|
4
|
+
import { CompileError } from "../errors.mjs";
|
|
5
|
+
import { logger } from "./log.mjs";
|
|
6
|
+
import { suggestSimilar } from "./suggest-similar.mjs";
|
|
7
|
+
import { dirname, resolve } from "node:path";
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { findConfigPath, readConfigFile } from "@format.dev/cli/config";
|
|
10
|
+
|
|
11
|
+
//#region src/server/utils/load-config.ts
|
|
12
|
+
function isValidFramework(type) {
|
|
13
|
+
return SUPPORTED_FRAMEWORKS.includes(type);
|
|
14
|
+
}
|
|
15
|
+
function containmentMatches(key) {
|
|
16
|
+
const lowerKey = key.toLowerCase();
|
|
17
|
+
return KNOWN_CONFIG_KEYS.filter((candidate) => {
|
|
18
|
+
const lowerCandidate = candidate.toLowerCase();
|
|
19
|
+
return lowerCandidate.includes(lowerKey) || lowerKey.includes(lowerCandidate);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function suggestConfigKeys(key) {
|
|
23
|
+
const editMatches = suggestSimilar({
|
|
24
|
+
word: key,
|
|
25
|
+
candidates: KNOWN_CONFIG_KEYS
|
|
26
|
+
});
|
|
27
|
+
if (editMatches.length > 0) return editMatches;
|
|
28
|
+
if (key.length < 4) return [];
|
|
29
|
+
return containmentMatches(key);
|
|
30
|
+
}
|
|
31
|
+
function getUnknownConfigKeyWarnings(config) {
|
|
32
|
+
return Object.keys(config).filter((key) => !KNOWN_CONFIG_KEYS.includes(key)).map((key) => {
|
|
33
|
+
const suggestions = suggestConfigKeys(key);
|
|
34
|
+
return `Unknown option "${key}" in your Format config.${suggestions.length > 0 ? ` Did you mean "${suggestions.join("\" or \"")}"?` : ""} See ${CONFIG_DOCS_URL}`;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function warnUnknownConfigKeys(config) {
|
|
38
|
+
for (const warning of getUnknownConfigKeyWarnings(config)) logger.warn(warning);
|
|
39
|
+
}
|
|
40
|
+
async function loadConfig(configPath) {
|
|
41
|
+
const filepath = configPath ? resolve(configPath) : findFormatConfigPath(process.cwd());
|
|
42
|
+
if (!filepath || !existsSync(filepath)) throw new CompileError(NO_CONFIG_FILE_MESSAGE);
|
|
43
|
+
let config;
|
|
44
|
+
try {
|
|
45
|
+
config = (await readConfigFile(filepath)).config;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new CompileError(error instanceof Error ? error.message : NO_CONFIG_FILE_MESSAGE);
|
|
48
|
+
}
|
|
49
|
+
warnUnknownConfigKeys(config);
|
|
50
|
+
if (!config.framework) throw new CompileError(INVALID_FRAMEWORK_MESSAGE);
|
|
51
|
+
if (!isValidFramework(config.framework)) throw new CompileError(INVALID_FRAMEWORK_MESSAGE);
|
|
52
|
+
const configDir = dirname(filepath);
|
|
53
|
+
setUserProjectDir(config.cwd ? resolve(configDir, config.cwd) : configDir);
|
|
54
|
+
return {
|
|
55
|
+
config,
|
|
56
|
+
filepath
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function findFormatConfigPath(projectRoot) {
|
|
60
|
+
return findConfigPath(projectRoot, { baseName: CONFIG_FILE_NAME });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { findFormatConfigPath, getUnknownConfigKeyWarnings, loadConfig };
|
|
65
|
+
//# sourceMappingURL=load-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.mjs","names":["resolvePath","config: FormatConfig"],"sources":["../../../src/server/utils/load-config.ts"],"sourcesContent":["import type { FormatConfig, Framework } from '../../shared/types'\n\nimport { existsSync } from 'node:fs'\nimport { dirname, resolve as resolvePath } from 'node:path'\nimport { findConfigPath, readConfigFile } from '@format.dev/cli/config'\n\nimport { logger } from './log'\nimport { setUserProjectDir } from '../project/user-project-dir'\nimport { SUPPORTED_FRAMEWORKS, KNOWN_CONFIG_KEYS } from '../../shared/types/public/config'\nimport { CONFIG_FILE_NAME, NO_CONFIG_FILE_MESSAGE, INVALID_FRAMEWORK_MESSAGE, CONFIG_DOCS_URL } from '../constants'\nimport { CompileError } from '../errors'\nimport { suggestSimilar } from './suggest-similar'\n\ninterface FormatConfigResult {\n\tconfig: FormatConfig\n\tfilepath: string\n}\n\nfunction isValidFramework(type: string): type is Framework {\n\treturn SUPPORTED_FRAMEWORKS.includes(type as Framework)\n}\n\n// Known keys that contain (or are contained by) the unknown key, ignoring\n// case. This catches typos edit distance misses, such as `assetsDir` for\n// `sharedAssetsDir`, where the correct key just has an extra prefix.\nfunction containmentMatches(key: string): string[] {\n\tconst lowerKey = key.toLowerCase()\n\n\treturn KNOWN_CONFIG_KEYS.filter(candidate => {\n\t\tconst lowerCandidate = candidate.toLowerCase()\n\n\t\treturn lowerCandidate.includes(lowerKey) || lowerKey.includes(lowerCandidate)\n\t})\n}\n\n// Suggest the known key(s) most likely intended for a mistyped one. Edit\n// distance handles ordinary typos (e.g `framwork`); the containment fallback\n// handles keys that are a substring of the real one (`assetsDir`).\nfunction suggestConfigKeys(key: string): string[] {\n\tconst editMatches = suggestSimilar({ word: key, candidates: KNOWN_CONFIG_KEYS })\n\n\tif (editMatches.length > 0) {\n\t\treturn editMatches\n\t}\n\n\t// Only fall back for keys long enough that a substring match is meaningful,\n\t// otherwise short fragments like `dir` would match several keys.\n\tif (key.length < 4) {\n\t\treturn []\n\t}\n\n\treturn containmentMatches(key)\n}\n\n// Build a warning for every config key we don't recognise. These are almost\n// always typos (e.g. `assetsDir` for `sharedAssetsDir`), so we point at the\n// closest known key. Returned as strings rather than logged directly so callers\n// that clear the screen at startup (the dev server) can surface them after the\n// clear, once the console is settled.\nexport function getUnknownConfigKeyWarnings(config: FormatConfig): string[] {\n\tconst unknownKeys = Object.keys(config).filter(key => !KNOWN_CONFIG_KEYS.includes(key as keyof FormatConfig))\n\n\treturn unknownKeys.map(key => {\n\t\tconst suggestions = suggestConfigKeys(key)\n\t\tconst didYouMean = suggestions.length > 0 ? ` Did you mean \"${suggestions.join('\" or \"')}\"?` : ''\n\n\t\treturn `Unknown option \"${key}\" in your Format config.${didYouMean} See ${CONFIG_DOCS_URL}`\n\t})\n}\n\n// Log unknown-key warnings immediately. This never throws: an unknown optional\n// key shouldn't stop Studio booting, and a missing required key is reported\n// separately.\nfunction warnUnknownConfigKeys(config: FormatConfig) {\n\tfor (const warning of getUnknownConfigKeyWarnings(config)) {\n\t\tlogger.warn(warning)\n\t}\n}\n\nexport async function loadConfig(configPath?: string | null): Promise<FormatConfigResult> {\n\tconst filepath = configPath ? resolvePath(configPath) : findFormatConfigPath(process.cwd())\n\n\tif (!filepath || !existsSync(filepath)) {\n\t\tthrow new CompileError(NO_CONFIG_FILE_MESSAGE)\n\t}\n\n\tlet config: FormatConfig\n\n\ttry {\n\t\tconst result = await readConfigFile(filepath)\n\t\tconfig = result.config as unknown as FormatConfig\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : NO_CONFIG_FILE_MESSAGE\n\n\t\tthrow new CompileError(message)\n\t}\n\n\twarnUnknownConfigKeys(config)\n\n\tif (!config.framework) {\n\t\tthrow new CompileError(INVALID_FRAMEWORK_MESSAGE)\n\t}\n\n\tif (!isValidFramework(config.framework)) {\n\t\tthrow new CompileError(INVALID_FRAMEWORK_MESSAGE)\n\t}\n\n\tconst configDir = dirname(filepath)\n\tconst baseDir = config.cwd ? resolvePath(configDir, config.cwd) : configDir\n\tsetUserProjectDir(baseDir)\n\n\treturn { config, filepath }\n}\n\n// Locate the Format config file on disk, searching up from the project root.\n// Used directly by callers that need to amend the config (e.g. Panda setup).\n// Delegates to the shared finder in @format.dev/cli, honouring the test-only\n// FMT_CONFIG_FILE_NAME base-name override.\nexport function findFormatConfigPath(projectRoot: string): string | null {\n\treturn findConfigPath(projectRoot, { baseName: CONFIG_FILE_NAME })\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAS,iBAAiB,MAAiC;AAC1D,QAAO,qBAAqB,SAAS,KAAkB;;AAMxD,SAAS,mBAAmB,KAAuB;CAClD,MAAM,WAAW,IAAI,aAAa;AAElC,QAAO,kBAAkB,QAAO,cAAa;EAC5C,MAAM,iBAAiB,UAAU,aAAa;AAE9C,SAAO,eAAe,SAAS,SAAS,IAAI,SAAS,SAAS,eAAe;GAC5E;;AAMH,SAAS,kBAAkB,KAAuB;CACjD,MAAM,cAAc,eAAe;EAAE,MAAM;EAAK,YAAY;EAAmB,CAAC;AAEhF,KAAI,YAAY,SAAS,EACxB,QAAO;AAKR,KAAI,IAAI,SAAS,EAChB,QAAO,EAAE;AAGV,QAAO,mBAAmB,IAAI;;AAQ/B,SAAgB,4BAA4B,QAAgC;AAG3E,QAFoB,OAAO,KAAK,OAAO,CAAC,QAAO,QAAO,CAAC,kBAAkB,SAAS,IAA0B,CAAC,CAE1F,KAAI,QAAO;EAC7B,MAAM,cAAc,kBAAkB,IAAI;AAG1C,SAAO,mBAAmB,IAAI,0BAFX,YAAY,SAAS,IAAI,kBAAkB,YAAY,KAAK,WAAS,CAAC,MAAM,GAE5B,OAAO;GACzE;;AAMH,SAAS,sBAAsB,QAAsB;AACpD,MAAK,MAAM,WAAW,4BAA4B,OAAO,CACxD,QAAO,KAAK,QAAQ;;AAItB,eAAsB,WAAW,YAAyD;CACzF,MAAM,WAAW,aAAaA,QAAY,WAAW,GAAG,qBAAqB,QAAQ,KAAK,CAAC;AAE3F,KAAI,CAAC,YAAY,CAAC,WAAW,SAAS,CACrC,OAAM,IAAI,aAAa,uBAAuB;CAG/C,IAAIC;AAEJ,KAAI;AAEH,YADe,MAAM,eAAe,SAAS,EAC7B;UACR,OAAO;AAGf,QAAM,IAAI,aAFM,iBAAiB,QAAQ,MAAM,UAAU,uBAE1B;;AAGhC,uBAAsB,OAAO;AAE7B,KAAI,CAAC,OAAO,UACX,OAAM,IAAI,aAAa,0BAA0B;AAGlD,KAAI,CAAC,iBAAiB,OAAO,UAAU,CACtC,OAAM,IAAI,aAAa,0BAA0B;CAGlD,MAAM,YAAY,QAAQ,SAAS;AAEnC,mBADgB,OAAO,MAAMD,QAAY,WAAW,OAAO,IAAI,GAAG,UACxC;AAE1B,QAAO;EAAE;EAAQ;EAAU;;AAO5B,SAAgB,qBAAqB,aAAoC;AACxE,QAAO,eAAe,aAAa,EAAE,UAAU,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LogLevel } from "../../shared/types/log.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/server/utils/log.d.ts
|
|
4
|
+
declare const logPrefix = "[format:studio]";
|
|
5
|
+
declare const LEVEL_COLORS: Readonly<{
|
|
6
|
+
error: "\u001B[31m";
|
|
7
|
+
warn: "\u001B[33m";
|
|
8
|
+
info: "\u001B[36m";
|
|
9
|
+
log: "\u001B[32m";
|
|
10
|
+
debug: "\u001B[35m";
|
|
11
|
+
}>;
|
|
12
|
+
declare const setLogLevel: (level: LogLevel) => void;
|
|
13
|
+
declare const defaultLogLevel = LogLevel.INFO;
|
|
14
|
+
declare const getLogLevel: () => LogLevel;
|
|
15
|
+
declare const setLogFilter: (fn: ((level: keyof typeof LEVEL_COLORS, ...args: any[]) => boolean) | null) => void;
|
|
16
|
+
declare const logger: {
|
|
17
|
+
clear: () => void;
|
|
18
|
+
error: (...args: any[]) => void;
|
|
19
|
+
warn: (...args: any[]) => void;
|
|
20
|
+
log: (...args: any[]) => void;
|
|
21
|
+
info: (...args: any[]) => void;
|
|
22
|
+
time: (label: string) => void;
|
|
23
|
+
timeEnd: (label: string) => void;
|
|
24
|
+
debug: (...args: any[]) => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Temporarily override the console methods with the logger methods.
|
|
28
|
+
* Helpful when we don't have control of a logger instance inside another package.
|
|
29
|
+
*
|
|
30
|
+
* @param run - The async or sync function to run with the prefixed console
|
|
31
|
+
* @param filter - Optional filter function (return false to suppress a log)
|
|
32
|
+
*/
|
|
33
|
+
declare function withPrefixedConsole(run: () => Promise<any> | any, filter?: (level: keyof typeof LEVEL_COLORS, ...args: any[]) => boolean): Promise<any>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { defaultLogLevel, getLogLevel, logPrefix, logger, setLogFilter, setLogLevel, withPrefixedConsole };
|
|
36
|
+
//# sourceMappingURL=log.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.mts","names":[],"sources":["../../../src/server/utils/log.ts"],"sourcesContent":[],"mappings":";;;cAEa,SAAA;cAcP,cAAY;EAdL,KAAA,EAAA,YAAS;EAchB,IAAA,EAAA,YAMJ;EAKW,IAAA,EAAA,YAEZ;EAEY,GAAA,EAAA,YAAA;EAEA,KAAA,EAAA,YAAmC;AAEhD,CAAA,CAAA;AA4Ca,cApDA,WAgGZ,EAAA,CAAA,KAAA,EAhGkC,QAgGlC,EAAA,GAAA,IAAA;AASqB,cArGT,eAAA,GAqG4B,QAAA,CAAA,IAAA;AAC7B,cApGC,WAoGD,EAAA,GAAA,GApGY,QAoGZ;AACmB,cAnGlB,YAmGkB,EAAA,CAAA,EAAA,EAAA,CAAA,CAAA,KAAA,EAAA,MAAA,OAnGwB,YAmGxB,EAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GAAA,OAAA,CAAA,GAAA,IAAA,EAAA,GAAA,IAAA;AAAwC,cAvD1D,MAuD0D,EAAA;EAAA,KAAA,EAAA,GAAA,GAAA,IAAA;;;;;;;;;;;;;;;;iBAFjD,mBAAA,YACV,kDACmB,2CAAwC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { LogLevel } from "../../shared/types/log.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/server/utils/log.ts
|
|
4
|
+
const logPrefix = "[format:studio]";
|
|
5
|
+
const COLORS = Object.freeze({
|
|
6
|
+
reset: "\x1B[0m",
|
|
7
|
+
red: "\x1B[31m",
|
|
8
|
+
green: "\x1B[32m",
|
|
9
|
+
yellow: "\x1B[33m",
|
|
10
|
+
blue: "\x1B[34m",
|
|
11
|
+
magenta: "\x1B[35m",
|
|
12
|
+
cyan: "\x1B[36m",
|
|
13
|
+
gray: "\x1B[90m"
|
|
14
|
+
});
|
|
15
|
+
const LEVEL_COLORS = Object.freeze({
|
|
16
|
+
error: COLORS.red,
|
|
17
|
+
warn: COLORS.yellow,
|
|
18
|
+
info: COLORS.cyan,
|
|
19
|
+
log: COLORS.green,
|
|
20
|
+
debug: COLORS.magenta
|
|
21
|
+
});
|
|
22
|
+
let currentLogLevel = LogLevel.INFO;
|
|
23
|
+
let logFilter = null;
|
|
24
|
+
const setLogLevel = (level) => {
|
|
25
|
+
currentLogLevel = level;
|
|
26
|
+
};
|
|
27
|
+
const defaultLogLevel = LogLevel.INFO;
|
|
28
|
+
const getLogLevel = () => currentLogLevel;
|
|
29
|
+
const setLogFilter = (fn) => {
|
|
30
|
+
logFilter = fn;
|
|
31
|
+
};
|
|
32
|
+
const shouldLog = (level, name, ...args) => level <= currentLogLevel && (!logFilter || logFilter(name, ...args));
|
|
33
|
+
function formatTimestamp() {
|
|
34
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace(/\..+/, "");
|
|
35
|
+
}
|
|
36
|
+
const colorize = (level) => {
|
|
37
|
+
const ts = formatTimestamp();
|
|
38
|
+
return `${COLORS.gray}[${ts}]${COLORS.reset} ${LEVEL_COLORS[level]}${logPrefix}${COLORS.reset}`;
|
|
39
|
+
};
|
|
40
|
+
const originalConsole = {
|
|
41
|
+
log: console.log,
|
|
42
|
+
info: console.info,
|
|
43
|
+
warn: console.warn,
|
|
44
|
+
error: console.error,
|
|
45
|
+
debug: console.debug,
|
|
46
|
+
clear: console.clear
|
|
47
|
+
};
|
|
48
|
+
const timers = /* @__PURE__ */ new Map();
|
|
49
|
+
function startTimer(label) {
|
|
50
|
+
timers.set(label, performance.now());
|
|
51
|
+
}
|
|
52
|
+
function endTimer(label) {
|
|
53
|
+
const start = timers.get(label);
|
|
54
|
+
if (start == null) return null;
|
|
55
|
+
const duration = performance.now() - start;
|
|
56
|
+
timers.delete(label);
|
|
57
|
+
return `${label}: ${duration.toFixed(2)}ms`;
|
|
58
|
+
}
|
|
59
|
+
const logger = {
|
|
60
|
+
clear: () => {
|
|
61
|
+
originalConsole.clear();
|
|
62
|
+
},
|
|
63
|
+
error: (...args) => {
|
|
64
|
+
if (shouldLog(LogLevel.ERROR, "error", ...args)) originalConsole.error(colorize("error"), ...args);
|
|
65
|
+
},
|
|
66
|
+
warn: (...args) => {
|
|
67
|
+
if (shouldLog(LogLevel.WARN, "warn", ...args)) originalConsole.warn(colorize("warn"), ...args);
|
|
68
|
+
},
|
|
69
|
+
log: (...args) => {
|
|
70
|
+
if (shouldLog(LogLevel.INFO, "log", ...args)) originalConsole.log(colorize("log"), ...args);
|
|
71
|
+
},
|
|
72
|
+
info: (...args) => {
|
|
73
|
+
if (shouldLog(LogLevel.INFO, "info", ...args)) originalConsole.info(colorize("info"), ...args);
|
|
74
|
+
},
|
|
75
|
+
time: (label) => {
|
|
76
|
+
if (shouldLog(LogLevel.INFO, "info", label)) startTimer(label);
|
|
77
|
+
},
|
|
78
|
+
timeEnd: (label) => {
|
|
79
|
+
if (shouldLog(LogLevel.INFO, "info", label)) {
|
|
80
|
+
const result = endTimer(label);
|
|
81
|
+
if (result) originalConsole.info(colorize("info"), result);
|
|
82
|
+
else originalConsole.warn(colorize("warn"), `No such label: ${label}`);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
debug: (...args) => {
|
|
86
|
+
if (shouldLog(LogLevel.DEBUG, "debug", ...args)) originalConsole.debug(colorize("debug"), ...args);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Temporarily override the console methods with the logger methods.
|
|
91
|
+
* Helpful when we don't have control of a logger instance inside another package.
|
|
92
|
+
*
|
|
93
|
+
* @param run - The async or sync function to run with the prefixed console
|
|
94
|
+
* @param filter - Optional filter function (return false to suppress a log)
|
|
95
|
+
*/
|
|
96
|
+
async function withPrefixedConsole(run, filter) {
|
|
97
|
+
const { log, info, warn, error, debug, clear, time, timeEnd } = console;
|
|
98
|
+
const previousFilter = logFilter;
|
|
99
|
+
if (filter) setLogFilter(filter);
|
|
100
|
+
console.log = logger.log;
|
|
101
|
+
console.info = logger.info;
|
|
102
|
+
console.warn = logger.warn;
|
|
103
|
+
console.error = logger.error;
|
|
104
|
+
console.debug = logger.debug;
|
|
105
|
+
console.clear = logger.clear;
|
|
106
|
+
console.time = logger.time;
|
|
107
|
+
console.timeEnd = logger.timeEnd;
|
|
108
|
+
try {
|
|
109
|
+
return await run();
|
|
110
|
+
} finally {
|
|
111
|
+
console.log = log;
|
|
112
|
+
console.info = info;
|
|
113
|
+
console.warn = warn;
|
|
114
|
+
console.error = error;
|
|
115
|
+
console.debug = debug;
|
|
116
|
+
console.clear = clear;
|
|
117
|
+
console.time = time;
|
|
118
|
+
console.timeEnd = timeEnd;
|
|
119
|
+
setLogFilter(previousFilter);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { defaultLogLevel, getLogLevel, logPrefix, logger, setLogFilter, setLogLevel, withPrefixedConsole };
|
|
125
|
+
//# sourceMappingURL=log.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.mjs","names":["logFilter: ((level: keyof typeof LEVEL_COLORS, ...args: any[]) => boolean) | null"],"sources":["../../../src/server/utils/log.ts"],"sourcesContent":["import { LogLevel } from '../../shared/types'\n\nexport const logPrefix = '[format:studio]'\n\n// ANSI escape sequences\nconst COLORS = Object.freeze({\n\treset: '\\u001b[0m',\n\tred: '\\u001b[31m',\n\tgreen: '\\u001b[32m',\n\tyellow: '\\u001b[33m',\n\tblue: '\\u001b[34m',\n\tmagenta: '\\u001b[35m',\n\tcyan: '\\u001b[36m',\n\tgray: '\\u001b[90m'\n})\n\nconst LEVEL_COLORS = Object.freeze({\n\terror: COLORS.red,\n\twarn: COLORS.yellow,\n\tinfo: COLORS.cyan,\n\tlog: COLORS.green,\n\tdebug: COLORS.magenta\n})\n\nlet currentLogLevel = LogLevel.INFO\nlet logFilter: ((level: keyof typeof LEVEL_COLORS, ...args: any[]) => boolean) | null = null\n\nexport const setLogLevel = (level: LogLevel) => {\n\tcurrentLogLevel = level\n}\n\nexport const defaultLogLevel = LogLevel.INFO\n\nexport const getLogLevel = () => currentLogLevel\n\nexport const setLogFilter = (fn: ((level: keyof typeof LEVEL_COLORS, ...args: any[]) => boolean) | null) => {\n\tlogFilter = fn\n}\n\nconst shouldLog = (level: LogLevel, name: keyof typeof LEVEL_COLORS, ...args: any[]) =>\n\tlevel <= currentLogLevel && (!logFilter || logFilter(name, ...args))\n\nfunction formatTimestamp(): string {\n\tconst now = new Date()\n\t// e.g. \"2025-09-03 20:15:43\"\n\treturn now.toISOString().replace('T', ' ').replace(/\\..+/, '')\n}\n\nconst colorize = (level: keyof typeof LEVEL_COLORS) => {\n\tconst ts = formatTimestamp()\n\treturn `${COLORS.gray}[${ts}]${COLORS.reset} ${LEVEL_COLORS[level]}${logPrefix}${COLORS.reset}`\n}\n\n// Capture the real console once so logger never recurses\nconst originalConsole = {\n\tlog: console.log,\n\tinfo: console.info,\n\twarn: console.warn,\n\terror: console.error,\n\tdebug: console.debug,\n\tclear: console.clear\n}\n\nconst timers = new Map<string, number>()\n\nfunction startTimer(label: string) {\n\ttimers.set(label, performance.now())\n}\n\nfunction endTimer(label: string): string | null {\n\tconst start = timers.get(label)\n\tif (start == null) {\n\t\treturn null\n\t}\n\tconst duration = performance.now() - start\n\ttimers.delete(label)\n\treturn `${label}: ${duration.toFixed(2)}ms`\n}\n\nexport const logger = {\n\tclear: () => {\n\t\toriginalConsole.clear()\n\t},\n\terror: (...args: any[]) => {\n\t\tif (shouldLog(LogLevel.ERROR, 'error', ...args)) {\n\t\t\toriginalConsole.error(colorize('error'), ...args)\n\t\t}\n\t},\n\twarn: (...args: any[]) => {\n\t\tif (shouldLog(LogLevel.WARN, 'warn', ...args)) {\n\t\t\toriginalConsole.warn(colorize('warn'), ...args)\n\t\t}\n\t},\n\tlog: (...args: any[]) => {\n\t\tif (shouldLog(LogLevel.INFO, 'log', ...args)) {\n\t\t\toriginalConsole.log(colorize('log'), ...args)\n\t\t}\n\t},\n\tinfo: (...args: any[]) => {\n\t\tif (shouldLog(LogLevel.INFO, 'info', ...args)) {\n\t\t\toriginalConsole.info(colorize('info'), ...args)\n\t\t}\n\t},\n\ttime: (label: string) => {\n\t\tif (shouldLog(LogLevel.INFO, 'info', label)) {\n\t\t\tstartTimer(label)\n\t\t}\n\t},\n\ttimeEnd: (label: string) => {\n\t\tif (shouldLog(LogLevel.INFO, 'info', label)) {\n\t\t\tconst result = endTimer(label)\n\t\t\tif (result) {\n\t\t\t\toriginalConsole.info(colorize('info'), result)\n\t\t\t} else {\n\t\t\t\toriginalConsole.warn(colorize('warn'), `No such label: ${label}`)\n\t\t\t}\n\t\t}\n\t},\n\tdebug: (...args: any[]) => {\n\t\tif (shouldLog(LogLevel.DEBUG, 'debug', ...args)) {\n\t\t\toriginalConsole.debug(colorize('debug'), ...args)\n\t\t}\n\t}\n}\n\n/**\n * Temporarily override the console methods with the logger methods.\n * Helpful when we don't have control of a logger instance inside another package.\n *\n * @param run - The async or sync function to run with the prefixed console\n * @param filter - Optional filter function (return false to suppress a log)\n */\nexport async function withPrefixedConsole(\n\trun: () => Promise<any> | any,\n\tfilter?: (level: keyof typeof LEVEL_COLORS, ...args: any[]) => boolean\n) {\n\tconst { log, info, warn, error, debug, clear, time, timeEnd } = console\n\tconst previousFilter = logFilter\n\n\tif (filter) {\n\t\tsetLogFilter(filter)\n\t}\n\n\tconsole.log = logger.log\n\tconsole.info = logger.info\n\tconsole.warn = logger.warn\n\tconsole.error = logger.error\n\tconsole.debug = logger.debug\n\tconsole.clear = logger.clear\n\tconsole.time = logger.time\n\tconsole.timeEnd = logger.timeEnd\n\n\ttry {\n\t\treturn await run()\n\t} finally {\n\t\tconsole.log = log\n\t\tconsole.info = info\n\t\tconsole.warn = warn\n\t\tconsole.error = error\n\t\tconsole.debug = debug\n\t\tconsole.clear = clear\n\t\tconsole.time = time\n\t\tconsole.timeEnd = timeEnd\n\n\t\t// restore previous filter\n\t\tsetLogFilter(previousFilter)\n\t}\n}\n"],"mappings":";;;AAEA,MAAa,YAAY;AAGzB,MAAM,SAAS,OAAO,OAAO;CAC5B,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,MAAM;CACN,CAAC;AAEF,MAAM,eAAe,OAAO,OAAO;CAClC,OAAO,OAAO;CACd,MAAM,OAAO;CACb,MAAM,OAAO;CACb,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,CAAC;AAEF,IAAI,kBAAkB,SAAS;AAC/B,IAAIA,YAAoF;AAExF,MAAa,eAAe,UAAoB;AAC/C,mBAAkB;;AAGnB,MAAa,kBAAkB,SAAS;AAExC,MAAa,oBAAoB;AAEjC,MAAa,gBAAgB,OAA+E;AAC3G,aAAY;;AAGb,MAAM,aAAa,OAAiB,MAAiC,GAAG,SACvE,SAAS,oBAAoB,CAAC,aAAa,UAAU,MAAM,GAAG,KAAK;AAEpE,SAAS,kBAA0B;AAGlC,yBAFY,IAAI,MAAM,EAEX,aAAa,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,QAAQ,GAAG;;AAG/D,MAAM,YAAY,UAAqC;CACtD,MAAM,KAAK,iBAAiB;AAC5B,QAAO,GAAG,OAAO,KAAK,GAAG,GAAG,GAAG,OAAO,MAAM,GAAG,aAAa,SAAS,YAAY,OAAO;;AAIzF,MAAM,kBAAkB;CACvB,KAAK,QAAQ;CACb,MAAM,QAAQ;CACd,MAAM,QAAQ;CACd,OAAO,QAAQ;CACf,OAAO,QAAQ;CACf,OAAO,QAAQ;CACf;AAED,MAAM,yBAAS,IAAI,KAAqB;AAExC,SAAS,WAAW,OAAe;AAClC,QAAO,IAAI,OAAO,YAAY,KAAK,CAAC;;AAGrC,SAAS,SAAS,OAA8B;CAC/C,MAAM,QAAQ,OAAO,IAAI,MAAM;AAC/B,KAAI,SAAS,KACZ,QAAO;CAER,MAAM,WAAW,YAAY,KAAK,GAAG;AACrC,QAAO,OAAO,MAAM;AACpB,QAAO,GAAG,MAAM,IAAI,SAAS,QAAQ,EAAE,CAAC;;AAGzC,MAAa,SAAS;CACrB,aAAa;AACZ,kBAAgB,OAAO;;CAExB,QAAQ,GAAG,SAAgB;AAC1B,MAAI,UAAU,SAAS,OAAO,SAAS,GAAG,KAAK,CAC9C,iBAAgB,MAAM,SAAS,QAAQ,EAAE,GAAG,KAAK;;CAGnD,OAAO,GAAG,SAAgB;AACzB,MAAI,UAAU,SAAS,MAAM,QAAQ,GAAG,KAAK,CAC5C,iBAAgB,KAAK,SAAS,OAAO,EAAE,GAAG,KAAK;;CAGjD,MAAM,GAAG,SAAgB;AACxB,MAAI,UAAU,SAAS,MAAM,OAAO,GAAG,KAAK,CAC3C,iBAAgB,IAAI,SAAS,MAAM,EAAE,GAAG,KAAK;;CAG/C,OAAO,GAAG,SAAgB;AACzB,MAAI,UAAU,SAAS,MAAM,QAAQ,GAAG,KAAK,CAC5C,iBAAgB,KAAK,SAAS,OAAO,EAAE,GAAG,KAAK;;CAGjD,OAAO,UAAkB;AACxB,MAAI,UAAU,SAAS,MAAM,QAAQ,MAAM,CAC1C,YAAW,MAAM;;CAGnB,UAAU,UAAkB;AAC3B,MAAI,UAAU,SAAS,MAAM,QAAQ,MAAM,EAAE;GAC5C,MAAM,SAAS,SAAS,MAAM;AAC9B,OAAI,OACH,iBAAgB,KAAK,SAAS,OAAO,EAAE,OAAO;OAE9C,iBAAgB,KAAK,SAAS,OAAO,EAAE,kBAAkB,QAAQ;;;CAIpE,QAAQ,GAAG,SAAgB;AAC1B,MAAI,UAAU,SAAS,OAAO,SAAS,GAAG,KAAK,CAC9C,iBAAgB,MAAM,SAAS,QAAQ,EAAE,GAAG,KAAK;;CAGnD;;;;;;;;AASD,eAAsB,oBACrB,KACA,QACC;CACD,MAAM,EAAE,KAAK,MAAM,MAAM,OAAO,OAAO,OAAO,MAAM,YAAY;CAChE,MAAM,iBAAiB;AAEvB,KAAI,OACH,cAAa,OAAO;AAGrB,SAAQ,MAAM,OAAO;AACrB,SAAQ,OAAO,OAAO;AACtB,SAAQ,OAAO,OAAO;AACtB,SAAQ,QAAQ,OAAO;AACvB,SAAQ,QAAQ,OAAO;AACvB,SAAQ,QAAQ,OAAO;AACvB,SAAQ,OAAO,OAAO;AACtB,SAAQ,UAAU,OAAO;AAEzB,KAAI;AACH,SAAO,MAAM,KAAK;WACT;AACT,UAAQ,MAAM;AACd,UAAQ,OAAO;AACf,UAAQ,OAAO;AACf,UAAQ,QAAQ;AAChB,UAAQ,QAAQ;AAChB,UAAQ,QAAQ;AAChB,UAAQ,OAAO;AACf,UAAQ,UAAU;AAGlB,eAAa,eAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.d.mts","names":[],"sources":["../../../src/server/utils/read-file.ts"],"sourcesContent":[],"mappings":";iBAEsB,QAAA,gBAAwB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFile as readFile$1 } from "fs/promises";
|
|
2
|
+
|
|
3
|
+
//#region src/server/utils/read-file.ts
|
|
4
|
+
async function readFile(path) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(await readFile$1(path, "utf-8"));
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { readFile };
|
|
14
|
+
//# sourceMappingURL=read-file.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.mjs","names":["_readFile"],"sources":["../../../src/server/utils/read-file.ts"],"sourcesContent":["import { readFile as _readFile } from 'fs/promises'\n\nexport async function readFile(path: string): Promise<any | null> {\n\ttry {\n\t\treturn JSON.parse(await _readFile(path, 'utf-8'))\n\t} catch {\n\t\treturn null\n\t}\n}\n"],"mappings":";;;AAEA,eAAsB,SAAS,MAAmC;AACjE,KAAI;AACH,SAAO,KAAK,MAAM,MAAMA,WAAU,MAAM,QAAQ,CAAC;SAC1C;AACP,SAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/server/utils/resolve-path-with-extensions.d.ts
|
|
2
|
+
interface ResolvePathWithExtensionsOptions {
|
|
3
|
+
path: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
extensions: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Finds the first matching file from a list of extensions.
|
|
9
|
+
* Performs fs.access on each candidate path in parallel and returns the first match.
|
|
10
|
+
* If multiple matches are found, returns the first but logs a warning about duplicates.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The search options
|
|
13
|
+
* @param options.path - The base directory path
|
|
14
|
+
* @param options.fileName - The file name (without extension)
|
|
15
|
+
* @param options.extensions - Array of extensions to check (e.g. ['.tsx', '.ts', '.js'])
|
|
16
|
+
* @returns The full absolute path to the first matching file or null if no matching files are found
|
|
17
|
+
*/
|
|
18
|
+
declare function resolvePathWithExtensions(options: ResolvePathWithExtensionsOptions): Promise<string | null>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { resolvePathWithExtensions };
|
|
21
|
+
//# sourceMappingURL=resolve-path-with-extensions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-path-with-extensions.d.mts","names":[],"sources":["../../../src/server/utils/resolve-path-with-extensions.ts"],"sourcesContent":[],"mappings":";UAIU,gCAAA;EAAA,IAAA,EAAA,MAAA;EAkBY,QAAA,EAAA,MAAA;;;;;;;;;;;;;;iBAAA,yBAAA,UAAmC,mCAAmC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { logger } from "./log.mjs";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import { join, resolve } from "path";
|
|
4
|
+
|
|
5
|
+
//#region src/server/utils/resolve-path-with-extensions.ts
|
|
6
|
+
/**
|
|
7
|
+
* Finds the first matching file from a list of extensions.
|
|
8
|
+
* Performs fs.access on each candidate path in parallel and returns the first match.
|
|
9
|
+
* If multiple matches are found, returns the first but logs a warning about duplicates.
|
|
10
|
+
*
|
|
11
|
+
* @param options - The search options
|
|
12
|
+
* @param options.path - The base directory path
|
|
13
|
+
* @param options.fileName - The file name (without extension)
|
|
14
|
+
* @param options.extensions - Array of extensions to check (e.g. ['.tsx', '.ts', '.js'])
|
|
15
|
+
* @returns The full absolute path to the first matching file or null if no matching files are found
|
|
16
|
+
*/
|
|
17
|
+
async function resolvePathWithExtensions(options) {
|
|
18
|
+
const { path, fileName, extensions } = options;
|
|
19
|
+
const potentialFiles = extensions.map((ext) => join(path, `${fileName}${ext}`));
|
|
20
|
+
const filePaths = (await Promise.all(potentialFiles.map(async (path$1) => {
|
|
21
|
+
try {
|
|
22
|
+
await fs.access(path$1);
|
|
23
|
+
return path$1;
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}))).filter((path$1) => Boolean(path$1));
|
|
28
|
+
if (filePaths.length === 0) {
|
|
29
|
+
const expected = extensions.map((ext) => `${fileName}${ext}`).join(", ");
|
|
30
|
+
throw new Error(`No "${fileName}" file found in "${path}". Expected one of: ${expected}`);
|
|
31
|
+
}
|
|
32
|
+
const filePath = filePaths[0];
|
|
33
|
+
if (filePaths.length > 1) logger.warn(`Warning: Multiple "${fileName}" files found in "${path}". Pick one extension and remove the others. Using ${filePath}`);
|
|
34
|
+
return resolve(filePath);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { resolvePathWithExtensions };
|
|
39
|
+
//# sourceMappingURL=resolve-path-with-extensions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-path-with-extensions.mjs","names":["path"],"sources":["../../../src/server/utils/resolve-path-with-extensions.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport { join, resolve } from 'path'\nimport { logger } from './log'\n\ninterface ResolvePathWithExtensionsOptions {\n\tpath: string\n\tfileName: string\n\textensions: string[]\n}\n\n/**\n * Finds the first matching file from a list of extensions.\n * Performs fs.access on each candidate path in parallel and returns the first match.\n * If multiple matches are found, returns the first but logs a warning about duplicates.\n *\n * @param options - The search options\n * @param options.path - The base directory path\n * @param options.fileName - The file name (without extension)\n * @param options.extensions - Array of extensions to check (e.g. ['.tsx', '.ts', '.js'])\n * @returns The full absolute path to the first matching file or null if no matching files are found\n */\n\nexport async function resolvePathWithExtensions(options: ResolvePathWithExtensionsOptions): Promise<string | null> {\n\tconst { path, fileName, extensions } = options\n\n\tconst potentialFiles = extensions.map(ext => join(path, `${fileName}${ext}`))\n\n\tconst filePaths = (\n\t\tawait Promise.all(\n\t\t\tpotentialFiles.map(async path => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.access(path)\n\t\t\t\t\treturn path\n\t\t\t\t} catch {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t).filter((path): path is string => Boolean(path))\n\n\tconst noFileFound = filePaths.length === 0\n\n\tif (noFileFound) {\n\t\tconst expected = extensions.map(ext => `${fileName}${ext}`).join(', ')\n\t\tthrow new Error(`No \"${fileName}\" file found in \"${path}\". Expected one of: ${expected}`)\n\t}\n\n\tconst filePath = filePaths[0]\n\n\tconst multipleFilesFound = filePaths.length > 1\n\n\tif (multipleFilesFound) {\n\t\tlogger.warn(\n\t\t\t`Warning: Multiple \"${fileName}\" files found in \"${path}\". Pick one extension and remove the others. Using ${filePath}`\n\t\t)\n\t}\n\n\treturn resolve(filePath)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,eAAsB,0BAA0B,SAAmE;CAClH,MAAM,EAAE,MAAM,UAAU,eAAe;CAEvC,MAAM,iBAAiB,WAAW,KAAI,QAAO,KAAK,MAAM,GAAG,WAAW,MAAM,CAAC;CAE7E,MAAM,aACL,MAAM,QAAQ,IACb,eAAe,IAAI,OAAM,WAAQ;AAChC,MAAI;AACH,SAAM,GAAG,OAAOA,OAAK;AACrB,UAAOA;UACA;AACP,UAAO;;GAEP,CACF,EACA,QAAQ,WAAyB,QAAQA,OAAK,CAAC;AAIjD,KAFoB,UAAU,WAAW,GAExB;EAChB,MAAM,WAAW,WAAW,KAAI,QAAO,GAAG,WAAW,MAAM,CAAC,KAAK,KAAK;AACtE,QAAM,IAAI,MAAM,OAAO,SAAS,mBAAmB,KAAK,sBAAsB,WAAW;;CAG1F,MAAM,WAAW,UAAU;AAI3B,KAF2B,UAAU,SAAS,EAG7C,QAAO,KACN,sBAAsB,SAAS,oBAAoB,KAAK,qDAAqD,WAC7G;AAGF,QAAO,QAAQ,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../../../src/server/utils/schema.ts"],"sourcesContent":[],"mappings":";;;iBAKsB,aAAA,mBAAgC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEFAULT_SCHEMA_FILE_NAME } from "../constants.mjs";
|
|
2
|
+
import { resolvePathWithExtensions } from "./resolve-path-with-extensions.mjs";
|
|
3
|
+
import standard_schema_validate_default from "./standard-schema-validate.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/server/utils/schema.ts
|
|
6
|
+
async function getSchemaPath(dataDir) {
|
|
7
|
+
const fileName = process.env.FMT_SCHEMA_FILE_NAME || DEFAULT_SCHEMA_FILE_NAME;
|
|
8
|
+
try {
|
|
9
|
+
return await resolvePathWithExtensions({
|
|
10
|
+
path: dataDir,
|
|
11
|
+
fileName,
|
|
12
|
+
extensions: [".ts", ".js"]
|
|
13
|
+
});
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getSchemaPath, standard_schema_validate_default as validate };
|
|
21
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../../../src/server/utils/schema.ts"],"sourcesContent":["import { resolvePathWithExtensions } from './resolve-path-with-extensions'\nimport { DEFAULT_SCHEMA_FILE_NAME } from '../constants'\n\nexport { default as validate } from './standard-schema-validate'\n\nexport async function getSchemaPath(dataDir: string): Promise<string | null> {\n\tconst fileName = process.env.FMT_SCHEMA_FILE_NAME || DEFAULT_SCHEMA_FILE_NAME\n\n\ttry {\n\t\tconst result = await resolvePathWithExtensions({\n\t\t\tpath: dataDir,\n\t\t\tfileName,\n\t\t\textensions: ['.ts', '.js']\n\t\t})\n\n\t\treturn result\n\t} catch (error) {\n\t\treturn null\n\t}\n}\n"],"mappings":";;;;;AAKA,eAAsB,cAAc,SAAyC;CAC5E,MAAM,WAAW,QAAQ,IAAI,wBAAwB;AAErD,KAAI;AAOH,SANe,MAAM,0BAA0B;GAC9C,MAAM;GACN;GACA,YAAY,CAAC,OAAO,MAAM;GAC1B,CAAC;UAGM,OAAO;AACf,SAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
|
|
3
|
+
//#region src/server/utils/standard-schema-validate.d.ts
|
|
4
|
+
declare function validate<TSchema extends StandardSchemaV1>(schema: TSchema, input: unknown): Promise<{
|
|
5
|
+
ok: true;
|
|
6
|
+
data: StandardSchemaV1.InferOutput<TSchema>;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
errors: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
10
|
+
}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { validate as default, validate };
|
|
13
|
+
//# sourceMappingURL=standard-schema-validate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-schema-validate.d.mts","names":[],"sources":["../../../src/server/utils/standard-schema-validate.ts"],"sourcesContent":[],"mappings":";;;iBASsB,yBAAyB,0BACtC,0BAEN;;EAHmB,IAAA,EAID,gBAAA,CAAiB,WAJR,CAIoB,OAJpB,CAAA;CAAiB,GAAA;EACtC,EAAA,EAAA,KAAA;EAGyC,MAAA,EAC1B,aAD0B,CACZ,gBAAA,CAAiB,KADL,CAAA;CAA7B,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/server/utils/standard-schema-validate.ts
|
|
2
|
+
function hasIssues(x) {
|
|
3
|
+
return typeof x === "object" && x !== null && "issues" in x;
|
|
4
|
+
}
|
|
5
|
+
async function validate(schema, input) {
|
|
6
|
+
let result = schema["~standard"].validate(input);
|
|
7
|
+
if (result instanceof Promise) result = await result;
|
|
8
|
+
if (hasIssues(result)) return {
|
|
9
|
+
ok: false,
|
|
10
|
+
errors: result.issues ?? []
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
ok: true,
|
|
14
|
+
data: result.value
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var standard_schema_validate_default = validate;
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { standard_schema_validate_default as default, validate };
|
|
21
|
+
//# sourceMappingURL=standard-schema-validate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-schema-validate.mjs","names":[],"sources":["../../../src/server/utils/standard-schema-validate.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec'\n\ntype Failure = { issues: ReadonlyArray<StandardSchemaV1.Issue> }\ntype Success<T> = { value: T }\n\nfunction hasIssues(x: unknown): x is Failure {\n\treturn typeof x === 'object' && x !== null && 'issues' in x\n}\n\nexport async function validate<TSchema extends StandardSchemaV1>(\n\tschema: TSchema,\n\tinput: unknown\n): Promise<\n\t| { ok: true; data: StandardSchemaV1.InferOutput<TSchema> }\n\t| { ok: false; errors: ReadonlyArray<StandardSchemaV1.Issue> }\n> {\n\tlet result = schema['~standard'].validate(input)\n\tif (result instanceof Promise) result = await result\n\n\tif (hasIssues(result)) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terrors: result.issues ?? []\n\t\t}\n\t}\n\n\treturn {\n\t\tok: true,\n\t\tdata: (result as Success<StandardSchemaV1.InferOutput<TSchema>>).value\n\t}\n}\n\nexport default validate\n"],"mappings":";AAKA,SAAS,UAAU,GAA0B;AAC5C,QAAO,OAAO,MAAM,YAAY,MAAM,QAAQ,YAAY;;AAG3D,eAAsB,SACrB,QACA,OAIC;CACD,IAAI,SAAS,OAAO,aAAa,SAAS,MAAM;AAChD,KAAI,kBAAkB,QAAS,UAAS,MAAM;AAE9C,KAAI,UAAU,OAAO,CACpB,QAAO;EACN,IAAI;EACJ,QAAQ,OAAO,UAAU,EAAE;EAC3B;AAGF,QAAO;EACN,IAAI;EACJ,MAAO,OAA0D;EACjE;;AAGF,uCAAe"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/server/utils/suggest-similar.d.ts
|
|
2
|
+
interface SuggestSimilarArgs {
|
|
3
|
+
word: string;
|
|
4
|
+
candidates: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
declare function suggestSimilar(args: SuggestSimilarArgs): string[];
|
|
7
|
+
//#endregion
|
|
8
|
+
export { suggestSimilar };
|
|
9
|
+
//# sourceMappingURL=suggest-similar.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest-similar.d.mts","names":[],"sources":["../../../src/server/utils/suggest-similar.ts"],"sourcesContent":[],"mappings":";UAiDU,kBAAA;EAAA,IAAA,EAAA,MAAA;EAOM,UAAA,EAAA,SAAc,MAAA,EAAA;;iBAAd,cAAA,OAAqB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/server/utils/suggest-similar.ts
|
|
2
|
+
const MAX_EDIT_DISTANCE = 3;
|
|
3
|
+
const MIN_SIMILARITY = .4;
|
|
4
|
+
function editDistance(source, target) {
|
|
5
|
+
if (Math.abs(source.length - target.length) > MAX_EDIT_DISTANCE) return Math.max(source.length, target.length);
|
|
6
|
+
const distances = [];
|
|
7
|
+
for (let row = 0; row <= source.length; row++) distances[row] = [row];
|
|
8
|
+
for (let column = 0; column <= target.length; column++) distances[0][column] = column;
|
|
9
|
+
for (let column = 1; column <= target.length; column++) for (let row = 1; row <= source.length; row++) {
|
|
10
|
+
const cost = source[row - 1] === target[column - 1] ? 0 : 1;
|
|
11
|
+
distances[row][column] = Math.min(distances[row - 1][column] + 1, distances[row][column - 1] + 1, distances[row - 1][column - 1] + cost);
|
|
12
|
+
if (row > 1 && column > 1 && source[row - 1] === target[column - 2] && source[row - 2] === target[column - 1]) distances[row][column] = Math.min(distances[row][column], distances[row - 2][column - 2] + 1);
|
|
13
|
+
}
|
|
14
|
+
return distances[source.length][target.length];
|
|
15
|
+
}
|
|
16
|
+
function suggestSimilar(args) {
|
|
17
|
+
const { word, candidates } = args;
|
|
18
|
+
if (candidates.length === 0) return [];
|
|
19
|
+
const uniqueCandidates = Array.from(new Set(candidates));
|
|
20
|
+
let similar = [];
|
|
21
|
+
let bestDistance = MAX_EDIT_DISTANCE;
|
|
22
|
+
for (const candidate of uniqueCandidates) {
|
|
23
|
+
if (candidate.length <= 1) continue;
|
|
24
|
+
const distance = editDistance(word, candidate);
|
|
25
|
+
const length = Math.max(word.length, candidate.length);
|
|
26
|
+
if ((length - distance) / length <= MIN_SIMILARITY) continue;
|
|
27
|
+
if (distance < bestDistance) {
|
|
28
|
+
bestDistance = distance;
|
|
29
|
+
similar = [candidate];
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (distance === bestDistance) similar.push(candidate);
|
|
33
|
+
}
|
|
34
|
+
return similar.sort((a, b) => a.localeCompare(b));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { suggestSimilar };
|
|
39
|
+
//# sourceMappingURL=suggest-similar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest-similar.mjs","names":["distances: number[][]","similar: string[]"],"sources":["../../../src/server/utils/suggest-similar.ts"],"sourcesContent":["// \"Did you mean\" matching, ported from commander's suggestSimilar so our\n// suggestions behave like the ones the CLI already shows for unknown flags.\n// https://github.com/tj/commander.js/blob/master/lib/suggestSimilar.js\n\nconst MAX_EDIT_DISTANCE = 3\nconst MIN_SIMILARITY = 0.4\n\n// Optimal string alignment (Damerau-Levenshtein) distance between two words,\n// where no substring is edited more than once. `distances[row][column]` holds\n// the edit distance between the row-length prefix of `source` and the\n// column-length prefix of `target`.\nfunction editDistance(source: string, target: string): number {\n\t// Early exit with the worst case when the lengths are already too far apart.\n\tif (Math.abs(source.length - target.length) > MAX_EDIT_DISTANCE) {\n\t\treturn Math.max(source.length, target.length)\n\t}\n\n\tconst distances: number[][] = []\n\n\tfor (let row = 0; row <= source.length; row++) {\n\t\tdistances[row] = [row]\n\t}\n\n\tfor (let column = 0; column <= target.length; column++) {\n\t\tdistances[0][column] = column\n\t}\n\n\tfor (let column = 1; column <= target.length; column++) {\n\t\tfor (let row = 1; row <= source.length; row++) {\n\t\t\tconst cost = source[row - 1] === target[column - 1] ? 0 : 1\n\n\t\t\tdistances[row][column] = Math.min(\n\t\t\t\tdistances[row - 1][column] + 1, // deletion\n\t\t\t\tdistances[row][column - 1] + 1, // insertion\n\t\t\t\tdistances[row - 1][column - 1] + cost // substitution\n\t\t\t)\n\n\t\t\tconst isTransposition =\n\t\t\t\trow > 1 && column > 1 && source[row - 1] === target[column - 2] && source[row - 2] === target[column - 1]\n\n\t\t\tif (isTransposition) {\n\t\t\t\tdistances[row][column] = Math.min(distances[row][column], distances[row - 2][column - 2] + 1)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn distances[source.length][target.length]\n}\n\ninterface SuggestSimilarArgs {\n\tword: string\n\tcandidates: readonly string[]\n}\n\n// Return the candidates closest to `word`, best matches first. Empty when\n// nothing is similar enough to be a likely typo.\nexport function suggestSimilar(args: SuggestSimilarArgs): string[] {\n\tconst { word, candidates } = args\n\n\tif (candidates.length === 0) {\n\t\treturn []\n\t}\n\n\tconst uniqueCandidates = Array.from(new Set(candidates))\n\n\tlet similar: string[] = []\n\tlet bestDistance = MAX_EDIT_DISTANCE\n\n\tfor (const candidate of uniqueCandidates) {\n\t\tif (candidate.length <= 1) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst distance = editDistance(word, candidate)\n\t\tconst length = Math.max(word.length, candidate.length)\n\t\tconst similarity = (length - distance) / length\n\n\t\tif (similarity <= MIN_SIMILARITY) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif (distance < bestDistance) {\n\t\t\tbestDistance = distance\n\t\t\tsimilar = [candidate]\n\t\t\tcontinue\n\t\t}\n\n\t\tif (distance === bestDistance) {\n\t\t\tsimilar.push(candidate)\n\t\t}\n\t}\n\n\treturn similar.sort((a, b) => a.localeCompare(b))\n}\n"],"mappings":";AAIA,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AAMvB,SAAS,aAAa,QAAgB,QAAwB;AAE7D,KAAI,KAAK,IAAI,OAAO,SAAS,OAAO,OAAO,GAAG,kBAC7C,QAAO,KAAK,IAAI,OAAO,QAAQ,OAAO,OAAO;CAG9C,MAAMA,YAAwB,EAAE;AAEhC,MAAK,IAAI,MAAM,GAAG,OAAO,OAAO,QAAQ,MACvC,WAAU,OAAO,CAAC,IAAI;AAGvB,MAAK,IAAI,SAAS,GAAG,UAAU,OAAO,QAAQ,SAC7C,WAAU,GAAG,UAAU;AAGxB,MAAK,IAAI,SAAS,GAAG,UAAU,OAAO,QAAQ,SAC7C,MAAK,IAAI,MAAM,GAAG,OAAO,OAAO,QAAQ,OAAO;EAC9C,MAAM,OAAO,OAAO,MAAM,OAAO,OAAO,SAAS,KAAK,IAAI;AAE1D,YAAU,KAAK,UAAU,KAAK,IAC7B,UAAU,MAAM,GAAG,UAAU,GAC7B,UAAU,KAAK,SAAS,KAAK,GAC7B,UAAU,MAAM,GAAG,SAAS,KAAK,KACjC;AAKD,MAFC,MAAM,KAAK,SAAS,KAAK,OAAO,MAAM,OAAO,OAAO,SAAS,MAAM,OAAO,MAAM,OAAO,OAAO,SAAS,GAGvG,WAAU,KAAK,UAAU,KAAK,IAAI,UAAU,KAAK,SAAS,UAAU,MAAM,GAAG,SAAS,KAAK,EAAE;;AAKhG,QAAO,UAAU,OAAO,QAAQ,OAAO;;AAUxC,SAAgB,eAAe,MAAoC;CAClE,MAAM,EAAE,MAAM,eAAe;AAE7B,KAAI,WAAW,WAAW,EACzB,QAAO,EAAE;CAGV,MAAM,mBAAmB,MAAM,KAAK,IAAI,IAAI,WAAW,CAAC;CAExD,IAAIC,UAAoB,EAAE;CAC1B,IAAI,eAAe;AAEnB,MAAK,MAAM,aAAa,kBAAkB;AACzC,MAAI,UAAU,UAAU,EACvB;EAGD,MAAM,WAAW,aAAa,MAAM,UAAU;EAC9C,MAAM,SAAS,KAAK,IAAI,KAAK,QAAQ,UAAU,OAAO;AAGtD,OAFoB,SAAS,YAAY,UAEvB,eACjB;AAGD,MAAI,WAAW,cAAc;AAC5B,kBAAe;AACf,aAAU,CAAC,UAAU;AACrB;;AAGD,MAAI,aAAa,aAChB,SAAQ,KAAK,UAAU;;AAIzB,QAAO,QAAQ,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/server/utils/warn-lockstep.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Best-effort compile-time lockstep warning for the non-Studio paths (`format
|
|
4
|
+
* compile` and the bundler plugins). Studio blocks on drift at boot; here we
|
|
5
|
+
* only warn, so a drifted-but-not-yet-updated project still compiles.
|
|
6
|
+
*
|
|
7
|
+
* Uses the CLI's lockstep check so config.version stays the single source of
|
|
8
|
+
* truth across every path.
|
|
9
|
+
*/
|
|
10
|
+
declare function warnOnLockstepDrift(cwd: string): Promise<void>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { warnOnLockstepDrift };
|
|
13
|
+
//# sourceMappingURL=warn-lockstep.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn-lockstep.d.mts","names":[],"sources":["../../../src/server/utils/warn-lockstep.ts"],"sourcesContent":[],"mappings":";;AAYA;;;;;;;iBAAsB,mBAAA,eAAkC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { logger } from "./log.mjs";
|
|
2
|
+
import { getLockstepStatus } from "@format.dev/cli/lockstep";
|
|
3
|
+
|
|
4
|
+
//#region src/server/utils/warn-lockstep.ts
|
|
5
|
+
/**
|
|
6
|
+
* Best-effort compile-time lockstep warning for the non-Studio paths (`format
|
|
7
|
+
* compile` and the bundler plugins). Studio blocks on drift at boot; here we
|
|
8
|
+
* only warn, so a drifted-but-not-yet-updated project still compiles.
|
|
9
|
+
*
|
|
10
|
+
* Uses the CLI's lockstep check so config.version stays the single source of
|
|
11
|
+
* truth across every path.
|
|
12
|
+
*/
|
|
13
|
+
async function warnOnLockstepDrift(cwd) {
|
|
14
|
+
const { pinnedVersion, mismatches } = await getLockstepStatus(cwd);
|
|
15
|
+
if (!pinnedVersion || mismatches.length === 0) return;
|
|
16
|
+
logger.warn(`Some installed Format packages do not match config.version (${pinnedVersion}):`);
|
|
17
|
+
for (const mismatch of mismatches) logger.warn(` ${mismatch.name} ${mismatch.actual} (expected ${mismatch.expected})`);
|
|
18
|
+
logger.warn("Run `format update` to bring everything in line.");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { warnOnLockstepDrift };
|
|
23
|
+
//# sourceMappingURL=warn-lockstep.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn-lockstep.mjs","names":[],"sources":["../../../src/server/utils/warn-lockstep.ts"],"sourcesContent":["import { getLockstepStatus } from '@format.dev/cli/lockstep'\n\nimport { logger } from './log'\n\n/**\n * Best-effort compile-time lockstep warning for the non-Studio paths (`format\n * compile` and the bundler plugins). Studio blocks on drift at boot; here we\n * only warn, so a drifted-but-not-yet-updated project still compiles.\n *\n * Uses the CLI's lockstep check so config.version stays the single source of\n * truth across every path.\n */\nexport async function warnOnLockstepDrift(cwd: string): Promise<void> {\n\tconst { pinnedVersion, mismatches } = await getLockstepStatus(cwd)\n\n\tif (!pinnedVersion || mismatches.length === 0) {\n\t\treturn\n\t}\n\n\tlogger.warn(`Some installed Format packages do not match config.version (${pinnedVersion}):`)\n\n\tfor (const mismatch of mismatches) {\n\t\tlogger.warn(` ${mismatch.name} ${mismatch.actual} (expected ${mismatch.expected})`)\n\t}\n\n\tlogger.warn('Run `format update` to bring everything in line.')\n}\n"],"mappings":";;;;;;;;;;;;AAYA,eAAsB,oBAAoB,KAA4B;CACrE,MAAM,EAAE,eAAe,eAAe,MAAM,kBAAkB,IAAI;AAElE,KAAI,CAAC,iBAAiB,WAAW,WAAW,EAC3C;AAGD,QAAO,KAAK,+DAA+D,cAAc,IAAI;AAE7F,MAAK,MAAM,YAAY,WACtB,QAAO,KAAK,KAAK,SAAS,KAAK,IAAI,SAAS,OAAO,aAAa,SAAS,SAAS,GAAG;AAGtF,QAAO,KAAK,mDAAmD"}
|