@unhead/solid-js 3.0.0-beta.9 → 3.0.0-rc.3

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 CHANGED
@@ -1,10 +1,11 @@
1
- import { CreateClientHeadOptions, Unhead } from 'unhead/types';
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 { UnheadContext } from './server.mjs';
4
- export { renderDOMHead } from 'unhead/client';
5
6
  import 'solid-js';
6
7
  import 'unhead/server';
7
8
 
8
- declare function createHead(options?: CreateClientHeadOptions): Unhead;
9
+ declare function createHead(options?: CreateClientHeadOptions): ClientUnhead;
9
10
 
10
11
  export { createHead };
package/dist/client.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { CreateClientHeadOptions, Unhead } from 'unhead/types';
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 { UnheadContext } from './server.js';
4
- export { renderDOMHead } from 'unhead/client';
5
6
  import 'solid-js';
6
7
  import 'unhead/server';
7
8
 
8
- declare function createHead(options?: CreateClientHeadOptions): Unhead;
9
+ declare function createHead(options?: CreateClientHeadOptions): ClientUnhead;
9
10
 
10
11
  export { createHead };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { onMount, onCleanup, useContext, createSignal, createEffect } from 'solid-js';
1
+ import { onMount, onCleanup, useContext, getOwner, runWithOwner, createSignal, createEffect } from 'solid-js';
2
2
  import { isServer } from 'solid-js/web';
3
3
  import { useScript as useScript$1, useHead as useHead$1, useHeadSafe as useHeadSafe$1, useSeoMeta as useSeoMeta$1 } from 'unhead';
4
4
  import { U as UnheadContext } from './shared/solid-js.BJ7JZ7E-.mjs';
@@ -21,6 +21,13 @@ function useUnhead() {
21
21
  }
22
22
  function withSideEffects(input, options, fn) {
23
23
  const unhead = options.head || useUnhead();
24
+ if (options.onRendered && !isServer) {
25
+ const owner = getOwner();
26
+ if (owner) {
27
+ const _onRendered = options.onRendered;
28
+ options = { ...options, onRendered: (ctx) => runWithOwner(owner, () => _onRendered(ctx)) };
29
+ }
30
+ }
24
31
  const entry = fn(unhead, input, options);
25
32
  if (!isServer) {
26
33
  const [entrySignal] = createSignal(entry);
@@ -1,14 +1,14 @@
1
- import { Unhead, CreateStreamableServerHeadOptions } from 'unhead/types';
1
+ import { ServerUnhead } from 'unhead/server';
2
+ import { CreateStreamableServerHeadOptions } from 'unhead/types';
2
3
  export { UnheadContext } from '../server.mjs';
3
4
  export { StreamingTemplateParts, WebStreamableHeadContext, prepareStreamingTemplate, renderSSRHeadShell, renderSSRHeadSuspenseChunk, wrapStream } from 'unhead/stream/server';
4
5
  import 'solid-js';
5
- import 'unhead/server';
6
6
 
7
7
  /**
8
8
  * Solid-js streaming context returned by createStreamableHead.
9
9
  */
10
10
  interface SolidStreamableHeadContext {
11
- head: Unhead;
11
+ head: ServerUnhead;
12
12
  /**
13
13
  * Callback to pass to renderToStream's onCompleteShell option.
14
14
  * This captures head entries from shell components before streaming starts.
@@ -1,14 +1,14 @@
1
- import { Unhead, CreateStreamableServerHeadOptions } from 'unhead/types';
1
+ import { ServerUnhead } from 'unhead/server';
2
+ import { CreateStreamableServerHeadOptions } from 'unhead/types';
2
3
  export { UnheadContext } from '../server.js';
3
4
  export { StreamingTemplateParts, WebStreamableHeadContext, prepareStreamingTemplate, renderSSRHeadShell, renderSSRHeadSuspenseChunk, wrapStream } from 'unhead/stream/server';
4
5
  import 'solid-js';
5
- import 'unhead/server';
6
6
 
7
7
  /**
8
8
  * Solid-js streaming context returned by createStreamableHead.
9
9
  */
10
10
  interface SolidStreamableHeadContext {
11
- head: Unhead;
11
+ head: ServerUnhead;
12
12
  /**
13
13
  * Callback to pass to renderToStream's onCompleteShell option.
14
14
  * This captures head entries from shell components before streaming starts.
@@ -1,6 +1,6 @@
1
1
  import { useContext } from 'solid-js';
2
2
  import { ssr } from 'solid-js/web';
3
- import { createStreamableHead as createStreamableHead$1, prepareStreamingTemplate, renderSSRHeadSuspenseChunk } from 'unhead/stream/server';
3
+ import { renderSSRHeadSuspenseChunk, createStreamableHead as createStreamableHead$1, prepareStreamingTemplate } from 'unhead/stream/server';
4
4
  export { prepareStreamingTemplate, renderSSRHeadShell, renderSSRHeadSuspenseChunk, wrapStream } from 'unhead/stream/server';
5
5
  import { U as UnheadContext } from '../shared/solid-js.BJ7JZ7E-.mjs';
6
6
 
@@ -2,6 +2,7 @@ import MagicString from 'magic-string';
2
2
  import { parseAndWalk } from 'oxc-walker';
3
3
  import { createStreamingPlugin } from 'unhead/stream/vite';
4
4
 
5
+ const FILTER_RE = /\.[jt]sx$/;
5
6
  function transform(code, id, isSSR, s) {
6
7
  const lang = id.endsWith(".tsx") ? "tsx" : id.endsWith(".jsx") ? "jsx" : "tsx";
7
8
  const returns = [];
@@ -84,7 +85,7 @@ import { HeadStream } from '${importPath}'`);
84
85
  function unheadSolidPlugin(options) {
85
86
  return createStreamingPlugin({
86
87
  framework: "@unhead/solid-js",
87
- filter: /\.[jt]sx$/,
88
+ filter: FILTER_RE,
88
89
  mode: options?.mode,
89
90
  transform(code, id, opts) {
90
91
  const s = new MagicString(code);
@@ -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 UnheadSolidViteOptions 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/solid-js`.
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 solid from 'vite-plugin-solid'
23
+ * import { Unhead } from '@unhead/solid-js/vite'
24
+ *
25
+ * export default defineConfig({
26
+ * plugins: [Unhead(), solid()],
27
+ * })
28
+ * ```
29
+ */
30
+ declare function Unhead(options?: UnheadSolidViteOptions): Plugin[];
31
+
32
+ export { Unhead };
33
+ export type { UnheadSolidViteOptions };
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 UnheadSolidViteOptions 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/solid-js`.
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 solid from 'vite-plugin-solid'
23
+ * import { Unhead } from '@unhead/solid-js/vite'
24
+ *
25
+ * export default defineConfig({
26
+ * plugins: [Unhead(), solid()],
27
+ * })
28
+ * ```
29
+ */
30
+ declare function Unhead(options?: UnheadSolidViteOptions): Plugin[];
31
+
32
+ export { Unhead };
33
+ export type { UnheadSolidViteOptions };
package/dist/vite.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { Unhead as Unhead$1 } from '@unhead/bundler/vite';
2
+ import unheadSolidPlugin 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/solid-js" })];
9
+ if (options.streaming) {
10
+ const streamingOpts = typeof options.streaming === "object" ? options.streaming : void 0;
11
+ plugins.push(unheadSolidPlugin(streamingOpts));
12
+ }
13
+ return plugins;
14
+ }
15
+
16
+ export { Unhead };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/solid-js",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.9",
4
+ "version": "3.0.0-rc.3",
5
5
  "description": "Full-stack <head> manager built for SolidJS.",
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
  ]
@@ -83,8 +90,8 @@
83
90
  "dist"
84
91
  ],
85
92
  "peerDependencies": {
86
- "solid-js": ">=19",
87
- "vite": ">=6"
93
+ "solid-js": ">=1.9.0",
94
+ "vite": ">=6.4.2"
88
95
  },
89
96
  "peerDependenciesMeta": {
90
97
  "vite": {
@@ -98,17 +105,18 @@
98
105
  },
99
106
  "dependencies": {
100
107
  "magic-string": "^0.30.21",
101
- "oxc-parser": "^0.106.0",
108
+ "oxc-parser": "^0.124.0",
102
109
  "oxc-walker": "^0.7.0",
103
- "unhead": "3.0.0-beta.9"
110
+ "@unhead/bundler": "3.0.0-rc.3",
111
+ "unhead": "3.0.0-rc.3"
104
112
  },
105
113
  "devDependencies": {
106
114
  "@solidjs/testing-library": "^0.8.10",
107
115
  "@testing-library/jest-dom": "^6.9.1",
108
116
  "@testing-library/user-event": "14.6.1",
109
- "solid-js": "^1.9.10",
110
- "vite": "^7.2.2",
111
- "vite-plugin-solid": "^2.11.10"
117
+ "solid-js": "^1.9.12",
118
+ "vite": "^8.0.8",
119
+ "vite-plugin-solid": "^2.11.12"
112
120
  },
113
121
  "scripts": {
114
122
  "build": "unbuild",