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/desktop.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
export type DesktopRuntimeName = 'quickjs' | 'bun' | 'node' | 'deno';
|
|
2
|
-
|
|
3
|
-
export interface WindowOptions {
|
|
4
|
-
url?: string;
|
|
5
|
-
html?: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
width?: number;
|
|
8
|
-
height?: number;
|
|
9
|
-
x?: number;
|
|
10
|
-
y?: number;
|
|
11
|
-
center?: boolean;
|
|
12
|
-
maximized?: boolean;
|
|
13
|
-
resizable?: boolean;
|
|
14
|
-
decorations?: boolean;
|
|
15
|
-
transparent?: boolean;
|
|
16
|
-
always_on_top?: boolean;
|
|
17
|
-
minimizable?: boolean;
|
|
18
|
-
maximizable?: boolean;
|
|
19
|
-
closable?: boolean;
|
|
20
|
-
skip_taskbar?: boolean;
|
|
21
|
-
icon?: string;
|
|
22
|
-
devtools?: boolean;
|
|
23
|
-
proxy_port?: number;
|
|
24
|
-
proxy_pipe?: string;
|
|
25
|
-
proxy_secret?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface ServeWindowOptions extends Omit<WindowOptions, 'url'> {
|
|
29
|
-
port?: number;
|
|
30
|
-
exposePort?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface ServeWindowResultExposed {
|
|
34
|
-
port: number;
|
|
35
|
-
host: string;
|
|
36
|
-
url: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ServeWindowResultPipe {
|
|
40
|
-
pipe: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type ServeWindowResult = ServeWindowResultExposed | ServeWindowResultPipe;
|
|
44
|
-
|
|
45
|
-
type DesktopGlobals = typeof globalThis & {
|
|
46
|
-
createWindow?: (opts: WindowOptions) => void;
|
|
47
|
-
createWindowServer?: (app: (req: any, res: any) => void, opts?: ServeWindowOptions) => Promise<ServeWindowResult>;
|
|
48
|
-
windowEval?: (code: string) => void;
|
|
49
|
-
onMessage?: (handler: (msg: string) => void) => void;
|
|
50
|
-
windowMinimize?: () => void;
|
|
51
|
-
windowMaximize?: () => void;
|
|
52
|
-
windowUnmaximize?: () => void;
|
|
53
|
-
windowSetTitle?: (title: string) => void;
|
|
54
|
-
windowDrag?: () => void;
|
|
55
|
-
windowSetPosition?: (x: number, y: number) => void;
|
|
56
|
-
windowSetSize?: (w: number, h: number) => void;
|
|
57
|
-
windowSetAlwaysOnTop?: (value: boolean) => void;
|
|
58
|
-
windowQuit?: () => void;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const desktopGlobals = globalThis as DesktopGlobals;
|
|
62
|
-
|
|
63
|
-
export const createWindow = desktopGlobals.createWindow as (opts: WindowOptions) => void;
|
|
64
|
-
export const createWindowServer = desktopGlobals.createWindowServer as (
|
|
65
|
-
app: (req: any, res: any) => void,
|
|
66
|
-
opts?: ServeWindowOptions,
|
|
67
|
-
) => Promise<ServeWindowResult>;
|
|
68
|
-
export const windowEval = desktopGlobals.windowEval as (code: string) => void;
|
|
69
|
-
export const onMessage = desktopGlobals.onMessage as (handler: (msg: string) => void) => void;
|
|
70
|
-
export const windowMinimize = desktopGlobals.windowMinimize as () => void;
|
|
71
|
-
export const windowMaximize = desktopGlobals.windowMaximize as () => void;
|
|
72
|
-
export const windowUnmaximize = desktopGlobals.windowUnmaximize as () => void;
|
|
73
|
-
export const windowSetTitle = desktopGlobals.windowSetTitle as (title: string) => void;
|
|
74
|
-
export const windowDrag = desktopGlobals.windowDrag as () => void;
|
|
75
|
-
export const windowSetPosition = desktopGlobals.windowSetPosition as (x: number, y: number) => void;
|
|
76
|
-
export const windowSetSize = desktopGlobals.windowSetSize as (w: number, h: number) => void;
|
|
77
|
-
export const windowSetAlwaysOnTop = desktopGlobals.windowSetAlwaysOnTop as (value: boolean) => void;
|
|
78
|
-
export const windowQuit = desktopGlobals.windowQuit as () => void;
|
|
79
|
-
|
|
80
|
-
declare global {
|
|
81
|
-
function createWindow(opts: WindowOptions): void;
|
|
82
|
-
function windowEval(code: string): void;
|
|
83
|
-
function onMessage(handler: (msg: string) => void): void;
|
|
84
|
-
function windowMinimize(): void;
|
|
85
|
-
function windowMaximize(): void;
|
|
86
|
-
function windowUnmaximize(): void;
|
|
87
|
-
function windowSetTitle(title: string): void;
|
|
88
|
-
function windowDrag(): void;
|
|
89
|
-
function windowSetPosition(x: number, y: number): void;
|
|
90
|
-
function windowSetSize(w: number, h: number): void;
|
|
91
|
-
function windowSetAlwaysOnTop(value: boolean): void;
|
|
92
|
-
function windowQuit(): void;
|
|
93
|
-
function createWindowServer(
|
|
94
|
-
app: (req: any, res: any) => void,
|
|
95
|
-
opts?: ServeWindowOptions,
|
|
96
|
-
): Promise<ServeWindowResult>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export {};
|
package/src/dev-build.ts
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readdirSync } from './fs';
|
|
2
|
-
import { basename, dirname, extname, join, relative, resolve } from './path';
|
|
3
|
-
|
|
4
|
-
import type { DevServerOptions } from './types';
|
|
5
|
-
import {
|
|
6
|
-
createInlineConfigSource,
|
|
7
|
-
createWorkspacePackagePlugin,
|
|
8
|
-
normalizeImportPath,
|
|
9
|
-
normalizeRelativePath,
|
|
10
|
-
writeStandalonePackageJson,
|
|
11
|
-
} from './preview-build';
|
|
12
|
-
|
|
13
|
-
interface StandaloneDevClientPlan {
|
|
14
|
-
basePath: string;
|
|
15
|
-
fallbackRootRelativePath: string;
|
|
16
|
-
index?: string;
|
|
17
|
-
rootRelativePath: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface StandaloneDevBuildPlan {
|
|
21
|
-
clients?: StandaloneDevClientPlan[];
|
|
22
|
-
fallbackRootRelativePath?: string;
|
|
23
|
-
index?: string;
|
|
24
|
-
outputPath: string;
|
|
25
|
-
outputRoot: string;
|
|
26
|
-
packageJsonPath: string;
|
|
27
|
-
rootRelativePath?: string;
|
|
28
|
-
usesClientArray: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface StandaloneDevBuildOptions {
|
|
32
|
-
allBuilds?: Array<{ outDir?: string }>;
|
|
33
|
-
buildConfig?: { outDir?: string } | null;
|
|
34
|
-
configPath?: string | null;
|
|
35
|
-
cwd?: string;
|
|
36
|
-
devConfig?: DevServerOptions | null;
|
|
37
|
-
logging?: boolean;
|
|
38
|
-
outDir?: string;
|
|
39
|
-
outFile?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const defaultStandaloneDevRuntimeIgnorePatterns = ['node_modules/**', 'dist/**', 'dev-dist/**', '.git/**', 'coverage/**', '**/*.d.ts'];
|
|
43
|
-
|
|
44
|
-
function normalizeStandaloneDevRuntimeIgnorePatterns(devConfig?: DevServerOptions | null): string[] {
|
|
45
|
-
const merged = new Set<string>(defaultStandaloneDevRuntimeIgnorePatterns);
|
|
46
|
-
|
|
47
|
-
if (devConfig?.outDir) {
|
|
48
|
-
merged.add(`${normalizeRelativePath(devConfig.outDir).replace(/^\.\//, '')}/**`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (const pattern of devConfig?.ignore || []) {
|
|
52
|
-
merged.add(pattern);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [...merged];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function shouldIgnoreStandaloneDevRuntimePath(relativePath: string, isDirectory: boolean, ignorePatterns: string[]): boolean {
|
|
59
|
-
const normalizedPath = relativePath.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
60
|
-
|
|
61
|
-
if (!normalizedPath) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
for (const pattern of ignorePatterns) {
|
|
66
|
-
const normalizedPattern = pattern.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
67
|
-
|
|
68
|
-
if (normalizedPattern === '**/*.d.ts') {
|
|
69
|
-
if (!isDirectory && normalizedPath.endsWith('.d.ts')) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const directoryToken = normalizedPattern
|
|
76
|
-
.replace(/^\*\*\//, '')
|
|
77
|
-
.replace(/\/\*\*$/, '')
|
|
78
|
-
.replace(/\*.*$/, '')
|
|
79
|
-
.replace(/\/+$/, '');
|
|
80
|
-
|
|
81
|
-
if (!directoryToken) {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (normalizedPath === directoryToken || normalizedPath.startsWith(`${directoryToken}/`) || normalizedPath.includes(`/${directoryToken}/`)) {
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function rootContainsEsbuildDependentSources(rootDir: string, ignorePatterns: string[]): boolean {
|
|
94
|
-
if (!existsSync(rootDir)) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const pendingDirectories = [rootDir];
|
|
99
|
-
|
|
100
|
-
while (pendingDirectories.length > 0) {
|
|
101
|
-
const currentDirectory = pendingDirectories.pop()!;
|
|
102
|
-
const entries = readdirSync(currentDirectory, { withFileTypes: true }) as Array<{ name: string; isDirectory(): boolean; isFile(): boolean }>;
|
|
103
|
-
|
|
104
|
-
for (const entry of entries) {
|
|
105
|
-
const absolutePath = join(currentDirectory, entry.name);
|
|
106
|
-
const relativePath = normalizeRelativePath(relative(rootDir, absolutePath));
|
|
107
|
-
const isDirectory = entry.isDirectory();
|
|
108
|
-
|
|
109
|
-
if (shouldIgnoreStandaloneDevRuntimePath(relativePath, isDirectory, ignorePatterns)) {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (isDirectory) {
|
|
114
|
-
pendingDirectories.push(absolutePath);
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!entry.isFile()) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const extension = extname(entry.name).toLowerCase();
|
|
123
|
-
if (extension === '.tsx' || extension === '.jsx') {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function standaloneDevNeedsEsbuildRuntime(cwd: string, devConfig?: DevServerOptions | null): boolean {
|
|
133
|
-
const resolvedCwd = resolve(cwd || process.cwd());
|
|
134
|
-
const clientRoots = devConfig?.clients && devConfig.clients.length > 0
|
|
135
|
-
? devConfig.clients.map((client) => resolve(resolvedCwd, client.root || '.'))
|
|
136
|
-
: [resolve(resolvedCwd, devConfig?.root || '.')];
|
|
137
|
-
const ignorePatterns = normalizeStandaloneDevRuntimeIgnorePatterns(devConfig);
|
|
138
|
-
|
|
139
|
-
return clientRoots.some((clientRoot) => rootContainsEsbuildDependentSources(clientRoot, ignorePatterns));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function resolveStandaloneDevBuildPlan(options: StandaloneDevBuildOptions): StandaloneDevBuildPlan {
|
|
143
|
-
const cwd = resolve(options.cwd || process.cwd());
|
|
144
|
-
const devConfig = options.devConfig || undefined;
|
|
145
|
-
const allBuilds = options.allBuilds && options.allBuilds.length > 0
|
|
146
|
-
? options.allBuilds
|
|
147
|
-
: [options.buildConfig || {}];
|
|
148
|
-
const primaryBuild = options.buildConfig || allBuilds[0] || {};
|
|
149
|
-
const outputRoot = resolve(cwd, options.outDir || devConfig?.outDir || 'dev-dist');
|
|
150
|
-
const outputFile = options.outFile || devConfig?.outFile || 'index.js';
|
|
151
|
-
const outputPath = resolve(join(outputRoot, outputFile));
|
|
152
|
-
const bundleDir = dirname(outputPath);
|
|
153
|
-
|
|
154
|
-
if (devConfig?.clients && devConfig.clients.length > 0) {
|
|
155
|
-
const clients = devConfig.clients.map((client, index) => {
|
|
156
|
-
const buildForClient = allBuilds[index] || primaryBuild;
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
basePath: client.basePath || '',
|
|
160
|
-
fallbackRootRelativePath: normalizeRelativePath(relative(bundleDir, resolve(cwd, buildForClient.outDir || 'dist'))),
|
|
161
|
-
index: client.index,
|
|
162
|
-
rootRelativePath: normalizeRelativePath(relative(bundleDir, resolve(cwd, client.root || '.'))),
|
|
163
|
-
};
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
clients,
|
|
168
|
-
outputPath,
|
|
169
|
-
outputRoot,
|
|
170
|
-
packageJsonPath: join(outputRoot, 'package.json'),
|
|
171
|
-
usesClientArray: true,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const rootRelativePath = normalizeRelativePath(relative(bundleDir, resolve(cwd, devConfig?.root || '.')));
|
|
176
|
-
const fallbackRootRelativePath = normalizeRelativePath(relative(bundleDir, resolve(cwd, primaryBuild.outDir || 'dist')));
|
|
177
|
-
|
|
178
|
-
return {
|
|
179
|
-
fallbackRootRelativePath,
|
|
180
|
-
index: devConfig?.index,
|
|
181
|
-
outputPath,
|
|
182
|
-
outputRoot,
|
|
183
|
-
packageJsonPath: join(outputRoot, 'package.json'),
|
|
184
|
-
clients: undefined,
|
|
185
|
-
rootRelativePath,
|
|
186
|
-
usesClientArray: false,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function resolveStandaloneDevFallbackRootRelativePath(plan: StandaloneDevBuildPlan, options: StandaloneDevBuildOptions): string {
|
|
191
|
-
if (plan.fallbackRootRelativePath) {
|
|
192
|
-
return plan.fallbackRootRelativePath;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const cwd = resolve(options.cwd || process.cwd());
|
|
196
|
-
const primaryBuild = options.buildConfig || options.allBuilds?.[0] || {};
|
|
197
|
-
return normalizeRelativePath(relative(dirname(plan.outputPath), resolve(cwd, primaryBuild.outDir || 'dist')));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function createStandaloneDevFallbackRootRelativePath(options: StandaloneDevBuildOptions): string {
|
|
201
|
-
const plan = resolveStandaloneDevBuildPlan(options);
|
|
202
|
-
return resolveStandaloneDevFallbackRootRelativePath(plan, options);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function createStandaloneDevEntrySource(
|
|
206
|
-
configPath: string | null | undefined,
|
|
207
|
-
plan: StandaloneDevBuildPlan,
|
|
208
|
-
devConfig?: DevServerOptions | null,
|
|
209
|
-
buildOptions?: Pick<StandaloneDevBuildOptions, 'cwd' | 'buildConfig' | 'allBuilds'>,
|
|
210
|
-
): string {
|
|
211
|
-
const fallbackRootRelativePath = resolveStandaloneDevFallbackRootRelativePath(plan, {
|
|
212
|
-
cwd: buildOptions?.cwd,
|
|
213
|
-
buildConfig: buildOptions?.buildConfig,
|
|
214
|
-
allBuilds: buildOptions?.allBuilds,
|
|
215
|
-
});
|
|
216
|
-
const configImportBlock = configPath
|
|
217
|
-
? `import userConfigModule from ${JSON.stringify(normalizeImportPath(configPath))};\nconst resolvedConfig = userConfigModule ?? {};`
|
|
218
|
-
: 'const resolvedConfig = {} as Record<string, any>;' ;
|
|
219
|
-
const inlineConfigSource = createInlineConfigSource({
|
|
220
|
-
port: devConfig?.port,
|
|
221
|
-
host: devConfig?.host,
|
|
222
|
-
open: devConfig?.open,
|
|
223
|
-
logging: devConfig?.logging,
|
|
224
|
-
domain: devConfig?.domain,
|
|
225
|
-
env: devConfig?.env,
|
|
226
|
-
basePath: devConfig?.basePath,
|
|
227
|
-
index: devConfig?.index,
|
|
228
|
-
watch: devConfig?.watch,
|
|
229
|
-
ignore: devConfig?.ignore,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const clientArraySource = plan.clients
|
|
233
|
-
? `const runtimeClients = [
|
|
234
|
-
${plan.clients.map((client, index) => ` {
|
|
235
|
-
...(mergedConfig.clients?.[${index}] ?? {}),
|
|
236
|
-
basePath: mergedConfig.clients?.[${index}]?.basePath ?? ${JSON.stringify(client.basePath)},
|
|
237
|
-
fallbackRoot: resolve(__dirname, ${JSON.stringify(client.fallbackRootRelativePath)}),
|
|
238
|
-
index: mergedConfig.clients?.[${index}]?.index ?? ${client.index ? JSON.stringify(client.index) : 'undefined'},
|
|
239
|
-
root: resolve(__dirname, ${JSON.stringify(client.rootRelativePath)}),
|
|
240
|
-
mode: 'dev',
|
|
241
|
-
}`).join(',\n')}
|
|
242
|
-
];`
|
|
243
|
-
: '';
|
|
244
|
-
|
|
245
|
-
const rootSource = plan.usesClientArray
|
|
246
|
-
? ' clients: runtimeClients,\n'
|
|
247
|
-
: ` root: resolve(__dirname, ${JSON.stringify(plan.rootRelativePath || '.')}),\n fallbackRoot: resolve(__dirname, ${JSON.stringify(fallbackRootRelativePath)}),\n basePath: mergedConfig.basePath ?? '',\n index: mergedConfig.index ?? ${plan.index ? JSON.stringify(plan.index) : 'undefined'},\n`;
|
|
248
|
-
|
|
249
|
-
return `import { createDevServer } from 'elit/server';
|
|
250
|
-
import { resolve } from 'node:path';
|
|
251
|
-
|
|
252
|
-
${configImportBlock}
|
|
253
|
-
|
|
254
|
-
const inlineDevConfig = ${inlineConfigSource};
|
|
255
|
-
const runtimeConfig = (resolvedConfig as any).dev ?? {};
|
|
256
|
-
const mergedConfig = { ...runtimeConfig, ...inlineDevConfig };
|
|
257
|
-
${clientArraySource}
|
|
258
|
-
const options = {
|
|
259
|
-
port: mergedConfig.port || 3000,
|
|
260
|
-
host: mergedConfig.host || 'localhost',
|
|
261
|
-
open: mergedConfig.open ?? false,
|
|
262
|
-
logging: mergedConfig.logging ?? true,
|
|
263
|
-
domain: mergedConfig.domain,
|
|
264
|
-
api: mergedConfig.api,
|
|
265
|
-
ws: mergedConfig.ws,
|
|
266
|
-
https: mergedConfig.https,
|
|
267
|
-
ssr: mergedConfig.ssr,
|
|
268
|
-
proxy: mergedConfig.proxy,
|
|
269
|
-
worker: mergedConfig.worker ?? [],
|
|
270
|
-
watch: mergedConfig.watch ?? ['**/*.ts', '**/*.js', '**/*.html', '**/*.css'],
|
|
271
|
-
ignore: mergedConfig.ignore ?? ['node_modules/**', 'dist/**', '.git/**', '**/*.d.ts'],
|
|
272
|
-
env: mergedConfig.env,
|
|
273
|
-
${rootSource} mode: 'dev',
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const devServer = createDevServer(options);
|
|
277
|
-
|
|
278
|
-
const shutdown = async () => {
|
|
279
|
-
await devServer.close();
|
|
280
|
-
process.exit(0);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
process.on('SIGINT', shutdown);
|
|
284
|
-
process.on('SIGTERM', shutdown);
|
|
285
|
-
`;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export async function buildStandaloneDevServer(options: StandaloneDevBuildOptions): Promise<string> {
|
|
289
|
-
const cwd = resolve(options.cwd || process.cwd());
|
|
290
|
-
const plan = resolveStandaloneDevBuildPlan({
|
|
291
|
-
...options,
|
|
292
|
-
cwd,
|
|
293
|
-
});
|
|
294
|
-
const outputDir = dirname(plan.outputPath);
|
|
295
|
-
|
|
296
|
-
mkdirSync(outputDir, { recursive: true });
|
|
297
|
-
|
|
298
|
-
const { build, version } = await import('esbuild');
|
|
299
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin(cwd);
|
|
300
|
-
const entrySource = createStandaloneDevEntrySource(options.configPath, plan, options.devConfig, {
|
|
301
|
-
cwd,
|
|
302
|
-
buildConfig: options.buildConfig,
|
|
303
|
-
allBuilds: options.allBuilds,
|
|
304
|
-
});
|
|
305
|
-
const needsEsbuildRuntime = standaloneDevNeedsEsbuildRuntime(cwd, options.devConfig);
|
|
306
|
-
|
|
307
|
-
await build({
|
|
308
|
-
stdin: {
|
|
309
|
-
contents: entrySource,
|
|
310
|
-
loader: 'ts',
|
|
311
|
-
resolveDir: cwd,
|
|
312
|
-
sourcefile: 'elit-standalone-dev-entry.ts',
|
|
313
|
-
},
|
|
314
|
-
bundle: true,
|
|
315
|
-
outfile: plan.outputPath,
|
|
316
|
-
format: 'cjs',
|
|
317
|
-
mainFields: ['module', 'main'],
|
|
318
|
-
platform: 'node',
|
|
319
|
-
plugins: [workspacePackagePlugin],
|
|
320
|
-
external: ['esbuild', 'javascript-obfuscator', 'open'],
|
|
321
|
-
sourcemap: false,
|
|
322
|
-
target: 'es2020',
|
|
323
|
-
logLevel: options.logging === false ? 'silent' : 'info',
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
writeStandalonePackageJson(plan.packageJsonPath, basename(plan.outputPath), {
|
|
327
|
-
dependencies: needsEsbuildRuntime
|
|
328
|
-
? {
|
|
329
|
-
esbuild: typeof version === 'string' && version.length > 0 ? `^${version}` : '*',
|
|
330
|
-
}
|
|
331
|
-
: {},
|
|
332
|
-
replaceDependencies: true,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
if (options.logging !== false) {
|
|
336
|
-
console.log(` ✓ Standalone dev server → ${plan.outputPath}`);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return plan.outputPath;
|
|
340
|
-
}
|