@bakery-framework/plugin-vue 2.2.1 → 2.2.2
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 +7 -1
- package/src/shell.ts +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakery-framework/plugin-vue",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
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.2.
|
|
46
|
+
"@bakery-framework/core": "^2.2.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"bun": ">=1.4.0"
|
package/src/handler.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
parseVue,
|
|
33
33
|
vueBuildVariant,
|
|
34
34
|
} from './compile'
|
|
35
|
-
import { VUE_HTML_SHELL } from './shell'
|
|
35
|
+
import { declaresViewport, VIEWPORT_META, VUE_HTML_SHELL } from './shell'
|
|
36
36
|
import type { ParsedCacheEntry, VueMeta } from './types'
|
|
37
37
|
import {
|
|
38
38
|
cacheDir,
|
|
@@ -709,6 +709,12 @@ export class VueHandler extends DynamicHandler {
|
|
|
709
709
|
() => serverDecl + moduleDecl + routeDecl,
|
|
710
710
|
)
|
|
711
711
|
|
|
712
|
+
// An app's own viewport, through `head`, would lose to the shell's: see
|
|
713
|
+
// `declaresViewport`.
|
|
714
|
+
if (declaresViewport(Bakery.config.head)) {
|
|
715
|
+
hydrated = hydrated.replace(VIEWPORT_META, '')
|
|
716
|
+
}
|
|
717
|
+
|
|
712
718
|
// Static markup, injected verbatim. See parseSkeleton for why it is
|
|
713
719
|
// never rendered. mount() replaces the container children, so it
|
|
714
720
|
// disappears the moment the real component is up.
|
package/src/shell.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page's default viewport. Without one a phone lays the page out 980 px
|
|
3
|
+
* wide and no `max-width` media query applies (measured in Chrome under 390 px
|
|
4
|
+
* emulation: `innerWidth` 980, and 390 with this tag).
|
|
5
|
+
*/
|
|
6
|
+
export const VIEWPORT_META =
|
|
7
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Whether `head` markup declares a viewport of its own.
|
|
11
|
+
*
|
|
12
|
+
* The host's `head` is spliced in right after `<head>`, ahead of the shell's
|
|
13
|
+
* own tags, and of two viewport metas Chrome honors the later one (measured:
|
|
14
|
+
* `width=600` after `device-width` reads 600, before it 390). So the default
|
|
15
|
+
* above would override an app's own, and the handler drops it instead.
|
|
16
|
+
*/
|
|
17
|
+
export function declaresViewport(head: string | undefined): boolean {
|
|
18
|
+
return !!head && /<meta\b[^>]*\sname\s*=\s*["']?viewport\b/i.test(head)
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
export const VUE_HTML_SHELL = `
|
|
2
22
|
<!DOCTYPE html>
|
|
3
23
|
<html lang="en">
|
|
4
24
|
|
|
5
25
|
<head>
|
|
6
26
|
<meta charset="UTF-8">
|
|
27
|
+
${VIEWPORT_META}
|
|
7
28
|
<title>Vue App</title>
|
|
8
29
|
/*__SERVER_VARIABLES__*/
|
|
9
30
|
</head>
|