@weapp-tailwindcss/react-native 0.3.3 → 0.3.5

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.
Files changed (38) hide show
  1. package/README.md +14 -0
  2. package/README.zh-CN.md +14 -0
  3. package/dist/babel.cjs +2 -3
  4. package/dist/babel.d.ts +1 -2
  5. package/dist/babel.js +1 -2
  6. package/dist/compiler.cjs +12 -2
  7. package/dist/compiler.d.ts +1 -3
  8. package/dist/compiler.js +13 -3
  9. package/dist/env.d.ts +1 -3
  10. package/dist/index.cjs +7 -3
  11. package/dist/index.d.ts +5 -5
  12. package/dist/index.js +4 -4
  13. package/dist/manifest-DRxbQp2v.cjs +47 -0
  14. package/dist/manifest-DuhmZ2T9.js +24 -0
  15. package/dist/{metro-BZbdIyTH.js → metro-OMh6z1jy.js} +216 -97
  16. package/dist/metro-ahmChgsA.d.ts +63 -0
  17. package/dist/{metro-Ds2ZUc6_.cjs → metro-kaKzXOAU.cjs} +238 -101
  18. package/dist/metro-transformer.cjs +5 -11
  19. package/dist/metro-transformer.d.ts +1 -3
  20. package/dist/metro-transformer.js +4 -10
  21. package/dist/metro.cjs +4 -1
  22. package/dist/metro.d.ts +2 -53
  23. package/dist/metro.js +1 -2
  24. package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
  25. package/dist/runtime-BivP43Uy.cjs +382 -0
  26. package/dist/{runtime-B3hAisFx.d.ts → runtime-Bm9mAKDC.d.ts} +13 -10
  27. package/dist/runtime-BzHdtM5_.js +329 -0
  28. package/dist/runtime.cjs +10 -186
  29. package/dist/runtime.d.ts +3 -3
  30. package/dist/runtime.js +1 -179
  31. package/dist/tailwind-4T0v_pRK.d.ts +13 -0
  32. package/dist/tailwind-B1Gl9P_t.js +121 -0
  33. package/dist/tailwind-CVspvWID.cjs +129 -0
  34. package/dist/tailwind.cjs +2 -58
  35. package/dist/tailwind.d.ts +2 -16
  36. package/dist/tailwind.js +1 -55
  37. package/dist/{types-CKAFTXX9.d.ts → types-CxNMLBiF.d.ts} +6 -3
  38. package/package.json +9 -8
package/dist/runtime.js CHANGED
@@ -1,179 +1 @@
1
- //#region src/runtime.ts
2
- let activeManifest;
3
- let activeEnvironment = {};
4
- const styleMetadata = /* @__PURE__ */ new Map();
5
- let styleSheetFactory;
6
- let nativeStyleSheet = {};
7
- function createStyleSheet(manifest) {
8
- const source = manifest.styleSheet ?? Object.fromEntries(Object.entries(manifest.styleEntries ?? {}).map(([id, rule]) => [id, rule.style]));
9
- nativeStyleSheet = styleSheetFactory?.(source) ?? source;
10
- }
11
- function flatten(value, result) {
12
- if (!value) return;
13
- if (typeof value === "string") {
14
- result.push(...value.split(/\s+/).filter(Boolean));
15
- return;
16
- }
17
- if (Array.isArray(value)) {
18
- for (const item of value) flatten(item, result);
19
- return;
20
- }
21
- for (const [className, enabled] of Object.entries(value)) if (enabled) result.push(className);
22
- }
23
- function canonicalTokens(value) {
24
- const tokens = [];
25
- flatten(value, tokens);
26
- return [...new Set(tokens)].sort();
27
- }
28
- function matches(rule, environment) {
29
- if (rule.colorScheme && rule.colorScheme !== environment.colorScheme) return false;
30
- if (!rule.platform) return true;
31
- if (rule.platform === "native") return environment.platform !== "web";
32
- return rule.platform === environment.platform;
33
- }
34
- function resolveRules(ids, manifest, environment) {
35
- const normal = [];
36
- const important = [];
37
- for (const id of ids) {
38
- const rule = manifest?.styleEntries?.[id];
39
- if (rule) {
40
- if (!matches(rule, environment)) continue;
41
- (rule.important ? important : normal).push({
42
- rule,
43
- id
44
- });
45
- continue;
46
- }
47
- const fallbackIds = manifest?.staticLookup?.[id] ?? [];
48
- if (fallbackIds.length) for (const fallbackId of fallbackIds) {
49
- const fallbackRule = manifest?.styleEntries?.[fallbackId];
50
- if (!fallbackRule || !matches(fallbackRule, environment)) continue;
51
- (fallbackRule.important ? important : normal).push({
52
- rule: fallbackRule,
53
- id: fallbackId
54
- });
55
- }
56
- else for (const fallbackRule of manifest?.rules?.[id] ?? []) {
57
- if (!matches(fallbackRule, environment)) continue;
58
- (fallbackRule.important ? important : normal).push({
59
- rule: fallbackRule,
60
- id
61
- });
62
- }
63
- }
64
- const order = (left, right) => (left.rule.order ?? 0) - (right.rule.order ?? 0);
65
- normal.sort(order);
66
- important.sort(order);
67
- const style = {};
68
- const importantStyle = {};
69
- for (const { rule } of normal) Object.assign(style, rule.style);
70
- for (const { rule } of important) {
71
- Object.assign(style, rule.style);
72
- Object.assign(importantStyle, rule.style);
73
- }
74
- const normalIds = normal.map((item) => item.id);
75
- const importantIds = important.map((item) => item.id);
76
- const asStyleValue = (ids, fallback) => {
77
- if (!styleSheetFactory) return fallback;
78
- const values = ids.map((id) => nativeStyleSheet[id]).filter((value) => value !== void 0);
79
- if (values.length === 1) return values[0];
80
- if (values.length > 1) return values;
81
- return fallback;
82
- };
83
- return {
84
- style,
85
- importantStyle,
86
- styleValue: asStyleValue(normalIds, style),
87
- importantValue: asStyleValue(importantIds, importantStyle)
88
- };
89
- }
90
- function resolveDynamic(value, manifest, environment) {
91
- const classNames = canonicalTokens(value);
92
- return resolveRules(manifest?.staticLookup ? classNames.flatMap((className) => manifest.staticLookup?.[className] ?? []) : classNames, manifest, environment);
93
- }
94
- function rememberStyle(style, importantStyle) {
95
- if (importantStyle && (typeof importantStyle !== "object" || Object.keys(importantStyle).length)) styleMetadata.set(style, { important: importantStyle });
96
- return style;
97
- }
98
- function createNativeStyleRuntime(initialManifest) {
99
- let manifest = initialManifest;
100
- let environment = activeEnvironment;
101
- const cache = /* @__PURE__ */ new Map();
102
- const runtime = {
103
- tw(value, requestedEnvironment = {}) {
104
- const effectiveEnvironment = {
105
- ...environment,
106
- ...requestedEnvironment
107
- };
108
- const key = `${canonicalTokens(value).join("")}|${effectiveEnvironment.colorScheme ?? ""}|${effectiveEnvironment.platform ?? ""}`;
109
- const cached = cache.get(key);
110
- if (cached) return cached;
111
- const resolved = resolveDynamic(value, manifest, effectiveEnvironment);
112
- const style = rememberStyle(resolved.styleValue, resolved.importantValue);
113
- cache.set(key, style);
114
- return style;
115
- },
116
- getStaticStyle(ids, requestedEnvironment = {}) {
117
- const effectiveEnvironment = {
118
- ...environment,
119
- ...requestedEnvironment
120
- };
121
- const resolved = resolveRules(ids, manifest, effectiveEnvironment);
122
- return rememberStyle(resolved.styleValue, resolved.importantValue);
123
- },
124
- composeStyle(tailwindStyle, inlineStyle) {
125
- const important = styleMetadata.get(tailwindStyle)?.important;
126
- return important !== void 0 ? [
127
- tailwindStyle,
128
- inlineStyle,
129
- important
130
- ] : [tailwindStyle, inlineStyle];
131
- },
132
- setManifest(nextManifest) {
133
- manifest = nextManifest;
134
- cache.clear();
135
- styleMetadata.clear();
136
- createStyleSheet(nextManifest);
137
- activeManifest = nextManifest;
138
- },
139
- setEnvironment(nextEnvironment) {
140
- environment = nextEnvironment;
141
- activeEnvironment = nextEnvironment;
142
- cache.clear();
143
- },
144
- getManifest() {
145
- return manifest;
146
- }
147
- };
148
- if (initialManifest) {
149
- createStyleSheet(initialManifest);
150
- activeManifest = initialManifest;
151
- }
152
- return runtime;
153
- }
154
- const defaultRuntime = createNativeStyleRuntime();
155
- function setManifest(manifest) {
156
- defaultRuntime.setManifest(manifest);
157
- }
158
- /** 由 Expo virtual module 注入,避免 runtime 引入 Node-only 的 require shim。 */
159
- function setStyleSheetFactory(factory) {
160
- styleSheetFactory = factory;
161
- if (activeManifest) createStyleSheet(activeManifest);
162
- }
163
- function setEnvironment(environment) {
164
- defaultRuntime.setEnvironment(environment);
165
- }
166
- function getManifest() {
167
- return activeManifest ?? defaultRuntime.getManifest();
168
- }
169
- function tw(value, environment) {
170
- return defaultRuntime.tw(value, environment);
171
- }
172
- function getStaticStyle(ids, environment) {
173
- return defaultRuntime.getStaticStyle(ids, environment);
174
- }
175
- function composeStyle(tailwindStyle, inlineStyle) {
176
- return defaultRuntime.composeStyle(tailwindStyle, inlineStyle);
177
- }
178
- //#endregion
179
- export { composeStyle, createNativeStyleRuntime, getManifest, getStaticStyle, setEnvironment, setManifest, setStyleSheetFactory, tw };
1
+ export { t as composeStyle, n as createNativeStyleRuntime, r as getManifest, i as getPublication, a as getStaticStyle, o as setEnvironment, s as setManifest, c as setStyleSheetFactory, l as tw } from "./runtime-BzHdtM5_.js";
@@ -0,0 +1,13 @@
1
+ import { a as NativeStyleManifest, t as CompileNativeStylesheetOptions } from "./types-CxNMLBiF.js";
2
+ import { TailwindV4SourceOptions } from "weapp-tailwindcss/generator";
3
+ interface GenerateNativeStylesheetOptions extends Omit<TailwindV4SourceOptions, 'projectRoot' | 'cssEntries'>, Pick<CompileNativeStylesheetOptions, 'boxShadow'> {
4
+ /** Tailwind source 扫描根目录;用于 workspace 示例和 Metro 项目。 */
5
+ projectRoot?: string | undefined;
6
+ /** Tailwind CSS 入口文件;相对路径会按 projectRoot 解析。 */
7
+ cssEntries?: string[] | undefined;
8
+ candidates?: Iterable<string> | undefined;
9
+ sourceGlobs?: string[] | undefined;
10
+ }
11
+ /** 生成应用使用的原生样式;需要分层诊断时使用 generateNativeStylesheetEvidence。 */
12
+ declare function generateNativeStylesheet(options?: GenerateNativeStylesheetOptions): Promise<NativeStyleManifest>;
13
+ export { generateNativeStylesheet as n, GenerateNativeStylesheetOptions as t };
@@ -0,0 +1,121 @@
1
+ import { addNativeVariantRules, baseClassName, compileNativeStylesheet, finalizeNativeManifest } from "./compiler.js";
2
+ import process from "node:process";
3
+ import { createWeappTailwindcssGenerator, resolveTailwindV4Source } from "weapp-tailwindcss/generator";
4
+ // src/tailwind/merge.ts
5
+ /** 每个入口先解析自己的变量,再合并已编码规则,避免主题与前缀串入其它入口。 */
6
+ function mergeNativeManifests(manifests) {
7
+ const merged = {
8
+ version: 1,
9
+ classSet: [],
10
+ rules: {},
11
+ variables: {},
12
+ warnings: []
13
+ };
14
+ const warnings = /* @__PURE__ */ new Set();
15
+ let orderOffset = 0;
16
+ for (const manifest of manifests) {
17
+ let entryOrder = 0;
18
+ Object.assign(merged.variables, manifest.variables);
19
+ for (const [className, rules] of Object.entries(manifest.rules)) {
20
+ const target = merged.rules[className] ??= [];
21
+ for (const rule of rules) {
22
+ const localOrder = rule.order ?? 0;
23
+ const copied = {
24
+ ...rule,
25
+ style: { ...rule.style },
26
+ order: orderOffset + localOrder
27
+ };
28
+ delete copied.id;
29
+ target.push(copied);
30
+ entryOrder = Math.max(entryOrder, localOrder + 1);
31
+ }
32
+ }
33
+ for (const warning of manifest.warnings) {
34
+ const key = JSON.stringify(warning);
35
+ if (!warnings.has(key)) {
36
+ warnings.add(key);
37
+ merged.warnings.push(warning);
38
+ }
39
+ }
40
+ orderOffset += entryOrder;
41
+ }
42
+ return finalizeNativeManifest(merged);
43
+ }
44
+ // src/tailwind/generate.ts
45
+ async function generateSourceEvidence(source, options) {
46
+ const generator = createWeappTailwindcssGenerator(source);
47
+ try {
48
+ const sourcePatterns = options.sourceGlobs?.map((pattern) => ({
49
+ base: source.projectRoot,
50
+ pattern,
51
+ negated: false
52
+ }));
53
+ const generatorCandidates = new Set(options.candidates ?? []);
54
+ for (const candidate of generatorCandidates) {
55
+ const base = baseClassName(candidate);
56
+ if (base && /^(?:ios|android|native):/.test(candidate)) generatorCandidates.add(base);
57
+ }
58
+ let generated = await generator.generate({
59
+ target: "web",
60
+ ...generatorCandidates.size ? { candidates: generatorCandidates } : {},
61
+ scanSources: sourcePatterns ?? true
62
+ });
63
+ const platformBases = /* @__PURE__ */ new Set();
64
+ for (const candidate of generated.rawCandidates ?? []) {
65
+ const base = baseClassName(candidate);
66
+ if (base && /^(?:ios|android|native):/.test(candidate) && !generated.classSet.has(base)) platformBases.add(base);
67
+ }
68
+ if (platformBases.size) generated = await generator.generate({
69
+ target: "web",
70
+ candidates: /* @__PURE__ */ new Set([...generatorCandidates, ...platformBases]),
71
+ scanSources: sourcePatterns ?? true
72
+ });
73
+ const requestedCandidates = new Set(options.candidates ?? []);
74
+ for (const candidate of generated.rawCandidates ?? []) if (baseClassName(candidate) && /^(?:dark|ios|android|native):/.test(candidate)) requestedCandidates.add(candidate);
75
+ const manifest = compileNativeStylesheet(generated.rawCss, { boxShadow: options.boxShadow });
76
+ addNativeVariantRules(manifest, requestedCandidates);
77
+ finalizeNativeManifest(manifest);
78
+ return {
79
+ rawCss: generated.rawCss,
80
+ generatedClassSet: [...generated.classSet],
81
+ manifest
82
+ };
83
+ } finally {
84
+ generator.dispose?.();
85
+ }
86
+ }
87
+ async function generateNativeStylesheetEvidence(options = {}) {
88
+ const { projectRoot = process.cwd(), cssEntries, cssSources, css, candidates, sourceGlobs, boxShadow, ...sourceOptions } = options;
89
+ const shared = {
90
+ ...sourceOptions,
91
+ projectRoot
92
+ };
93
+ const inputs = css !== void 0 ? [{
94
+ ...shared,
95
+ css
96
+ }] : [...(cssEntries ?? []).map((entry) => ({
97
+ ...shared,
98
+ cssEntries: [entry]
99
+ })), ...(cssSources ?? []).map((source) => ({
100
+ ...shared,
101
+ cssSources: [source]
102
+ }))];
103
+ if (!inputs.length) inputs.push(shared);
104
+ const generationOptions = {
105
+ candidates: [...candidates ?? []],
106
+ boxShadow,
107
+ ...sourceGlobs ? { sourceGlobs } : {}
108
+ };
109
+ const entries = [];
110
+ for (const input of inputs) entries.push(await generateSourceEvidence(await resolveTailwindV4Source(input), generationOptions));
111
+ return {
112
+ rawCss: entries.map((entry) => entry.rawCss).join("\n"),
113
+ generatedClassSet: [...new Set(entries.flatMap((entry) => entry.generatedClassSet))],
114
+ manifest: mergeNativeManifests(entries.map((entry) => entry.manifest))
115
+ };
116
+ }
117
+ /** 生成应用使用的原生样式;需要分层诊断时使用 generateNativeStylesheetEvidence。 */
118
+ async function generateNativeStylesheet(options = {}) {
119
+ return (await generateNativeStylesheetEvidence(options)).manifest;
120
+ }
121
+ export { generateNativeStylesheet as t };
@@ -0,0 +1,129 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.cjs");
2
+ const require_compiler = require("./compiler.cjs");
3
+ let node_process = require("node:process");
4
+ node_process = require_rolldown_runtime.__toESM(node_process, 1);
5
+ let weapp_tailwindcss_generator = require("weapp-tailwindcss/generator");
6
+ let _weapp_tailwindcss_postcss_native = require("@weapp-tailwindcss/postcss/native");
7
+ // src/tailwind/merge.ts
8
+ /** 每个入口先解析自己的变量,再合并已编码规则,避免主题与前缀串入其它入口。 */
9
+ function mergeNativeManifests(manifests) {
10
+ const merged = {
11
+ version: 1,
12
+ classSet: [],
13
+ rules: {},
14
+ variables: {},
15
+ warnings: []
16
+ };
17
+ const warnings = /* @__PURE__ */ new Set();
18
+ let orderOffset = 0;
19
+ for (const manifest of manifests) {
20
+ let entryOrder = 0;
21
+ Object.assign(merged.variables, manifest.variables);
22
+ for (const [className, rules] of Object.entries(manifest.rules)) {
23
+ const target = merged.rules[className] ??= [];
24
+ for (const rule of rules) {
25
+ const localOrder = rule.order ?? 0;
26
+ const copied = {
27
+ ...rule,
28
+ style: { ...rule.style },
29
+ order: orderOffset + localOrder
30
+ };
31
+ delete copied.id;
32
+ target.push(copied);
33
+ entryOrder = Math.max(entryOrder, localOrder + 1);
34
+ }
35
+ }
36
+ for (const warning of manifest.warnings) {
37
+ const key = JSON.stringify(warning);
38
+ if (!warnings.has(key)) {
39
+ warnings.add(key);
40
+ merged.warnings.push(warning);
41
+ }
42
+ }
43
+ orderOffset += entryOrder;
44
+ }
45
+ return require_compiler.finalizeNativeManifest(merged);
46
+ }
47
+ // src/tailwind/generate.ts
48
+ async function generateSourceEvidence(source, options) {
49
+ const generator = (0, weapp_tailwindcss_generator.createWeappTailwindcssGenerator)(source);
50
+ try {
51
+ const sourcePatterns = options.sourceGlobs?.map((pattern) => ({
52
+ base: source.projectRoot,
53
+ pattern,
54
+ negated: false
55
+ }));
56
+ const generatorCandidates = new Set(options.candidates ?? []);
57
+ for (const candidate of generatorCandidates) {
58
+ const base = (0, _weapp_tailwindcss_postcss_native.baseClassName)(candidate);
59
+ if (base && /^(?:ios|android|native):/.test(candidate)) generatorCandidates.add(base);
60
+ }
61
+ let generated = await generator.generate({
62
+ target: "web",
63
+ ...generatorCandidates.size ? { candidates: generatorCandidates } : {},
64
+ scanSources: sourcePatterns ?? true
65
+ });
66
+ const platformBases = /* @__PURE__ */ new Set();
67
+ for (const candidate of generated.rawCandidates ?? []) {
68
+ const base = (0, _weapp_tailwindcss_postcss_native.baseClassName)(candidate);
69
+ if (base && /^(?:ios|android|native):/.test(candidate) && !generated.classSet.has(base)) platformBases.add(base);
70
+ }
71
+ if (platformBases.size) generated = await generator.generate({
72
+ target: "web",
73
+ candidates: /* @__PURE__ */ new Set([...generatorCandidates, ...platformBases]),
74
+ scanSources: sourcePatterns ?? true
75
+ });
76
+ const requestedCandidates = new Set(options.candidates ?? []);
77
+ for (const candidate of generated.rawCandidates ?? []) if ((0, _weapp_tailwindcss_postcss_native.baseClassName)(candidate) && /^(?:dark|ios|android|native):/.test(candidate)) requestedCandidates.add(candidate);
78
+ const manifest = require_compiler.compileNativeStylesheet(generated.rawCss, { boxShadow: options.boxShadow });
79
+ require_compiler.addNativeVariantRules(manifest, requestedCandidates);
80
+ require_compiler.finalizeNativeManifest(manifest);
81
+ return {
82
+ rawCss: generated.rawCss,
83
+ generatedClassSet: [...generated.classSet],
84
+ manifest
85
+ };
86
+ } finally {
87
+ generator.dispose?.();
88
+ }
89
+ }
90
+ async function generateNativeStylesheetEvidence(options = {}) {
91
+ const { projectRoot = node_process.default.cwd(), cssEntries, cssSources, css, candidates, sourceGlobs, boxShadow, ...sourceOptions } = options;
92
+ const shared = {
93
+ ...sourceOptions,
94
+ projectRoot
95
+ };
96
+ const inputs = css !== void 0 ? [{
97
+ ...shared,
98
+ css
99
+ }] : [...(cssEntries ?? []).map((entry) => ({
100
+ ...shared,
101
+ cssEntries: [entry]
102
+ })), ...(cssSources ?? []).map((source) => ({
103
+ ...shared,
104
+ cssSources: [source]
105
+ }))];
106
+ if (!inputs.length) inputs.push(shared);
107
+ const generationOptions = {
108
+ candidates: [...candidates ?? []],
109
+ boxShadow,
110
+ ...sourceGlobs ? { sourceGlobs } : {}
111
+ };
112
+ const entries = [];
113
+ for (const input of inputs) entries.push(await generateSourceEvidence(await (0, weapp_tailwindcss_generator.resolveTailwindV4Source)(input), generationOptions));
114
+ return {
115
+ rawCss: entries.map((entry) => entry.rawCss).join("\n"),
116
+ generatedClassSet: [...new Set(entries.flatMap((entry) => entry.generatedClassSet))],
117
+ manifest: mergeNativeManifests(entries.map((entry) => entry.manifest))
118
+ };
119
+ }
120
+ /** 生成应用使用的原生样式;需要分层诊断时使用 generateNativeStylesheetEvidence。 */
121
+ async function generateNativeStylesheet(options = {}) {
122
+ return (await generateNativeStylesheetEvidence(options)).manifest;
123
+ }
124
+ Object.defineProperty(exports, "generateNativeStylesheet", {
125
+ enumerable: true,
126
+ get: function() {
127
+ return generateNativeStylesheet;
128
+ }
129
+ });
package/dist/tailwind.cjs CHANGED
@@ -1,59 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
- const require_compiler = require("./compiler.cjs");
4
- let node_process = require("node:process");
5
- node_process = require_rolldown_runtime.__toESM(node_process, 1);
6
- let weapp_tailwindcss_generator = require("weapp-tailwindcss/generator");
7
- let _weapp_tailwindcss_postcss_native = require("@weapp-tailwindcss/postcss/native");
8
- //#region src/tailwind.ts
9
- /**
10
- * 使用 weapp-tailwindcss 的 Tailwind v4 generator 生成原始 CSS,再编译为 RN manifest。
11
- */
12
- async function generateNativeStylesheet(options = {}) {
13
- const { projectRoot = node_process.default.cwd(), cssEntries, ...sourceOptions } = options;
14
- const source = await (0, weapp_tailwindcss_generator.resolveTailwindV4Source)({
15
- ...sourceOptions,
16
- projectRoot,
17
- ...cssEntries ? { cssEntries } : {}
18
- });
19
- const generator = (0, weapp_tailwindcss_generator.createWeappTailwindcssGenerator)(source);
20
- const sourcePatterns = options.sourceGlobs?.map((pattern) => ({
21
- base: source.projectRoot,
22
- pattern,
23
- negated: false
24
- }));
25
- const generatorCandidates = new Set(options.candidates ?? []);
26
- for (const candidate of generatorCandidates) {
27
- const base = (0, _weapp_tailwindcss_postcss_native.baseClassName)(candidate);
28
- if (base && /^(?:ios|android|native):/.test(candidate)) generatorCandidates.add(base);
29
- }
30
- let generated = await generator.generate({
31
- target: "web",
32
- ...generatorCandidates.size ? { candidates: generatorCandidates } : {},
33
- scanSources: sourcePatterns ?? true
34
- });
35
- const platformBases = /* @__PURE__ */ new Set();
36
- for (const candidate of generated.rawCandidates ?? []) {
37
- const base = (0, _weapp_tailwindcss_postcss_native.baseClassName)(candidate);
38
- if (base && /^(?:ios|android|native):/.test(candidate) && !generated.classSet.has(base)) platformBases.add(base);
39
- }
40
- if (platformBases.size) generated = await generator.generate({
41
- target: "web",
42
- candidates: /* @__PURE__ */ new Set([...generatorCandidates, ...platformBases]),
43
- scanSources: sourcePatterns ?? true
44
- });
45
- const classSet = new Set(generated.classSet);
46
- const requestedCandidates = new Set(options.candidates ?? []);
47
- for (const candidate of generated.rawCandidates ?? []) {
48
- const base = (0, _weapp_tailwindcss_postcss_native.baseClassName)(candidate);
49
- if (base && generated.classSet.has(base) && /^(?:dark|ios|android|native):/.test(candidate)) requestedCandidates.add(candidate);
50
- }
51
- for (const candidate of requestedCandidates) classSet.add(candidate);
52
- const manifest = require_compiler.compileNativeStylesheet(generated.rawCss, { classSet });
53
- require_compiler.addNativeVariantRules(manifest, requestedCandidates);
54
- require_compiler.finalizeNativeManifest(manifest);
55
- generator.dispose?.();
56
- return manifest;
57
- }
58
- //#endregion
59
- exports.generateNativeStylesheet = generateNativeStylesheet;
2
+ const require_tailwind = require("./tailwind-CVspvWID.cjs");
3
+ exports.generateNativeStylesheet = require_tailwind.generateNativeStylesheet;
@@ -1,16 +1,2 @@
1
- import { i as NativeStyleManifest } from "./types-CKAFTXX9.js";
2
- import { TailwindV4SourceOptions } from "weapp-tailwindcss/generator";
3
- //#region src/tailwind.d.ts
4
- export interface GenerateNativeStylesheetOptions extends Omit<TailwindV4SourceOptions, 'projectRoot' | 'cssEntries'> {
5
- /** Tailwind source 扫描根目录;用于 workspace 示例和 Metro 项目。 */
6
- projectRoot?: string | undefined;
7
- /** Tailwind CSS 入口文件;相对路径会按 projectRoot 解析。 */
8
- cssEntries?: string[] | undefined;
9
- candidates?: Iterable<string> | undefined;
10
- sourceGlobs?: string[] | undefined;
11
- }
12
- /**
13
- * 使用 weapp-tailwindcss 的 Tailwind v4 generator 生成原始 CSS,再编译为 RN manifest。
14
- */
15
- export declare function generateNativeStylesheet(options?: GenerateNativeStylesheetOptions): Promise<NativeStyleManifest>;
16
- //#endregion
1
+ import { n as generateNativeStylesheet, t as GenerateNativeStylesheetOptions } from "./tailwind-4T0v_pRK.js";
2
+ export { type GenerateNativeStylesheetOptions, generateNativeStylesheet };
package/dist/tailwind.js CHANGED
@@ -1,55 +1 @@
1
- import { addNativeVariantRules, baseClassName, compileNativeStylesheet, finalizeNativeManifest } from "./compiler.js";
2
- import process from "node:process";
3
- import { createWeappTailwindcssGenerator, resolveTailwindV4Source } from "weapp-tailwindcss/generator";
4
- //#region src/tailwind.ts
5
- /**
6
- * 使用 weapp-tailwindcss 的 Tailwind v4 generator 生成原始 CSS,再编译为 RN manifest。
7
- */
8
- async function generateNativeStylesheet(options = {}) {
9
- const { projectRoot = process.cwd(), cssEntries, ...sourceOptions } = options;
10
- const source = await resolveTailwindV4Source({
11
- ...sourceOptions,
12
- projectRoot,
13
- ...cssEntries ? { cssEntries } : {}
14
- });
15
- const generator = createWeappTailwindcssGenerator(source);
16
- const sourcePatterns = options.sourceGlobs?.map((pattern) => ({
17
- base: source.projectRoot,
18
- pattern,
19
- negated: false
20
- }));
21
- const generatorCandidates = new Set(options.candidates ?? []);
22
- for (const candidate of generatorCandidates) {
23
- const base = baseClassName(candidate);
24
- if (base && /^(?:ios|android|native):/.test(candidate)) generatorCandidates.add(base);
25
- }
26
- let generated = await generator.generate({
27
- target: "web",
28
- ...generatorCandidates.size ? { candidates: generatorCandidates } : {},
29
- scanSources: sourcePatterns ?? true
30
- });
31
- const platformBases = /* @__PURE__ */ new Set();
32
- for (const candidate of generated.rawCandidates ?? []) {
33
- const base = baseClassName(candidate);
34
- if (base && /^(?:ios|android|native):/.test(candidate) && !generated.classSet.has(base)) platformBases.add(base);
35
- }
36
- if (platformBases.size) generated = await generator.generate({
37
- target: "web",
38
- candidates: /* @__PURE__ */ new Set([...generatorCandidates, ...platformBases]),
39
- scanSources: sourcePatterns ?? true
40
- });
41
- const classSet = new Set(generated.classSet);
42
- const requestedCandidates = new Set(options.candidates ?? []);
43
- for (const candidate of generated.rawCandidates ?? []) {
44
- const base = baseClassName(candidate);
45
- if (base && generated.classSet.has(base) && /^(?:dark|ios|android|native):/.test(candidate)) requestedCandidates.add(candidate);
46
- }
47
- for (const candidate of requestedCandidates) classSet.add(candidate);
48
- const manifest = compileNativeStylesheet(generated.rawCss, { classSet });
49
- addNativeVariantRules(manifest, requestedCandidates);
50
- finalizeNativeManifest(manifest);
51
- generator.dispose?.();
52
- return manifest;
53
- }
54
- //#endregion
55
- export { generateNativeStylesheet };
1
+ export { t as generateNativeStylesheet } from "./tailwind-B1Gl9P_t.js";
@@ -1,5 +1,9 @@
1
1
  import { CompileNativeStylesheetOptions, NativeCompilerWarning, NativeCompilerWarning as NativeCompilerWarning$1, NativePlatform, NativeStyleRule, NativeStyleRule as NativeStyleRule$1 } from "@weapp-tailwindcss/postcss/native";
2
- //#region src/types.d.ts
2
+ /** 同一轮 Metro 发布的便携身份,不包含构建机器的文件路径。 */
3
+ interface NativeManifestPublication {
4
+ revision: string;
5
+ manifestSha256: string;
6
+ }
3
7
  interface NativeStyleManifest {
4
8
  version: 1;
5
9
  classSet: string[];
@@ -13,5 +17,4 @@ interface NativeStyleManifest {
13
17
  variables: Record<string, string>;
14
18
  warnings: NativeCompilerWarning[];
15
19
  }
16
- //#endregion
17
- export { NativeStyleRule$1 as a, NativeStyleManifest as i, NativeCompilerWarning$1 as n, NativePlatform as r, CompileNativeStylesheetOptions as t };
20
+ export { NativeStyleManifest as a, NativePlatform as i, NativeCompilerWarning$1 as n, NativeStyleRule$1 as o, NativeManifestPublication as r, CompileNativeStylesheetOptions as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/react-native",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.3.5",
5
5
  "description": "Tailwind CSS compiler and Expo Metro integration for cross-platform React Native apps. 面向跨端 React Native 应用的 Tailwind CSS 编译器与 Expo Metro 集成。",
6
6
  "license": "MIT",
7
7
  "homepage": "https://tw.weapp.dev/docs/quick-start/react-native-expo",
@@ -91,15 +91,16 @@
91
91
  }
92
92
  },
93
93
  "dependencies": {
94
- "@babel/types": "^8.0.5",
95
- "@weapp-tailwindcss/postcss": "3.4.2",
96
- "weapp-tailwindcss": "5.6.2"
94
+ "@babel/types": "^8.0.8",
95
+ "@weapp-tailwindcss/postcss": "4.0.0",
96
+ "weapp-tailwindcss": "5.7.0"
97
97
  },
98
98
  "devDependencies": {
99
- "@babel/core": "^8.0.5",
100
- "@types/react": "^19.2.18",
101
- "react": "^19.2.8",
102
- "vitest": "~5.0.3"
99
+ "@babel/core": "^7.29.7",
100
+ "@types/react": "^19.3.0",
101
+ "react": "^19.3.1",
102
+ "typescript": "^5.9.3",
103
+ "vitest": "~5.1.0"
103
104
  },
104
105
  "scripts": {
105
106
  "build": "tsdown",