elit 3.5.6 → 3.5.8
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/Cargo.toml +1 -1
- package/README.md +1 -1
- package/desktop/build.rs +83 -0
- package/desktop/icon.rs +106 -0
- package/desktop/lib.rs +2 -0
- package/desktop/main.rs +235 -0
- package/desktop/native_main.rs +128 -0
- package/desktop/native_renderer/action_widgets.rs +184 -0
- package/desktop/native_renderer/app_models.rs +171 -0
- package/desktop/native_renderer/app_runtime.rs +140 -0
- package/desktop/native_renderer/container_rendering.rs +610 -0
- package/desktop/native_renderer/content_widgets.rs +634 -0
- package/desktop/native_renderer/css_models.rs +371 -0
- package/desktop/native_renderer/embedded_surfaces.rs +414 -0
- package/desktop/native_renderer/form_controls.rs +516 -0
- package/desktop/native_renderer/interaction_dispatch.rs +89 -0
- package/desktop/native_renderer/runtime_support.rs +135 -0
- package/desktop/native_renderer/utilities.rs +495 -0
- package/desktop/native_renderer/vector_drawing.rs +491 -0
- package/desktop/native_renderer.rs +4122 -0
- package/desktop/runtime/external.rs +422 -0
- package/desktop/runtime/mod.rs +67 -0
- package/desktop/runtime/quickjs.rs +106 -0
- package/desktop/window.rs +383 -0
- package/dist/build.d.ts +1 -1
- package/dist/cli.cjs +16 -2
- package/dist/cli.mjs +16 -2
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/desktop-auto-render.cjs +2370 -0
- package/dist/desktop-auto-render.d.ts +13 -0
- package/dist/desktop-auto-render.js +2341 -0
- package/dist/desktop-auto-render.mjs +2344 -0
- package/dist/render-context.cjs +118 -0
- package/dist/render-context.d.ts +39 -0
- package/dist/render-context.js +77 -0
- package/dist/render-context.mjs +87 -0
- package/dist/{server-CNgDUgSZ.d.ts → server-FCdUqabc.d.ts} +1 -1
- package/dist/server.d.ts +1 -1
- package/package.json +26 -3
- package/dist/build.d.mts +0 -20
- package/dist/chokidar.d.mts +0 -134
- package/dist/cli.d.mts +0 -81
- package/dist/config.d.mts +0 -254
- package/dist/coverage.d.mts +0 -85
- package/dist/database.d.mts +0 -52
- package/dist/desktop.d.mts +0 -68
- package/dist/dom.d.mts +0 -87
- package/dist/el.d.mts +0 -208
- package/dist/fs.d.mts +0 -255
- package/dist/hmr.d.mts +0 -38
- package/dist/http.d.mts +0 -169
- package/dist/https.d.mts +0 -108
- package/dist/index.d.mts +0 -13
- package/dist/mime-types.d.mts +0 -48
- package/dist/native.d.mts +0 -136
- package/dist/path.d.mts +0 -163
- package/dist/router.d.mts +0 -49
- package/dist/runtime.d.mts +0 -97
- package/dist/server-D0Dp4R5z.d.mts +0 -449
- package/dist/server.d.mts +0 -7
- package/dist/state.d.mts +0 -117
- package/dist/style.d.mts +0 -232
- package/dist/test-reporter.d.mts +0 -77
- package/dist/test-runtime.d.mts +0 -122
- package/dist/test.d.mts +0 -39
- package/dist/types.d.mts +0 -586
- package/dist/universal.d.mts +0 -21
- package/dist/ws.d.mts +0 -200
- package/dist/wss.d.mts +0 -108
- package/src/build.ts +0 -362
- package/src/chokidar.ts +0 -427
- package/src/cli.ts +0 -1162
- package/src/config.ts +0 -509
- package/src/coverage.ts +0 -1479
- package/src/database.ts +0 -1410
- package/src/desktop-auto-render.ts +0 -317
- package/src/desktop-cli.ts +0 -1533
- package/src/desktop.ts +0 -99
- package/src/dev-build.ts +0 -340
- package/src/dom.ts +0 -901
- package/src/el.ts +0 -183
- package/src/fs.ts +0 -609
- package/src/hmr.ts +0 -149
- package/src/http.ts +0 -856
- package/src/https.ts +0 -411
- package/src/index.ts +0 -16
- package/src/mime-types.ts +0 -222
- package/src/mobile-cli.ts +0 -2313
- package/src/native-background.ts +0 -444
- package/src/native-border.ts +0 -343
- package/src/native-canvas.ts +0 -260
- package/src/native-cli.ts +0 -414
- package/src/native-color.ts +0 -904
- package/src/native-estimation.ts +0 -194
- package/src/native-grid.ts +0 -590
- package/src/native-interaction.ts +0 -1289
- package/src/native-layout.ts +0 -568
- package/src/native-link.ts +0 -76
- package/src/native-render-support.ts +0 -361
- package/src/native-spacing.ts +0 -231
- package/src/native-state.ts +0 -318
- package/src/native-strings.ts +0 -46
- package/src/native-transform.ts +0 -120
- package/src/native-types.ts +0 -439
- package/src/native-typography.ts +0 -254
- package/src/native-units.ts +0 -441
- package/src/native-vector.ts +0 -910
- package/src/native.ts +0 -5606
- package/src/path.ts +0 -493
- package/src/pm-cli.ts +0 -2498
- package/src/preview-build.ts +0 -294
- package/src/render-context.ts +0 -138
- package/src/router.ts +0 -260
- package/src/runtime.ts +0 -97
- package/src/server.ts +0 -2294
- package/src/state.ts +0 -556
- package/src/style.ts +0 -1790
- package/src/test-globals.d.ts +0 -184
- package/src/test-reporter.ts +0 -609
- package/src/test-runtime.ts +0 -1359
- package/src/test.ts +0 -368
- package/src/types.ts +0 -381
- package/src/universal.ts +0 -81
- package/src/wapk-cli.ts +0 -3213
- package/src/workspace-package.ts +0 -102
- package/src/ws.ts +0 -648
- package/src/wss.ts +0 -241
package/src/native-cli.ts
DELETED
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { mkdirSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { basename, dirname, extname, resolve } from 'node:path';
|
|
4
|
-
import { pathToFileURL } from 'node:url';
|
|
5
|
-
|
|
6
|
-
import { build as esbuild } from 'esbuild';
|
|
7
|
-
|
|
8
|
-
import { loadConfig } from './config';
|
|
9
|
-
import { renderAndroidCompose, renderNativeJson, renderSwiftUI, type NativePlatform } from './native';
|
|
10
|
-
import {
|
|
11
|
-
clearCapturedRenderedVNode,
|
|
12
|
-
clearDesktopRenderOptions,
|
|
13
|
-
getDesktopRenderOptions,
|
|
14
|
-
getCapturedRenderedVNode,
|
|
15
|
-
restoreRenderRuntimeTarget,
|
|
16
|
-
setRenderRuntimeTarget,
|
|
17
|
-
type DesktopRenderOptions,
|
|
18
|
-
} from './render-context';
|
|
19
|
-
import type { Child } from './types';
|
|
20
|
-
import { resolveWorkspacePackageImport } from './workspace-package';
|
|
21
|
-
|
|
22
|
-
type NativeTarget = 'android' | 'ios' | 'ir';
|
|
23
|
-
export type NativeEntryRuntimeTarget = 'mobile' | 'desktop';
|
|
24
|
-
|
|
25
|
-
export interface LoadedNativeEntryResult {
|
|
26
|
-
entry: Child;
|
|
27
|
-
desktopRenderOptions?: DesktopRenderOptions;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface NativeEntryRenderOptions {
|
|
31
|
-
entryPath: string;
|
|
32
|
-
exportName?: string;
|
|
33
|
-
includePreview?: boolean;
|
|
34
|
-
name?: string;
|
|
35
|
-
packageName?: string;
|
|
36
|
-
platform?: NativePlatform;
|
|
37
|
-
target: NativeTarget;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface NativeGenerateOptions {
|
|
41
|
-
cwd: string;
|
|
42
|
-
entryPath: string;
|
|
43
|
-
exportName?: string;
|
|
44
|
-
includePreview: boolean;
|
|
45
|
-
name: string;
|
|
46
|
-
outputPath?: string;
|
|
47
|
-
packageName?: string;
|
|
48
|
-
platform: NativePlatform;
|
|
49
|
-
target: NativeTarget;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const DEFAULT_ENTRY_EXPORTS = ['default', 'screen', 'app', 'view', 'root', 'native', 'Screen', 'App', 'View', 'Root'] as const;
|
|
53
|
-
|
|
54
|
-
export async function runNativeCommand(args: string[]): Promise<void> {
|
|
55
|
-
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
56
|
-
printNativeHelp();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const command = args[0];
|
|
61
|
-
|
|
62
|
-
switch (command) {
|
|
63
|
-
case 'generate':
|
|
64
|
-
if (args.slice(1).length === 0 || args.slice(1).includes('--help') || args.slice(1).includes('-h')) {
|
|
65
|
-
printNativeHelp();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
await generateNativeFromCli(args.slice(1));
|
|
69
|
-
return;
|
|
70
|
-
default:
|
|
71
|
-
throw new Error(`Unknown native command: ${command}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function generateNativeFromCli(args: string[]): Promise<void> {
|
|
76
|
-
const options = await parseNativeGenerateArgs(args);
|
|
77
|
-
const output = await generateNativeEntryOutput({
|
|
78
|
-
entryPath: options.entryPath,
|
|
79
|
-
exportName: options.exportName,
|
|
80
|
-
includePreview: options.includePreview,
|
|
81
|
-
name: options.name,
|
|
82
|
-
packageName: options.packageName,
|
|
83
|
-
platform: options.platform,
|
|
84
|
-
target: options.target,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (options.outputPath) {
|
|
88
|
-
mkdirSync(dirname(options.outputPath), { recursive: true });
|
|
89
|
-
writeFileSync(options.outputPath, output);
|
|
90
|
-
console.log(`[native] Generated ${options.target} output at ${options.outputPath}`);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
process.stdout.write(output);
|
|
95
|
-
if (!output.endsWith('\n')) {
|
|
96
|
-
process.stdout.write('\n');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function parseNativeGenerateArgs(args: string[]): Promise<NativeGenerateOptions> {
|
|
101
|
-
const target = parseNativeTargetArg(args[0]);
|
|
102
|
-
let cwd = process.cwd();
|
|
103
|
-
|
|
104
|
-
for (let i = 1; i < args.length; i++) {
|
|
105
|
-
if (args[i] === '--cwd') {
|
|
106
|
-
const value = args[++i];
|
|
107
|
-
if (!value) throw new Error('Missing value for --cwd');
|
|
108
|
-
cwd = resolve(value);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const config = await loadConfig(cwd);
|
|
113
|
-
const mobileConfig = config?.mobile;
|
|
114
|
-
|
|
115
|
-
const options: NativeGenerateOptions = {
|
|
116
|
-
cwd,
|
|
117
|
-
entryPath: '',
|
|
118
|
-
exportName: undefined,
|
|
119
|
-
includePreview: true,
|
|
120
|
-
name: 'GeneratedScreen',
|
|
121
|
-
outputPath: undefined,
|
|
122
|
-
packageName: target === 'android' ? mobileConfig?.appId : undefined,
|
|
123
|
-
platform: target === 'android' ? 'android' : target === 'ios' ? 'ios' : 'generic',
|
|
124
|
-
target,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
let entryValue: string | undefined;
|
|
128
|
-
|
|
129
|
-
for (let i = 1; i < args.length; i++) {
|
|
130
|
-
const arg = args[i];
|
|
131
|
-
|
|
132
|
-
if (!arg.startsWith('-')) {
|
|
133
|
-
if (entryValue) {
|
|
134
|
-
throw new Error(`Unexpected extra argument: ${arg}`);
|
|
135
|
-
}
|
|
136
|
-
entryValue = arg;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
switch (arg) {
|
|
141
|
-
case '--entry': {
|
|
142
|
-
const value = args[++i];
|
|
143
|
-
if (!value) throw new Error('Missing value for --entry');
|
|
144
|
-
entryValue = value;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case '--out': {
|
|
148
|
-
const value = args[++i];
|
|
149
|
-
if (!value) throw new Error('Missing value for --out');
|
|
150
|
-
options.outputPath = resolve(cwd, value);
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
case '--name': {
|
|
154
|
-
const value = args[++i];
|
|
155
|
-
if (!value) throw new Error('Missing value for --name');
|
|
156
|
-
options.name = value;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case '--package': {
|
|
160
|
-
const value = args[++i];
|
|
161
|
-
if (!value) throw new Error('Missing value for --package');
|
|
162
|
-
options.packageName = value;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
case '--export': {
|
|
166
|
-
const value = args[++i];
|
|
167
|
-
if (!value) throw new Error('Missing value for --export');
|
|
168
|
-
options.exportName = value;
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
case '--platform': {
|
|
172
|
-
const value = args[++i];
|
|
173
|
-
if (!value) throw new Error('Missing value for --platform');
|
|
174
|
-
options.platform = parseNativePlatformArg(value);
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
case '--cwd': {
|
|
178
|
-
i++;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
case '--preview': {
|
|
182
|
-
options.includePreview = true;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
case '--no-preview': {
|
|
186
|
-
options.includePreview = false;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
default:
|
|
190
|
-
throw new Error(`Unknown native option: ${arg}`);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (!entryValue) {
|
|
195
|
-
throw new Error('Native generation requires an entry file. Use: elit native generate android <entry>');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
options.entryPath = resolve(cwd, entryValue);
|
|
199
|
-
return options;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export async function generateNativeEntryOutput(options: NativeEntryRenderOptions): Promise<string> {
|
|
203
|
-
const entry = await loadNativeEntryValue(options.entryPath, options.exportName);
|
|
204
|
-
|
|
205
|
-
switch (options.target) {
|
|
206
|
-
case 'android':
|
|
207
|
-
return renderAndroidCompose(entry, {
|
|
208
|
-
functionName: options.name ?? 'GeneratedScreen',
|
|
209
|
-
includePreview: options.includePreview ?? true,
|
|
210
|
-
packageName: options.packageName,
|
|
211
|
-
});
|
|
212
|
-
case 'ios':
|
|
213
|
-
return renderSwiftUI(entry, {
|
|
214
|
-
includePreview: options.includePreview ?? true,
|
|
215
|
-
structName: options.name ?? 'GeneratedScreen',
|
|
216
|
-
});
|
|
217
|
-
case 'ir':
|
|
218
|
-
default:
|
|
219
|
-
return renderNativeJson(entry, { platform: options.platform ?? 'generic' });
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export async function loadNativeEntryValue(entryPath: string, exportName?: string): Promise<Child> {
|
|
224
|
-
const result = await loadNativeEntryResult(entryPath, exportName);
|
|
225
|
-
return result.entry;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export async function loadNativeEntryResult(
|
|
229
|
-
entryPath: string,
|
|
230
|
-
exportName?: string,
|
|
231
|
-
runtimeTarget: NativeEntryRuntimeTarget = 'mobile',
|
|
232
|
-
): Promise<LoadedNativeEntryResult> {
|
|
233
|
-
const tempFile = await compileNativeEntry(entryPath);
|
|
234
|
-
const previousTarget = setRenderRuntimeTarget(runtimeTarget);
|
|
235
|
-
clearCapturedRenderedVNode();
|
|
236
|
-
clearDesktopRenderOptions();
|
|
237
|
-
|
|
238
|
-
try {
|
|
239
|
-
const moduleRecord = await import(pathToFileURL(tempFile).href) as Record<string, unknown>;
|
|
240
|
-
const entry = await resolveNativeEntryExport(moduleRecord, exportName);
|
|
241
|
-
return {
|
|
242
|
-
entry,
|
|
243
|
-
...(runtimeTarget === 'desktop' ? { desktopRenderOptions: getDesktopRenderOptions() } : {}),
|
|
244
|
-
};
|
|
245
|
-
} finally {
|
|
246
|
-
restoreRenderRuntimeTarget(previousTarget);
|
|
247
|
-
clearDesktopRenderOptions();
|
|
248
|
-
safeCleanup(tempFile);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
async function compileNativeEntry(entryPath: string): Promise<string> {
|
|
253
|
-
const entryDir = dirname(entryPath);
|
|
254
|
-
const tempFile = resolve(
|
|
255
|
-
entryDir,
|
|
256
|
-
`.elit-native-${basename(entryPath, extname(entryPath))}-${randomUUID()}.mjs`,
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
const externalPackagesPlugin = {
|
|
260
|
-
name: 'external-packages',
|
|
261
|
-
setup(build: any) {
|
|
262
|
-
build.onResolve({ filter: /.*/ }, (args: { path: string; resolveDir?: string }) => {
|
|
263
|
-
const localWorkspaceImport = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
|
|
264
|
-
if (localWorkspaceImport) {
|
|
265
|
-
return { path: localWorkspaceImport };
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (isBareSpecifier(args.path)) {
|
|
269
|
-
return { path: args.path, external: true };
|
|
270
|
-
}
|
|
271
|
-
return undefined;
|
|
272
|
-
});
|
|
273
|
-
},
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
await esbuild({
|
|
277
|
-
absWorkingDir: entryDir,
|
|
278
|
-
bundle: true,
|
|
279
|
-
entryPoints: [entryPath],
|
|
280
|
-
external: ['node:*', 'bun', 'bun:*', 'deno', 'deno:*'],
|
|
281
|
-
format: 'esm',
|
|
282
|
-
logLevel: 'silent',
|
|
283
|
-
outfile: tempFile,
|
|
284
|
-
platform: 'node',
|
|
285
|
-
plugins: [externalPackagesPlugin],
|
|
286
|
-
sourcemap: false,
|
|
287
|
-
target: 'es2022',
|
|
288
|
-
write: true,
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
return tempFile;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function isBareSpecifier(specifier: string): boolean {
|
|
295
|
-
if (specifier.startsWith('./') || specifier.startsWith('../') || specifier.startsWith('/')) {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return !/^[A-Za-z]:[\\/]/.test(specifier);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export async function resolveNativeEntryExport(moduleRecord: Record<string, unknown>, exportName?: string): Promise<Child> {
|
|
303
|
-
if (exportName) {
|
|
304
|
-
if (!(exportName in moduleRecord)) {
|
|
305
|
-
throw new Error(`Export "${exportName}" was not found in the native entry module.`);
|
|
306
|
-
}
|
|
307
|
-
return resolveNativeExportValue(moduleRecord[exportName], exportName);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
for (const candidate of DEFAULT_ENTRY_EXPORTS) {
|
|
311
|
-
if (candidate in moduleRecord && moduleRecord[candidate] !== undefined) {
|
|
312
|
-
return resolveNativeExportValue(moduleRecord[candidate], candidate);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const capturedRender = getCapturedRenderedVNode();
|
|
317
|
-
if (capturedRender?.vNode) {
|
|
318
|
-
return capturedRender.vNode;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const remainingExports = Object.keys(moduleRecord).filter((key) => key !== '__esModule');
|
|
322
|
-
if (remainingExports.length === 1) {
|
|
323
|
-
const [candidate] = remainingExports;
|
|
324
|
-
return resolveNativeExportValue(moduleRecord[candidate], candidate);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
throw new Error(
|
|
328
|
-
'Native entry must export a value or zero-argument function as default, screen, app, or another named export via --export, or call render(...) so the CLI can capture the VNode.',
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export async function resolveNativeExportValue(value: unknown, exportName: string): Promise<Child> {
|
|
333
|
-
let resolved = value;
|
|
334
|
-
|
|
335
|
-
if (typeof resolved === 'function') {
|
|
336
|
-
if (resolved.length > 0) {
|
|
337
|
-
throw new Error(`Export "${exportName}" must be a native tree value or a zero-argument function.`);
|
|
338
|
-
}
|
|
339
|
-
resolved = (resolved as () => unknown)();
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (isPromiseLike(resolved)) {
|
|
343
|
-
resolved = await resolved;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (resolved == null) {
|
|
347
|
-
throw new Error(`Export "${exportName}" returned no value.`);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return resolved as Child;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function isPromiseLike(value: unknown): value is PromiseLike<unknown> {
|
|
354
|
-
return Boolean(
|
|
355
|
-
value &&
|
|
356
|
-
(typeof value === 'object' || typeof value === 'function') &&
|
|
357
|
-
'then' in value,
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function parseNativeTargetArg(value: string | undefined): NativeTarget {
|
|
362
|
-
if (value === 'android' || value === 'ios' || value === 'ir') {
|
|
363
|
-
return value;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
throw new Error(`Invalid native target: ${value ?? '(missing)'}. Expected android, ios, or ir.`);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function parseNativePlatformArg(value: string): NativePlatform {
|
|
370
|
-
if (value === 'generic' || value === 'android' || value === 'ios') {
|
|
371
|
-
return value;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
throw new Error(`Invalid native platform: ${value}. Expected generic, android, or ios.`);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function safeCleanup(filePath: string): void {
|
|
378
|
-
try {
|
|
379
|
-
unlinkSync(filePath);
|
|
380
|
-
} catch {
|
|
381
|
-
// Ignore cleanup errors for generated temp files.
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function printNativeHelp(): void {
|
|
386
|
-
console.log([
|
|
387
|
-
'Elit Native Commands',
|
|
388
|
-
'',
|
|
389
|
-
'Usage:',
|
|
390
|
-
' elit native generate android <entry> [options]',
|
|
391
|
-
' elit native generate ios <entry> [options]',
|
|
392
|
-
' elit native generate ir <entry> [options]',
|
|
393
|
-
'',
|
|
394
|
-
'Options:',
|
|
395
|
-
' --entry <file> Entry file to evaluate if not passed positionally',
|
|
396
|
-
' --out <file> Write generated output to a file instead of stdout',
|
|
397
|
-
' --name <name> Generated Compose function or SwiftUI struct name',
|
|
398
|
-
' --package <name> Kotlin package name for android output',
|
|
399
|
-
' --export <name> Specific export to read from the entry module',
|
|
400
|
-
' --platform <name> IR platform tag: generic, android, ios',
|
|
401
|
-
' --cwd <dir> Resolve config and relative paths from this directory',
|
|
402
|
-
' --preview Include preview helpers (default)',
|
|
403
|
-
' --no-preview Skip preview helpers in generated output',
|
|
404
|
-
'',
|
|
405
|
-
'Entry expectations:',
|
|
406
|
-
' The entry module should export a VNode/native tree value or a zero-argument',
|
|
407
|
-
' function that returns one. Auto-detected export names: default, screen, app, view, root.',
|
|
408
|
-
'',
|
|
409
|
-
'Examples:',
|
|
410
|
-
' elit native generate android ./src/native-screen.ts --name HomeScreen --package com.example.app',
|
|
411
|
-
' elit native generate ios ./src/native-screen.ts --out ./ios/HomeScreen.swift',
|
|
412
|
-
' elit native generate ir ./src/native-screen.ts --platform android --export screen',
|
|
413
|
-
].join('\n'));
|
|
414
|
-
}
|