@tamagui/cli 2.7.7 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/add.cjs +77 -87
- package/dist/build.cjs +415 -277
- package/dist/cli.cjs +343 -340
- package/dist/generate-prompt.cjs +344 -357
- package/dist/generate.cjs +46 -54
- package/dist/index.cjs +2 -1
- package/dist/migrate.cjs +370 -0
- package/dist/setup-prompt.cjs +158 -0
- package/dist/to-tailwind-default-config.cjs +778 -0
- package/dist/to-tailwind.cjs +214 -0
- package/dist/update-template.cjs +44 -52
- package/dist/update.cjs +15 -18
- package/dist/upgrade.cjs +407 -398
- package/dist/utils.cjs +85 -101
- package/metro.cjs +1 -0
- package/metro.d.ts +1 -0
- package/metro.mjs +1 -0
- package/package.json +41 -12
- package/src/build.ts +574 -363
- package/src/cli.ts +96 -12
- package/src/generate-prompt.ts +16 -24
- package/src/migrate.ts +354 -0
- package/src/setup-prompt.ts +139 -0
- package/src/to-tailwind-default-config.ts +755 -0
- package/src/to-tailwind.ts +313 -0
- package/src/utils.ts +11 -9
- package/types/add.d.ts +1 -1
- package/types/add.d.ts.map +1 -1
- package/types/build.d.ts +1 -1
- package/types/build.d.ts.map +1 -1
- package/types/migrate.d.ts +7 -0
- package/types/migrate.d.ts.map +1 -0
- package/types/setup-prompt.d.ts +3 -0
- package/types/setup-prompt.d.ts.map +1 -0
- package/types/to-tailwind-default-config.d.ts +53 -0
- package/types/to-tailwind-default-config.d.ts.map +1 -0
- package/types/to-tailwind.d.ts +16 -0
- package/types/to-tailwind.d.ts.map +1 -0
- package/types/utils.d.ts.map +1 -1
- package/vite.cjs +1 -0
- package/vite.d.ts +1 -0
- package/vite.mjs +1 -0
package/dist/generate-prompt.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,401 +6,387 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var generate_prompt_exports = {};
|
|
35
|
-
__export(generate_prompt_exports, {
|
|
36
|
-
generatePrompt: () => generatePrompt
|
|
37
|
-
});
|
|
29
|
+
__export(generate_prompt_exports, { generatePrompt: () => generatePrompt });
|
|
38
30
|
module.exports = __toCommonJS(generate_prompt_exports);
|
|
39
31
|
var import_node_path = require("node:path");
|
|
40
32
|
var FS = __toESM(require("fs-extra"));
|
|
41
33
|
async function generatePrompt(options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const config = await FS.readJSON(configPath);
|
|
59
|
-
const markdown = generateMarkdown(config);
|
|
60
|
-
const outputPath = output || (0, import_node_path.join)(process.cwd(), "tamagui-prompt.md");
|
|
61
|
-
await FS.writeFile(outputPath, markdown, "utf-8");
|
|
62
|
-
console.info(`
|
|
34
|
+
const { paths, output } = options;
|
|
35
|
+
const { loadTamagui } = require("@tamagui/static/loadTamagui");
|
|
36
|
+
process.env.TAMAGUI_KEEP_THEMES = "1";
|
|
37
|
+
await loadTamagui({
|
|
38
|
+
...options.tamaguiOptions,
|
|
39
|
+
platform: "web"
|
|
40
|
+
});
|
|
41
|
+
const configPath = (0, import_node_path.join)(paths.dotDir, "tamagui.config.json");
|
|
42
|
+
if (!FS.existsSync(configPath)) {
|
|
43
|
+
throw new Error(`Config file not found at ${configPath}. Please run 'tamagui generate' first.`);
|
|
44
|
+
}
|
|
45
|
+
const config = await FS.readJSON(configPath);
|
|
46
|
+
const markdown = generateMarkdown(config);
|
|
47
|
+
const outputPath = output || (0, import_node_path.join)(process.cwd(), "tamagui-prompt.md");
|
|
48
|
+
await FS.writeFile(outputPath, markdown, "utf-8");
|
|
49
|
+
console.info(`
|
|
63
50
|
\u2713 Generated prompt file at ${outputPath}
|
|
64
51
|
`);
|
|
65
52
|
}
|
|
66
53
|
function generateMarkdown(config) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
const sections = [];
|
|
55
|
+
sections.push("# Tamagui Configuration\n\n");
|
|
56
|
+
sections.push("This document provides an overview of the Tamagui configuration for this project.\n\n");
|
|
57
|
+
const shorthands = config.tamaguiConfig?.shorthands || {};
|
|
58
|
+
const reverseShorthands = {};
|
|
59
|
+
for (const [short, full] of Object.entries(shorthands)) {
|
|
60
|
+
reverseShorthands[full] = short;
|
|
61
|
+
}
|
|
62
|
+
const getPropName = (fullProp) => {
|
|
63
|
+
const settings2 = config.tamaguiConfig?.settings || {};
|
|
64
|
+
if (settings2.onlyAllowShorthands && reverseShorthands[fullProp]) {
|
|
65
|
+
return reverseShorthands[fullProp];
|
|
66
|
+
}
|
|
67
|
+
return fullProp;
|
|
68
|
+
};
|
|
69
|
+
const settings = config.tamaguiConfig?.settings || {};
|
|
70
|
+
if (Object.keys(settings).length > 0) {
|
|
71
|
+
sections.push("## Configuration Settings\n\n");
|
|
72
|
+
sections.push("**IMPORTANT:** These settings affect how you write Tamagui code in this project.\n\n");
|
|
73
|
+
if (settings.defaultFont) {
|
|
74
|
+
sections.push(`### Default Font: \`${settings.defaultFont}\`
|
|
88
75
|
|
|
89
76
|
`);
|
|
90
|
-
|
|
77
|
+
sections.push(`All text components will use the "${settings.defaultFont}" font family by default.
|
|
91
78
|
|
|
92
79
|
`);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
}
|
|
81
|
+
if (settings.onlyAllowShorthands !== void 0) {
|
|
82
|
+
sections.push(`### Only Allow Shorthands: \`${settings.onlyAllowShorthands}\`
|
|
96
83
|
|
|
97
84
|
`);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
85
|
+
if (settings.onlyAllowShorthands) {
|
|
86
|
+
sections.push("**You MUST use shorthand properties in this project.**\n\n");
|
|
87
|
+
sections.push("Full property names are not allowed. For example:\n");
|
|
88
|
+
sections.push("- ✅ `<View w=\"10\" />` (correct)\n");
|
|
89
|
+
sections.push("- ❌ `<View width=\"10\" />` (will error)\n\n");
|
|
90
|
+
sections.push("See the Shorthand Properties section below for all available shorthands.\n\n");
|
|
91
|
+
} else {
|
|
92
|
+
sections.push("You can use either shorthand or full property names.\n\n");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (settings.addThemeClassName !== void 0) {
|
|
96
|
+
sections.push(`### Theme Class Name: \`${settings.addThemeClassName}\`
|
|
110
97
|
|
|
111
98
|
`);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
if (settings.addThemeClassName === "html") {
|
|
100
|
+
sections.push("Theme classes are applied to the root HTML element.\n\n");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const platform = settings.platform || settings.defaultProps?.platform;
|
|
104
|
+
if (platform) {
|
|
105
|
+
sections.push(`### Platform Mode: \`${platform}\`
|
|
119
106
|
|
|
120
107
|
`);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
108
|
+
if (platform === "web") {
|
|
109
|
+
sections.push("This project is configured for **web only**.\n\n");
|
|
110
|
+
} else if (platform === "native") {
|
|
111
|
+
sections.push("This project is configured for **React Native only**.\n\n");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (settings.webContainerType) {
|
|
115
|
+
sections.push(`### Web Container Type: \`${settings.webContainerType}\`
|
|
129
116
|
|
|
130
117
|
`);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
118
|
+
sections.push("Enables web-specific container query optimizations.\n\n");
|
|
119
|
+
}
|
|
120
|
+
const configString = JSON.stringify(config.tamaguiConfig);
|
|
121
|
+
if (configString.includes("semi-strict-web")) {
|
|
122
|
+
sections.push("### Mode: `semi-strict-web`\n\n");
|
|
123
|
+
sections.push("This configuration uses semi-strict-web mode, which:\n");
|
|
124
|
+
sections.push("- Optimizes for web performance\n");
|
|
125
|
+
sections.push("- May have limited React Native API support\n");
|
|
126
|
+
sections.push("- Focuses on web-first development\n\n");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const componentsSection = [];
|
|
130
|
+
const allComponents = [];
|
|
131
|
+
for (const componentModule of config.components) {
|
|
132
|
+
const componentNames = Object.keys(componentModule.nameToInfo);
|
|
133
|
+
allComponents.push(...componentNames);
|
|
134
|
+
}
|
|
135
|
+
const componentGroups = /* @__PURE__ */ new Map();
|
|
136
|
+
const processed = /* @__PURE__ */ new Set();
|
|
137
|
+
const sortedComponents = [...allComponents].sort((a, b) => a.length - b.length);
|
|
138
|
+
for (const name of sortedComponents) {
|
|
139
|
+
if (processed.has(name)) continue;
|
|
140
|
+
const children = allComponents.filter((other) => other !== name && other.startsWith(name) && other[name.length]?.match(/[A-Z]/));
|
|
141
|
+
if (children.length > 0) {
|
|
142
|
+
componentGroups.set(name, new Set(children));
|
|
143
|
+
processed.add(name);
|
|
144
|
+
children.forEach((child) => processed.add(child));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const standaloneComponents = allComponents.filter((name) => !processed.has(name));
|
|
148
|
+
componentsSection.push("## Components\n\n");
|
|
149
|
+
componentsSection.push("The following components are available:\n\n");
|
|
150
|
+
const allBaseComponents = [...standaloneComponents, ...Array.from(componentGroups.keys())].sort();
|
|
151
|
+
for (const name of allBaseComponents) {
|
|
152
|
+
componentsSection.push(`- ${name}
|
|
166
153
|
`);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
154
|
+
if (componentGroups.has(name)) {
|
|
155
|
+
const children = Array.from(componentGroups.get(name)).sort();
|
|
156
|
+
for (const child of children) {
|
|
157
|
+
const suffix = child.slice(name.length);
|
|
158
|
+
componentsSection.push(` - ${name}.${suffix}
|
|
172
159
|
`);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
componentsSection.push("\n");
|
|
164
|
+
sections.push("## Shorthand Properties\n\n");
|
|
165
|
+
sections.push("These shorthand properties are available for styling:\n\n");
|
|
166
|
+
const shorthandEntries = Object.entries(shorthands).sort(([a], [b]) => a.localeCompare(b));
|
|
167
|
+
sections.push(shorthandEntries.map(([short, full]) => `- \`${short}\` \u2192 \`${full}\``).join("\n"));
|
|
168
|
+
sections.push("\n\n");
|
|
169
|
+
sections.push("## Themes\n\n");
|
|
170
|
+
const themes = config.tamaguiConfig?.themes || {};
|
|
171
|
+
const themeNames = Object.keys(themes).sort();
|
|
172
|
+
const hierarchy = {
|
|
173
|
+
level1: /* @__PURE__ */ new Set(),
|
|
174
|
+
level2: /* @__PURE__ */ new Set(),
|
|
175
|
+
level3: /* @__PURE__ */ new Set(),
|
|
176
|
+
components: /* @__PURE__ */ new Set()
|
|
177
|
+
};
|
|
178
|
+
for (const themeName of themeNames) {
|
|
179
|
+
const parts = themeName.split("_");
|
|
180
|
+
if (parts[0] === "light" || parts[0] === "dark") {
|
|
181
|
+
hierarchy.level1.add(parts[0]);
|
|
182
|
+
if (parts.length > 1 && parts[1] && !parts[1].startsWith("alt") && parts[1] !== "active") {
|
|
183
|
+
if (parts[1][0] === parts[1][0].toLowerCase()) {
|
|
184
|
+
hierarchy.level2.add(parts[1]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
for (const part of parts) {
|
|
188
|
+
if (part.startsWith("alt") || part === "active") {
|
|
189
|
+
hierarchy.level3.add(part);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const part of parts) {
|
|
193
|
+
if (part[0] && part[0] === part[0].toUpperCase() && part[0] !== part[0].toLowerCase()) {
|
|
194
|
+
hierarchy.components.add(part);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
if (parts.length === 1) {
|
|
199
|
+
hierarchy.level1.add(themeName);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
sections.push("Themes are organized hierarchically and can be combined:\n\n");
|
|
204
|
+
if (hierarchy.level1.size > 0) {
|
|
205
|
+
sections.push("**Level 1 (Base):**\n\n");
|
|
206
|
+
sections.push(Array.from(hierarchy.level1).sort().map((name) => `- ${name}`).join("\n"));
|
|
207
|
+
sections.push("\n\n");
|
|
208
|
+
}
|
|
209
|
+
if (hierarchy.level2.size > 0) {
|
|
210
|
+
sections.push("**Level 2 (Color Schemes):**\n\n");
|
|
211
|
+
sections.push(Array.from(hierarchy.level2).sort().map((name) => `- ${name}`).join("\n"));
|
|
212
|
+
sections.push("\n\n");
|
|
213
|
+
}
|
|
214
|
+
if (hierarchy.level3.size > 0) {
|
|
215
|
+
sections.push("**Level 3 (Variants):**\n\n");
|
|
216
|
+
sections.push(Array.from(hierarchy.level3).sort().map((name) => `- ${name}`).join("\n"));
|
|
217
|
+
sections.push("\n\n");
|
|
218
|
+
}
|
|
219
|
+
if (hierarchy.components.size > 0) {
|
|
220
|
+
sections.push("**Component Themes:**\n\n");
|
|
221
|
+
sections.push(Array.from(hierarchy.components).sort().map((name) => `- ${name}`).join("\n"));
|
|
222
|
+
sections.push("\n\n");
|
|
223
|
+
}
|
|
224
|
+
sections.push("### Theme Usage\n\n");
|
|
225
|
+
sections.push("Themes are combined hierarchically. For example, `light_blue_alt1_Button` combines:\n");
|
|
226
|
+
sections.push("- Base: `light`\n");
|
|
227
|
+
sections.push("- Color: `blue`\n");
|
|
228
|
+
sections.push("- Variant: `alt1`\n");
|
|
229
|
+
sections.push("- Component: `Button`\n\n");
|
|
230
|
+
sections.push("**Basic usage:**\n\n");
|
|
231
|
+
sections.push("```tsx\n");
|
|
232
|
+
sections.push("// Apply a theme to components\n");
|
|
233
|
+
sections.push("export default () => (\n");
|
|
234
|
+
sections.push(" <Theme name=\"dark\">\n");
|
|
235
|
+
sections.push(" <Button>I'm a dark button</Button>\n");
|
|
236
|
+
sections.push(" </Theme>\n");
|
|
237
|
+
sections.push(")\n\n");
|
|
238
|
+
sections.push("// Themes nest and combine automatically\n");
|
|
239
|
+
sections.push("export default () => (\n");
|
|
240
|
+
sections.push(" <Theme name=\"dark\">\n");
|
|
241
|
+
sections.push(" <Theme name=\"blue\">\n");
|
|
242
|
+
sections.push(" <Button>Uses dark_blue theme</Button>\n");
|
|
243
|
+
sections.push(" </Theme>\n");
|
|
244
|
+
sections.push(" </Theme>\n");
|
|
245
|
+
sections.push(")\n");
|
|
246
|
+
sections.push("```\n\n");
|
|
247
|
+
sections.push("**Accessing theme values:**\n\n");
|
|
248
|
+
sections.push("Components access theme values by their bare names:\n\n");
|
|
249
|
+
sections.push("```tsx\n");
|
|
250
|
+
sections.push(`<View ${getPropName("backgroundColor")}="background" ${getPropName("color")}="color" />
|
|
264
251
|
`);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
252
|
+
sections.push("```\n\n");
|
|
253
|
+
sections.push("**Special props:**\n\n");
|
|
254
|
+
sections.push("- `theme=\"inverse\"`: Uses the opposite light or dark sub-theme\n");
|
|
255
|
+
sections.push("- `reset`: Reverts to grandparent theme\n\n");
|
|
256
|
+
sections.push("## Tokens\n\n");
|
|
257
|
+
sections.push("Tokens are design system values referenced by their bare names.\n\n");
|
|
258
|
+
const tokens = config.tamaguiConfig?.tokens || {};
|
|
259
|
+
if (tokens.space) {
|
|
260
|
+
sections.push("### Space Tokens\n\n");
|
|
261
|
+
const spaceTokens = Object.entries(tokens.space).sort(([a], [b]) => {
|
|
262
|
+
const numA = parseFloat(a);
|
|
263
|
+
const numB = parseFloat(b);
|
|
264
|
+
if (!isNaN(numA) && !isNaN(numB)) {
|
|
265
|
+
return numA - numB;
|
|
266
|
+
}
|
|
267
|
+
return a.localeCompare(b);
|
|
268
|
+
});
|
|
269
|
+
sections.push(spaceTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join("\n"));
|
|
270
|
+
sections.push("\n\n");
|
|
271
|
+
}
|
|
272
|
+
if (tokens.size) {
|
|
273
|
+
sections.push("### Size Tokens\n\n");
|
|
274
|
+
const sizeTokens = Object.entries(tokens.size).sort(([a], [b]) => {
|
|
275
|
+
const numA = parseFloat(a);
|
|
276
|
+
const numB = parseFloat(b);
|
|
277
|
+
if (!isNaN(numA) && !isNaN(numB)) {
|
|
278
|
+
return numA - numB;
|
|
279
|
+
}
|
|
280
|
+
return a.localeCompare(b);
|
|
281
|
+
});
|
|
282
|
+
sections.push(sizeTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join("\n"));
|
|
283
|
+
sections.push("\n\n");
|
|
284
|
+
}
|
|
285
|
+
if (tokens.radius) {
|
|
286
|
+
sections.push("### Radius Tokens\n\n");
|
|
287
|
+
const radiusTokens = Object.entries(tokens.radius).sort(([a], [b]) => {
|
|
288
|
+
const numA = parseFloat(a);
|
|
289
|
+
const numB = parseFloat(b);
|
|
290
|
+
if (!isNaN(numA) && !isNaN(numB)) {
|
|
291
|
+
return numA - numB;
|
|
292
|
+
}
|
|
293
|
+
return a.localeCompare(b);
|
|
294
|
+
});
|
|
295
|
+
sections.push(radiusTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join("\n"));
|
|
296
|
+
sections.push("\n\n");
|
|
297
|
+
}
|
|
298
|
+
if (tokens.zIndex) {
|
|
299
|
+
sections.push("### Z-Index Tokens\n\n");
|
|
300
|
+
const zIndexTokens = Object.entries(tokens.zIndex).sort(([a], [b]) => {
|
|
301
|
+
const numA = parseFloat(a);
|
|
302
|
+
const numB = parseFloat(b);
|
|
303
|
+
if (!isNaN(numA) && !isNaN(numB)) {
|
|
304
|
+
return numA - numB;
|
|
305
|
+
}
|
|
306
|
+
return a.localeCompare(b);
|
|
307
|
+
});
|
|
308
|
+
sections.push(zIndexTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join("\n"));
|
|
309
|
+
sections.push("\n\n");
|
|
310
|
+
}
|
|
311
|
+
if (tokens.color) {
|
|
312
|
+
sections.push("### Color Tokens\n\n");
|
|
313
|
+
const colorTokens = Object.entries(tokens.color).sort(([a], [b]) => a.localeCompare(b));
|
|
314
|
+
sections.push(colorTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join("\n"));
|
|
315
|
+
sections.push("\n\n");
|
|
316
|
+
}
|
|
317
|
+
sections.push("### Token Usage\n\n");
|
|
318
|
+
sections.push("Tokens can be used in component props by their bare names:\n\n");
|
|
319
|
+
sections.push("```tsx\n");
|
|
320
|
+
sections.push("// Space tokens - for margin, padding, gap\n");
|
|
321
|
+
sections.push(`<View ${getPropName("padding")}="4" ${getPropName("gap")}="2" ${getPropName("margin")}="3" />
|
|
335
322
|
|
|
336
323
|
`);
|
|
337
|
-
|
|
338
|
-
|
|
324
|
+
sections.push("// Size tokens - for width, height, dimensions\n");
|
|
325
|
+
sections.push(`<View ${getPropName("width")}="10" ${getPropName("height")}="6" />
|
|
339
326
|
|
|
340
327
|
`);
|
|
341
|
-
|
|
342
|
-
|
|
328
|
+
sections.push("// Color tokens - for colors and backgrounds\n");
|
|
329
|
+
sections.push(`<View ${getPropName("backgroundColor")}="blue5" ${getPropName("color")}="gray12" />
|
|
343
330
|
|
|
344
331
|
`);
|
|
345
|
-
|
|
346
|
-
|
|
332
|
+
sections.push("// Radius tokens - for border-radius\n");
|
|
333
|
+
sections.push(`<View ${getPropName("borderRadius")}="4" />
|
|
347
334
|
`);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
335
|
+
sections.push("```\n\n");
|
|
336
|
+
if (config.tamaguiConfig?.media) {
|
|
337
|
+
sections.push("## Media Queries\n\n");
|
|
338
|
+
sections.push("Available responsive breakpoints:\n\n");
|
|
339
|
+
const media = config.tamaguiConfig.media;
|
|
340
|
+
const mediaEntries = Object.entries(media).sort(([a], [b]) => a.localeCompare(b));
|
|
341
|
+
for (const [name, query] of mediaEntries) {
|
|
342
|
+
sections.push(`- **${name}**: ${JSON.stringify(query)}
|
|
356
343
|
`);
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
344
|
+
}
|
|
345
|
+
sections.push("\n");
|
|
346
|
+
sections.push("### Media Query Usage\n\n");
|
|
347
|
+
sections.push("Media queries can be used as style props or with the `useMedia` hook:\n\n");
|
|
348
|
+
sections.push("```tsx\n");
|
|
349
|
+
sections.push("// As a clause in the same style value\n");
|
|
350
|
+
const firstMediaName = mediaEntries[0]?.[0];
|
|
351
|
+
if (firstMediaName) {
|
|
352
|
+
sections.push(`<View ${getPropName("width")}="100% ${firstMediaName}:50%" />
|
|
366
353
|
|
|
367
354
|
`);
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
355
|
+
}
|
|
356
|
+
sections.push("// Using the useMedia hook\n");
|
|
357
|
+
sections.push("const media = useMedia()\n");
|
|
358
|
+
if (firstMediaName) {
|
|
359
|
+
sections.push(`if (media.${firstMediaName}) {
|
|
373
360
|
`);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
361
|
+
sections.push(" // Render for this breakpoint\n");
|
|
362
|
+
sections.push("}\n");
|
|
363
|
+
}
|
|
364
|
+
sections.push("```\n\n");
|
|
365
|
+
}
|
|
366
|
+
if (config.tamaguiConfig?.fonts) {
|
|
367
|
+
sections.push("## Fonts\n\n");
|
|
368
|
+
sections.push("Available font families:\n\n");
|
|
369
|
+
const fonts = config.tamaguiConfig.fonts;
|
|
370
|
+
const fontNames = Object.keys(fonts).sort();
|
|
371
|
+
sections.push(fontNames.map((name) => `- ${name}`).join("\n"));
|
|
372
|
+
sections.push("\n\n");
|
|
373
|
+
}
|
|
374
|
+
if (config.tamaguiConfig?.animations) {
|
|
375
|
+
sections.push("## Animations\n\n");
|
|
376
|
+
sections.push("Available animation presets:\n\n");
|
|
377
|
+
const animations = config.tamaguiConfig.animations;
|
|
378
|
+
if (animations.animations) {
|
|
379
|
+
const animationNames = Object.keys(animations.animations).sort();
|
|
380
|
+
sections.push(animationNames.map((name) => `- ${name}`).join("\n"));
|
|
381
|
+
sections.push("\n\n");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
sections.push(...componentsSection);
|
|
385
|
+
return sections.join("");
|
|
399
386
|
}
|
|
400
387
|
function formatTokenValue(value) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
388
|
+
if (typeof value === "object" && value !== null && "val" in value) {
|
|
389
|
+
return String(value.val);
|
|
390
|
+
}
|
|
391
|
+
return String(value);
|
|
392
|
+
}
|