@tamagui/static 3.0.0-beta.807.1 → 3.0.0-beta.881.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.
- package/dist/cjs/compiler.cjs +17 -5
- package/dist/cjs/compilerHost.cjs +164 -50
- package/dist/cjs/componentDiscovery.cjs +90 -0
- package/dist/cjs/domStructuralPass.cjs +16 -6
- package/dist/cjs/exports.cjs +4 -1
- package/dist/cjs/extractor/bundleConfig.cjs +23 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +1 -1
- package/dist/cjs/zero/theme.cjs +5 -20
- package/dist/esm/compiler.mjs +18 -6
- package/dist/esm/compiler.mjs.map +1 -1
- package/dist/esm/compilerHost.mjs +162 -51
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/componentDiscovery.mjs +65 -0
- package/dist/esm/componentDiscovery.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +16 -6
- package/dist/esm/domStructuralPass.mjs.map +1 -1
- package/dist/esm/exports.mjs +4 -1
- package/dist/esm/extractor/bundleConfig.mjs +23 -1
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -1
- package/dist/esm/staticEvaluationIgnoredModules.mjs +1 -1
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -1
- package/dist/esm/zero/theme.mjs +5 -20
- package/dist/esm/zero/theme.mjs.map +1 -1
- package/package.json +17 -17
- package/src/compiler.ts +27 -5
- package/src/compilerHost.ts +274 -105
- package/src/componentDiscovery.ts +95 -0
- package/src/domStructuralPass.ts +26 -6
- package/src/exports.ts +2 -0
- package/src/extractor/bundleConfig.ts +34 -0
- package/src/staticEvaluationIgnoredModules.ts +1 -1
- package/src/zero/theme.ts +12 -21
- package/types/compiler.d.ts +13 -0
- package/types/compiler.d.ts.map +1 -1
- package/types/compilerHost.d.ts +13 -0
- package/types/compilerHost.d.ts.map +1 -1
- package/types/componentDiscovery.d.ts +27 -0
- package/types/componentDiscovery.d.ts.map +1 -0
- package/types/domStructuralPass.d.ts.map +1 -1
- package/types/exports.d.ts +2 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +7 -0
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/zero/theme.d.ts +0 -1
- package/types/zero/theme.d.ts.map +1 -1
package/dist/cjs/exports.cjs
CHANGED
|
@@ -23,7 +23,8 @@ var exports_exports = {};
|
|
|
23
23
|
__export(exports_exports, {
|
|
24
24
|
clearFormatCache: () => import_detectModuleFormat.clearFormatCache,
|
|
25
25
|
detectModuleFormat: () => import_detectModuleFormat.detectModuleFormat,
|
|
26
|
-
esbundleTamaguiConfig: () => import_bundle.esbundleTamaguiConfig
|
|
26
|
+
esbundleTamaguiConfig: () => import_bundle.esbundleTamaguiConfig,
|
|
27
|
+
evaluateComponentModule: () => import_bundleConfig.evaluateComponentModule
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(exports_exports);
|
|
29
30
|
__reExport(exports_exports, require("./checkDeps.cjs"), module.exports);
|
|
@@ -33,6 +34,8 @@ __reExport(exports_exports, require("./types.cjs"), module.exports);
|
|
|
33
34
|
__reExport(exports_exports, require("./constants.cjs"), module.exports);
|
|
34
35
|
__reExport(exports_exports, require("./extractor/concatClassName.cjs"), module.exports);
|
|
35
36
|
__reExport(exports_exports, require("./extractor/loadTamagui.cjs"), module.exports);
|
|
37
|
+
var import_bundleConfig = require("./extractor/bundleConfig.cjs");
|
|
38
|
+
__reExport(exports_exports, require("./componentDiscovery.cjs"), module.exports);
|
|
36
39
|
__reExport(exports_exports, require("./extractor/watchTamaguiConfig.cjs"), module.exports);
|
|
37
40
|
__reExport(exports_exports, require("./registerRequire.cjs"), module.exports);
|
|
38
41
|
var import_detectModuleFormat = require("./extractor/detectModuleFormat.cjs");
|
|
@@ -29,6 +29,7 @@ __export(bundleConfig_exports, {
|
|
|
29
29
|
bundleConfig: () => bundleConfig,
|
|
30
30
|
esbuildOptions: () => esbuildOptions,
|
|
31
31
|
esbuildOptionsWithPlugins: () => esbuildOptionsWithPlugins,
|
|
32
|
+
evaluateComponentModule: () => evaluateComponentModule,
|
|
32
33
|
getBundledConfig: () => getBundledConfig,
|
|
33
34
|
getComponentStaticConfigByName: () => getComponentStaticConfigByName,
|
|
34
35
|
getLoadedConfig: () => getLoadedConfig,
|
|
@@ -483,6 +484,28 @@ async function loadComponents(props, forceExports = false) {
|
|
|
483
484
|
const otherComponents = await loadComponentsInner(props, forceExports);
|
|
484
485
|
return [...coreComponents, ...otherComponents];
|
|
485
486
|
}
|
|
487
|
+
async function evaluateComponentModule(props, id) {
|
|
488
|
+
const previousIsStatic = process.env.IS_STATIC;
|
|
489
|
+
const previousIsServer = process.env.TAMAGUI_IS_SERVER;
|
|
490
|
+
process.env.IS_STATIC = "is_static";
|
|
491
|
+
process.env.TAMAGUI_IS_SERVER = "true";
|
|
492
|
+
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", { ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules });
|
|
493
|
+
try {
|
|
494
|
+
try {
|
|
495
|
+
return nodeRequire(id);
|
|
496
|
+
} catch (error) {
|
|
497
|
+
const code = error?.code;
|
|
498
|
+
if (code !== "ERR_REQUIRE_ESM" && code !== "ERR_REQUIRE_ASYNC_MODULE") throw error;
|
|
499
|
+
}
|
|
500
|
+
} finally {
|
|
501
|
+
unregister();
|
|
502
|
+
if (previousIsStatic === void 0) delete process.env.IS_STATIC;
|
|
503
|
+
else process.env.IS_STATIC = previousIsStatic;
|
|
504
|
+
if (previousIsServer === void 0) delete process.env.TAMAGUI_IS_SERVER;
|
|
505
|
+
else process.env.TAMAGUI_IS_SERVER = previousIsServer;
|
|
506
|
+
}
|
|
507
|
+
return import(`${(0, import_node_url.pathToFileURL)(id).href}?v=${import_fs_extra.default.statSync(id).mtimeMs}`);
|
|
508
|
+
}
|
|
486
509
|
function loadComponentsSync(props, forceExports = false) {
|
|
487
510
|
const coreComponents = getCoreComponentsSync(props);
|
|
488
511
|
const otherComponents = loadComponentsInnerSync(props, forceExports);
|
|
@@ -33,7 +33,7 @@ const tamaguiStaticEvaluationModules = Object.freeze({
|
|
|
33
33
|
"react-native-worklets": "react-native-worklets/lib/module/mock.js"
|
|
34
34
|
});
|
|
35
35
|
function getStaticEvaluationModuleReplacement(moduleName) {
|
|
36
|
-
return
|
|
36
|
+
return moduleName in tamaguiStaticEvaluationModules ? tamaguiStaticEvaluationModules[moduleName] : void 0;
|
|
37
37
|
}
|
|
38
38
|
function isIgnoredStaticEvaluationModule(moduleName, userIgnoredModules = []) {
|
|
39
39
|
return getStaticEvaluationModuleReplacement(moduleName) !== void 0 || userIgnoredModules.includes(moduleName);
|
package/dist/cjs/zero/theme.cjs
CHANGED
|
@@ -31,11 +31,7 @@ var import_helpers = require("@tamagui/helpers");
|
|
|
31
31
|
var import_web = require("@tamagui/web");
|
|
32
32
|
var import_theme_update = require("@tamagui/web/theme-update");
|
|
33
33
|
const MAX_THEME_BRANCHES = 8;
|
|
34
|
-
const LOWERABLE_RESERVED_PROPS = /* @__PURE__ */ new Set([
|
|
35
|
-
"name",
|
|
36
|
-
"reset",
|
|
37
|
-
"contain"
|
|
38
|
-
]);
|
|
34
|
+
const LOWERABLE_RESERVED_PROPS = /* @__PURE__ */ new Set(["name", "contain"]);
|
|
39
35
|
function jsxAttributeName(attribute) {
|
|
40
36
|
const name = (0, import_compiler_core.childNode)(attribute, "name");
|
|
41
37
|
return name && typeof name.name === "string" ? name.name : null;
|
|
@@ -98,7 +94,7 @@ function resolveThemeChain(chain, rootThemeName, config) {
|
|
|
98
94
|
const next = [];
|
|
99
95
|
for (const parent of branches) {
|
|
100
96
|
for (const option of node.options) {
|
|
101
|
-
const resolved = (0, import_web.resolveThemeName)(parent.name, option.name,
|
|
97
|
+
const resolved = (0, import_web.resolveThemeName)(parent.name, option.name, config.themes);
|
|
102
98
|
const tests = [parent.test, option.test].filter(Boolean);
|
|
103
99
|
next.push({
|
|
104
100
|
test: tests.length ? tests.join(" && ") : null,
|
|
@@ -126,7 +122,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
126
122
|
test: null,
|
|
127
123
|
name: void 0
|
|
128
124
|
}];
|
|
129
|
-
let reset = false;
|
|
130
125
|
let contain = false;
|
|
131
126
|
const themeKeyProps = {};
|
|
132
127
|
for (const attribute of (0, import_compiler_core.childNodes)(opening, "attributes")) {
|
|
@@ -191,7 +186,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
191
186
|
});
|
|
192
187
|
continue;
|
|
193
188
|
}
|
|
194
|
-
if (key === "reset") reset = literal2;
|
|
195
189
|
if (key === "contain") contain = literal2;
|
|
196
190
|
continue;
|
|
197
191
|
}
|
|
@@ -222,15 +216,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
222
216
|
}
|
|
223
217
|
themeKeyProps[key] = literal;
|
|
224
218
|
}
|
|
225
|
-
if (kind === "Theme" && reset && options.some((option) => option.name !== void 0)) {
|
|
226
|
-
violations.push({
|
|
227
|
-
rule: 4,
|
|
228
|
-
code: "local/unsupported-target",
|
|
229
|
-
span: span(opening),
|
|
230
|
-
component: "Theme",
|
|
231
|
-
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: "a <Theme> with both name and reset, which cannot mean one theme," })
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
219
|
if (!closing) {
|
|
235
220
|
violations.push({
|
|
236
221
|
rule: 4,
|
|
@@ -241,7 +226,8 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
241
226
|
});
|
|
242
227
|
}
|
|
243
228
|
const issues = [];
|
|
244
|
-
const
|
|
229
|
+
const themeUpdateConfig = config;
|
|
230
|
+
const inlineValues = kind === "ThemeUpdate" && Object.keys(themeKeyProps).length ? (0, import_theme_update.getInlineValuesFromProps)(themeKeyProps, themeUpdateConfig, (issue) => issues.push(issue)) : null;
|
|
245
231
|
for (const issue of issues) {
|
|
246
232
|
violations.push({
|
|
247
233
|
rule: 3,
|
|
@@ -255,7 +241,7 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
255
241
|
})
|
|
256
242
|
});
|
|
257
243
|
}
|
|
258
|
-
const inlineCSS = inlineValues ? (0, import_theme_update.getVariablesCSSRules)(inlineValues,
|
|
244
|
+
const inlineCSS = inlineValues ? (0, import_theme_update.getVariablesCSSRules)(inlineValues, themeUpdateConfig) : null;
|
|
259
245
|
if (inlineCSS) css.set(inlineCSS.identifier, inlineCSS.rules.join(""));
|
|
260
246
|
if (violations.length) return {
|
|
261
247
|
node: null,
|
|
@@ -269,7 +255,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
269
255
|
opening,
|
|
270
256
|
closing,
|
|
271
257
|
options,
|
|
272
|
-
reset,
|
|
273
258
|
contain,
|
|
274
259
|
layer: inlineValues && inlineCSS ? {
|
|
275
260
|
inlineValues,
|
package/dist/esm/compiler.mjs
CHANGED
|
@@ -2,7 +2,8 @@ import { CompilerSession, LOWERED_MODULE_PLAN_VERSION, ModulePlanCache, PLAN_CAC
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { ComponentDiscovery } from "./componentDiscovery.mjs";
|
|
6
|
+
import { createComponentRegistry, createTamaguiCompilerHost } from "./compilerHost.mjs";
|
|
6
7
|
import { domStructuralPass } from "./domStructuralPass.mjs";
|
|
7
8
|
import { loadTamagui } from "./extractor/loadTamagui.mjs";
|
|
8
9
|
import { resolveZeroRuntimeSync } from "./zero/options.mjs";
|
|
@@ -90,6 +91,7 @@ var CompilerFrontend = class {
|
|
|
90
91
|
planCaches = /* @__PURE__ */ new Map();
|
|
91
92
|
moduleRecords = /* @__PURE__ */ new Map();
|
|
92
93
|
moduleContext = null;
|
|
94
|
+
discovery = new ComponentDiscovery();
|
|
93
95
|
/**
|
|
94
96
|
* One cache per project root and platform. Absent when the project produced
|
|
95
97
|
* no content stamp, in which case plans are never persisted rather than
|
|
@@ -183,14 +185,18 @@ var CompilerFrontend = class {
|
|
|
183
185
|
if (!projectInfo.tamaguiConfig || !projectInfo.components) {
|
|
184
186
|
throw new Error("The compiler requires evaluated Tamagui config and components");
|
|
185
187
|
}
|
|
188
|
+
const componentModules = input.project.componentModules.map((component) => ({
|
|
189
|
+
moduleName: component.moduleName,
|
|
190
|
+
resolvedId: cleanId(component.id)
|
|
191
|
+
}));
|
|
192
|
+
const registry = createComponentRegistry(projectInfo.components, componentModules);
|
|
193
|
+
this.discovery.seed(registry);
|
|
186
194
|
const host = createTamaguiCompilerHost({
|
|
187
195
|
target: input.target,
|
|
188
196
|
tamaguiConfig: projectInfo.tamaguiConfig,
|
|
189
197
|
components: projectInfo.components,
|
|
190
|
-
componentModules
|
|
191
|
-
|
|
192
|
-
resolvedId: cleanId(component.id)
|
|
193
|
-
})),
|
|
198
|
+
componentModules,
|
|
199
|
+
registry,
|
|
194
200
|
disablePartialExtraction: input.project.disablePartialExtraction,
|
|
195
201
|
experimentalNativeFastPath: input.project.experimentalNativeFastPath,
|
|
196
202
|
zeroRuntime: input.project.zeroRuntime
|
|
@@ -204,7 +210,8 @@ var CompilerFrontend = class {
|
|
|
204
210
|
planCache: this.planCacheFor(input),
|
|
205
211
|
async load(id) {
|
|
206
212
|
return modules.get(id) ?? null;
|
|
207
|
-
}
|
|
213
|
+
},
|
|
214
|
+
prepare: (module) => this.discovery.prepare(module, registry, input.evaluate)
|
|
208
215
|
},
|
|
209
216
|
structuralPass: domStructuralPass
|
|
210
217
|
});
|
|
@@ -215,10 +222,15 @@ var CompilerFrontend = class {
|
|
|
215
222
|
invalidatedIds: [...invalidated].sort()
|
|
216
223
|
};
|
|
217
224
|
}
|
|
225
|
+
/** host-resolved ids of every module discovery found components in */
|
|
226
|
+
discoveredModuleIds() {
|
|
227
|
+
return this.discovery.ids();
|
|
228
|
+
}
|
|
218
229
|
async buildTree(input) {
|
|
219
230
|
const moduleContext = compilerContext(input);
|
|
220
231
|
if (this.moduleContext !== moduleContext) {
|
|
221
232
|
this.moduleRecords.clear();
|
|
233
|
+
this.discovery.clear();
|
|
222
234
|
this.moduleContext = moduleContext;
|
|
223
235
|
}
|
|
224
236
|
const componentBySpecifier = new Map(input.project.componentModules.map((component) => [component.moduleName, resolvedModuleId(cleanId(component.id))]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","names":[],"sources":["esm/compiler.js"],"sourcesContent":["import {\n CompilerSession,\n LOWERED_MODULE_PLAN_VERSION,\n ModulePlanCache,\n PLAN_CACHE_SCHEMA_VERSION,\n contentHash,\n defaultPlanCacheRoot,\n resolvedModuleId,\n stableStringify,\n yukuFactory\n} from \"@tamagui/compiler-core\";\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { createTamaguiCompilerHost } from \"./compilerHost\";\nimport { domStructuralPass } from \"./domStructuralPass\";\nimport { loadTamagui } from \"./extractor/loadTamagui\";\nimport { resolveZeroRuntimeSync } from \"./zero/options\";\nasync function loadCompilerProject({\n root,\n target,\n options: optionsIn,\n generation,\n rebuild = false,\n hostVersions = [],\n missingProjectMessage = \"Unable to load the Tamagui compiler project\",\n load = loadTamagui,\n resolveComponents\n}) {\n const components = [\n .../* @__PURE__ */ new Set([\"@tamagui/core\", ...optionsIn.components || [\"tamagui\"]])\n ];\n const options = {\n ...optionsIn,\n root,\n platform: target,\n components\n };\n const zeroRuntime = resolveZeroRuntimeSync(options, root).mode;\n if (zeroRuntime === \"enforce\") options.outputCSS = void 0;\n const projectInfo = await load(options, rebuild);\n if (!projectInfo?.tamaguiConfig || !projectInfo.components) {\n throw new Error(missingProjectMessage);\n }\n const componentModules = resolveComponents ? await resolveComponents(components, projectInfo, options) : [];\n const disablePartialExtraction = !!options.disablePartialExtraction;\n const experimentalNativeFastPath = target === \"native\" && options.experimental?.nativeFastPath === true;\n return {\n projectInfo,\n componentModules,\n generation: typeof generation === \"function\" ? generation(projectInfo, componentModules, options) : generation,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n cacheStamp: compilerProjectStamp({\n stampSources: projectInfo.stampSources ?? [],\n hostVersions,\n target,\n componentModules,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n development: process.env.NODE_ENV === \"development\"\n })\n };\n}\nconst requireFromCompiler = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst compilerPackageVersions = [\"@tamagui/compiler-core\", \"@tamagui/static\"].map(\n (name) => `${name}@${requireFromCompiler(`${name}/package.json`).version}`\n);\nfunction compilerProjectStamp(input) {\n if (!input.stampSources.length) return null;\n const sources = [];\n for (const file of [...new Set(input.stampSources)].sort()) {\n try {\n sources.push([file, contentHash(readFileSync(file))]);\n } catch {\n return null;\n }\n }\n return contentHash(\n stableStringify({\n schema: PLAN_CACHE_SCHEMA_VERSION,\n plan: LOWERED_MODULE_PLAN_VERSION,\n packages: [...compilerPackageVersions, ...input.hostVersions].sort(),\n target: input.target,\n development: input.development,\n componentModules: input.componentModules.map(({ moduleName, id }) => [\n moduleName,\n cleanId(id)\n ]),\n disablePartialExtraction: input.disablePartialExtraction,\n experimentalNativeFastPath: input.experimentalNativeFastPath,\n zeroRuntime: input.zeroRuntime,\n sources\n })\n );\n}\nfunction cleanId(id) {\n return id.split(/[?#]/, 1)[0];\n}\nfunction externalId(specifier) {\n return resolvedModuleId(`external://${encodeURIComponent(specifier)}`);\n}\nfunction compilerContext(input) {\n return `${input.root}\\0${input.target}\\0${input.environment ?? \"\"}\\0${input.project.generation}`;\n}\nfunction sourceCanBeLinked(root, id) {\n const clean = cleanId(id);\n const normalized = clean.replace(/\\\\/g, \"/\");\n if (!path.isAbsolute(clean) || normalized.includes(\"/node_modules/\")) return false;\n const relative = path.relative(root, clean);\n return relative === \"\" || relative !== \"..\" && !relative.startsWith(`..${path.sep}`);\n}\nclass CompilerFrontend {\n session = new CompilerSession();\n queue = Promise.resolve();\n planCaches = /* @__PURE__ */ new Map();\n moduleRecords = /* @__PURE__ */ new Map();\n moduleContext = null;\n /**\n * One cache per project root and platform. Absent when the project produced\n * no content stamp, in which case plans are never persisted rather than\n * persisted under an identity that cannot see a config change.\n */\n planCacheFor(input) {\n const stamp = input.project.cacheStamp;\n if (!stamp) return void 0;\n const root = defaultPlanCacheRoot(input.root, input.target);\n let store = this.planCaches.get(root);\n if (!store) {\n store = new ModulePlanCache(root);\n this.planCaches.set(root, store);\n }\n return { store, stamp };\n }\n /** Hits, misses and writes across every plan cache this frontend has used. */\n get planCacheStats() {\n const total = { hits: 0, misses: 0, writes: 0 };\n for (const store of this.planCaches.values()) {\n total.hits += store.stats.hits;\n total.misses += store.stats.misses;\n total.writes += store.stats.writes;\n }\n return total;\n }\n compile(input) {\n const operation = this.queue.then(async () => {\n const previousTarget = process.env.TAMAGUI_TARGET;\n const previousStatic = process.env.IS_STATIC;\n try {\n return await this.compileNow(input);\n } finally {\n if (previousTarget === void 0) delete process.env.TAMAGUI_TARGET;\n else process.env.TAMAGUI_TARGET = previousTarget;\n if (previousStatic === void 0) delete process.env.IS_STATIC;\n else process.env.IS_STATIC = previousStatic;\n }\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n update(input) {\n const operation = this.queue.then(async () => {\n const { modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n return [...invalidated].sort();\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n has(id) {\n return this.session.has(resolvedModuleId(cleanId(id)));\n }\n dependentsOf(id) {\n return this.session.dependentsOf(resolvedModuleId(cleanId(id)));\n }\n remove(id) {\n const operation = this.queue.then(async () => {\n const result = await this.session.remove(resolvedModuleId(cleanId(id)));\n for (const invalidatedId of result.invalidatedIds) {\n this.moduleRecords.delete(invalidatedId);\n }\n return result;\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n parseCount(id) {\n return this.session.parseCount(resolvedModuleId(cleanId(id)));\n }\n async compileNow(input) {\n const { rootModule, modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n const projectInfo = input.project.projectInfo;\n if (!projectInfo.tamaguiConfig || !projectInfo.components) {\n throw new Error(\"The compiler requires evaluated Tamagui config and components\");\n }\n const host = createTamaguiCompilerHost({\n target: input.target,\n tamaguiConfig: projectInfo.tamaguiConfig,\n components: projectInfo.components,\n componentModules: input.project.componentModules.map((component) => ({\n moduleName: component.moduleName,\n resolvedId: cleanId(component.id)\n })),\n disablePartialExtraction: input.project.disablePartialExtraction,\n experimentalNativeFastPath: input.project.experimentalNativeFastPath,\n zeroRuntime: input.project.zeroRuntime\n });\n const result = await this.session.compile({\n module: rootModule,\n adapter: {\n target: input.target,\n projectGeneration: input.project.generation,\n host,\n planCache: this.planCacheFor(input),\n async load(id) {\n return modules.get(id) ?? null;\n }\n },\n structuralPass: domStructuralPass\n });\n for (const id of result.invalidatedIds) invalidated.add(id);\n return {\n plan: result.plan,\n output: result.output,\n invalidatedIds: [...invalidated].sort()\n };\n }\n async buildTree(input) {\n const moduleContext = compilerContext(input);\n if (this.moduleContext !== moduleContext) {\n this.moduleRecords.clear();\n this.moduleContext = moduleContext;\n }\n const componentBySpecifier = new Map(\n input.project.componentModules.map((component) => [\n component.moduleName,\n resolvedModuleId(cleanId(component.id))\n ])\n );\n const modules = /* @__PURE__ */ new Map();\n const loading = /* @__PURE__ */ new Set();\n const addInstalledClosure = (module) => {\n if (modules.has(module.id) || loading.has(module.id)) return;\n loading.add(module.id);\n for (const dependency of module.imports) {\n if (dependency.external) continue;\n const installedDependency = this.moduleRecords.get(dependency.resolvedId);\n if (installedDependency && this.session.has(dependency.resolvedId)) {\n addInstalledClosure(installedDependency);\n }\n }\n modules.set(module.id, module);\n loading.delete(module.id);\n };\n const loadModule = async (rawId, source) => {\n const id = resolvedModuleId(cleanId(rawId));\n const existing = modules.get(id);\n if (existing) return existing;\n const installed = this.moduleRecords.get(id);\n if (installed?.source === source && this.session.has(id)) {\n addInstalledClosure(installed);\n return installed;\n }\n if (loading.has(id)) {\n return { id, source, imports: [] };\n }\n loading.add(id);\n const imports = [];\n for (const specifier of yukuFactory.scanImports(id, source)) {\n const configuredComponent = componentBySpecifier.get(specifier);\n if (configuredComponent) {\n imports.push({ specifier, resolvedId: configuredComponent, external: true });\n continue;\n }\n const resolution = await input.resolve(specifier, id);\n if (!resolution) continue;\n const canLink = !resolution.external && sourceCanBeLinked(input.root, resolution.id);\n const resolvedId = canLink ? resolvedModuleId(cleanId(resolution.id)) : path.isAbsolute(cleanId(resolution.id)) ? resolvedModuleId(cleanId(resolution.id)) : externalId(specifier);\n imports.push({ specifier, resolvedId, external: !canLink });\n if (canLink && !modules.has(resolvedId) && !loading.has(resolvedId)) {\n const installedDependency = this.moduleRecords.get(resolvedId);\n if (installedDependency && this.session.has(resolvedId)) {\n addInstalledClosure(installedDependency);\n } else {\n const dependencySource = await input.load(resolution.id);\n if (dependencySource !== null) {\n await loadModule(resolution.id, dependencySource);\n }\n }\n }\n }\n const module = { id, source, imports };\n modules.set(id, module);\n loading.delete(id);\n return module;\n };\n const rootModule = await loadModule(input.id, input.source);\n return { rootModule, modules };\n }\n}\nexport {\n CompilerFrontend,\n compilerProjectStamp,\n loadCompilerProject\n};\n//# sourceMappingURL=compiler.js.map\n"],"mappings":";;;;;;;;;;AAkBA,eAAe,oBAAoB,EACjC,MACA,QACA,SAAS,WACT,YACA,UAAU,OACV,eAAe,CAAC,GAChB,wBAAwB,+CACxB,OAAO,aACP,qBACC;CACD,MAAM,aAAa,CACjB,mBAAmB,IAAI,IAAI,CAAC,iBAAiB,GAAG,UAAU,cAAc,CAAC,SAAS,CAAC,CAAC,CACtF;CACA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W,IAAI,gBAAgB;MAClD;KACF;IACF;GACF;GACA,MAAM,SAAS;IAAE;IAAI;IAAQ;GAAQ;GACrC,QAAQ,IAAI,IAAI,MAAM;GACtB,QAAQ,OAAO,EAAE;GACjB,OAAO;EACT;EACA,MAAM,aAAa,MAAM,WAAW,MAAM,IAAI,MAAM,MAAM;EAC1D,OAAO;GAAE;GAAY;EAAQ;CAC/B;AACF"}
|
|
1
|
+
{"version":3,"file":"compiler.js","names":[],"sources":["esm/compiler.js"],"sourcesContent":["import {\n CompilerSession,\n LOWERED_MODULE_PLAN_VERSION,\n ModulePlanCache,\n PLAN_CACHE_SCHEMA_VERSION,\n contentHash,\n defaultPlanCacheRoot,\n resolvedModuleId,\n stableStringify,\n yukuFactory\n} from \"@tamagui/compiler-core\";\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { ComponentDiscovery } from \"./componentDiscovery\";\nimport { createComponentRegistry, createTamaguiCompilerHost } from \"./compilerHost\";\nimport { domStructuralPass } from \"./domStructuralPass\";\nimport { loadTamagui } from \"./extractor/loadTamagui\";\nimport { resolveZeroRuntimeSync } from \"./zero/options\";\nasync function loadCompilerProject({\n root,\n target,\n options: optionsIn,\n generation,\n rebuild = false,\n hostVersions = [],\n missingProjectMessage = \"Unable to load the Tamagui compiler project\",\n load = loadTamagui,\n resolveComponents\n}) {\n const components = [\n .../* @__PURE__ */ new Set([\"@tamagui/core\", ...optionsIn.components || [\"tamagui\"]])\n ];\n const options = {\n ...optionsIn,\n root,\n platform: target,\n components\n };\n const zeroRuntime = resolveZeroRuntimeSync(options, root).mode;\n if (zeroRuntime === \"enforce\") options.outputCSS = void 0;\n const projectInfo = await load(options, rebuild);\n if (!projectInfo?.tamaguiConfig || !projectInfo.components) {\n throw new Error(missingProjectMessage);\n }\n const componentModules = resolveComponents ? await resolveComponents(components, projectInfo, options) : [];\n const disablePartialExtraction = !!options.disablePartialExtraction;\n const experimentalNativeFastPath = target === \"native\" && options.experimental?.nativeFastPath === true;\n return {\n projectInfo,\n componentModules,\n generation: typeof generation === \"function\" ? generation(projectInfo, componentModules, options) : generation,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n cacheStamp: compilerProjectStamp({\n stampSources: projectInfo.stampSources ?? [],\n hostVersions,\n target,\n componentModules,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n development: process.env.NODE_ENV === \"development\"\n })\n };\n}\nconst requireFromCompiler = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst compilerPackageVersions = [\"@tamagui/compiler-core\", \"@tamagui/static\"].map(\n (name) => `${name}@${requireFromCompiler(`${name}/package.json`).version}`\n);\nfunction compilerProjectStamp(input) {\n if (!input.stampSources.length) return null;\n const sources = [];\n for (const file of [...new Set(input.stampSources)].sort()) {\n try {\n sources.push([file, contentHash(readFileSync(file))]);\n } catch {\n return null;\n }\n }\n return contentHash(\n stableStringify({\n schema: PLAN_CACHE_SCHEMA_VERSION,\n plan: LOWERED_MODULE_PLAN_VERSION,\n packages: [...compilerPackageVersions, ...input.hostVersions].sort(),\n target: input.target,\n development: input.development,\n componentModules: input.componentModules.map(({ moduleName, id }) => [\n moduleName,\n cleanId(id)\n ]),\n disablePartialExtraction: input.disablePartialExtraction,\n experimentalNativeFastPath: input.experimentalNativeFastPath,\n zeroRuntime: input.zeroRuntime,\n sources\n })\n );\n}\nfunction cleanId(id) {\n return id.split(/[?#]/, 1)[0];\n}\nfunction externalId(specifier) {\n return resolvedModuleId(`external://${encodeURIComponent(specifier)}`);\n}\nfunction compilerContext(input) {\n return `${input.root}\\0${input.target}\\0${input.environment ?? \"\"}\\0${input.project.generation}`;\n}\nfunction sourceCanBeLinked(root, id) {\n const clean = cleanId(id);\n const normalized = clean.replace(/\\\\/g, \"/\");\n if (!path.isAbsolute(clean) || normalized.includes(\"/node_modules/\")) return false;\n const relative = path.relative(root, clean);\n return relative === \"\" || relative !== \"..\" && !relative.startsWith(`..${path.sep}`);\n}\nclass CompilerFrontend {\n session = new CompilerSession();\n queue = Promise.resolve();\n planCaches = /* @__PURE__ */ new Map();\n moduleRecords = /* @__PURE__ */ new Map();\n moduleContext = null;\n discovery = new ComponentDiscovery();\n /**\n * One cache per project root and platform. Absent when the project produced\n * no content stamp, in which case plans are never persisted rather than\n * persisted under an identity that cannot see a config change.\n */\n planCacheFor(input) {\n const stamp = input.project.cacheStamp;\n if (!stamp) return void 0;\n const root = defaultPlanCacheRoot(input.root, input.target);\n let store = this.planCaches.get(root);\n if (!store) {\n store = new ModulePlanCache(root);\n this.planCaches.set(root, store);\n }\n return { store, stamp };\n }\n /** Hits, misses and writes across every plan cache this frontend has used. */\n get planCacheStats() {\n const total = { hits: 0, misses: 0, writes: 0 };\n for (const store of this.planCaches.values()) {\n total.hits += store.stats.hits;\n total.misses += store.stats.misses;\n total.writes += store.stats.writes;\n }\n return total;\n }\n compile(input) {\n const operation = this.queue.then(async () => {\n const previousTarget = process.env.TAMAGUI_TARGET;\n const previousStatic = process.env.IS_STATIC;\n try {\n return await this.compileNow(input);\n } finally {\n if (previousTarget === void 0) delete process.env.TAMAGUI_TARGET;\n else process.env.TAMAGUI_TARGET = previousTarget;\n if (previousStatic === void 0) delete process.env.IS_STATIC;\n else process.env.IS_STATIC = previousStatic;\n }\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n update(input) {\n const operation = this.queue.then(async () => {\n const { modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n return [...invalidated].sort();\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n has(id) {\n return this.session.has(resolvedModuleId(cleanId(id)));\n }\n dependentsOf(id) {\n return this.session.dependentsOf(resolvedModuleId(cleanId(id)));\n }\n remove(id) {\n const operation = this.queue.then(async () => {\n const result = await this.session.remove(resolvedModuleId(cleanId(id)));\n for (const invalidatedId of result.invalidatedIds) {\n this.moduleRecords.delete(invalidatedId);\n }\n return result;\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n parseCount(id) {\n return this.session.parseCount(resolvedModuleId(cleanId(id)));\n }\n async compileNow(input) {\n const { rootModule, modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n const projectInfo = input.project.projectInfo;\n if (!projectInfo.tamaguiConfig || !projectInfo.components) {\n throw new Error(\"The compiler requires evaluated Tamagui config and components\");\n }\n const componentModules = input.project.componentModules.map((component) => ({\n moduleName: component.moduleName,\n resolvedId: cleanId(component.id)\n }));\n const registry = createComponentRegistry(projectInfo.components, componentModules);\n this.discovery.seed(registry);\n const host = createTamaguiCompilerHost({\n target: input.target,\n tamaguiConfig: projectInfo.tamaguiConfig,\n components: projectInfo.components,\n componentModules,\n registry,\n disablePartialExtraction: input.project.disablePartialExtraction,\n experimentalNativeFastPath: input.project.experimentalNativeFastPath,\n zeroRuntime: input.project.zeroRuntime\n });\n const result = await this.session.compile({\n module: rootModule,\n adapter: {\n target: input.target,\n projectGeneration: input.project.generation,\n host,\n planCache: this.planCacheFor(input),\n async load(id) {\n return modules.get(id) ?? null;\n },\n prepare: (module) => this.discovery.prepare(module, registry, input.evaluate)\n },\n structuralPass: domStructuralPass\n });\n for (const id of result.invalidatedIds) invalidated.add(id);\n return {\n plan: result.plan,\n output: result.output,\n invalidatedIds: [...invalidated].sort()\n };\n }\n /** host-resolved ids of every module discovery found components in */\n discoveredModuleIds() {\n return this.discovery.ids();\n }\n async buildTree(input) {\n const moduleContext = compilerContext(input);\n if (this.moduleContext !== moduleContext) {\n this.moduleRecords.clear();\n this.discovery.clear();\n this.moduleContext = moduleContext;\n }\n const componentBySpecifier = new Map(\n input.project.componentModules.map((component) => [\n component.moduleName,\n resolvedModuleId(cleanId(component.id))\n ])\n );\n const modules = /* @__PURE__ */ new Map();\n const loading = /* @__PURE__ */ new Set();\n const addInstalledClosure = (module) => {\n if (modules.has(module.id) || loading.has(module.id)) return;\n loading.add(module.id);\n for (const dependency of module.imports) {\n if (dependency.external) continue;\n const installedDependency = this.moduleRecords.get(dependency.resolvedId);\n if (installedDependency && this.session.has(dependency.resolvedId)) {\n addInstalledClosure(installedDependency);\n }\n }\n modules.set(module.id, module);\n loading.delete(module.id);\n };\n const loadModule = async (rawId, source) => {\n const id = resolvedModuleId(cleanId(rawId));\n const existing = modules.get(id);\n if (existing) return existing;\n const installed = this.moduleRecords.get(id);\n if (installed?.source === source && this.session.has(id)) {\n addInstalledClosure(installed);\n return installed;\n }\n if (loading.has(id)) {\n return { id, source, imports: [] };\n }\n loading.add(id);\n const imports = [];\n for (const specifier of yukuFactory.scanImports(id, source)) {\n const configuredComponent = componentBySpecifier.get(specifier);\n if (configuredComponent) {\n imports.push({ specifier, resolvedId: configuredComponent, external: true });\n continue;\n }\n const resolution = await input.resolve(specifier, id);\n if (!resolution) continue;\n const canLink = !resolution.external && sourceCanBeLinked(input.root, resolution.id);\n const resolvedId = canLink ? resolvedModuleId(cleanId(resolution.id)) : path.isAbsolute(cleanId(resolution.id)) ? resolvedModuleId(cleanId(resolution.id)) : externalId(specifier);\n imports.push({ specifier, resolvedId, external: !canLink });\n if (canLink && !modules.has(resolvedId) && !loading.has(resolvedId)) {\n const installedDependency = this.moduleRecords.get(resolvedId);\n if (installedDependency && this.session.has(resolvedId)) {\n addInstalledClosure(installedDependency);\n } else {\n const dependencySource = await input.load(resolution.id);\n if (dependencySource !== null) {\n await loadModule(resolution.id, dependencySource);\n }\n }\n }\n }\n const module = { id, source, imports };\n modules.set(id, module);\n loading.delete(id);\n return module;\n };\n const rootModule = await loadModule(input.id, input.source);\n return { rootModule, modules };\n }\n}\nexport {\n CompilerFrontend,\n compilerProjectStamp,\n loadCompilerProject\n};\n//# sourceMappingURL=compiler.js.map\n"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