weapp-tailwindcss 5.0.12 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/auto-Ba6hDrse.mjs +13 -0
- package/dist/auto-DtU6f3X6.js +18 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +27 -10
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +6 -23
- package/dist/bundlers/shared/generator-css/types.d.ts +15 -1
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
- package/dist/bundlers/shared/run-tasks.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
- package/dist/bundlers/vite/css-memory.d.ts +37 -0
- package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +9 -7
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +63 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +80 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +5 -2
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +30 -0
- package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -1
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
- package/dist/bundlers/vite/map-cache.d.ts +2 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
- package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
- package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
- package/dist/bundlers/vite/source-candidates.d.ts +12 -2
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +3 -6
- package/dist/bundlers/vite/source-scan.d.ts +3 -3
- package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
- package/dist/bundlers/vite/utils.d.ts +1 -0
- package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -10
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +15 -1
- package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cli/mount-options.d.ts +2 -2
- package/dist/cli.js +126 -439
- package/dist/cli.mjs +121 -434
- package/dist/context/index.d.ts +3 -3
- package/dist/context/style-options.d.ts +4 -1
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/{precheck-30zNPRlI.js → context-BHxLe743.js} +484 -175
- package/dist/{precheck-CsFr1q2l.mjs → context-Mbzkek1q.mjs} +461 -159
- package/dist/core.js +15 -12
- package/dist/core.mjs +10 -7
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/{defaults-Boc26eel.js → defaults-CVcKbXBG.js} +6 -50
- package/dist/{defaults-DH0ZQRhy.mjs → defaults-ZElj1zKc.mjs} +7 -45
- package/dist/defaults.d.ts +1 -7
- package/dist/defaults.js +1 -2
- package/dist/defaults.mjs +2 -2
- package/dist/framework/index.d.ts +59 -0
- package/dist/framework.d.ts +1 -0
- package/dist/framework.js +198 -0
- package/dist/framework.mjs +180 -0
- package/dist/generator/index.d.ts +6 -7
- package/dist/generator/options.d.ts +3 -3
- package/dist/generator/types.d.ts +9 -10
- package/dist/generator-9rUz4Hcb.js +170 -0
- package/dist/generator-Dc4qaPmT.mjs +123 -0
- package/dist/generator.js +10 -16
- package/dist/generator.mjs +3 -3
- package/dist/{gulp-CxGZU0-v.js → gulp-B_sdP6dx.js} +80 -92
- package/dist/{gulp-BfZpaYSQ.mjs → gulp-uM36oIJs.mjs} +73 -85
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DNjF8bWA.mjs → hmr-timing-BXMLsF4b.mjs} +1289 -909
- package/dist/{hmr-timing-DFR51wgo.js → hmr-timing-CogqkFaF.js} +1397 -939
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -4
- package/dist/index.mjs +6 -5
- package/dist/js/fast-path/oxc.d.ts +4 -0
- package/dist/js/precheck.d.ts +1 -0
- package/dist/postcss.js +3 -4
- package/dist/postcss.mjs +2 -3
- package/dist/presets.js +10 -20
- package/dist/presets.mjs +9 -19
- package/dist/runtime-branch/create-branch.d.ts +2 -0
- package/dist/runtime-branch/generator-target-env.d.ts +4 -0
- package/dist/runtime-branch/index.d.ts +6 -0
- package/dist/runtime-branch/mini-program.d.ts +2 -0
- package/dist/runtime-branch/native-app.d.ts +2 -0
- package/dist/runtime-branch/platform.d.ts +6 -0
- package/dist/runtime-branch/tailwind-version.d.ts +2 -0
- package/dist/runtime-branch/types.d.ts +37 -0
- package/dist/runtime-branch/web.d.ts +2 -0
- package/dist/runtime-branch.d.ts +1 -0
- package/dist/{bundle-state-DU2ATDhw.js → source-candidate-scan-signature-2ybpptAK.js} +262 -20
- package/dist/{bundle-state-BxMNKjBV.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
- package/dist/tailwindcss/candidates.d.ts +7 -0
- package/dist/tailwindcss/index.d.ts +2 -2
- package/dist/tailwindcss/runtime/cache.d.ts +6 -6
- package/dist/tailwindcss/runtime-factory.d.ts +12 -0
- package/dist/tailwindcss/runtime-options.d.ts +8 -0
- package/dist/tailwindcss/runtime-types.d.ts +86 -0
- package/dist/tailwindcss/runtime.d.ts +6 -6
- package/dist/tailwindcss/source-scan.d.ts +1 -1
- package/dist/tailwindcss/targets.d.ts +2 -2
- package/dist/tailwindcss/v4/config.d.ts +3 -3
- package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
- package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
- package/dist/tailwindcss/v4/index.d.ts +1 -1
- package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
- package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
- package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
- package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
- package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
- package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
- package/dist/tailwindcss/version.d.ts +1 -1
- package/dist/tailwindcss-DHIYcqXT.js +1523 -0
- package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
- package/dist/{transform-CaVEBOuR.js → transform-CQVOgmzM.js} +45 -37
- package/dist/{transform-Cju08-aJ.mjs → transform-tExdt40m.mjs} +30 -22
- package/dist/typedoc.export.d.ts +1 -1
- package/dist/types/index.d.ts +16 -17
- package/dist/types/shared.d.ts +1 -1
- package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
- package/dist/types/user-defined-options/general.d.ts +8 -4
- package/dist/types/user-defined-options/important.d.ts +2 -2
- package/dist/uni-app-x/style-asset.d.ts +1 -0
- package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
- package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
- package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
- package/dist/v4-engine-D4ubP7N5.js +2778 -0
- package/dist/{vite-BBGOjh9e.js → vite-CP0ylSxZ.js} +2887 -1683
- package/dist/{vite-CS5DE-HD.mjs → vite-CPO83EhA.mjs} +2753 -1548
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5741 -4396
- package/dist/weapp-tw-runtime-classset-loader.js +36 -0
- package/dist/webpack-Bsek8VhR.js +2094 -0
- package/dist/webpack-BzqhJ8yK.mjs +2082 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +11 -7
- package/dist/auto-CTp6wE5a.js +0 -33
- package/dist/auto-Cl8_hsG6.mjs +0 -22
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
- package/dist/context/tailwindcss/rax.d.ts +0 -2
- package/dist/generator-Cb1Zp3Al.js +0 -92
- package/dist/generator-mvNFUvns.mjs +0 -67
- package/dist/tailwindcss/patcher-options.d.ts +0 -8
- package/dist/tailwindcss/patcher.d.ts +0 -12
- package/dist/tailwindcss/runtime-patch.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
- package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
- package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
- package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher.d.ts +0 -15
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
- package/dist/tailwindcss-CK84uGBp.mjs +0 -556
- package/dist/tailwindcss-Clpkz1oR.js +0 -613
- package/dist/v3-engine-CQE5JJNZ.js +0 -4639
- package/dist/v3-engine-DKBaKWGL.mjs +0 -4231
- package/dist/webpack-DIWrcpRo.js +0 -1066
- package/dist/webpack-SPcri_D8.mjs +0 -1054
- /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_context = require("./context-BHxLe743.js");
|
|
3
3
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
4
4
|
//#region src/core.ts
|
|
5
5
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
|
@@ -14,16 +14,19 @@ function resolveTransformWxssOptions(options) {
|
|
|
14
14
|
* @returns 返回一个包含 transformWxss、transformWxml 和 transformJs 方法的对象
|
|
15
15
|
*/
|
|
16
16
|
function createContext(options = {}) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const opts = require_context.getCompilerContext(options);
|
|
18
|
+
const { templateHandler, styleHandler, jsHandler } = opts;
|
|
19
|
+
const initialTailwindRuntime = opts.tailwindRuntime;
|
|
20
|
+
const refreshTailwindcssRuntime = opts.refreshTailwindcssRuntime;
|
|
21
|
+
const readyPromise = require_context.createTailwindRuntimeReadyPromise(initialTailwindRuntime);
|
|
19
22
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
20
23
|
const runtimeState = {
|
|
21
|
-
|
|
24
|
+
tailwindRuntime: initialTailwindRuntime,
|
|
22
25
|
readyPromise,
|
|
23
|
-
|
|
26
|
+
refreshTailwindcssRuntime
|
|
24
27
|
};
|
|
25
28
|
const defaultJsHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
26
|
-
function getDefaultJsHandlerOptions(majorVersion = runtimeState.
|
|
29
|
+
function getDefaultJsHandlerOptions(majorVersion = runtimeState.tailwindRuntime.majorVersion) {
|
|
27
30
|
if (typeof majorVersion !== "number") return;
|
|
28
31
|
let cached = defaultJsHandlerOptionsCache.get(majorVersion);
|
|
29
32
|
if (!cached) {
|
|
@@ -35,7 +38,7 @@ function createContext(options = {}) {
|
|
|
35
38
|
function withRuntimeTailwindMajorVersion(options) {
|
|
36
39
|
if (!options) return getDefaultJsHandlerOptions();
|
|
37
40
|
if (typeof options.tailwindcssMajorVersion === "number") return options;
|
|
38
|
-
const majorVersion = runtimeState.
|
|
41
|
+
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
39
42
|
if (typeof majorVersion !== "number") return options;
|
|
40
43
|
return {
|
|
41
44
|
...options,
|
|
@@ -106,25 +109,25 @@ function createContext(options = {}) {
|
|
|
106
109
|
async function transformWxss(rawCss, options) {
|
|
107
110
|
await runtimeState.readyPromise;
|
|
108
111
|
const result = await styleHandler(rawCss, resolveTransformWxssOptions(options));
|
|
109
|
-
runtimeSet = await
|
|
112
|
+
runtimeSet = await require_context.ensureRuntimeClassSet(runtimeState);
|
|
110
113
|
return result;
|
|
111
114
|
}
|
|
112
115
|
async function getRuntimeSet(options) {
|
|
113
116
|
await runtimeState.readyPromise;
|
|
114
|
-
runtimeSet = await
|
|
117
|
+
runtimeSet = await require_context.ensureRuntimeClassSet(runtimeState, options);
|
|
115
118
|
return runtimeSet;
|
|
116
119
|
}
|
|
117
120
|
async function transformJs(rawJs, options) {
|
|
118
121
|
await runtimeState.readyPromise;
|
|
119
122
|
if (options?.runtimeSet) runtimeSet = options.runtimeSet;
|
|
120
|
-
else if (runtimeSet.size === 0) runtimeSet = await
|
|
123
|
+
else if (runtimeSet.size === 0) runtimeSet = await require_context.ensureRuntimeClassSet(runtimeState, { forceCollect: true });
|
|
121
124
|
const resolvedOptions = resolveTransformJsOptions(options);
|
|
122
|
-
if (
|
|
125
|
+
if (require_context.shouldSkipJsTransform(rawJs, resolvedOptions)) return { code: rawJs };
|
|
123
126
|
return await jsHandler(rawJs, runtimeSet, resolvedOptions);
|
|
124
127
|
}
|
|
125
128
|
async function transformWxml(rawWxml, options) {
|
|
126
129
|
await runtimeState.readyPromise;
|
|
127
|
-
if (!options?.runtimeSet && runtimeSet.size === 0) runtimeSet = await
|
|
130
|
+
if (!options?.runtimeSet && runtimeSet.size === 0) runtimeSet = await require_context.ensureRuntimeClassSet(runtimeState, { forceCollect: true });
|
|
128
131
|
return templateHandler(rawWxml, resolveTransformWxmlOptions(options));
|
|
129
132
|
}
|
|
130
133
|
return {
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as shouldSkipJsTransform, t as getCompilerContext, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./context-Mbzkek1q.mjs";
|
|
2
2
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
3
3
|
//#region src/core.ts
|
|
4
4
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
|
@@ -13,16 +13,19 @@ function resolveTransformWxssOptions(options) {
|
|
|
13
13
|
* @returns 返回一个包含 transformWxss、transformWxml 和 transformJs 方法的对象
|
|
14
14
|
*/
|
|
15
15
|
function createContext(options = {}) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const opts = getCompilerContext(options);
|
|
17
|
+
const { templateHandler, styleHandler, jsHandler } = opts;
|
|
18
|
+
const initialTailwindRuntime = opts.tailwindRuntime;
|
|
19
|
+
const refreshTailwindcssRuntime = opts.refreshTailwindcssRuntime;
|
|
20
|
+
const readyPromise = createTailwindRuntimeReadyPromise(initialTailwindRuntime);
|
|
18
21
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
19
22
|
const runtimeState = {
|
|
20
|
-
|
|
23
|
+
tailwindRuntime: initialTailwindRuntime,
|
|
21
24
|
readyPromise,
|
|
22
|
-
|
|
25
|
+
refreshTailwindcssRuntime
|
|
23
26
|
};
|
|
24
27
|
const defaultJsHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
25
|
-
function getDefaultJsHandlerOptions(majorVersion = runtimeState.
|
|
28
|
+
function getDefaultJsHandlerOptions(majorVersion = runtimeState.tailwindRuntime.majorVersion) {
|
|
26
29
|
if (typeof majorVersion !== "number") return;
|
|
27
30
|
let cached = defaultJsHandlerOptionsCache.get(majorVersion);
|
|
28
31
|
if (!cached) {
|
|
@@ -34,7 +37,7 @@ function createContext(options = {}) {
|
|
|
34
37
|
function withRuntimeTailwindMajorVersion(options) {
|
|
35
38
|
if (!options) return getDefaultJsHandlerOptions();
|
|
36
39
|
if (typeof options.tailwindcssMajorVersion === "number") return options;
|
|
37
|
-
const majorVersion = runtimeState.
|
|
40
|
+
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
38
41
|
if (typeof majorVersion !== "number") return options;
|
|
39
42
|
return {
|
|
40
43
|
...options,
|
package/dist/css-macro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_auto = require("./auto-
|
|
3
|
-
require("./utils-
|
|
2
|
+
const require_auto = require("./auto-DtU6f3X6.js");
|
|
3
|
+
require("./utils-BCa37Wqj.js");
|
|
4
4
|
let tailwindcss_plugin = require("tailwindcss/plugin");
|
|
5
5
|
tailwindcss_plugin = require_chunk.__toESM(tailwindcss_plugin);
|
|
6
6
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
package/dist/css-macro.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as defu } from "./utils-
|
|
1
|
+
import { r as markCssMacroPlugin } from "./auto-Ba6hDrse.mjs";
|
|
2
|
+
import { t as defu } from "./utils-DodxWHGz.mjs";
|
|
3
3
|
import plugin from "tailwindcss/plugin";
|
|
4
4
|
//#region src/css-macro/constants.ts
|
|
5
5
|
const queryKey = "weapp-tw-platform";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require("./utils-
|
|
1
|
+
require("./utils-BCa37Wqj.js");
|
|
2
2
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
3
3
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
4
4
|
//#region src/js/babel/cache-options.ts
|
|
@@ -9,44 +9,15 @@ const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
|
|
|
9
9
|
const CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
|
|
10
10
|
const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
|
|
11
11
|
const JS_FILE_PATTERN = /.+\.[cm]?js?$/;
|
|
12
|
-
const BACKSLASH_RE = /\\/g;
|
|
13
|
-
function normalizePath(p) {
|
|
14
|
-
return p.replace(BACKSLASH_RE, "/");
|
|
15
|
-
}
|
|
16
|
-
const MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
|
|
17
|
-
const KBONE_MAIN_CSS_RE = /^(?:common\/)?miniprogram-app/;
|
|
18
|
-
const IMPLICIT_MAIN_CSS_RE = /^(?:app|common\/main|bundle)(?:\.|\/|$)/;
|
|
19
|
-
const MAIN_CSS_CHUNK_MATCHERS = {
|
|
20
|
-
"uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
|
|
21
|
-
"uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
22
|
-
"uni-app-x": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
23
|
-
"mpx": (file) => {
|
|
24
|
-
const normalized = normalizePath(file);
|
|
25
|
-
if (normalized.startsWith("app")) return true;
|
|
26
|
-
return MPX_STYLES_DIR_PATTERN.test(normalized);
|
|
27
|
-
},
|
|
28
|
-
"taro": (file) => file.startsWith("app"),
|
|
29
|
-
"remax": (file) => file.startsWith("app"),
|
|
30
|
-
"rax": (file) => file.startsWith("bundle"),
|
|
31
|
-
"native": (file) => file.startsWith("app"),
|
|
32
|
-
"weapp-vite": (file) => file.startsWith("app"),
|
|
33
|
-
"kbone": (file) => KBONE_MAIN_CSS_RE.test(file)
|
|
34
|
-
};
|
|
35
12
|
const alwaysFalse = () => false;
|
|
36
|
-
const TAILWIND_V3_CSS_PREFLIGHT = {
|
|
37
|
-
"box-sizing": "border-box",
|
|
38
|
-
"border-width": "0",
|
|
39
|
-
"border-style": "solid",
|
|
40
|
-
"border-color": "currentColor"
|
|
41
|
-
};
|
|
42
13
|
const TAILWIND_V4_CSS_PREFLIGHT = {
|
|
43
14
|
"box-sizing": "border-box",
|
|
44
15
|
"margin": "0",
|
|
45
16
|
"padding": "0",
|
|
46
17
|
"border": "0 solid"
|
|
47
18
|
};
|
|
48
|
-
function getDefaultCssPreflight(
|
|
49
|
-
return { ...
|
|
19
|
+
function getDefaultCssPreflight() {
|
|
20
|
+
return { ...TAILWIND_V4_CSS_PREFLIGHT };
|
|
50
21
|
}
|
|
51
22
|
function resolveDefaultCssPreflight(cssPreflight, tailwindcssMajorVersion) {
|
|
52
23
|
if (cssPreflight === false) return false;
|
|
@@ -55,16 +26,6 @@ function resolveDefaultCssPreflight(cssPreflight, tailwindcssMajorVersion) {
|
|
|
55
26
|
...cssPreflight ?? {}
|
|
56
27
|
};
|
|
57
28
|
}
|
|
58
|
-
function createMainCssChunkMatcher() {
|
|
59
|
-
return (file, appType) => {
|
|
60
|
-
if (!appType) {
|
|
61
|
-
const normalized = normalizePath(file);
|
|
62
|
-
return IMPLICIT_MAIN_CSS_RE.test(normalized) || MPX_STYLES_DIR_PATTERN.test(normalized) || KBONE_MAIN_CSS_RE.test(normalized);
|
|
63
|
-
}
|
|
64
|
-
const matcher = MAIN_CSS_CHUNK_MATCHERS[appType];
|
|
65
|
-
return matcher ? matcher(file) : true;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
29
|
function getDefaultOptions() {
|
|
69
30
|
return {
|
|
70
31
|
/**
|
|
@@ -93,7 +54,7 @@ function getDefaultOptions() {
|
|
|
93
54
|
if (file.includes("node_modules")) return false;
|
|
94
55
|
return JS_FILE_PATTERN.test(file);
|
|
95
56
|
},
|
|
96
|
-
mainCssChunkMatcher:
|
|
57
|
+
mainCssChunkMatcher: alwaysFalse,
|
|
97
58
|
wxsMatcher: alwaysFalse,
|
|
98
59
|
cssPreflight: getDefaultCssPreflight(3),
|
|
99
60
|
disabled: false,
|
|
@@ -141,9 +102,10 @@ function getDefaultOptions() {
|
|
|
141
102
|
ignoreCallExpressionIdentifiers: [],
|
|
142
103
|
ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"],
|
|
143
104
|
replaceRuntimePackages: false,
|
|
105
|
+
rewriteCssImports: false,
|
|
144
106
|
generator: {},
|
|
145
107
|
cssSourceTrace: false,
|
|
146
|
-
|
|
108
|
+
tailwindcssRuntimeOptions: { filter(className) {
|
|
147
109
|
return !(0, _weapp_core_escape.isAllowedClassName)(className);
|
|
148
110
|
} },
|
|
149
111
|
logLevel: "info"
|
|
@@ -162,12 +124,6 @@ Object.defineProperty(exports, "HARD_PARSE_CACHE_MAX_ENTRIES", {
|
|
|
162
124
|
return HARD_PARSE_CACHE_MAX_ENTRIES;
|
|
163
125
|
}
|
|
164
126
|
});
|
|
165
|
-
Object.defineProperty(exports, "TAILWIND_V3_CSS_PREFLIGHT", {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
get: function() {
|
|
168
|
-
return TAILWIND_V3_CSS_PREFLIGHT;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
127
|
Object.defineProperty(exports, "TAILWIND_V4_CSS_PREFLIGHT", {
|
|
172
128
|
enumerable: true,
|
|
173
129
|
get: function() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as noop } from "./utils-
|
|
1
|
+
import { a as noop } from "./utils-DodxWHGz.mjs";
|
|
2
2
|
import { MappingChars2String, isAllowedClassName } from "@weapp-core/escape";
|
|
3
3
|
//#region src/js/babel/cache-options.ts
|
|
4
4
|
const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
|
|
@@ -8,44 +8,15 @@ const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
|
|
|
8
8
|
const CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
|
|
9
9
|
const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
|
|
10
10
|
const JS_FILE_PATTERN = /.+\.[cm]?js?$/;
|
|
11
|
-
const BACKSLASH_RE = /\\/g;
|
|
12
|
-
function normalizePath(p) {
|
|
13
|
-
return p.replace(BACKSLASH_RE, "/");
|
|
14
|
-
}
|
|
15
|
-
const MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
|
|
16
|
-
const KBONE_MAIN_CSS_RE = /^(?:common\/)?miniprogram-app/;
|
|
17
|
-
const IMPLICIT_MAIN_CSS_RE = /^(?:app|common\/main|bundle)(?:\.|\/|$)/;
|
|
18
|
-
const MAIN_CSS_CHUNK_MATCHERS = {
|
|
19
|
-
"uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
|
|
20
|
-
"uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
21
|
-
"uni-app-x": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
22
|
-
"mpx": (file) => {
|
|
23
|
-
const normalized = normalizePath(file);
|
|
24
|
-
if (normalized.startsWith("app")) return true;
|
|
25
|
-
return MPX_STYLES_DIR_PATTERN.test(normalized);
|
|
26
|
-
},
|
|
27
|
-
"taro": (file) => file.startsWith("app"),
|
|
28
|
-
"remax": (file) => file.startsWith("app"),
|
|
29
|
-
"rax": (file) => file.startsWith("bundle"),
|
|
30
|
-
"native": (file) => file.startsWith("app"),
|
|
31
|
-
"weapp-vite": (file) => file.startsWith("app"),
|
|
32
|
-
"kbone": (file) => KBONE_MAIN_CSS_RE.test(file)
|
|
33
|
-
};
|
|
34
11
|
const alwaysFalse = () => false;
|
|
35
|
-
const TAILWIND_V3_CSS_PREFLIGHT = {
|
|
36
|
-
"box-sizing": "border-box",
|
|
37
|
-
"border-width": "0",
|
|
38
|
-
"border-style": "solid",
|
|
39
|
-
"border-color": "currentColor"
|
|
40
|
-
};
|
|
41
12
|
const TAILWIND_V4_CSS_PREFLIGHT = {
|
|
42
13
|
"box-sizing": "border-box",
|
|
43
14
|
"margin": "0",
|
|
44
15
|
"padding": "0",
|
|
45
16
|
"border": "0 solid"
|
|
46
17
|
};
|
|
47
|
-
function getDefaultCssPreflight(
|
|
48
|
-
return { ...
|
|
18
|
+
function getDefaultCssPreflight() {
|
|
19
|
+
return { ...TAILWIND_V4_CSS_PREFLIGHT };
|
|
49
20
|
}
|
|
50
21
|
function resolveDefaultCssPreflight(cssPreflight, tailwindcssMajorVersion) {
|
|
51
22
|
if (cssPreflight === false) return false;
|
|
@@ -54,16 +25,6 @@ function resolveDefaultCssPreflight(cssPreflight, tailwindcssMajorVersion) {
|
|
|
54
25
|
...cssPreflight ?? {}
|
|
55
26
|
};
|
|
56
27
|
}
|
|
57
|
-
function createMainCssChunkMatcher() {
|
|
58
|
-
return (file, appType) => {
|
|
59
|
-
if (!appType) {
|
|
60
|
-
const normalized = normalizePath(file);
|
|
61
|
-
return IMPLICIT_MAIN_CSS_RE.test(normalized) || MPX_STYLES_DIR_PATTERN.test(normalized) || KBONE_MAIN_CSS_RE.test(normalized);
|
|
62
|
-
}
|
|
63
|
-
const matcher = MAIN_CSS_CHUNK_MATCHERS[appType];
|
|
64
|
-
return matcher ? matcher(file) : true;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
28
|
function getDefaultOptions() {
|
|
68
29
|
return {
|
|
69
30
|
/**
|
|
@@ -92,7 +53,7 @@ function getDefaultOptions() {
|
|
|
92
53
|
if (file.includes("node_modules")) return false;
|
|
93
54
|
return JS_FILE_PATTERN.test(file);
|
|
94
55
|
},
|
|
95
|
-
mainCssChunkMatcher:
|
|
56
|
+
mainCssChunkMatcher: alwaysFalse,
|
|
96
57
|
wxsMatcher: alwaysFalse,
|
|
97
58
|
cssPreflight: getDefaultCssPreflight(3),
|
|
98
59
|
disabled: false,
|
|
@@ -140,13 +101,14 @@ function getDefaultOptions() {
|
|
|
140
101
|
ignoreCallExpressionIdentifiers: [],
|
|
141
102
|
ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"],
|
|
142
103
|
replaceRuntimePackages: false,
|
|
104
|
+
rewriteCssImports: false,
|
|
143
105
|
generator: {},
|
|
144
106
|
cssSourceTrace: false,
|
|
145
|
-
|
|
107
|
+
tailwindcssRuntimeOptions: { filter(className) {
|
|
146
108
|
return !isAllowedClassName(className);
|
|
147
109
|
} },
|
|
148
110
|
logLevel: "info"
|
|
149
111
|
};
|
|
150
112
|
}
|
|
151
113
|
//#endregion
|
|
152
|
-
export {
|
|
114
|
+
export { DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH as a, resolveDefaultCssPreflight as i, getDefaultCssPreflight as n, HARD_PARSE_CACHE_MAX_ENTRIES as o, getDefaultOptions as r, TAILWIND_V4_CSS_PREFLIGHT as t };
|
package/dist/defaults.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { CssPreflightOptions, UserDefinedOptions } from './types';
|
|
2
|
-
export declare const TAILWIND_V3_CSS_PREFLIGHT: {
|
|
3
|
-
'box-sizing': string;
|
|
4
|
-
'border-width': string;
|
|
5
|
-
'border-style': string;
|
|
6
|
-
'border-color': string;
|
|
7
|
-
};
|
|
8
2
|
export declare const TAILWIND_V4_CSS_PREFLIGHT: {
|
|
9
3
|
'box-sizing': string;
|
|
10
4
|
margin: string;
|
|
11
5
|
padding: string;
|
|
12
6
|
border: string;
|
|
13
7
|
};
|
|
14
|
-
export declare function getDefaultCssPreflight(
|
|
8
|
+
export declare function getDefaultCssPreflight(): Exclude<CssPreflightOptions, false>;
|
|
15
9
|
export declare function resolveDefaultCssPreflight(cssPreflight: CssPreflightOptions | undefined, tailwindcssMajorVersion?: number): CssPreflightOptions;
|
|
16
10
|
export declare function getDefaultOptions(): UserDefinedOptions;
|
package/dist/defaults.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_defaults = require("./defaults-
|
|
3
|
-
exports.TAILWIND_V3_CSS_PREFLIGHT = require_defaults.TAILWIND_V3_CSS_PREFLIGHT;
|
|
2
|
+
const require_defaults = require("./defaults-CVcKbXBG.js");
|
|
4
3
|
exports.TAILWIND_V4_CSS_PREFLIGHT = require_defaults.TAILWIND_V4_CSS_PREFLIGHT;
|
|
5
4
|
exports.getDefaultCssPreflight = require_defaults.getDefaultCssPreflight;
|
|
6
5
|
exports.getDefaultOptions = require_defaults.getDefaultOptions;
|
package/dist/defaults.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { i as resolveDefaultCssPreflight, n as getDefaultCssPreflight, r as getDefaultOptions, t as TAILWIND_V4_CSS_PREFLIGHT } from "./defaults-ZElj1zKc.mjs";
|
|
2
|
+
export { TAILWIND_V4_CSS_PREFLIGHT, getDefaultCssPreflight, getDefaultOptions, resolveDefaultCssPreflight };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type DetectableAppType = 'mpx' | 'taro' | 'uni-app' | 'uni-app-vite' | 'uni-app-x' | 'weapp-vite';
|
|
2
|
+
export type FrameworkEnv = Partial<Record<'MPX_CLI_MODE' | 'MPX_CURRENT_TARGET_MODE' | 'NODE_PATH' | 'TARO_ENV' | 'UNI_PLATFORM' | 'UNI_UTS_PLATFORM' | 'WEAPP_TAILWINDCSS_TARGET' | 'WEAPP_TW_TARGET', string | undefined>>;
|
|
3
|
+
export interface UniPlatformInfo {
|
|
4
|
+
raw: string | undefined;
|
|
5
|
+
normalized: string | undefined;
|
|
6
|
+
isApp: boolean;
|
|
7
|
+
isAppAndroid: boolean;
|
|
8
|
+
isAppHarmony: boolean;
|
|
9
|
+
isAppIos: boolean;
|
|
10
|
+
isMp: boolean;
|
|
11
|
+
isWeb: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface HBuilderXRuntimeHints {
|
|
14
|
+
cwd?: string | undefined;
|
|
15
|
+
env?: FrameworkEnv | undefined;
|
|
16
|
+
nodePath?: string | null | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface PackageJsonLike {
|
|
19
|
+
'dependencies'?: Record<string, string> | undefined;
|
|
20
|
+
'devDependencies'?: Record<string, string> | undefined;
|
|
21
|
+
'peerDependencies'?: Record<string, string> | undefined;
|
|
22
|
+
'optionalDependencies'?: Record<string, string> | undefined;
|
|
23
|
+
'scripts'?: Record<string, string> | undefined;
|
|
24
|
+
'uni-app'?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface UniAppManifestLike {
|
|
27
|
+
'uni-app-x'?: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface DetectAppTypeOptions {
|
|
30
|
+
root?: string | undefined;
|
|
31
|
+
packageJson?: PackageJsonLike | undefined;
|
|
32
|
+
manifest?: UniAppManifestLike | undefined;
|
|
33
|
+
searchUp?: boolean | undefined;
|
|
34
|
+
env?: FrameworkEnv | undefined;
|
|
35
|
+
detectEnv?: boolean | undefined;
|
|
36
|
+
cwd?: string | undefined;
|
|
37
|
+
hbuilderxVite?: boolean | undefined;
|
|
38
|
+
}
|
|
39
|
+
export declare function isRunningInHBuilderX(options?: HBuilderXRuntimeHints): boolean;
|
|
40
|
+
export declare function resolveUniPlatform(value: string | undefined): UniPlatformInfo;
|
|
41
|
+
export declare function resolveUniUtsPlatform(value: string | undefined): UniPlatformInfo;
|
|
42
|
+
export declare function resolveUniPlatformsFromEnv(env?: FrameworkEnv): {
|
|
43
|
+
uniPlatform: UniPlatformInfo;
|
|
44
|
+
uniUtsPlatform: UniPlatformInfo;
|
|
45
|
+
};
|
|
46
|
+
export declare function detectAppTypeFromEnv(env?: FrameworkEnv, options?: {
|
|
47
|
+
cwd?: string | undefined;
|
|
48
|
+
hbuilderxVite?: boolean | undefined;
|
|
49
|
+
}): DetectableAppType | undefined;
|
|
50
|
+
export declare function isWeappVitePackage(pkg: PackageJsonLike): boolean;
|
|
51
|
+
export declare function isMpxPackage(pkg: PackageJsonLike): boolean;
|
|
52
|
+
export declare function isTaroPackage(pkg: PackageJsonLike): boolean;
|
|
53
|
+
export declare function isUniAppVitePackage(pkg: PackageJsonLike): boolean;
|
|
54
|
+
export declare function isUniAppXPackage(pkg: PackageJsonLike): boolean;
|
|
55
|
+
export declare function isUniAppPackage(pkg: PackageJsonLike): boolean;
|
|
56
|
+
export declare function isUniAppXManifest(manifest: UniAppManifestLike | undefined): boolean;
|
|
57
|
+
export declare function detectAppTypeFromPackageJson(pkg: PackageJsonLike): DetectableAppType | undefined;
|
|
58
|
+
export declare function detectAppType(options?: DetectAppTypeOptions): DetectableAppType | undefined;
|
|
59
|
+
export declare const resolveImplicitAppTypeFromViteRoot: (root: string) => DetectableAppType | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './framework/index'
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
node_path = require_chunk.__toESM(node_path);
|
|
6
|
+
let node_process = require("node:process");
|
|
7
|
+
node_process = require_chunk.__toESM(node_process);
|
|
8
|
+
//#region src/framework/index.ts
|
|
9
|
+
const KNOWN_MAC_HBUILDERX_PLUGIN_DIRS = ["/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli-vite", "/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli"];
|
|
10
|
+
const HBUILDERX_PLUGIN_CWD_RE = /[\\/]HBuilderX(?:\.[^\\/]*)?(?:[\\/]Contents[\\/]HBuilderX)?[\\/]plugins[\\/]uniapp-cli(?:-vite)?(?:[\\/]|$)/i;
|
|
11
|
+
const PACKAGE_JSON_FILE = "package.json";
|
|
12
|
+
const MANIFEST_JSON_FILE = "manifest.json";
|
|
13
|
+
const MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;
|
|
14
|
+
const TARO_SCRIPT_RE = /\btaro\b/u;
|
|
15
|
+
const WEAPP_VITE_SCRIPT_RE = /\bweapp-vite\b/u;
|
|
16
|
+
const UNI_APP_SCRIPT_RE = /\buni(?:\s|$)/u;
|
|
17
|
+
const UNI_APP_VITE_SCRIPT_RE = /\buni(?:\s|$)/u;
|
|
18
|
+
const MPX_MARKERS = [["src/app.mpx", "mpx"], ["app.mpx", "mpx"]];
|
|
19
|
+
function getProcessEnv() {
|
|
20
|
+
return {
|
|
21
|
+
MPX_CLI_MODE: node_process.default.env["MPX_CLI_MODE"],
|
|
22
|
+
MPX_CURRENT_TARGET_MODE: node_process.default.env["MPX_CURRENT_TARGET_MODE"],
|
|
23
|
+
NODE_PATH: node_process.default.env["NODE_PATH"],
|
|
24
|
+
TARO_ENV: node_process.default.env["TARO_ENV"],
|
|
25
|
+
UNI_PLATFORM: node_process.default.env["UNI_PLATFORM"],
|
|
26
|
+
UNI_UTS_PLATFORM: node_process.default.env["UNI_UTS_PLATFORM"],
|
|
27
|
+
WEAPP_TAILWINDCSS_TARGET: node_process.default.env["WEAPP_TAILWINDCSS_TARGET"],
|
|
28
|
+
WEAPP_TW_TARGET: node_process.default.env["WEAPP_TW_TARGET"]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function resolveDependencyNames(pkg) {
|
|
32
|
+
return new Set([
|
|
33
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
34
|
+
...Object.keys(pkg.devDependencies ?? {}),
|
|
35
|
+
...Object.keys(pkg.peerDependencies ?? {}),
|
|
36
|
+
...Object.keys(pkg.optionalDependencies ?? {})
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
function hasDependencyPrefix(dependencyNames, prefix) {
|
|
40
|
+
return [...dependencyNames].some((name) => name.startsWith(prefix));
|
|
41
|
+
}
|
|
42
|
+
function hasScriptMatch(pkg, pattern) {
|
|
43
|
+
return Object.values(pkg.scripts ?? {}).some((script) => pattern.test(script));
|
|
44
|
+
}
|
|
45
|
+
function normalizePlatform(value) {
|
|
46
|
+
return value?.trim().toLowerCase() || void 0;
|
|
47
|
+
}
|
|
48
|
+
function resolvePlatformInfo(value) {
|
|
49
|
+
const normalized = normalizePlatform(value);
|
|
50
|
+
const isAppAndroid = normalized === "app-android";
|
|
51
|
+
const isAppIos = normalized === "app-ios";
|
|
52
|
+
const isAppHarmony = normalized === "app-harmony";
|
|
53
|
+
return {
|
|
54
|
+
raw: value,
|
|
55
|
+
normalized,
|
|
56
|
+
isApp: normalized?.startsWith("app-") === true || normalized === "app" || normalized === "app-plus",
|
|
57
|
+
isAppAndroid,
|
|
58
|
+
isAppHarmony,
|
|
59
|
+
isAppIos,
|
|
60
|
+
isMp: normalized?.startsWith("mp-") === true,
|
|
61
|
+
isWeb: normalized?.startsWith("web") === true || normalized === "h5"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function hasKnownHBuilderXPluginPrefix(normalizedCwd) {
|
|
65
|
+
for (const dir of KNOWN_MAC_HBUILDERX_PLUGIN_DIRS) {
|
|
66
|
+
const normalizedDir = node_path.default.normalize(dir);
|
|
67
|
+
if (normalizedCwd === normalizedDir || normalizedCwd.startsWith(`${normalizedDir}${node_path.default.sep}`)) return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function matchesHBuilderXPluginCwd(cwd) {
|
|
72
|
+
const normalized = node_path.default.normalize(cwd);
|
|
73
|
+
if (hasKnownHBuilderXPluginPrefix(normalized)) return true;
|
|
74
|
+
return HBUILDERX_PLUGIN_CWD_RE.test(normalized);
|
|
75
|
+
}
|
|
76
|
+
function isRunningInHBuilderX(options = {}) {
|
|
77
|
+
const env = options.env ?? getProcessEnv();
|
|
78
|
+
const nodePath = "nodePath" in options ? options.nodePath : env.NODE_PATH;
|
|
79
|
+
if (!(nodePath == null || nodePath.trim().length === 0)) return false;
|
|
80
|
+
return matchesHBuilderXPluginCwd(options.cwd ?? node_process.default.cwd());
|
|
81
|
+
}
|
|
82
|
+
function resolveUniPlatform(value) {
|
|
83
|
+
return resolvePlatformInfo(value);
|
|
84
|
+
}
|
|
85
|
+
function resolveUniUtsPlatform(value) {
|
|
86
|
+
return resolvePlatformInfo(value);
|
|
87
|
+
}
|
|
88
|
+
function resolveUniPlatformsFromEnv(env = getProcessEnv()) {
|
|
89
|
+
return {
|
|
90
|
+
uniPlatform: resolveUniPlatform(env.UNI_PLATFORM),
|
|
91
|
+
uniUtsPlatform: resolveUniUtsPlatform(env.UNI_UTS_PLATFORM)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function detectAppTypeFromEnv(env = getProcessEnv(), options = {}) {
|
|
95
|
+
if (env.WEAPP_TW_TARGET === "weapp-vite" || env.WEAPP_TAILWINDCSS_TARGET === "weapp-vite") return "weapp-vite";
|
|
96
|
+
if (env.TARO_ENV) return "taro";
|
|
97
|
+
if (env.MPX_CLI_MODE || env.MPX_CURRENT_TARGET_MODE) return "mpx";
|
|
98
|
+
const { uniPlatform, uniUtsPlatform } = resolveUniPlatformsFromEnv(env);
|
|
99
|
+
if (uniUtsPlatform.normalized) return "uni-app-x";
|
|
100
|
+
if (uniPlatform.normalized) return "uni-app-vite";
|
|
101
|
+
if (isRunningInHBuilderX({
|
|
102
|
+
cwd: options.cwd,
|
|
103
|
+
env
|
|
104
|
+
})) return options.hbuilderxVite === false ? "uni-app" : "uni-app-vite";
|
|
105
|
+
}
|
|
106
|
+
function isWeappVitePackage(pkg) {
|
|
107
|
+
const dependencyNames = resolveDependencyNames(pkg);
|
|
108
|
+
return dependencyNames.has("weapp-vite") || hasDependencyPrefix(dependencyNames, "@weapp-vite/") || hasScriptMatch(pkg, WEAPP_VITE_SCRIPT_RE);
|
|
109
|
+
}
|
|
110
|
+
function isMpxPackage(pkg) {
|
|
111
|
+
return hasDependencyPrefix(resolveDependencyNames(pkg), "@mpxjs/") || hasScriptMatch(pkg, MPX_SCRIPT_RE);
|
|
112
|
+
}
|
|
113
|
+
function isTaroPackage(pkg) {
|
|
114
|
+
return hasDependencyPrefix(resolveDependencyNames(pkg), "@tarojs/") || hasScriptMatch(pkg, TARO_SCRIPT_RE);
|
|
115
|
+
}
|
|
116
|
+
function isUniAppVitePackage(pkg) {
|
|
117
|
+
return resolveDependencyNames(pkg).has("@dcloudio/vite-plugin-uni") || hasScriptMatch(pkg, UNI_APP_VITE_SCRIPT_RE);
|
|
118
|
+
}
|
|
119
|
+
function isUniAppXPackage(pkg) {
|
|
120
|
+
const dependencyNames = resolveDependencyNames(pkg);
|
|
121
|
+
return dependencyNames.has("@dcloudio/uni-uts-v1") || dependencyNames.has("@weapp-tailwindcss/debug-uni-app-x");
|
|
122
|
+
}
|
|
123
|
+
function isUniAppPackage(pkg) {
|
|
124
|
+
const dependencyNames = resolveDependencyNames(pkg);
|
|
125
|
+
return dependencyNames.has("@dcloudio/vue-cli-plugin-uni") || dependencyNames.has("@dcloudio/uni-app") || Object.hasOwn(pkg, "uni-app") || hasScriptMatch(pkg, UNI_APP_SCRIPT_RE);
|
|
126
|
+
}
|
|
127
|
+
function isUniAppXManifest(manifest) {
|
|
128
|
+
return Boolean(manifest && Object.hasOwn(manifest, "uni-app-x"));
|
|
129
|
+
}
|
|
130
|
+
function detectAppTypeFromPackageJson(pkg) {
|
|
131
|
+
if (isWeappVitePackage(pkg)) return "weapp-vite";
|
|
132
|
+
if (isMpxPackage(pkg)) return "mpx";
|
|
133
|
+
if (isTaroPackage(pkg)) return "taro";
|
|
134
|
+
if (isUniAppXPackage(pkg)) return "uni-app-x";
|
|
135
|
+
if (isUniAppVitePackage(pkg)) return "uni-app-vite";
|
|
136
|
+
if (isUniAppPackage(pkg)) return "uni-app";
|
|
137
|
+
}
|
|
138
|
+
function tryReadJson(file) {
|
|
139
|
+
if (!(0, node_fs.existsSync)(file)) return;
|
|
140
|
+
try {
|
|
141
|
+
return JSON.parse((0, node_fs.readFileSync)(file, "utf8"));
|
|
142
|
+
} catch {}
|
|
143
|
+
}
|
|
144
|
+
function detectAppTypeFromMarkers(root) {
|
|
145
|
+
for (const [relativePath, appType] of MPX_MARKERS) if ((0, node_fs.existsSync)(node_path.default.join(root, relativePath))) return appType;
|
|
146
|
+
}
|
|
147
|
+
function detectAppTypeFromRoot(root, searchUp = true) {
|
|
148
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
149
|
+
if (!(0, node_fs.existsSync)(resolvedRoot)) return;
|
|
150
|
+
const markerDetected = detectAppTypeFromMarkers(resolvedRoot);
|
|
151
|
+
if (markerDetected) return markerDetected;
|
|
152
|
+
let current = resolvedRoot;
|
|
153
|
+
while (true) {
|
|
154
|
+
if (isUniAppXManifest(tryReadJson(node_path.default.join(current, MANIFEST_JSON_FILE)))) return "uni-app-x";
|
|
155
|
+
const pkg = tryReadJson(node_path.default.join(current, PACKAGE_JSON_FILE));
|
|
156
|
+
if (pkg) {
|
|
157
|
+
const detected = detectAppTypeFromPackageJson(pkg);
|
|
158
|
+
if (detected) return detected;
|
|
159
|
+
}
|
|
160
|
+
if (!searchUp) break;
|
|
161
|
+
const parent = node_path.default.dirname(current);
|
|
162
|
+
if (parent === current) break;
|
|
163
|
+
current = parent;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function detectAppType(options = {}) {
|
|
167
|
+
if (isUniAppXManifest(options.manifest)) return "uni-app-x";
|
|
168
|
+
if (options.packageJson) {
|
|
169
|
+
const detected = detectAppTypeFromPackageJson(options.packageJson);
|
|
170
|
+
if (detected) return detected;
|
|
171
|
+
}
|
|
172
|
+
if (options.root) {
|
|
173
|
+
const detected = detectAppTypeFromRoot(options.root, options.searchUp ?? true);
|
|
174
|
+
if (detected) return detected;
|
|
175
|
+
}
|
|
176
|
+
const env = options.env ?? (options.detectEnv ? getProcessEnv() : void 0);
|
|
177
|
+
if (env) return detectAppTypeFromEnv(env, {
|
|
178
|
+
cwd: options.cwd ?? options.root ?? (options.detectEnv ? node_process.default.cwd() : void 0),
|
|
179
|
+
hbuilderxVite: options.hbuilderxVite
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const resolveImplicitAppTypeFromViteRoot = (root) => detectAppType({ root });
|
|
183
|
+
//#endregion
|
|
184
|
+
exports.detectAppType = detectAppType;
|
|
185
|
+
exports.detectAppTypeFromEnv = detectAppTypeFromEnv;
|
|
186
|
+
exports.detectAppTypeFromPackageJson = detectAppTypeFromPackageJson;
|
|
187
|
+
exports.isMpxPackage = isMpxPackage;
|
|
188
|
+
exports.isRunningInHBuilderX = isRunningInHBuilderX;
|
|
189
|
+
exports.isTaroPackage = isTaroPackage;
|
|
190
|
+
exports.isUniAppPackage = isUniAppPackage;
|
|
191
|
+
exports.isUniAppVitePackage = isUniAppVitePackage;
|
|
192
|
+
exports.isUniAppXManifest = isUniAppXManifest;
|
|
193
|
+
exports.isUniAppXPackage = isUniAppXPackage;
|
|
194
|
+
exports.isWeappVitePackage = isWeappVitePackage;
|
|
195
|
+
exports.resolveImplicitAppTypeFromViteRoot = resolveImplicitAppTypeFromViteRoot;
|
|
196
|
+
exports.resolveUniPlatform = resolveUniPlatform;
|
|
197
|
+
exports.resolveUniPlatformsFromEnv = resolveUniPlatformsFromEnv;
|
|
198
|
+
exports.resolveUniUtsPlatform = resolveUniUtsPlatform;
|