@lolyjs/core 0.1.0-alpha.6 → 0.1.0-alpha.9
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/dist/cli.cjs.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +37 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +37 -16
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +61 -38
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.mts +45 -3
- package/dist/runtime.d.ts +45 -3
- package/dist/runtime.js +61 -34
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -2
- package/dist/bootstrap-BiCQmSkx.d.mts +0 -50
- package/dist/bootstrap-BiCQmSkx.d.ts +0 -50
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Socket, Server } from 'socket.io';
|
|
4
|
-
export { c as bootstrapClient } from './bootstrap-BiCQmSkx.mjs';
|
|
5
4
|
import { ZodSchema, z } from 'zod';
|
|
6
5
|
import * as express_rate_limit from 'express-rate-limit';
|
|
7
6
|
import pino, { Logger as Logger$1 } from 'pino';
|
|
@@ -216,6 +215,40 @@ interface BuildAppOptions {
|
|
|
216
215
|
}
|
|
217
216
|
declare function buildApp(options?: BuildAppOptions): Promise<void>;
|
|
218
217
|
|
|
218
|
+
declare const WINDOW_DATA_KEY = "__FW_DATA__";
|
|
219
|
+
|
|
220
|
+
type InitialData = {
|
|
221
|
+
pathname: string;
|
|
222
|
+
params: Record<string, string>;
|
|
223
|
+
props: Record<string, any>;
|
|
224
|
+
metadata?: {
|
|
225
|
+
title?: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
} | null;
|
|
228
|
+
notFound?: boolean;
|
|
229
|
+
error?: boolean;
|
|
230
|
+
theme?: string;
|
|
231
|
+
};
|
|
232
|
+
declare global {
|
|
233
|
+
interface Window {
|
|
234
|
+
[WINDOW_DATA_KEY]?: InitialData;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
type ClientLoadedComponents = {
|
|
238
|
+
Page: React.ComponentType<any>;
|
|
239
|
+
layouts: React.ComponentType<any>[];
|
|
240
|
+
};
|
|
241
|
+
type ClientRouteLoaded = {
|
|
242
|
+
pattern: string;
|
|
243
|
+
paramNames: string[];
|
|
244
|
+
load: () => Promise<ClientLoadedComponents>;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Bootstraps the client-side application.
|
|
249
|
+
*/
|
|
250
|
+
declare function bootstrapClient(routes: ClientRouteLoaded[], notFoundRoute: ClientRouteLoaded | null, errorRoute?: ClientRouteLoaded | null): void;
|
|
251
|
+
|
|
219
252
|
declare function withCache(fn: any, options: any): any;
|
|
220
253
|
|
|
221
254
|
/**
|
|
@@ -442,4 +475,4 @@ declare function requestLoggerMiddleware(options?: {
|
|
|
442
475
|
*/
|
|
443
476
|
declare function getRequestLogger(req: Request): Logger;
|
|
444
477
|
|
|
445
|
-
export { type ApiContext, type ApiMiddleware, DEFAULT_CONFIG, type FrameworkConfig, type GenerateStaticParams, type InitServerData, type LoaderResult, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type MetadataLoader, type RouteMiddleware, type ServerConfig, type ServerContext, type ServerLoader, ValidationError, type WssContext, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
|
|
478
|
+
export { type ApiContext, type ApiMiddleware, DEFAULT_CONFIG, type FrameworkConfig, type GenerateStaticParams, type InitServerData, type LoaderResult, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type MetadataLoader, type RouteMiddleware, type ServerConfig, type ServerContext, type ServerLoader, ValidationError, type WssContext, bootstrapClient, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Socket, Server } from 'socket.io';
|
|
4
|
-
export { c as bootstrapClient } from './bootstrap-BiCQmSkx.js';
|
|
5
4
|
import { ZodSchema, z } from 'zod';
|
|
6
5
|
import * as express_rate_limit from 'express-rate-limit';
|
|
7
6
|
import pino, { Logger as Logger$1 } from 'pino';
|
|
@@ -216,6 +215,40 @@ interface BuildAppOptions {
|
|
|
216
215
|
}
|
|
217
216
|
declare function buildApp(options?: BuildAppOptions): Promise<void>;
|
|
218
217
|
|
|
218
|
+
declare const WINDOW_DATA_KEY = "__FW_DATA__";
|
|
219
|
+
|
|
220
|
+
type InitialData = {
|
|
221
|
+
pathname: string;
|
|
222
|
+
params: Record<string, string>;
|
|
223
|
+
props: Record<string, any>;
|
|
224
|
+
metadata?: {
|
|
225
|
+
title?: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
} | null;
|
|
228
|
+
notFound?: boolean;
|
|
229
|
+
error?: boolean;
|
|
230
|
+
theme?: string;
|
|
231
|
+
};
|
|
232
|
+
declare global {
|
|
233
|
+
interface Window {
|
|
234
|
+
[WINDOW_DATA_KEY]?: InitialData;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
type ClientLoadedComponents = {
|
|
238
|
+
Page: React.ComponentType<any>;
|
|
239
|
+
layouts: React.ComponentType<any>[];
|
|
240
|
+
};
|
|
241
|
+
type ClientRouteLoaded = {
|
|
242
|
+
pattern: string;
|
|
243
|
+
paramNames: string[];
|
|
244
|
+
load: () => Promise<ClientLoadedComponents>;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Bootstraps the client-side application.
|
|
249
|
+
*/
|
|
250
|
+
declare function bootstrapClient(routes: ClientRouteLoaded[], notFoundRoute: ClientRouteLoaded | null, errorRoute?: ClientRouteLoaded | null): void;
|
|
251
|
+
|
|
219
252
|
declare function withCache(fn: any, options: any): any;
|
|
220
253
|
|
|
221
254
|
/**
|
|
@@ -442,4 +475,4 @@ declare function requestLoggerMiddleware(options?: {
|
|
|
442
475
|
*/
|
|
443
476
|
declare function getRequestLogger(req: Request): Logger;
|
|
444
477
|
|
|
445
|
-
export { type ApiContext, type ApiMiddleware, DEFAULT_CONFIG, type FrameworkConfig, type GenerateStaticParams, type InitServerData, type LoaderResult, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type MetadataLoader, type RouteMiddleware, type ServerConfig, type ServerContext, type ServerLoader, ValidationError, type WssContext, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
|
|
478
|
+
export { type ApiContext, type ApiMiddleware, DEFAULT_CONFIG, type FrameworkConfig, type GenerateStaticParams, type InitServerData, type LoaderResult, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type MetadataLoader, type RouteMiddleware, type ServerConfig, type ServerContext, type ServerLoader, ValidationError, type WssContext, bootstrapClient, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
|
package/dist/index.js
CHANGED
|
@@ -5099,6 +5099,11 @@ import { useEffect, useState, useRef } from "react";
|
|
|
5099
5099
|
// modules/runtime/client/RouterView.tsx
|
|
5100
5100
|
import { jsx } from "react/jsx-runtime";
|
|
5101
5101
|
function RouterView({ state }) {
|
|
5102
|
+
console.log("[loly:RouterView] Rendering", {
|
|
5103
|
+
url: state.url,
|
|
5104
|
+
hasRoute: !!state.route,
|
|
5105
|
+
hasComponents: !!state.components
|
|
5106
|
+
});
|
|
5102
5107
|
if (!state.route) {
|
|
5103
5108
|
if (state.components === null) {
|
|
5104
5109
|
return null;
|
|
@@ -5110,6 +5115,11 @@ function RouterView({ state }) {
|
|
|
5110
5115
|
}
|
|
5111
5116
|
const { Page, layouts } = state.components;
|
|
5112
5117
|
const { params, props } = state;
|
|
5118
|
+
console.log("[loly:RouterView] Creating page element", {
|
|
5119
|
+
hasPage: !!Page,
|
|
5120
|
+
layoutsCount: layouts.length,
|
|
5121
|
+
paramsKeys: Object.keys(params)
|
|
5122
|
+
});
|
|
5113
5123
|
let element = /* @__PURE__ */ jsx(Page, { params, ...props });
|
|
5114
5124
|
const layoutChain = layouts.slice().reverse();
|
|
5115
5125
|
for (const Layout of layoutChain) {
|
|
@@ -5580,6 +5590,10 @@ function AppShell({
|
|
|
5580
5590
|
notFoundRoute,
|
|
5581
5591
|
errorRoute
|
|
5582
5592
|
}) {
|
|
5593
|
+
console.log("[loly:AppShell] Component rendering", {
|
|
5594
|
+
url: initialState.url,
|
|
5595
|
+
hasRoute: !!initialState.route
|
|
5596
|
+
});
|
|
5583
5597
|
const [state, setState] = useState(initialState);
|
|
5584
5598
|
const handlersRef = useRef({
|
|
5585
5599
|
setState,
|
|
@@ -5588,6 +5602,11 @@ function AppShell({
|
|
|
5588
5602
|
errorRoute
|
|
5589
5603
|
});
|
|
5590
5604
|
useEffect(() => {
|
|
5605
|
+
console.log("[loly:AppShell] Updating handlersRef", {
|
|
5606
|
+
routesCount: routes.length,
|
|
5607
|
+
hasNotFound: !!notFoundRoute,
|
|
5608
|
+
hasError: !!errorRoute
|
|
5609
|
+
});
|
|
5591
5610
|
handlersRef.current = {
|
|
5592
5611
|
setState,
|
|
5593
5612
|
routes,
|
|
@@ -5596,7 +5615,8 @@ function AppShell({
|
|
|
5596
5615
|
};
|
|
5597
5616
|
}, [routes, notFoundRoute, errorRoute]);
|
|
5598
5617
|
useEffect(() => {
|
|
5599
|
-
|
|
5618
|
+
const effectId = Math.random().toString(36).substring(7);
|
|
5619
|
+
console.log("[loly:AppShell] Setting up event listeners", { effectId });
|
|
5600
5620
|
let isMounted = true;
|
|
5601
5621
|
let listenerCount = 0;
|
|
5602
5622
|
async function handleNavigate(nextUrl, options) {
|
|
@@ -5619,6 +5639,7 @@ function AppShell({
|
|
|
5619
5639
|
});
|
|
5620
5640
|
return () => {
|
|
5621
5641
|
console.log("[loly:AppShell] Cleaning up event listeners", {
|
|
5642
|
+
effectId,
|
|
5622
5643
|
wasMounted: isMounted,
|
|
5623
5644
|
listenersToRemove: listenerCount
|
|
5624
5645
|
});
|
|
@@ -5636,6 +5657,7 @@ function AppShell({
|
|
|
5636
5657
|
|
|
5637
5658
|
// modules/runtime/client/bootstrap.tsx
|
|
5638
5659
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
5660
|
+
var __loly_hydrated = false;
|
|
5639
5661
|
async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute, errorRoute) {
|
|
5640
5662
|
const isInitialNotFound = initialData?.notFound === true;
|
|
5641
5663
|
const isInitialError = initialData?.error === true;
|
|
@@ -5662,7 +5684,7 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
|
|
|
5662
5684
|
initialComponents = await notFoundRoute.load();
|
|
5663
5685
|
} else {
|
|
5664
5686
|
console.warn(
|
|
5665
|
-
`[client] No route match found for ${initialUrl}.
|
|
5687
|
+
`[client] No route match found for ${initialUrl}. Routes:`,
|
|
5666
5688
|
routes.map((r) => r.pattern)
|
|
5667
5689
|
);
|
|
5668
5690
|
}
|
|
@@ -5676,21 +5698,24 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
|
|
|
5676
5698
|
};
|
|
5677
5699
|
}
|
|
5678
5700
|
function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5701
|
+
if (__loly_hydrated) {
|
|
5702
|
+
console.warn("[loly:runtime] bootstrapClient SKIPPED (already hydrated)");
|
|
5703
|
+
return;
|
|
5704
|
+
}
|
|
5705
|
+
__loly_hydrated = true;
|
|
5706
|
+
console.log("[loly:runtime] bootstrapClient START");
|
|
5684
5707
|
(async function bootstrap() {
|
|
5685
5708
|
const container = document.getElementById(APP_CONTAINER_ID2);
|
|
5686
5709
|
const initialData = getWindowData();
|
|
5687
5710
|
console.log("[loly:runtime] bootstrap starting", {
|
|
5688
5711
|
hasContainer: !!container,
|
|
5689
|
-
|
|
5690
|
-
|
|
5712
|
+
hasInitialData: !!initialData,
|
|
5713
|
+
containerId: APP_CONTAINER_ID2
|
|
5691
5714
|
});
|
|
5692
5715
|
if (!container) {
|
|
5693
|
-
console.error(
|
|
5716
|
+
console.error(
|
|
5717
|
+
`[loly:runtime] Container #${APP_CONTAINER_ID2} not found.`
|
|
5718
|
+
);
|
|
5694
5719
|
return;
|
|
5695
5720
|
}
|
|
5696
5721
|
const initialUrl = window.location.pathname + window.location.search;
|
|
@@ -5724,13 +5749,9 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5724
5749
|
}
|
|
5725
5750
|
)
|
|
5726
5751
|
);
|
|
5727
|
-
console.log("[loly:runtime]
|
|
5752
|
+
console.log("[loly:runtime] Hydrated successfully");
|
|
5728
5753
|
} catch (error) {
|
|
5729
|
-
console.error(
|
|
5730
|
-
"[loly:runtime] Error loading initial route components for",
|
|
5731
|
-
initialUrl,
|
|
5732
|
-
error
|
|
5733
|
-
);
|
|
5754
|
+
console.error("[loly:runtime] Error during hydration:", error);
|
|
5734
5755
|
window.location.reload();
|
|
5735
5756
|
}
|
|
5736
5757
|
})();
|