elit 3.0.1 → 3.0.3

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 (87) hide show
  1. package/dist/build.d.ts +4 -12
  2. package/dist/build.d.ts.map +1 -0
  3. package/dist/chokidar.d.ts +7 -9
  4. package/dist/chokidar.d.ts.map +1 -0
  5. package/dist/cli.d.ts +6 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +250 -21
  8. package/dist/config.d.ts +29 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/dom.d.ts +7 -14
  11. package/dist/dom.d.ts.map +1 -0
  12. package/dist/el.d.ts +19 -191
  13. package/dist/el.d.ts.map +1 -0
  14. package/dist/fs.d.ts +35 -35
  15. package/dist/fs.d.ts.map +1 -0
  16. package/dist/hmr.d.ts +3 -3
  17. package/dist/hmr.d.ts.map +1 -0
  18. package/dist/http.d.ts +20 -22
  19. package/dist/http.d.ts.map +1 -0
  20. package/dist/https.d.ts +12 -15
  21. package/dist/https.d.ts.map +1 -0
  22. package/dist/index.d.ts +10 -629
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/mime-types.d.ts +9 -9
  25. package/dist/mime-types.d.ts.map +1 -0
  26. package/dist/path.d.ts +22 -19
  27. package/dist/path.d.ts.map +1 -0
  28. package/dist/router.d.ts +10 -17
  29. package/dist/router.d.ts.map +1 -0
  30. package/dist/runtime.d.ts +5 -6
  31. package/dist/runtime.d.ts.map +1 -0
  32. package/dist/server.d.ts +109 -7
  33. package/dist/server.d.ts.map +1 -0
  34. package/dist/server.js +712 -137
  35. package/dist/server.mjs +711 -137
  36. package/dist/state.d.ts +21 -27
  37. package/dist/state.d.ts.map +1 -0
  38. package/dist/style.d.ts +14 -55
  39. package/dist/style.d.ts.map +1 -0
  40. package/dist/types.d.ts +26 -240
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/ws.d.ts +14 -17
  43. package/dist/ws.d.ts.map +1 -0
  44. package/dist/wss.d.ts +16 -16
  45. package/dist/wss.d.ts.map +1 -0
  46. package/package.json +3 -2
  47. package/src/build.ts +337 -0
  48. package/src/chokidar.ts +401 -0
  49. package/src/cli.ts +638 -0
  50. package/src/config.ts +205 -0
  51. package/src/dom.ts +817 -0
  52. package/src/el.ts +164 -0
  53. package/src/fs.ts +727 -0
  54. package/src/hmr.ts +137 -0
  55. package/src/http.ts +775 -0
  56. package/src/https.ts +411 -0
  57. package/src/index.ts +14 -0
  58. package/src/mime-types.ts +222 -0
  59. package/src/path.ts +493 -0
  60. package/src/router.ts +237 -0
  61. package/src/runtime.ts +97 -0
  62. package/src/server.ts +1593 -0
  63. package/src/state.ts +468 -0
  64. package/src/style.ts +524 -0
  65. package/{dist/types-Du6kfwTm.d.ts → src/types.ts} +58 -141
  66. package/src/ws.ts +506 -0
  67. package/src/wss.ts +241 -0
  68. package/dist/build.d.mts +0 -20
  69. package/dist/chokidar.d.mts +0 -134
  70. package/dist/dom.d.mts +0 -87
  71. package/dist/el.d.mts +0 -207
  72. package/dist/fs.d.mts +0 -255
  73. package/dist/hmr.d.mts +0 -38
  74. package/dist/http.d.mts +0 -163
  75. package/dist/https.d.mts +0 -108
  76. package/dist/index.d.mts +0 -629
  77. package/dist/mime-types.d.mts +0 -48
  78. package/dist/path.d.mts +0 -163
  79. package/dist/router.d.mts +0 -47
  80. package/dist/runtime.d.mts +0 -97
  81. package/dist/server.d.mts +0 -7
  82. package/dist/state.d.mts +0 -111
  83. package/dist/style.d.mts +0 -159
  84. package/dist/types-C0nGi6MX.d.mts +0 -346
  85. package/dist/types.d.mts +0 -452
  86. package/dist/ws.d.mts +0 -195
  87. package/dist/wss.d.mts +0 -108
package/dist/build.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- import { B as BuildOptions, j as BuildResult } from './types-Du6kfwTm.js';
2
- import './http.js';
3
- import 'node:events';
4
- import './ws.js';
5
- import 'events';
6
- import 'http';
7
- import 'ws';
8
-
9
1
  /**
10
2
  * Build module for bundling applications
11
3
  * Pure implementation with cross-runtime support
@@ -14,7 +6,7 @@ import 'ws';
14
6
  * - Bun: uses Bun.build
15
7
  * - Deno: uses Deno.emit
16
8
  */
17
-
18
- declare function build(options: BuildOptions): Promise<BuildResult>;
19
-
20
- export { BuildOptions, BuildResult, build };
9
+ import type { BuildOptions, BuildResult } from './types';
10
+ export declare function build(options: BuildOptions): Promise<BuildResult>;
11
+ export type { BuildOptions, BuildResult } from './types';
12
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA2EzD,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA+OvE;AAUD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -1,5 +1,3 @@
1
- import { EventEmitter } from 'events';
2
-
3
1
  /**
4
2
  * File watcher module with unified API across runtimes
5
3
  * Pure implementation without external dependencies
@@ -8,11 +6,11 @@ import { EventEmitter } from 'events';
8
6
  * - Bun: uses native fs.watch with enhancements
9
7
  * - Deno: uses Deno.watchFs
10
8
  */
11
-
9
+ import { EventEmitter } from 'events';
12
10
  /**
13
11
  * Watch options
14
12
  */
15
- interface WatchOptions {
13
+ export interface WatchOptions {
16
14
  /**
17
15
  * Indicates whether the process should continue to run as long as files are being watched.
18
16
  * If set to false, the process will continue running even if the watcher is closed.
@@ -84,7 +82,7 @@ interface WatchOptions {
84
82
  /**
85
83
  * FSWatcher class - Compatible with chokidar
86
84
  */
87
- declare class FSWatcher extends EventEmitter {
85
+ export declare class FSWatcher extends EventEmitter {
88
86
  private _watcher;
89
87
  private _closed;
90
88
  private _watched;
@@ -117,11 +115,11 @@ declare class FSWatcher extends EventEmitter {
117
115
  /**
118
116
  * Watch files and directories
119
117
  */
120
- declare function watch(paths: string | string[], options?: WatchOptions): FSWatcher;
118
+ export declare function watch(paths: string | string[], options?: WatchOptions): FSWatcher;
121
119
  /**
122
120
  * Get current runtime
123
121
  */
124
- declare function getRuntime(): 'node' | 'bun' | 'deno';
122
+ export declare function getRuntime(): 'node' | 'bun' | 'deno';
125
123
  /**
126
124
  * Default export
127
125
  */
@@ -130,5 +128,5 @@ declare const _default: {
130
128
  FSWatcher: typeof FSWatcher;
131
129
  getRuntime: typeof getRuntime;
132
130
  };
133
-
134
- export { FSWatcher, type WatchOptions, _default as default, getRuntime, watch };
131
+ export default _default;
132
+ //# sourceMappingURL=chokidar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chokidar.d.ts","sourceRoot":"","sources":["../src/chokidar.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAyEtC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAExD;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG;QAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B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ceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG"}
package/dist/cli.js CHANGED
@@ -1412,7 +1412,7 @@ var require_package = __commonJS({
1412
1412
  "package.json"(exports2, module2) {
1413
1413
  module2.exports = {
1414
1414
  name: "elit",
1415
- version: "3.0.1",
1415
+ version: "3.0.3",
1416
1416
  description: "Optimized lightweight library for creating DOM elements with reactive state",
1417
1417
  main: "dist/index.js",
1418
1418
  module: "dist/index.mjs",
@@ -1513,7 +1513,7 @@ var require_package = __commonJS({
1513
1513
  }
1514
1514
  },
1515
1515
  scripts: {
1516
- build: "tsup",
1516
+ build: "tsup && tsc --emitDeclarationOnly",
1517
1517
  dev: "tsup --watch",
1518
1518
  typecheck: "tsc --noEmit",
1519
1519
  benchmark: "node benchmark/server-benchmark.js",
@@ -1574,6 +1574,7 @@ var require_package = __commonJS({
1574
1574
  },
1575
1575
  files: [
1576
1576
  "dist",
1577
+ "src",
1577
1578
  "README.md",
1578
1579
  "LICENSE"
1579
1580
  ]
@@ -3027,10 +3028,23 @@ var sendError = (res, code, msg) => {
3027
3028
  var send404 = (res, msg = "Not Found") => sendError(res, 404, msg);
3028
3029
  var send403 = (res, msg = "Forbidden") => sendError(res, 403, msg);
3029
3030
  var send500 = (res, msg = "Internal Server Error") => sendError(res, 500, msg);
3030
- var createElitImportMap = (basePath = "", mode = "dev") => {
3031
- const srcPath = mode === "dev" ? basePath ? `${basePath}/node_modules/elit/src` : "/node_modules/elit/src" : basePath ? `${basePath}/dist` : "/dist";
3031
+ var createElitImportMap = async (rootDir, basePath = "", mode = "dev") => {
3032
+ const srcPath = mode === "dev" ? basePath ? `${basePath}/node_modules/elit/src` : "/node_modules/elit/src" : basePath ? `${basePath}/node_modules/elit/dist` : "/node_modules/elit/dist";
3032
3033
  const fileExt = mode === "dev" ? ".ts" : ".mjs";
3033
- return `<script type="importmap">{"imports":{"elit":"${srcPath}/index${fileExt}","elit/":"${srcPath}/","elit/dom":"${srcPath}/dom${fileExt}","elit/state":"${srcPath}/state${fileExt}","elit/style":"${srcPath}/style${fileExt}","elit/el":"${srcPath}/el${fileExt}","elit/router":"${srcPath}/router${fileExt}","elit/hmr":"${srcPath}/hmr${fileExt}","elit/types":"${srcPath}/types${fileExt}"}}</script>`;
3034
+ const elitImports = {
3035
+ "elit": `${srcPath}/index${fileExt}`,
3036
+ "elit/": `${srcPath}/`,
3037
+ "elit/dom": `${srcPath}/dom${fileExt}`,
3038
+ "elit/state": `${srcPath}/state${fileExt}`,
3039
+ "elit/style": `${srcPath}/style${fileExt}`,
3040
+ "elit/el": `${srcPath}/el${fileExt}`,
3041
+ "elit/router": `${srcPath}/router${fileExt}`,
3042
+ "elit/hmr": `${srcPath}/hmr${fileExt}`,
3043
+ "elit/types": `${srcPath}/types${fileExt}`
3044
+ };
3045
+ const externalImports = await generateExternalImportMaps(rootDir, basePath);
3046
+ const allImports = { ...externalImports, ...elitImports };
3047
+ return `<script type="importmap">${JSON.stringify({ imports: allImports }, null, 2)}</script>`;
3034
3048
  };
3035
3049
  var createHMRScript = (port, wsPath) => `<script>(function(){let ws;let retries=0;let maxRetries=5;function connect(){ws=new WebSocket('ws://'+window.location.hostname+':${port}${wsPath}');ws.onopen=()=>{console.log('[Elit HMR] Connected');retries=0};ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{if(retries<maxRetries){retries++;setTimeout(connect,1000*retries)}else if(retries===maxRetries){console.log('[Elit HMR] Connection closed. Start dev server to reconnect.')}};ws.onerror=()=>{ws.close()}}connect()})();</script>`;
3036
3050
  var rewriteRelativePaths = (html, basePath) => {
@@ -3058,6 +3072,220 @@ async function findSpecialDir(startDir, targetDir) {
3058
3072
  }
3059
3073
  return null;
3060
3074
  }
3075
+ var importMapCache = /* @__PURE__ */ new Map();
3076
+ async function generateExternalImportMaps(rootDir, basePath = "") {
3077
+ const cacheKey = `${rootDir}:${basePath}`;
3078
+ if (importMapCache.has(cacheKey)) {
3079
+ return importMapCache.get(cacheKey);
3080
+ }
3081
+ const importMap = {};
3082
+ const nodeModulesPath = await findNodeModules(rootDir);
3083
+ if (!nodeModulesPath) {
3084
+ importMapCache.set(cacheKey, importMap);
3085
+ return importMap;
3086
+ }
3087
+ try {
3088
+ const { readdir: readdir2 } = await Promise.resolve().then(() => (init_fs(), fs_exports));
3089
+ const packages = await readdir2(nodeModulesPath);
3090
+ for (const pkgEntry of packages) {
3091
+ const pkg = typeof pkgEntry === "string" ? pkgEntry : pkgEntry.name;
3092
+ if (pkg.startsWith(".")) continue;
3093
+ if (pkg.startsWith("@")) {
3094
+ try {
3095
+ const scopedPackages = await readdir2(join(nodeModulesPath, pkg));
3096
+ for (const scopedEntry of scopedPackages) {
3097
+ const scopedPkg = typeof scopedEntry === "string" ? scopedEntry : scopedEntry.name;
3098
+ const fullPkgName = `${pkg}/${scopedPkg}`;
3099
+ await processPackage(nodeModulesPath, fullPkgName, importMap, basePath);
3100
+ }
3101
+ } catch {
3102
+ }
3103
+ } else {
3104
+ await processPackage(nodeModulesPath, pkg, importMap, basePath);
3105
+ }
3106
+ }
3107
+ } catch (error) {
3108
+ console.error("[Import Maps] Error scanning node_modules:", error);
3109
+ }
3110
+ importMapCache.set(cacheKey, importMap);
3111
+ return importMap;
3112
+ }
3113
+ async function findNodeModules(startDir) {
3114
+ const foundDir = await findSpecialDir(startDir, "node_modules");
3115
+ return foundDir ? join(foundDir, "node_modules") : null;
3116
+ }
3117
+ function isBrowserCompatible(pkgName, pkgJson) {
3118
+ const buildTools = [
3119
+ "typescript",
3120
+ "esbuild",
3121
+ "@esbuild/",
3122
+ "tsx",
3123
+ "tsup",
3124
+ "rollup",
3125
+ "vite",
3126
+ "webpack",
3127
+ "parcel",
3128
+ "terser",
3129
+ "uglify",
3130
+ "babel",
3131
+ "@babel/",
3132
+ "postcss",
3133
+ "autoprefixer",
3134
+ "cssnano",
3135
+ "sass",
3136
+ "less",
3137
+ "stylus"
3138
+ ];
3139
+ const nodeOnly = [
3140
+ "node-",
3141
+ "@node-",
3142
+ "fsevents",
3143
+ "chokidar",
3144
+ "express",
3145
+ "koa",
3146
+ "fastify",
3147
+ "nest",
3148
+ "commander",
3149
+ "yargs",
3150
+ "inquirer",
3151
+ "chalk",
3152
+ "ora",
3153
+ "nodemon",
3154
+ "pm2",
3155
+ "dotenv"
3156
+ ];
3157
+ const testingTools = [
3158
+ "jest",
3159
+ "vitest",
3160
+ "mocha",
3161
+ "chai",
3162
+ "jasmine",
3163
+ "@jest/",
3164
+ "@testing-library/",
3165
+ "@vitest/",
3166
+ "playwright",
3167
+ "puppeteer",
3168
+ "cypress"
3169
+ ];
3170
+ const linters = [
3171
+ "eslint",
3172
+ "@eslint/",
3173
+ "prettier",
3174
+ "tslint",
3175
+ "stylelint",
3176
+ "commitlint"
3177
+ ];
3178
+ const typeDefinitions = [
3179
+ "@types/",
3180
+ "@typescript-eslint/"
3181
+ ];
3182
+ const utilities = [
3183
+ "get-tsconfig",
3184
+ "resolve-pkg-maps",
3185
+ "pkg-types",
3186
+ "fast-glob",
3187
+ "globby",
3188
+ "micromatch",
3189
+ "execa",
3190
+ "cross-spawn",
3191
+ "shelljs"
3192
+ ];
3193
+ const skipPatterns = [
3194
+ ...buildTools,
3195
+ ...nodeOnly,
3196
+ ...testingTools,
3197
+ ...linters,
3198
+ ...typeDefinitions,
3199
+ ...utilities
3200
+ ];
3201
+ if (skipPatterns.some((pattern) => pkgName.startsWith(pattern))) {
3202
+ return false;
3203
+ }
3204
+ if (pkgName === "lodash") {
3205
+ return false;
3206
+ }
3207
+ if (pkgJson.browser || pkgJson.module) {
3208
+ return true;
3209
+ }
3210
+ if (pkgJson.exports) {
3211
+ const exportsStr = JSON.stringify(pkgJson.exports);
3212
+ if (exportsStr.includes('"import"') || exportsStr.includes('"browser"')) {
3213
+ return true;
3214
+ }
3215
+ }
3216
+ if (pkgJson.type === "commonjs" && !pkgJson.module && !pkgJson.browser) {
3217
+ return false;
3218
+ }
3219
+ return !!(pkgJson.exports || pkgJson.type === "module" || pkgJson.module);
3220
+ }
3221
+ async function processPackage(nodeModulesPath, pkgName, importMap, basePath) {
3222
+ const pkgPath = join(nodeModulesPath, pkgName);
3223
+ const pkgJsonPath = join(pkgPath, "package.json");
3224
+ try {
3225
+ const pkgJsonContent = await readFile(pkgJsonPath);
3226
+ const pkgJson = JSON.parse(pkgJsonContent.toString());
3227
+ if (!isBrowserCompatible(pkgName, pkgJson)) {
3228
+ return;
3229
+ }
3230
+ const baseUrl = basePath ? `${basePath}/node_modules/${pkgName}` : `/node_modules/${pkgName}`;
3231
+ if (pkgJson.exports) {
3232
+ processExportsField(pkgName, pkgJson.exports, baseUrl, importMap);
3233
+ } else {
3234
+ const entryPoint = pkgJson.browser || pkgJson.module || pkgJson.main || "index.js";
3235
+ importMap[pkgName] = `${baseUrl}/${entryPoint}`;
3236
+ importMap[`${pkgName}/`] = `${baseUrl}/`;
3237
+ }
3238
+ } catch {
3239
+ }
3240
+ }
3241
+ function processExportsField(pkgName, exports2, baseUrl, importMap) {
3242
+ if (typeof exports2 === "string") {
3243
+ importMap[pkgName] = `${baseUrl}/${exports2}`;
3244
+ importMap[`${pkgName}/`] = `${baseUrl}/`;
3245
+ return;
3246
+ }
3247
+ if (typeof exports2 === "object" && exports2 !== null) {
3248
+ if ("." in exports2) {
3249
+ const dotExport = exports2["."];
3250
+ const resolved = resolveExport(dotExport);
3251
+ if (resolved) {
3252
+ importMap[pkgName] = `${baseUrl}/${resolved}`;
3253
+ }
3254
+ } else if ("import" in exports2) {
3255
+ const resolved = resolveExport(exports2);
3256
+ if (resolved) {
3257
+ importMap[pkgName] = `${baseUrl}/${resolved}`;
3258
+ }
3259
+ }
3260
+ for (const [key, value] of Object.entries(exports2)) {
3261
+ if (key === "." || key === "import" || key === "require" || key === "types" || key === "default") {
3262
+ continue;
3263
+ }
3264
+ const resolved = resolveExport(value);
3265
+ if (resolved) {
3266
+ const cleanKey = key.startsWith("./") ? key.slice(2) : key;
3267
+ const importName = cleanKey ? `${pkgName}/${cleanKey}` : pkgName;
3268
+ importMap[importName] = `${baseUrl}/${resolved}`;
3269
+ }
3270
+ }
3271
+ importMap[`${pkgName}/`] = `${baseUrl}/`;
3272
+ }
3273
+ }
3274
+ function resolveExport(exportValue) {
3275
+ if (typeof exportValue === "string") {
3276
+ return exportValue.startsWith("./") ? exportValue.slice(2) : exportValue;
3277
+ }
3278
+ if (typeof exportValue === "object" && exportValue !== null) {
3279
+ const resolved = exportValue.import || exportValue.browser || exportValue.default || exportValue.require;
3280
+ if (typeof resolved === "object" && resolved !== null) {
3281
+ return resolveExport(resolved);
3282
+ }
3283
+ if (typeof resolved === "string") {
3284
+ return resolved.startsWith("./") ? resolved.slice(2) : resolved;
3285
+ }
3286
+ }
3287
+ return null;
3288
+ }
3061
3289
  function rewritePath(path, pathRewrite) {
3062
3290
  if (!pathRewrite) return path;
3063
3291
  for (const [from, to] of Object.entries(pathRewrite)) {
@@ -3306,7 +3534,7 @@ function createDevServer(options) {
3306
3534
  }
3307
3535
  let filePath;
3308
3536
  if (url === "/" && matchedClient.ssr && !matchedClient.index) {
3309
- return serveSSR(res, matchedClient);
3537
+ return await serveSSR(res, matchedClient);
3310
3538
  } else {
3311
3539
  filePath = url === "/" ? matchedClient.index || "/index.html" : url;
3312
3540
  }
@@ -3388,7 +3616,7 @@ function createDevServer(options) {
3388
3616
  if (!resolvedPath) {
3389
3617
  if (!res.headersSent) {
3390
3618
  if (filePath === "/index.html" && matchedClient.ssr) {
3391
- return serveSSR(res, matchedClient);
3619
+ return await serveSSR(res, matchedClient);
3392
3620
  }
3393
3621
  if (config.logging) console.log(`[404] ${filePath}`);
3394
3622
  return send404(res, "404 Not Found");
@@ -3412,7 +3640,7 @@ function createDevServer(options) {
3412
3640
  } catch {
3413
3641
  if (config.logging) console.log(`[DEBUG] No index file found in directory`);
3414
3642
  if (matchedClient.ssr) {
3415
- return serveSSR(res, matchedClient);
3643
+ return await serveSSR(res, matchedClient);
3416
3644
  }
3417
3645
  return send404(res, "404 Not Found");
3418
3646
  }
@@ -3432,12 +3660,12 @@ function createDevServer(options) {
3432
3660
  return send403(res, "403 Forbidden");
3433
3661
  }
3434
3662
  await stat(indexPath);
3435
- return serveFile(indexPath, res, matchedClient);
3663
+ return serveFile(indexPath, res, matchedClient, isDistRequest || isNodeModulesRequest);
3436
3664
  } catch {
3437
3665
  return send404(res, "404 Not Found");
3438
3666
  }
3439
3667
  }
3440
- await serveFile(fullPath, res, matchedClient);
3668
+ await serveFile(fullPath, res, matchedClient, isDistRequest || isNodeModulesRequest);
3441
3669
  } catch (error) {
3442
3670
  if (!res.headersSent) {
3443
3671
  if (config.logging) console.log(`[404] ${filePath}`);
@@ -3445,16 +3673,12 @@ function createDevServer(options) {
3445
3673
  }
3446
3674
  }
3447
3675
  });
3448
- async function serveFile(filePath, res, client) {
3676
+ async function serveFile(filePath, res, client, isNodeModulesOrDist = false) {
3449
3677
  try {
3450
3678
  const rootDir = await realpath(resolve(client.root));
3451
3679
  const unresolvedPath = resolve(filePath);
3452
- const isNodeModules = filePath.includes("/node_modules/") || filePath.includes("\\node_modules\\");
3453
- const isDist = filePath.includes("/dist/") || filePath.includes("\\dist\\");
3454
- const projectRoot = await realpath(resolve(client.root, ".."));
3455
- const isInProjectRoot = unresolvedPath.startsWith(projectRoot + sep) || unresolvedPath === projectRoot;
3456
- if (!unresolvedPath.startsWith(rootDir + sep) && unresolvedPath !== rootDir && !isInProjectRoot) {
3457
- if (!isNodeModules && !isDist) {
3680
+ if (!isNodeModulesOrDist) {
3681
+ if (!unresolvedPath.startsWith(rootDir + sep) && unresolvedPath !== rootDir) {
3458
3682
  if (config.logging) console.log(`[403] Attempted to serve file outside allowed directories: ${filePath}`);
3459
3683
  return send403(res, "403 Forbidden");
3460
3684
  }
@@ -3462,9 +3686,14 @@ function createDevServer(options) {
3462
3686
  let resolvedPath;
3463
3687
  try {
3464
3688
  resolvedPath = await realpath(unresolvedPath);
3689
+ if (isNodeModulesOrDist && resolvedPath) {
3690
+ if (config.logging && !resolvedPath.startsWith(rootDir + sep)) {
3691
+ console.log(`[DEBUG] Serving symlinked file: ${resolvedPath}`);
3692
+ }
3693
+ }
3465
3694
  } catch {
3466
3695
  if (filePath.endsWith("index.html") && client.ssr) {
3467
- return serveSSR(res, client);
3696
+ return await serveSSR(res, client);
3468
3697
  }
3469
3698
  return send404(res, "404 Not Found");
3470
3699
  }
@@ -3568,7 +3797,7 @@ ${error}`);
3568
3797
  }
3569
3798
  }
3570
3799
  }
3571
- const elitImportMap = createElitImportMap(basePath, client.mode);
3800
+ const elitImportMap = await createElitImportMap(client.root, basePath, client.mode);
3572
3801
  const headInjection = ssrStyles ? `${ssrStyles}
3573
3802
  ${elitImportMap}` : elitImportMap;
3574
3803
  html = html.includes("</head>") ? html.replace("</head>", `${headInjection}</head>`) : html;
@@ -3598,7 +3827,7 @@ ${elitImportMap}` : elitImportMap;
3598
3827
  send500(res, "500 Internal Server Error");
3599
3828
  }
3600
3829
  }
3601
- function serveSSR(res, client) {
3830
+ async function serveSSR(res, client) {
3602
3831
  try {
3603
3832
  if (!client.ssr) {
3604
3833
  return send500(res, "SSR function not configured");
@@ -3620,7 +3849,7 @@ ${elitImportMap}` : elitImportMap;
3620
3849
  const basePath = normalizeBasePath(client.basePath);
3621
3850
  html = rewriteRelativePaths(html, basePath);
3622
3851
  const hmrScript = createHMRScript(config.port, basePath);
3623
- const elitImportMap = createElitImportMap(basePath, client.mode);
3852
+ const elitImportMap = await createElitImportMap(client.root, basePath, client.mode);
3624
3853
  html = html.includes("</head>") ? html.replace("</head>", `${elitImportMap}</head>`) : html;
3625
3854
  html = html.includes("</body>") ? html.replace("</body>", `${hmrScript}</body>`) : html + hmrScript;
3626
3855
  res.writeHead(200, { "Content-Type": "text/html", "Cache-Control": "no-cache, no-store, must-revalidate" });
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Config loader for elit.config.{ts,js,json}
3
+ */
4
+ import type { DevServerOptions, BuildOptions, PreviewOptions } from './types';
5
+ export interface ElitConfig {
6
+ /** Development server configuration */
7
+ dev?: DevServerOptions;
8
+ /** Build configuration - supports single build or multiple builds */
9
+ build?: BuildOptions | BuildOptions[];
10
+ /** Preview server configuration */
11
+ preview?: PreviewOptions;
12
+ }
13
+ /**
14
+ * Helper function for type-safe config definition
15
+ */
16
+ export declare function defineConfig(config: ElitConfig): ElitConfig;
17
+ /**
18
+ * Load environment variables from .env files
19
+ */
20
+ export declare function loadEnv(mode?: string, cwd?: string): Record<string, string>;
21
+ /**
22
+ * Load elit config from current directory
23
+ */
24
+ export declare function loadConfig(cwd?: string): Promise<ElitConfig | null>;
25
+ /**
26
+ * Merge CLI args with config file
27
+ */
28
+ export declare function mergeConfig<T extends Record<string, any>>(config: T | undefined, cliArgs: Partial<T>): T;
29
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA2C9E,MAAM,WAAW,UAAU;IACvB,uCAAuC;IACvC,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,qEAAqE;IACrE,KAAK,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACtC,mCAAmC;IACnC,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAE3D;AAUD;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,GAAE,MAAsB,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoCzG;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAgBxF;AAsDD;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,MAAM,EAAE,CAAC,GAAG,SAAS,EACrB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GACpB,CAAC,CAWH"}
package/dist/dom.d.ts CHANGED
@@ -1,14 +1,8 @@
1
- import { Props, Children, VNode, Child, StateOptions, State, VirtualListController, JsonNode, VNodeJson } from './types.js';
2
- import 'node:events';
3
- import 'events';
4
- import 'http';
5
- import 'ws';
6
-
7
1
  /**
8
2
  * Elit - DomNode Core Class
9
3
  */
10
-
11
- declare class DomNode {
4
+ import type { VNode, Child, Children, Props, State, StateOptions, VirtualListController, JsonNode, VNodeJson } from './types';
5
+ export declare class DomNode {
12
6
  private elementCache;
13
7
  createElement(tagName: string, props?: Props, children?: Children): VNode;
14
8
  renderToDOM(vNode: Child, parent: HTMLElement | SVGElement | DocumentFragment): void;
@@ -76,12 +70,11 @@ declare class DomNode {
76
70
  }): string;
77
71
  getElementCache(): WeakMap<Element, boolean>;
78
72
  }
79
- declare const dom: DomNode;
80
- declare const render: (rootElement: string | HTMLElement, vNode: VNode) => HTMLElement;
81
- declare const renderToString: (vNode: Child, options?: {
73
+ export declare const dom: DomNode;
74
+ export declare const render: (rootElement: string | HTMLElement, vNode: VNode) => HTMLElement;
75
+ export declare const renderToString: (vNode: Child, options?: {
82
76
  pretty?: boolean;
83
77
  indent?: number;
84
78
  }) => string;
85
- declare const mount: (rootElement: string | HTMLElement, vNode: VNode) => HTMLElement;
86
-
87
- export { DomNode, dom, mount, render, renderToString };
79
+ export declare const mount: (rootElement: string | HTMLElement, vNode: VNode) => HTMLElement;
80
+ //# sourceMappingURL=dom.d.ts.map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