@tamagui/static 3.1.2 → 3.1.4
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/compilerHost.cjs +3 -0
- package/dist/cjs/extractor/bundle.cjs +17 -1
- package/dist/cjs/extractor/bundleConfig.cjs +18 -4
- package/dist/cjs/extractor/loadTamagui.cjs +4 -1
- package/dist/cjs/registerRequire.cjs +18 -1
- package/dist/esm/compilerHost.mjs +3 -0
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/extractor/bundle.mjs +17 -1
- package/dist/esm/extractor/bundle.mjs.map +1 -1
- package/dist/esm/extractor/bundleConfig.mjs +18 -4
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -1
- package/dist/esm/extractor/loadTamagui.mjs +4 -1
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -1
- package/dist/esm/registerRequire.mjs +18 -2
- package/dist/esm/registerRequire.mjs.map +1 -1
- package/package.json +19 -19
- package/src/compilerHost.ts +6 -0
- package/src/extractor/bundle.ts +19 -0
- package/src/extractor/bundleConfig.ts +12 -1
- package/src/extractor/loadTamagui.ts +1 -0
- package/src/registerRequire.ts +31 -1
- package/types/compilerHost.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +1 -0
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/registerRequire.d.ts +3 -1
- package/types/registerRequire.d.ts.map +1 -1
|
@@ -1116,6 +1116,8 @@ function createTamaguiCompilerHost(options) {
|
|
|
1116
1116
|
}
|
|
1117
1117
|
const row = import_dom.TAGS[tag];
|
|
1118
1118
|
const textLike = row.backing === "text" || row.backing === "textinput";
|
|
1119
|
+
const moduleName = modulesById.get(identity.resolvedId);
|
|
1120
|
+
const frontend = moduleName ? componentsByModule.get(moduleName)?.nameToInfo[textLike ? "Text" : "View"]?.staticConfig.styleFrontend : void 0;
|
|
1119
1121
|
const base = (textLike ? core.Text : core.View)?.staticConfig;
|
|
1120
1122
|
if (!base) return null;
|
|
1121
1123
|
const platformDefaults = platform === "web" ? {
|
|
@@ -1133,6 +1135,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1133
1135
|
displayName: tag,
|
|
1134
1136
|
staticConfig: normalizeStaticConfig({
|
|
1135
1137
|
...base,
|
|
1138
|
+
styleFrontend: frontend,
|
|
1136
1139
|
isDOM: true,
|
|
1137
1140
|
isInput: row.backing === "textinput",
|
|
1138
1141
|
validStyles: {
|
|
@@ -70,7 +70,7 @@ const esbuildLoaderConfig = {
|
|
|
70
70
|
};
|
|
71
71
|
const dataExtensions = Object.keys(esbuildLoaderConfig).filter((k) => esbuildLoaderConfig[k] === "file" || esbuildLoaderConfig[k] === "dataurl").map((k) => k.slice(1));
|
|
72
72
|
const esbuildIgnoreFilesRegex = new RegExp(`.(${dataExtensions.join("|")})$`, "i");
|
|
73
|
-
function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangerouslyIgnoreStaticEvaluationModules = [], define: callerDefine, conditions: callerConditions = [], ...options }, platform, aliases) {
|
|
73
|
+
function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangerouslyIgnoreStaticEvaluationModules = [], nativePlatform, define: callerDefine, conditions: callerConditions = [], ...options }, platform, aliases) {
|
|
74
74
|
if (process.env.DEBUG?.startsWith("tamagui")) {
|
|
75
75
|
console.info(`Building`, entryPoints);
|
|
76
76
|
}
|
|
@@ -169,6 +169,22 @@ function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangero
|
|
|
169
169
|
{
|
|
170
170
|
name: "external",
|
|
171
171
|
setup(build) {
|
|
172
|
+
if (platform === "native") {
|
|
173
|
+
build.onResolve({ filter: /^react-native$/ }, () => ({
|
|
174
|
+
path: "react-native",
|
|
175
|
+
namespace: "tamagui-native-evaluation"
|
|
176
|
+
}));
|
|
177
|
+
build.onLoad({
|
|
178
|
+
filter: /.*/,
|
|
179
|
+
namespace: "tamagui-native-evaluation"
|
|
180
|
+
}, () => ({
|
|
181
|
+
contents: `export * from ${JSON.stringify(nodeRequire.resolve("@tamagui/react-native-web-lite"))}
|
|
182
|
+
import { getNativeColorFactories } from ${JSON.stringify(nodeRequire.resolve("@tamagui/react-native-web-lite/nativeColors"))}
|
|
183
|
+
export const { PlatformColor, DynamicColorIOS } = getNativeColorFactories(${JSON.stringify(nativePlatform || process.env.EXPO_OS || "ios")})`,
|
|
184
|
+
loader: "js",
|
|
185
|
+
resolveDir: build.initialOptions.absWorkingDir || process.cwd()
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
172
188
|
build.onResolve({ filter: /^@tamagui\/(core|web)$/ }, (args) => {
|
|
173
189
|
if (args.kind === "entry-point") {
|
|
174
190
|
return null;
|
|
@@ -182,6 +182,7 @@ function getBundleKey(props) {
|
|
|
182
182
|
components: props.components,
|
|
183
183
|
config: props.config,
|
|
184
184
|
platform: props.platform,
|
|
185
|
+
nativePlatform: props.nativePlatform,
|
|
185
186
|
dangerouslyIgnoreStaticEvaluationModules: props.dangerouslyIgnoreStaticEvaluationModules
|
|
186
187
|
});
|
|
187
188
|
}
|
|
@@ -277,7 +278,7 @@ async function bundleConfig(props, rebuild = false) {
|
|
|
277
278
|
isBundling = true;
|
|
278
279
|
const rootRequire = (0, import_node_module.createRequire)((0, import_node_path.join)(root, "package.json"));
|
|
279
280
|
const tmpDir = (0, import_node_path.join)(root, ".tamagui");
|
|
280
|
-
const platformSuffix =
|
|
281
|
+
const platformSuffix = props.platform === "native" ? `.native${props.nativePlatform ? `.${props.nativePlatform}` : ""}` : ".web";
|
|
281
282
|
const configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs";
|
|
282
283
|
const configExt = configFormat === "esm" ? ".mjs" : ".cjs";
|
|
283
284
|
const configOutPath = (0, import_node_path.join)(tmpDir, `tamagui.config${platformSuffix}${configExt}`);
|
|
@@ -330,6 +331,7 @@ async function bundleConfig(props, rebuild = false) {
|
|
|
330
331
|
absWorkingDir: root,
|
|
331
332
|
metafile: true,
|
|
332
333
|
dangerouslyIgnoreStaticEvaluationModules: props.dangerouslyIgnoreStaticEvaluationModules,
|
|
334
|
+
nativePlatform: props.nativePlatform,
|
|
333
335
|
...esbuildExtraOptions
|
|
334
336
|
}, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => {
|
|
335
337
|
return (0, import_bundle.esbundleTamaguiConfig)({
|
|
@@ -342,6 +344,7 @@ async function bundleConfig(props, rebuild = false) {
|
|
|
342
344
|
absWorkingDir: root,
|
|
343
345
|
metafile: true,
|
|
344
346
|
dangerouslyIgnoreStaticEvaluationModules: props.dangerouslyIgnoreStaticEvaluationModules,
|
|
347
|
+
nativePlatform: props.nativePlatform,
|
|
345
348
|
...esbuildExtraOptions
|
|
346
349
|
}, props.platform || "web");
|
|
347
350
|
})]);
|
|
@@ -488,7 +491,10 @@ async function evaluateComponentModule(props, id) {
|
|
|
488
491
|
const previousIsServer = process.env.TAMAGUI_IS_SERVER;
|
|
489
492
|
process.env.IS_STATIC = "is_static";
|
|
490
493
|
process.env.TAMAGUI_IS_SERVER = "true";
|
|
491
|
-
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
494
|
+
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
495
|
+
ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules,
|
|
496
|
+
nativePlatform: props.nativePlatform
|
|
497
|
+
});
|
|
492
498
|
try {
|
|
493
499
|
try {
|
|
494
500
|
return nodeRequire(id);
|
|
@@ -527,13 +533,17 @@ async function loadComponentsInner(props, forceExports = false) {
|
|
|
527
533
|
const componentsModules = props.components || [];
|
|
528
534
|
const key = JSON.stringify([
|
|
529
535
|
props.platform,
|
|
536
|
+
props.nativePlatform,
|
|
530
537
|
componentsModules,
|
|
531
538
|
props.dangerouslyIgnoreStaticEvaluationModules
|
|
532
539
|
]);
|
|
533
540
|
if (!forceExports && cacheComponents[key]) {
|
|
534
541
|
return cacheComponents[key];
|
|
535
542
|
}
|
|
536
|
-
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
543
|
+
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
544
|
+
ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules,
|
|
545
|
+
nativePlatform: props.nativePlatform
|
|
546
|
+
});
|
|
537
547
|
try {
|
|
538
548
|
const results = [];
|
|
539
549
|
for (const name of componentsModules) {
|
|
@@ -632,13 +642,17 @@ function loadComponentsInnerSync(props, forceExports = false) {
|
|
|
632
642
|
const componentsModules = props.components || [];
|
|
633
643
|
const key = JSON.stringify([
|
|
634
644
|
props.platform,
|
|
645
|
+
props.nativePlatform,
|
|
635
646
|
componentsModules,
|
|
636
647
|
props.dangerouslyIgnoreStaticEvaluationModules
|
|
637
648
|
]);
|
|
638
649
|
if (!forceExports && cacheComponents[key]) {
|
|
639
650
|
return cacheComponents[key];
|
|
640
651
|
}
|
|
641
|
-
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
652
|
+
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
653
|
+
ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules,
|
|
654
|
+
nativePlatform: props.nativePlatform
|
|
655
|
+
});
|
|
642
656
|
try {
|
|
643
657
|
const info = componentsModules.flatMap((name) => {
|
|
644
658
|
const extension = (0, import_node_path.extname)(name);
|
|
@@ -248,7 +248,10 @@ function loadTamaguiSync({ forceExports, cacheKey, ...propsIn }) {
|
|
|
248
248
|
const previousDev = globalThis["__DEV__"];
|
|
249
249
|
process.env.IS_STATIC = "is_static";
|
|
250
250
|
process.env.TAMAGUI_IS_SERVER = "true";
|
|
251
|
-
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
251
|
+
const { unregister } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
252
|
+
ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules,
|
|
253
|
+
nativePlatform: props.nativePlatform
|
|
254
|
+
});
|
|
252
255
|
try {
|
|
253
256
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
254
257
|
let tamaguiConfig = null;
|
|
@@ -22,6 +22,7 @@ var registerRequire_exports = {};
|
|
|
22
22
|
__export(registerRequire_exports, {
|
|
23
23
|
getNameToPaths: () => getNameToPaths,
|
|
24
24
|
registerRequire: () => registerRequire,
|
|
25
|
+
requireNativeEvaluationModule: () => requireNativeEvaluationModule,
|
|
25
26
|
setRequireResult: () => setRequireResult
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(registerRequire_exports);
|
|
@@ -31,6 +32,7 @@ var import_node = require("esbuild-register/dist/node");
|
|
|
31
32
|
var import_node_module = require("node:module");
|
|
32
33
|
var import_bundle = require("./extractor/bundle.cjs");
|
|
33
34
|
var import_requireTamaguiCore = require("./helpers/requireTamaguiCore.cjs");
|
|
35
|
+
var import_nativeColors = require("@tamagui/react-native-web-lite/nativeColors");
|
|
34
36
|
var import_staticEvaluationIgnoredModules = require("./staticEvaluationIgnoredModules.cjs");
|
|
35
37
|
const import_meta = {};
|
|
36
38
|
const nameToPaths = {};
|
|
@@ -59,6 +61,14 @@ const compiled = {};
|
|
|
59
61
|
function setRequireResult(name, result) {
|
|
60
62
|
compiled[name] = result;
|
|
61
63
|
}
|
|
64
|
+
function requireNativeEvaluationModule(modulePath, nativePlatform) {
|
|
65
|
+
const registration = registerRequire("native", { nativePlatform });
|
|
66
|
+
try {
|
|
67
|
+
return nodeRequire(modulePath);
|
|
68
|
+
} finally {
|
|
69
|
+
registration.unregister();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
62
72
|
function getStaticExtractionStub(path) {
|
|
63
73
|
switch (path) {
|
|
64
74
|
case "expo-constants": return {
|
|
@@ -112,7 +122,7 @@ function getStaticExtractionStub(path) {
|
|
|
112
122
|
default: return null;
|
|
113
123
|
}
|
|
114
124
|
}
|
|
115
|
-
function registerRequire(platform, { ignoredModules = [] } = { ignoredModules: [] }) {
|
|
125
|
+
function registerRequire(platform, { ignoredModules = [], nativePlatform } = { ignoredModules: [] }) {
|
|
116
126
|
if (isRegistered) {
|
|
117
127
|
return {
|
|
118
128
|
tamaguiRequire: nodeRequire,
|
|
@@ -141,6 +151,7 @@ function registerRequire(platform, { ignoredModules = [] } = { ignoredModules: [
|
|
|
141
151
|
}
|
|
142
152
|
isRegistered = true;
|
|
143
153
|
Module.prototype.require = tamaguiRequire;
|
|
154
|
+
let nativeModule;
|
|
144
155
|
function tamaguiRequire(path) {
|
|
145
156
|
const staticExtractionStub = getStaticExtractionStub(path);
|
|
146
157
|
if (staticExtractionStub) {
|
|
@@ -188,6 +199,12 @@ function registerRequire(platform, { ignoredModules = [] } = { ignoredModules: [
|
|
|
188
199
|
if (path === "react-native/package.json") {
|
|
189
200
|
return og.apply(this, ["react-native-web/package.json"]);
|
|
190
201
|
}
|
|
202
|
+
if (platform === "native" && path === "react-native") {
|
|
203
|
+
return nativeModule ||= {
|
|
204
|
+
...og.apply(this, ["@tamagui/react-native-web-lite"]),
|
|
205
|
+
...(0, import_nativeColors.getNativeColorFactories)(nativePlatform || process.env.EXPO_OS || "ios")
|
|
206
|
+
};
|
|
207
|
+
}
|
|
191
208
|
if (path === "@tamagui/react-native-web-lite" || path === "react-native" || path.startsWith("react-native/") || path === "react-native-web" || path.startsWith("react-native-web/")) {
|
|
192
209
|
try {
|
|
193
210
|
return og.apply("react-native");
|
|
@@ -1091,6 +1091,8 @@ function createTamaguiCompilerHost(options) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
const row = TAGS[tag];
|
|
1093
1093
|
const textLike = row.backing === "text" || row.backing === "textinput";
|
|
1094
|
+
const moduleName = modulesById.get(identity.resolvedId);
|
|
1095
|
+
const frontend = moduleName ? componentsByModule.get(moduleName)?.nameToInfo[textLike ? "Text" : "View"]?.staticConfig.styleFrontend : void 0;
|
|
1094
1096
|
const base = (textLike ? core.Text : core.View)?.staticConfig;
|
|
1095
1097
|
if (!base) return null;
|
|
1096
1098
|
const platformDefaults = platform === "web" ? {
|
|
@@ -1108,6 +1110,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1108
1110
|
displayName: tag,
|
|
1109
1111
|
staticConfig: normalizeStaticConfig({
|
|
1110
1112
|
...base,
|
|
1113
|
+
styleFrontend: frontend,
|
|
1111
1114
|
isDOM: true,
|
|
1112
1115
|
isInput: row.backing === "textinput",
|
|
1113
1116
|
validStyles: {
|