vike-solid 0.1.3 → 0.2.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/README.md CHANGED
@@ -1,18 +1,12 @@
1
- [<img src="https://avatars.githubusercontent.com/u/86403530?s=200&v=4" align="right" width="64" height="64">](https://vite-plugin-ssr.com)
1
+ [<img src="https://avatars.githubusercontent.com/u/86403530?s=200&v=4" align="right" width="64" height="64">](https://vike.dev)
2
2
  [![npm version](https://img.shields.io/npm/v/vike-solid)](https://www.npmjs.com/package/vike-solid)
3
3
 
4
4
  # `vike-solid`
5
5
 
6
- Vike-solid is a demo showcasing a SolidJS framework built using [vite-plugin-ssr](https://vite-plugin-ssr.com/).
6
+ SolidJS integration for [Vike](https://github.com/vikejs/vike/issues/736) (using the
7
+ [V1 design](https://vike.dev/migration/v1-design)).
7
8
 
8
- It uses VPS's [V1 design](https://github.com/brillout/vite-plugin-ssr/issues/578) which is in beta.
9
+ > [!NOTE]
10
+ > For integrations with React and Vue, see the other [`vike-*` packages](https://vike.dev/vike-packages).
9
11
 
10
- > **NOTE:** For VPS/Vike integrations with other UI frameworks (e.g. React), see
11
- > [`vike-*` packages](https://vite-plugin-ssr.com/vike-packages).
12
-
13
- To run the example:
14
-
15
- - Clone the repo: `git clone git@github.com:magne4000/vike-solid`
16
- - Install dependencies: `pnpm install`
17
- - Build vike-solid: `pnpm run build`
18
- - Run the example: `cd examples/basic/ && pnpm run dev`
12
+ See [examples/](https://github.com/magne4000/vike-solid/tree/main/examples).
package/dist/+config.js CHANGED
@@ -1,6 +1,8 @@
1
+ // We purposely define the ConfigVikeSolid interface in this file: that way we ensure it's always applied whenever the user `import vikeSolid from 'vike-solid'`
2
+
1
3
  // Depending on the value of `config.meta.ssr`, set other config options' `env`
2
4
  // accordingly.
3
- // See https://vite-plugin-ssr.com/meta#modify-existing-configurations
5
+ // See https://vike.dev/meta#modify-existing-configurations
4
6
  const toggleSsrRelatedConfig = ({
5
7
  configDefinedAt,
6
8
  configValue
@@ -49,6 +51,4 @@ var _config = {
49
51
  }
50
52
  };
51
53
 
52
- // We purposely define the ConfigVikeSolid interface in this file: that way we ensure it's always applied whenever the user `import vikeSolid from 'vike-solid'`
53
-
54
54
  export { _config as default };
@@ -38,30 +38,15 @@ function getPageElement(pageContext) {
38
38
  const page = createComponent(PageContextProvider, {
39
39
  pageContext: pageContext,
40
40
  get children() {
41
- return createComponent(Wrapper, {
41
+ return createComponent(Layout, {
42
42
  get children() {
43
- return createComponent(Layout, {
44
- get children() {
45
- return createComponent(Page, {});
46
- }
47
- });
43
+ return createComponent(Page, {});
48
44
  }
49
45
  });
50
46
  }
51
47
  });
52
48
  return page;
53
49
  }
54
- function Wrapper(props) {
55
- const pageContext = usePageContext();
56
- return createComponent(Dynamic, {
57
- get component() {
58
- return pageContext.config.Wrapper ?? Passthrough;
59
- },
60
- get children() {
61
- return props.children;
62
- }
63
- });
64
- }
65
50
  function Layout(props) {
66
51
  const pageContext = usePageContext();
67
52
  return createComponent(Dynamic, {
@@ -1,5 +1,5 @@
1
1
  import { createComponent, Dynamic, mergeProps, renderToString, renderToStream, generateHydrationScript } from 'solid-js/web';
2
- import { escapeInject, stampPipe, dangerouslySkipEscape } from 'vite-plugin-ssr/server';
2
+ import { escapeInject, stampPipe, dangerouslySkipEscape } from 'vike/server';
3
3
  import { P as PageContextProvider, u as usePageContext } from './usePageContext-a90cda5a.js';
4
4
  import 'solid-js';
5
5
 
@@ -38,30 +38,15 @@ function getPageElement(pageContext) {
38
38
  const page = createComponent(PageContextProvider, {
39
39
  pageContext: pageContext,
40
40
  get children() {
41
- return createComponent(Wrapper, {
41
+ return createComponent(Layout, {
42
42
  get children() {
43
- return createComponent(Layout, {
44
- get children() {
45
- return createComponent(Page, {});
46
- }
47
- });
43
+ return createComponent(Page, {});
48
44
  }
49
45
  });
50
46
  }
51
47
  });
52
48
  return page;
53
49
  }
54
- function Wrapper(props) {
55
- const pageContext = usePageContext();
56
- return createComponent(Dynamic, {
57
- get component() {
58
- return pageContext.config.Wrapper ?? Passthrough;
59
- },
60
- get children() {
61
- return props.children;
62
- }
63
- });
64
- }
65
50
  function Layout(props) {
66
51
  const pageContext = usePageContext();
67
52
  return createComponent(Dynamic, {
@@ -1,9 +1,9 @@
1
1
  import { build } from 'vite';
2
- import { c as config } from './vite.config-0442c29d.js';
2
+ import { c as config } from './vite.config-2b9e1d28.js';
3
3
  import 'vite-plugin-solid';
4
- import 'vite-plugin-ssr/plugin';
4
+ import 'vike/plugin';
5
5
 
6
- // import { prerender } from 'vite-plugin-ssr/prerender'
6
+ // import { prerender } from 'vike/prerender'
7
7
 
8
8
  main();
9
9
  async function main() {
@@ -1,24 +1,42 @@
1
- import { PageContextBuiltInServer, PageContextBuiltInClientWithClientRouting } from 'vite-plugin-ssr/types';
2
- import { JSX } from 'solid-js';
3
-
4
- type Page = (pageProps: PageProps) => JSX.Element;
5
- type PageProps = Record<string, unknown>;
6
- type WrapperComponent = ({ children }: {
7
- children: any;
8
- }) => JSX.Element;
9
- type PageContextCommon = {
10
- Page: Page;
11
- pageProps?: PageProps;
12
- config: {
13
- Layout?: WrapperComponent;
14
- Wrapper?: WrapperComponent;
15
- };
16
- };
17
- type PageContextServer = PageContextBuiltInServer<Page> & PageContextCommon;
18
- type PageContextClient = PageContextBuiltInClientWithClientRouting<Page> & PageContextCommon;
19
- type PageContext = PageContextClient | PageContextServer;
1
+ import * as vike_dist_esm_shared_types from 'vike/dist/esm/shared/types';
2
+ import * as vike_dist_esm_shared_addUrlComputedProps from 'vike/dist/esm/shared/addUrlComputedProps';
3
+ import * as vike_dist_esm_shared_getPageFiles_getExports from 'vike/dist/esm/shared/getPageFiles/getExports';
4
+ import * as vike_dist_esm_shared_page_configs_Config_PageContextConfig from 'vike/dist/esm/shared/page-configs/Config/PageContextConfig';
20
5
 
21
6
  /** Access the pageContext from any SolidJS component */
22
- declare function usePageContext(): PageContext;
7
+ declare function usePageContext(): (Partial<{
8
+ Page: unknown;
9
+ routeParams: Record<string, string>;
10
+ config: vike_dist_esm_shared_page_configs_Config_PageContextConfig.PageContextConfig;
11
+ configEntries: vike_dist_esm_shared_getPageFiles_getExports.ConfigEntries;
12
+ exports: Record<string, unknown>;
13
+ exportsAll: vike_dist_esm_shared_getPageFiles_getExports.ExportsAll;
14
+ urlOriginal: string;
15
+ is404: boolean | null;
16
+ isClientSideNavigation: boolean;
17
+ abortReason?: unknown;
18
+ abortStatusCode?: undefined;
19
+ errorWhileRendering?: unknown;
20
+ url: string;
21
+ pageExports: Record<string, unknown>;
22
+ }> & Pick<{
23
+ Page: unknown;
24
+ routeParams: Record<string, string>;
25
+ config: vike_dist_esm_shared_page_configs_Config_PageContextConfig.PageContextConfig;
26
+ configEntries: vike_dist_esm_shared_getPageFiles_getExports.ConfigEntries;
27
+ exports: Record<string, unknown>;
28
+ exportsAll: vike_dist_esm_shared_getPageFiles_getExports.ExportsAll;
29
+ urlOriginal: string;
30
+ is404: boolean | null;
31
+ isClientSideNavigation: boolean;
32
+ abortReason?: unknown;
33
+ abortStatusCode?: undefined;
34
+ errorWhileRendering?: unknown;
35
+ url: string;
36
+ pageExports: Record<string, unknown>;
37
+ }, "Page" | "pageExports" | "config" | "configEntries" | "exports" | "exportsAll" | "abortReason"> & {
38
+ isHydration: boolean;
39
+ isBackwardNavigation: boolean | null;
40
+ } & vike_dist_esm_shared_addUrlComputedProps.PageContextUrlComputedPropsClient & Vike.PageContext) | vike_dist_esm_shared_types.PageContextServer;
23
41
 
24
42
  export { usePageContext };
@@ -1,7 +1,7 @@
1
1
  import { createServer } from 'vite';
2
- import { c as config } from './vite.config-0442c29d.js';
2
+ import { c as config } from './vite.config-2b9e1d28.js';
3
3
  import 'vite-plugin-solid';
4
- import 'vite-plugin-ssr/plugin';
4
+ import 'vike/plugin';
5
5
 
6
6
  main();
7
7
  async function main() {
package/dist/index.js CHANGED
@@ -3,13 +3,13 @@ const cmd = parseCliArgs();
3
3
  cli();
4
4
  async function cli() {
5
5
  if (cmd === "dev") {
6
- await import('./dev-66f2fdf4.js');
6
+ await import('./dev-dfbf584d.js');
7
7
  }
8
8
  if (cmd === "build") {
9
- await import('./build-15504eb6.js');
9
+ await import('./build-4b79b655.js');
10
10
  }
11
11
  if (cmd === "preview") {
12
- await import('./preview-43d6feda.js');
12
+ await import('./preview-535a0307.js');
13
13
  }
14
14
  }
15
15
  function parseCliArgs() {
@@ -1,7 +1,7 @@
1
1
  import { preview } from 'vite';
2
- import { c as config } from './vite.config-0442c29d.js';
2
+ import { c as config } from './vite.config-2b9e1d28.js';
3
3
  import 'vite-plugin-solid';
4
- import 'vite-plugin-ssr/plugin';
4
+ import 'vike/plugin';
5
5
 
6
6
  main();
7
7
  async function main() {
@@ -1,5 +1,17 @@
1
- import { ConfigEffect } from 'vite-plugin-ssr/types';
2
- import { Component } from 'solid-js';
1
+ import { PageContext, ConfigEffect } from 'vike/types';
2
+ import { JSX, Component } from 'solid-js';
3
+
4
+ type Page = (pageProps: PageProps) => JSX.Element;
5
+ type PageProps = Record<string, unknown>;
6
+ declare global {
7
+ namespace Vike {
8
+ interface PageContext {
9
+ Page: Page;
10
+ pageProps: Record<string, unknown>;
11
+ title?: string;
12
+ }
13
+ }
14
+ }
3
15
 
4
16
  declare const _default: {
5
17
  onRenderHtml: "import:vike-solid/renderer/onRenderHtml";
@@ -36,7 +48,7 @@ declare global {
36
48
  /** Solid element renderer and appended into <head></head> */
37
49
  Head?: Component;
38
50
  Layout?: Component;
39
- title?: string;
51
+ title?: string | ((pageContext: PageContext) => string);
40
52
  description?: string;
41
53
  /**
42
54
  * @default 'en'
@@ -48,12 +60,13 @@ declare global {
48
60
  * If false, render mode is SPA. In other words, the page will only be
49
61
  * rendered in the browser.
50
62
  *
51
- * See https://vite-plugin-ssr.com/render-modes
63
+ * See https://vike.dev/render-modes
52
64
  *
53
65
  * @default true
54
66
  *
55
67
  */
56
68
  ssr?: boolean;
69
+ /** The page's root Solid component */
57
70
  Page?: Component;
58
71
  }
59
72
  }
@@ -1,5 +1,5 @@
1
1
  import { Options as Options$1 } from 'vite-plugin-solid';
2
- import { UserConfig } from 'vite-plugin-ssr/plugin';
2
+ import { UserConfig } from 'vike/plugin';
3
3
  import { Plugin } from 'vite';
4
4
 
5
5
  interface Options {
@@ -8,4 +8,4 @@ interface Options {
8
8
  }
9
9
  declare function export_default(options?: Options): Plugin[];
10
10
 
11
- export { Options, export_default as default };
11
+ export { type Options, export_default as default };
@@ -1,5 +1,5 @@
1
1
  import solidPlugin from 'vite-plugin-solid';
2
- import ssr from 'vite-plugin-ssr/plugin';
2
+ import ssr from 'vike/plugin';
3
3
  import { mergeConfig } from 'vite';
4
4
 
5
5
  function overrideConfig() {
@@ -1,5 +1,5 @@
1
1
  import solidPlugin from 'vite-plugin-solid';
2
- import ssr from 'vite-plugin-ssr/plugin';
2
+ import ssr from 'vike/plugin';
3
3
  import { mergeConfig } from 'vite';
4
4
 
5
5
  function overrideConfig() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-solid",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/+config.js",
@@ -10,28 +10,29 @@
10
10
  "./renderer/onRenderClient": "./dist/+onRenderClient.js"
11
11
  },
12
12
  "dependencies": {
13
- "vite": "^4.4.9",
14
13
  "vite-plugin-solid": "^2.7.0"
15
14
  },
16
15
  "peerDependencies": {
17
- "solid-js": "^1.7.11",
18
- "vite-plugin-ssr": "^0.4.141"
16
+ "solid-js": "^1.7.12",
17
+ "vite": "^4.4.9",
18
+ "vike": "^0.4.142"
19
19
  },
20
20
  "devDependencies": {
21
- "@babel/core": "^7.22.10",
22
- "@babel/preset-env": "^7.22.10",
23
- "@babel/preset-typescript": "^7.22.5",
21
+ "@babel/core": "^7.22.20",
22
+ "@babel/preset-env": "^7.22.20",
23
+ "@babel/preset-typescript": "^7.22.15",
24
24
  "@rollup/plugin-babel": "^6.0.3",
25
- "@rollup/plugin-node-resolve": "^15.1.0",
25
+ "@rollup/plugin-node-resolve": "^15.2.1",
26
26
  "@types/node": "^18.17.4",
27
- "babel-preset-solid": "^1.7.7",
28
- "bumpp": "^9.1.1",
29
- "rollup": "^3.28.0",
30
- "rollup-plugin-dts": "^5.3.1",
31
- "solid-js": "^1.7.11",
32
- "tslib": "^2.6.1",
33
- "typescript": "^5.1.6",
34
- "vite-plugin-ssr": "^0.4.141"
27
+ "babel-preset-solid": "^1.7.12",
28
+ "bumpp": "^9.2.0",
29
+ "rollup": "^3.29.2",
30
+ "rollup-plugin-dts": "^6.0.2",
31
+ "solid-js": "^1.7.12",
32
+ "tslib": "^2.6.2",
33
+ "typescript": "^5.2.2",
34
+ "vite": "^4.4.9",
35
+ "vike": "^0.4.142"
35
36
  },
36
37
  "typesVersions": {
37
38
  "*": {
@@ -60,7 +61,7 @@
60
61
  "license": "MIT",
61
62
  "scripts": {
62
63
  "dev": "rollup -c rollup.config.js --watch",
63
- "build": "rollup -c rollup.config.js",
64
+ "build": "tsc --noEmit && rollup -c rollup.config.js",
64
65
  "release": "pnpm run build && bumpp --commit --push --tag && pnpm publish"
65
66
  }
66
67
  }