@lolyjs/core 0.2.0-alpha.2 → 0.2.0-alpha.4
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/LICENCE.md +9 -0
- package/dist/{bootstrap-BiCQmSkx.d.mts → bootstrap-DgvWWDim.d.mts} +7 -0
- package/dist/{bootstrap-BiCQmSkx.d.ts → bootstrap-DgvWWDim.d.ts} +7 -0
- package/dist/cli.cjs +34 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +34 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +110 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +106 -6
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.cjs +210 -2
- package/dist/react/hooks.cjs.map +1 -1
- package/dist/react/hooks.d.mts +84 -1
- package/dist/react/hooks.d.ts +84 -1
- package/dist/react/hooks.js +208 -1
- package/dist/react/hooks.js.map +1 -1
- package/dist/runtime.cjs +81 -9
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +77 -5
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -2
package/LICENCE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 LolyJS.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const WINDOW_DATA_KEY = "__FW_DATA__";
|
|
2
|
+
declare const ROUTER_DATA_KEY = "__LOLY_ROUTER_DATA__";
|
|
2
3
|
|
|
3
4
|
type InitialData = {
|
|
4
5
|
pathname: string;
|
|
@@ -12,9 +13,15 @@ type InitialData = {
|
|
|
12
13
|
error?: boolean;
|
|
13
14
|
theme?: string;
|
|
14
15
|
};
|
|
16
|
+
type RouterData = {
|
|
17
|
+
pathname: string;
|
|
18
|
+
params: Record<string, string>;
|
|
19
|
+
searchParams: Record<string, unknown>;
|
|
20
|
+
};
|
|
15
21
|
declare global {
|
|
16
22
|
interface Window {
|
|
17
23
|
[WINDOW_DATA_KEY]?: InitialData;
|
|
24
|
+
[ROUTER_DATA_KEY]?: RouterData;
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
type ClientLoadedComponents = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const WINDOW_DATA_KEY = "__FW_DATA__";
|
|
2
|
+
declare const ROUTER_DATA_KEY = "__LOLY_ROUTER_DATA__";
|
|
2
3
|
|
|
3
4
|
type InitialData = {
|
|
4
5
|
pathname: string;
|
|
@@ -12,9 +13,15 @@ type InitialData = {
|
|
|
12
13
|
error?: boolean;
|
|
13
14
|
theme?: string;
|
|
14
15
|
};
|
|
16
|
+
type RouterData = {
|
|
17
|
+
pathname: string;
|
|
18
|
+
params: Record<string, string>;
|
|
19
|
+
searchParams: Record<string, unknown>;
|
|
20
|
+
};
|
|
15
21
|
declare global {
|
|
16
22
|
interface Window {
|
|
17
23
|
[WINDOW_DATA_KEY]?: InitialData;
|
|
24
|
+
[ROUTER_DATA_KEY]?: RouterData;
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
type ClientLoadedComponents = {
|
package/dist/cli.cjs
CHANGED
|
@@ -47,17 +47,19 @@ __export(globals_exports, {
|
|
|
47
47
|
NOT_FOUND_FILE_PREFIX: () => NOT_FOUND_FILE_PREFIX,
|
|
48
48
|
NOT_FOUND_PATTERN: () => NOT_FOUND_PATTERN,
|
|
49
49
|
PAGE_FILE_NAME: () => PAGE_FILE_NAME,
|
|
50
|
+
ROUTER_DATA_KEY: () => ROUTER_DATA_KEY,
|
|
50
51
|
STATIC_PATH: () => STATIC_PATH,
|
|
51
52
|
STYLE_FILE_NAME: () => STYLE_FILE_NAME,
|
|
52
53
|
WINDOW_DATA_KEY: () => WINDOW_DATA_KEY
|
|
53
54
|
});
|
|
54
|
-
var BUILD_FOLDER_NAME, STYLE_FILE_NAME, WINDOW_DATA_KEY, APP_CONTAINER_ID, STATIC_PATH, NOT_FOUND_PATTERN, ERROR_PATTERN, NOT_FOUND_CHUNK_KEY, ERROR_CHUNK_KEY, NOT_FOUND_FILE_PREFIX, ERROR_FILE_PREFIX, PAGE_FILE_NAME, LAYOUT_FILE_NAME, FAVICON_PATH, CLIENT_CSS_PATH, CLIENT_JS_PATH, ASSETS_BASE_DIR;
|
|
55
|
+
var BUILD_FOLDER_NAME, STYLE_FILE_NAME, WINDOW_DATA_KEY, ROUTER_DATA_KEY, APP_CONTAINER_ID, STATIC_PATH, NOT_FOUND_PATTERN, ERROR_PATTERN, NOT_FOUND_CHUNK_KEY, ERROR_CHUNK_KEY, NOT_FOUND_FILE_PREFIX, ERROR_FILE_PREFIX, PAGE_FILE_NAME, LAYOUT_FILE_NAME, FAVICON_PATH, CLIENT_CSS_PATH, CLIENT_JS_PATH, ASSETS_BASE_DIR;
|
|
55
56
|
var init_globals = __esm({
|
|
56
57
|
"constants/globals.ts"() {
|
|
57
58
|
"use strict";
|
|
58
59
|
BUILD_FOLDER_NAME = ".loly";
|
|
59
60
|
STYLE_FILE_NAME = "styles.css";
|
|
60
61
|
WINDOW_DATA_KEY = "__FW_DATA__";
|
|
62
|
+
ROUTER_DATA_KEY = "__LOLY_ROUTER_DATA__";
|
|
61
63
|
APP_CONTAINER_ID = "__app";
|
|
62
64
|
STATIC_PATH = "/static";
|
|
63
65
|
NOT_FOUND_PATTERN = "/not-found";
|
|
@@ -1490,6 +1492,7 @@ function createDocumentTree(options) {
|
|
|
1490
1492
|
const {
|
|
1491
1493
|
appTree,
|
|
1492
1494
|
initialData,
|
|
1495
|
+
routerData,
|
|
1493
1496
|
meta,
|
|
1494
1497
|
titleFallback,
|
|
1495
1498
|
descriptionFallback,
|
|
@@ -1527,6 +1530,9 @@ function createDocumentTree(options) {
|
|
|
1527
1530
|
...initialData,
|
|
1528
1531
|
theme
|
|
1529
1532
|
});
|
|
1533
|
+
const routerSerialized = JSON.stringify({
|
|
1534
|
+
...routerData
|
|
1535
|
+
});
|
|
1530
1536
|
const documentTree = import_react.default.createElement(
|
|
1531
1537
|
"html",
|
|
1532
1538
|
{ lang },
|
|
@@ -1574,6 +1580,12 @@ function createDocumentTree(options) {
|
|
|
1574
1580
|
dangerouslySetInnerHTML: {
|
|
1575
1581
|
__html: `window.${WINDOW_DATA_KEY} = ${serialized};`
|
|
1576
1582
|
}
|
|
1583
|
+
}),
|
|
1584
|
+
import_react.default.createElement("script", {
|
|
1585
|
+
nonce,
|
|
1586
|
+
dangerouslySetInnerHTML: {
|
|
1587
|
+
__html: `window.${ROUTER_DATA_KEY} = ${routerSerialized};`
|
|
1588
|
+
}
|
|
1577
1589
|
})
|
|
1578
1590
|
);
|
|
1579
1591
|
return documentTree;
|
|
@@ -1596,6 +1608,15 @@ function buildInitialData(urlPath, params, loaderResult) {
|
|
|
1596
1608
|
};
|
|
1597
1609
|
}
|
|
1598
1610
|
|
|
1611
|
+
// modules/rendering/routerData/index.ts
|
|
1612
|
+
var buildRouterData = (req) => {
|
|
1613
|
+
return {
|
|
1614
|
+
pathname: req.path,
|
|
1615
|
+
params: req.params,
|
|
1616
|
+
searchParams: req.query
|
|
1617
|
+
};
|
|
1618
|
+
};
|
|
1619
|
+
|
|
1599
1620
|
// modules/build/ssg/renderer.ts
|
|
1600
1621
|
init_globals();
|
|
1601
1622
|
async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params) {
|
|
@@ -1649,10 +1670,12 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params)
|
|
|
1649
1670
|
return;
|
|
1650
1671
|
}
|
|
1651
1672
|
const initialData = buildInitialData(urlPath, params, loaderResult);
|
|
1673
|
+
const routerData = buildRouterData(req);
|
|
1652
1674
|
const appTree = buildAppTree(route, params, initialData.props);
|
|
1653
1675
|
const documentTree = createDocumentTree({
|
|
1654
1676
|
appTree,
|
|
1655
1677
|
initialData,
|
|
1678
|
+
routerData,
|
|
1656
1679
|
meta: loaderResult.metadata,
|
|
1657
1680
|
titleFallback: "My Framework Dev",
|
|
1658
1681
|
descriptionFallback: "Static page generated by @lolyjs/core.",
|
|
@@ -4454,6 +4477,7 @@ async function handlePageRequestInternal(options) {
|
|
|
4454
4477
|
}
|
|
4455
4478
|
}
|
|
4456
4479
|
const matched = matchRoute(routes, urlPath);
|
|
4480
|
+
const routerData = buildRouterData(req);
|
|
4457
4481
|
if (!matched) {
|
|
4458
4482
|
if (notFoundPage) {
|
|
4459
4483
|
const ctx2 = {
|
|
@@ -4474,6 +4498,7 @@ async function handlePageRequestInternal(options) {
|
|
|
4474
4498
|
const documentTree2 = createDocumentTree({
|
|
4475
4499
|
appTree: appTree2,
|
|
4476
4500
|
initialData: initialData2,
|
|
4501
|
+
routerData,
|
|
4477
4502
|
meta: loaderResult2.metadata ?? null,
|
|
4478
4503
|
titleFallback: "Not found",
|
|
4479
4504
|
descriptionFallback: "Loly demo",
|
|
@@ -4581,6 +4606,7 @@ async function handlePageRequestInternal(options) {
|
|
|
4581
4606
|
const documentTree = createDocumentTree({
|
|
4582
4607
|
appTree,
|
|
4583
4608
|
initialData,
|
|
4609
|
+
routerData,
|
|
4584
4610
|
meta: loaderResult.metadata,
|
|
4585
4611
|
titleFallback: "Loly framework",
|
|
4586
4612
|
descriptionFallback: "Loly demo",
|
|
@@ -4638,6 +4664,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
4638
4664
|
loaderResult.theme = theme;
|
|
4639
4665
|
}
|
|
4640
4666
|
const initialData = buildInitialData(req.path, { error: String(error) }, loaderResult);
|
|
4667
|
+
const routerData = buildRouterData(req);
|
|
4641
4668
|
initialData.error = true;
|
|
4642
4669
|
if (isDataReq) {
|
|
4643
4670
|
res.statusCode = 500;
|
|
@@ -4668,6 +4695,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
4668
4695
|
const documentTree = createDocumentTree({
|
|
4669
4696
|
appTree,
|
|
4670
4697
|
initialData,
|
|
4698
|
+
routerData,
|
|
4671
4699
|
meta: loaderResult.metadata ?? null,
|
|
4672
4700
|
titleFallback: "Error",
|
|
4673
4701
|
descriptionFallback: "An error occurred",
|
|
@@ -5093,7 +5121,7 @@ async function startProdServer(options = {}) {
|
|
|
5093
5121
|
var import_client5 = require("react-dom/client");
|
|
5094
5122
|
|
|
5095
5123
|
// modules/runtime/client/AppShell.tsx
|
|
5096
|
-
var
|
|
5124
|
+
var import_react3 = require("react");
|
|
5097
5125
|
|
|
5098
5126
|
// modules/runtime/client/RouterView.tsx
|
|
5099
5127
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -5122,6 +5150,10 @@ var dataCache = cacheStore.data;
|
|
|
5122
5150
|
var pathIndex = cacheStore.index;
|
|
5123
5151
|
var lru = cacheStore.lru;
|
|
5124
5152
|
|
|
5153
|
+
// modules/runtime/client/RouterContext.tsx
|
|
5154
|
+
var import_react2 = require("react");
|
|
5155
|
+
var RouterContext = (0, import_react2.createContext)(null);
|
|
5156
|
+
|
|
5125
5157
|
// modules/runtime/client/AppShell.tsx
|
|
5126
5158
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
5127
5159
|
|