@weapp-tailwindcss/react-native 0.3.4 → 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
@@ -1,4 +1,5 @@
1
1
  import { compileNativeStylesheet } from "./compiler.js";
2
+ import { i as parseManifestSnapshot, n as copyPublication, r as freezeSnapshot } from "./manifest-DuhmZ2T9.js";
2
3
  import { createRequire } from "node:module";
3
4
  import { createHash, randomUUID } from "node:crypto";
4
5
  import fs from "node:fs";
@@ -7,7 +8,14 @@ import path from "node:path";
7
8
  import process from "node:process";
8
9
  import { URL, fileURLToPath } from "node:url";
9
10
  import { setTimeout } from "node:timers/promises";
10
- //#region src/metro/manifest-store.ts
11
+ // src/metro/manifest-store.ts
12
+ function throwWhenAborted(signal) {
13
+ if (!signal?.aborted) return;
14
+ if ("reason" in signal) throw signal.reason;
15
+ const error = /* @__PURE__ */ new Error("React Native manifest 读取已取消");
16
+ error.name = "AbortError";
17
+ throw error;
18
+ }
11
19
  /** 同目录替换,避免 Metro 或 worker 读到截断后的虚拟模块与 JSON。 */
12
20
  function writeManifestFile(filename, content) {
13
21
  const temporary = `${filename}.${randomUUID()}.tmp`;
@@ -19,40 +27,98 @@ function writeManifestFile(filename, content) {
19
27
  }
20
28
  }
21
29
  /** ready 前后版本一致才接受产物;失败和超时不能降级成旧 manifest。 */
22
- async function readPublishedSnapshot(filename, readyPath) {
30
+ async function readPublishedSnapshot(filename, readyPath, signal) {
31
+ throwWhenAborted(signal);
23
32
  if (!readyPath) try {
24
- return { manifest: JSON.parse(await fs.promises.readFile(filename, "utf8")) };
33
+ const manifestJson = await fs.promises.readFile(filename, {
34
+ encoding: "utf8",
35
+ signal
36
+ });
37
+ return freezeSnapshot({
38
+ manifest: parseManifestSnapshot(manifestJson),
39
+ manifestJson
40
+ });
25
41
  } catch (error) {
26
42
  if (error.code === "ENOENT") return;
27
43
  throw error;
28
44
  }
29
45
  const deadline = Date.now() + 12e4;
30
46
  while (Date.now() < deadline) {
47
+ throwWhenAborted(signal);
31
48
  try {
32
- const before = await fs.promises.readFile(readyPath, "utf8");
33
- const content = await fs.promises.readFile(filename, "utf8");
34
- if (before === await fs.promises.readFile(readyPath, "utf8")) {
35
- let virtualPath;
36
- if (before.startsWith("{")) {
37
- const publication = JSON.parse(before);
38
- if (publication.error) throw new Error(publication.error);
39
- if (!publication.revision || !publication.virtualPath) throw new Error("React Native manifest 缺少发布身份");
40
- virtualPath = publication.virtualPath;
41
- } else if (!/^\d+\s*$/.test(before)) throw new Error("React Native manifest 发布标识无效");
42
- return {
43
- manifest: JSON.parse(content),
44
- ...virtualPath ? { virtualPath } : {}
45
- };
49
+ const before = await fs.promises.readFile(readyPath, {
50
+ encoding: "utf8",
51
+ signal
52
+ });
53
+ const ready = JSON.parse(before);
54
+ if (ready?.error) {
55
+ if (before !== await fs.promises.readFile(readyPath, {
56
+ encoding: "utf8",
57
+ signal
58
+ })) continue;
59
+ throw new Error(ready.error);
60
+ }
61
+ if (!ready || typeof ready.virtualPath !== "string" || !ready.virtualPath || !ready.revision || !ready.manifestSha256) throw new Error("React Native manifest 缺少发布身份");
62
+ const publication = copyPublication({
63
+ revision: ready.revision,
64
+ manifestSha256: ready.manifestSha256
65
+ });
66
+ const content = await fs.promises.readFile(filename, {
67
+ encoding: "utf8",
68
+ signal
69
+ });
70
+ if (before === await fs.promises.readFile(readyPath, {
71
+ encoding: "utf8",
72
+ signal
73
+ })) {
74
+ if (createHash("sha256").update(content, "utf8").digest("hex") !== publication.manifestSha256) throw new Error("React Native manifest 字节摘要不匹配");
75
+ return freezeSnapshot({
76
+ manifest: parseManifestSnapshot(content),
77
+ manifestJson: content,
78
+ virtualPath: ready.virtualPath,
79
+ publication
80
+ });
46
81
  }
47
82
  } catch (error) {
48
83
  if (error.code !== "ENOENT") throw error;
49
84
  }
50
- await setTimeout(25);
85
+ await setTimeout(25, void 0, { signal });
51
86
  }
52
87
  throw new Error(`等待 React Native manifest 超时:${filename}`);
53
88
  }
54
- //#endregion
55
- //#region src/metro/refresh.ts
89
+ // src/metro/virtual-module.ts
90
+ function virtualModuleCode(manifest, publication, manifestJson = JSON.stringify(manifest)) {
91
+ const identity = publication ? `, ${JSON.stringify(publication)}` : "";
92
+ return `import { setEnvironment, setManifest, setStyleSheetFactory } from ${JSON.stringify("@weapp-tailwindcss/react-native/runtime")};\nimport { Appearance, Platform, StyleSheet } from 'react-native';\nsetStyleSheetFactory(StyleSheet.create, StyleSheet.flatten);\nconst syncEnvironment = () => setEnvironment({ platform: Platform.OS, colorScheme: Appearance.getColorScheme() ?? 'light' });\nsetManifest(${manifestJson}${identity});\nsyncEnvironment();\nAppearance.addChangeListener?.(({ colorScheme }) => setEnvironment({ platform: Platform.OS, colorScheme: colorScheme ?? 'light' }));\nexport default undefined;`;
93
+ }
94
+ // src/metro/publication.ts
95
+ function createManifestSnapshot(manifest, virtualPath, version) {
96
+ const manifestJson = JSON.stringify(manifest);
97
+ const publication = version > 0 ? {
98
+ revision: randomUUID(),
99
+ manifestSha256: createHash("sha256").update(manifestJson, "utf8").digest("hex")
100
+ } : void 0;
101
+ return freezeSnapshot({
102
+ manifest: parseManifestSnapshot(manifestJson),
103
+ manifestJson,
104
+ virtualPath,
105
+ version,
106
+ ...publication ? { publication } : {}
107
+ });
108
+ }
109
+ /** 三份产物共用一次序列化;最后的 ready 成功前不提交内存状态。 */
110
+ function writeManifestSnapshot(paths, snapshot) {
111
+ fs.mkdirSync(path.dirname(snapshot.virtualPath), { recursive: true });
112
+ fs.mkdirSync(path.dirname(paths.manifestPath), { recursive: true });
113
+ writeManifestFile(snapshot.virtualPath, virtualModuleCode(snapshot.manifest, snapshot.publication, snapshot.manifestJson));
114
+ writeManifestFile(paths.manifestPath, snapshot.manifestJson);
115
+ if (snapshot.publication) writeManifestFile(paths.manifestReadyPath, JSON.stringify({
116
+ ...snapshot.publication,
117
+ version: snapshot.version,
118
+ virtualPath: snapshot.virtualPath
119
+ }));
120
+ }
121
+ // src/metro/refresh.ts
56
122
  function fingerprint(files) {
57
123
  const hash = createHash("sha256");
58
124
  for (const file of files) try {
@@ -91,8 +157,26 @@ async function compileStableInput(files, compile, isCurrent) {
91
157
  }
92
158
  if (isCurrent()) throw new Error("React Native 样式输入持续变化,5 次稳定性检查后仍未完成保存;请完成保存后重试。");
93
159
  }
94
- /** 等待期间出现新一轮刷新时,继续等待新一轮;过期轮的失败不能遮蔽新结果。 */
95
- async function waitForCurrentRefresh(entry) {
160
+ // src/metro/registry.ts
161
+ const registry = /* @__PURE__ */ new Map();
162
+ const publicEntries = /* @__PURE__ */ new WeakMap();
163
+ function getRegisteredVirtualModule(filename) {
164
+ const entry = [...registry.values()].find((entry) => entry.virtualPath === filename);
165
+ if (!entry) return;
166
+ let view = publicEntries.get(entry);
167
+ if (!view) {
168
+ const properties = Object.fromEntries(Object.keys(entry).map((key) => [key, {
169
+ enumerable: true,
170
+ get: () => entry[key]
171
+ }]));
172
+ view = Object.freeze(Object.defineProperties({}, properties));
173
+ publicEntries.set(entry, view);
174
+ }
175
+ return view;
176
+ }
177
+ /** 检查 ready 与返回 snapshot 在同一微任务内完成,不能夹入新的刷新。 */
178
+ async function readRegisteredSnapshot(entry) {
179
+ if (!entry) return;
96
180
  for (;;) {
97
181
  const ready = entry.ready;
98
182
  try {
@@ -100,31 +184,106 @@ async function waitForCurrentRefresh(entry) {
100
184
  } catch (error) {
101
185
  if (ready === entry.ready) throw error;
102
186
  }
103
- if (ready === entry.ready) return;
187
+ if (ready === entry.ready) return entry.snapshot;
104
188
  }
105
189
  }
106
- //#endregion
107
- //#region src/metro/virtual-module.ts
108
- function virtualModuleCode(manifest) {
109
- return `import { setEnvironment, setManifest, setStyleSheetFactory } from ${JSON.stringify("@weapp-tailwindcss/react-native/runtime")};\nimport { Appearance, Platform, StyleSheet } from 'react-native';\nsetStyleSheetFactory(StyleSheet.create);\nconst syncEnvironment = () => setEnvironment({ platform: Platform.OS, colorScheme: Appearance.getColorScheme() ?? 'light' });\nsetManifest(${JSON.stringify(manifest)});\nsyncEnvironment();\nAppearance.addChangeListener?.(({ colorScheme }) => setEnvironment({ platform: Platform.OS, colorScheme: colorScheme ?? 'light' }));\nexport default undefined;`;
190
+ function getRegisteredSnapshot(id) {
191
+ return readRegisteredSnapshot(registry.get(id));
192
+ }
193
+ /** 文件路径与项目根目录查询均选择最近注册的入口,不能混用两个实例的身份。 */
194
+ function getRegisteredSnapshotByPath(filename) {
195
+ return readRegisteredSnapshot([...registry.values()].filter((entry) => entry.manifestPath === filename).at(-1));
196
+ }
197
+ function getRegisteredSnapshotByProjectRoot(projectRoot) {
198
+ const resolvedRoot = path.resolve(projectRoot);
199
+ return readRegisteredSnapshot([...registry.values()].filter((entry) => entry.projectRoot === resolvedRoot).at(-1));
200
+ }
201
+ async function getRegisteredManifest(id) {
202
+ return (await getRegisteredSnapshot(id))?.manifest;
203
+ }
204
+ async function getRegisteredManifestByPath(filename) {
205
+ return (await getRegisteredSnapshotByPath(filename))?.manifest;
206
+ }
207
+ async function getRegisteredManifestByProjectRoot(projectRoot) {
208
+ return (await getRegisteredSnapshotByProjectRoot(projectRoot))?.manifest;
209
+ }
210
+ /** 同步读取最近快照供诊断;只有异步入口会等待当前发布成功。 */
211
+ function getVirtualModuleCode(filename) {
212
+ const snapshot = getRegisteredVirtualModule(filename)?.snapshot;
213
+ return snapshot ? virtualModuleCode(snapshot.manifest, snapshot.publication, snapshot.manifestJson) : void 0;
214
+ }
215
+ async function getVirtualModuleCodeAsync(filename) {
216
+ const snapshot = await readRegisteredSnapshot(getRegisteredVirtualModule(filename));
217
+ return snapshot ? virtualModuleCode(snapshot.manifest, snapshot.publication, snapshot.manifestJson) : void 0;
218
+ }
219
+ // src/metro/watch.ts
220
+ function fileVersion(stat) {
221
+ return [
222
+ stat.dev,
223
+ stat.ino,
224
+ stat.size,
225
+ stat.mtimeNs,
226
+ stat.ctimeNs
227
+ ].join(":");
228
+ }
229
+ function readFileVersion(target) {
230
+ try {
231
+ return fileVersion(fs.statSync(target, { bigint: true }));
232
+ } catch (error) {
233
+ if (["ENOENT", "ENOTDIR"].includes(error.code ?? "")) return;
234
+ throw error;
235
+ }
110
236
  }
111
- //#endregion
112
- //#region src/metro/watch.ts
113
- /** 文件监听绑定父目录,避免编辑器原子替换文件后仍监听已移除的 inode。 */
237
+ /** 父目录事件提供即时通知,文件版本核对补齐原生通知遗漏。 */
114
238
  function watchInput(target, changed) {
115
- const recursive = fs.statSync(target).isDirectory();
239
+ const initial = fs.statSync(target, { bigint: true });
240
+ const recursive = initial.isDirectory();
116
241
  const watchRoot = recursive ? target : path.dirname(target);
117
- return fs.watch(watchRoot, {
242
+ let version = fileVersion(initial);
243
+ let closed = false;
244
+ let timer;
245
+ const watcher = fs.watch(watchRoot, {
118
246
  persistent: false,
119
247
  recursive
120
248
  }, (_event, filename) => {
121
- if (recursive || filename === null || path.resolve(watchRoot, filename) === target) changed();
249
+ if (closed) return;
250
+ if (recursive) changed();
251
+ else if (filename === null || path.resolve(watchRoot, filename) === target) reconcile(true);
122
252
  });
253
+ function reconcile(force) {
254
+ if (closed) return;
255
+ let current;
256
+ try {
257
+ current = readFileVersion(target);
258
+ } catch (error) {
259
+ watcher.close();
260
+ watcher.emit("error", error);
261
+ return;
262
+ }
263
+ if (force || current !== version) {
264
+ version = current;
265
+ changed();
266
+ }
267
+ }
268
+ const stop = () => {
269
+ closed = true;
270
+ clearInterval(timer);
271
+ };
272
+ const close = watcher.close.bind(watcher);
273
+ watcher.close = () => {
274
+ if (closed) return;
275
+ stop();
276
+ close();
277
+ };
278
+ watcher.once("close", stop);
279
+ if (!recursive) {
280
+ timer = setInterval(reconcile, 100, false);
281
+ timer.unref();
282
+ }
283
+ return watcher;
123
284
  }
124
- //#endregion
125
- //#region src/metro.ts
285
+ // src/metro.ts
126
286
  const VIRTUAL_MANIFEST_MODULE = "@weapp-tailwindcss/react-native/virtual";
127
- const registry = /* @__PURE__ */ new Map();
128
287
  const appRootSingletonModules = /* @__PURE__ */ new Set(["react"]);
129
288
  let nextId = 0;
130
289
  function packageNameFromModuleId(moduleName) {
@@ -172,12 +331,6 @@ function emptyManifest() {
172
331
  warnings: []
173
332
  };
174
333
  }
175
- function writeVirtualModule(entry) {
176
- fs.mkdirSync(path.dirname(entry.virtualPath), { recursive: true });
177
- fs.mkdirSync(path.dirname(entry.manifestPath), { recursive: true });
178
- writeManifestFile(entry.virtualPath, virtualModuleCode(entry.manifest));
179
- writeManifestFile(entry.manifestPath, JSON.stringify(entry.manifest));
180
- }
181
334
  /**
182
335
  * Metro worker 会把文件路径先相对化再恢复为绝对路径。虚拟模块必须位于
183
336
  * 项目根目录内,否则 Windows 跨盘符路径会被错误拼接成 `D:\\C:\\...`。
@@ -188,13 +341,6 @@ function getVirtualModulePath(projectRoot, id) {
188
341
  function markManifestPending(entry) {
189
342
  fs.rmSync(entry.manifestReadyPath, { force: true });
190
343
  }
191
- function markManifestReady(entry) {
192
- writeManifestFile(entry.manifestReadyPath, JSON.stringify({
193
- revision: randomUUID(),
194
- version: entry.version,
195
- virtualPath: entry.virtualPath
196
- }));
197
- }
198
344
  async function compileOptions(options, projectRoot) {
199
345
  if (options.manifest) return options.manifest;
200
346
  if (options.input) {
@@ -212,37 +358,46 @@ function register(options) {
212
358
  const id = `weapp-tailwindcss-native-${nextId++}`;
213
359
  const projectRoot = path.resolve(options.projectRoot ?? process.cwd());
214
360
  const manifestPaths = getManifestPathsForProjectRoot(projectRoot);
361
+ const virtualPath = getVirtualModulePath(projectRoot, id);
215
362
  const entry = {
216
- version: 0,
217
- manifest: options.manifest ?? (options.css ? compileNativeStylesheet(options.css, { classSet: options.classSet }) : emptyManifest()),
363
+ snapshot: createManifestSnapshot(options.manifest ?? (options.css ? compileNativeStylesheet(options.css, { classSet: options.classSet }) : emptyManifest()), virtualPath, 0),
364
+ get version() {
365
+ return this.snapshot.version;
366
+ },
367
+ get manifest() {
368
+ return this.snapshot.manifest;
369
+ },
218
370
  projectRoot,
219
- virtualPath: getVirtualModulePath(projectRoot, id),
371
+ virtualPath,
220
372
  manifestPath: manifestPaths.manifestPath,
221
373
  manifestReadyPath: manifestPaths.manifestReadyPath,
222
374
  ready: Promise.resolve(),
223
375
  refresh: async () => {}
224
376
  };
377
+ fs.mkdirSync(path.dirname(virtualPath), { recursive: true });
378
+ writeManifestFile(virtualPath, virtualModuleCode(entry.snapshot.manifest));
225
379
  registry.set(id, entry);
226
- markManifestPending(entry);
227
- writeVirtualModule(entry);
228
380
  const inputFiles = [...new Set([...options.watchFiles ?? [], ...options.input ? [options.input] : []].map((file) => path.resolve(projectRoot, file)))];
229
381
  let generation = 0;
230
382
  entry.refresh = () => {
231
383
  const currentGeneration = ++generation;
232
- markManifestPending(entry);
233
384
  entry.ready = (async () => {
234
385
  try {
386
+ markManifestPending(entry);
235
387
  const manifest = await compileStableInput(inputFiles, () => compileOptions(options, projectRoot), () => currentGeneration === generation);
236
388
  if (manifest && currentGeneration === generation) {
237
- entry.manifest = manifest;
238
- entry.version++;
239
- writeVirtualModule(entry);
240
- markManifestReady(entry);
389
+ const snapshot = createManifestSnapshot(manifest, entry.virtualPath, entry.version + 1);
390
+ writeManifestSnapshot(entry, snapshot);
391
+ entry.snapshot = snapshot;
241
392
  }
242
393
  } catch (error) {
243
394
  if (currentGeneration !== generation) return;
244
395
  const message = `生成 React Native manifest 失败:${error instanceof Error ? error.message : String(error)}`;
245
- writeManifestFile(entry.manifestReadyPath, JSON.stringify({ error: message }));
396
+ try {
397
+ writeManifestFile(entry.manifestReadyPath, JSON.stringify({ error: message }));
398
+ } catch (publicationError) {
399
+ throw new AggregateError([error, publicationError], message, { cause: error });
400
+ }
246
401
  throw new Error(message, { cause: error });
247
402
  }
248
403
  })();
@@ -270,41 +425,6 @@ function register(options) {
270
425
  entry
271
426
  };
272
427
  }
273
- function getRegisteredVirtualModule(filename) {
274
- for (const entry of registry.values()) if (entry.virtualPath === filename) return entry;
275
- }
276
- async function getRegisteredManifest(id) {
277
- const registered = registry.get(id);
278
- if (!registered) return;
279
- await waitForCurrentRefresh(registered);
280
- return registered.manifest;
281
- }
282
- /** 等待并读取由 Metro 配置注册的 manifest 文件,兼容未透传自定义 Metro id 的 transformer。 */
283
- async function getRegisteredManifestByPath(filename) {
284
- for (const entry of registry.values()) if (entry.manifestPath === filename) {
285
- await waitForCurrentRefresh(entry);
286
- return entry.manifest;
287
- }
288
- }
289
- /** 按 Metro 传入的项目根目录读取当前注册项,兼容 transformer 未透传自定义字段的实现。 */
290
- async function getRegisteredManifestByProjectRoot(projectRoot) {
291
- const resolvedRoot = path.resolve(projectRoot);
292
- const entry = [...registry.values()].filter((entry) => entry.projectRoot === resolvedRoot).at(-1);
293
- if (!entry) return;
294
- await waitForCurrentRefresh(entry);
295
- return entry.manifest;
296
- }
297
- function getVirtualModuleCode(filename) {
298
- const registered = getRegisteredVirtualModule(filename);
299
- if (!registered) return;
300
- return virtualModuleCode(registered.manifest);
301
- }
302
- async function getVirtualModuleCodeAsync(filename) {
303
- const registered = getRegisteredVirtualModule(filename);
304
- if (!registered) return;
305
- await waitForCurrentRefresh(registered);
306
- return getVirtualModuleCode(filename);
307
- }
308
428
  function withWeappTailwindcss(config, options = {}) {
309
429
  if (typeof config === "function" || config && typeof config.then === "function") return Promise.resolve(typeof config === "function" ? config() : config).then((resolved) => withWeappTailwindcss(resolved, options));
310
430
  const resolvedConfig = config;
@@ -349,5 +469,4 @@ function withWeappTailwindcss(config, options = {}) {
349
469
  }
350
470
  };
351
471
  }
352
- //#endregion
353
- export { getRegisteredManifestByProjectRoot as a, getVirtualModuleCodeAsync as c, waitForCurrentRefresh as d, readPublishedSnapshot as f, getRegisteredManifestByPath as i, withWeappTailwindcss as l, getManifestPathsForProjectRoot as n, getRegisteredVirtualModule as o, getRegisteredManifest as r, getVirtualModuleCode as s, VIRTUAL_MANIFEST_MODULE as t, virtualModuleCode as u };
472
+ export { getRegisteredManifestByPath as a, getRegisteredSnapshotByPath as c, getVirtualModuleCode as d, getVirtualModuleCodeAsync as f, readPublishedSnapshot as h, getRegisteredManifest as i, getRegisteredSnapshotByProjectRoot as l, virtualModuleCode as m, getManifestPathsForProjectRoot as n, getRegisteredManifestByProjectRoot as o, readRegisteredSnapshot as p, withWeappTailwindcss as r, getRegisteredSnapshot as s, VIRTUAL_MANIFEST_MODULE as t, getRegisteredVirtualModule as u };
@@ -0,0 +1,63 @@
1
+ import { a as NativeStyleManifest, r as NativeManifestPublication } from "./types-CxNMLBiF.js";
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 };