@tamagui/static 3.0.0-beta.924.1 → 3.0.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/compilerHost.cjs +241 -75
- package/dist/cjs/exports.cjs +5 -1
- package/dist/cjs/extractor/bundle.cjs +14 -9
- package/dist/cjs/extractor/bundleConfig.cjs +0 -1
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +81 -45
- package/dist/cjs/extractor/generateConfigMarkdown.cjs +492 -0
- package/dist/cjs/extractor/loadTamagui.cjs +28 -20
- package/dist/cjs/extractor/regenerateConfig.cjs +30 -20
- package/dist/cjs/zero/islands.cjs +2 -1
- package/dist/cjs/zero/theme.cjs +6 -3
- package/dist/esm/compilerHost.mjs +242 -76
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/exports.mjs +3 -1
- package/dist/esm/extractor/bundle.mjs +14 -9
- package/dist/esm/extractor/bundle.mjs.map +1 -1
- package/dist/esm/extractor/bundleConfig.mjs +0 -1
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -1
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +80 -45
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -1
- package/dist/esm/extractor/generateConfigMarkdown.mjs +472 -0
- package/dist/esm/extractor/generateConfigMarkdown.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +28 -20
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -1
- package/dist/esm/extractor/regenerateConfig.mjs +30 -20
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -1
- package/dist/esm/zero/islands.mjs +2 -1
- package/dist/esm/zero/islands.mjs.map +1 -1
- package/dist/esm/zero/theme.mjs +7 -4
- package/dist/esm/zero/theme.mjs.map +1 -1
- package/package.json +23 -20
- package/src/compilerHost.ts +387 -160
- package/src/exports.ts +3 -0
- package/src/extractor/bundle.ts +19 -7
- package/src/extractor/bundleConfig.ts +0 -1
- package/src/extractor/esbuildTsconfigPaths.ts +106 -78
- package/src/extractor/generateConfigMarkdown.ts +610 -0
- package/src/extractor/loadTamagui.ts +55 -24
- package/src/extractor/regenerateConfig.ts +36 -35
- package/src/zero/islands.ts +2 -1
- package/src/zero/options.ts +8 -3
- package/src/zero/theme.ts +29 -4
- package/types/compilerHost.d.ts.map +1 -1
- package/types/exports.d.ts +2 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildTsconfigPaths.d.ts +5 -7
- package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
- package/types/extractor/generateConfigMarkdown.d.ts +5 -0
- package/types/extractor/generateConfigMarkdown.d.ts.map +1 -0
- package/types/extractor/loadTamagui.d.ts +13 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/zero/identity.d.ts +1 -1
- package/types/zero/islands.d.ts.map +1 -1
- package/types/zero/options.d.ts +8 -3
- package/types/zero/options.d.ts.map +1 -1
- package/types/zero/theme.d.ts +2 -0
- package/types/zero/theme.d.ts.map +1 -1
|
@@ -117,6 +117,7 @@ async function loadTamaguiFromModules(propsIn, evaluated) {
|
|
|
117
117
|
if (props.outputCSS) {
|
|
118
118
|
await (0, import_bundleConfig.writeTamaguiCSS)(props.outputCSS, projectInfo.tamaguiConfig);
|
|
119
119
|
}
|
|
120
|
+
await (0, import_regenerateConfig.regenerateConfig)(props, projectInfo);
|
|
120
121
|
return projectInfo;
|
|
121
122
|
}
|
|
122
123
|
let waiting = false;
|
|
@@ -147,30 +148,37 @@ const buildConfigDependencies = /* @__PURE__ */ new WeakMap();
|
|
|
147
148
|
function getTamaguiBuildConfigDependencies(options) {
|
|
148
149
|
return buildConfigDependencies.get(options) ?? [];
|
|
149
150
|
}
|
|
150
|
-
async
|
|
151
|
+
const esbuildBuildConfigLoader = async (absolutePath, root) => {
|
|
152
|
+
const result = await import_esbuild.default.build({
|
|
153
|
+
entryPoints: [absolutePath],
|
|
154
|
+
absWorkingDir: root,
|
|
155
|
+
bundle: true,
|
|
156
|
+
packages: "external",
|
|
157
|
+
platform: "node",
|
|
158
|
+
format: "cjs",
|
|
159
|
+
target: "node18",
|
|
160
|
+
write: false,
|
|
161
|
+
metafile: true
|
|
162
|
+
});
|
|
163
|
+
const code = result.outputFiles[0]?.text;
|
|
164
|
+
if (!code) throw new Error(`No output generated for ${absolutePath}`);
|
|
165
|
+
const module2 = { exports: {} };
|
|
166
|
+
const projectRequire = (0, import_node_module.createRequire)(absolutePath);
|
|
167
|
+
const fn = new Function("module", "exports", "require", "process", code);
|
|
168
|
+
fn(module2, module2.exports, projectRequire, process);
|
|
169
|
+
return {
|
|
170
|
+
exports: module2.exports,
|
|
171
|
+
dependencies: Object.keys(result.metafile.inputs)
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
async function loadTamaguiBuildConfigAsync(tamaguiOptions, loadBuildConfigModule = esbuildBuildConfigLoader) {
|
|
151
175
|
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts";
|
|
152
176
|
const root = tamaguiOptions?.root || process.cwd();
|
|
153
177
|
const absolutePath = (0, import_node_path.resolve)(root, buildFilePath);
|
|
154
178
|
if (import_fs_extra.default.existsSync(absolutePath)) {
|
|
155
179
|
try {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
absWorkingDir: root,
|
|
159
|
-
bundle: true,
|
|
160
|
-
packages: "external",
|
|
161
|
-
platform: "node",
|
|
162
|
-
format: "cjs",
|
|
163
|
-
target: "node18",
|
|
164
|
-
write: false,
|
|
165
|
-
metafile: true
|
|
166
|
-
});
|
|
167
|
-
const module2 = { exports: {} };
|
|
168
|
-
const projectRequire = (0, import_node_module.createRequire)(absolutePath);
|
|
169
|
-
const code = result.outputFiles[0]?.text;
|
|
170
|
-
if (!code) throw new Error(`No output generated for ${buildFilePath}`);
|
|
171
|
-
const fn = new Function("module", "exports", "require", "process", code);
|
|
172
|
-
fn(module2, module2.exports, projectRequire, process);
|
|
173
|
-
const out = module2.exports.default || module2.exports;
|
|
180
|
+
const evaluated = await loadBuildConfigModule(absolutePath, root);
|
|
181
|
+
const out = evaluated.exports.default || evaluated.exports;
|
|
174
182
|
if (!out || typeof out !== "object") {
|
|
175
183
|
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
176
184
|
}
|
|
@@ -178,7 +186,7 @@ async function loadTamaguiBuildConfigAsync(tamaguiOptions) {
|
|
|
178
186
|
...tamaguiOptions,
|
|
179
187
|
...out
|
|
180
188
|
};
|
|
181
|
-
const dependencies2 =
|
|
189
|
+
const dependencies2 = evaluated.dependencies.map((file) => (0, import_node_path.resolve)(root, file));
|
|
182
190
|
buildConfigDependencies.set(loadedOptions, dependencies2);
|
|
183
191
|
tamaguiOptions = loadedOptions;
|
|
184
192
|
} catch (err) {
|
|
@@ -37,33 +37,35 @@ var import_generate_themes = require("@tamagui/generate-themes");
|
|
|
37
37
|
var import_helpers = require("@tamagui/helpers");
|
|
38
38
|
var import_tooling = require("@tamagui/style-grammar/tooling");
|
|
39
39
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
40
|
+
var import_generateConfigMarkdown = require("./generateConfigMarkdown.cjs");
|
|
40
41
|
var import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs");
|
|
41
42
|
var import_bundleConfig = require("./bundleConfig.cjs");
|
|
42
43
|
async function regenerateConfig(tamaguiOptions, configIn, rebuild = false) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await import_fs_extra.default.
|
|
49
|
-
|
|
50
|
-
} catch (err) {
|
|
51
|
-
if (process.env.DEBUG?.includes("tamagui") || process.env.IS_TAMAGUI_DEV) {
|
|
52
|
-
console.warn("regenerateConfig error", err);
|
|
44
|
+
const config = configIn ?? await (0, import_bundleConfig.getBundledConfig)(tamaguiOptions, rebuild);
|
|
45
|
+
if (!config) return;
|
|
46
|
+
const outputs = getConfigOutputs(tamaguiOptions, config);
|
|
47
|
+
await import_fs_extra.default.ensureDir((0, import_node_path.dirname)(outputs[0][0]));
|
|
48
|
+
await Promise.all(outputs.map(async ([file, content]) => {
|
|
49
|
+
if (await import_fs_extra.default.pathExists(file)) {
|
|
50
|
+
if (await import_fs_extra.default.readFile(file, "utf8") === content) return;
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
await import_fs_extra.default.writeFile(file, content);
|
|
53
|
+
}));
|
|
55
54
|
}
|
|
56
55
|
function regenerateConfigSync(tamaguiOptions, config) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
import_fs_extra.default.
|
|
61
|
-
|
|
62
|
-
if (process.env.DEBUG?.includes("tamagui") || process.env.IS_TAMAGUI_DEV) {
|
|
63
|
-
console.warn("regenerateConfig error", err);
|
|
64
|
-
}
|
|
56
|
+
const outputs = getConfigOutputs(tamaguiOptions, config);
|
|
57
|
+
import_fs_extra.default.ensureDirSync((0, import_node_path.dirname)(outputs[0][0]));
|
|
58
|
+
for (const [file, content] of outputs) {
|
|
59
|
+
if (import_fs_extra.default.existsSync(file) && import_fs_extra.default.readFileSync(file, "utf8") === content) continue;
|
|
60
|
+
import_fs_extra.default.writeFileSync(file, content);
|
|
65
61
|
}
|
|
66
62
|
}
|
|
63
|
+
function getConfigOutputs(options, config) {
|
|
64
|
+
const out = transformConfig(config, options.platform || "web");
|
|
65
|
+
const confFile = getConfigFile(options);
|
|
66
|
+
return [[confFile, `${JSON.stringify(out, null, 2)}
|
|
67
|
+
`], [(0, import_node_path.join)((0, import_node_path.dirname)(confFile), "prompt.md"), (0, import_generateConfigMarkdown.generateConfigMarkdown)(out)]];
|
|
68
|
+
}
|
|
67
69
|
async function generateTamaguiThemes(tamaguiOptions, force = false) {
|
|
68
70
|
if (!tamaguiOptions.themeBuilder) {
|
|
69
71
|
return;
|
|
@@ -97,7 +99,15 @@ function cloneDeepSafe(x, excludeKeys = {}) {
|
|
|
97
99
|
if (typeof x === "function") return `Function`;
|
|
98
100
|
if (typeof x !== "object") return x;
|
|
99
101
|
if ("$$typeof" in x) return "Component";
|
|
100
|
-
|
|
102
|
+
const entries = Object.entries(x);
|
|
103
|
+
let kept = 0;
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
if (excludeKeys[entry[0]]) continue;
|
|
106
|
+
entry[1] = cloneDeepSafe(entry[1]);
|
|
107
|
+
entries[kept++] = entry;
|
|
108
|
+
}
|
|
109
|
+
entries.length = kept;
|
|
110
|
+
return Object.fromEntries(entries);
|
|
101
111
|
}
|
|
102
112
|
function buildPropCategories() {
|
|
103
113
|
const out = {};
|
|
@@ -164,7 +164,8 @@ function generateIslandEntrySource(input) {
|
|
|
164
164
|
const entry = input.island.entry;
|
|
165
165
|
return `// generated by @tamagui/static zero-runtime. do not edit.
|
|
166
166
|
import * as React from 'react'
|
|
167
|
-
import { TamaguiProvider
|
|
167
|
+
import { TamaguiProvider } from 'tamagui/provider'
|
|
168
|
+
import { Theme } from '@tamagui/core'
|
|
168
169
|
import { createThemeUpdateState } from '@tamagui/web/theme-update'
|
|
169
170
|
import config from ${JSON.stringify(importPath(entry, input.configPath))}
|
|
170
171
|
import IslandRoot from ${JSON.stringify(importPath(entry, input.island.module))}
|
package/dist/cjs/zero/theme.cjs
CHANGED
|
@@ -88,18 +88,21 @@ function resolveThemeChain(chain, rootThemeName, config) {
|
|
|
88
88
|
let branches = [{
|
|
89
89
|
test: null,
|
|
90
90
|
name: rootThemeName,
|
|
91
|
-
isNew: false
|
|
91
|
+
isNew: false,
|
|
92
|
+
schemeAuthored: false
|
|
92
93
|
}];
|
|
93
94
|
for (const node of chain) {
|
|
94
95
|
const next = [];
|
|
95
96
|
for (const parent of branches) {
|
|
96
97
|
for (const option of node.options) {
|
|
97
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);
|
|
98
100
|
const tests = [parent.test, option.test].filter(Boolean);
|
|
99
101
|
next.push({
|
|
100
102
|
test: tests.length ? tests.join(" && ") : null,
|
|
101
103
|
name: resolved ?? parent.name,
|
|
102
|
-
isNew: resolved !== null
|
|
104
|
+
isNew: resolved !== null || schemeAuthored !== parent.schemeAuthored,
|
|
105
|
+
schemeAuthored
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
108
|
}
|
|
@@ -288,7 +291,7 @@ function lowerStaticTheme(node, chain, rootThemeName, config, id) {
|
|
|
288
291
|
const classBranches = branches.map((branch) => ({
|
|
289
292
|
test: branch.test,
|
|
290
293
|
value: JSON.stringify([
|
|
291
|
-
branch.isNew ? (0, import_helpers.getThemeClassNames)(branch.name) : "",
|
|
294
|
+
branch.isNew ? (0, import_helpers.getThemeClassNames)(branch.name, false, branch.schemeAuthored) : "",
|
|
292
295
|
"is_Theme",
|
|
293
296
|
inlineClass
|
|
294
297
|
].filter(Boolean).join(" ").replace(/\s+/g, " ").trim())
|