@tamagui/metro-plugin 2.7.7 → 3.0.0-beta.643.1

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 (72) hide show
  1. package/README.md +12 -0
  2. package/dist/cjs/babel.cjs +77 -0
  3. package/dist/cjs/compilerCache.cjs +237 -0
  4. package/dist/cjs/diagnostics.cjs +41 -0
  5. package/dist/cjs/frontend.cjs +870 -0
  6. package/dist/cjs/index.cjs +102 -0
  7. package/dist/cjs/lowering.cjs +109 -0
  8. package/dist/cjs/metroResolver.cjs +197 -0
  9. package/dist/cjs/transformOptions.cjs +35 -0
  10. package/dist/cjs/transformer.cjs +142 -0
  11. package/dist/cjs/zeroRuntime.cjs +140 -0
  12. package/dist/cjs/zeroSerializer.cjs +150 -0
  13. package/dist/esm/babel.mjs +52 -0
  14. package/dist/esm/babel.mjs.map +1 -0
  15. package/dist/esm/compilerCache.mjs +212 -0
  16. package/dist/esm/compilerCache.mjs.map +1 -0
  17. package/dist/esm/diagnostics.mjs +18 -0
  18. package/dist/esm/diagnostics.mjs.map +1 -0
  19. package/dist/esm/frontend.mjs +839 -0
  20. package/dist/esm/frontend.mjs.map +1 -0
  21. package/dist/esm/index.mjs +64 -22
  22. package/dist/esm/index.mjs.map +1 -1
  23. package/dist/esm/lowering.mjs +89 -0
  24. package/dist/esm/lowering.mjs.map +1 -0
  25. package/dist/esm/metroResolver.mjs +173 -0
  26. package/dist/esm/metroResolver.mjs.map +1 -0
  27. package/dist/esm/transformOptions.mjs +14 -0
  28. package/dist/esm/transformOptions.mjs.map +1 -0
  29. package/dist/esm/transformer.mjs +119 -0
  30. package/dist/esm/transformer.mjs.map +1 -0
  31. package/dist/esm/zeroRuntime.mjs +105 -0
  32. package/dist/esm/zeroRuntime.mjs.map +1 -0
  33. package/dist/esm/zeroSerializer.mjs +123 -0
  34. package/dist/esm/zeroSerializer.mjs.map +1 -0
  35. package/package.json +33 -5
  36. package/src/babel.ts +87 -0
  37. package/src/compilerCache.ts +346 -0
  38. package/src/diagnostics.ts +47 -0
  39. package/src/frontend.ts +1178 -0
  40. package/src/index.ts +117 -14
  41. package/src/lowering.ts +136 -0
  42. package/src/metroResolver.ts +209 -0
  43. package/src/transformOptions.ts +36 -0
  44. package/src/transformer.ts +210 -0
  45. package/src/zeroRuntime.ts +212 -0
  46. package/src/zeroSerializer.ts +175 -0
  47. package/types/babel.d.ts +28 -0
  48. package/types/babel.d.ts.map +11 -0
  49. package/types/compilerCache.d.ts +63 -0
  50. package/types/compilerCache.d.ts.map +11 -0
  51. package/types/diagnostics.d.ts +16 -0
  52. package/types/diagnostics.d.ts.map +11 -0
  53. package/types/frontend.d.ts +73 -0
  54. package/types/frontend.d.ts.map +11 -0
  55. package/types/index.d.ts +49 -32
  56. package/types/index.d.ts.map +11 -1
  57. package/types/lowering.d.ts +20 -0
  58. package/types/lowering.d.ts.map +11 -0
  59. package/types/metroResolver.d.ts +21 -0
  60. package/types/metroResolver.d.ts.map +11 -0
  61. package/types/transformOptions.d.ts +13 -0
  62. package/types/transformOptions.d.ts.map +11 -0
  63. package/types/transformer.d.ts +26 -0
  64. package/types/transformer.d.ts.map +11 -0
  65. package/types/zeroRuntime.d.ts +75 -0
  66. package/types/zeroRuntime.d.ts.map +11 -0
  67. package/types/zeroSerializer.d.ts +6 -0
  68. package/types/zeroSerializer.d.ts.map +11 -0
  69. package/dist/cjs/index.js +0 -45
  70. package/dist/cjs/index.js.map +0 -6
  71. package/dist/esm/index.js +0 -25
  72. package/dist/esm/index.js.map +0 -1
@@ -0,0 +1,140 @@
1
+
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var zeroRuntime_exports = {};
29
+ __export(zeroRuntime_exports, {
30
+ ZERO_CSS_FILENAME: () => ZERO_CSS_FILENAME,
31
+ ZERO_ISLAND_DIRNAME: () => ZERO_ISLAND_DIRNAME,
32
+ createMetroZeroController: () => createMetroZeroController,
33
+ finalizeMetroZero: () => finalizeMetroZero,
34
+ islandBundleHashPath: () => islandBundleHashPath,
35
+ islandFragmentPath: () => islandFragmentPath,
36
+ writeIslandRuntimeShims: () => writeIslandRuntimeShims,
37
+ zeroModuleKey: () => zeroModuleKey
38
+ });
39
+ module.exports = __toCommonJS(zeroRuntime_exports);
40
+ var import_node_crypto = require("node:crypto");
41
+ var import_node_fs = require("node:fs");
42
+ var import_node_path = __toESM(require("node:path"), 1);
43
+ var import_static = __toESM(require("@tamagui/static"), 1);
44
+ const ZERO_CSS_FILENAME = "tamagui-zero.css";
45
+ const ZERO_ISLAND_DIRNAME = "tamagui-islands";
46
+ const normalizePath = (value) => value.replace(/\\/g, "/");
47
+ const zeroModuleKey = (value) => normalizePath(value).replace(/\.(?:js|jsx|ts|tsx|mjs|cjs)$/, "");
48
+ function islandFragmentPath(outDir, islandId) {
49
+ return import_node_path.default.join(outDir, ZERO_ISLAND_DIRNAME, `${islandId}.css`);
50
+ }
51
+ function islandBundleHashPath(outDir, islandId) {
52
+ return import_node_path.default.join(outDir, ZERO_ISLAND_DIRNAME, `${islandId}.hash`);
53
+ }
54
+ function createMetroZeroController(options, root, islandBuild, publicDirName) {
55
+ const resolved = import_static.default.resolveZeroRuntimeSync(options, root);
56
+ if (resolved.mode === "off") return null;
57
+ import_static.default.assertZeroIntegrationSupport("metro-web", resolved);
58
+ const cssHref = `/${ZERO_CSS_FILENAME}`;
59
+ const artifact = new import_static.default.ZeroCSSArtifact(resolved.cssPath);
60
+ artifact.expectIslands(resolved.islands.map((island) => island.id));
61
+ const configPath = import_node_path.default.isAbsolute(options.config || "") ? options.config : import_node_path.default.resolve(root, options.config || "tamagui.config.ts");
62
+ for (const island of resolved.islands) {
63
+ import_static.default.writeIslandModules({
64
+ island,
65
+ integration: "metro-web",
66
+ configPath,
67
+ scriptUrl: `/${ZERO_ISLAND_DIRNAME}/${island.id}.js`,
68
+ cssHref
69
+ });
70
+ }
71
+ return {
72
+ resolved,
73
+ artifact,
74
+ cssHref,
75
+ root,
76
+ publicDir: import_node_path.default.join(root, publicDirName),
77
+ islandBuild,
78
+ bridges: /* @__PURE__ */ new Map(),
79
+ violations: [],
80
+ transformed: /* @__PURE__ */ new Set(),
81
+ erasedExports: /* @__PURE__ */ new Map(),
82
+ isEnforcing: resolved.mode === "enforce",
83
+ loaderIds: new Map(resolved.islands.map((island) => [zeroModuleKey(island.loader), island.id])),
84
+ islandModuleIds: new Map(resolved.islands.map((island) => [zeroModuleKey(island.module), island.id])),
85
+ configCSS: "",
86
+ plansRestoredFromCache: false
87
+ };
88
+ }
89
+ function writeIslandRuntimeShims(outDir) {
90
+ const directory = import_node_path.default.join(outDir, "runtime-shim");
91
+ (0, import_node_fs.mkdirSync)(directory, { recursive: true });
92
+ const shims = {};
93
+ for (const [specifier, segments] of Object.entries(import_static.default.ISLAND_EXTERNAL_GLOBAL_PATHS)) {
94
+ const file = import_node_path.default.join(directory, `${specifier.replace(/[^a-zA-Z0-9]+/g, "_")}.js`);
95
+ const source = `// generated by @tamagui/metro-plugin zero-runtime. do not edit.
96
+ module.exports = globalThis.${segments.join(".")}
97
+ `;
98
+ if (!(0, import_node_fs.existsSync)(file) || (0, import_node_fs.readFileSync)(file, "utf8") !== source) {
99
+ (0, import_node_fs.writeFileSync)(file, source);
100
+ }
101
+ shims[specifier] = file;
102
+ }
103
+ return shims;
104
+ }
105
+ function finalizeMetroZero(input) {
106
+ const { controller } = input;
107
+ const outDir = controller.resolved.outDir;
108
+ if (controller.islandBuild) {
109
+ const fragment = [...controller.artifact.islandCSS(controller.islandBuild)].join("");
110
+ const file = islandFragmentPath(outDir, controller.islandBuild);
111
+ (0, import_node_fs.mkdirSync)(import_node_path.default.dirname(file), { recursive: true });
112
+ (0, import_node_fs.writeFileSync)(file, fragment);
113
+ (0, import_node_fs.writeFileSync)(islandBundleHashPath(outDir, controller.islandBuild), (0, import_node_crypto.createHash)("sha256").update(input.bundleCode).digest("hex").slice(0, 16));
114
+ return {
115
+ cssPath: file,
116
+ hash: "",
117
+ islandOutputHashes: {}
118
+ };
119
+ }
120
+ controller.artifact.setConfigCSS(controller.configCSS);
121
+ const islandOutputHashes = {};
122
+ for (const island of controller.resolved.islands) {
123
+ const fragment = islandFragmentPath(outDir, island.id);
124
+ if (!(0, import_node_fs.existsSync)(fragment)) {
125
+ throw new Error(`[tamagui zero-runtime] island "${island.id}" has not been built. Build every declared island bundle before the zero entry so the one CSS artifact can be finalized.`);
126
+ }
127
+ controller.artifact.setIslandModuleCSS(island.id, island.module, (0, import_node_fs.readFileSync)(fragment, "utf8"));
128
+ const hashFile = islandBundleHashPath(outDir, island.id);
129
+ islandOutputHashes[island.id] = (0, import_node_fs.existsSync)(hashFile) ? (0, import_node_fs.readFileSync)(hashFile, "utf8") : "";
130
+ }
131
+ const written = controller.artifact.write();
132
+ if (!written.complete) {
133
+ throw new Error(`[tamagui zero-runtime] cannot derive TAMAGUI_DID_OUTPUT_CSS: the generated CSS artifact is missing ${written.missing.join(", ")}`);
134
+ }
135
+ return {
136
+ cssPath: written.path,
137
+ hash: written.hash,
138
+ islandOutputHashes
139
+ };
140
+ }
@@ -0,0 +1,150 @@
1
+
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var zeroSerializer_exports = {};
29
+ __export(zeroSerializer_exports, { applyMetroZeroRuntime: () => applyMetroZeroRuntime });
30
+ module.exports = __toCommonJS(zeroSerializer_exports);
31
+ var import_node_fs = require("node:fs");
32
+ var import_node_module = require("node:module");
33
+ var import_node_path = __toESM(require("node:path"), 1);
34
+ var import_node_zlib = require("node:zlib");
35
+ var import_static = __toESM(require("@tamagui/static"), 1);
36
+ var import_zeroRuntime = require("./zeroRuntime.cjs");
37
+ const import_meta = {};
38
+ const requireFromPlugin = (0, import_node_module.createRequire)(typeof __filename === "string" ? __filename : import_meta.url);
39
+ const baseJSBundle = requireFromPlugin("metro/private/DeltaBundler/Serializers/baseJSBundle").default;
40
+ const bundleToString = requireFromPlugin("metro/private/lib/bundleToString").default;
41
+ function applyMetroZeroRuntime(metroConfig, zero) {
42
+ if (zero.islandBuild) {
43
+ const shims = (0, import_zeroRuntime.writeIslandRuntimeShims)(zero.resolved.outDir);
44
+ const userResolveRequest = metroConfig.resolver?.resolveRequest;
45
+ metroConfig.resolver = {
46
+ ...metroConfig.resolver,
47
+ resolveRequest(context, moduleName, platform) {
48
+ const shim = shims[moduleName];
49
+ if (shim) return {
50
+ type: "sourceFile",
51
+ filePath: shim
52
+ };
53
+ return userResolveRequest ? userResolveRequest(context, moduleName, platform) : context.resolveRequest(context, moduleName, platform);
54
+ }
55
+ };
56
+ }
57
+ const userSerializer = metroConfig.serializer?.customSerializer;
58
+ metroConfig.serializer = {
59
+ ...metroConfig.serializer,
60
+ async customSerializer(entryPoint, preModules, graph, opts) {
61
+ const receipt = checkGraph(zero, entryPoint, graph);
62
+ const output = userSerializer ? await userSerializer(entryPoint, preModules, graph, opts) : bundleToString(baseJSBundle(entryPoint, preModules, graph, opts)).code;
63
+ const finalized = (0, import_zeroRuntime.finalizeMetroZero)({
64
+ controller: zero,
65
+ bundleCode: typeof output === "string" ? output : ""
66
+ });
67
+ if (!zero.islandBuild) {
68
+ (0, import_node_fs.mkdirSync)(zero.publicDir, { recursive: true });
69
+ const css = zero.artifact.css();
70
+ const published = import_node_path.default.join(zero.publicDir, import_zeroRuntime.ZERO_CSS_FILENAME);
71
+ (0, import_node_fs.writeFileSync)(published, css);
72
+ const publishFailure = import_static.default.checkGlobalCSSArtifact({
73
+ cssPath: published,
74
+ expectedCSS: css,
75
+ loadedModuleIds: [published],
76
+ importHint: ""
77
+ });
78
+ if (publishFailure) throw new Error(publishFailure.message);
79
+ receipt.cssArtifact = {
80
+ path: zero.cssHref,
81
+ hash: finalized.hash
82
+ };
83
+ receipt.gzip = {
84
+ [import_zeroRuntime.ZERO_CSS_FILENAME]: (0, import_node_zlib.gzipSync)(Buffer.from(css), { level: 9 }).length,
85
+ bundle: (0, import_node_zlib.gzipSync)(Buffer.from(typeof output === "string" ? output : ""), { level: 9 }).length
86
+ };
87
+ const bridgeManifest = import_static.default.canonicalizeBridgeManifest(Object.fromEntries([...zero.bridges.entries()].sort(([left], [right]) => left < right ? -1 : 1)));
88
+ const identityInputs = {
89
+ runtimeLiteral: "zero",
90
+ target: "web",
91
+ configGeneration: import_static.default.hashBridgeManifest(zero.configCSS),
92
+ cssHash: finalized.hash,
93
+ compilerVersion: import_static.default.ZERO_COMPILER_VERSION,
94
+ islandEntries: zero.resolved.islands.map((island) => island.module),
95
+ bridgeManifestHash: import_static.default.hashBridgeManifest(bridgeManifest),
96
+ islandOutputHashes: finalized.islandOutputHashes
97
+ };
98
+ receipt.identity = import_static.default.hashZeroIdentity(identityInputs);
99
+ receipt.plansRestoredFromCache = zero.plansRestoredFromCache;
100
+ import_static.default.writeZeroGraphReceipt(zero.resolved.outDir, "metro-zero", receipt);
101
+ (0, import_node_fs.writeFileSync)(import_node_path.default.join(zero.resolved.outDir, "metro-zero.bridges.json"), `${JSON.stringify({
102
+ identity: receipt.identity,
103
+ identityInputs,
104
+ bridges: bridgeManifest
105
+ }, null, 2)}
106
+ `);
107
+ if (receipt.forbidden.length) {
108
+ throw new Error(import_static.default.formatZeroGraphFailure(receipt));
109
+ }
110
+ console.info(` \u27A1 [tamagui zero-runtime] ${receipt.moduleCount} modules, 0 forbidden, css ${receipt.gzip[import_zeroRuntime.ZERO_CSS_FILENAME]} gzip, islands: ${zero.resolved.islands.map((island) => island.id).join(", ") || "none"}`);
111
+ }
112
+ return output;
113
+ }
114
+ };
115
+ }
116
+ function checkGraph(zero, entryPoint, graph) {
117
+ const modules = [];
118
+ const importerEdges = /* @__PURE__ */ new Map();
119
+ for (const [id, module2] of graph.dependencies) {
120
+ const importers = [...module2.inverseDependencies ?? []];
121
+ importerEdges.set(id, importers);
122
+ modules.push({
123
+ id,
124
+ importers
125
+ });
126
+ }
127
+ const escape = import_static.default.erasedExportEscape({
128
+ integration: "metro-web",
129
+ transformed: zero.transformed,
130
+ erasedExports: zero.erasedExports,
131
+ importersOf: importerEdges
132
+ });
133
+ if (escape) throw new Error(escape);
134
+ const checked = import_static.default.checkZeroGraph({
135
+ entries: [entryPoint],
136
+ modules,
137
+ importerEdges,
138
+ root: zero.resolved.root
139
+ });
140
+ return {
141
+ integration: "metro-web",
142
+ graph: zero.islandBuild ? "island" : "zero",
143
+ entries: [entryPoint],
144
+ moduleCount: modules.length,
145
+ tamaguiModules: checked.tamaguiModules,
146
+ forbidden: checked.forbidden,
147
+ cssArtifact: null,
148
+ identity: ""
149
+ };
150
+ }
@@ -0,0 +1,52 @@
1
+ import { createHash } from "node:crypto";
2
+ import { createRequire } from "node:module";
3
+ import { dirname } from "node:path";
4
+
5
+ function asTransformer(module, path) {
6
+ const transformer = module?.default?.transform ? module.default : module;
7
+ if (!transformer || typeof transformer.transform !== "function") {
8
+ throw new Error(`Metro Babel transformer ${path} has no transform function`);
9
+ }
10
+ return transformer;
11
+ }
12
+ function loadMetroBabelTransformer(path) {
13
+ return asTransformer(createRequire(path)(path), path);
14
+ }
15
+ async function compileWithUserBabel(transformerPath, args) {
16
+ const transformer = loadMetroBabelTransformer(transformerPath);
17
+ const result = await transformer.transform(args);
18
+ if (!result?.ast) {
19
+ throw new Error(`Metro Babel transformer ${transformerPath} returned no AST`);
20
+ }
21
+ const requireFromTransformer = createRequire(transformerPath);
22
+ const generatorModule = requireFromTransformer("@babel/generator");
23
+ const generate = generatorModule.default ?? generatorModule;
24
+ const generated = generate(result.ast, {
25
+ comments: true,
26
+ compact: false,
27
+ retainLines: true,
28
+ sourceFileName: args.filename,
29
+ sourceMaps: true
30
+ }, args.src);
31
+ if (!generated || typeof generated.code !== "string") {
32
+ throw new Error(`Babel generator for ${transformerPath} returned no code`);
33
+ }
34
+ if (!generated.map) {
35
+ throw new Error(`Babel generator for ${transformerPath} returned no source map`);
36
+ }
37
+ return {
38
+ code: generated.code,
39
+ map: generated.map,
40
+ result
41
+ };
42
+ }
43
+ function userBabelCacheKey(transformerPath) {
44
+ const transformer = loadMetroBabelTransformer(transformerPath);
45
+ return createHash("sha256").update(transformerPath).update("\0").update(transformer.getCacheKey?.() ?? "").digest("hex");
46
+ }
47
+ function transformerDirectory(transformerPath) {
48
+ return dirname(transformerPath);
49
+ }
50
+
51
+ export { compileWithUserBabel, loadMetroBabelTransformer, transformerDirectory, userBabelCacheKey };
52
+ //# sourceMappingURL=babel.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.js","names":[],"sources":["esm/babel.js"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { createRequire } from \"node:module\";\nimport { dirname } from \"node:path\";\nfunction asTransformer(module, path) {\n const transformer = module?.default?.transform ? module.default : module;\n if (!transformer || typeof transformer.transform !== \"function\") {\n throw new Error(`Metro Babel transformer ${path} has no transform function`);\n }\n return transformer;\n}\nfunction loadMetroBabelTransformer(path) {\n return asTransformer(createRequire(path)(path), path);\n}\nasync function compileWithUserBabel(transformerPath, args) {\n const transformer = loadMetroBabelTransformer(transformerPath);\n const result = await transformer.transform(args);\n if (!result?.ast) {\n throw new Error(`Metro Babel transformer ${transformerPath} returned no AST`);\n }\n const requireFromTransformer = createRequire(transformerPath);\n const generatorModule = requireFromTransformer(\"@babel/generator\");\n const generate = generatorModule.default ?? generatorModule;\n const generated = generate(\n result.ast,\n {\n comments: true,\n compact: false,\n retainLines: true,\n sourceFileName: args.filename,\n sourceMaps: true\n },\n args.src\n );\n if (!generated || typeof generated.code !== \"string\") {\n throw new Error(`Babel generator for ${transformerPath} returned no code`);\n }\n if (!generated.map) {\n throw new Error(`Babel generator for ${transformerPath} returned no source map`);\n }\n return { code: generated.code, map: generated.map, result };\n}\nfunction userBabelCacheKey(transformerPath) {\n const transformer = loadMetroBabelTransformer(transformerPath);\n return createHash(\"sha256\").update(transformerPath).update(\"\\0\").update(transformer.getCacheKey?.() ?? \"\").digest(\"hex\");\n}\nfunction transformerDirectory(transformerPath) {\n return dirname(transformerPath);\n}\nexport {\n compileWithUserBabel,\n loadMetroBabelTransformer,\n transformerDirectory,\n userBabelCacheKey\n};\n//# sourceMappingURL=babel.js.map\n"],"mappings":";;;;;AAGA,SAAS,cAAc,QAAQ,MAAM;CACnC,MAAM,cAAc,QAAQ,SAAS,YAAY,OAAO,UAAU;CAClE,IAAI,CAAC,eAAe,OAAO,YAAY,cAAc,YAAY;EAC/D,MAAM,IAAI,MAAM,2BAA2B,KAAK,2BAA2B;CAC7E;CACA,OAAO;AACT;AACA,SAAS,0BAA0B,MAAM;CACvC,OAAO,cAAc,cAAc,IAAI,EAAE,IAAI,GAAG,IAAI;AACtD;AACA,eAAe,qBAAqB,iBAAiB,MAAM;CACzD,MAAM,cAAc,0BAA0B,eAAe;CAC7D,MAAM,SAAS,MAAM,YAAY,UAAU,IAAI;CAC/C,IAAI,CAAC,QAAQ,KAAK;EAChB,MAAM,IAAI,MAAM,2BAA2B,gBAAgB,iBAAiB;CAC9E;CACA,MAAM,yBAAyB,cAAc,eAAe;CAC5D,MAAM,kBAAkB,uBAAuB,kBAAkB;CACjE,MAAM,WAAW,gBAAgB,WAAW;CAC5C,MAAM,YAAY,SAChB,OAAO,KACP;EACE,UAAU;EACV,SAAS;EACT,aAAa;EACb,gBAAgB,KAAK;EACrB,YAAY;CACd,GACA,KAAK,GACP;CACA,IAAI,CAAC,aAAa,OAAO,UAAU,SAAS,UAAU;EACpD,MAAM,IAAI,MAAM,uBAAuB,gBAAgB,kBAAkB;CAC3E;CACA,IAAI,CAAC,UAAU,KAAK;EAClB,MAAM,IAAI,MAAM,uBAAuB,gBAAgB,wBAAwB;CACjF;CACA,OAAO;EAAE,MAAM,UAAU;EAAM,KAAK,UAAU;EAAK;CAAO;AAC5D;AACA,SAAS,kBAAkB,iBAAiB;CAC1C,MAAM,cAAc,0BAA0B,eAAe;CAC7D,OAAO,WAAW,QAAQ,EAAE,OAAO,eAAe,EAAE,OAAO,IAAI,EAAE,OAAO,YAAY,cAAc,KAAK,EAAE,EAAE,OAAO,KAAK;AACzH;AACA,SAAS,qBAAqB,iBAAiB;CAC7C,OAAO,QAAQ,eAAe;AAChC"}
@@ -0,0 +1,212 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { LOWERED_MODULE_PLAN_VERSION, contentHash, stableStringify, tamaguiCacheRoot } from "@tamagui/compiler-core";
5
+ import { metroDiagnostic } from "./diagnostics.mjs";
6
+
7
+ const METRO_COMPILER_CACHE_VERSION = 6;
8
+ var MetroCompilerCacheError = class extends Error {
9
+ constructor(diagnostic) {
10
+ super(diagnostic.message);
11
+ this.diagnostic = diagnostic;
12
+ this.name = "MetroCompilerCacheError";
13
+ }
14
+ diagnostic;
15
+ };
16
+ function compareCodeUnits(left, right) {
17
+ return left < right ? -1 : left > right ? 1 : 0;
18
+ }
19
+ function stableEntries(record) {
20
+ return Object.entries(record).sort(([left], [right]) => compareCodeUnits(left, right));
21
+ }
22
+ function cacheCorrupt(message, moduleId) {
23
+ return new MetroCompilerCacheError(metroDiagnostic("metro/cache-corrupt", message, { moduleId }));
24
+ }
25
+ function parseJson(source, description, moduleId) {
26
+ try {
27
+ return JSON.parse(source);
28
+ } catch (error) {
29
+ throw cacheCorrupt(`${description} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, moduleId);
30
+ }
31
+ }
32
+ function defaultMetroCompilerCacheRoot(projectRoot) {
33
+ return join(tamaguiCacheRoot(projectRoot), "metro-compiler");
34
+ }
35
+ var MetroCompilerCache = class {
36
+ constructor(root) {
37
+ this.root = root;
38
+ this.#blobsDirectory = join(root, `v${6}`, "blobs");
39
+ this.#manifestPath = join(root, `v${6}`, "manifest.json");
40
+ }
41
+ root;
42
+ #blobsDirectory;
43
+ #manifestPath;
44
+ async publish(platform, entries, optionsHash) {
45
+ await mkdir(this.#blobsDirectory, { recursive: true });
46
+ const descriptors = {};
47
+ for (const entry of [...entries].sort((left, right) => compareCodeUnits(left.moduleId, right.moduleId))) {
48
+ if (entry.schemaVersion !== 6) {
49
+ throw new Error(`Cannot publish cache schema ${entry.schemaVersion}`);
50
+ }
51
+ const serialized = `${stableStringify(entry)}
52
+ `;
53
+ const blobHash = contentHash(serialized);
54
+ const blobPath = join(this.#blobsDirectory, `${blobHash}.json`);
55
+ try {
56
+ await writeFile(blobPath, serialized, {
57
+ encoding: "utf8",
58
+ flag: "wx"
59
+ });
60
+ } catch (error) {
61
+ if (error.code !== "EEXIST") throw error;
62
+ const existing = await readFile(blobPath, "utf8");
63
+ if (contentHash(existing) !== blobHash) {
64
+ const temporaryBlobPath = `${blobPath}.${process.pid}-${randomBytes(6).toString("hex")}.tmp`;
65
+ await writeFile(temporaryBlobPath, serialized, "utf8");
66
+ await rename(temporaryBlobPath, blobPath);
67
+ }
68
+ }
69
+ descriptors[entry.moduleId] = {
70
+ blobHash,
71
+ sourceHash: entry.sourceHash
72
+ };
73
+ }
74
+ const generation = contentHash(stableStringify(descriptors));
75
+ const manifest = {
76
+ schemaVersion: 6,
77
+ generation,
78
+ optionsHash,
79
+ platform,
80
+ entries: descriptors
81
+ };
82
+ const manifestDirectory = join(this.root, `v${6}`);
83
+ const temporaryPath = join(manifestDirectory, `.manifest-${process.pid}-${randomBytes(6).toString("hex")}.json`);
84
+ await writeFile(temporaryPath, `${stableStringify(manifest)}
85
+ `, "utf8");
86
+ await rename(temporaryPath, this.#manifestPath);
87
+ return generation;
88
+ }
89
+ async read(moduleId, rawSource, onMiss) {
90
+ const manifest = await this.#readManifest();
91
+ if (!manifest) return null;
92
+ const descriptor = manifest.entries[moduleId];
93
+ if (!descriptor) {
94
+ onMiss?.("no-entry");
95
+ return null;
96
+ }
97
+ const sourceHash = contentHash(rawSource);
98
+ if (sourceHash !== descriptor.sourceHash) {
99
+ onMiss?.("source-hash-mismatch", `worker ${sourceHash.slice(0, 12)} vs plan ${descriptor.sourceHash.slice(0, 12)}`);
100
+ return null;
101
+ }
102
+ return await this.#readBlob(moduleId, descriptor);
103
+ }
104
+ async validate() {
105
+ const diagnostics = [];
106
+ try {
107
+ const manifest = await this.#readManifest();
108
+ if (!manifest) {
109
+ return {
110
+ valid: false,
111
+ diagnostics,
112
+ generation: null,
113
+ moduleIds: [],
114
+ sourceHashes: {},
115
+ optionsHash: null
116
+ };
117
+ }
118
+ const sourceHashes = {};
119
+ for (const [moduleId, descriptor] of stableEntries(manifest.entries)) {
120
+ await this.#readBlob(moduleId, descriptor);
121
+ sourceHashes[moduleId] = descriptor.sourceHash;
122
+ }
123
+ return {
124
+ valid: true,
125
+ diagnostics,
126
+ generation: manifest.generation,
127
+ moduleIds: Object.keys(manifest.entries).sort(compareCodeUnits),
128
+ sourceHashes,
129
+ optionsHash: manifest.optionsHash
130
+ };
131
+ } catch (error) {
132
+ if (error instanceof MetroCompilerCacheError) {
133
+ diagnostics.push(error.diagnostic);
134
+ return {
135
+ valid: false,
136
+ diagnostics,
137
+ generation: null,
138
+ moduleIds: [],
139
+ sourceHashes: {},
140
+ optionsHash: null
141
+ };
142
+ }
143
+ throw error;
144
+ }
145
+ }
146
+ async discardManifest() {
147
+ await rm(this.#manifestPath, { force: true });
148
+ }
149
+ #zeroSidecarPath(generation) {
150
+ return join(this.root, `v${6}`, `zero-${generation.slice(0, 32)}.json`);
151
+ }
152
+ async publishZeroCSS(sidecar) {
153
+ await mkdir(join(this.root, `v${6}`), { recursive: true });
154
+ const file = this.#zeroSidecarPath(sidecar.generation);
155
+ const temporaryPath = `${file}.${process.pid}-${randomBytes(6).toString("hex")}.tmp`;
156
+ await writeFile(temporaryPath, `${stableStringify(sidecar)}
157
+ `, "utf8");
158
+ await rename(temporaryPath, file);
159
+ }
160
+ /** Null whenever the sidecar is absent or does not describe this generation. */
161
+ async readZeroCSS(generation) {
162
+ let source;
163
+ try {
164
+ source = await readFile(this.#zeroSidecarPath(generation), "utf8");
165
+ } catch (error) {
166
+ if (error.code === "ENOENT") return null;
167
+ throw error;
168
+ }
169
+ const sidecar = parseJson(source, "Zero CSS sidecar");
170
+ if (sidecar.schemaVersion !== 6 || sidecar.generation !== generation || typeof sidecar.configCSS !== "string" || !sidecar.zeroModuleCSS || typeof sidecar.zeroModuleCSS !== "object" || !sidecar.bridgeCSS || typeof sidecar.bridgeCSS !== "object" || !sidecar.bridges || typeof sidecar.bridges !== "object") {
171
+ return null;
172
+ }
173
+ return sidecar;
174
+ }
175
+ async #readManifest() {
176
+ let source;
177
+ try {
178
+ source = await readFile(this.#manifestPath, "utf8");
179
+ } catch (error) {
180
+ if (error.code === "ENOENT") return null;
181
+ throw error;
182
+ }
183
+ const manifest = parseJson(source, "Cache manifest");
184
+ if (manifest.schemaVersion !== 6 || typeof manifest.generation !== "string" || typeof manifest.optionsHash !== "string" || !manifest.entries || typeof manifest.entries !== "object") {
185
+ throw cacheCorrupt("Cache manifest has an unsupported schema");
186
+ }
187
+ return manifest;
188
+ }
189
+ async #readBlob(moduleId, descriptor) {
190
+ const blobPath = join(this.#blobsDirectory, `${descriptor.blobHash}.json`);
191
+ let source;
192
+ try {
193
+ source = await readFile(blobPath, "utf8");
194
+ } catch (error) {
195
+ if (error.code === "ENOENT") {
196
+ throw cacheCorrupt(`Cache blob ${descriptor.blobHash} is missing`, moduleId);
197
+ }
198
+ throw error;
199
+ }
200
+ if (contentHash(source) !== descriptor.blobHash) {
201
+ throw cacheCorrupt(`Cache blob ${descriptor.blobHash} failed its hash`, moduleId);
202
+ }
203
+ const entry = parseJson(source, `Cache blob ${descriptor.blobHash}`, moduleId);
204
+ if (entry.schemaVersion !== 6 || entry.moduleId !== moduleId || typeof entry.sourceHash !== "string" || entry.sourceHash !== descriptor.sourceHash || !entry.plan || entry.plan.version !== LOWERED_MODULE_PLAN_VERSION || entry.plan.id !== moduleId || entry.plan.sourceHash !== entry.sourceHash || !Array.isArray(entry.plan.edits) || !Array.isArray(entry.plan.diagnostics) || !Array.isArray(entry.diagnostics)) {
205
+ throw cacheCorrupt(`Cache blob ${descriptor.blobHash} has invalid contents`, moduleId);
206
+ }
207
+ return entry;
208
+ }
209
+ };
210
+
211
+ export { METRO_COMPILER_CACHE_VERSION, MetroCompilerCache, MetroCompilerCacheError, defaultMetroCompilerCacheRoot };
212
+ //# sourceMappingURL=compilerCache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compilerCache.js","names":["#blobsDirectory","#manifestPath","#readManifest","#readBlob","#zeroSidecarPath"],"sources":["esm/compilerCache.js"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n LOWERED_MODULE_PLAN_VERSION,\n contentHash,\n stableStringify,\n tamaguiCacheRoot\n} from \"@tamagui/compiler-core\";\nimport { metroDiagnostic } from \"./diagnostics\";\nconst METRO_COMPILER_CACHE_VERSION = 6;\nclass MetroCompilerCacheError extends Error {\n constructor(diagnostic) {\n super(diagnostic.message);\n this.diagnostic = diagnostic;\n this.name = \"MetroCompilerCacheError\";\n }\n diagnostic;\n}\nfunction compareCodeUnits(left, right) {\n return left < right ? -1 : left > right ? 1 : 0;\n}\nfunction stableEntries(record) {\n return Object.entries(record).sort(([left], [right]) => compareCodeUnits(left, right));\n}\nfunction cacheCorrupt(message, moduleId) {\n return new MetroCompilerCacheError(\n metroDiagnostic(\"metro/cache-corrupt\", message, { moduleId })\n );\n}\nfunction parseJson(source, description, moduleId) {\n try {\n return JSON.parse(source);\n } catch (error) {\n throw cacheCorrupt(\n `${description} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n moduleId\n );\n }\n}\nfunction defaultMetroCompilerCacheRoot(projectRoot) {\n return join(tamaguiCacheRoot(projectRoot), \"metro-compiler\");\n}\nclass MetroCompilerCache {\n constructor(root) {\n this.root = root;\n this.#blobsDirectory = join(root, `v${METRO_COMPILER_CACHE_VERSION}`, \"blobs\");\n this.#manifestPath = join(root, `v${METRO_COMPILER_CACHE_VERSION}`, \"manifest.json\");\n }\n root;\n #blobsDirectory;\n #manifestPath;\n async publish(platform, entries, optionsHash) {\n await mkdir(this.#blobsDirectory, { recursive: true });\n const descriptors = {};\n for (const entry of [...entries].sort(\n (left, right) => compareCodeUnits(left.moduleId, right.moduleId)\n )) {\n if (entry.schemaVersion !== METRO_COMPILER_CACHE_VERSION) {\n throw new Error(`Cannot publish cache schema ${entry.schemaVersion}`);\n }\n const serialized = `${stableStringify(entry)}\n`;\n const blobHash = contentHash(serialized);\n const blobPath = join(this.#blobsDirectory, `${blobHash}.json`);\n try {\n await writeFile(blobPath, serialized, { encoding: \"utf8\", flag: \"wx\" });\n } catch (error) {\n if (error.code !== \"EEXIST\") throw error;\n const existing = await readFile(blobPath, \"utf8\");\n if (contentHash(existing) !== blobHash) {\n const temporaryBlobPath = `${blobPath}.${process.pid}-${randomBytes(6).toString(\"hex\")}.tmp`;\n await writeFile(temporaryBlobPath, serialized, \"utf8\");\n await rename(temporaryBlobPath, blobPath);\n }\n }\n descriptors[entry.moduleId] = {\n blobHash,\n sourceHash: entry.sourceHash\n };\n }\n const generation = contentHash(stableStringify(descriptors));\n const manifest = {\n schemaVersion: METRO_COMPILER_CACHE_VERSION,\n generation,\n optionsHash,\n platform,\n entries: descriptors\n };\n const manifestDirectory = join(this.root, `v${METRO_COMPILER_CACHE_VERSION}`);\n const temporaryPath = join(\n manifestDirectory,\n `.manifest-${process.pid}-${randomBytes(6).toString(\"hex\")}.json`\n );\n await writeFile(temporaryPath, `${stableStringify(manifest)}\n`, \"utf8\");\n await rename(temporaryPath, this.#manifestPath);\n return generation;\n }\n async read(moduleId, rawSource, onMiss) {\n const manifest = await this.#readManifest();\n if (!manifest) return null;\n const descriptor = manifest.entries[moduleId];\n if (!descriptor) {\n onMiss?.(\"no-entry\");\n return null;\n }\n const sourceHash = contentHash(rawSource);\n if (sourceHash !== descriptor.sourceHash) {\n onMiss?.(\n \"source-hash-mismatch\",\n `worker ${sourceHash.slice(0, 12)} vs plan ${descriptor.sourceHash.slice(0, 12)}`\n );\n return null;\n }\n return await this.#readBlob(moduleId, descriptor);\n }\n async validate() {\n const diagnostics = [];\n try {\n const manifest = await this.#readManifest();\n if (!manifest) {\n return {\n valid: false,\n diagnostics,\n generation: null,\n moduleIds: [],\n sourceHashes: {},\n optionsHash: null\n };\n }\n const sourceHashes = {};\n for (const [moduleId, descriptor] of stableEntries(manifest.entries)) {\n await this.#readBlob(moduleId, descriptor);\n sourceHashes[moduleId] = descriptor.sourceHash;\n }\n return {\n valid: true,\n diagnostics,\n generation: manifest.generation,\n moduleIds: Object.keys(manifest.entries).sort(compareCodeUnits),\n sourceHashes,\n optionsHash: manifest.optionsHash\n };\n } catch (error) {\n if (error instanceof MetroCompilerCacheError) {\n diagnostics.push(error.diagnostic);\n return {\n valid: false,\n diagnostics,\n generation: null,\n moduleIds: [],\n sourceHashes: {},\n optionsHash: null\n };\n }\n throw error;\n }\n }\n async discardManifest() {\n await rm(this.#manifestPath, { force: true });\n }\n #zeroSidecarPath(generation) {\n return join(\n this.root,\n `v${METRO_COMPILER_CACHE_VERSION}`,\n `zero-${generation.slice(0, 32)}.json`\n );\n }\n async publishZeroCSS(sidecar) {\n await mkdir(join(this.root, `v${METRO_COMPILER_CACHE_VERSION}`), { recursive: true });\n const file = this.#zeroSidecarPath(sidecar.generation);\n const temporaryPath = `${file}.${process.pid}-${randomBytes(6).toString(\"hex\")}.tmp`;\n await writeFile(temporaryPath, `${stableStringify(sidecar)}\n`, \"utf8\");\n await rename(temporaryPath, file);\n }\n /** Null whenever the sidecar is absent or does not describe this generation. */\n async readZeroCSS(generation) {\n let source;\n try {\n source = await readFile(this.#zeroSidecarPath(generation), \"utf8\");\n } catch (error) {\n if (error.code === \"ENOENT\") return null;\n throw error;\n }\n const sidecar = parseJson(source, \"Zero CSS sidecar\");\n if (sidecar.schemaVersion !== METRO_COMPILER_CACHE_VERSION || sidecar.generation !== generation || typeof sidecar.configCSS !== \"string\" || !sidecar.zeroModuleCSS || typeof sidecar.zeroModuleCSS !== \"object\" || !sidecar.bridgeCSS || typeof sidecar.bridgeCSS !== \"object\" || !sidecar.bridges || typeof sidecar.bridges !== \"object\") {\n return null;\n }\n return sidecar;\n }\n async #readManifest() {\n let source;\n try {\n source = await readFile(this.#manifestPath, \"utf8\");\n } catch (error) {\n if (error.code === \"ENOENT\") return null;\n throw error;\n }\n const manifest = parseJson(source, \"Cache manifest\");\n if (manifest.schemaVersion !== METRO_COMPILER_CACHE_VERSION || typeof manifest.generation !== \"string\" || typeof manifest.optionsHash !== \"string\" || !manifest.entries || typeof manifest.entries !== \"object\") {\n throw cacheCorrupt(\"Cache manifest has an unsupported schema\");\n }\n return manifest;\n }\n async #readBlob(moduleId, descriptor) {\n const blobPath = join(this.#blobsDirectory, `${descriptor.blobHash}.json`);\n let source;\n try {\n source = await readFile(blobPath, \"utf8\");\n } catch (error) {\n if (error.code === \"ENOENT\") {\n throw cacheCorrupt(`Cache blob ${descriptor.blobHash} is missing`, moduleId);\n }\n throw error;\n }\n if (contentHash(source) !== descriptor.blobHash) {\n throw cacheCorrupt(`Cache blob ${descriptor.blobHash} failed its hash`, moduleId);\n }\n const entry = parseJson(\n source,\n `Cache blob ${descriptor.blobHash}`,\n moduleId\n );\n if (entry.schemaVersion !== METRO_COMPILER_CACHE_VERSION || entry.moduleId !== moduleId || typeof entry.sourceHash !== \"string\" || entry.sourceHash !== descriptor.sourceHash || !entry.plan || entry.plan.version !== LOWERED_MODULE_PLAN_VERSION || entry.plan.id !== moduleId || entry.plan.sourceHash !== entry.sourceHash || !Array.isArray(entry.plan.edits) || !Array.isArray(entry.plan.diagnostics) || !Array.isArray(entry.diagnostics)) {\n throw cacheCorrupt(\n `Cache blob ${descriptor.blobHash} has invalid contents`,\n moduleId\n );\n }\n return entry;\n }\n}\nexport {\n METRO_COMPILER_CACHE_VERSION,\n MetroCompilerCache,\n MetroCompilerCacheError,\n defaultMetroCompilerCacheRoot\n};\n//# sourceMappingURL=compilerCache.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AAM,WAAW,UAAU;GAC/C,MAAM,aAAa,cAAc,WAAW,SAAS,mBAAmB,QAAQ;EAClF;EACA,MAAM,QAAQ,UACZ,QACA,cAAc,WAAW,YACzB,QACF;EACA,IAAI,MAAM,uBAAkD,MAAM,aAAa,YAAY,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,WAAW,cAAc,CAAC,MAAM,QAAQ,MAAM,KAAK,YAAY,+BAA+B,MAAM,KAAK,OAAO,YAAY,MAAM,KAAK,eAAe,MAAM,cAAc,CAAC,MAAM,QAAQ,MAAM,KAAK,KAAK,KAAK,CAAC,MAAM,QAAQ,MAAM,KAAK,WAAW,KAAK,CAAC,MAAM,QAAQ,MAAM,WAAW,GAAG;GACjb,MAAM,aACJ,cAAc,WAAW,SAAS,wBAClC,QACF;EACF;EACA,OAAO;CACT;AACF"}
@@ -0,0 +1,18 @@
1
+ import { isAbsolute, relative } from "node:path";
2
+
3
+ function metroDiagnostic(code, message, details = {}) {
4
+ return {
5
+ code,
6
+ message,
7
+ ...details
8
+ };
9
+ }
10
+ function formatMetroCompilerDiagnostic(diagnostic, projectRoot) {
11
+ const sourceId = diagnostic.span?.id ?? diagnostic.moduleId;
12
+ const file = sourceId ? isAbsolute(sourceId) ? relative(projectRoot, sourceId) || "." : sourceId : null;
13
+ const location = file && diagnostic.line != null && diagnostic.column != null ? `${file}:${diagnostic.line}:${diagnostic.column}: ` : "";
14
+ return `[@tamagui/metro-plugin] ${location}${diagnostic.code}: ${diagnostic.message}`;
15
+ }
16
+
17
+ export { formatMetroCompilerDiagnostic, metroDiagnostic };
18
+ //# sourceMappingURL=diagnostics.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","names":[],"sources":["esm/diagnostics.js"],"sourcesContent":["import { isAbsolute, relative } from \"node:path\";\nfunction metroDiagnostic(code, message, details = {}) {\n return { code, message, ...details };\n}\nfunction formatMetroCompilerDiagnostic(diagnostic, projectRoot) {\n const sourceId = diagnostic.span?.id ?? diagnostic.moduleId;\n const file = sourceId ? isAbsolute(sourceId) ? relative(projectRoot, sourceId) || \".\" : sourceId : null;\n const location = file && diagnostic.line != null && diagnostic.column != null ? `${file}:${diagnostic.line}:${diagnostic.column}: ` : \"\";\n return `[@tamagui/metro-plugin] ${location}${diagnostic.code}: ${diagnostic.message}`;\n}\nexport {\n formatMetroCompilerDiagnostic,\n metroDiagnostic\n};\n//# sourceMappingURL=diagnostics.js.map\n"],"mappings":";;;AACA,SAAS,gBAAgB,MAAM,SAAS,UAAU,CAAC,GAAG;CACpD,OAAO;EAAE;EAAM;EAAS,GAAG;CAAQ;AACrC;AACA,SAAS,8BAA8B,YAAY,aAAa;CAC9D,MAAM,WAAW,WAAW,MAAM,MAAM,WAAW;CACnD,MAAM,OAAO,WAAW,WAAW,QAAQ,IAAI,SAAS,aAAa,QAAQ,KAAK,MAAM,WAAW;CACnG,MAAM,WAAW,QAAQ,WAAW,QAAQ,QAAQ,WAAW,UAAU,OAAO,GAAG,KAAK,GAAG,WAAW,KAAK,GAAG,WAAW,OAAO,MAAM;CACtI,OAAO,2BAA2B,WAAW,WAAW,KAAK,IAAI,WAAW;AAC9E"}