@bakery-framework/plugin-vue 2.3.0 → 2.4.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/package.json +2 -2
- package/src/handler.ts +28 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakery-framework/plugin-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Bakery vue plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bakery",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vue": "^3.5.38"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@bakery-framework/core": "^2.
|
|
46
|
+
"@bakery-framework/core": "^2.4.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"bun": ">=1.4.0"
|
package/src/handler.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { readdirSync } from 'node:fs'
|
|
|
2
2
|
import { LRUCache } from '@bakery-framework/core/cache/lru'
|
|
3
3
|
import { Bakery, hostKey } from '@bakery-framework/core/core/bakery'
|
|
4
4
|
import type { Handler } from '@bakery-framework/core/handlers'
|
|
5
|
+
import { routeOf } from '@bakery-framework/core/router'
|
|
5
6
|
import {
|
|
6
7
|
beginPageRoute,
|
|
7
8
|
DynamicErrorHandler,
|
|
@@ -991,8 +992,11 @@ async function sharedHandler(
|
|
|
991
992
|
|
|
992
993
|
// `base` is the URL prefix the page owns: the file's directory. For
|
|
993
994
|
// `wiki/[...page!].vue` that is `/wiki`; for a root-level catch-all it is
|
|
994
|
-
// the empty string, which `defineLayout` treats as "everything".
|
|
995
|
+
// the empty string, which `defineLayout` treats as "everything". On a host
|
|
996
|
+
// that serves `/wiki` at its root, it is spelled the way that host's URLs
|
|
997
|
+
// are: see `baseOnHost`.
|
|
995
998
|
const catchAll = Boolean(info.catchAll)
|
|
999
|
+
const routed = routeOf(req)
|
|
996
1000
|
return VueHandler.handleHtml(
|
|
997
1001
|
id,
|
|
998
1002
|
finalParams,
|
|
@@ -1001,7 +1005,10 @@ async function sharedHandler(
|
|
|
1001
1005
|
parsed,
|
|
1002
1006
|
{
|
|
1003
1007
|
catchAll,
|
|
1004
|
-
base:
|
|
1008
|
+
base: baseOnHost(
|
|
1009
|
+
routePath.slice(0, routePath.lastIndexOf('/')),
|
|
1010
|
+
routed.mount,
|
|
1011
|
+
),
|
|
1005
1012
|
param: info.params.length ? info.params[info.params.length - 1] : null,
|
|
1006
1013
|
// Catch-all pages only: `defineLayout()` refuses every other page, so
|
|
1007
1014
|
// on those the claims would be sibling names published in the HTML with
|
|
@@ -1011,11 +1018,29 @@ async function sharedHandler(
|
|
|
1011
1018
|
// The page's own URL routes back to this component; see `assetPath`. An
|
|
1012
1019
|
// error render is the exception: its URL is the one that failed, and it
|
|
1013
1020
|
// would route to the error, not to the error page's component.
|
|
1014
|
-
|
|
1021
|
+
//
|
|
1022
|
+
// The URL as the app names it, which on a mounted host is not the one in
|
|
1023
|
+
// the address bar: `/kit/forms` for a page at `/forms`. The stylesheet and
|
|
1024
|
+
// root script requests are not page requests, so the router serves them
|
|
1025
|
+
// from the app's root, where only the app's spelling reaches the page.
|
|
1026
|
+
errorData ? routePath : routed.path,
|
|
1015
1027
|
built,
|
|
1016
1028
|
)
|
|
1017
1029
|
}
|
|
1018
1030
|
|
|
1031
|
+
/**
|
|
1032
|
+
* `base` as a host serving `mount` at its root spells it: `/kit/forms` is
|
|
1033
|
+
* `/forms` there, and `/kit` itself is `''`, which `defineLayout()` reads as
|
|
1034
|
+
* the whole host. A base outside the mount (a catch-all above it, answering a
|
|
1035
|
+
* path the subtree has no page for) has no spelling without the prefix, and
|
|
1036
|
+
* is left as it is.
|
|
1037
|
+
*/
|
|
1038
|
+
function baseOnHost(base: string, mount: string | null): string {
|
|
1039
|
+
if (!mount) return base
|
|
1040
|
+
if (base === mount) return ''
|
|
1041
|
+
return base.startsWith(`${mount}/`) ? base.slice(mount.length) : base
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1019
1044
|
/**
|
|
1020
1045
|
* The exports of the server blocks of the components a built page reaches,
|
|
1021
1046
|
* keyed by route path, for the page's HTML.
|