weapp-tailwindcss 5.1.15 → 5.2.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.en.md +6 -0
- package/README.md +6 -0
- package/bin/{weapp-tailwindcss.js → weapp-tailwindcss.cjs} +1 -1
- package/dist/bundlers/framework-selector.d.ts +2 -2
- package/dist/bundlers/gulp/asset-emission-plan.d.ts +10 -0
- package/dist/bundlers/gulp/frameworks/native/index.d.ts +10 -3
- package/dist/bundlers/gulp/index.d.ts +10 -3
- package/dist/bundlers/gulp/module-graph.d.ts +1 -1
- package/dist/bundlers/gulp/runtime-snapshot.d.ts +4 -2
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +45 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +9 -2
- package/dist/bundlers/rspack/index.d.ts +2 -2
- package/dist/bundlers/shared/cache.d.ts +1 -1
- package/dist/bundlers/shared/css-imports.d.ts +1 -1
- package/dist/bundlers/shared/css-source-trace.d.ts +2 -2
- package/dist/bundlers/shared/framework-postcss.d.ts +21 -0
- package/dist/bundlers/shared/generator-css/candidates.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +19 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +5 -3
- package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +58 -0
- package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +32 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +13 -5
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +4 -4
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +7 -9
- package/dist/bundlers/shared/generator-css/types.d.ts +12 -3
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
- package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -1
- package/dist/bundlers/shared/generator-css.d.ts +9 -10
- package/dist/bundlers/shared/runtime-class-set/entries.d.ts +4 -0
- package/dist/bundlers/shared/runtime-class-set/escaped-candidates.d.ts +9 -0
- package/dist/bundlers/shared/runtime-class-set.d.ts +30 -0
- package/dist/bundlers/shared/runtime-entry-type.d.ts +8 -0
- package/dist/bundlers/shared/runtime-signatures.d.ts +8 -0
- package/dist/bundlers/shared/source-candidate-scan-signature.d.ts +13 -0
- package/dist/bundlers/shared/source-candidates/collector.d.ts +8 -0
- package/dist/bundlers/shared/source-candidates/scan-root.d.ts +10 -0
- package/dist/bundlers/{vite → shared}/source-candidates/script.d.ts +1 -1
- package/dist/bundlers/shared/source-candidates/store.d.ts +2 -0
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +69 -0
- package/dist/bundlers/shared/source-candidates.d.ts +4 -0
- package/dist/bundlers/shared/source-scan/css-entries.d.ts +18 -0
- package/dist/bundlers/shared/source-scan.d.ts +16 -0
- package/dist/bundlers/shared/static-config-content.d.ts +5 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +9 -1
- package/dist/bundlers/vite/bundle-entries.d.ts +1 -1
- package/dist/bundlers/vite/bundle-state.d.ts +11 -38
- package/dist/bundlers/vite/css-asset-identity.d.ts +11 -0
- package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
- package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
- package/dist/bundlers/vite/css-memory.d.ts +1 -2
- package/dist/bundlers/vite/frameworks/generic/index.d.ts +2 -2
- package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -2
- package/dist/bundlers/vite/frameworks/uni-app/index.d.ts +3 -3
- package/dist/bundlers/vite/frameworks/uni-app-x/index.d.ts +3 -3
- package/dist/bundlers/vite/frameworks/weapp-vite/index.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/asset-emission-plan.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +4 -4
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +34 -0
- package/dist/bundlers/vite/generate-bundle/css-composition-plan.d.ts +58 -0
- package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-entry-processing.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +21 -2
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-source-plan.d.ts +19 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +61 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +23 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +42 -0
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +3 -2
- package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
- package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +6 -5
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-plan.d.ts +35 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +5 -6
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +54 -0
- package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +3 -3
- package/dist/bundlers/vite/generate-bundle/runtime.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +1 -8
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +3 -3
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +14 -1
- package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/transform-scheduling.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +8 -7
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +3 -2
- package/dist/bundlers/vite/generate-bundle/validate-runtime-candidates.d.ts +22 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +7 -7
- package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +1 -4
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -3
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +2 -30
- package/dist/bundlers/vite/index.d.ts +3 -3
- package/dist/bundlers/vite/js-precheck.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +13 -0
- package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
- package/dist/bundlers/vite/processed-css-assets/empty-at-rule.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
- package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
- package/dist/bundlers/vite/resolve-app-type.d.ts +1 -1
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +3 -1
- package/dist/bundlers/vite/runtime-affecting-signature.d.ts +1 -2
- package/dist/bundlers/vite/runtime-candidate-entry.d.ts +9 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +4 -4
- package/dist/bundlers/vite/serve-css-generation.d.ts +2 -0
- package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
- package/dist/bundlers/vite/serve-root-import-shell.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -8
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +45 -0
- package/dist/bundlers/vite/shared/framework-post-plugin.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-processed-css-registry.d.ts +22 -0
- package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-candidates-plugin.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +38 -0
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -4
- package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +2 -13
- package/dist/bundlers/vite/source-candidates/scan-root.d.ts +1 -10
- package/dist/bundlers/vite/source-candidates.d.ts +1 -68
- package/dist/bundlers/vite/source-output-relations.d.ts +24 -0
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -18
- package/dist/bundlers/vite/source-scan.d.ts +2 -16
- package/dist/bundlers/vite/static-config-content.d.ts +1 -5
- package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
- package/dist/bundlers/vite/web-css-compat.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/asset-emission-plan.d.ts +18 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +2 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +11 -41
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +4 -10
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -219
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +3 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +3 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +2 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -4
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -2
- package/dist/bundlers/webpack/frameworks/generic/index.d.ts +2 -2
- package/dist/bundlers/webpack/frameworks/index.d.ts +7 -7
- package/dist/bundlers/webpack/frameworks/mpx/index.d.ts +2 -2
- package/dist/bundlers/webpack/frameworks/taro/index.d.ts +2 -2
- package/dist/bundlers/webpack/frameworks/uni-app/index.d.ts +2 -2
- package/dist/bundlers/webpack/frameworks/weapp-vite/index.d.ts +2 -2
- package/dist/bundlers/webpack/index.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +7 -2
- package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +1 -1
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
- package/dist/cli/context.d.ts +2 -2
- package/dist/cli/doctor.d.ts +1 -1
- package/dist/cli/helpers/options.d.ts +3 -3
- package/dist/cli/helpers.d.ts +1 -1
- package/dist/cli.cjs +37012 -0
- package/dist/cli.js +145 -176
- package/dist/compiler/artifact.d.ts +14 -0
- package/dist/compiler/candidate-index.d.ts +10 -0
- package/dist/compiler/compilation-change-coordinator.d.ts +28 -0
- package/dist/compiler/compilation-dependency-state.d.ts +16 -0
- package/dist/compiler/compilation-scope-graph.d.ts +31 -0
- package/dist/compiler/compilation-session-pool.d.ts +54 -0
- package/dist/compiler/compiler-owner-state.d.ts +3 -0
- package/dist/compiler/composition.d.ts +8 -0
- package/dist/compiler/emission-plan.d.ts +26 -0
- package/dist/compiler/index.d.ts +23 -0
- package/dist/compiler/invalidation.d.ts +3 -0
- package/dist/compiler/mode.d.ts +3 -0
- package/dist/compiler/owner-lifecycle.d.ts +1 -0
- package/dist/compiler/platform-adapter.d.ts +9 -0
- package/dist/compiler/runtime-affecting-signature.d.ts +2 -0
- package/dist/compiler/runtime-build-state.d.ts +6 -0
- package/dist/compiler/runtime-snapshot.d.ts +53 -0
- package/dist/compiler/scope-planner.d.ts +6 -0
- package/dist/compiler/semantic-css.d.ts +66 -0
- package/dist/compiler/session.d.ts +13 -0
- package/dist/compiler/shadow-gate.d.ts +26 -0
- package/dist/compiler/shadow-report-session.d.ts +37 -0
- package/dist/compiler/shadow-report.d.ts +15 -0
- package/dist/compiler/source-graph.d.ts +32 -0
- package/dist/compiler/tailwind-generation-session-pool.d.ts +22 -0
- package/dist/compiler/types.d.ts +95 -0
- package/dist/constants.d.ts +2 -2
- package/dist/context/compiler-context-cache.d.ts +1 -1
- package/dist/context/custom-attributes.d.ts +1 -1
- package/dist/context/handlers.d.ts +3 -3
- package/dist/context/index.d.ts +1 -1
- package/dist/context/runtime-package-replacements.d.ts +1 -1
- package/dist/context/style-options.d.ts +1 -1
- package/dist/context/tailwindcss.d.ts +3 -3
- package/dist/{context-VeFq_8vW.js → context-PZXBqrAJ.cjs} +32 -94
- package/dist/{context-BgGWVAmN.mjs → context-oTkxC5aZ.js} +23 -12
- package/dist/{core.mjs → core.cjs} +13 -12
- package/dist/core.d.ts +2 -2
- package/dist/core.js +12 -13
- package/dist/css-imports-DfNC3e6a.cjs +43 -0
- package/dist/css-loader-runtime-CSv0lKqV.cjs +11 -0
- package/dist/css-macro/postcss.cjs +19 -0
- package/dist/css-macro/postcss.js +2 -19
- package/dist/{css-macro.mjs → css-macro.cjs} +11 -8
- package/dist/css-macro.d.ts +2 -2
- package/dist/css-macro.js +8 -11
- package/dist/{defaults.mjs → defaults.cjs} +16 -11
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +11 -16
- package/dist/{escape.mjs → escape.cjs} +18 -4
- package/dist/escape.js +4 -18
- package/dist/framework/platform.d.ts +1 -1
- package/dist/{framework.mjs → framework.cjs} +47 -25
- package/dist/framework.d.ts +1 -1
- package/dist/framework.js +25 -47
- package/dist/generator/index.d.ts +6 -6
- package/dist/generator/options.d.ts +3 -3
- package/dist/generator/types.d.ts +2 -2
- package/dist/{generator-CEnUsjed.js → generator-C8D5cnbe.cjs} +730 -468
- package/dist/{generator-CEo920So.mjs → generator-CDdzqf1S.js} +747 -497
- package/dist/generator.cjs +12 -0
- package/dist/generator.d.ts +1 -1
- package/dist/generator.js +2 -12
- package/dist/{gulp-3m1dAiig.js → gulp-Cjcss8T_.cjs} +326 -241
- package/dist/{gulp-DP71z1jG.mjs → gulp-DNXQvDUw.js} +316 -234
- package/dist/gulp.cjs +5 -0
- package/dist/gulp.d.ts +4 -4
- package/dist/gulp.js +2 -5
- package/dist/{hmr-timing-1aS6--U7.mjs → hmr-timing-CuJwQzDc.js} +5230 -3259
- package/dist/hmr-timing-DMLfNfGG.cjs +555 -0
- package/dist/index.cjs +45 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -45
- package/dist/js/JsTokenUpdater.d.ts +1 -1
- package/dist/js/ModuleGraph.d.ts +3 -3
- package/dist/js/NodePathWalker.d.ts +2 -2
- package/dist/js/babel/process.d.ts +2 -2
- package/dist/js/babel.d.ts +8 -8
- package/dist/js/evalTransforms.d.ts +2 -2
- package/dist/js/fast-path/oxc.d.ts +1 -1
- package/dist/js/handlers.d.ts +2 -2
- package/dist/js/index.d.ts +3 -3
- package/dist/js/literal-transform.d.ts +1 -1
- package/dist/js/module-graph/ignored-exports.d.ts +4 -4
- package/dist/js/module-graph/types.d.ts +2 -2
- package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
- package/dist/js/precheck.d.ts +1 -1
- package/dist/js/replacement-cache.d.ts +1 -1
- package/dist/js/sourceAnalysis.d.ts +3 -3
- package/dist/js/taggedTemplateIgnore.d.ts +1 -1
- package/dist/object-Bvy6-w9r.js +47 -0
- package/dist/object-C_Vr6_S5.cjs +58 -0
- package/dist/options-DlvhQwWB.cjs +775 -0
- package/dist/pipeline-helpers-XtUmUlci.cjs +955 -0
- package/dist/postcss-html-transform.cjs +7 -0
- package/dist/postcss-html-transform.js +3 -5
- package/dist/postcss.cjs +15 -0
- package/dist/postcss.js +7 -11
- package/dist/presets/hbuilderx.d.ts +2 -2
- package/dist/presets/index.d.ts +4 -4
- package/dist/presets/shared.d.ts +1 -1
- package/dist/presets/taro.d.ts +2 -2
- package/dist/presets/uni-app-x.d.ts +1 -1
- package/dist/presets/uni-app.d.ts +2 -2
- package/dist/{presets.mjs → presets.cjs} +37 -24
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +24 -36
- package/dist/reset.cjs +19 -0
- package/dist/reset.d.ts +2 -2
- package/dist/reset.js +2 -19
- package/dist/{rolldown-runtime-emK7D4bc.js → rolldown-runtime-CVvi-lCc.cjs} +15 -0
- package/dist/{rspack.mjs → rspack.cjs} +10 -4
- package/dist/rspack.d.ts +3 -3
- package/dist/rspack.js +4 -10
- package/dist/runtime-branch/create-branch.d.ts +1 -1
- package/dist/runtime-branch/generator-target-env.d.ts +1 -1
- package/dist/runtime-branch/index.d.ts +2 -2
- package/dist/runtime-branch/mini-program.d.ts +1 -1
- package/dist/runtime-branch/native-app.d.ts +1 -1
- package/dist/runtime-branch/platform.d.ts +2 -2
- package/dist/runtime-branch/tailwind-version.d.ts +1 -1
- package/dist/runtime-branch/types.d.ts +2 -2
- package/dist/runtime-branch/web.d.ts +1 -1
- package/dist/runtime-branch.d.ts +1 -1
- package/dist/runtime-registry-Y7NrD2WH.cjs +31 -0
- package/dist/shared/classname-transform.d.ts +1 -1
- package/dist/shared/mpx-plugin-owner.d.ts +2 -0
- package/dist/shared/mpx.d.ts +1 -1
- package/dist/{source-candidate-scan-signature-Cf7259PR.mjs → source-candidate-scan-signature-B0S7f5P7.js} +26 -336
- package/dist/{source-candidate-scan-signature-BAahhiwb.js → source-candidate-scan-signature-BmSuoxR9.cjs} +31 -414
- package/dist/style-injector/internal.d.ts +6 -6
- package/dist/style-options-CEfXwZzX.cjs +75 -0
- package/dist/tailwindcss/candidates.d.ts +2 -2
- package/dist/tailwindcss/index.d.ts +1 -1
- package/dist/tailwindcss/runtime/cache.d.ts +1 -1
- package/dist/tailwindcss/runtime-factory.d.ts +2 -2
- package/dist/tailwindcss/runtime-options.d.ts +1 -1
- package/dist/tailwindcss/runtime-types.d.ts +2 -2
- package/dist/tailwindcss/runtime.d.ts +2 -2
- package/dist/tailwindcss/source-scan.d.ts +2 -2
- package/dist/tailwindcss/targets.d.ts +1 -1
- package/dist/tailwindcss/v4/config.d.ts +1 -1
- package/dist/tailwindcss/v4/css-sources.d.ts +2 -1
- package/dist/tailwindcss/v4/index.d.ts +2 -2
- package/dist/tailwindcss/v4/multi-runtime.d.ts +1 -1
- package/dist/tailwindcss/v4/runtime-factory.d.ts +5 -5
- package/dist/tailwindcss/v4/runtime-options.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +51 -0
- package/dist/tailwindcss/v4-engine/generator/native-session.d.ts +17 -0
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -1
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
- package/dist/tailwindcss/v4-engine/index.d.ts +5 -5
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -0
- package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-Cs94gJgf.cjs} +10 -770
- package/dist/{tailwindcss-xs704TRw.mjs → tailwindcss-D7TGiZR2.js} +23 -23
- package/dist/transform-BUEyOCT7.cjs +341 -0
- package/dist/transform-BbaPIji9.js +342 -0
- package/dist/typedoc.export.d.ts +4 -4
- package/dist/types/index.d.ts +7 -7
- package/dist/types/shared.d.ts +1 -1
- package/dist/types/typedoc-tailwindcss-runtime.d.ts +3 -3
- package/dist/types/user-defined-options/general.d.ts +5 -5
- package/dist/types/user-defined-options/important.d.ts +2 -2
- package/dist/types/user-defined-options/index.d.ts +9 -9
- package/dist/types/user-defined-options/matcher.d.ts +2 -2
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -0
- package/dist/uni-app-x/harmony.d.ts +1 -0
- package/dist/uni-app-x/index.d.ts +2 -2
- package/dist/uni-app-x/options.d.ts +1 -1
- package/dist/uni-app-x/style-asset/harmony-apply.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +3 -0
- package/dist/uni-app-x/style-asset.d.ts +5 -4
- package/dist/uni-app-x/transform.d.ts +1 -1
- package/dist/uni-app-x/vite/harmony-apply.d.ts +19 -0
- package/dist/uni-app-x/vite/native-target.d.ts +2 -0
- package/dist/uni-app-x/vite.d.ts +5 -2
- package/dist/unocss/index.d.ts +1 -1
- package/dist/utils/disabled.d.ts +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/{hmr-timing-B8p4f0ca.js → v4-generation-core-D7MuR5ZF.cjs} +4886 -3330
- package/dist/{vite-nXZEiwG0.mjs → vite-BI1TeUPO.js} +6148 -4522
- package/dist/{vite-DUVjMduj.js → vite-CBzmUTu-.cjs} +6267 -4666
- package/dist/vite.cjs +4 -0
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +2 -4
- package/dist/watch-dependencies-BZGubvuJ.cjs +40 -0
- package/dist/{weapp-tw-css-generation-loader.js → weapp-tw-css-generation-loader.cjs} +3 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +201 -0
- package/dist/{weapp-tw-runtime-classset-loader.js → weapp-tw-runtime-classset-loader.cjs} +19 -15
- package/dist/{webpack-nppysF4B.js → webpack-Dao6bWEj.cjs} +1000 -1473
- package/dist/{webpack-C_UUFRgj.mjs → webpack-dAY9h8r8.js} +1462 -1185
- package/dist/webpack.cjs +5 -0
- package/dist/webpack.d.ts +2 -2
- package/dist/webpack.js +2 -5
- package/dist/wxml/Tokenizer.d.ts +2 -2
- package/dist/wxml/custom-attributes.d.ts +1 -1
- package/dist/wxml/index.d.ts +2 -2
- package/dist/wxml/shared.d.ts +1 -1
- package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +1 -1
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
- package/dist/wxml/utils/codegen.d.ts +1 -1
- package/dist/wxml/utils/custom-template.d.ts +2 -2
- package/dist/wxml/utils/fragment-helpers.d.ts +2 -2
- package/dist/wxml/utils/fragment-updater.d.ts +2 -2
- package/dist/wxml/utils/template-fragments.d.ts +2 -2
- package/dist/wxml/utils.d.ts +5 -5
- package/dist/wxml-DSMNuUaP.cjs +38609 -0
- package/dist/{cli.mjs → wxml-IBzZSaQC.js} +237 -718
- package/package.json +59 -54
- package/dist/css-macro/postcss.mjs +0 -2
- package/dist/generator.mjs +0 -2
- package/dist/gulp.mjs +0 -2
- package/dist/index.mjs +0 -9
- package/dist/object-BJSWl-E5.mjs +0 -9
- package/dist/object-COs_Mw6p.js +0 -14
- package/dist/postcss-html-transform.mjs +0 -5
- package/dist/postcss.mjs +0 -11
- package/dist/reset.mjs +0 -2
- package/dist/transform-B_KM9sLX.mjs +0 -14930
- package/dist/transform-CcYptivi.js +0 -14927
- package/dist/types.mjs +0 -1
- package/dist/vite.mjs +0 -2
- package/dist/watch-dependencies-bpG6kmAf.js +0 -80
- package/dist/weapp-tw-css-import-rewrite-loader-DNk0IxAt.js +0 -10198
- package/dist/weapp-tw-css-import-rewrite-loader.js +0 -10
- package/dist/webpack.mjs +0 -2
- package/dist/wxml-Ce10eREX.js +0 -3979
- package/dist/wxml-DdGdeqaH.mjs +0 -3861
- /package/dist/{auto-2dg_uhEJ.mjs → auto-2dg_uhEJ.js} +0 -0
- /package/dist/{auto-DtU6f3X6.js → auto-DtU6f3X6.cjs} +0 -0
- /package/dist/bundlers/{vite → shared}/source-scan/dependencies.d.ts +0 -0
- /package/dist/{cache-options-DavPxrhC.js → cache-options-DavPxrhC.cjs} +0 -0
- /package/dist/{cache-options-DwBtLwQe.mjs → cache-options-DwBtLwQe.js} +0 -0
- /package/dist/{logger-BNzxZbZj.mjs → logger-BNzxZbZj.js} +0 -0
- /package/dist/{logger-TlKT3xmR.js → logger-TlKT3xmR.cjs} +0 -0
- /package/dist/{utils-CuKLf1Zv.js → utils-CuKLf1Zv.cjs} +0 -0
- /package/dist/{utils-MVwpU07P.mjs → utils-MVwpU07P.js} +0 -0
|
@@ -1,142 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
6
|
-
import { logger } from "@weapp-tailwindcss/logger";
|
|
1
|
+
import { n as _defineProperty, t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
2
|
+
import { n as HARD_PARSE_CACHE_MAX_ENTRIES, t as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH } from "./cache-options-DwBtLwQe.js";
|
|
3
|
+
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
7
4
|
import { LRUCache } from "lru-cache";
|
|
8
5
|
import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
|
|
9
|
-
import {
|
|
10
|
-
import "@weapp-tailwindcss/shared";
|
|
11
|
-
import { constants, existsSync, readFileSync } from "node:fs";
|
|
12
|
-
import _createDebug from "debug";
|
|
13
|
-
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
14
|
-
import { createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
15
|
-
import "micromatch";
|
|
16
|
-
import "fast-glob";
|
|
17
|
-
import "tailwindcss-config";
|
|
6
|
+
import { Parser } from "htmlparser2";
|
|
18
7
|
import _babelTraverse from "@babel/traverse";
|
|
19
|
-
import { parse } from "@babel/parser";
|
|
8
|
+
import { parse, parseExpression } from "@babel/parser";
|
|
20
9
|
import MagicString from "magic-string";
|
|
21
|
-
import "
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/debug/index.ts
|
|
27
|
-
const _debug = _createDebug("weapp-tw");
|
|
28
|
-
function createDebug(prefix) {
|
|
29
|
-
const debug = ((formatter, ...args) => {
|
|
30
|
-
return _debug((prefix ?? "") + formatter, ...args);
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(debug, "enabled", {
|
|
33
|
-
enumerable: false,
|
|
34
|
-
configurable: false,
|
|
35
|
-
get() {
|
|
36
|
-
return _debug.enabled;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return debug;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/utils/object.ts
|
|
43
|
-
function definedEntries(value) {
|
|
44
|
-
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
45
|
-
}
|
|
46
|
-
function omitUndefined(value) {
|
|
47
|
-
return Object.fromEntries(definedEntries(value));
|
|
48
|
-
}
|
|
49
|
-
createRequire(import.meta.url);
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
|
|
52
|
-
const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
|
|
53
|
-
new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
|
|
54
|
-
new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
|
|
55
|
-
new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/tailwindcss/source-scan.ts
|
|
58
|
-
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
59
|
-
"html",
|
|
60
|
-
"wxml",
|
|
61
|
-
"axml",
|
|
62
|
-
"jxml",
|
|
63
|
-
"ksml",
|
|
64
|
-
"ttml",
|
|
65
|
-
"qml",
|
|
66
|
-
"tyml",
|
|
67
|
-
"xhsml",
|
|
68
|
-
"swan",
|
|
69
|
-
"vue",
|
|
70
|
-
"mpx",
|
|
71
|
-
"js",
|
|
72
|
-
"jsx",
|
|
73
|
-
"ts",
|
|
74
|
-
"tsx"
|
|
75
|
-
];
|
|
76
|
-
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
77
|
-
"js",
|
|
78
|
-
"jsx",
|
|
79
|
-
"mjs",
|
|
80
|
-
"cjs",
|
|
81
|
-
"ts",
|
|
82
|
-
"tsx",
|
|
83
|
-
"mts",
|
|
84
|
-
"cts",
|
|
85
|
-
"vue",
|
|
86
|
-
"uvue",
|
|
87
|
-
"nvue",
|
|
88
|
-
"svelte",
|
|
89
|
-
"mpx",
|
|
90
|
-
"html",
|
|
91
|
-
"wxml",
|
|
92
|
-
"axml",
|
|
93
|
-
"jxml",
|
|
94
|
-
"ksml",
|
|
95
|
-
"ttml",
|
|
96
|
-
"qml",
|
|
97
|
-
"tyml",
|
|
98
|
-
"xhsml",
|
|
99
|
-
"swan",
|
|
100
|
-
"css",
|
|
101
|
-
"wxss",
|
|
102
|
-
"acss",
|
|
103
|
-
"jxss",
|
|
104
|
-
"ttss",
|
|
105
|
-
"qss",
|
|
106
|
-
"tyss",
|
|
107
|
-
"scss",
|
|
108
|
-
"sass",
|
|
109
|
-
"less",
|
|
110
|
-
"styl",
|
|
111
|
-
"stylus"
|
|
112
|
-
];
|
|
113
|
-
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
114
|
-
return `**/*.{${extensions.join(",")}}`;
|
|
115
|
-
}
|
|
116
|
-
createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
117
|
-
new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
118
|
-
createStyleHandler({
|
|
119
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
120
|
-
cssRemoveHoverPseudoClass: true,
|
|
121
|
-
isMainChunk: true,
|
|
122
|
-
majorVersion: 4
|
|
123
|
-
});
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/tailwindcss/v4-engine/generator.ts
|
|
126
|
-
const INCREMENTAL_GENERATE_CACHE_MAX = 8;
|
|
127
|
-
const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
|
|
128
|
-
new LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
|
|
129
|
-
new LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
|
|
130
|
-
createRequire(import.meta.url);
|
|
131
|
-
createDebug("[tailwindcss:runtime] ");
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/tailwindcss/runtime-logs.ts
|
|
134
|
-
const runtimeLogDedupeHolder = globalThis;
|
|
135
|
-
runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
|
|
136
|
-
createRequire(import.meta.url);
|
|
137
|
-
const globalCacheHolder = globalThis;
|
|
138
|
-
globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
|
|
139
|
-
//#endregion
|
|
10
|
+
import _createDebug from "debug";
|
|
11
|
+
import { MappingChars2String, escape } from "@weapp-core/escape";
|
|
12
|
+
import * as t from "@babel/types";
|
|
140
13
|
//#region src/babel/index.ts
|
|
141
14
|
function _interopDefaultCompat(e) {
|
|
142
15
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
@@ -248,6 +121,22 @@ function babelParse(code, opts = {}) {
|
|
|
248
121
|
return result;
|
|
249
122
|
}
|
|
250
123
|
//#endregion
|
|
124
|
+
//#region src/debug/index.ts
|
|
125
|
+
const _debug = _createDebug("weapp-tw");
|
|
126
|
+
function createDebug(prefix) {
|
|
127
|
+
const debug = ((formatter, ...args) => {
|
|
128
|
+
return _debug((prefix ?? "") + formatter, ...args);
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(debug, "enabled", {
|
|
131
|
+
enumerable: false,
|
|
132
|
+
configurable: false,
|
|
133
|
+
get() {
|
|
134
|
+
return _debug.enabled;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return debug;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
251
140
|
//#region src/wxml/shared.ts
|
|
252
141
|
const NEWLINE_RE = /[\n\r]+/g;
|
|
253
142
|
function replaceWxml(original, options = {
|
|
@@ -836,44 +725,6 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
836
725
|
}
|
|
837
726
|
}
|
|
838
727
|
//#endregion
|
|
839
|
-
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
|
|
840
|
-
function _typeof(o) {
|
|
841
|
-
"@babel/helpers - typeof";
|
|
842
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
843
|
-
return typeof o;
|
|
844
|
-
} : function(o) {
|
|
845
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
846
|
-
}, _typeof(o);
|
|
847
|
-
}
|
|
848
|
-
//#endregion
|
|
849
|
-
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
|
|
850
|
-
function toPrimitive(t, r) {
|
|
851
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
852
|
-
var e = t[Symbol.toPrimitive];
|
|
853
|
-
if (void 0 !== e) {
|
|
854
|
-
var i = e.call(t, r || "default");
|
|
855
|
-
if ("object" != _typeof(i)) return i;
|
|
856
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
857
|
-
}
|
|
858
|
-
return ("string" === r ? String : Number)(t);
|
|
859
|
-
}
|
|
860
|
-
//#endregion
|
|
861
|
-
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
|
|
862
|
-
function toPropertyKey(t) {
|
|
863
|
-
var i = toPrimitive(t, "string");
|
|
864
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
865
|
-
}
|
|
866
|
-
//#endregion
|
|
867
|
-
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
|
|
868
|
-
function _defineProperty(e, r, t) {
|
|
869
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
870
|
-
value: t,
|
|
871
|
-
enumerable: !0,
|
|
872
|
-
configurable: !0,
|
|
873
|
-
writable: !0
|
|
874
|
-
}) : e[r] = t, e;
|
|
875
|
-
}
|
|
876
|
-
//#endregion
|
|
877
728
|
//#region src/js/JsTokenUpdater.ts
|
|
878
729
|
/**
|
|
879
730
|
* Lightweight helper that batches updates to {@link MagicString}.
|
|
@@ -1611,8 +1462,91 @@ function jsHandler(rawSource, options) {
|
|
|
1611
1462
|
return result;
|
|
1612
1463
|
}
|
|
1613
1464
|
defaultEvalHandler = jsHandler;
|
|
1614
|
-
|
|
1615
|
-
|
|
1465
|
+
//#endregion
|
|
1466
|
+
//#region src/wxml/custom-attributes.ts
|
|
1467
|
+
function regTest(reg, str) {
|
|
1468
|
+
reg.lastIndex = 0;
|
|
1469
|
+
return reg.test(str);
|
|
1470
|
+
}
|
|
1471
|
+
function isPropsMatch(props, attr) {
|
|
1472
|
+
if (Array.isArray(props)) {
|
|
1473
|
+
let lowerAttr;
|
|
1474
|
+
for (const prop of props) if (typeof prop === "string") {
|
|
1475
|
+
lowerAttr ?? (lowerAttr = attr.toLowerCase());
|
|
1476
|
+
if (prop.toLowerCase() === lowerAttr) return true;
|
|
1477
|
+
} else if (regTest(prop, attr)) return true;
|
|
1478
|
+
return false;
|
|
1479
|
+
} else if (typeof props === "string") return props === attr;
|
|
1480
|
+
else return regTest(props, attr);
|
|
1481
|
+
}
|
|
1482
|
+
function createAttributeMatcher(entities) {
|
|
1483
|
+
if (!entities || entities.length === 0) return;
|
|
1484
|
+
const wildcardAttributeRules = [];
|
|
1485
|
+
const tagAttributeRuleMap = /* @__PURE__ */ new Map();
|
|
1486
|
+
const regexpAttributeRules = [];
|
|
1487
|
+
for (const [selector, props] of entities) if (selector === "*") wildcardAttributeRules.push(props);
|
|
1488
|
+
else if (typeof selector === "string") {
|
|
1489
|
+
const list = tagAttributeRuleMap.get(selector);
|
|
1490
|
+
if (list) list.push(props);
|
|
1491
|
+
else tagAttributeRuleMap.set(selector, [props]);
|
|
1492
|
+
} else regexpAttributeRules.push([selector, props]);
|
|
1493
|
+
return (tag, attr) => {
|
|
1494
|
+
for (const props of wildcardAttributeRules) if (isPropsMatch(props, attr)) return true;
|
|
1495
|
+
const tagRules = tagAttributeRuleMap.get(tag);
|
|
1496
|
+
if (tagRules) {
|
|
1497
|
+
for (const props of tagRules) if (isPropsMatch(props, attr)) return true;
|
|
1498
|
+
}
|
|
1499
|
+
for (const [selector, props] of regexpAttributeRules) if (regTest(selector, tag) && isPropsMatch(props, attr)) return true;
|
|
1500
|
+
return false;
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
//#endregion
|
|
1504
|
+
//#region src/wxml/utils/codegen/legacy-visitor.ts
|
|
1505
|
+
function shouldSkipLegacyStringLiteral(path) {
|
|
1506
|
+
if (t.isMemberExpression(path.parent)) return true;
|
|
1507
|
+
return Boolean(t.isBinaryExpression(path.parent) && (t.isConditionalExpression(path.parentPath?.parent) || t.isLogicalExpression(path.parentPath?.parent)));
|
|
1508
|
+
}
|
|
1509
|
+
function createLegacyTraverseOptions(options, jsTokenUpdater) {
|
|
1510
|
+
const legacyReplaceOptions = {
|
|
1511
|
+
escapeMap: options.escapeMap,
|
|
1512
|
+
classNameSet: options.runtimeSet,
|
|
1513
|
+
needEscaped: true,
|
|
1514
|
+
alwaysEscape: true
|
|
1515
|
+
};
|
|
1516
|
+
return {
|
|
1517
|
+
StringLiteral(path) {
|
|
1518
|
+
if (shouldSkipLegacyStringLiteral(path)) return;
|
|
1519
|
+
jsTokenUpdater.addToken(replaceHandleValue(path, legacyReplaceOptions));
|
|
1520
|
+
},
|
|
1521
|
+
noScope: true
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
//#endregion
|
|
1525
|
+
//#region src/wxml/utils/codegen/legacy-rewriter.ts
|
|
1526
|
+
function rewriteLegacyExpression(match, options) {
|
|
1527
|
+
const ast = parseExpression(match);
|
|
1528
|
+
const jsTokenUpdater = new JsTokenUpdater();
|
|
1529
|
+
traverse(ast, createLegacyTraverseOptions(options, jsTokenUpdater));
|
|
1530
|
+
if (jsTokenUpdater.length === 0) return match;
|
|
1531
|
+
const ms = new MagicString(match);
|
|
1532
|
+
jsTokenUpdater.updateMagicString(ms);
|
|
1533
|
+
return ms.toString();
|
|
1534
|
+
}
|
|
1535
|
+
//#endregion
|
|
1536
|
+
//#region src/wxml/utils/codegen.ts
|
|
1537
|
+
const WRAP_EXPRESSION_HANDLER_OPTIONS = Object.freeze({ wrapExpression: true });
|
|
1538
|
+
function generateCode(match, options = {}) {
|
|
1539
|
+
try {
|
|
1540
|
+
const { jsHandler, runtimeSet, wrapExpression } = options;
|
|
1541
|
+
if (jsHandler && runtimeSet) {
|
|
1542
|
+
const initial = jsHandler(match, runtimeSet, wrapExpression ? WRAP_EXPRESSION_HANDLER_OPTIONS : void 0);
|
|
1543
|
+
if (!initial.error || wrapExpression) return initial.code;
|
|
1544
|
+
return jsHandler(match, runtimeSet, WRAP_EXPRESSION_HANDLER_OPTIONS).code;
|
|
1545
|
+
} else return rewriteLegacyExpression(match, options);
|
|
1546
|
+
} catch {
|
|
1547
|
+
return match;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1616
1550
|
//#endregion
|
|
1617
1551
|
//#region src/wxml/whitespace.ts
|
|
1618
1552
|
const WHITESPACE_CODES = /* @__PURE__ */ new Set([
|
|
@@ -1629,6 +1563,10 @@ function isWhitespace(char) {
|
|
|
1629
1563
|
if (char.length === 0) return false;
|
|
1630
1564
|
return WHITESPACE_CODES.has(char.charCodeAt(0));
|
|
1631
1565
|
}
|
|
1566
|
+
function isAllWhitespace(value) {
|
|
1567
|
+
for (let i = 0; i < value.length; i++) if (!WHITESPACE_CODES.has(value.charCodeAt(i))) return false;
|
|
1568
|
+
return true;
|
|
1569
|
+
}
|
|
1632
1570
|
//#endregion
|
|
1633
1571
|
//#region src/wxml/Tokenizer.ts
|
|
1634
1572
|
var Tokenizer = class {
|
|
@@ -1753,565 +1691,146 @@ var Tokenizer = class {
|
|
|
1753
1691
|
this.expressions = [];
|
|
1754
1692
|
}
|
|
1755
1693
|
};
|
|
1756
|
-
new Tokenizer();
|
|
1757
1694
|
//#endregion
|
|
1758
|
-
//#region src/
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
if (relative.startsWith("..")) return path.normalize(target);
|
|
1767
|
-
return relative.startsWith(".") ? relative : `.${path.sep}${relative}`;
|
|
1768
|
-
}
|
|
1769
|
-
//#endregion
|
|
1770
|
-
//#region src/cli/doctor/constants.ts
|
|
1771
|
-
const CONFIG_FILES = {
|
|
1772
|
-
tailwind: [
|
|
1773
|
-
"tailwind.config.js",
|
|
1774
|
-
"tailwind.config.cjs",
|
|
1775
|
-
"tailwind.config.mjs",
|
|
1776
|
-
"tailwind.config.ts"
|
|
1777
|
-
],
|
|
1778
|
-
postcss: [
|
|
1779
|
-
"postcss.config.js",
|
|
1780
|
-
"postcss.config.cjs",
|
|
1781
|
-
"postcss.config.mjs",
|
|
1782
|
-
"postcss.config.ts"
|
|
1783
|
-
],
|
|
1784
|
-
vite: [
|
|
1785
|
-
"vite.config.js",
|
|
1786
|
-
"vite.config.mjs",
|
|
1787
|
-
"vite.config.ts"
|
|
1788
|
-
],
|
|
1789
|
-
webpack: [
|
|
1790
|
-
"webpack.config.js",
|
|
1791
|
-
"webpack.config.cjs",
|
|
1792
|
-
"webpack.config.ts"
|
|
1793
|
-
]
|
|
1794
|
-
};
|
|
1795
|
-
const FRAMEWORK_DEPS = [
|
|
1796
|
-
["@tarojs/taro", "Taro"],
|
|
1797
|
-
["@dcloudio/uni-app", "uni-app"],
|
|
1798
|
-
["@mpxjs/core", "MPX"],
|
|
1799
|
-
["remax", "Remax"]
|
|
1800
|
-
];
|
|
1801
|
-
//#endregion
|
|
1802
|
-
//#region src/cli/doctor.ts
|
|
1803
|
-
function tryReadJson(file) {
|
|
1804
|
-
try {
|
|
1805
|
-
return JSON.parse(readFileSync(file, "utf8"));
|
|
1806
|
-
} catch {
|
|
1807
|
-
return;
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
function findFirstExisting(cwd, files) {
|
|
1811
|
-
return files.find((file) => existsSync(path.join(cwd, file)));
|
|
1812
|
-
}
|
|
1813
|
-
function readProjectPackageJson(cwd) {
|
|
1814
|
-
return tryReadJson(path.join(cwd, "package.json"));
|
|
1815
|
-
}
|
|
1816
|
-
function readDependencyVersion(cwd, packageName) {
|
|
1817
|
-
try {
|
|
1818
|
-
return tryReadJson(createRequire(path.join(cwd, "package.json")).resolve(`${packageName}/package.json`))?.version;
|
|
1819
|
-
} catch {
|
|
1820
|
-
return;
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
function collectDependencySpecs(pkg) {
|
|
1824
|
-
return {
|
|
1825
|
-
...pkg?.dependencies ?? {},
|
|
1826
|
-
...pkg?.devDependencies ?? {},
|
|
1827
|
-
...pkg?.optionalDependencies ?? {},
|
|
1828
|
-
...pkg?.peerDependencies ?? {}
|
|
1829
|
-
};
|
|
1830
|
-
}
|
|
1831
|
-
function detectPackageManager(cwd, pkg) {
|
|
1832
|
-
if (pkg?.packageManager) return pkg.packageManager;
|
|
1833
|
-
if (existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1834
|
-
if (existsSync(path.join(cwd, "package-lock.json"))) return "npm";
|
|
1835
|
-
if (existsSync(path.join(cwd, "yarn.lock"))) return "yarn";
|
|
1836
|
-
}
|
|
1837
|
-
function detectFrameworks(deps) {
|
|
1838
|
-
return FRAMEWORK_DEPS.filter(([dependency]) => dependency in deps).map(([, label]) => label);
|
|
1839
|
-
}
|
|
1840
|
-
function addCheck(checks, check) {
|
|
1841
|
-
checks.push(check);
|
|
1842
|
-
}
|
|
1843
|
-
function summarizeChecks(checks) {
|
|
1844
|
-
return checks.reduce((summary, check) => {
|
|
1845
|
-
summary[check.status] += 1;
|
|
1846
|
-
return summary;
|
|
1847
|
-
}, {
|
|
1848
|
-
ok: 0,
|
|
1849
|
-
warn: 0,
|
|
1850
|
-
error: 0,
|
|
1851
|
-
info: 0
|
|
1852
|
-
});
|
|
1853
|
-
}
|
|
1854
|
-
function hasDependency(deps, packageName) {
|
|
1855
|
-
return packageName in deps;
|
|
1856
|
-
}
|
|
1857
|
-
function getMajorVersion(version) {
|
|
1858
|
-
if (!version) return;
|
|
1859
|
-
return semver.parse(version)?.major;
|
|
1860
|
-
}
|
|
1861
|
-
function getDependencyMajor(deps, packageName) {
|
|
1862
|
-
const spec = deps[packageName];
|
|
1863
|
-
return spec ? semver.minVersion(spec)?.major : void 0;
|
|
1864
|
-
}
|
|
1865
|
-
function createDoctorReport(options = {}) {
|
|
1866
|
-
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
1867
|
-
const nodeVersion = options.nodeVersion ?? process.versions.node;
|
|
1868
|
-
const pkg = readProjectPackageJson(cwd);
|
|
1869
|
-
const deps = collectDependencySpecs(pkg);
|
|
1870
|
-
const checks = [];
|
|
1871
|
-
const packageManager = detectPackageManager(cwd, pkg);
|
|
1872
|
-
const frameworks = detectFrameworks(deps);
|
|
1873
|
-
const tailwindcssVersion = readDependencyVersion(cwd, "tailwindcss");
|
|
1874
|
-
const weappTailwindcssVersion = readDependencyVersion(cwd, "weapp-tailwindcss");
|
|
1875
|
-
const tailwindMajor = getMajorVersion(tailwindcssVersion) ?? getDependencyMajor(deps, "tailwindcss");
|
|
1876
|
-
const tailwindConfig = findFirstExisting(cwd, CONFIG_FILES.tailwind);
|
|
1877
|
-
const postcssConfig = findFirstExisting(cwd, CONFIG_FILES.postcss);
|
|
1878
|
-
const viteConfig = findFirstExisting(cwd, CONFIG_FILES.vite);
|
|
1879
|
-
const webpackConfig = findFirstExisting(cwd, CONFIG_FILES.webpack);
|
|
1880
|
-
addCheck(checks, pkg ? {
|
|
1881
|
-
id: "package-json",
|
|
1882
|
-
title: "package.json",
|
|
1883
|
-
status: "ok",
|
|
1884
|
-
message: "已找到项目 package.json。"
|
|
1885
|
-
} : {
|
|
1886
|
-
id: "package-json",
|
|
1887
|
-
title: "package.json",
|
|
1888
|
-
status: "error",
|
|
1889
|
-
message: "当前目录没有 package.json。",
|
|
1890
|
-
suggestion: "请在项目根目录运行 doctor,或通过 --cwd 指向项目根目录。"
|
|
1891
|
-
});
|
|
1892
|
-
addCheck(checks, semver.satisfies(nodeVersion, "^20.19.0 || >=22.12.0") ? {
|
|
1893
|
-
id: "node-version",
|
|
1894
|
-
title: "Node.js",
|
|
1895
|
-
status: "ok",
|
|
1896
|
-
message: `当前 Node.js ${nodeVersion} 满足版本要求 ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE}。`
|
|
1897
|
-
} : {
|
|
1898
|
-
id: "node-version",
|
|
1899
|
-
title: "Node.js",
|
|
1900
|
-
status: "error",
|
|
1901
|
-
message: `当前 Node.js ${nodeVersion} 不满足版本要求 ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE}。`,
|
|
1902
|
-
suggestion: "请升级 Node.js 后再安装或构建 weapp-tailwindcss 项目。"
|
|
1903
|
-
});
|
|
1904
|
-
addCheck(checks, packageManager ? {
|
|
1905
|
-
id: "package-manager",
|
|
1906
|
-
title: "包管理器",
|
|
1907
|
-
status: packageManager.startsWith("pnpm") ? "ok" : "info",
|
|
1908
|
-
message: `检测到 ${packageManager}。`
|
|
1909
|
-
} : {
|
|
1910
|
-
id: "package-manager",
|
|
1911
|
-
title: "包管理器",
|
|
1912
|
-
status: "info",
|
|
1913
|
-
message: "未检测到 lockfile 或 packageManager 字段。"
|
|
1914
|
-
});
|
|
1915
|
-
addCheck(checks, hasDependency(deps, "weapp-tailwindcss") || Boolean(weappTailwindcssVersion) ? {
|
|
1916
|
-
id: "weapp-tailwindcss",
|
|
1917
|
-
title: "weapp-tailwindcss",
|
|
1918
|
-
status: "ok",
|
|
1919
|
-
message: `检测到 weapp-tailwindcss${weappTailwindcssVersion ? `@${weappTailwindcssVersion}` : ""}。`
|
|
1920
|
-
} : {
|
|
1921
|
-
id: "weapp-tailwindcss",
|
|
1922
|
-
title: "weapp-tailwindcss",
|
|
1923
|
-
status: "warn",
|
|
1924
|
-
message: "未在当前项目依赖中检测到 weapp-tailwindcss。",
|
|
1925
|
-
suggestion: "如果这是业务项目,请安装 weapp-tailwindcss 并确认命令运行在项目根目录。"
|
|
1926
|
-
});
|
|
1927
|
-
addCheck(checks, hasDependency(deps, "tailwindcss") || Boolean(tailwindcssVersion) ? {
|
|
1928
|
-
id: "tailwindcss",
|
|
1929
|
-
title: "Tailwind CSS",
|
|
1930
|
-
status: "ok",
|
|
1931
|
-
message: `检测到 tailwindcss${tailwindcssVersion ? `@${tailwindcssVersion}` : ""}。`
|
|
1932
|
-
} : {
|
|
1933
|
-
id: "tailwindcss",
|
|
1934
|
-
title: "Tailwind CSS",
|
|
1935
|
-
status: "error",
|
|
1936
|
-
message: "未检测到 tailwindcss。",
|
|
1937
|
-
suggestion: "请安装 tailwindcss,并确认依赖可以从当前项目解析。"
|
|
1938
|
-
});
|
|
1939
|
-
addCheck(checks, tailwindConfig ? {
|
|
1940
|
-
id: "tailwind-config",
|
|
1941
|
-
title: "Tailwind 配置",
|
|
1942
|
-
status: "ok",
|
|
1943
|
-
message: `检测到 ${tailwindConfig}。`
|
|
1944
|
-
} : {
|
|
1945
|
-
id: "tailwind-config",
|
|
1946
|
-
title: "Tailwind 配置",
|
|
1947
|
-
status: tailwindMajor === 4 ? "info" : "warn",
|
|
1948
|
-
message: "未检测到 tailwind.config.*。",
|
|
1949
|
-
suggestion: tailwindMajor === 4 ? "Tailwind CSS v4 可以采用 CSS-first 配置;复杂 content/source 场景请补充配置文件。" : "请确认 Tailwind content/source 配置能够覆盖小程序页面、组件和脚本文件。"
|
|
1950
|
-
});
|
|
1951
|
-
addCheck(checks, postcssConfig ? {
|
|
1952
|
-
id: "postcss-config",
|
|
1953
|
-
title: "PostCSS 配置",
|
|
1954
|
-
status: "ok",
|
|
1955
|
-
message: `检测到 ${postcssConfig}。`
|
|
1956
|
-
} : {
|
|
1957
|
-
id: "postcss-config",
|
|
1958
|
-
title: "PostCSS 配置",
|
|
1959
|
-
status: viteConfig ? "info" : "warn",
|
|
1960
|
-
message: "未检测到 postcss.config.*。",
|
|
1961
|
-
suggestion: "如果通过 PostCSS 接入,请补充 postcss.config.*;如果通过 Vite/Taro 插件接入,可忽略此项。"
|
|
1962
|
-
});
|
|
1963
|
-
if (tailwindMajor === 4 && postcssConfig && !hasDependency(deps, "@tailwindcss/postcss")) addCheck(checks, {
|
|
1964
|
-
id: "tailwindcss-v4-postcss",
|
|
1965
|
-
title: "Tailwind v4 PostCSS",
|
|
1966
|
-
status: "warn",
|
|
1967
|
-
message: "Tailwind CSS v4 项目存在 PostCSS 配置,但未检测到 @tailwindcss/postcss。",
|
|
1968
|
-
suggestion: "如果 PostCSS 配置中仍直接使用 tailwindcss,请迁移到 @tailwindcss/postcss。"
|
|
1969
|
-
});
|
|
1970
|
-
addCheck(checks, frameworks.length > 0 ? {
|
|
1971
|
-
id: "framework",
|
|
1972
|
-
title: "框架识别",
|
|
1973
|
-
status: "ok",
|
|
1974
|
-
message: `检测到 ${frameworks.join(", ")}。`
|
|
1975
|
-
} : {
|
|
1976
|
-
id: "framework",
|
|
1977
|
-
title: "框架识别",
|
|
1978
|
-
status: "info",
|
|
1979
|
-
message: "未从依赖中识别出 Taro、uni-app、MPX 或 Remax。"
|
|
1980
|
-
});
|
|
1981
|
-
addCheck(checks, viteConfig || webpackConfig ? {
|
|
1982
|
-
id: "bundler-config",
|
|
1983
|
-
title: "构建器配置",
|
|
1984
|
-
status: "ok",
|
|
1985
|
-
message: `检测到 ${[viteConfig, webpackConfig].filter(Boolean).join(", ")}。`
|
|
1986
|
-
} : {
|
|
1987
|
-
id: "bundler-config",
|
|
1988
|
-
title: "构建器配置",
|
|
1989
|
-
status: "info",
|
|
1990
|
-
message: "未检测到 vite.config.* 或 webpack.config.*。"
|
|
1991
|
-
});
|
|
1992
|
-
return {
|
|
1993
|
-
cwd,
|
|
1994
|
-
nodeVersion,
|
|
1995
|
-
detected: {
|
|
1996
|
-
packageManager,
|
|
1997
|
-
frameworks,
|
|
1998
|
-
tailwindcssVersion,
|
|
1999
|
-
weappTailwindcssVersion
|
|
2000
|
-
},
|
|
2001
|
-
summary: summarizeChecks(checks),
|
|
2002
|
-
checks
|
|
2003
|
-
};
|
|
1695
|
+
//#region src/wxml/utils/fragment-helpers.ts
|
|
1696
|
+
function updateWhitespaceGap(ms, start, end, options) {
|
|
1697
|
+
const gap = ms.slice(start, end);
|
|
1698
|
+
if (isAllWhitespace(gap)) ms.update(start, end, replaceWxml(gap, {
|
|
1699
|
+
keepEOL: false,
|
|
1700
|
+
escapeMap: options.escapeMap,
|
|
1701
|
+
ignoreHead: true
|
|
1702
|
+
}));
|
|
2004
1703
|
}
|
|
2005
|
-
function
|
|
2006
|
-
|
|
1704
|
+
function updateWxmlSegment(ms, start, end, options, keepEOL, ignoreHead) {
|
|
1705
|
+
ms.update(start, end, replaceWxml(ms.slice(start, end), {
|
|
1706
|
+
keepEOL,
|
|
1707
|
+
escapeMap: options.escapeMap,
|
|
1708
|
+
ignoreHead
|
|
1709
|
+
}));
|
|
2007
1710
|
}
|
|
2008
|
-
function
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2011
|
-
`cwd: ${report.cwd}`,
|
|
2012
|
-
`summary: ${report.summary.error} error, ${report.summary.warn} warn, ${report.summary.ok} ok, ${report.summary.info} info`,
|
|
2013
|
-
""
|
|
2014
|
-
];
|
|
2015
|
-
for (const check of report.checks) {
|
|
2016
|
-
lines.push(`[${check.status}] ${check.title}: ${check.message}`);
|
|
2017
|
-
if (check.suggestion) lines.push(` -> ${check.suggestion}`);
|
|
2018
|
-
}
|
|
2019
|
-
return lines.join("\n");
|
|
1711
|
+
function updateExpressionSegment(ms, exp, options) {
|
|
1712
|
+
const code = `{{${generateCode(exp.value.slice(2, -2), options)}}}`;
|
|
1713
|
+
ms.update(exp.start, exp.end, code);
|
|
2020
1714
|
}
|
|
2021
1715
|
//#endregion
|
|
2022
|
-
//#region src/
|
|
2023
|
-
function
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
if (
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
return trimmed;
|
|
2038
|
-
});
|
|
2039
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
1716
|
+
//#region src/wxml/utils/fragment-updater.ts
|
|
1717
|
+
function handleEachClassFragment(ms, tokens, options = {}) {
|
|
1718
|
+
let previousEnd = 0;
|
|
1719
|
+
for (const token of tokens) {
|
|
1720
|
+
if (token.start > previousEnd) updateWhitespaceGap(ms, previousEnd, token.start, options);
|
|
1721
|
+
let p = token.start;
|
|
1722
|
+
if (token.expressions.length > 0) {
|
|
1723
|
+
for (const exp of token.expressions) {
|
|
1724
|
+
if (exp.start > token.start && p < exp.start) updateWxmlSegment(ms, p, exp.start, options, true, p > 0);
|
|
1725
|
+
updateExpressionSegment(ms, exp, options);
|
|
1726
|
+
p = exp.end;
|
|
1727
|
+
}
|
|
1728
|
+
if (token.end > p) updateWxmlSegment(ms, p, token.end, options, false, true);
|
|
1729
|
+
} else updateWxmlSegment(ms, token.start, token.end, options, false, false);
|
|
1730
|
+
previousEnd = token.end;
|
|
2040
1731
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
if (typeof value === "boolean") return value;
|
|
2046
|
-
if (typeof value === "string") {
|
|
2047
|
-
if (value === "true") return true;
|
|
2048
|
-
if (value === "false") return false;
|
|
1732
|
+
if (tokens.length > 0) {
|
|
1733
|
+
const lastToken = tokens[tokens.length - 1];
|
|
1734
|
+
if (!lastToken) return;
|
|
1735
|
+
if (lastToken.end < ms.original.length) updateWhitespaceGap(ms, lastToken.end, ms.original.length, options);
|
|
2049
1736
|
}
|
|
2050
|
-
if (value == null) return fallback;
|
|
2051
|
-
return Boolean(value);
|
|
2052
1737
|
}
|
|
2053
1738
|
//#endregion
|
|
2054
|
-
//#region src/
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
1739
|
+
//#region src/wxml/utils/template-fragments.ts
|
|
1740
|
+
/**
|
|
1741
|
+
* 模块级共享 Tokenizer 实例,避免每次调用都重新创建。
|
|
1742
|
+
* Tokenizer.run() 末尾已调用 reset(),天然支持复用。
|
|
1743
|
+
*/
|
|
1744
|
+
const sharedTokenizer = new Tokenizer();
|
|
1745
|
+
function templateReplacer(original, options = {}, tokenizer) {
|
|
1746
|
+
const ms = new MagicString(original);
|
|
1747
|
+
handleEachClassFragment(ms, (tokenizer ?? sharedTokenizer).run(ms.original), options);
|
|
1748
|
+
return ms.toString();
|
|
2059
1749
|
}
|
|
2060
1750
|
//#endregion
|
|
2061
|
-
//#region src/
|
|
2062
|
-
async function
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
function
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
1751
|
+
//#region src/wxml/utils/custom-template.ts
|
|
1752
|
+
async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
1753
|
+
const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options ?? {};
|
|
1754
|
+
const matchCustomAttribute = cachedMatcher ?? createAttributeMatcher(customAttributesEntities);
|
|
1755
|
+
const defaultTemplateHandlerEnabled = !disabledDefaultTemplateHandler;
|
|
1756
|
+
let replaceOptions;
|
|
1757
|
+
let cachedQuote;
|
|
1758
|
+
let s;
|
|
1759
|
+
let tag = "";
|
|
1760
|
+
let wxsArray;
|
|
1761
|
+
function getMagicString() {
|
|
1762
|
+
if (!s) s = new MagicString(rawSource);
|
|
1763
|
+
return s;
|
|
1764
|
+
}
|
|
1765
|
+
function getReplaceOptions(quote) {
|
|
1766
|
+
if (!replaceOptions) {
|
|
1767
|
+
replaceOptions = {
|
|
1768
|
+
...options,
|
|
1769
|
+
quote
|
|
1770
|
+
};
|
|
1771
|
+
cachedQuote = quote;
|
|
1772
|
+
return replaceOptions;
|
|
2078
1773
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
//#region src/cli/mount-options.ts
|
|
2083
|
-
const PATCH_COMMAND_OBSOLETE_NOTICE = "提示:weapp-tailwindcss@5 已由构建运行时接管 Tailwind CSS 处理,weapp-tw patch 已无需执行;请移除 package.json 中的 postinstall 钩子。";
|
|
2084
|
-
const obsoletePatchCommands = [
|
|
2085
|
-
"extract",
|
|
2086
|
-
"tokens",
|
|
2087
|
-
"init",
|
|
2088
|
-
"migrate",
|
|
2089
|
-
"restore",
|
|
2090
|
-
"validate"
|
|
2091
|
-
];
|
|
2092
|
-
function logPatchCommandObsoleteNotice() {
|
|
2093
|
-
logger.warn(PATCH_COMMAND_OBSOLETE_NOTICE);
|
|
2094
|
-
}
|
|
2095
|
-
function logObsoletePatchCommand(command) {
|
|
2096
|
-
logPatchCommandObsoleteNotice();
|
|
2097
|
-
logger.warn(`命令 "${command}" 来自旧版 tailwindcss-patch 工作流,当前版本无需执行。`);
|
|
2098
|
-
}
|
|
2099
|
-
const DEFAULT_VSCODE_SOURCES = [
|
|
2100
|
-
"not \"./dist\"",
|
|
2101
|
-
"not \"./unpackage\"",
|
|
2102
|
-
"./src/**/*.{wxml,axml,swan,qml,ttml,ux,uts}",
|
|
2103
|
-
"./src/**/*.{js,jsx,ts,tsx,mjs,cjs,wxs,sjs}",
|
|
2104
|
-
"./src/**/*.{vue,svelte,mpx,html,md,mdx}"
|
|
2105
|
-
];
|
|
2106
|
-
const SINGLE_QUOTE = "'";
|
|
2107
|
-
const DOUBLE_QUOTE = "\"";
|
|
2108
|
-
const BACKSLASH_RE = /\\/g;
|
|
2109
|
-
function toPosixPath(filepath) {
|
|
2110
|
-
return filepath.replace(BACKSLASH_RE, "/");
|
|
2111
|
-
}
|
|
2112
|
-
async function assertFileExists(filepath) {
|
|
2113
|
-
try {
|
|
2114
|
-
await access(filepath, constants.F_OK);
|
|
2115
|
-
} catch (error) {
|
|
2116
|
-
const err = error;
|
|
2117
|
-
if (err?.code === "ENOENT") throw new Error(`CSS entry file not found: ${filepath}`);
|
|
2118
|
-
throw err;
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
async function assertCanWrite(filepath, force) {
|
|
2122
|
-
try {
|
|
2123
|
-
await access(filepath, constants.F_OK);
|
|
2124
|
-
if (!force) throw new Error(`VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.`);
|
|
2125
|
-
} catch (error) {
|
|
2126
|
-
const err = error;
|
|
2127
|
-
if (err?.code === "ENOENT") return;
|
|
2128
|
-
throw err;
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
function toCssLiteral(value) {
|
|
2132
|
-
const normalized = toPosixPath(value);
|
|
2133
|
-
return JSON.stringify(normalized);
|
|
2134
|
-
}
|
|
2135
|
-
function formatSource(pattern) {
|
|
2136
|
-
const trimmed = pattern.trim();
|
|
2137
|
-
if (!trimmed) return null;
|
|
2138
|
-
if (trimmed.startsWith("@source ")) return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
|
|
2139
|
-
let body = trimmed;
|
|
2140
|
-
let keyword = "";
|
|
2141
|
-
if (body.startsWith("not ")) {
|
|
2142
|
-
keyword = "not ";
|
|
2143
|
-
body = body.slice(4).trim();
|
|
2144
|
-
} else if (body.startsWith("!")) {
|
|
2145
|
-
keyword = "not ";
|
|
2146
|
-
body = body.slice(1).trim();
|
|
2147
|
-
}
|
|
2148
|
-
if (!body) throw new Error("Invalid @source pattern: empty body.");
|
|
2149
|
-
if (!body.startsWith(SINGLE_QUOTE) && !body.startsWith(DOUBLE_QUOTE)) body = toCssLiteral(body);
|
|
2150
|
-
return `@source ${keyword}${body};`;
|
|
2151
|
-
}
|
|
2152
|
-
function resolveOutputPath(baseDir, output) {
|
|
2153
|
-
const target = output ?? ".vscode/weapp-tailwindcss.intellisense.css";
|
|
2154
|
-
return path.isAbsolute(target) ? path.normalize(target) : path.resolve(baseDir, target);
|
|
2155
|
-
}
|
|
2156
|
-
function resolveCssEntry(baseDir, entry) {
|
|
2157
|
-
return path.isAbsolute(entry) ? path.normalize(entry) : path.resolve(baseDir, entry);
|
|
2158
|
-
}
|
|
2159
|
-
function toRelativeImport(fromFile, targetFile) {
|
|
2160
|
-
const fromDir = path.dirname(fromFile);
|
|
2161
|
-
let relative = path.relative(fromDir, targetFile);
|
|
2162
|
-
if (!relative) relative = path.basename(targetFile);
|
|
2163
|
-
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
2164
|
-
return toPosixPath(relative);
|
|
2165
|
-
}
|
|
2166
|
-
async function generateVscodeIntellisenseEntry(options) {
|
|
2167
|
-
const baseDir = options.baseDir;
|
|
2168
|
-
const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
|
|
2169
|
-
await assertFileExists(cssEntryPath);
|
|
2170
|
-
const outputPath = resolveOutputPath(baseDir, options.output);
|
|
2171
|
-
await ensureDir(path.dirname(outputPath));
|
|
2172
|
-
await assertCanWrite(outputPath, options.force);
|
|
2173
|
-
const formattedSources = (options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES).map(formatSource).filter((statement) => Boolean(statement));
|
|
2174
|
-
const cssImport = toRelativeImport(outputPath, cssEntryPath);
|
|
2175
|
-
const separator = formattedSources.length > 0 ? [""] : [];
|
|
2176
|
-
await writeFile(outputPath, `${[
|
|
2177
|
-
"/*",
|
|
2178
|
-
" * Auto-generated by weapp-tailwindcss.",
|
|
2179
|
-
" * This file exists solely to activate Tailwind CSS IntelliSense in VS Code.",
|
|
2180
|
-
" * Do not import it in your actual mini-program bundles.",
|
|
2181
|
-
" */",
|
|
2182
|
-
"@import 'tailwindcss';",
|
|
2183
|
-
"",
|
|
2184
|
-
...formattedSources,
|
|
2185
|
-
...separator,
|
|
2186
|
-
`@import '${cssImport}';`,
|
|
2187
|
-
""
|
|
2188
|
-
].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n")}\n`, "utf8");
|
|
2189
|
-
return {
|
|
2190
|
-
outputPath,
|
|
2191
|
-
cssEntryPath
|
|
2192
|
-
};
|
|
2193
|
-
}
|
|
2194
|
-
//#endregion
|
|
2195
|
-
//#region src/cli.ts
|
|
2196
|
-
process.title = "node (weapp-tailwindcss)";
|
|
2197
|
-
if (!semver.satisfies(process.versions.node, "^20.19.0 || >=22.12.0")) logger.warn(`You are using Node.js ${process.versions.node}. For weapp-tailwindcss, Node.js version ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE} is required.`);
|
|
2198
|
-
function parseArgs(argv) {
|
|
2199
|
-
const options = {};
|
|
2200
|
-
const positional = [];
|
|
2201
|
-
for (let index = 0; index < argv.length; index++) {
|
|
2202
|
-
const arg = argv[index];
|
|
2203
|
-
if (arg === void 0) continue;
|
|
2204
|
-
if (!arg.startsWith("--")) {
|
|
2205
|
-
positional.push(arg);
|
|
2206
|
-
continue;
|
|
1774
|
+
if (cachedQuote !== quote) {
|
|
1775
|
+
replaceOptions.quote = quote;
|
|
1776
|
+
cachedQuote = quote;
|
|
2207
1777
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
1778
|
+
return replaceOptions;
|
|
1779
|
+
}
|
|
1780
|
+
function isDefaultTemplateAttribute(name) {
|
|
1781
|
+
if (name === "class" || name === "hover-class" || name === "virtualhostclass") return true;
|
|
1782
|
+
const lowerName = name.toLowerCase();
|
|
1783
|
+
return lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass";
|
|
1784
|
+
}
|
|
1785
|
+
const parser = new Parser({
|
|
1786
|
+
onopentagname(name) {
|
|
1787
|
+
tag = name;
|
|
1788
|
+
},
|
|
1789
|
+
onattribute(name, value, quote) {
|
|
1790
|
+
if (!value) return;
|
|
1791
|
+
const shouldHandleDefault = defaultTemplateHandlerEnabled && isDefaultTemplateAttribute(name);
|
|
1792
|
+
const shouldHandleCustom = matchCustomAttribute?.(tag, name) ?? false;
|
|
1793
|
+
if (!shouldHandleDefault && !shouldHandleCustom) return;
|
|
1794
|
+
getMagicString().update(parser.startIndex + name.length + 2, parser.endIndex - 1, templateReplacer(value, getReplaceOptions(quote)));
|
|
1795
|
+
},
|
|
1796
|
+
ontext(data) {
|
|
1797
|
+
if (inlineWxs && tag === "wxs") (wxsArray ?? (wxsArray = [])).push({
|
|
1798
|
+
data,
|
|
1799
|
+
endIndex: parser.endIndex + 1,
|
|
1800
|
+
startIndex: parser.startIndex
|
|
1801
|
+
});
|
|
1802
|
+
},
|
|
1803
|
+
onclosetag() {
|
|
1804
|
+
tag = "";
|
|
2217
1805
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
1806
|
+
}, { xmlMode: true });
|
|
1807
|
+
parser.write(rawSource);
|
|
1808
|
+
parser.end();
|
|
1809
|
+
if (jsHandler) for (const { data, endIndex, startIndex } of wxsArray ?? []) {
|
|
1810
|
+
const { code } = await jsHandler(data, runtimeSet);
|
|
1811
|
+
if (code !== data) getMagicString().update(startIndex, endIndex, code);
|
|
2222
1812
|
}
|
|
2223
|
-
return
|
|
2224
|
-
command: positional[0],
|
|
2225
|
-
options
|
|
2226
|
-
};
|
|
1813
|
+
return s?.toString() ?? rawSource;
|
|
2227
1814
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
}
|
|
2245
|
-
async function runStatus(options) {
|
|
2246
|
-
const payload = {
|
|
2247
|
-
required: false,
|
|
2248
|
-
status: "unnecessary",
|
|
2249
|
-
message: PATCH_COMMAND_OBSOLETE_NOTICE
|
|
2250
|
-
};
|
|
2251
|
-
if (toBoolean(options["json"], false)) {
|
|
2252
|
-
logger.log(JSON.stringify(payload, null, 2));
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
|
-
logPatchCommandObsoleteNotice();
|
|
2256
|
-
logger.success("无需检查 Tailwind CSS patch 状态。");
|
|
2257
|
-
}
|
|
2258
|
-
async function runVscodeEntry(options) {
|
|
2259
|
-
const resolvedCwd = resolveCliCwd(options.cwd);
|
|
2260
|
-
const baseDir = resolvedCwd ?? process.cwd();
|
|
2261
|
-
const cssEntry = readStringOption("css", options["css"]);
|
|
2262
|
-
if (!cssEntry) throw new Error("Option \"--css\" is required.");
|
|
2263
|
-
const result = await generateVscodeIntellisenseEntry({
|
|
2264
|
-
baseDir,
|
|
2265
|
-
cssEntry,
|
|
2266
|
-
output: readStringOption("output", options["output"]),
|
|
2267
|
-
sources: readStringArrayOption("source", options["source"]),
|
|
2268
|
-
force: toBoolean(options["force"], false)
|
|
2269
|
-
});
|
|
2270
|
-
logger.success(`VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}`);
|
|
2271
|
-
}
|
|
2272
|
-
async function runDoctor(options) {
|
|
2273
|
-
const report = createDoctorReport({ cwd: resolveCliCwd(options.cwd) });
|
|
2274
|
-
if (toBoolean(options["json"], false)) logger.log(JSON.stringify(report, null, 2));
|
|
2275
|
-
else logger.log(formatDoctorReport(report));
|
|
2276
|
-
if (hasDoctorFailure(report, toBoolean(options["strict"], false))) process.exitCode = 1;
|
|
2277
|
-
}
|
|
2278
|
-
async function main() {
|
|
2279
|
-
const { command, options } = parseArgs(process.argv.slice(2));
|
|
2280
|
-
await commandAction(async () => {
|
|
2281
|
-
switch (command) {
|
|
2282
|
-
case void 0:
|
|
2283
|
-
case "-h":
|
|
2284
|
-
case "--help":
|
|
2285
|
-
case "help":
|
|
2286
|
-
printHelp();
|
|
2287
|
-
return;
|
|
2288
|
-
case "-v":
|
|
2289
|
-
case "--version":
|
|
2290
|
-
case "version":
|
|
2291
|
-
logger.log(process.env["npm_package_version"] ?? "0.0.0");
|
|
2292
|
-
return;
|
|
2293
|
-
case "patch":
|
|
2294
|
-
case "install":
|
|
2295
|
-
await runPatch();
|
|
2296
|
-
return;
|
|
2297
|
-
case "status":
|
|
2298
|
-
await runStatus(options);
|
|
2299
|
-
return;
|
|
2300
|
-
case "vscode-entry":
|
|
2301
|
-
await runVscodeEntry(options);
|
|
2302
|
-
return;
|
|
2303
|
-
case "doctor":
|
|
2304
|
-
await runDoctor(options);
|
|
2305
|
-
return;
|
|
2306
|
-
default:
|
|
2307
|
-
if (obsoletePatchCommands.includes(command)) {
|
|
2308
|
-
logObsoletePatchCommand(command);
|
|
2309
|
-
return;
|
|
2310
|
-
}
|
|
2311
|
-
throw new Error(`Unknown command: ${command}`);
|
|
1815
|
+
//#endregion
|
|
1816
|
+
//#region src/wxml/utils.ts
|
|
1817
|
+
function createTemplateHandler(options = {}) {
|
|
1818
|
+
const cachedMatcher = createAttributeMatcher(options.customAttributesEntities);
|
|
1819
|
+
const defaultOptions = options;
|
|
1820
|
+
let cachedRuntimeSet;
|
|
1821
|
+
let cachedOptionsWithRuntimeSet;
|
|
1822
|
+
return (rawSource, opt) => {
|
|
1823
|
+
const runtimeSet = opt?.runtimeSet;
|
|
1824
|
+
if (runtimeSet === void 0) return customTemplateHandler(rawSource, defaultOptions, cachedMatcher);
|
|
1825
|
+
if (cachedRuntimeSet !== runtimeSet || !cachedOptionsWithRuntimeSet) {
|
|
1826
|
+
cachedRuntimeSet = runtimeSet;
|
|
1827
|
+
cachedOptionsWithRuntimeSet = {
|
|
1828
|
+
...defaultOptions,
|
|
1829
|
+
runtimeSet
|
|
1830
|
+
};
|
|
2312
1831
|
}
|
|
2313
|
-
|
|
1832
|
+
return customTemplateHandler(rawSource, cachedOptionsWithRuntimeSet, cachedMatcher);
|
|
1833
|
+
};
|
|
2314
1834
|
}
|
|
2315
|
-
main();
|
|
2316
1835
|
//#endregion
|
|
2317
|
-
export {};
|
|
1836
|
+
export { traverse as _, jsHandler as a, getReplacementCacheStore as c, decodeUnicode2 as d, resolveClassNameTransformWithResult as f, babelParse as g, createDebug as h, analyzeSource as i, jsStringEscape as l, replaceWxml as m, generateCode as n, JsTokenUpdater as o, shouldEnableArbitraryValueFallback as p, createAttributeMatcher as r, getReplacement as s, createTemplateHandler as t, isClassContextLiteralPath as u, md5Hash as v };
|