vike-solid 0.7.6 → 0.7.8

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/+config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ConfigEffect } from 'vike/types';
2
- import './Config-DC6Ltq1D.js';
2
+ import './Config-B_i-zLx_.js';
3
3
  import { JSX } from 'solid-js';
4
4
 
5
5
  declare function ssrEffect({ configDefinedAt, configValue }: Parameters<ConfigEffect>[0]): ReturnType<ConfigEffect>;
@@ -128,15 +128,11 @@ declare global {
128
128
  */
129
129
  ssr?: boolean;
130
130
  /**
131
- * Whether to stream the page's HTML. Requires Server-Side Rendering (`ssr: true`).
132
- *
133
- * If `true`, the stream will be a Node Stream. If you need a Web Stream, use `stream: 'web'`.
134
- *
135
- * @default false
131
+ * Enable or disable HTML Streaming.
136
132
  *
137
133
  * https://vike.dev/stream
138
134
  */
139
- stream?: boolean | "web";
135
+ stream?: boolean | "node" | "web";
140
136
  /**
141
137
  * Client-side hook called after the page is rendered.
142
138
  *
@@ -1,4 +1,4 @@
1
- import { C as ConfigFromHook } from '../../Config-DC6Ltq1D.js';
1
+ import { C as ConfigFromHook } from '../../Config-B_i-zLx_.js';
2
2
  import 'vike/types';
3
3
  import 'solid-js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ConfigFromHook } from '../../Config-DC6Ltq1D.js';
1
+ import { C as ConfigFromHook } from '../../Config-B_i-zLx_.js';
2
2
  import 'vike/types';
3
3
  import 'solid-js';
4
4
 
@@ -6,8 +6,10 @@ import { Component, ComponentProps, JSX } from 'solid-js';
6
6
  */
7
7
  declare function clientOnly<T extends Component<any>>(fn: () => Promise<{
8
8
  default: T;
9
- } | T>): (props: ComponentProps<T> & {
9
+ } | T>, options?: {
10
+ lazy?: boolean;
11
+ }): (props: ComponentProps<T> & {
10
12
  fallback?: JSX.Element;
11
- }) => any;
13
+ }) => JSX.Element;
12
14
 
13
15
  export { clientOnly };
@@ -6,19 +6,29 @@ import { isServer } from 'solid-js/web';
6
6
  * Load and render a component only on the client-side.
7
7
  * @see {@link https://vike.dev/clientOnly}
8
8
  */
9
- function clientOnly(fn) {
9
+ function clientOnly(fn, options = {}) {
10
10
  if (isServer) return props => props.fallback;
11
11
  const [comp, setComp] = createSignal();
12
- fn().then(m => setComp(() => "default" in m ? m.default : m));
12
+ if (!options.lazy) {
13
+ load(fn, setComp);
14
+ }
15
+ // eslint-disable-next-line solid/reactivity
13
16
  return props => {
14
17
  let Comp;
15
18
  let m;
16
19
  const [, rest] = splitProps(props, ["fallback"]);
20
+ if (options.lazy) {
21
+ load(fn, setComp);
22
+ }
17
23
  if ((Comp = comp()) && !sharedConfig.context) return Comp(rest);
18
24
  const [mounted, setMounted] = createSignal(!sharedConfig.context);
19
25
  onMount(() => setMounted(true));
26
+ // eslint-disable-next-line solid/reactivity
20
27
  return createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
21
28
  };
22
29
  }
30
+ function load(fn, setComp) {
31
+ fn().then(m => setComp(() => "default" in m ? m.default : m));
32
+ }
23
33
 
24
34
  export { clientOnly };
@@ -1,4 +1,4 @@
1
- import { C as ConfigFromHook } from '../../Config-DC6Ltq1D.js';
1
+ import { C as ConfigFromHook } from '../../Config-B_i-zLx_.js';
2
2
  import 'vike/types';
3
3
  import 'solid-js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ConfigFromHook } from '../../Config-DC6Ltq1D.js';
1
+ import { C as ConfigFromHook } from '../../Config-B_i-zLx_.js';
2
2
  import 'vike/types';
3
3
  import 'solid-js';
4
4
 
@@ -4,7 +4,7 @@ import { createContext, useContext } from 'solid-js';
4
4
  function getGlobalObject(
5
5
  // We use the filename as key; each `getGlobalObject()` call should live inside a file with a unique filename.
6
6
  key, defaultValue) {
7
- // @ts-ignore
7
+ // @ts-expect-error Property '_vike_solid' does not exist on type 'typeof globalThis'
8
8
  const globalObjectsAll = globalThis[projectKey] = globalThis[projectKey] || {};
9
9
  const globalObject = globalObjectsAll[key] = globalObjectsAll[key] || defaultValue;
10
10
  return globalObject;
@@ -18,6 +18,7 @@ function PageContextProvider(props) {
18
18
  const {
19
19
  solidContext
20
20
  } = globalContext;
21
+ // eslint-disable-next-line solid/reactivity
21
22
  return createComponent(solidContext.Provider, {
22
23
  get value() {
23
24
  return props.pageContext;
@@ -1,4 +1,4 @@
1
- import { createComponent, Dynamic, memo, hydrate, render } from 'solid-js/web';
1
+ import { createComponent, memo, Dynamic, hydrate, render } from 'solid-js/web';
2
2
  import { i as includes, c as configsCumulative } from '../includes-B0OUVLz0.js';
3
3
  import { PageContextProvider, usePageContext } from '../hooks/usePageContext.js';
4
4
  import { createComputed, createComponent as createComponent$1 } from 'solid-js';
@@ -49,10 +49,11 @@ function Wrapper(props) {
49
49
  // Inner wrapping
50
50
  ...(pageContext.config.Layout || []),
51
51
  // Outer wrapping
52
- ...(pageContext.config.Wrapper || [])]));
52
+ ...(pageContext.config.Wrapper || [])].reverse()));
53
53
  });
54
54
  const renderWrappers = (i = 0) => {
55
- let item = wrappers.at(-(i + 1));
55
+ let item = wrappers[i]; // Assumes reversed, and must access with `[i]` instead of `.at(i)` otherwise, wrapper's states are not persisted.
56
+
56
57
  if (!item) return props.children;
57
58
  if (typeof item !== "function") item = Passthrough;
58
59
  return createComponent$1(item, {
@@ -61,7 +62,7 @@ function Wrapper(props) {
61
62
  }
62
63
  });
63
64
  };
64
- return renderWrappers();
65
+ return memo(() => renderWrappers(0));
65
66
  }
66
67
  function Page() {
67
68
  const pageContext = usePageContext();
@@ -49,10 +49,11 @@ function Wrapper(props) {
49
49
  // Inner wrapping
50
50
  ...(pageContext.config.Layout || []),
51
51
  // Outer wrapping
52
- ...(pageContext.config.Wrapper || [])]));
52
+ ...(pageContext.config.Wrapper || [])].reverse()));
53
53
  });
54
54
  const renderWrappers = (i = 0) => {
55
- let item = wrappers.at(-(i + 1));
55
+ let item = wrappers[i]; // Assumes reversed, and must access with `[i]` instead of `.at(i)` otherwise, wrapper's states are not persisted.
56
+
56
57
  if (!item) return props.children;
57
58
  if (typeof item !== "function") item = Passthrough;
58
59
  return createComponent$1(item, {
@@ -61,7 +62,7 @@ function Wrapper(props) {
61
62
  }
62
63
  });
63
64
  };
64
- return renderWrappers();
65
+ return renderWrappers(0);
65
66
  }
66
67
  function Page() {
67
68
  const pageContext = usePageContext();
@@ -111,7 +112,7 @@ async function getPageHtml(pageContext) {
111
112
  let pageHtml = "";
112
113
  const userAgent = pageContext.headers?.["user-agent"] ||
113
114
  // TODO/eventually: remove old way of acccessing the User Agent header.
114
- // @ts-ignore
115
+ // @ts-expect-error Property 'userAgent' does not exist on type
115
116
  pageContext.userAgent;
116
117
  if (pageContext.Page) {
117
118
  if (userAgent && isBot(userAgent)) {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "vike-solid",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "isbot-fast": "^1.2.0",
7
- "vite-plugin-solid": "^2.10.2"
7
+ "vite-plugin-solid": "^2.11.0"
8
8
  },
9
9
  "peerDependencies": {
10
10
  "solid-js": "^1.8.7",
@@ -12,22 +12,22 @@
12
12
  "vite": ">=5.0.0"
13
13
  },
14
14
  "devDependencies": {
15
- "@babel/core": "^7.25.2",
16
- "@babel/preset-env": "^7.25.4",
17
- "@babel/preset-typescript": "^7.24.7",
15
+ "@babel/core": "^7.26.0",
16
+ "@babel/preset-env": "^7.26.0",
17
+ "@babel/preset-typescript": "^7.26.0",
18
18
  "@brillout/release-me": "^0.4.2",
19
19
  "@rollup/plugin-babel": "^6.0.4",
20
- "@rollup/plugin-node-resolve": "^15.2.4",
21
- "@types/node": "^22.5.5",
22
- "babel-preset-solid": "^1.8.22",
23
- "bumpp": "^9.5.2",
24
- "rollup": "^4.22.4",
20
+ "@rollup/plugin-node-resolve": "^16.0.0",
21
+ "@types/node": "^22.10.1",
22
+ "babel-preset-solid": "^1.9.3",
23
+ "bumpp": "^9.9.1",
24
+ "rollup": "^4.28.1",
25
25
  "rollup-plugin-dts": "^6.1.1",
26
- "solid-js": "^1.8.22",
27
- "tslib": "^2.7.0",
28
- "typescript": "^5.6.2",
29
- "vike": "^0.4.197",
30
- "vite": "^5.4.7"
26
+ "solid-js": "^1.9.3",
27
+ "tslib": "^2.8.1",
28
+ "typescript": "^5.7.2",
29
+ "vike": "^0.4.209",
30
+ "vite": "^6.0.3"
31
31
  },
32
32
  "exports": {
33
33
  "./config": "./dist/+config.js",