zelune 1.6.3 → 1.6.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/bin/cli.mjs +13 -53
  3. package/dist/assets/CheckoutScreen-6IdrpKgm.js +229 -0
  4. package/dist/assets/HomeScreen-Dxe9L4I2.js +316 -0
  5. package/dist/assets/LoginScreen-Dp1awI4F.js +189 -0
  6. package/dist/assets/ProductDetailScreen-Wa5_nlRP.js +196 -0
  7. package/dist/assets/ProfileScreen-riAU6vVh.js +185 -0
  8. package/dist/assets/index-hEzd4JVy.js +44697 -0
  9. package/{index.html → dist/index.html} +3 -1
  10. package/mcp/server.mjs +1324 -29
  11. package/package.json +10 -13
  12. package/plugin.json +1 -1
  13. package/socket.yml +11 -0
  14. package/mcp/server.ts +0 -446
  15. package/plugins/viteReactNativeFallbackPlugin.ts +0 -522
  16. package/plugins/viteRnSourceInject.ts +0 -105
  17. package/plugins/viteVirtualScreensPlugin.ts +0 -216
  18. package/src/canvas/CanvasApp.tsx +0 -1655
  19. package/src/canvas/FlowArrowsLayer.tsx +0 -239
  20. package/src/canvas/InspectorPanel.tsx +0 -1494
  21. package/src/canvas/ScreenArtboard.tsx +0 -1491
  22. package/src/canvas/types.ts +0 -23
  23. package/src/main.tsx +0 -80
  24. package/src/runtime/MockNavigationContext.tsx +0 -1869
  25. package/src/runtime/ScreenErrorBoundary.tsx +0 -86
  26. package/src/runtime/nativewindShim.ts +0 -997
  27. package/src/runtime/reactNativeShim.ts +0 -1674
  28. package/src/screens/CheckoutScreen.tsx +0 -229
  29. package/src/screens/HomeScreen.tsx +0 -288
  30. package/src/screens/LoginScreen.tsx +0 -176
  31. package/src/screens/ProductDetailScreen.tsx +0 -207
  32. package/src/screens/ProfileScreen.tsx +0 -172
  33. package/src/screens/index.ts +0 -1
  34. package/src/server/apiMiddleware.ts +0 -378
  35. package/src/server/astEngine.ts +0 -2624
  36. package/src/vite-env.d.ts +0 -7
  37. package/tsconfig.json +0 -23
  38. package/vite.config.ts +0 -339
  39. /package/{src/styles.css → dist/assets/index-C7nrS82N.css} +0 -0
package/src/vite-env.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- declare module 'virtual:zelune-screens' {
4
- import type React from 'react';
5
- export const SCREEN_COMPONENTS: Record<string, React.ComponentType>;
6
- export const SCREEN_ORDER: string[];
7
- }
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "useDefineForClassFields": true,
5
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
- "moduleResolution": "bundler",
9
- "allowImportingTsExtensions": true,
10
- "resolveJsonModule": true,
11
- "isolatedModules": true,
12
- "noEmit": true,
13
- "jsx": "react-jsx",
14
- "strict": true,
15
- "noUnusedLocals": false,
16
- "noUnusedParameters": false,
17
- "noFallthroughCasesInSwitch": true,
18
- "paths": {
19
- "react-native": ["./node_modules/react-native-web"]
20
- }
21
- },
22
- "include": ["src", "plugins", "mcp", "tests", "vite.config.ts"]
23
- }
package/vite.config.ts DELETED
@@ -1,339 +0,0 @@
1
- import { parse } from '@babel/parser';
2
- import { build, defineConfig, loadEnv } from 'vite';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
- import { viteRnSourceInject } from './plugins/viteRnSourceInject';
7
- import { viteVirtualScreensPlugin } from './plugins/viteVirtualScreensPlugin';
8
- import { viteReactNativeFallbackPlugin } from './plugins/viteReactNativeFallbackPlugin';
9
- import { viteCanvasApiMiddleware } from './src/server/apiMiddleware';
10
- import { findMobileAppRoot } from './src/server/astEngine';
11
-
12
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
-
14
- const rawTargetRoot = process.env.ANTIGRAVITY_TARGET_PROJECT
15
- ? path.resolve(process.env.ANTIGRAVITY_TARGET_PROJECT)
16
- : __dirname;
17
-
18
- const workspaceRoot = process.env.ANTIGRAVITY_WORKSPACE_ROOT
19
- ? path.resolve(process.env.ANTIGRAVITY_WORKSPACE_ROOT)
20
- : rawTargetRoot;
21
-
22
- const targetProjectRoot = findMobileAppRoot(rawTargetRoot);
23
- const mockNavShimPath = path.resolve(__dirname, 'src/runtime/MockNavigationContext.tsx');
24
- const reactNativeShimPath = path.resolve(__dirname, 'src/runtime/reactNativeShim.ts');
25
-
26
- function safeRealpath(targetPath: string): string {
27
- try {
28
- return fs.realpathSync(targetPath);
29
- } catch {
30
- return path.resolve(targetPath);
31
- }
32
- }
33
-
34
- function resolvePackageRootDir(pkgName: string): string {
35
- try {
36
- const pkgJsonUrl = import.meta.resolve(`${pkgName}/package.json`);
37
- return path.dirname(fileURLToPath(pkgJsonUrl));
38
- } catch {
39
- return pkgName;
40
- }
41
- }
42
-
43
- const resolvedReactDir = resolvePackageRootDir('react');
44
- const resolvedReactDomDir = resolvePackageRootDir('react-dom');
45
- const resolvedLucideDir = resolvePackageRootDir('lucide-react');
46
-
47
- function loadPublicProjectEnv(roots: string[]): Record<string, string> {
48
- const publicEnv: Record<string, string> = {
49
- NODE_ENV: 'development',
50
- EXPO_PUBLIC_PLATFORM: 'web',
51
- };
52
- const uniqueRoots = Array.from(new Set(roots.map((r) => path.resolve(r))));
53
-
54
- for (const rootDir of uniqueRoots) {
55
- try {
56
- const loaded = loadEnv('development', rootDir, ['EXPO_PUBLIC_', 'NEXT_PUBLIC_', 'VITE_']);
57
- Object.assign(publicEnv, loaded);
58
- } catch {
59
- // Ignore unreadable env directories
60
- }
61
- }
62
- return publicEnv;
63
- }
64
-
65
- const publicProjectEnv = loadPublicProjectEnv([workspaceRoot, rawTargetRoot, targetProjectRoot]);
66
-
67
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
- function extractStaticAstValue(node: any, scope: Map<string, unknown>, depth = 0): unknown {
69
- if (!node || depth > 12) return undefined;
70
-
71
- switch (node.type) {
72
- case 'StringLiteral':
73
- case 'NumericLiteral':
74
- case 'BooleanLiteral':
75
- return node.value;
76
- case 'NullLiteral':
77
- return null;
78
- case 'UnaryExpression': {
79
- const arg = extractStaticAstValue(node.argument, scope, depth + 1);
80
- if (typeof arg === 'number') {
81
- if (node.operator === '-') return -arg;
82
- if (node.operator === '+') return +arg;
83
- }
84
- return undefined;
85
- }
86
- case 'TemplateLiteral': {
87
- if (Array.isArray(node.expressions) && node.expressions.length === 0) {
88
- return node.quasis?.[0]?.value?.cooked ?? node.quasis?.[0]?.value?.raw ?? '';
89
- }
90
- return undefined;
91
- }
92
- case 'ArrayExpression': {
93
- const items: unknown[] = [];
94
- for (const el of node.elements ?? []) {
95
- if (!el) continue;
96
- if (el.type === 'SpreadElement') {
97
- const spreadVal = extractStaticAstValue(el.argument, scope, depth + 1);
98
- if (Array.isArray(spreadVal)) items.push(...spreadVal);
99
- } else {
100
- const val = extractStaticAstValue(el, scope, depth + 1);
101
- if (val !== undefined) items.push(val);
102
- }
103
- }
104
- return items;
105
- }
106
- case 'ObjectExpression': {
107
- const result: Record<string, unknown> = {};
108
- for (const prop of node.properties ?? []) {
109
- if (prop.type === 'SpreadElement') {
110
- const spreadObj = extractStaticAstValue(prop.argument, scope, depth + 1);
111
- if (spreadObj && typeof spreadObj === 'object' && !Array.isArray(spreadObj)) {
112
- Object.assign(result, spreadObj);
113
- }
114
- continue;
115
- }
116
- if (prop.type !== 'ObjectProperty' || prop.computed) continue;
117
- const key =
118
- prop.key?.type === 'Identifier'
119
- ? prop.key.name
120
- : prop.key?.type === 'StringLiteral' || prop.key?.type === 'NumericLiteral'
121
- ? String(prop.key.value)
122
- : null;
123
- if (!key) continue;
124
- const val = extractStaticAstValue(prop.value, scope, depth + 1);
125
- if (val !== undefined) {
126
- result[key] = val;
127
- }
128
- }
129
- return result;
130
- }
131
- case 'TSAsExpression':
132
- case 'TSSatisfiesExpression':
133
- case 'TSTypeAssertion':
134
- case 'ParenthesizedExpression':
135
- return extractStaticAstValue(node.expression, scope, depth + 1);
136
- case 'Identifier':
137
- return scope.get(node.name);
138
- default:
139
- return undefined;
140
- }
141
- }
142
-
143
- export function parseTailwindConfigSource(raw: string): Record<string, unknown> {
144
- try {
145
- const ast = parse(raw, {
146
- sourceType: 'unambiguous',
147
- plugins: ['typescript', 'jsx'],
148
- errorRecovery: true,
149
- });
150
-
151
- const scope = new Map<string, unknown>();
152
- let exportedConfig: unknown;
153
-
154
- for (const stmt of ast.program.body) {
155
- if (stmt.type === 'VariableDeclaration') {
156
- for (const decl of stmt.declarations) {
157
- if (decl.id.type === 'Identifier' && decl.init) {
158
- const val = extractStaticAstValue(decl.init, scope);
159
- if (val !== undefined) {
160
- scope.set(decl.id.name, val);
161
- }
162
- }
163
- }
164
- } else if (stmt.type === 'ExportDefaultDeclaration') {
165
- exportedConfig = extractStaticAstValue(stmt.declaration, scope);
166
- } else if (
167
- stmt.type === 'ExpressionStatement' &&
168
- stmt.expression.type === 'AssignmentExpression'
169
- ) {
170
- const left = stmt.expression.left;
171
- if (
172
- left.type === 'MemberExpression' &&
173
- left.object.type === 'Identifier' &&
174
- left.property.type === 'Identifier' &&
175
- ((left.object.name === 'module' && left.property.name === 'exports') ||
176
- (left.object.name === 'exports' && left.property.name === 'default'))
177
- ) {
178
- exportedConfig = extractStaticAstValue(stmt.expression.right, scope);
179
- }
180
- }
181
- }
182
-
183
- const cfg = exportedConfig as
184
- | { theme?: Record<string, unknown> & { extend?: Record<string, unknown> } }
185
- | undefined;
186
-
187
- if (cfg?.theme && typeof cfg.theme === 'object') {
188
- const baseTheme = { ...cfg.theme };
189
- const extendTheme =
190
- cfg.theme.extend && typeof cfg.theme.extend === 'object' ? cfg.theme.extend : {};
191
- delete baseTheme.extend;
192
- const merged: Record<string, unknown> = { ...baseTheme };
193
- for (const [k, v] of Object.entries(extendTheme)) {
194
- if (v && typeof v === 'object' && !Array.isArray(v)) {
195
- merged[k] = {
196
- ...((baseTheme[k] as Record<string, unknown>) ?? {}),
197
- ...(v as Record<string, unknown>),
198
- };
199
- } else {
200
- merged[k] = v;
201
- }
202
- }
203
- return merged;
204
- }
205
- } catch {
206
- // Ignore tailwind config parse errors
207
- }
208
- return {};
209
- }
210
-
211
- function loadProjectTailwindTheme(roots: string[]): Record<string, unknown> {
212
- const candidates = [
213
- 'tailwind.config.js',
214
- 'tailwind.config.cjs',
215
- 'tailwind.config.mjs',
216
- 'tailwind.config.ts',
217
- ];
218
- const uniqueRoots = Array.from(new Set(roots.map((r) => path.resolve(r))));
219
- for (const rootDir of uniqueRoots) {
220
- for (const fileName of candidates) {
221
- const fullPath = path.join(rootDir, fileName);
222
- try {
223
- if (!fs.existsSync(fullPath)) continue;
224
- const raw = fs.readFileSync(fullPath, 'utf-8');
225
- const parsedTheme = parseTailwindConfigSource(raw);
226
- if (Object.keys(parsedTheme).length > 0) {
227
- return parsedTheme;
228
- }
229
- } catch {
230
- // Ignore unreadable tailwind config files
231
- }
232
- }
233
- }
234
- return {};
235
- }
236
-
237
- const projectTailwindTheme = loadProjectTailwindTheme([
238
- targetProjectRoot,
239
- rawTargetRoot,
240
- workspaceRoot,
241
- ]);
242
-
243
- const allowedFsRoots = Array.from(
244
- new Set([
245
- __dirname,
246
- safeRealpath(__dirname),
247
- workspaceRoot,
248
- safeRealpath(workspaceRoot),
249
- rawTargetRoot,
250
- safeRealpath(rawTargetRoot),
251
- targetProjectRoot,
252
- safeRealpath(targetProjectRoot),
253
- ])
254
- );
255
-
256
- export default defineConfig({
257
- plugins: [
258
- {
259
- name: 'vite-zelune-process-env-shim',
260
- transformIndexHtml(html) {
261
- const serializedEnv = JSON.stringify(publicProjectEnv);
262
- const serializedTailwindTheme = JSON.stringify(projectTailwindTheme);
263
- const envScript = `<script>window.__ZELUNE_TAILWIND_THEME__ = ${serializedTailwindTheme}; window.__ZELUNE_PUBLIC_ENV__ = ${serializedEnv};</script>`;
264
- return html.replace('<head>', `<head>\n ${envScript}`);
265
- },
266
- async closeBundle() {
267
- await build({
268
- configFile: false,
269
- css: { postcss: {} },
270
- logLevel: 'silent',
271
- build: {
272
- ssr: path.resolve(__dirname, 'mcp/server.ts'),
273
- outDir: path.resolve(__dirname, 'mcp'),
274
- emptyOutDir: false,
275
- minify: false,
276
- rollupOptions: {
277
- external: [/^node:/, /^@babel\//],
278
- output: {
279
- format: 'es',
280
- entryFileNames: 'server.mjs',
281
- },
282
- },
283
- },
284
- });
285
- },
286
- },
287
- viteReactNativeFallbackPlugin(targetProjectRoot, mockNavShimPath, workspaceRoot),
288
- viteVirtualScreensPlugin(targetProjectRoot),
289
- viteRnSourceInject(targetProjectRoot),
290
- viteCanvasApiMiddleware(targetProjectRoot),
291
- ],
292
- optimizeDeps: {
293
- noDiscovery: true,
294
- include: [
295
- 'react',
296
- 'react/jsx-runtime',
297
- 'react/jsx-dev-runtime',
298
- 'react-dom',
299
- 'react-dom/client',
300
- 'lucide-react',
301
- ],
302
- },
303
- esbuild: {
304
- // Ensure .tsx/.ts/.jsx/.js files (including RN .js files with JSX) are transpiled cleanly
305
- jsx: 'automatic',
306
- include: /\.(tsx|ts|jsx|js)$/,
307
- exclude: [],
308
- loader: 'tsx',
309
- },
310
- resolve: {
311
- dedupe: ['react', 'react-dom'],
312
- alias: {
313
- react: resolvedReactDir,
314
- 'react-dom': resolvedReactDomDir,
315
- 'react-native': reactNativeShimPath,
316
- 'react-native-web': reactNativeShimPath,
317
- 'lucide-react': resolvedLucideDir,
318
- },
319
- extensions: ['.web.tsx', '.web.ts', '.web.js', '.tsx', '.ts', '.jsx', '.js'],
320
- },
321
- define: {
322
- __DEV__: JSON.stringify(true),
323
- global: 'window',
324
- },
325
- css: {
326
- postcss: {},
327
- },
328
- server: {
329
- host: '127.0.0.1',
330
- port: 5173,
331
- strictPort: false,
332
- cors: false,
333
- allowedHosts: ['127.0.0.1', 'localhost', '::1'],
334
- fs: {
335
- strict: false,
336
- allow: allowedFsRoots,
337
- },
338
- },
339
- });