@tamagui/static 2.7.7 → 3.0.0-beta.1093.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/check-dep-versions.cjs +354 -0
- package/dist/cjs/checkDeps.cjs +301 -0
- package/dist/cjs/compiler.cjs +349 -0
- package/dist/cjs/compilerHost.cjs +2285 -0
- package/dist/cjs/componentDiscovery.cjs +94 -0
- package/dist/cjs/constants.cjs +32 -0
- package/dist/cjs/domStructuralPass.cjs +121 -0
- package/dist/cjs/exports.cjs +44 -0
- package/dist/cjs/extractor/addLocalExports.cjs +63 -0
- package/dist/cjs/extractor/bundle.cjs +229 -0
- package/dist/cjs/extractor/bundleConfig.cjs +769 -0
- package/dist/cjs/extractor/concatClassName.cjs +120 -0
- package/dist/cjs/extractor/detectModuleFormat.cjs +53 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.cjs +46 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +91 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +42 -0
- package/dist/cjs/extractor/loadTamagui.cjs +394 -0
- package/dist/cjs/extractor/regenerateConfig.cjs +160 -0
- package/dist/cjs/extractor/watchTamaguiConfig.cjs +63 -0
- package/dist/cjs/getPragmaOptions.cjs +66 -0
- package/dist/cjs/helpers/memoize.cjs +41 -0
- package/dist/cjs/helpers/requireTamaguiCore.cjs +39 -0
- package/dist/cjs/index.cjs +33 -0
- package/dist/cjs/registerRequire.cjs +219 -0
- package/dist/cjs/server.cjs +65 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +85 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/zero/artifact.cjs +144 -0
- package/dist/cjs/zero/graph.cjs +208 -0
- package/dist/cjs/zero/identity.cjs +60 -0
- package/dist/cjs/zero/index.cjs +33 -0
- package/dist/cjs/zero/islands.cjs +234 -0
- package/dist/cjs/zero/options.cjs +162 -0
- package/dist/cjs/zero/ownership.cjs +78 -0
- package/dist/cjs/zero/theme.cjs +337 -0
- package/dist/cjs/zero/transform.cjs +207 -0
- package/dist/esm/check-dep-versions.mjs +329 -0
- package/dist/esm/check-dep-versions.mjs.map +1 -0
- package/dist/esm/checkDeps.mjs +279 -0
- package/dist/esm/checkDeps.mjs.map +1 -0
- package/dist/esm/compiler.mjs +319 -0
- package/dist/esm/compiler.mjs.map +1 -0
- package/dist/esm/compilerHost.mjs +2263 -0
- package/dist/esm/compilerHost.mjs.map +1 -0
- package/dist/esm/componentDiscovery.mjs +69 -0
- package/dist/esm/componentDiscovery.mjs.map +1 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +102 -0
- package/dist/esm/domStructuralPass.mjs.map +1 -0
- package/dist/esm/exports.mjs +29 -0
- package/dist/esm/extractor/addLocalExports.mjs +44 -0
- package/dist/esm/extractor/addLocalExports.mjs.map +1 -0
- package/dist/esm/extractor/bundle.mjs +199 -0
- package/dist/esm/extractor/bundle.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.mjs +728 -0
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -0
- package/dist/esm/extractor/concatClassName.mjs +100 -0
- package/dist/esm/extractor/concatClassName.mjs.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.mjs +31 -0
- package/dist/esm/extractor/detectModuleFormat.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs +26 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +23 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +357 -0
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -0
- package/dist/esm/extractor/regenerateConfig.mjs +131 -0
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs +43 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.mjs +46 -0
- package/dist/esm/getPragmaOptions.mjs.map +1 -0
- package/dist/esm/helpers/memoize.mjs +21 -0
- package/dist/esm/helpers/memoize.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs +19 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/registerRequire.mjs +195 -0
- package/dist/esm/registerRequire.mjs.map +1 -0
- package/dist/esm/server.mjs +40 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/setup.mjs +0 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs +61 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/zero/artifact.mjs +119 -0
- package/dist/esm/zero/artifact.mjs.map +1 -0
- package/dist/esm/zero/graph.mjs +170 -0
- package/dist/esm/zero/graph.mjs.map +1 -0
- package/dist/esm/zero/identity.mjs +36 -0
- package/dist/esm/zero/identity.mjs.map +1 -0
- package/dist/esm/zero/index.mjs +19 -0
- package/dist/esm/zero/islands.mjs +200 -0
- package/dist/esm/zero/islands.mjs.map +1 -0
- package/dist/esm/zero/options.mjs +129 -0
- package/dist/esm/zero/options.mjs.map +1 -0
- package/dist/esm/zero/ownership.mjs +48 -0
- package/dist/esm/zero/ownership.mjs.map +1 -0
- package/dist/esm/zero/theme.mjs +313 -0
- package/dist/esm/zero/theme.mjs.map +1 -0
- package/dist/esm/zero/transform.mjs +182 -0
- package/dist/esm/zero/transform.mjs.map +1 -0
- package/package.json +38 -47
- package/src/check-dep-versions.ts +2 -2
- package/src/checkDeps.ts +3 -2
- package/src/compiler.ts +506 -0
- package/src/compilerHost.ts +3752 -0
- package/src/componentDiscovery.ts +105 -0
- package/src/constants.ts +0 -5
- package/src/domStructuralPass.ts +190 -0
- package/src/exports.ts +5 -6
- package/src/extractor/addLocalExports.ts +49 -0
- package/src/extractor/bundle.ts +38 -40
- package/src/extractor/bundleConfig.ts +368 -187
- package/src/extractor/concatClassName.ts +21 -24
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +13 -5
- package/src/extractor/loadTamagui.ts +196 -143
- package/src/extractor/regenerateConfig.ts +65 -13
- package/src/extractor/watchTamaguiConfig.ts +6 -1
- package/src/helpers/requireTamaguiCore.ts +6 -1
- package/src/registerRequire.ts +94 -132
- package/src/staticEvaluationIgnoredModules.ts +74 -0
- package/src/types.ts +2 -107
- package/src/zero/artifact.ts +142 -0
- package/src/zero/graph.ts +359 -0
- package/src/zero/identity.ts +73 -0
- package/src/zero/index.ts +9 -0
- package/src/zero/islands.ts +265 -0
- package/src/zero/options.ts +239 -0
- package/src/zero/ownership.ts +113 -0
- package/src/zero/theme.ts +526 -0
- package/src/zero/transform.ts +329 -0
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/compiler.d.ts +134 -0
- package/types/compiler.d.ts.map +1 -0
- package/types/compilerHost.d.ts +38 -0
- package/types/compilerHost.d.ts.map +1 -0
- package/types/componentDiscovery.d.ts +27 -0
- package/types/componentDiscovery.d.ts.map +1 -0
- package/types/constants.d.ts +0 -1
- package/types/constants.d.ts.map +1 -1
- package/types/domStructuralPass.d.ts +3 -0
- package/types/domStructuralPass.d.ts.map +1 -0
- package/types/exports.d.ts +5 -6
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/addLocalExports.d.ts +3 -0
- package/types/extractor/addLocalExports.d.ts.map +1 -0
- package/types/extractor/bundle.d.ts +66 -65
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +26 -4
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +26 -3
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchTamaguiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +2 -2
- package/types/registerRequire.d.ts.map +1 -1
- package/types/staticEvaluationIgnoredModules.d.ts +9 -0
- package/types/staticEvaluationIgnoredModules.d.ts.map +1 -0
- package/types/types.d.ts +2 -90
- package/types/types.d.ts.map +1 -1
- package/types/zero/artifact.d.ts +44 -0
- package/types/zero/artifact.d.ts.map +1 -0
- package/types/zero/graph.d.ts +139 -0
- package/types/zero/graph.d.ts.map +1 -0
- package/types/zero/identity.d.ts +33 -0
- package/types/zero/identity.d.ts.map +1 -0
- package/types/zero/index.d.ts +10 -0
- package/types/zero/index.d.ts.map +1 -0
- package/types/zero/islands.d.ts +56 -0
- package/types/zero/islands.d.ts.map +1 -0
- package/types/zero/options.d.ts +58 -0
- package/types/zero/options.d.ts.map +1 -0
- package/types/zero/ownership.d.ts +51 -0
- package/types/zero/ownership.d.ts.map +1 -0
- package/types/zero/theme.d.ts +85 -0
- package/types/zero/theme.d.ts.map +1 -0
- package/types/zero/transform.d.ts +53 -0
- package/types/zero/transform.d.ts.map +1 -0
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -48
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -129
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1968
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -108
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -475
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadTamagui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -100
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchTamaguiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireTamaguiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
- package/src/extractor/accessSafe.ts +0 -22
- package/src/extractor/babelParse.ts +0 -38
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/createEvaluator.ts +0 -82
- package/src/extractor/createExtractor.ts +0 -2970
- package/src/extractor/createLogger.ts +0 -41
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/errors.ts +0 -1
- package/src/extractor/evaluateAstNode.ts +0 -136
- package/src/extractor/extractHelpers.ts +0 -211
- package/src/extractor/extractMediaStyle.ts +0 -194
- package/src/extractor/extractToClassNames.ts +0 -733
- package/src/extractor/extractToNative.ts +0 -506
- package/src/extractor/findTopmostFunction.ts +0 -24
- package/src/extractor/generatedUid.ts +0 -41
- package/src/extractor/getPrefixLogs.ts +0 -9
- package/src/extractor/getPropValueFromAttributes.ts +0 -95
- package/src/extractor/getSourceModule.ts +0 -96
- package/src/extractor/getStaticBindingsForScope.ts +0 -237
- package/src/extractor/hasTopLevelAwait.ts +0 -28
- package/src/extractor/hoistClassNames.ts +0 -52
- package/src/extractor/literalToAst.ts +0 -85
- package/src/extractor/loadFile.ts +0 -17
- package/src/extractor/logLines.ts +0 -16
- package/src/extractor/normalizeTernaries.ts +0 -89
- package/src/extractor/propsToFontFamilyCache.ts +0 -18
- package/src/extractor/removeUnusedHooks.ts +0 -83
- package/src/extractor/timer.ts +0 -25
- package/src/extractor/validHTMLAttributes.ts +0 -52
- package/src/worker.ts +0 -142
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts +0 -12
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts +0 -32
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/createLogger.d.ts +0 -3
- package/types/extractor/createLogger.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/errors.d.ts +0 -3
- package/types/extractor/errors.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts +0 -28
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -11
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts +0 -25
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/extractToNative.d.ts +0 -13
- package/types/extractor/extractToNative.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts +0 -3
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -19
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -5
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hasTopLevelAwait.d.ts +0 -2
- package/types/extractor/hasTopLevelAwait.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadFile.d.ts +0 -1
- package/types/extractor/loadFile.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts +0 -5
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +0 -4
- package/types/extractor/propsToFontFamilyCache.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -52
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/worker.d.ts +0 -46
- package/types/worker.d.ts.map +0 -1
- /package/dist/{setup.cjs → cjs/setup.cjs} +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var options_exports = {};
|
|
28
|
+
__export(options_exports, {
|
|
29
|
+
ZERO_INTEGRATION_SUPPORT: () => ZERO_INTEGRATION_SUPPORT,
|
|
30
|
+
ZERO_OUT_DIRNAME: () => ZERO_OUT_DIRNAME,
|
|
31
|
+
assertZeroConfigDrivers: () => assertZeroConfigDrivers,
|
|
32
|
+
assertZeroIntegrationSupport: () => assertZeroIntegrationSupport,
|
|
33
|
+
islandIdFor: () => islandIdFor,
|
|
34
|
+
resolveZeroRuntime: () => resolveZeroRuntime,
|
|
35
|
+
resolveZeroRuntimeSync: () => resolveZeroRuntimeSync
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(options_exports);
|
|
38
|
+
var import_compiler_core = require("@tamagui/compiler-core");
|
|
39
|
+
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
40
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
41
|
+
const ZERO_OUT_DIRNAME = ".tamagui/zero";
|
|
42
|
+
function islandIdFor(moduleId) {
|
|
43
|
+
return import_node_path.default.basename(moduleId).replace(/\.[jt]sx?$/, "");
|
|
44
|
+
}
|
|
45
|
+
async function resolveZeroRuntime(options, root) {
|
|
46
|
+
const early = resolveZeroRuntimeEarly(options, root);
|
|
47
|
+
if (early.done) return early.resolved;
|
|
48
|
+
return finishZeroRuntime(options, root, early.islandGlobs, early.islandGlobs.length ? await (0, import_fast_glob.default)(early.islandGlobs, {
|
|
49
|
+
cwd: root,
|
|
50
|
+
absolute: true,
|
|
51
|
+
dot: false
|
|
52
|
+
}) : []);
|
|
53
|
+
}
|
|
54
|
+
function resolveZeroRuntimeSync(options, root) {
|
|
55
|
+
const early = resolveZeroRuntimeEarly(options, root);
|
|
56
|
+
if (early.done) return early.resolved;
|
|
57
|
+
return finishZeroRuntime(options, root, early.islandGlobs, early.islandGlobs.length ? import_fast_glob.default.sync(early.islandGlobs, {
|
|
58
|
+
cwd: root,
|
|
59
|
+
absolute: true,
|
|
60
|
+
dot: false
|
|
61
|
+
}) : []);
|
|
62
|
+
}
|
|
63
|
+
function resolveZeroRuntimeEarly(options, root) {
|
|
64
|
+
const requested = options.experimental?.zeroRuntime;
|
|
65
|
+
const outDir = import_node_path.default.join(root, ZERO_OUT_DIRNAME);
|
|
66
|
+
const off = {
|
|
67
|
+
mode: "off",
|
|
68
|
+
root,
|
|
69
|
+
islandGlobs: [],
|
|
70
|
+
islands: [],
|
|
71
|
+
outDir,
|
|
72
|
+
cssPath: ""
|
|
73
|
+
};
|
|
74
|
+
if (!requested) return {
|
|
75
|
+
done: true,
|
|
76
|
+
resolved: off
|
|
77
|
+
};
|
|
78
|
+
if (options.platform === "native" && requested === "report") {
|
|
79
|
+
return {
|
|
80
|
+
done: true,
|
|
81
|
+
resolved: {
|
|
82
|
+
...off,
|
|
83
|
+
mode: "report"
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (options.platform === "native") {
|
|
88
|
+
throw new Error(`[tamagui zero-runtime] experimental.zeroRuntime is web only. A native build always receives TAMAGUI_RUNTIME="full".`);
|
|
89
|
+
}
|
|
90
|
+
if (requested !== "report" && !options.outputCSS) {
|
|
91
|
+
throw new Error(`[tamagui zero-runtime] experimental.zeroRuntime requires outputCSS. The bundler owns one generated CSS artifact and derives TAMAGUI_DID_OUTPUT_CSS from it.`);
|
|
92
|
+
}
|
|
93
|
+
if (requested !== "report" && process.env.TAMAGUI_DOES_SSR_CSS === "mutates-themes") {
|
|
94
|
+
throw new Error(`[tamagui zero-runtime] Rule 4: TAMAGUI_DOES_SSR_CSS="mutates-themes" declares runtime theme mutation. Zero-runtime themes are build-time data. Remove runtime mutation or move that surface to a full-runtime island.`);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
done: false,
|
|
98
|
+
islandGlobs: requested === true || requested === "report" ? [] : requested.islands
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function finishZeroRuntime(options, root, islandGlobs, matches) {
|
|
102
|
+
const outDir = import_node_path.default.join(root, ZERO_OUT_DIRNAME);
|
|
103
|
+
const outputCSS = options.outputCSS ?? "";
|
|
104
|
+
const islands = [...new Set(matches.map((match) => import_node_path.default.normalize(match)))].sort().map((module2) => {
|
|
105
|
+
const id = islandIdFor(module2);
|
|
106
|
+
return {
|
|
107
|
+
id,
|
|
108
|
+
module: module2,
|
|
109
|
+
loader: import_node_path.default.join(outDir, `${id}.loader.js`),
|
|
110
|
+
entry: import_node_path.default.join(outDir, `${id}.entry.js`)
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const seen = /* @__PURE__ */ new Set();
|
|
114
|
+
for (const island of islands) {
|
|
115
|
+
if (seen.has(island.id)) {
|
|
116
|
+
throw new Error(`[tamagui zero-runtime] two declared islands share the basename "${island.id}". Island ids are their module basename because that is also the generated loader's filename.`);
|
|
117
|
+
}
|
|
118
|
+
seen.add(island.id);
|
|
119
|
+
}
|
|
120
|
+
if (islandGlobs.length && islands.length === 0) {
|
|
121
|
+
throw new Error(`[tamagui zero-runtime] experimental.zeroRuntime.islands matched no module for ${JSON.stringify(islandGlobs)}`);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
mode: options.experimental?.zeroRuntime === "report" ? "report" : "enforce",
|
|
125
|
+
root,
|
|
126
|
+
islandGlobs,
|
|
127
|
+
islands,
|
|
128
|
+
outDir,
|
|
129
|
+
cssPath: !outputCSS ? "" : import_node_path.default.isAbsolute(outputCSS) ? outputCSS : import_node_path.default.resolve(root, outputCSS)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function assertZeroConfigDrivers(config) {
|
|
133
|
+
const drivers = config.animationDrivers ? Object.entries(config.animationDrivers) : [["default", config.animations]];
|
|
134
|
+
for (const [name, driver] of drivers) {
|
|
135
|
+
if (!driver || driver.outputStyle === "css") continue;
|
|
136
|
+
throw new Error((0, import_compiler_core.zeroConfigDriverMessage)(name, driver.outputStyle));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const ZERO_INTEGRATION_SUPPORT = {
|
|
140
|
+
vite: {
|
|
141
|
+
base: true,
|
|
142
|
+
islands: true
|
|
143
|
+
},
|
|
144
|
+
"next-webpack": {
|
|
145
|
+
base: true,
|
|
146
|
+
islands: true
|
|
147
|
+
},
|
|
148
|
+
"metro-web": {
|
|
149
|
+
base: true,
|
|
150
|
+
islands: true
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
function assertZeroIntegrationSupport(integration, resolved) {
|
|
154
|
+
if (resolved.mode !== "enforce") return;
|
|
155
|
+
const support = ZERO_INTEGRATION_SUPPORT[integration];
|
|
156
|
+
if (!support.base) {
|
|
157
|
+
throw new Error(`[tamagui zero-runtime] ${integration} has not qualified for zero-runtime output in this version. Use zeroRuntime: "report" or choose a qualified integration.`);
|
|
158
|
+
}
|
|
159
|
+
if (resolved.islands.length && !support.islands) {
|
|
160
|
+
throw new Error(`[tamagui zero-runtime] ${integration} does not support experimental.zeroRuntime islands in this version. Use zeroRuntime: true without islands or choose an integration with island support.`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var ownership_exports = {};
|
|
28
|
+
__export(ownership_exports, {
|
|
29
|
+
checkGlobalCSSArtifact: () => checkGlobalCSSArtifact,
|
|
30
|
+
declaresRuntimeThemeMutation: () => declaresRuntimeThemeMutation,
|
|
31
|
+
hashCSS: () => hashCSS,
|
|
32
|
+
resolveGlobalCSSOwnership: () => resolveGlobalCSSOwnership
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ownership_exports);
|
|
35
|
+
var import_node_crypto = require("node:crypto");
|
|
36
|
+
var import_node_fs = require("node:fs");
|
|
37
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
38
|
+
var import_options = require("./options.cjs");
|
|
39
|
+
const hashCSS = (css) => (0, import_node_crypto.createHash)("sha256").update(css).digest("hex").slice(0, 16);
|
|
40
|
+
const normalize = (value) => value.split(/[?#]/, 1)[0].replace(/\\/g, "/");
|
|
41
|
+
const declaresRuntimeThemeMutation = () => process.env.TAMAGUI_DOES_SSR_CSS === "mutates-themes";
|
|
42
|
+
function resolveGlobalCSSOwnership(options, root) {
|
|
43
|
+
if (options.disable) return null;
|
|
44
|
+
if (options.platform === "native") return null;
|
|
45
|
+
if (!options.outputCSS) return null;
|
|
46
|
+
if (declaresRuntimeThemeMutation()) return null;
|
|
47
|
+
if ((0, import_options.resolveZeroRuntimeSync)(options, root).mode === "enforce") return null;
|
|
48
|
+
return { cssPath: import_node_path.default.isAbsolute(options.outputCSS) ? options.outputCSS : import_node_path.default.resolve(root, options.outputCSS) };
|
|
49
|
+
}
|
|
50
|
+
function checkGlobalCSSArtifact(input) {
|
|
51
|
+
const { cssPath, expectedCSS } = input;
|
|
52
|
+
let onDisk;
|
|
53
|
+
try {
|
|
54
|
+
onDisk = (0, import_node_fs.readFileSync)(cssPath, "utf8");
|
|
55
|
+
} catch {
|
|
56
|
+
return {
|
|
57
|
+
kind: "missing",
|
|
58
|
+
cssPath,
|
|
59
|
+
message: `[tamagui] the generated CSS artifact ${cssPath} does not exist, so this build cannot claim TAMAGUI_DID_OUTPUT_CSS. The design-system, :root, font and theme rules would be stripped from JavaScript and put nowhere.`
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (onDisk !== expectedCSS) {
|
|
63
|
+
return {
|
|
64
|
+
kind: "stale",
|
|
65
|
+
cssPath,
|
|
66
|
+
message: `[tamagui] the generated CSS artifact ${cssPath} is stale: it hashes ${hashCSS(onDisk)} but this build's config generates ${hashCSS(expectedCSS)}. Deriving TAMAGUI_DID_OUTPUT_CSS from it would ship rules that do not match the build.`
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const wanted = normalize(cssPath);
|
|
70
|
+
for (const id of input.loadedModuleIds) {
|
|
71
|
+
if (normalize(id) === wanted) return null;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
kind: "unimported",
|
|
75
|
+
cssPath,
|
|
76
|
+
message: `[tamagui] the generated CSS artifact ${cssPath} exists but the entry graph never loads it. ${input.importHint}`
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var theme_exports = {};
|
|
22
|
+
__export(theme_exports, {
|
|
23
|
+
foldBranches: () => foldBranches,
|
|
24
|
+
lowerStaticTheme: () => lowerStaticTheme,
|
|
25
|
+
readStaticTheme: () => readStaticTheme,
|
|
26
|
+
resolveThemeChain: () => resolveThemeChain
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(theme_exports);
|
|
29
|
+
var import_compiler_core = require("@tamagui/compiler-core");
|
|
30
|
+
var import_helpers = require("@tamagui/helpers");
|
|
31
|
+
var import_web = require("@tamagui/web");
|
|
32
|
+
var import_theme_update = require("@tamagui/web/theme-update");
|
|
33
|
+
const MAX_THEME_BRANCHES = 8;
|
|
34
|
+
const LOWERABLE_RESERVED_PROPS = /* @__PURE__ */ new Set(["name", "contain"]);
|
|
35
|
+
function jsxAttributeName(attribute) {
|
|
36
|
+
const name = (0, import_compiler_core.childNode)(attribute, "name");
|
|
37
|
+
return name && typeof name.name === "string" ? name.name : null;
|
|
38
|
+
}
|
|
39
|
+
function literalOf(node) {
|
|
40
|
+
if (!node) return void 0;
|
|
41
|
+
if (node.type === "Literal" && typeof node.value !== "object") {
|
|
42
|
+
return node.value;
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
function hasSideEffects(node) {
|
|
47
|
+
let found = false;
|
|
48
|
+
(0, import_compiler_core.walkAst)(node, (child) => {
|
|
49
|
+
if (child.type === "CallExpression" || child.type === "OptionalCallExpression" || child.type === "NewExpression" || child.type === "AwaitExpression" || child.type === "YieldExpression" || child.type === "AssignmentExpression" || child.type === "UpdateExpression" || child.type === "TaggedTemplateExpression") {
|
|
50
|
+
found = true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
function readNameOptions(value, source, guards) {
|
|
56
|
+
const literal = literalOf(value);
|
|
57
|
+
if (typeof literal === "string") {
|
|
58
|
+
return [{
|
|
59
|
+
test: guards.length ? guards.join(" && ") : null,
|
|
60
|
+
name: literal
|
|
61
|
+
}];
|
|
62
|
+
}
|
|
63
|
+
if (value.type === "ConditionalExpression") {
|
|
64
|
+
const test = (0, import_compiler_core.childNode)(value, "test");
|
|
65
|
+
const consequent = (0, import_compiler_core.childNode)(value, "consequent");
|
|
66
|
+
const alternate = (0, import_compiler_core.childNode)(value, "alternate");
|
|
67
|
+
if (!test || !consequent || !alternate) return null;
|
|
68
|
+
if (hasSideEffects(test)) return null;
|
|
69
|
+
const testText = source.slice(test.start, test.end).replace(/\s+/g, " ").trim();
|
|
70
|
+
const left = readNameOptions(consequent, source, [...guards, `(${testText})`]);
|
|
71
|
+
const right = readNameOptions(alternate, source, [...guards, `!(${testText})`]);
|
|
72
|
+
if (!left || !right) return null;
|
|
73
|
+
return [...left, ...right];
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function foldBranches(branches) {
|
|
78
|
+
const last = branches[branches.length - 1];
|
|
79
|
+
if (new Set(branches.map((branch) => branch.value)).size === 1) return last.value;
|
|
80
|
+
let expression = last.value;
|
|
81
|
+
for (let index = branches.length - 2; index >= 0; index--) {
|
|
82
|
+
const branch = branches[index];
|
|
83
|
+
expression = branch.test === null ? branch.value : `${branch.test} ? ${branch.value} : ${expression}`;
|
|
84
|
+
}
|
|
85
|
+
return expression;
|
|
86
|
+
}
|
|
87
|
+
function resolveThemeChain(chain, rootThemeName, config) {
|
|
88
|
+
let branches = [{
|
|
89
|
+
test: null,
|
|
90
|
+
name: rootThemeName,
|
|
91
|
+
isNew: false,
|
|
92
|
+
schemeAuthored: false
|
|
93
|
+
}];
|
|
94
|
+
for (const node of chain) {
|
|
95
|
+
const next = [];
|
|
96
|
+
for (const parent of branches) {
|
|
97
|
+
for (const option of node.options) {
|
|
98
|
+
const resolved = (0, import_web.resolveThemeName)(parent.name, option.name, config.themes);
|
|
99
|
+
const schemeAuthored = parent.schemeAuthored || Boolean(option.name && (0, import_helpers.getThemeScheme)(option.name) && option.name in config.themes);
|
|
100
|
+
const tests = [parent.test, option.test].filter(Boolean);
|
|
101
|
+
next.push({
|
|
102
|
+
test: tests.length ? tests.join(" && ") : null,
|
|
103
|
+
name: resolved ?? parent.name,
|
|
104
|
+
isNew: resolved !== null || schemeAuthored !== parent.schemeAuthored,
|
|
105
|
+
schemeAuthored
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
branches = next;
|
|
110
|
+
}
|
|
111
|
+
return branches;
|
|
112
|
+
}
|
|
113
|
+
function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
114
|
+
const moduleId = (0, import_compiler_core.resolvedModuleId)(id);
|
|
115
|
+
const violations = [];
|
|
116
|
+
const css = /* @__PURE__ */ new Map();
|
|
117
|
+
const opening = (0, import_compiler_core.childNode)(element, "openingElement");
|
|
118
|
+
const closing = (0, import_compiler_core.childNode)(element, "closingElement");
|
|
119
|
+
const span = (node) => ({
|
|
120
|
+
id: moduleId,
|
|
121
|
+
start: node.start,
|
|
122
|
+
end: node.end
|
|
123
|
+
});
|
|
124
|
+
let options = [{
|
|
125
|
+
test: null,
|
|
126
|
+
name: void 0
|
|
127
|
+
}];
|
|
128
|
+
let contain = false;
|
|
129
|
+
const themeKeyProps = {};
|
|
130
|
+
for (const attribute of (0, import_compiler_core.childNodes)(opening, "attributes")) {
|
|
131
|
+
if (attribute.type !== "JSXAttribute") {
|
|
132
|
+
violations.push({
|
|
133
|
+
rule: 1,
|
|
134
|
+
code: "local/unsafe-style-spread",
|
|
135
|
+
span: span(attribute),
|
|
136
|
+
component: kind,
|
|
137
|
+
message: (0, import_compiler_core.zeroRuleMessage)(1, { component: kind })
|
|
138
|
+
});
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const key = jsxAttributeName(attribute);
|
|
142
|
+
if (!key) continue;
|
|
143
|
+
const rawValue = (0, import_compiler_core.childNode)(attribute, "value");
|
|
144
|
+
const value = rawValue && rawValue.type === "JSXExpressionContainer" ? (0, import_compiler_core.childNode)(rawValue, "expression") : rawValue;
|
|
145
|
+
if (kind === "ThemeUpdate" && import_helpers.reservedThemeProps[key]) {
|
|
146
|
+
violations.push({
|
|
147
|
+
rule: 4,
|
|
148
|
+
code: "local/unsupported-target",
|
|
149
|
+
span: span(attribute),
|
|
150
|
+
component: kind,
|
|
151
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `the <ThemeUpdate ${key}> prop, which belongs on <Theme>,` })
|
|
152
|
+
});
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (kind === "Theme" && key === "name") {
|
|
156
|
+
const read = value ? readNameOptions(value, source, []) : null;
|
|
157
|
+
if (!read) {
|
|
158
|
+
violations.push({
|
|
159
|
+
rule: 4,
|
|
160
|
+
code: "local/unsupported-target",
|
|
161
|
+
span: span(attribute),
|
|
162
|
+
component: "Theme",
|
|
163
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `the <Theme name> value ${source.slice(attribute.start, attribute.end).replace(/\s+/g, " ").trim()}, which is not a literal theme name or a conditional over literal theme names,` })
|
|
164
|
+
});
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
options = read;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (kind === "Theme" && import_helpers.reservedThemeProps[key]) {
|
|
171
|
+
if (!LOWERABLE_RESERVED_PROPS.has(key)) {
|
|
172
|
+
violations.push({
|
|
173
|
+
rule: 4,
|
|
174
|
+
code: "local/unsupported-target",
|
|
175
|
+
span: span(attribute),
|
|
176
|
+
component: "Theme",
|
|
177
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `the <Theme ${key}> prop, which has no compiled form,` })
|
|
178
|
+
});
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const literal2 = value ? literalOf(value) : true;
|
|
182
|
+
if (typeof literal2 !== "boolean") {
|
|
183
|
+
violations.push({
|
|
184
|
+
rule: 4,
|
|
185
|
+
code: "local/unsupported-target",
|
|
186
|
+
span: span(attribute),
|
|
187
|
+
component: "Theme",
|
|
188
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `a non-literal <Theme ${key}> value,` })
|
|
189
|
+
});
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (key === "contain") contain = literal2;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (kind === "Theme") {
|
|
196
|
+
violations.push({
|
|
197
|
+
rule: 4,
|
|
198
|
+
code: "local/unsupported-target",
|
|
199
|
+
span: span(attribute),
|
|
200
|
+
component: "Theme",
|
|
201
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `the removed <Theme ${key}> inline-value spelling. Use <ThemeUpdate ${key}> around the subtree instead,` })
|
|
202
|
+
});
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const literal = value ? literalOf(value) : void 0;
|
|
206
|
+
if (typeof literal !== "string" && typeof literal !== "number") {
|
|
207
|
+
violations.push({
|
|
208
|
+
rule: 3,
|
|
209
|
+
code: "local/dynamic-style-value",
|
|
210
|
+
span: span(attribute),
|
|
211
|
+
component: kind,
|
|
212
|
+
message: (0, import_compiler_core.zeroRuleMessage)(3, {
|
|
213
|
+
prop: key,
|
|
214
|
+
component: kind,
|
|
215
|
+
detail: value ? "a theme value must be a string or number literal at build time" : "a theme key needs a value"
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
themeKeyProps[key] = literal;
|
|
221
|
+
}
|
|
222
|
+
if (!closing) {
|
|
223
|
+
violations.push({
|
|
224
|
+
rule: 4,
|
|
225
|
+
code: "local/unsupported-target",
|
|
226
|
+
span: span(element),
|
|
227
|
+
component: "Theme",
|
|
228
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `a self-closing <${kind}>, which has no subtree to theme,` })
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const issues = [];
|
|
232
|
+
const themeUpdateConfig = config;
|
|
233
|
+
const inlineValues = kind === "ThemeUpdate" && Object.keys(themeKeyProps).length ? (0, import_theme_update.getInlineValuesFromProps)(themeKeyProps, themeUpdateConfig, (issue) => issues.push(issue)) : null;
|
|
234
|
+
for (const issue of issues) {
|
|
235
|
+
violations.push({
|
|
236
|
+
rule: 3,
|
|
237
|
+
code: "local/dynamic-style-value",
|
|
238
|
+
span: span(opening),
|
|
239
|
+
component: kind,
|
|
240
|
+
message: (0, import_compiler_core.zeroRuleMessage)(3, {
|
|
241
|
+
prop: issue.key,
|
|
242
|
+
component: kind,
|
|
243
|
+
detail: issue.message
|
|
244
|
+
})
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const inlineCSS = inlineValues ? (0, import_theme_update.getVariablesCSSRules)(inlineValues, themeUpdateConfig) : null;
|
|
248
|
+
if (inlineCSS) css.set(inlineCSS.identifier, inlineCSS.rules.join(""));
|
|
249
|
+
if (violations.length) return {
|
|
250
|
+
node: null,
|
|
251
|
+
violations,
|
|
252
|
+
css
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
node: {
|
|
256
|
+
kind,
|
|
257
|
+
element,
|
|
258
|
+
opening,
|
|
259
|
+
closing,
|
|
260
|
+
options,
|
|
261
|
+
contain,
|
|
262
|
+
layer: inlineValues && inlineCSS ? {
|
|
263
|
+
inlineValues,
|
|
264
|
+
inlineClassName: inlineCSS.identifier
|
|
265
|
+
} : null
|
|
266
|
+
},
|
|
267
|
+
violations,
|
|
268
|
+
css
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function lowerStaticTheme(node, chain, rootThemeName, config, id) {
|
|
272
|
+
const moduleId = (0, import_compiler_core.resolvedModuleId)(id);
|
|
273
|
+
const branches = resolveThemeChain(chain, rootThemeName, config);
|
|
274
|
+
if (branches.length > MAX_THEME_BRANCHES) {
|
|
275
|
+
return {
|
|
276
|
+
edits: [],
|
|
277
|
+
violations: [{
|
|
278
|
+
rule: 4,
|
|
279
|
+
code: "local/unsupported-target",
|
|
280
|
+
span: {
|
|
281
|
+
id: moduleId,
|
|
282
|
+
start: node.element.start,
|
|
283
|
+
end: node.element.end
|
|
284
|
+
},
|
|
285
|
+
component: "Theme",
|
|
286
|
+
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: `a <Theme> chain that enumerates ${branches.length} theme names, past the ${MAX_THEME_BRANCHES} this lowers,` })
|
|
287
|
+
}]
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const inlineClass = node.layer?.inlineClassName ?? "";
|
|
291
|
+
const classBranches = branches.map((branch) => ({
|
|
292
|
+
test: branch.test,
|
|
293
|
+
value: JSON.stringify([
|
|
294
|
+
branch.isNew ? (0, import_helpers.getThemeClassNames)(branch.name, false, branch.schemeAuthored) : "",
|
|
295
|
+
"is_Theme",
|
|
296
|
+
inlineClass
|
|
297
|
+
].filter(Boolean).join(" ").replace(/\s+/g, " ").trim())
|
|
298
|
+
}));
|
|
299
|
+
const baseStyle = node.contain ? `display:"contents",contain:"strict"` : `display:"contents"`;
|
|
300
|
+
const styleBranches = branches.map((branch) => {
|
|
301
|
+
const theme = config.themes[branch.name];
|
|
302
|
+
const color = branch.isNew && theme ? (0, import_web.variableToString)(theme.color) : "";
|
|
303
|
+
return {
|
|
304
|
+
test: branch.test,
|
|
305
|
+
value: color ? `{color:${JSON.stringify(color)},${baseStyle}}` : `{${baseStyle}}`
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
const className = foldBranches(classBranches);
|
|
309
|
+
const style = foldBranches(styleBranches);
|
|
310
|
+
const classAttribute = className.startsWith("\"") ? `className=${className}` : `className={${className}}`;
|
|
311
|
+
const edits = [{
|
|
312
|
+
start: node.opening.start,
|
|
313
|
+
end: node.opening.end,
|
|
314
|
+
content: `<span ${classAttribute} style={${style}}>`,
|
|
315
|
+
origin: {
|
|
316
|
+
id: moduleId,
|
|
317
|
+
start: node.opening.start,
|
|
318
|
+
end: node.opening.end
|
|
319
|
+
}
|
|
320
|
+
}];
|
|
321
|
+
if (node.closing) {
|
|
322
|
+
edits.push({
|
|
323
|
+
start: node.closing.start,
|
|
324
|
+
end: node.closing.end,
|
|
325
|
+
content: `</span>`,
|
|
326
|
+
origin: {
|
|
327
|
+
id: moduleId,
|
|
328
|
+
start: node.closing.start,
|
|
329
|
+
end: node.closing.end
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
edits,
|
|
335
|
+
violations: []
|
|
336
|
+
};
|
|
337
|
+
}
|