@unhead/svelte 3.0.0-beta.9 → 3.0.0-rc.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/client.d.mts +4 -3
- package/dist/client.d.ts +4 -3
- package/dist/stream/vite.mjs +6 -3
- package/dist/vite.d.mts +33 -0
- package/dist/vite.d.ts +33 -0
- package/dist/vite.mjs +16 -0
- package/package.json +15 -7
package/dist/client.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientUnhead } from 'unhead/client';
|
|
2
|
+
export { renderDOMHead } from 'unhead/client';
|
|
3
|
+
import { CreateClientHeadOptions } from 'unhead/types';
|
|
2
4
|
export { CreateClientHeadOptions, Unhead } from 'unhead/types';
|
|
3
5
|
export { UnheadContextKey } from './server.mjs';
|
|
4
|
-
export { renderDOMHead } from 'unhead/client';
|
|
5
6
|
import 'unhead/server';
|
|
6
7
|
|
|
7
|
-
declare function createHead(options?: CreateClientHeadOptions):
|
|
8
|
+
declare function createHead(options?: CreateClientHeadOptions): ClientUnhead;
|
|
8
9
|
|
|
9
10
|
export { createHead };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientUnhead } from 'unhead/client';
|
|
2
|
+
export { renderDOMHead } from 'unhead/client';
|
|
3
|
+
import { CreateClientHeadOptions } from 'unhead/types';
|
|
2
4
|
export { CreateClientHeadOptions, Unhead } from 'unhead/types';
|
|
3
5
|
export { UnheadContextKey } from './server.js';
|
|
4
|
-
export { renderDOMHead } from 'unhead/client';
|
|
5
6
|
import 'unhead/server';
|
|
6
7
|
|
|
7
|
-
declare function createHead(options?: CreateClientHeadOptions):
|
|
8
|
+
declare function createHead(options?: CreateClientHeadOptions): ClientUnhead;
|
|
8
9
|
|
|
9
10
|
export { createHead };
|
package/dist/stream/vite.mjs
CHANGED
|
@@ -2,16 +2,19 @@ import MagicString from 'magic-string';
|
|
|
2
2
|
import { parseAndWalk } from 'oxc-walker';
|
|
3
3
|
import { createStreamingPlugin } from 'unhead/stream/vite';
|
|
4
4
|
|
|
5
|
+
const SCRIPT_CLOSE_RE = /<\/script>/;
|
|
6
|
+
const SCRIPT_RE = /<script[^>]*>/i;
|
|
7
|
+
const FILTER_RE = /\.svelte$/;
|
|
5
8
|
function transform(code, id, isSSR, s) {
|
|
6
9
|
if (!code.includes("useHead") && !code.includes("useSeoMeta") && !code.includes("useHeadSafe"))
|
|
7
10
|
return false;
|
|
8
|
-
const scriptCloseMatch = code.match(
|
|
11
|
+
const scriptCloseMatch = code.match(SCRIPT_CLOSE_RE);
|
|
9
12
|
if (!scriptCloseMatch)
|
|
10
13
|
return false;
|
|
11
14
|
const templateStart = scriptCloseMatch.index + scriptCloseMatch[0].length;
|
|
12
15
|
s.appendRight(templateStart, "\n{@html HeadStream()}");
|
|
13
16
|
const importPath = `@unhead/svelte/stream/${isSSR ? "server" : "client"}`;
|
|
14
|
-
const scriptMatch = code.match(
|
|
17
|
+
const scriptMatch = code.match(SCRIPT_RE);
|
|
15
18
|
if (!scriptMatch)
|
|
16
19
|
return true;
|
|
17
20
|
const scriptEnd = scriptMatch.index + scriptMatch[0].length;
|
|
@@ -49,7 +52,7 @@ import { HeadStream } from '${importPath}'`);
|
|
|
49
52
|
function unheadSveltePlugin(options) {
|
|
50
53
|
return createStreamingPlugin({
|
|
51
54
|
framework: "@unhead/svelte",
|
|
52
|
-
filter:
|
|
55
|
+
filter: FILTER_RE,
|
|
53
56
|
mode: options?.mode,
|
|
54
57
|
transform(code, id, opts) {
|
|
55
58
|
const s = new MagicString(code);
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { VitePluginOptions } from '@unhead/bundler/vite';
|
|
2
|
+
import { StreamingPluginOptions } from 'unhead/stream/vite';
|
|
3
|
+
import { Plugin } from 'vite';
|
|
4
|
+
|
|
5
|
+
interface UnheadSvelteViteOptions extends VitePluginOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Enable streaming SSR support.
|
|
8
|
+
* Set to `true` or a config object to enable.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
streaming?: true | Pick<StreamingPluginOptions, 'mode'> | false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Unified Vite plugin for `@unhead/svelte`.
|
|
15
|
+
*
|
|
16
|
+
* Combines build optimizations (tree-shaking, useSeoMeta transform, minification)
|
|
17
|
+
* with streaming SSR support into a single plugin.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // vite.config.ts
|
|
22
|
+
* import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
23
|
+
* import { Unhead } from '@unhead/svelte/vite'
|
|
24
|
+
*
|
|
25
|
+
* export default defineConfig({
|
|
26
|
+
* plugins: [Unhead(), svelte()],
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function Unhead(options?: UnheadSvelteViteOptions): Plugin[];
|
|
31
|
+
|
|
32
|
+
export { Unhead };
|
|
33
|
+
export type { UnheadSvelteViteOptions };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { VitePluginOptions } from '@unhead/bundler/vite';
|
|
2
|
+
import { StreamingPluginOptions } from 'unhead/stream/vite';
|
|
3
|
+
import { Plugin } from 'vite';
|
|
4
|
+
|
|
5
|
+
interface UnheadSvelteViteOptions extends VitePluginOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Enable streaming SSR support.
|
|
8
|
+
* Set to `true` or a config object to enable.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
streaming?: true | Pick<StreamingPluginOptions, 'mode'> | false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Unified Vite plugin for `@unhead/svelte`.
|
|
15
|
+
*
|
|
16
|
+
* Combines build optimizations (tree-shaking, useSeoMeta transform, minification)
|
|
17
|
+
* with streaming SSR support into a single plugin.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // vite.config.ts
|
|
22
|
+
* import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
23
|
+
* import { Unhead } from '@unhead/svelte/vite'
|
|
24
|
+
*
|
|
25
|
+
* export default defineConfig({
|
|
26
|
+
* plugins: [Unhead(), svelte()],
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function Unhead(options?: UnheadSvelteViteOptions): Plugin[];
|
|
31
|
+
|
|
32
|
+
export { Unhead };
|
|
33
|
+
export type { UnheadSvelteViteOptions };
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Unhead as Unhead$1 } from '@unhead/bundler/vite';
|
|
2
|
+
import unheadSveltePlugin from './stream/vite.mjs';
|
|
3
|
+
import 'magic-string';
|
|
4
|
+
import 'oxc-walker';
|
|
5
|
+
import 'unhead/stream/vite';
|
|
6
|
+
|
|
7
|
+
function Unhead(options = {}) {
|
|
8
|
+
const plugins = [...Unhead$1({ ...options, _framework: "@unhead/svelte" })];
|
|
9
|
+
if (options.streaming) {
|
|
10
|
+
const streamingOpts = typeof options.streaming === "object" ? options.streaming : void 0;
|
|
11
|
+
plugins.push(unheadSveltePlugin(streamingOpts));
|
|
12
|
+
}
|
|
13
|
+
return plugins;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { Unhead };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-
|
|
4
|
+
"version": "3.0.0-rc.4",
|
|
5
5
|
"description": "Full-stack <head> manager built for Svelte.",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
"types": "./dist/plugins.d.ts",
|
|
46
46
|
"default": "./dist/plugins.mjs"
|
|
47
47
|
},
|
|
48
|
+
"./vite": {
|
|
49
|
+
"types": "./dist/vite.d.ts",
|
|
50
|
+
"default": "./dist/vite.mjs"
|
|
51
|
+
},
|
|
48
52
|
"./stream/vite": {
|
|
49
53
|
"types": "./dist/stream/vite.d.ts",
|
|
50
54
|
"default": "./dist/stream/vite.mjs"
|
|
@@ -73,6 +77,9 @@
|
|
|
73
77
|
"utils": [
|
|
74
78
|
"dist/utils"
|
|
75
79
|
],
|
|
80
|
+
"vite": [
|
|
81
|
+
"dist/vite"
|
|
82
|
+
],
|
|
76
83
|
"stream/vite": [
|
|
77
84
|
"dist/stream/vite"
|
|
78
85
|
]
|
|
@@ -84,7 +91,7 @@
|
|
|
84
91
|
],
|
|
85
92
|
"peerDependencies": {
|
|
86
93
|
"svelte": ">=5.38.0",
|
|
87
|
-
"vite": ">=6"
|
|
94
|
+
"vite": ">=6.4.2"
|
|
88
95
|
},
|
|
89
96
|
"peerDependenciesMeta": {
|
|
90
97
|
"vite": {
|
|
@@ -98,15 +105,16 @@
|
|
|
98
105
|
},
|
|
99
106
|
"dependencies": {
|
|
100
107
|
"magic-string": "^0.30.21",
|
|
101
|
-
"oxc-parser": "^0.
|
|
108
|
+
"oxc-parser": "^0.124.0",
|
|
102
109
|
"oxc-walker": "^0.7.0",
|
|
103
|
-
"unhead": "3.0.0-
|
|
110
|
+
"@unhead/bundler": "3.0.0-rc.4",
|
|
111
|
+
"unhead": "3.0.0-rc.4"
|
|
104
112
|
},
|
|
105
113
|
"devDependencies": {
|
|
106
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
114
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
107
115
|
"@testing-library/svelte": "^5.3.1",
|
|
108
|
-
"svelte": "^5.
|
|
109
|
-
"vite": "^
|
|
116
|
+
"svelte": "^5.55.2",
|
|
117
|
+
"vite": "^8.0.8"
|
|
110
118
|
},
|
|
111
119
|
"scripts": {
|
|
112
120
|
"build": "unbuild .",
|