elit 3.2.5 → 3.2.6

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.
@@ -180,6 +180,38 @@ interface BuildResult {
180
180
  /** Output file size in bytes */
181
181
  size: number;
182
182
  }
183
+ interface PreviewOptions {
184
+ /** Port to run the preview server on (default: 4173) */
185
+ port?: number;
186
+ /** Host to bind to (default: 'localhost') */
187
+ host?: string;
188
+ /** Domain to map (e.g., 'idevcoder.com') - redirects domain traffic to this server's port */
189
+ domain?: string;
190
+ /** Root directory to serve files from (default: dist or build.outDir) */
191
+ root?: string;
192
+ /** Base path for the application (e.g., '/app') */
193
+ basePath?: string;
194
+ /** Custom index file path (relative to root, e.g., './public/index.html') */
195
+ index?: string;
196
+ /** Array of client configurations - allows multiple clients on same port */
197
+ clients?: ClientConfig[];
198
+ /** Enable HTTPS (default: false) */
199
+ https?: boolean;
200
+ /** Open browser automatically (default: true) */
201
+ open?: boolean;
202
+ /** Enable logging (default: true) */
203
+ logging?: boolean;
204
+ /** API router for REST endpoints */
205
+ api?: Router;
206
+ /** SSR render function - returns HTML VNode or string */
207
+ ssr?: () => Child | string;
208
+ /** Proxy configuration for API requests */
209
+ proxy?: ProxyConfig[];
210
+ /** Global worker scripts (applies to all clients) */
211
+ worker?: WorkerConfig[];
212
+ /** Environment variables to inject (prefix with VITE_ for client access) */
213
+ env?: Record<string, string>;
214
+ }
183
215
 
184
216
  /**
185
217
  * Development server with HMR support
@@ -300,4 +332,4 @@ declare class StateManager {
300
332
  }
301
333
  declare function createDevServer(options: DevServerOptions): DevServer;
302
334
 
303
- export { type BuildOptions as B, type ElitRequest as E, type HttpMethod as H, type Middleware as M, type ServerRouteContext as S, type BuildResult as a, type ElitResponse as b, type ServerRouteHandler as c, ServerRouter as d, clearImportMapCache as e, cors as f, errorHandler as g, html as h, bodyLimit as i, json as j, cacheControl as k, logger as l, compress as m, security as n, createProxyHandler as o, type StateChangeHandler as p, type SharedStateOptions as q, rateLimit as r, status as s, text as t, SharedState as u, StateManager as v, createDevServer as w };
335
+ export { type BuildOptions as B, type DevServerOptions as D, type ElitRequest as E, type HttpMethod as H, type Middleware as M, type PreviewOptions as P, type ServerRouteContext as S, type BuildResult as a, type ElitResponse as b, type ServerRouteHandler as c, ServerRouter as d, clearImportMapCache as e, cors as f, errorHandler as g, html as h, bodyLimit as i, json as j, cacheControl as k, logger as l, compress as m, security as n, createProxyHandler as o, type StateChangeHandler as p, type SharedStateOptions as q, rateLimit as r, status as s, text as t, SharedState as u, StateManager as v, createDevServer as w };
@@ -180,6 +180,38 @@ interface BuildResult {
180
180
  /** Output file size in bytes */
181
181
  size: number;
182
182
  }
183
+ interface PreviewOptions {
184
+ /** Port to run the preview server on (default: 4173) */
185
+ port?: number;
186
+ /** Host to bind to (default: 'localhost') */
187
+ host?: string;
188
+ /** Domain to map (e.g., 'idevcoder.com') - redirects domain traffic to this server's port */
189
+ domain?: string;
190
+ /** Root directory to serve files from (default: dist or build.outDir) */
191
+ root?: string;
192
+ /** Base path for the application (e.g., '/app') */
193
+ basePath?: string;
194
+ /** Custom index file path (relative to root, e.g., './public/index.html') */
195
+ index?: string;
196
+ /** Array of client configurations - allows multiple clients on same port */
197
+ clients?: ClientConfig[];
198
+ /** Enable HTTPS (default: false) */
199
+ https?: boolean;
200
+ /** Open browser automatically (default: true) */
201
+ open?: boolean;
202
+ /** Enable logging (default: true) */
203
+ logging?: boolean;
204
+ /** API router for REST endpoints */
205
+ api?: Router;
206
+ /** SSR render function - returns HTML VNode or string */
207
+ ssr?: () => Child | string;
208
+ /** Proxy configuration for API requests */
209
+ proxy?: ProxyConfig[];
210
+ /** Global worker scripts (applies to all clients) */
211
+ worker?: WorkerConfig[];
212
+ /** Environment variables to inject (prefix with VITE_ for client access) */
213
+ env?: Record<string, string>;
214
+ }
183
215
 
184
216
  /**
185
217
  * Development server with HMR support
@@ -300,4 +332,4 @@ declare class StateManager {
300
332
  }
301
333
  declare function createDevServer(options: DevServerOptions): DevServer;
302
334
 
303
- export { type BuildOptions as B, type ElitRequest as E, type HttpMethod as H, type Middleware as M, type ServerRouteContext as S, type BuildResult as a, type ElitResponse as b, type ServerRouteHandler as c, ServerRouter as d, clearImportMapCache as e, cors as f, errorHandler as g, html as h, bodyLimit as i, json as j, cacheControl as k, logger as l, compress as m, security as n, createProxyHandler as o, type StateChangeHandler as p, type SharedStateOptions as q, rateLimit as r, status as s, text as t, SharedState as u, StateManager as v, createDevServer as w };
335
+ export { type BuildOptions as B, type DevServerOptions as D, type ElitRequest as E, type HttpMethod as H, type Middleware as M, type PreviewOptions as P, type ServerRouteContext as S, type BuildResult as a, type ElitResponse as b, type ServerRouteHandler as c, ServerRouter as d, clearImportMapCache as e, cors as f, errorHandler as g, html as h, bodyLimit as i, json as j, cacheControl as k, logger as l, compress as m, security as n, createProxyHandler as o, type StateChangeHandler as p, type SharedStateOptions as q, rateLimit as r, status as s, text as t, SharedState as u, StateManager as v, createDevServer as w };
package/dist/server.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './http.mjs';
2
2
  import './ws.mjs';
3
- export { E as ElitRequest, b as ElitResponse, H as HttpMethod, M as Middleware, S as ServerRouteContext, c as ServerRouteHandler, d as ServerRouter, u as SharedState, q as SharedStateOptions, p as StateChangeHandler, v as StateManager, i as bodyLimit, k as cacheControl, e as clearImportMapCache, m as compress, f as cors, w as createDevServer, o as createProxyHandler, g as errorHandler, h as html, j as json, l as logger, r as rateLimit, n as security, s as status, t as text } from './server-SjfPJEWf.mjs';
3
+ export { E as ElitRequest, b as ElitResponse, H as HttpMethod, M as Middleware, S as ServerRouteContext, c as ServerRouteHandler, d as ServerRouter, u as SharedState, q as SharedStateOptions, p as StateChangeHandler, v as StateManager, i as bodyLimit, k as cacheControl, e as clearImportMapCache, m as compress, f as cors, w as createDevServer, o as createProxyHandler, g as errorHandler, h as html, j as json, l as logger, r as rateLimit, n as security, s as status, t as text } from './server-U0JYnJFs.mjs';
4
4
  import 'node:events';
5
5
  import 'events';
6
6
  import 'http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elit",
3
- "version": "3.2.5",
3
+ "version": "3.2.6",
4
4
  "description": "Optimized lightweight library for creating DOM elements with reactive state",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/config.ts CHANGED
@@ -144,14 +144,44 @@ async function loadConfigFile(configPath: string): Promise<ElitConfig> {
144
144
  // Load TypeScript config by transpiling it with esbuild
145
145
  try {
146
146
  const { build } = await import('esbuild');
147
- const { tmpdir } = await import('os');
148
147
  const { join, dirname } = await import('./path');
149
148
 
150
- // Create temporary output file
151
- const tempFile = join(tmpdir(), `elit-config-${Date.now()}.mjs`);
152
-
153
- // Bundle the TypeScript config with proper path resolution
149
+ // Create temporary output file in the same directory as the config
150
+ // This ensures that imports like 'elit/server' can be resolved correctly
154
151
  const configDir = dirname(configPath);
152
+ const tempFile = join(configDir, `.elit-config-${Date.now()}.mjs`);
153
+
154
+ // Custom plugin to external all dependencies
155
+ const externalAllPlugin = {
156
+ name: 'external-all',
157
+ setup(build: any) {
158
+ build.onResolve({ filter: /.*/ }, (args: any) => {
159
+ // Skip relative imports (local files)
160
+ if (args.path.startsWith('./') || args.path.startsWith('../')) {
161
+ return undefined;
162
+ }
163
+
164
+ // External everything in node_modules
165
+ if (args.path.includes('node_modules') || args.resolveDir?.includes('node_modules')) {
166
+ return { path: args.path, external: true };
167
+ }
168
+
169
+ // External known packages by exact match or prefix
170
+ const knownPackages = ['esbuild', 'elit', 'fs', 'path', 'os', 'vm', 'crypto', 'http', 'https', 'url', 'bun'];
171
+ if (knownPackages.some(pkg => args.path === pkg || args.path.startsWith(pkg + '/'))) {
172
+ return { path: args.path, external: true };
173
+ }
174
+
175
+ // External any imports from dist directory (elit package)
176
+ if (args.resolveDir?.includes('elit/dist') || args.path.includes('elit/dist')) {
177
+ return { path: args.path, external: true };
178
+ }
179
+
180
+ return undefined;
181
+ });
182
+ }
183
+ };
184
+
155
185
  await build({
156
186
  entryPoints: [configPath],
157
187
  bundle: true,
@@ -160,14 +190,12 @@ async function loadConfigFile(configPath: string): Promise<ElitConfig> {
160
190
  outfile: tempFile,
161
191
  write: true,
162
192
  target: 'es2020',
163
- // Bundle everything including elit/* so config can use elit modules
164
- // Only mark Node.js built-ins and runtime-specific packages as external
193
+ plugins: [externalAllPlugin],
194
+ // External Node.js built-ins and runtime-specific packages
165
195
  external: [
166
196
  'node:*',
167
- 'bun',
168
- 'bun:*',
169
- 'deno',
170
- 'deno:*'
197
+ 'fs', 'path', 'os', 'vm', 'crypto', 'http', 'https',
198
+ 'bun', 'bun:*', 'deno', 'deno:*'
171
199
  ],
172
200
  // Use the config directory as the working directory for resolution
173
201
  absWorkingDir: configDir,