@lolyjs/core 0.2.0-alpha.3 → 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/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 +29 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +29 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +86 -1
- 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 +86 -1
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.cjs +98 -22
- package/dist/react/hooks.cjs.map +1 -1
- package/dist/react/hooks.d.mts +5 -0
- package/dist/react/hooks.d.ts +5 -0
- package/dist/react/hooks.js +99 -23
- package/dist/react/hooks.js.map +1 -1
- package/dist/runtime.cjs +57 -0
- 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 +57 -0
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -42,17 +42,19 @@ __export(globals_exports, {
|
|
|
42
42
|
NOT_FOUND_FILE_PREFIX: () => NOT_FOUND_FILE_PREFIX,
|
|
43
43
|
NOT_FOUND_PATTERN: () => NOT_FOUND_PATTERN,
|
|
44
44
|
PAGE_FILE_NAME: () => PAGE_FILE_NAME,
|
|
45
|
+
ROUTER_DATA_KEY: () => ROUTER_DATA_KEY,
|
|
45
46
|
STATIC_PATH: () => STATIC_PATH,
|
|
46
47
|
STYLE_FILE_NAME: () => STYLE_FILE_NAME,
|
|
47
48
|
WINDOW_DATA_KEY: () => WINDOW_DATA_KEY
|
|
48
49
|
});
|
|
49
|
-
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;
|
|
50
|
+
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;
|
|
50
51
|
var init_globals = __esm({
|
|
51
52
|
"constants/globals.ts"() {
|
|
52
53
|
"use strict";
|
|
53
54
|
BUILD_FOLDER_NAME = ".loly";
|
|
54
55
|
STYLE_FILE_NAME = "styles.css";
|
|
55
56
|
WINDOW_DATA_KEY = "__FW_DATA__";
|
|
57
|
+
ROUTER_DATA_KEY = "__LOLY_ROUTER_DATA__";
|
|
56
58
|
APP_CONTAINER_ID = "__app";
|
|
57
59
|
STATIC_PATH = "/static";
|
|
58
60
|
NOT_FOUND_PATTERN = "/not-found";
|
|
@@ -1485,6 +1487,7 @@ function createDocumentTree(options) {
|
|
|
1485
1487
|
const {
|
|
1486
1488
|
appTree,
|
|
1487
1489
|
initialData,
|
|
1490
|
+
routerData,
|
|
1488
1491
|
meta,
|
|
1489
1492
|
titleFallback,
|
|
1490
1493
|
descriptionFallback,
|
|
@@ -1522,6 +1525,9 @@ function createDocumentTree(options) {
|
|
|
1522
1525
|
...initialData,
|
|
1523
1526
|
theme
|
|
1524
1527
|
});
|
|
1528
|
+
const routerSerialized = JSON.stringify({
|
|
1529
|
+
...routerData
|
|
1530
|
+
});
|
|
1525
1531
|
const documentTree = React.createElement(
|
|
1526
1532
|
"html",
|
|
1527
1533
|
{ lang },
|
|
@@ -1569,6 +1575,12 @@ function createDocumentTree(options) {
|
|
|
1569
1575
|
dangerouslySetInnerHTML: {
|
|
1570
1576
|
__html: `window.${WINDOW_DATA_KEY} = ${serialized};`
|
|
1571
1577
|
}
|
|
1578
|
+
}),
|
|
1579
|
+
React.createElement("script", {
|
|
1580
|
+
nonce,
|
|
1581
|
+
dangerouslySetInnerHTML: {
|
|
1582
|
+
__html: `window.${ROUTER_DATA_KEY} = ${routerSerialized};`
|
|
1583
|
+
}
|
|
1572
1584
|
})
|
|
1573
1585
|
);
|
|
1574
1586
|
return documentTree;
|
|
@@ -1591,6 +1603,15 @@ function buildInitialData(urlPath, params, loaderResult) {
|
|
|
1591
1603
|
};
|
|
1592
1604
|
}
|
|
1593
1605
|
|
|
1606
|
+
// modules/rendering/routerData/index.ts
|
|
1607
|
+
var buildRouterData = (req) => {
|
|
1608
|
+
return {
|
|
1609
|
+
pathname: req.path,
|
|
1610
|
+
params: req.params,
|
|
1611
|
+
searchParams: req.query
|
|
1612
|
+
};
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1594
1615
|
// modules/build/ssg/renderer.ts
|
|
1595
1616
|
init_globals();
|
|
1596
1617
|
async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params) {
|
|
@@ -1644,10 +1665,12 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params)
|
|
|
1644
1665
|
return;
|
|
1645
1666
|
}
|
|
1646
1667
|
const initialData = buildInitialData(urlPath, params, loaderResult);
|
|
1668
|
+
const routerData = buildRouterData(req);
|
|
1647
1669
|
const appTree = buildAppTree(route, params, initialData.props);
|
|
1648
1670
|
const documentTree = createDocumentTree({
|
|
1649
1671
|
appTree,
|
|
1650
1672
|
initialData,
|
|
1673
|
+
routerData,
|
|
1651
1674
|
meta: loaderResult.metadata,
|
|
1652
1675
|
titleFallback: "My Framework Dev",
|
|
1653
1676
|
descriptionFallback: "Static page generated by @lolyjs/core.",
|
|
@@ -4449,6 +4472,7 @@ async function handlePageRequestInternal(options) {
|
|
|
4449
4472
|
}
|
|
4450
4473
|
}
|
|
4451
4474
|
const matched = matchRoute(routes, urlPath);
|
|
4475
|
+
const routerData = buildRouterData(req);
|
|
4452
4476
|
if (!matched) {
|
|
4453
4477
|
if (notFoundPage) {
|
|
4454
4478
|
const ctx2 = {
|
|
@@ -4469,6 +4493,7 @@ async function handlePageRequestInternal(options) {
|
|
|
4469
4493
|
const documentTree2 = createDocumentTree({
|
|
4470
4494
|
appTree: appTree2,
|
|
4471
4495
|
initialData: initialData2,
|
|
4496
|
+
routerData,
|
|
4472
4497
|
meta: loaderResult2.metadata ?? null,
|
|
4473
4498
|
titleFallback: "Not found",
|
|
4474
4499
|
descriptionFallback: "Loly demo",
|
|
@@ -4576,6 +4601,7 @@ async function handlePageRequestInternal(options) {
|
|
|
4576
4601
|
const documentTree = createDocumentTree({
|
|
4577
4602
|
appTree,
|
|
4578
4603
|
initialData,
|
|
4604
|
+
routerData,
|
|
4579
4605
|
meta: loaderResult.metadata,
|
|
4580
4606
|
titleFallback: "Loly framework",
|
|
4581
4607
|
descriptionFallback: "Loly demo",
|
|
@@ -4633,6 +4659,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
4633
4659
|
loaderResult.theme = theme;
|
|
4634
4660
|
}
|
|
4635
4661
|
const initialData = buildInitialData(req.path, { error: String(error) }, loaderResult);
|
|
4662
|
+
const routerData = buildRouterData(req);
|
|
4636
4663
|
initialData.error = true;
|
|
4637
4664
|
if (isDataReq) {
|
|
4638
4665
|
res.statusCode = 500;
|
|
@@ -4663,6 +4690,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
|
|
|
4663
4690
|
const documentTree = createDocumentTree({
|
|
4664
4691
|
appTree,
|
|
4665
4692
|
initialData,
|
|
4693
|
+
routerData,
|
|
4666
4694
|
meta: loaderResult.metadata ?? null,
|
|
4667
4695
|
titleFallback: "Error",
|
|
4668
4696
|
descriptionFallback: "An error occurred",
|