vike-lite 1.4.0 → 1.5.0
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/README.md +1 -7
- package/dist/__internal/server.d.mts +1 -1
- package/dist/__internal/shared.d.mts +1 -1
- package/dist/__internal/shared.mjs +1 -1
- package/dist/{index-kftPCG4J.d.mts → index-Dt5n1zWh.d.mts} +2 -2
- package/dist/{matchRoute-BNUQpQu-.mjs → matchRoute-nTNPxoMq.mjs} +12 -6
- package/dist/server.mjs +1 -1
- package/dist/vite.mjs +11 -4
- package/package.json +1 -1
- package/LICENSE +0 -9
package/README.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# vike-lite
|
|
2
2
|
|
|
3
|
-
Light version of [Vike](https://vike.dev)
|
|
4
|
-
|
|
5
|
-
### ✨ Features
|
|
6
|
-
❯ **Zero dependencies:**<br> _light_ with less dependencies and essential checks
|
|
7
|
-
❯ **Functionalities:**<br> [See documentation](doc/FUNCTIONALITIES.md)
|
|
8
|
-
|
|
9
3
|
### ⚙️ Install
|
|
10
4
|
| Package Manager | Command
|
|
11
5
|
| - | -
|
|
@@ -79,4 +73,4 @@ git clone https://github.com/node-ecosystem/vike-lite.git
|
|
|
79
73
|
|
|
80
74
|
---
|
|
81
75
|
|
|
82
|
-
This project is licensed under the [MIT License](LICENSE).
|
|
76
|
+
This project is licensed under the [MIT License](../../LICENSE).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RenderContext, r as matchRoute, t as Config } from "../index-
|
|
1
|
+
import { n as RenderContext, r as matchRoute, t as Config } from "../index-Dt5n1zWh.mjs";
|
|
2
2
|
export { Config, RenderContext, matchRoute };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as matchRoute } from "../matchRoute-
|
|
1
|
+
import { t as matchRoute } from "../matchRoute-nTNPxoMq.mjs";
|
|
2
2
|
export { matchRoute };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//#region src/shared/matchRoute.d.ts
|
|
1
|
+
//#region src/__internal/shared/matchRoute.d.ts
|
|
2
2
|
declare function matchRoute(urlPathname: string, routes: typeof import('virtual:routes').routes): {
|
|
3
3
|
route: any;
|
|
4
4
|
routeParams: Record<string, string>;
|
|
5
5
|
} | null;
|
|
6
6
|
//#endregion
|
|
7
|
-
//#region src/shared/index.d.ts
|
|
7
|
+
//#region src/__internal/shared/index.d.ts
|
|
8
8
|
interface RenderContext {
|
|
9
9
|
pageContext: any;
|
|
10
10
|
Page: unknown;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
//#region src/shared/matchRoute.ts
|
|
1
|
+
//#region src/__internal/shared/matchRoute.ts
|
|
2
2
|
const regexCache = /* @__PURE__ */ new Map();
|
|
3
|
+
function escapeRegex(str) {
|
|
4
|
+
return str.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
5
|
+
}
|
|
3
6
|
function matchRoute(urlPathname, routes) {
|
|
4
7
|
for (const route of routes) {
|
|
5
8
|
if (!route.path.includes(":")) {
|
|
@@ -12,10 +15,13 @@ function matchRoute(urlPathname, routes) {
|
|
|
12
15
|
let compiled = regexCache.get(route.path);
|
|
13
16
|
if (!compiled) {
|
|
14
17
|
const paramNames = [];
|
|
15
|
-
const regexPath = route.path.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const regexPath = route.path.split("/").map((segment) => {
|
|
19
|
+
if (segment.startsWith(":")) {
|
|
20
|
+
paramNames.push(segment.slice(1));
|
|
21
|
+
return "([^/]+)";
|
|
22
|
+
}
|
|
23
|
+
return escapeRegex(segment);
|
|
24
|
+
}).join("/");
|
|
19
25
|
compiled = {
|
|
20
26
|
regex: new RegExp(`^${regexPath}/?$`),
|
|
21
27
|
paramNames
|
|
@@ -25,7 +31,7 @@ function matchRoute(urlPathname, routes) {
|
|
|
25
31
|
const match = urlPathname.match(compiled.regex);
|
|
26
32
|
if (match) {
|
|
27
33
|
const routeParams = {};
|
|
28
|
-
for (let i = 0; i < compiled.paramNames.length; i++) routeParams[compiled.paramNames[i]] = match[i + 1];
|
|
34
|
+
for (let i = 0; i < compiled.paramNames.length; i++) routeParams[compiled.paramNames[i]] = decodeURIComponent(match[i + 1]);
|
|
29
35
|
return {
|
|
30
36
|
route,
|
|
31
37
|
routeParams
|
package/dist/server.mjs
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -198,15 +198,13 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
198
198
|
import { onRenderClient } from '${virtualRendererId}';
|
|
199
199
|
const { default: render } = await onRenderClient();
|
|
200
200
|
await render({ routes, errorRoute });`;
|
|
201
|
-
if (id === resolvedVirtualSetupId) return `
|
|
202
|
-
import { routes, errorRoute, config } from '${virtualModuleId}';
|
|
201
|
+
if (id === resolvedVirtualSetupId) return `import { routes, errorRoute, config } from '${virtualModuleId}';
|
|
203
202
|
import { setVikeState } from 'vike-lite/__internal/server';
|
|
204
203
|
let manifest;
|
|
205
204
|
if (process.env.NODE_ENV === 'production') {
|
|
206
205
|
manifest = (await import('${virtualManifestId}')).default;
|
|
207
206
|
}
|
|
208
|
-
setVikeState({ routes, errorRoute, config, manifest })
|
|
209
|
-
`;
|
|
207
|
+
setVikeState({ routes, errorRoute, config, manifest });`;
|
|
210
208
|
if (id === resolvedVirtualEntryServerId) {
|
|
211
209
|
const extensions = [
|
|
212
210
|
".ts",
|
|
@@ -315,6 +313,15 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
315
313
|
},
|
|
316
314
|
configureServer(server) {
|
|
317
315
|
return () => {
|
|
316
|
+
const pagesPath = path.resolve(viteConfigRoot, pagesDir);
|
|
317
|
+
server.watcher.on("all", (event, file) => {
|
|
318
|
+
if (!((event === "add" || event === "unlink") && file.startsWith(pagesPath))) return;
|
|
319
|
+
for (const env of Object.values(server.environments)) {
|
|
320
|
+
const mod = env.moduleGraph.getModuleById(resolvedVirtualModuleId);
|
|
321
|
+
if (mod) env.moduleGraph.invalidateModule(mod);
|
|
322
|
+
}
|
|
323
|
+
server.ws.send({ type: "full-reload" });
|
|
324
|
+
});
|
|
318
325
|
server.middlewares.use(async (req, res, next) => {
|
|
319
326
|
try {
|
|
320
327
|
const { default: app } = await server.environments.ssr.runner.import(resolvedVirtualEntryServerId);
|
package/package.json
CHANGED
package/LICENSE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-present node-ecosystem
|
|
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.
|