@weapp-tailwindcss/react-native 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/README.zh-CN.md +14 -0
- package/dist/babel.cjs +2 -3
- package/dist/babel.d.cts +6 -0
- package/dist/babel.d.ts +2 -3
- package/dist/babel.js +1 -2
- package/dist/compiler.cjs +12 -2
- package/dist/compiler.d.cts +7 -0
- package/dist/compiler.d.ts +1 -3
- package/dist/compiler.js +13 -3
- package/dist/env.d.cts +10 -0
- package/dist/env.d.ts +1 -3
- package/dist/index.cjs +7 -3
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/manifest-DRxbQp2v.cjs +47 -0
- package/dist/manifest-DuhmZ2T9.js +24 -0
- package/dist/metro-BdsKKvRn.d.cts +63 -0
- package/dist/{metro-BZbdIyTH.js → metro-OMh6z1jy.js} +216 -97
- package/dist/metro-ahmChgsA.d.ts +63 -0
- package/dist/{metro-Ds2ZUc6_.cjs → metro-kaKzXOAU.cjs} +238 -101
- package/dist/metro-transformer.cjs +5 -11
- package/dist/metro-transformer.d.cts +2 -0
- package/dist/metro-transformer.d.ts +1 -3
- package/dist/metro-transformer.js +4 -10
- package/dist/metro.cjs +4 -1
- package/dist/metro.d.cts +2 -0
- package/dist/metro.d.ts +2 -53
- package/dist/metro.js +1 -2
- package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/dist/runtime-CbkbHrPb.cjs +383 -0
- package/dist/runtime-D4ZGX6yk.d.cts +42 -0
- package/dist/runtime-DuvYZu4P.js +330 -0
- package/dist/{runtime-B3hAisFx.d.ts → runtime-YHlnn5ip.d.ts} +20 -12
- package/dist/runtime.cjs +10 -186
- package/dist/runtime.d.cts +3 -0
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +1 -179
- package/dist/tailwind-4T0v_pRK.d.ts +13 -0
- package/dist/tailwind-B1Gl9P_t.js +121 -0
- package/dist/tailwind-CVspvWID.cjs +129 -0
- package/dist/tailwind-CfKLPJuW.d.cts +13 -0
- package/dist/tailwind.cjs +2 -58
- package/dist/tailwind.d.cts +2 -0
- package/dist/tailwind.d.ts +2 -16
- package/dist/tailwind.js +1 -55
- package/dist/{types-CKAFTXX9.d.ts → types-CxNMLBiF.d.cts} +6 -3
- package/dist/types-CxNMLBiF.d.ts +20 -0
- package/package.json +75 -33
package/README.md
CHANGED
|
@@ -43,6 +43,20 @@ On Android and iOS, the Metro integration resolves `react` and `react-native` fr
|
|
|
43
43
|
|
|
44
44
|
`tw()` and `getStaticStyle()` return React Native `StyleProp` values, which can be passed directly to View, Text, and Image styles. They may contain registered StyleSheet IDs or arrays; use `StyleSheet.flatten()` when you need to inspect individual properties. `composeStyle()` preserves the inline style type, including `false`, `null`, and nested arrays.
|
|
45
45
|
|
|
46
|
+
Each runtime owns its registration table, cache, and style metadata. Replacing the shared StyleSheet factory refreshes each runtime on its next lookup. Nested inline arrays are expanded iteratively; the host flattener resolves their registered ID leaves. Cyclic arrays produce an explicit error.
|
|
47
|
+
|
|
48
|
+
`setManifest(manifest, publication?)` and `createNativeStyleRuntime(manifest?, publication?)` copy and freeze installed manifests. `getManifest()` returns that immutable snapshot. Host registration receives a separate mutable styles copy; if registration fails, the previous manifest, publication, cache and style metadata remain installed. Independent runtimes do not replace the top-level default runtime.
|
|
49
|
+
|
|
50
|
+
Metro publishes `{ revision, manifestSha256 }` with the exact manifest JSON bytes and installs the same identity through the virtual module. `getPublication()` returns this immutable identity; a manual `setManifest(manifest)` clears the previous identity. Node workers verify the JSON digest, while the native runtime validates and preserves the identity without recomputing SHA-256. `getRegisteredSnapshot`, `getRegisteredSnapshotByPath`, and `getRegisteredSnapshotByProjectRoot` await a complete publication. The synchronous `getVirtualModuleCode` only reads a diagnostic snapshot; use its async counterpart to wait for readiness. A publication identity does not prove which complete bundle the device received.
|
|
51
|
+
|
|
52
|
+
Variable-based transforms resolve after all selected custom properties have cascaded, so combinations such as `skew-x-6 skew-y-3` retain both axes. Unsupported selector structures and transform functions produce diagnostics instead of partial styles.
|
|
53
|
+
|
|
54
|
+
Unitless, percentage, and `em` line heights are resolved against the final font size after class and inline style precedence. The compiler retains their multiplier outside the static StyleSheet values. When font size comes from a parent, pass its known value through `tw(value, { fontSize })` or `getStaticStyle(ids, { fontSize })`; an unknown inherited size is not replaced with an assumed default. Custom runtime integrations can pass `StyleSheet.flatten` as the second argument to `setStyleSheetFactory` so registered inline styles participate in this calculation; Metro does this automatically.
|
|
55
|
+
|
|
56
|
+
Shadows use the modern React Native `boxShadow` array, preserving all layers, blur, spread, color, and inset. The host must support this property: use the New Architecture and check its OS requirements (Android outset shadows require Android 9+, inset shadows Android 10+). Pass `boxShadow: false` to `compileNativeStylesheet()` or `generateNativeStylesheet()` for an unsupported host; declarations then produce warnings rather than a partial legacy shadow approximation.
|
|
57
|
+
|
|
58
|
+
Shadow variables and color modifiers resolve after all selected class declarations and `!important` precedence. Fully transparent placeholder layers are omitted. `currentColor` and omitted shadow colors use the final class or inline text color; provide a known inherited color with `{ color }` in the runtime environment when needed. Unknown inherited colors remain unresolved until that context is provided. Color functions are normalized for both React Native and React Native Web.
|
|
59
|
+
|
|
46
60
|
## Public entry points
|
|
47
61
|
|
|
48
62
|
The package exposes `compiler`, `tailwind`, `babel`, `metro`, `runtime`, and the platform-neutral `env` type entry. Custom Metro setups can compose these entry points directly.
|
package/README.zh-CN.md
CHANGED
|
@@ -43,6 +43,20 @@ Metro 会扫描源码、生成精确候选集合和 manifest,并把 Babel JSX
|
|
|
43
43
|
|
|
44
44
|
`tw()` 与 `getStaticStyle()` 返回 React Native 的 `StyleProp`,可以直接传给 View、Text、Image 的 style。返回值可能含已注册的 StyleSheet ID 或数组;需要读取具体属性时使用 `StyleSheet.flatten()`。`composeStyle()` 保留内联样式类型,包括 `false`、`null` 和嵌套数组。
|
|
45
45
|
|
|
46
|
+
每个运行时独立保存注册表、缓存与样式元数据。替换共享 StyleSheet 注册器后,各实例在下次查询时刷新注册表。内联嵌套数组使用迭代展开,宿主 flattener 只解析其中已注册的 ID;循环数组会明确报错。
|
|
47
|
+
|
|
48
|
+
`setManifest(manifest, publication?)` 与 `createNativeStyleRuntime(manifest?, publication?)` 会复制并冻结安装的 manifest,`getManifest()` 返回该不可变快照。宿主注册器收到独立的可变 styles 副本;注册失败时,旧 manifest、发布身份、缓存及样式元数据保持完整。独立运行时不会替换顶层默认实例。
|
|
49
|
+
|
|
50
|
+
Metro 为实际 manifest JSON 字节发布 `{ revision, manifestSha256 }`,虚拟模块安装同一身份。`getPublication()` 返回不可变身份;手工调用不带身份的 `setManifest(manifest)` 会清除旧身份。Node worker 核对 JSON 摘要,原生运行时仅校验身份格式并保留身份,不重新计算 SHA-256。`getRegisteredSnapshot`、`getRegisteredSnapshotByPath` 与 `getRegisteredSnapshotByProjectRoot` 等待完整发布;同步 `getVirtualModuleCode` 只用于读取诊断快照,等待就绪应使用其异步版本。发布身份不能证明设备实际收到了哪份完整 bundle。
|
|
51
|
+
|
|
52
|
+
基于变量的 transform 在选中的全部自定义属性完成级联后计算,`skew-x-6 skew-y-3` 等组合会保留两轴。不支持的 selector 结构和 transform 函数会产生诊断,不能静默生成局部样式。
|
|
53
|
+
|
|
54
|
+
无单位、百分比和 `em` 行高在 class 与内联样式完成级联后,按最终字号计算;倍率保存在规则元数据中,不写入静态 StyleSheet。字号来自父元素时,可通过 `tw(value, { fontSize })` 或 `getStaticStyle(ids, { fontSize })` 显式提供已知继承字号;字号未知时不会猜测平台默认值。自定义运行时接入可把 `StyleSheet.flatten` 作为 `setStyleSheetFactory` 的第二个参数,使已注册的内联样式也参与计算;Metro 会自动接入。
|
|
55
|
+
|
|
56
|
+
阴影使用现代 React Native `boxShadow` 数组,保留所有层的模糊、spread、颜色与 inset。宿主需要启用新架构并满足平台要求:Android 外阴影要求 Android 9+,内阴影要求 Android 10+。不支持的宿主可向 `compileNativeStylesheet()` 或 `generateNativeStylesheet()` 传入 `boxShadow: false`;相关声明会产生告警,不会静默降级为丢失层或 spread 的旧阴影属性。
|
|
57
|
+
|
|
58
|
+
阴影变量和颜色 modifier 在选中 class 与 `!important` 声明完成级联后计算,全透明占位层会被省略。`currentColor` 和省略颜色的阴影使用最终 class 或内联文字颜色;需要继承颜色时,可通过运行时环境的 `{ color }` 提供已知值。继承颜色未知时保留未解析状态,不猜测黑色。颜色函数会规范化为 React Native 与 React Native Web 都接受的写法。
|
|
59
|
+
|
|
46
60
|
## 公开入口
|
|
47
61
|
|
|
48
62
|
包提供 `compiler`、`tailwind`、`babel`、`metro`、`runtime` 与中性类型入口 `env`。非 Expo 或定制 Metro 场景可以显式组合这些入口。
|
package/dist/babel.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.cjs");
|
|
2
2
|
let _babel_types = require("@babel/types");
|
|
3
3
|
_babel_types = require_rolldown_runtime.__toESM(_babel_types, 1);
|
|
4
|
-
|
|
4
|
+
// src/babel.ts
|
|
5
5
|
function classTokens(value) {
|
|
6
6
|
return value.split(/\s+/).filter(Boolean);
|
|
7
7
|
}
|
|
@@ -111,5 +111,4 @@ function weappReactNativeBabel() {
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
//#endregion
|
|
115
114
|
module.exports = weappReactNativeBabel;
|
package/dist/babel.d.cts
ADDED
package/dist/babel.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PluginObject, PluginPass } from "@babel/core";
|
|
2
1
|
import * as t from "@babel/types";
|
|
3
|
-
|
|
2
|
+
import { PluginObject, PluginPass } from "@babel/core";
|
|
4
3
|
export interface WeappReactNativeBabelOptions {
|
|
5
4
|
classNameSet?: Iterable<string> | undefined;
|
|
6
5
|
/** Metro 生成的 token -> StyleSheet ID lookup。 */
|
|
@@ -17,4 +16,4 @@ interface PluginState extends PluginPass {
|
|
|
17
16
|
virtualImported?: boolean;
|
|
18
17
|
}
|
|
19
18
|
export default function weappReactNativeBabel(): PluginObject<PluginState>;
|
|
20
|
-
|
|
19
|
+
export {};
|
package/dist/babel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
|
|
2
|
+
// src/babel.ts
|
|
3
3
|
function classTokens(value) {
|
|
4
4
|
return value.split(/\s+/).filter(Boolean);
|
|
5
5
|
}
|
|
@@ -109,5 +109,4 @@ function weappReactNativeBabel() {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
//#endregion
|
|
113
112
|
export { weappReactNativeBabel as default };
|
package/dist/compiler.cjs
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let node_crypto = require("node:crypto");
|
|
3
3
|
let _weapp_tailwindcss_postcss_native = require("@weapp-tailwindcss/postcss/native");
|
|
4
|
-
|
|
4
|
+
// src/compiler.ts
|
|
5
5
|
function addNativeVariantRules(manifest, candidates) {
|
|
6
6
|
for (const candidate of candidates) {
|
|
7
7
|
const parts = (0, _weapp_tailwindcss_postcss_native.splitClassName)(candidate);
|
|
8
8
|
if (parts.length < 2) continue;
|
|
9
9
|
const base = parts.at(-1);
|
|
10
10
|
if (!base || manifest.rules[candidate] || !manifest.rules[base]) continue;
|
|
11
|
+
const unsupported = (0, _weapp_tailwindcss_postcss_native.unsupportedVariant)(candidate);
|
|
12
|
+
if (unsupported) {
|
|
13
|
+
const warning = {
|
|
14
|
+
className: candidate,
|
|
15
|
+
property: "variant",
|
|
16
|
+
message: `不支持将 ${unsupported}: 变体编译为 React Native 条件样式`
|
|
17
|
+
};
|
|
18
|
+
if (!manifest.warnings.some((item) => item.className === candidate && item.property === warning.property && item.message === warning.message)) manifest.warnings.push(warning);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
11
21
|
const variant = (0, _weapp_tailwindcss_postcss_native.variantForClass)(candidate);
|
|
12
22
|
if (!variant.colorScheme && !variant.platform) continue;
|
|
13
23
|
manifest.rules[candidate] = manifest.rules[base].map((rule) => ({
|
|
14
24
|
...rule,
|
|
25
|
+
id: void 0,
|
|
15
26
|
...variant,
|
|
16
27
|
style: { ...rule.style }
|
|
17
28
|
}));
|
|
@@ -45,7 +56,6 @@ function compileNativeStylesheet(css, options = {}) {
|
|
|
45
56
|
...compiled
|
|
46
57
|
});
|
|
47
58
|
}
|
|
48
|
-
//#endregion
|
|
49
59
|
exports.addNativeVariantRules = addNativeVariantRules;
|
|
50
60
|
Object.defineProperty(exports, "baseClassName", {
|
|
51
61
|
enumerable: true,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as NativeStyleManifest, t as CompileNativeStylesheetOptions } from "./types-CxNMLBiF.cjs";
|
|
2
|
+
import { baseClassName } from "@weapp-tailwindcss/postcss/native";
|
|
3
|
+
export declare function addNativeVariantRules(manifest: NativeStyleManifest, candidates: Iterable<string>): void;
|
|
4
|
+
/** 为 manifest 生成稳定的 StyleSheet ID 和 Babel 静态 lookup。 */
|
|
5
|
+
export declare function finalizeNativeManifest(manifest: NativeStyleManifest): NativeStyleManifest;
|
|
6
|
+
export declare function compileNativeStylesheet(css: string, options?: CompileNativeStylesheetOptions): NativeStyleManifest;
|
|
7
|
+
export { baseClassName };
|
package/dist/compiler.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as NativeStyleManifest, t as CompileNativeStylesheetOptions } from "./types-CxNMLBiF.js";
|
|
2
2
|
import { baseClassName } from "@weapp-tailwindcss/postcss/native";
|
|
3
|
-
//#region src/compiler.d.ts
|
|
4
3
|
export declare function addNativeVariantRules(manifest: NativeStyleManifest, candidates: Iterable<string>): void;
|
|
5
4
|
/** 为 manifest 生成稳定的 StyleSheet ID 和 Babel 静态 lookup。 */
|
|
6
5
|
export declare function finalizeNativeManifest(manifest: NativeStyleManifest): NativeStyleManifest;
|
|
7
6
|
export declare function compileNativeStylesheet(css: string, options?: CompileNativeStylesheetOptions): NativeStyleManifest;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { baseClassName };
|
package/dist/compiler.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { baseClassName, compileNativeCss, splitClassName, variantForClass } from "@weapp-tailwindcss/postcss/native";
|
|
3
|
-
|
|
2
|
+
import { baseClassName, compileNativeCss, splitClassName, unsupportedVariant, variantForClass } from "@weapp-tailwindcss/postcss/native";
|
|
3
|
+
// src/compiler.ts
|
|
4
4
|
function addNativeVariantRules(manifest, candidates) {
|
|
5
5
|
for (const candidate of candidates) {
|
|
6
6
|
const parts = splitClassName(candidate);
|
|
7
7
|
if (parts.length < 2) continue;
|
|
8
8
|
const base = parts.at(-1);
|
|
9
9
|
if (!base || manifest.rules[candidate] || !manifest.rules[base]) continue;
|
|
10
|
+
const unsupported = unsupportedVariant(candidate);
|
|
11
|
+
if (unsupported) {
|
|
12
|
+
const warning = {
|
|
13
|
+
className: candidate,
|
|
14
|
+
property: "variant",
|
|
15
|
+
message: `不支持将 ${unsupported}: 变体编译为 React Native 条件样式`
|
|
16
|
+
};
|
|
17
|
+
if (!manifest.warnings.some((item) => item.className === candidate && item.property === warning.property && item.message === warning.message)) manifest.warnings.push(warning);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
10
20
|
const variant = variantForClass(candidate);
|
|
11
21
|
if (!variant.colorScheme && !variant.platform) continue;
|
|
12
22
|
manifest.rules[candidate] = manifest.rules[base].map((rule) => ({
|
|
13
23
|
...rule,
|
|
24
|
+
id: void 0,
|
|
14
25
|
...variant,
|
|
15
26
|
style: { ...rule.style }
|
|
16
27
|
}));
|
|
@@ -44,5 +55,4 @@ function compileNativeStylesheet(css, options = {}) {
|
|
|
44
55
|
...compiled
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
|
-
//#endregion
|
|
48
58
|
export { addNativeVariantRules, baseClassName, compileNativeStylesheet, finalizeNativeManifest };
|
package/dist/env.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 供业务组件复用的 React Native className 属性。 */
|
|
2
|
+
export interface NativeClassNameProps {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
declare module 'react-native' {
|
|
6
|
+
interface ViewProps extends NativeClassNameProps {}
|
|
7
|
+
interface TextProps extends NativeClassNameProps {}
|
|
8
|
+
interface ImageProps extends NativeClassNameProps {}
|
|
9
|
+
interface ScrollViewProps extends NativeClassNameProps {}
|
|
10
|
+
}
|
package/dist/env.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/env.d.ts
|
|
2
1
|
/** 供业务组件复用的 React Native className 属性。 */
|
|
3
2
|
export interface NativeClassNameProps {
|
|
4
3
|
className?: string | undefined;
|
|
@@ -8,5 +7,4 @@ declare module 'react-native' {
|
|
|
8
7
|
interface TextProps extends NativeClassNameProps {}
|
|
9
8
|
interface ImageProps extends NativeClassNameProps {}
|
|
10
9
|
interface ScrollViewProps extends NativeClassNameProps {}
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
10
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_babel = require("./babel.cjs");
|
|
3
3
|
const require_compiler = require("./compiler.cjs");
|
|
4
|
-
const require_metro = require("./metro-
|
|
5
|
-
const require_runtime = require("./runtime.cjs");
|
|
6
|
-
const require_tailwind = require("./tailwind.cjs");
|
|
4
|
+
const require_metro = require("./metro-kaKzXOAU.cjs");
|
|
5
|
+
const require_runtime = require("./runtime-CbkbHrPb.cjs");
|
|
6
|
+
const require_tailwind = require("./tailwind-CVspvWID.cjs");
|
|
7
7
|
exports.VIRTUAL_MANIFEST_MODULE = require_metro.VIRTUAL_MANIFEST_MODULE;
|
|
8
8
|
exports.babelPlugin = require_babel;
|
|
9
9
|
exports.compileNativeStylesheet = require_compiler.compileNativeStylesheet;
|
|
@@ -11,7 +11,11 @@ exports.composeStyle = require_runtime.composeStyle;
|
|
|
11
11
|
exports.createNativeStyleRuntime = require_runtime.createNativeStyleRuntime;
|
|
12
12
|
exports.generateNativeStylesheet = require_tailwind.generateNativeStylesheet;
|
|
13
13
|
exports.getManifest = require_runtime.getManifest;
|
|
14
|
+
exports.getPublication = require_runtime.getPublication;
|
|
14
15
|
exports.getRegisteredManifest = require_metro.getRegisteredManifest;
|
|
16
|
+
exports.getRegisteredSnapshot = require_metro.getRegisteredSnapshot;
|
|
17
|
+
exports.getRegisteredSnapshotByPath = require_metro.getRegisteredSnapshotByPath;
|
|
18
|
+
exports.getRegisteredSnapshotByProjectRoot = require_metro.getRegisteredSnapshotByProjectRoot;
|
|
15
19
|
exports.getStaticStyle = require_runtime.getStaticStyle;
|
|
16
20
|
exports.getVirtualModuleCode = require_metro.getVirtualModuleCode;
|
|
17
21
|
exports.getVirtualModuleCodeAsync = require_metro.getVirtualModuleCodeAsync;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import weappReactNativeBabel from "./babel.cjs";
|
|
2
|
+
import { a as NativeStyleManifest, i as NativePlatform, n as NativeCompilerWarning, o as NativeStyleRule, r as NativeManifestPublication, t as CompileNativeStylesheetOptions } from "./types-CxNMLBiF.cjs";
|
|
3
|
+
import { compileNativeStylesheet } from "./compiler.cjs";
|
|
4
|
+
import { d as getRegisteredSnapshotByPath, f as getRegisteredSnapshotByProjectRoot, h as getVirtualModuleCodeAsync, m as getVirtualModuleCode, o as withWeappTailwindcss, r as VIRTUAL_MANIFEST_MODULE, s as getRegisteredManifest, u as getRegisteredSnapshot } from "./metro-BdsKKvRn.cjs";
|
|
5
|
+
import { a as getStaticStyle, c as setStyleSheetFactory, d as NativeStyleEnvironment, f as NativeStyleRuntime, i as getPublication, l as tw, n as createNativeStyleRuntime, o as setEnvironment, p as NativeStyleValue, r as getManifest, s as setManifest, t as composeStyle, u as NativeClassValue } from "./runtime-D4ZGX6yk.cjs";
|
|
6
|
+
import { n as generateNativeStylesheet } from "./tailwind-CfKLPJuW.cjs";
|
|
7
|
+
export { type CompileNativeStylesheetOptions, type NativeClassValue, type NativeCompilerWarning, type NativeManifestPublication, type NativePlatform, type NativeStyleEnvironment, type NativeStyleManifest, type NativeStyleRule, type NativeStyleRuntime, type NativeStyleValue, VIRTUAL_MANIFEST_MODULE, weappReactNativeBabel as babelPlugin, compileNativeStylesheet, composeStyle, createNativeStyleRuntime, generateNativeStylesheet, getManifest, getPublication, getRegisteredManifest, getRegisteredSnapshot, getRegisteredSnapshotByPath, getRegisteredSnapshotByProjectRoot, getStaticStyle, getVirtualModuleCode, getVirtualModuleCodeAsync, setEnvironment, setManifest, setStyleSheetFactory, tw, withWeappTailwindcss };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import weappReactNativeBabel from "./babel.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as NativeStyleManifest, i as NativePlatform, n as NativeCompilerWarning, o as NativeStyleRule, r as NativeManifestPublication, t as CompileNativeStylesheetOptions } from "./types-CxNMLBiF.js";
|
|
3
3
|
import { compileNativeStylesheet } from "./compiler.js";
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import { generateNativeStylesheet } from "./tailwind.js";
|
|
7
|
-
export { type CompileNativeStylesheetOptions, type NativeClassValue, type NativeCompilerWarning, type NativePlatform, type NativeStyleEnvironment, type NativeStyleManifest, type NativeStyleRule, type NativeStyleRuntime, type NativeStyleValue, VIRTUAL_MANIFEST_MODULE, weappReactNativeBabel as babelPlugin, compileNativeStylesheet, composeStyle, createNativeStyleRuntime, generateNativeStylesheet, getManifest, getRegisteredManifest, getStaticStyle, getVirtualModuleCode, getVirtualModuleCodeAsync, setEnvironment, setManifest, setStyleSheetFactory, tw, withWeappTailwindcss };
|
|
4
|
+
import { d as getRegisteredSnapshotByPath, f as getRegisteredSnapshotByProjectRoot, h as getVirtualModuleCodeAsync, m as getVirtualModuleCode, o as withWeappTailwindcss, r as VIRTUAL_MANIFEST_MODULE, s as getRegisteredManifest, u as getRegisteredSnapshot } from "./metro-ahmChgsA.js";
|
|
5
|
+
import { a as getStaticStyle, c as setStyleSheetFactory, d as NativeStyleEnvironment, f as NativeStyleRuntime, i as getPublication, l as tw, n as createNativeStyleRuntime, o as setEnvironment, p as NativeStyleValue, r as getManifest, s as setManifest, t as composeStyle, u as NativeClassValue } from "./runtime-YHlnn5ip.js";
|
|
6
|
+
import { n as generateNativeStylesheet } from "./tailwind-4T0v_pRK.js";
|
|
7
|
+
export { type CompileNativeStylesheetOptions, type NativeClassValue, type NativeCompilerWarning, type NativeManifestPublication, type NativePlatform, type NativeStyleEnvironment, type NativeStyleManifest, type NativeStyleRule, type NativeStyleRuntime, type NativeStyleValue, VIRTUAL_MANIFEST_MODULE, weappReactNativeBabel as babelPlugin, compileNativeStylesheet, composeStyle, createNativeStyleRuntime, generateNativeStylesheet, getManifest, getPublication, getRegisteredManifest, getRegisteredSnapshot, getRegisteredSnapshotByPath, getRegisteredSnapshotByProjectRoot, getStaticStyle, getVirtualModuleCode, getVirtualModuleCodeAsync, setEnvironment, setManifest, setStyleSheetFactory, tw, withWeappTailwindcss };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import weappReactNativeBabel from "./babel.js";
|
|
2
2
|
import { compileNativeStylesheet } from "./compiler.js";
|
|
3
|
-
import { c as getVirtualModuleCodeAsync, l as
|
|
4
|
-
import {
|
|
5
|
-
import { generateNativeStylesheet } from "./tailwind.js";
|
|
6
|
-
export { VIRTUAL_MANIFEST_MODULE, weappReactNativeBabel as babelPlugin, compileNativeStylesheet, composeStyle, createNativeStyleRuntime, generateNativeStylesheet, getManifest, getRegisteredManifest, getStaticStyle, getVirtualModuleCode, getVirtualModuleCodeAsync, setEnvironment, setManifest, setStyleSheetFactory, tw, withWeappTailwindcss };
|
|
3
|
+
import { c as getRegisteredSnapshotByPath, d as getVirtualModuleCode, f as getVirtualModuleCodeAsync, i as getRegisteredManifest, l as getRegisteredSnapshotByProjectRoot, r as withWeappTailwindcss, s as getRegisteredSnapshot, t as VIRTUAL_MANIFEST_MODULE } from "./metro-OMh6z1jy.js";
|
|
4
|
+
import { a as getStaticStyle, c as setStyleSheetFactory, i as getPublication, l as tw, n as createNativeStyleRuntime, o as setEnvironment, r as getManifest, s as setManifest, t as composeStyle } from "./runtime-DuvYZu4P.js";
|
|
5
|
+
import { t as generateNativeStylesheet } from "./tailwind-B1Gl9P_t.js";
|
|
6
|
+
export { VIRTUAL_MANIFEST_MODULE, weappReactNativeBabel as babelPlugin, compileNativeStylesheet, composeStyle, createNativeStyleRuntime, generateNativeStylesheet, getManifest, getPublication, getRegisteredManifest, getRegisteredSnapshot, getRegisteredSnapshotByPath, getRegisteredSnapshotByProjectRoot, getStaticStyle, getVirtualModuleCode, getVirtualModuleCodeAsync, setEnvironment, setManifest, setStyleSheetFactory, tw, withWeappTailwindcss };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/runtime/manifest.ts
|
|
2
|
+
/** 只冻结当前快照拥有的数据,不冻结调用方传入的对象。 */
|
|
3
|
+
function freezeSnapshot(value) {
|
|
4
|
+
if (value && typeof value === "object") {
|
|
5
|
+
for (const child of Object.values(value)) freezeSnapshot(child);
|
|
6
|
+
Object.freeze(value);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function parseManifestSnapshot(json) {
|
|
11
|
+
return freezeSnapshot(JSON.parse(json));
|
|
12
|
+
}
|
|
13
|
+
function copyManifestSnapshot(manifest) {
|
|
14
|
+
return parseManifestSnapshot(JSON.stringify(manifest));
|
|
15
|
+
}
|
|
16
|
+
function copyPublication(publication) {
|
|
17
|
+
if (!publication) return;
|
|
18
|
+
if (typeof publication.revision !== "string" || !publication.revision.trim() || typeof publication.manifestSha256 !== "string" || !/^[a-f\d]{64}$/.test(publication.manifestSha256)) throw new Error("React Native manifest 发布身份无效");
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
revision: publication.revision,
|
|
21
|
+
manifestSha256: publication.manifestSha256
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(exports, "copyManifestSnapshot", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function() {
|
|
27
|
+
return copyManifestSnapshot;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "copyPublication", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return copyPublication;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "freezeSnapshot", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function() {
|
|
39
|
+
return freezeSnapshot;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "parseManifestSnapshot", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function() {
|
|
45
|
+
return parseManifestSnapshot;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/runtime/manifest.ts
|
|
2
|
+
/** 只冻结当前快照拥有的数据,不冻结调用方传入的对象。 */
|
|
3
|
+
function freezeSnapshot(value) {
|
|
4
|
+
if (value && typeof value === "object") {
|
|
5
|
+
for (const child of Object.values(value)) freezeSnapshot(child);
|
|
6
|
+
Object.freeze(value);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function parseManifestSnapshot(json) {
|
|
11
|
+
return freezeSnapshot(JSON.parse(json));
|
|
12
|
+
}
|
|
13
|
+
function copyManifestSnapshot(manifest) {
|
|
14
|
+
return parseManifestSnapshot(JSON.stringify(manifest));
|
|
15
|
+
}
|
|
16
|
+
function copyPublication(publication) {
|
|
17
|
+
if (!publication) return;
|
|
18
|
+
if (typeof publication.revision !== "string" || !publication.revision.trim() || typeof publication.manifestSha256 !== "string" || !/^[a-f\d]{64}$/.test(publication.manifestSha256)) throw new Error("React Native manifest 发布身份无效");
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
revision: publication.revision,
|
|
21
|
+
manifestSha256: publication.manifestSha256
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export { parseManifestSnapshot as i, copyPublication as n, freezeSnapshot as r, copyManifestSnapshot as t };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { a as NativeStyleManifest, r as NativeManifestPublication } from "./types-CxNMLBiF.cjs";
|
|
2
|
+
interface NativeManifestSnapshot {
|
|
3
|
+
version: number;
|
|
4
|
+
manifest: NativeStyleManifest;
|
|
5
|
+
manifestJson: string;
|
|
6
|
+
virtualPath: string;
|
|
7
|
+
publication?: NativeManifestPublication;
|
|
8
|
+
}
|
|
9
|
+
interface RegisteredManifest {
|
|
10
|
+
readonly version: number;
|
|
11
|
+
readonly manifest: NativeManifestSnapshot['manifest'];
|
|
12
|
+
snapshot: NativeManifestSnapshot;
|
|
13
|
+
projectRoot: string;
|
|
14
|
+
virtualPath: string;
|
|
15
|
+
manifestPath: string;
|
|
16
|
+
manifestReadyPath: string;
|
|
17
|
+
ready: Promise<void>;
|
|
18
|
+
refresh: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
declare function getRegisteredVirtualModule(filename: string): Readonly<RegisteredManifest> | undefined;
|
|
21
|
+
declare function getRegisteredSnapshot(id: string): Promise<NativeManifestSnapshot | undefined>;
|
|
22
|
+
/** 文件路径与项目根目录查询均选择最近注册的入口,不能混用两个实例的身份。 */
|
|
23
|
+
declare function getRegisteredSnapshotByPath(filename: string): Promise<NativeManifestSnapshot | undefined>;
|
|
24
|
+
declare function getRegisteredSnapshotByProjectRoot(projectRoot: string): Promise<NativeManifestSnapshot | undefined>;
|
|
25
|
+
declare function getRegisteredManifest(id: string): Promise<NativeStyleManifest | undefined>;
|
|
26
|
+
declare function getRegisteredManifestByPath(filename: string): Promise<NativeStyleManifest | undefined>;
|
|
27
|
+
declare function getRegisteredManifestByProjectRoot(projectRoot: string): Promise<NativeStyleManifest | undefined>;
|
|
28
|
+
/** 同步读取最近快照供诊断;只有异步入口会等待当前发布成功。 */
|
|
29
|
+
declare function getVirtualModuleCode(filename: string): string | undefined;
|
|
30
|
+
declare function getVirtualModuleCodeAsync(filename: string): Promise<string | undefined>;
|
|
31
|
+
declare const VIRTUAL_MANIFEST_MODULE = "@weapp-tailwindcss/react-native/virtual";
|
|
32
|
+
interface MetroConfigLike {
|
|
33
|
+
resolver?: {
|
|
34
|
+
extraNodeModules?: Record<string, string>;
|
|
35
|
+
sourceExts?: string[];
|
|
36
|
+
resolveRequest?: (context: unknown, moduleName: string, platform?: string) => unknown;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
transformer?: Record<string, unknown>;
|
|
40
|
+
transformerPath?: string;
|
|
41
|
+
watchFolders?: string[];
|
|
42
|
+
server?: Record<string, unknown>;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
interface WeappReactNativeMetroOptions {
|
|
46
|
+
projectRoot?: string | undefined;
|
|
47
|
+
input?: string | undefined;
|
|
48
|
+
css?: string | undefined;
|
|
49
|
+
manifest?: NativeStyleManifest | undefined;
|
|
50
|
+
classSet?: Iterable<string> | undefined;
|
|
51
|
+
sourceGlobs?: string[] | undefined;
|
|
52
|
+
watchFiles?: string[] | undefined;
|
|
53
|
+
}
|
|
54
|
+
interface NativeManifestPaths {
|
|
55
|
+
manifestPath: string;
|
|
56
|
+
manifestReadyPath: string;
|
|
57
|
+
}
|
|
58
|
+
/** 为 Metro worker 提供不依赖进程内 registry 的 manifest 入口。 */
|
|
59
|
+
declare function getManifestPathsForProjectRoot(projectRoot: string): NativeManifestPaths;
|
|
60
|
+
declare function withWeappTailwindcss<T extends MetroConfigLike>(config: T, options?: WeappReactNativeMetroOptions): T & MetroConfigLike;
|
|
61
|
+
declare function withWeappTailwindcss<T extends MetroConfigLike>(config: Promise<T> | (() => T | Promise<T>), options?: WeappReactNativeMetroOptions): Promise<T & MetroConfigLike>;
|
|
62
|
+
declare function withWeappTailwindcss<T extends MetroConfigLike>(config: T | Promise<T> | (() => T | Promise<T>), options?: WeappReactNativeMetroOptions): (T & MetroConfigLike) | Promise<T & MetroConfigLike>;
|
|
63
|
+
export { getManifestPathsForProjectRoot as a, getRegisteredManifestByPath as c, getRegisteredSnapshotByPath as d, getRegisteredSnapshotByProjectRoot as f, getVirtualModuleCodeAsync as h, WeappReactNativeMetroOptions as i, getRegisteredManifestByProjectRoot as l, getVirtualModuleCode as m, NativeManifestPaths as n, withWeappTailwindcss as o, getRegisteredVirtualModule as p, VIRTUAL_MANIFEST_MODULE as r, getRegisteredManifest as s, MetroConfigLike as t, getRegisteredSnapshot as u };
|