@noego/forge 0.0.27 → 0.1.1

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.
@@ -0,0 +1,398 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import path__default from "path";
5
+ import fs__default from "fs";
6
+ import { pathToFileURL } from "url";
7
+ import yaml from "js-yaml";
8
+ import "clone-deep";
9
+ import join from "url-join";
10
+ import { p as parsePathConfig } from "./path-BqcF5dbs.js";
11
+ import pathToRegex from "path-to-regex";
12
+ class BasicComponentLoader {
13
+ constructor(basePath) {
14
+ __publicField(this, "resolvedBasePath");
15
+ this.basePath = basePath;
16
+ this.resolvedBasePath = path__default.isAbsolute(basePath) ? basePath : path__default.resolve(process.cwd(), basePath);
17
+ }
18
+ async load(componentPath) {
19
+ const component_full_path = this.getComponentFullPath(componentPath);
20
+ const module = await import(pathToFileURL(component_full_path).href);
21
+ return module;
22
+ }
23
+ getComponentFullPath(componentPath) {
24
+ return path__default.join(this.resolvedBasePath, componentPath);
25
+ }
26
+ }
27
+ class ViteComponentLoader {
28
+ constructor(basePath, vite) {
29
+ this.basePath = basePath;
30
+ this.vite = vite;
31
+ }
32
+ async load(componentPath, options = { use_base_path: true }) {
33
+ const absoluteComponentPath = this.getComponentFullPath(componentPath, options);
34
+ console.log(`[ViteComponentLoader] Loading component from path: ${absoluteComponentPath}`);
35
+ const jsPath = absoluteComponentPath.replace(/\.svelte$/, ".js");
36
+ fs__default.existsSync(jsPath);
37
+ let vitePath = path__default.relative(process.cwd(), absoluteComponentPath);
38
+ vitePath = vitePath.replace(/\\/g, "/");
39
+ if (!vitePath.startsWith("/")) {
40
+ vitePath = "/" + vitePath;
41
+ }
42
+ console.log(`[ViteComponentLoader] Resolved Vite path: ${vitePath} from componentPath: ${componentPath}`);
43
+ try {
44
+ console.log(`[ViteComponentLoader] Loading module for vitePath: ${vitePath}`);
45
+ const module = await this.vite.ssrLoadModule(vitePath);
46
+ console.log(`[ViteComponentLoader] Module loaded successfully for: ${vitePath}`);
47
+ if (!module || !module.default) {
48
+ console.error(`[ViteComponentLoader] Loaded module for ${vitePath} is invalid or missing a default export. Module content:`, module);
49
+ throw new Error(`Module ${vitePath} loaded successfully but is invalid or missing default export.`);
50
+ }
51
+ return module;
52
+ } catch (error) {
53
+ console.error(`[ViteComponentLoader] Error loading module for vitePath: ${vitePath} (derived from componentPath: ${componentPath})`, error);
54
+ try {
55
+ await fs__default.promises.access(absoluteComponentPath);
56
+ } catch (fsError) {
57
+ }
58
+ throw error;
59
+ }
60
+ }
61
+ getComponentFullPath(componentPath, options = { use_base_path: true }) {
62
+ const use_base_path = options.use_base_path || false;
63
+ if (use_base_path) {
64
+ return path__default.join(this.basePath, componentPath);
65
+ }
66
+ if (path__default.isAbsolute(componentPath)) {
67
+ return componentPath;
68
+ }
69
+ return componentPath;
70
+ }
71
+ }
72
+ class ProdComponentLoader {
73
+ constructor(base_path) {
74
+ __publicField(this, "componentMapPromise", null);
75
+ this.base_path = base_path;
76
+ }
77
+ async load(componentPath) {
78
+ const normalized = this.normalizeKey(componentPath);
79
+ try {
80
+ const map = await this.loadComponentMap();
81
+ const module2 = map[normalized];
82
+ if (module2) {
83
+ return module2;
84
+ }
85
+ } catch (error) {
86
+ console.warn(`[Forge] Failed to load component "${componentPath}" from entry manifest:`, error);
87
+ }
88
+ const component_path = this.getComponentFullPath(componentPath);
89
+ const fallbackPath = component_path.endsWith(".js") ? component_path : component_path.replace(/\.svelte$/, ".js");
90
+ const module = await import(pathToFileURL(fallbackPath).href);
91
+ return module;
92
+ }
93
+ getComponentFullPath(componentPath) {
94
+ return path__default.join(this.base_path, componentPath);
95
+ }
96
+ normalizeKey(componentPath) {
97
+ const trimmed = componentPath.replace(/^\.\//, "");
98
+ if (trimmed.endsWith(".svelte")) {
99
+ return trimmed.replace(/\.svelte$/, ".js");
100
+ }
101
+ return trimmed;
102
+ }
103
+ async loadComponentMap() {
104
+ if (!this.componentMapPromise) {
105
+ const entryPath = path__default.join(this.base_path, "entry-ssr.js");
106
+ const entryUrl = pathToFileURL(entryPath).href;
107
+ this.componentMapPromise = import(entryUrl).then((mod) => {
108
+ const source = mod.components ?? mod.default ?? {};
109
+ const normalized = {};
110
+ for (const [key, value] of Object.entries(source)) {
111
+ const cleanKey = key.replace(/^\.\//, "");
112
+ normalized[cleanKey] = value;
113
+ if (cleanKey.startsWith("ui/")) {
114
+ normalized[cleanKey.slice(3)] = value;
115
+ }
116
+ if (cleanKey.endsWith(".svelte")) {
117
+ const jsKey = cleanKey.replace(/\.svelte$/, ".js");
118
+ normalized[jsKey] = value;
119
+ }
120
+ }
121
+ return normalized;
122
+ }).catch((error) => {
123
+ this.componentMapPromise = null;
124
+ throw error;
125
+ });
126
+ }
127
+ return this.componentMapPromise;
128
+ }
129
+ }
130
+ const HTTP_METHODS = /* @__PURE__ */ new Set([
131
+ "get",
132
+ "post",
133
+ "put",
134
+ "delete",
135
+ "patch",
136
+ "head",
137
+ "options",
138
+ "trace"
139
+ ]);
140
+ function getGlobalPathsMiddleware(openapi) {
141
+ if (!openapi || !openapi.paths) {
142
+ return [];
143
+ }
144
+ const value = openapi.paths["x-middleware"];
145
+ return Array.isArray(value) ? [...value] : [];
146
+ }
147
+ function parseConfigfile(file_content) {
148
+ let config = null;
149
+ try {
150
+ config = yaml.load(file_content);
151
+ } catch (e) {
152
+ console.log(e);
153
+ }
154
+ return config;
155
+ }
156
+ function parse_modules(openapi, inheritedMiddleware = []) {
157
+ const modules_config = openapi.modules || openapi.module;
158
+ if (!modules_config) {
159
+ return;
160
+ }
161
+ const modules = Object.entries(modules_config).map(([_, module]) => {
162
+ return module;
163
+ });
164
+ const globalMiddleware = [...inheritedMiddleware, ...getGlobalPathsMiddleware(openapi)];
165
+ const modules_path = modules.map((module) => {
166
+ const basePath = module.basePath || "";
167
+ const baseLayouts = module.baseLayouts || [];
168
+ const moduleMiddleware = Array.isArray(module["x-middleware"]) ? module["x-middleware"] : [];
169
+ const inherited = [...globalMiddleware, ...moduleMiddleware];
170
+ const paths = module.paths;
171
+ if (!paths) {
172
+ return;
173
+ }
174
+ const configurations = Object.entries(paths).filter(([path]) => typeof path === "string" && path.startsWith("/")).map(([path, method_config]) => {
175
+ return Object.entries(method_config).filter(([method]) => HTTP_METHODS.has(String(method).toLowerCase())).map(([method, config]) => {
176
+ const methodName = String(method);
177
+ return parsePathConfig(path, methodName, config, inherited);
178
+ });
179
+ });
180
+ const routes = configurations.reduce((flat_config, config) => {
181
+ return flat_config.concat(config);
182
+ }, []);
183
+ routes.forEach((route) => {
184
+ route.path = join(basePath, route.path);
185
+ route.layout = baseLayouts.concat(route.layout || []);
186
+ });
187
+ return routes;
188
+ });
189
+ return modules_path.reduce(
190
+ (flat_config, config) => {
191
+ if (!config) {
192
+ return flat_config;
193
+ }
194
+ return flat_config.concat(config);
195
+ },
196
+ []
197
+ );
198
+ }
199
+ function parse_paths(openapi, inheritedMiddleware = []) {
200
+ const paths = openapi.paths;
201
+ if (!paths) {
202
+ return;
203
+ }
204
+ const globalMiddleware = [...inheritedMiddleware, ...getGlobalPathsMiddleware(openapi)];
205
+ const configurations = Object.entries(paths).filter(([path]) => typeof path === "string" && path.startsWith("/")).map(([path, method_config]) => {
206
+ return Object.entries(method_config).filter(([method]) => HTTP_METHODS.has(String(method).toLowerCase())).map(([method, config]) => {
207
+ const methodName = String(method);
208
+ return parsePathConfig(path, methodName, config, globalMiddleware);
209
+ });
210
+ });
211
+ const routes = configurations.reduce((flat_config, config) => {
212
+ return flat_config.concat(config);
213
+ }, []);
214
+ return routes;
215
+ }
216
+ function isStitchConfig(document) {
217
+ return document && typeof document === "object" && "stitch" in document;
218
+ }
219
+ function isOpenAPIConfig(document) {
220
+ return document && typeof document === "object" && ("paths" in document || "module" in document || "modules" in document);
221
+ }
222
+ async function parse_openapi_config(openapi_config_path) {
223
+ const content = fs__default.readFileSync(openapi_config_path, "utf8");
224
+ const parsed_config = parseConfigfile(content);
225
+ let openapi_config;
226
+ if (isStitchConfig(parsed_config)) {
227
+ console.log("Detected stitch configuration, building with Node.js stitch engine...");
228
+ try {
229
+ const { StitchEngine } = await import("@noego/stitch");
230
+ const startTime = Date.now();
231
+ const engine = new StitchEngine();
232
+ const result = engine.buildSync(openapi_config_path, { format: "json" });
233
+ if (!result.success) {
234
+ throw new Error(`Stitch build failed: ${result.error}`);
235
+ }
236
+ const buildTime = Date.now() - startTime;
237
+ console.log(`INFO Stitch build completed in ${buildTime} ms – ${parsed_config.stitch ? parsed_config.stitch.length : 0} modules processed`);
238
+ openapi_config = typeof result.data === "string" ? JSON.parse(result.data) : result.data;
239
+ } catch (error) {
240
+ throw new Error(`Failed to process stitch configuration: ${error instanceof Error ? error.message : String(error)}`);
241
+ }
242
+ } else if (isOpenAPIConfig(parsed_config)) {
243
+ console.log("Detected regular OpenAPI configuration");
244
+ openapi_config = parsed_config;
245
+ } else {
246
+ throw new Error(`Invalid OpenAPI or stitch configuration file: ${openapi_config_path}. File must contain either 'stitch', 'paths', 'module', or 'modules' at the root level.`);
247
+ }
248
+ const globalPathsMiddleware = getGlobalPathsMiddleware(openapi_config);
249
+ let modules = parse_modules(openapi_config) || [];
250
+ let paths = parse_paths(openapi_config) || [];
251
+ let fallback_layout = openapi_config["x-fallback-layout"] || null;
252
+ let fallback_view = openapi_config["x-fallback-view"] || null;
253
+ const fallback_middleware = Array.isArray(openapi_config["x-fallback-middleware"]) ? [...openapi_config["x-fallback-middleware"]] : [...globalPathsMiddleware];
254
+ let fallback = {
255
+ layout: fallback_layout ? [fallback_layout] : [],
256
+ view: fallback_view,
257
+ middleware: fallback_middleware
258
+ };
259
+ const routes = [...modules, ...paths];
260
+ let config = {
261
+ fallback,
262
+ routes
263
+ };
264
+ return config;
265
+ }
266
+ class ComponentManager {
267
+ constructor(componentLoader) {
268
+ this.componentLoader = componentLoader;
269
+ }
270
+ async getLayoutComponents(route) {
271
+ const layout_paths = route.layout || [];
272
+ const layouts_components = await Promise.all(layout_paths.map((layout) => {
273
+ console.log("layout path", layout);
274
+ return this.componentLoader.load(layout);
275
+ }));
276
+ return layouts_components;
277
+ }
278
+ async getLayouts(route) {
279
+ const layout_paths = route.layout || [];
280
+ const layouts_components = await Promise.all(layout_paths.map(async (layout_path) => {
281
+ const layout = await this.componentLoader.load(layout_path);
282
+ return layout.default;
283
+ }));
284
+ return layouts_components;
285
+ }
286
+ async getLayoutLoaders(route) {
287
+ const layout_paths = route.layout || [];
288
+ const loaders_from_files = await Promise.all(
289
+ layout_paths.map((layoutPath) => this.resolveLoader(layoutPath))
290
+ );
291
+ const needs_fallback = loaders_from_files.some((loader) => !loader);
292
+ if (needs_fallback) {
293
+ const layout_components = await this.getLayoutComponents(route);
294
+ const old_style_loaders = layout_components.map((layout) => layout.load);
295
+ return loaders_from_files.map(
296
+ (loader, index) => loader || old_style_loaders[index] || null
297
+ );
298
+ }
299
+ return loaders_from_files;
300
+ }
301
+ async getViewComponent(route) {
302
+ return await this.componentLoader.load(route.view);
303
+ }
304
+ async hasLoaders(route) {
305
+ const componentPaths = [...route.layout || [], route.view];
306
+ for (const componentPath of componentPaths) {
307
+ const loader = await this.resolveLoader(componentPath);
308
+ if (loader) {
309
+ return true;
310
+ }
311
+ }
312
+ return false;
313
+ }
314
+ async getLoaders(route) {
315
+ const layoutPaths = route.layout || [];
316
+ const layouts = await Promise.all(layoutPaths.map((layoutPath) => this.resolveLoader(layoutPath)));
317
+ const view = await this.resolveLoader(route.view);
318
+ return {
319
+ layouts,
320
+ view
321
+ };
322
+ }
323
+ getLoaderFilePath(componentPath, extension = ".js") {
324
+ if (!componentPath) {
325
+ return null;
326
+ }
327
+ const fullPath = this.componentLoader.getComponentFullPath(componentPath);
328
+ const { dir, name } = path__default.parse(fullPath);
329
+ return path__default.join(dir, `${name}.load${extension}`);
330
+ }
331
+ async resolveLoader(componentPath) {
332
+ if (!componentPath) {
333
+ return null;
334
+ }
335
+ const extensions = [".js", ".ts"];
336
+ for (const ext of extensions) {
337
+ const loaderFilePath = this.getLoaderFilePath(componentPath, ext);
338
+ if (!loaderFilePath) {
339
+ continue;
340
+ }
341
+ try {
342
+ console.log(`[ComponentManager] Trying loader path: ${loaderFilePath}`);
343
+ const module = await import(pathToFileURL(loaderFilePath).href);
344
+ const loader = module == null ? void 0 : module.default;
345
+ console.log(`[ComponentManager] Imported loader module: default=${typeof loader}`);
346
+ if (typeof loader === "function") {
347
+ console.log(`[ComponentManager] Loaded loader function from: ${loaderFilePath}`);
348
+ return loader;
349
+ }
350
+ } catch (error) {
351
+ const code = (error == null ? void 0 : error.code) || (error == null ? void 0 : error.name) || "UNKNOWN_ERROR";
352
+ if (code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND") {
353
+ console.warn(`[ComponentManager] Loader not found at ${loaderFilePath} (${ext}): ${(error == null ? void 0 : error.message) || code}`);
354
+ continue;
355
+ }
356
+ console.error(`[ComponentManager] Failed to load loader for ${componentPath} (${ext}) at ${loaderFilePath}:`, error);
357
+ }
358
+ }
359
+ return null;
360
+ }
361
+ async getView(route) {
362
+ const view = await this.componentLoader.load(route.view);
363
+ return view.default;
364
+ }
365
+ }
366
+ function makeUrlParser(pattern) {
367
+ const parser = new pathToRegex(pattern);
368
+ return (pathname) => {
369
+ const result = parser.match(pathname);
370
+ return result || null;
371
+ };
372
+ }
373
+ function findRoute(pathname, routes) {
374
+ for (const { pattern, parser } of routes) {
375
+ const params = parser(pathname);
376
+ if (params) {
377
+ return { pattern, params };
378
+ }
379
+ }
380
+ return null;
381
+ }
382
+ function initialize_route_matchers(routes) {
383
+ return routes.map((route) => {
384
+ const pattern = route.path;
385
+ const parser = makeUrlParser(pattern);
386
+ return { pattern, parser };
387
+ });
388
+ }
389
+ export {
390
+ BasicComponentLoader as B,
391
+ ComponentManager as C,
392
+ ProdComponentLoader as P,
393
+ ViteComponentLoader as V,
394
+ findRoute as f,
395
+ initialize_route_matchers as i,
396
+ parse_openapi_config as p
397
+ };
398
+ //# sourceMappingURL=url_parser-DRWHePkU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url_parser-DRWHePkU.js","sources":["../src/routing/component_loader/component_loader.ts","../src/parser/openapi.ts","../src/routing/component_loader/component_manager.ts","../src/routing/url_parser.ts"],"sourcesContent":["import type { SvelteComponent } from 'svelte';\nimport type { ViteDevServer } from 'vite';\nimport path from 'path';\nimport fs from 'fs';\nimport { pathToFileURL } from 'url';\nimport { SvelteImport, SvelteModuleComponent } from '../base';\n\n\ntype SvelteResource<K> = SvelteImport<K> & SvelteModuleComponent\n\nexport interface IComponentLoader{\n load(component: string,options?:any): Promise<SvelteResource<SvelteComponent>>\n getComponentFullPath(component: string, options?: any): string\n}\n\n\nexport class BasicComponentLoader implements IComponentLoader {\n private resolvedBasePath: string;\n\n constructor(private basePath: string) {\n // Resolve basePath relative to current working directory\n this.resolvedBasePath = path.isAbsolute(basePath)\n ? basePath\n : path.resolve(process.cwd(), basePath);\n }\n\n async load(componentPath: string) {\n const component_full_path = this.getComponentFullPath(componentPath);\n // Use pathToFileURL for proper ESM import of absolute paths\n const module = await import(pathToFileURL(component_full_path).href);\n return module as SvelteResource<any>;\n }\n\n getComponentFullPath(componentPath: string): string {\n return path.join(this.resolvedBasePath, componentPath);\n }\n}\n\n\n\nexport class ViteComponentLoader implements IComponentLoader {\n constructor(private basePath:string, private vite: ViteDevServer) {}\n \n async load(componentPath: string, options = {use_base_path:true}): Promise<SvelteResource<any>> {\n const absoluteComponentPath = this.getComponentFullPath(componentPath, options);\n\n console.log(`[ViteComponentLoader] Loading component from path: ${absoluteComponentPath}`);\n\n // Smart detection: check for precompiled .js file first\n const jsPath = absoluteComponentPath.replace(/\\.svelte$/, '.js');\n const jsExists = fs.existsSync(jsPath);\n\n // TODO: Remove this if we only need svelte files\n if (false && jsExists) {\n // Precompiled .js exists - use it directly (production mode)\n console.log(`[ViteComponentLoader] Found precompiled component at: ${jsPath}`);\n try {\n const module: any = await import(jsPath);\n console.log(`[ViteComponentLoader] Loaded precompiled module successfully`);\n return module as SvelteResource<any>;\n } catch (error) {\n console.error(`[ViteComponentLoader] Error loading precompiled module from ${jsPath}`, error);\n throw error;\n }\n }\n\n // No .js file - fall back to Vite dev mode (.svelte)\n let vitePath = path.relative(process.cwd(), absoluteComponentPath);\n\n vitePath = vitePath.replace(/\\\\/g, '/');\n\n if (!vitePath.startsWith('/')) {\n vitePath = '/' + vitePath;\n }\n\n console.log(`[ViteComponentLoader] Resolved Vite path: ${vitePath} from componentPath: ${componentPath}`);\n\n\n try {\n console.log(`[ViteComponentLoader] Loading module for vitePath: ${vitePath}`);\n const module = await this.vite.ssrLoadModule(vitePath);\n console.log(`[ViteComponentLoader] Module loaded successfully for: ${vitePath}`);\n if (!module || !module.default) {\n console.error(`[ViteComponentLoader] Loaded module for ${vitePath} is invalid or missing a default export. Module content:`, module);\n throw new Error(`Module ${vitePath} loaded successfully but is invalid or missing default export.`);\n }\n return module as SvelteResource<any>;\n } catch (error) {\n console.error(`[ViteComponentLoader] Error loading module for vitePath: ${vitePath} (derived from componentPath: ${componentPath})`, error);\n\n try {\n await fs.promises.access(absoluteComponentPath);\n } catch (fsError) {\n }\n throw error;\n }\n }\n\n getComponentFullPath(componentPath: string, options = {use_base_path:true}): string {\n const use_base_path = options.use_base_path || false;\n\n if (use_base_path) {\n return path.join(this.basePath, componentPath);\n }\n\n if (path.isAbsolute(componentPath)) {\n return componentPath;\n }\n\n return componentPath;\n }\n}\n\n\nexport class ProdComponentLoader implements IComponentLoader {\n\n private componentMapPromise: Promise<Record<string, SvelteResource<any>>> | null = null;\n\n constructor(private base_path: string) {}\n\n async load(componentPath: string): Promise<SvelteResource<any>> {\n const normalized = this.normalizeKey(componentPath);\n\n try {\n const map = await this.loadComponentMap();\n const module = map[normalized];\n if (module) {\n return module;\n }\n } catch (error) {\n console.warn(`[Forge] Failed to load component \"${componentPath}\" from entry manifest:`, error);\n }\n\n const component_path = this.getComponentFullPath(componentPath);\n const fallbackPath = component_path.endsWith('.js')\n ? component_path\n : component_path.replace(/\\.svelte$/, '.js');\n const module: any = await import(pathToFileURL(fallbackPath).href);\n return module as SvelteResource<any>;\n }\n\n getComponentFullPath(componentPath: string): string {\n return path.join(this.base_path, componentPath);\n }\n\n private normalizeKey(componentPath: string): string {\n const trimmed = componentPath.replace(/^\\.\\//, '');\n if (trimmed.endsWith('.svelte')) {\n return trimmed.replace(/\\.svelte$/, '.js');\n }\n return trimmed;\n }\n\n private async loadComponentMap(): Promise<Record<string, SvelteResource<any>>> {\n if (!this.componentMapPromise) {\n const entryPath = path.join(this.base_path, 'entry-ssr.js');\n const entryUrl = pathToFileURL(entryPath).href;\n this.componentMapPromise = import(entryUrl)\n .then((mod: any) => {\n const source = mod.components ?? mod.default ?? {};\n const normalized: Record<string, SvelteResource<any>> = {};\n for (const [key, value] of Object.entries<SvelteResource<any>>(source)) {\n const cleanKey = key.replace(/^\\.\\//, '');\n normalized[cleanKey] = value;\n if (cleanKey.startsWith('ui/')) {\n normalized[cleanKey.slice(3)] = value;\n }\n if (cleanKey.endsWith('.svelte')) {\n const jsKey = cleanKey.replace(/\\.svelte$/, '.js');\n normalized[jsKey] = value;\n }\n }\n return normalized;\n })\n .catch((error) => {\n this.componentMapPromise = null;\n throw error;\n });\n }\n return this.componentMapPromise;\n }\n}\n","import yaml from 'js-yaml'\nimport clone from 'clone-deep'\nimport join from 'url-join'\nimport type {IRoute, IServerRoute} from \"./IRoute\"\nimport {parsePathConfig} from \"./path\"\nimport fs from 'fs'\n\nconst HTTP_METHODS = new Set([\n 'get',\n 'post',\n 'put',\n 'delete',\n 'patch',\n 'head',\n 'options',\n 'trace'\n])\n\nfunction getGlobalPathsMiddleware(openapi:any): string[] {\n if (!openapi || !openapi.paths) {\n return []\n }\n const value = openapi.paths['x-middleware']\n return Array.isArray(value) ? [...value] : []\n}\n\nexport function parseConfigfile(file_content:string) {\n let config:any = null\n try {\n config = yaml.load(file_content)\n } catch (e) {\n console.log(e)\n }\n return config\n}\n\n\nexport function parse_modules(openapi:any, inheritedMiddleware: string[] = []){\n const modules_config = (openapi.modules || openapi.module)\n if (!modules_config) {\n return\n }\n\n const modules:any = Object.entries(modules_config).map(([_,module])=>{\n return module\n })\n\n\n const globalMiddleware = [...inheritedMiddleware, ...getGlobalPathsMiddleware(openapi)]\n\n const modules_path: (IRoute[] | undefined)[] = modules.map((module:any) => {\n const basePath = module.basePath || ''\n const baseLayouts = module.baseLayouts || []\n const moduleMiddleware = Array.isArray(module['x-middleware']) ? module['x-middleware'] : []\n const inherited = [...globalMiddleware, ...moduleMiddleware]\n\n const paths = module.paths\n\n if(!paths){\n return\n }\n\n const configurations = Object.entries(paths)\n .filter(([path]) => typeof path === 'string' && path.startsWith('/'))\n .map(([path, method_config]:[string,any]) => {\n return Object.entries(method_config)\n .filter(([method]) => HTTP_METHODS.has(String(method).toLowerCase()))\n .map(([method, config]) => {\n const methodName = String(method)\n return parsePathConfig(path,methodName,config,inherited)\n })\n })\n\n const routes = configurations.reduce((flat_config,config)=>{\n return flat_config.concat(config)\n },[])\n\n routes.forEach((route:IRoute) => {\n route.path = join(basePath, route.path)\n route.layout = baseLayouts.concat(route.layout|| [])\n })\n return routes\n })\n\n return modules_path.reduce((flat_config,config)=>{\n if (!config) {\n return flat_config\n }\n return flat_config.concat(config)\n }\n ,[] as IRoute[])\n}\n\n\nexport function parse_paths(openapi:any, inheritedMiddleware: string[] = []){\n const paths = openapi.paths\n if (!paths) {\n return\n }\n\n const globalMiddleware = [...inheritedMiddleware, ...getGlobalPathsMiddleware(openapi)]\n\n const configurations = Object.entries(paths)\n .filter(([path]) => typeof path === 'string' && path.startsWith('/'))\n .map(([path, method_config]:[string,any]) => {\n return Object.entries(method_config)\n .filter(([method]) => HTTP_METHODS.has(String(method).toLowerCase()))\n .map(([method, config]) => {\n const methodName = String(method)\n return parsePathConfig(path,methodName,config,globalMiddleware)\n })\n })\n\n const routes = configurations.reduce((flat_config,config)=>{\n return flat_config.concat(config)\n },[] as IRoute[])\n\n return routes\n}\n\n\n\n\nexport function transform_openapi_spec(openapi_spec:string) {\n\n const openapi = parseConfigfile(openapi_spec)\n const config = normalize_openapi_config(openapi)\n return yaml.dump(config)\n}\n\n\nexport function normalize_openapi_config(openapi_config:any){\n const config = clone(openapi_config)\n\n const modules = parse_modules(config) || []\n const paths = parse_paths(config) || []\n\n const routes = [...modules, ...paths]\n\n routes.forEach((route:IRoute) => {\n const path = route.path\n const method = route.method\n const config_path = config.paths[path] || {}\n const config_method = config_path[method] || {}\n\n config_method.summary = route.summary\n config_method.description = route.description\n config_method.parameters = route.parameters\n config_method.query = route.query\n config_method.body = route.body\n config_method.responses = route.responses\n config_method['x-view'] = route.view\n config_method['x-layout'] = route.layout\n if (route.middleware && route.middleware.length > 0) {\n config_method['x-middleware'] = route.middleware\n } else {\n delete config_method['x-middleware']\n }\n\n config_path[method] = config_method\n config.paths[path] = config_path\n })\n\n delete config.modules\n return config\n}\n\n\n/**\n * Check if a YAML document is a stitch configuration file\n * @param document The parsed YAML document\n * @returns True if it's a stitch config, false otherwise\n */\nfunction isStitchConfig(document: any): boolean {\n return document && typeof document === 'object' && 'stitch' in document;\n}\n\n/**\n * Check if a YAML document is a regular OpenAPI file\n * @param document The parsed YAML document\n * @returns True if it's a regular OpenAPI file, false otherwise\n */\nfunction isOpenAPIConfig(document: any): boolean {\n return document && typeof document === 'object' && ('paths' in document || 'module' in document || 'modules' in document);\n}\n\nexport async function parse_openapi_config(openapi_config_path:string):Promise<IServerRoute>{\n const content = fs.readFileSync(openapi_config_path, 'utf8')\n const parsed_config = parseConfigfile(content)\n \n let openapi_config: any;\n \n if (isStitchConfig(parsed_config)) {\n // Handle stitch configuration - build using Node.js stitch engine\n console.log('Detected stitch configuration, building with Node.js stitch engine...');\n \n try {\n const { StitchEngine } = await import('@noego/stitch');\n \n const startTime = Date.now();\n const engine = new StitchEngine();\n const result = engine.buildSync(openapi_config_path, { format: 'json' });\n \n if (!result.success) {\n throw new Error(`Stitch build failed: ${result.error}`);\n }\n \n const buildTime = Date.now() - startTime;\n console.log(`INFO Stitch build completed in ${buildTime} ms – ${parsed_config.stitch ? parsed_config.stitch.length : 0} modules processed`);\n \n // Parse the JSON string result to get the JavaScript object\n openapi_config = typeof result.data === 'string' ? JSON.parse(result.data) : result.data;\n } catch (error) {\n throw new Error(`Failed to process stitch configuration: ${error instanceof Error ? error.message : String(error)}`);\n }\n } else if (isOpenAPIConfig(parsed_config)) {\n // Handle regular OpenAPI file (legacy path)\n console.log('Detected regular OpenAPI configuration');\n openapi_config = parsed_config;\n } else {\n throw new Error(`Invalid OpenAPI or stitch configuration file: ${openapi_config_path}. File must contain either 'stitch', 'paths', 'module', or 'modules' at the root level.`);\n }\n const globalPathsMiddleware = getGlobalPathsMiddleware(openapi_config)\n\n let modules = parse_modules(openapi_config) || []\n let paths = parse_paths(openapi_config) || []\n\n let fallback_layout = openapi_config['x-fallback-layout'] || null\n let fallback_view = openapi_config['x-fallback-view'] || null\n const fallback_middleware = Array.isArray(openapi_config['x-fallback-middleware'])\n ? [...openapi_config['x-fallback-middleware']]\n : [...globalPathsMiddleware]\n let fallback = {\n layout: fallback_layout ? [fallback_layout]:[],\n view: fallback_view,\n middleware: fallback_middleware\n }\n\n const routes = [...modules, ...paths]\n\n let config = {\n fallback,\n routes\n }\n return config\n}\n\n\nexport function transform_openapi_config(openapi_config:any):IRoute[] {\n let modules = parse_modules(openapi_config) || []\n let paths = parse_paths(openapi_config) || []\n\n let routes = [...modules, ...paths]\n return routes\n}\n","import path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport type { IRoute } from \"../../parser/IRoute\";\nimport type { IComponentLoader } from \"./component_loader\";\n\n\n\n\n\n\nexport class ComponentManager {\n\n constructor(\n private componentLoader: IComponentLoader\n ){\n\n }\n\n async getLayoutComponents(route:IRoute){\n const layout_paths = route.layout || [];\n const layouts_components = await Promise.all(layout_paths.map((layout)=>{\n console.log(\"layout path\",layout)\n return this.componentLoader.load(layout)}))\n return layouts_components\n }\n\n async getLayouts(route:IRoute){\n const layout_paths = route.layout || [];\n const layouts_components = await Promise.all(layout_paths.map(async (layout_path)=>{\n const layout = await this.componentLoader.load(layout_path)\n return layout.default\n \n }))\n return layouts_components\n }\n\n async getLayoutLoaders(route:IRoute){\n const layout_paths = route.layout || [];\n \n // First, check for .load.js/.load.ts files using resolveLoader (maintains order)\n // Each loader at index N corresponds to the layout at index N\n const loaders_from_files = await Promise.all(\n layout_paths.map((layoutPath) => this.resolveLoader(layoutPath))\n );\n \n // Check if any need fallback to old-style component.load\n const needs_fallback = loaders_from_files.some(loader => !loader);\n \n if (needs_fallback) {\n // Fall back to old-style component.load for backward compatibility\n const layout_components = await this.getLayoutComponents(route);\n const old_style_loaders = layout_components.map(layout => layout.load);\n \n // Merge: prefer .load.js/.load.ts file loaders, fall back to old-style component.load\n // This maintains order: loader[index] corresponds to layout_paths[index]\n return loaders_from_files.map((loader, index) => \n loader || old_style_loaders[index] || null\n );\n }\n \n return loaders_from_files;\n }\n\n\n async getViewComponent(route: IRoute) {\n return await this.componentLoader.load(route.view)\n }\n\n\n async hasLoaders(route:IRoute):Promise<boolean>{\n const componentPaths = [...(route.layout || []), route.view];\n\n for (const componentPath of componentPaths) {\n const loader = await this.resolveLoader(componentPath);\n if (loader) {\n return true;\n }\n }\n\n return false;\n }\n\n\n async getLoaders(route: IRoute) {\n const layoutPaths = route.layout || [];\n const layouts = await Promise.all(layoutPaths.map((layoutPath) => this.resolveLoader(layoutPath)));\n const view = await this.resolveLoader(route.view);\n\n return {\n layouts,\n view\n };\n }\n\n\n private getLoaderFilePath(componentPath?: string | null, extension: '.js' | '.ts' = '.js'): string | null {\n if (!componentPath) {\n return null;\n }\n\n const fullPath = this.componentLoader.getComponentFullPath(componentPath);\n const { dir, name } = path.parse(fullPath);\n return path.join(dir, `${name}.load${extension}`);\n }\n\n\n private async resolveLoader(componentPath?: string | null): Promise<((...args: any[]) => any) | null> {\n if (!componentPath) {\n return null;\n }\n\n // Try .load.js first (production), then .load.ts (development)\n const extensions: Array<'.js' | '.ts'> = ['.js', '.ts'];\n \n for (const ext of extensions) {\n const loaderFilePath = this.getLoaderFilePath(componentPath, ext);\n if (!loaderFilePath) {\n continue;\n }\n\n try {\n console.log(`[ComponentManager] Trying loader path: ${loaderFilePath}`);\n const module = await import(pathToFileURL(loaderFilePath).href);\n const loader = module?.default;\n console.log(`[ComponentManager] Imported loader module: default=${typeof loader}`);\n if (typeof loader === \"function\") {\n console.log(`[ComponentManager] Loaded loader function from: ${loaderFilePath}`);\n return loader;\n }\n } catch (error: any) {\n const code = error?.code || error?.name || 'UNKNOWN_ERROR';\n if (code === \"MODULE_NOT_FOUND\" || code === \"ERR_MODULE_NOT_FOUND\") {\n console.warn(`[ComponentManager] Loader not found at ${loaderFilePath} (${ext}): ${error?.message || code}`);\n // File doesn't exist with this extension, try next one\n continue;\n }\n // Other errors (syntax errors, etc.) should be logged\n console.error(`[ComponentManager] Failed to load loader for ${componentPath} (${ext}) at ${loaderFilePath}:`, error);\n // Continue to try next extension\n }\n }\n\n // Neither .load.js nor .load.ts found\n return null;\n }\n\n\n async getView(route: IRoute) {\n const view = await this.componentLoader.load(route.view)\n return view.default\n }\n}\n","import pathToRegex from 'path-to-regex';\nimport type { IRoute } from '../parser/IRoute';\n\n\n\nexport function makeUrlParser(pattern: string) {\n const parser = new pathToRegex(pattern);\n return (pathname: string) => {\n const result = parser.match(pathname);\n return result || null;\n };\n}\n\n\nexport type UrlMatcher = {\n pattern: string,\n parser: ReturnType<typeof makeUrlParser>\n}\n\nexport function findRoute(pathname:string, routes: UrlMatcher[]) {\n for (const { pattern, parser } of routes) {\n const params = parser(pathname);\n if (params) {\n return { pattern, params };\n }\n }\n return null;\n}\n\n\n\n\n\nexport function initialize_route_matchers(routes: IRoute[]): UrlMatcher[] {\n return routes.map((route: I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AS,0BAA0B,QAAgC;AACjE,SAAA,OAAO,IAAI,CAAC,UAAkB;AACnC,UAAM,UAAU,MAAM;AAChB,UAAA,SAAS,cAAc,OAAO;AAC7B,WAAA,EAAE,SAAS,OAAO;AAAA,EAAA,CAC1B;AACH;"}
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@noego/forge",
3
- "version": "0.0.27",
3
+ "version": "0.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "imports": {
7
7
  "#recursive-render": "./src/components/RecursiveRender.svelte"
8
8
  },
9
+ "bin": {
10
+ "forge": "./bin/forge.js"
11
+ },
9
12
  "files": [
13
+ "bin",
10
14
  "dist",
11
15
  "dist-ssr",
12
16
  "loaders",
@@ -52,6 +56,16 @@
52
56
  "import": "./dist-ssr/server.js",
53
57
  "require": "./dist-ssr/server.cjs"
54
58
  },
59
+ "./static": {
60
+ "types": "./dist-ssr/static.d.ts",
61
+ "import": "./dist-ssr/static.js",
62
+ "require": "./dist-ssr/static.cjs"
63
+ },
64
+ "./test": {
65
+ "types": "./dist-ssr/test.d.ts",
66
+ "import": "./dist-ssr/test.js",
67
+ "require": "./dist-ssr/test.cjs"
68
+ },
55
69
  "./page": {
56
70
  "types": "./dist/page.d.ts",
57
71
  "import": "./dist/page.mjs",
@@ -74,7 +88,17 @@
74
88
  },
75
89
  "peerDependencies": {
76
90
  "express": "^4",
77
- "svelte": "^5.28.2"
91
+ "playwright": "^1.40.0",
92
+ "svelte": "^5.28.2",
93
+ "tsx": "^4.0.0"
94
+ },
95
+ "peerDependenciesMeta": {
96
+ "playwright": {
97
+ "optional": true
98
+ },
99
+ "tsx": {
100
+ "optional": true
101
+ }
78
102
  },
79
103
  "typesVersions": {
80
104
  "*": {
@@ -90,6 +114,18 @@
90
114
  "server/*": [
91
115
  "dist-ssr/server/*"
92
116
  ],
117
+ "static": [
118
+ "dist-ssr/static.d.mts"
119
+ ],
120
+ "static/*": [
121
+ "dist-ssr/static/*"
122
+ ],
123
+ "test": [
124
+ "dist-ssr/test.d.mts"
125
+ ],
126
+ "test/*": [
127
+ "dist-ssr/test/*"
128
+ ],
93
129
  "options": [
94
130
  "dist/options/ServerOptions.d.ts"
95
131
  ],
@@ -135,6 +171,7 @@
135
171
  "http-proxy-middleware": "^3.0.5",
136
172
  "jest": "^29.7.0",
137
173
  "jsdom": "^26.0.0",
174
+ "playwright": "^1.57.0",
138
175
  "prettier": "^3.5.3",
139
176
  "svelte": "5.38",
140
177
  "svelte-preprocess": "^6.0.0",