vike-lite 1.3.1 → 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 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,4 +1,4 @@
1
- import { t as Config } from "../index-kftPCG4J.mjs";
1
+ import { t as Config } from "../index-Dt5n1zWh.mjs";
2
2
 
3
3
  //#region src/server/store.d.ts
4
4
  interface VikeState {
@@ -1,2 +1,2 @@
1
- import { n as RenderContext, r as matchRoute, t as Config } from "../index-kftPCG4J.mjs";
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-BNUQpQu-.mjs";
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.replaceAll(/:([^/]+)/g, (_, name) => {
16
- paramNames.push(name);
17
- return "([^/]+)";
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
@@ -1,4 +1,4 @@
1
- import { t as matchRoute } from "./matchRoute-BNUQpQu-.mjs";
1
+ import { t as matchRoute } from "./matchRoute-nTNPxoMq.mjs";
2
2
  import { n as store } from "./store-CfUB1COP.mjs";
3
3
  //#region src/utils/serializeContext.ts
4
4
  const ESCAPE_LOOKUP = {
package/dist/vite.mjs CHANGED
@@ -109,6 +109,7 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
109
109
  const { emptyOutDir, minify = true, cssMinify = true, sourcemap } = config.build || {};
110
110
  return {
111
111
  appType: "custom",
112
+ ssr: { noExternal: [/^vike-lite(?:$|-)/] },
112
113
  environments: {
113
114
  client: { build: {
114
115
  outDir: path.join(outDir, "client"),
@@ -197,15 +198,13 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
197
198
  import { onRenderClient } from '${virtualRendererId}';
198
199
  const { default: render } = await onRenderClient();
199
200
  await render({ routes, errorRoute });`;
200
- if (id === resolvedVirtualSetupId) return `
201
- import { routes, errorRoute, config } from '${virtualModuleId}';
201
+ if (id === resolvedVirtualSetupId) return `import { routes, errorRoute, config } from '${virtualModuleId}';
202
202
  import { setVikeState } from 'vike-lite/__internal/server';
203
203
  let manifest;
204
204
  if (process.env.NODE_ENV === 'production') {
205
205
  manifest = (await import('${virtualManifestId}')).default;
206
206
  }
207
- setVikeState({ routes, errorRoute, config, manifest });
208
- `;
207
+ setVikeState({ routes, errorRoute, config, manifest });`;
209
208
  if (id === resolvedVirtualEntryServerId) {
210
209
  const extensions = [
211
210
  ".ts",
@@ -314,6 +313,15 @@ if (process.env.NODE_ENV === 'production') {
314
313
  },
315
314
  configureServer(server) {
316
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
+ });
317
325
  server.middlewares.use(async (req, res, next) => {
318
326
  try {
319
327
  const { default: app } = await server.environments.ssr.runner.import(resolvedVirtualEntryServerId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-lite",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
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.