@ssgoi/solid 7.0.3 → 7.1.0-beta.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/dist/solidstart.cjs +1 -0
- package/dist/solidstart.d.ts +14 -0
- package/dist/solidstart.js +36 -0
- package/package.json +19 -5
- package/src/lib/solidstart.tsx +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("solid-js/web"),l=require("@solidjs/router"),r=require("solid-js");function m(a){const n=l.useLocation(),[e,u]=r.splitProps(a,["children","as","resolve","routeKey"]),i=r.createMemo(()=>e.resolve?.({pathname:n.pathname})??{id:n.pathname}),d=r.createMemo(o=>{const c=i(),s=e.routeKey??c.key??c.id;return o?.key===s?o:{key:s}});return t.createComponent(r.Show,{get when(){return d()},keyed:!0,children:o=>t.createComponent(t.Dynamic,t.mergeProps({get component(){return e.as??"div"}},u,{get"data-ssgoi-transition"(){return i().id},get children(){return e.children}}))})}exports.SsgoiRouteBoundary=m;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
export interface RouteBoundaryState {
|
|
3
|
+
id: string;
|
|
4
|
+
key?: string | number;
|
|
5
|
+
}
|
|
6
|
+
export type SsgoiRouteBoundaryProps = JSX.HTMLAttributes<HTMLElement> & {
|
|
7
|
+
as?: keyof JSX.IntrinsicElements;
|
|
8
|
+
routeKey?: string | number;
|
|
9
|
+
resolve?: (location: {
|
|
10
|
+
pathname: string;
|
|
11
|
+
}) => RouteBoundaryState;
|
|
12
|
+
};
|
|
13
|
+
/** Solid Router boundary, including SolidStart. */
|
|
14
|
+
export declare function SsgoiRouteBoundary(props: SsgoiRouteBoundaryProps): JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createComponent as a, Dynamic as d, mergeProps as l } from "solid-js/web";
|
|
2
|
+
import { useLocation as p } from "@solidjs/router";
|
|
3
|
+
import { splitProps as h, createMemo as c, Show as y } from "solid-js";
|
|
4
|
+
function v(s) {
|
|
5
|
+
const r = p(), [e, m] = h(s, ["children", "as", "resolve", "routeKey"]), o = c(() => e.resolve?.({
|
|
6
|
+
pathname: r.pathname
|
|
7
|
+
}) ?? {
|
|
8
|
+
id: r.pathname
|
|
9
|
+
}), u = c((t) => {
|
|
10
|
+
const n = o(), i = e.routeKey ?? n.key ?? n.id;
|
|
11
|
+
return t?.key === i ? t : {
|
|
12
|
+
key: i
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
return a(y, {
|
|
16
|
+
get when() {
|
|
17
|
+
return u();
|
|
18
|
+
},
|
|
19
|
+
keyed: !0,
|
|
20
|
+
children: (t) => a(d, l({
|
|
21
|
+
get component() {
|
|
22
|
+
return e.as ?? "div";
|
|
23
|
+
}
|
|
24
|
+
}, m, {
|
|
25
|
+
get "data-ssgoi-transition"() {
|
|
26
|
+
return o().id;
|
|
27
|
+
},
|
|
28
|
+
get children() {
|
|
29
|
+
return e.children;
|
|
30
|
+
}
|
|
31
|
+
}))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
v as SsgoiRouteBoundary
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/solid",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-beta.0",
|
|
4
4
|
"description": "Solid.js bindings for SSGOI - Native app-like page transitions for Solid applications",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -36,10 +36,17 @@
|
|
|
36
36
|
"import": "./dist/view-transitions.js",
|
|
37
37
|
"require": "./dist/view-transitions.cjs",
|
|
38
38
|
"default": "./dist/view-transitions.js"
|
|
39
|
+
},
|
|
40
|
+
"./solidstart": {
|
|
41
|
+
"solid": "./src/lib/solidstart.tsx",
|
|
42
|
+
"types": "./dist/solidstart.d.ts",
|
|
43
|
+
"import": "./dist/solidstart.js",
|
|
44
|
+
"require": "./dist/solidstart.cjs",
|
|
45
|
+
"default": "./dist/solidstart.js"
|
|
39
46
|
}
|
|
40
47
|
},
|
|
41
48
|
"dependencies": {
|
|
42
|
-
"@ssgoi/core": "^7.0.
|
|
49
|
+
"@ssgoi/core": "^7.1.0-beta.0"
|
|
43
50
|
},
|
|
44
51
|
"devDependencies": {
|
|
45
52
|
"@eslint/js": "^9.30.1",
|
|
@@ -47,15 +54,17 @@
|
|
|
47
54
|
"eslint": "^9.30.1",
|
|
48
55
|
"globals": "^16.3.0",
|
|
49
56
|
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
50
|
-
"solid-js": "^1.9.
|
|
57
|
+
"solid-js": "^1.9.13",
|
|
51
58
|
"typescript": "~5.9.3",
|
|
52
59
|
"typescript-eslint": "^8.35.1",
|
|
53
60
|
"vite": "^7.2.4",
|
|
54
61
|
"vite-plugin-dts": "^4.5.4",
|
|
55
|
-
"vite-plugin-solid": "^2.11.10"
|
|
62
|
+
"vite-plugin-solid": "^2.11.10",
|
|
63
|
+
"@solidjs/router": "^0.16.1"
|
|
56
64
|
},
|
|
57
65
|
"peerDependencies": {
|
|
58
|
-
"solid-js": "^1.0.0"
|
|
66
|
+
"solid-js": "^1.0.0",
|
|
67
|
+
"@solidjs/router": "*"
|
|
59
68
|
},
|
|
60
69
|
"keywords": [
|
|
61
70
|
"solid",
|
|
@@ -82,6 +91,11 @@
|
|
|
82
91
|
"engines": {
|
|
83
92
|
"node": ">=18.0.0"
|
|
84
93
|
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
95
|
+
"@solidjs/router": {
|
|
96
|
+
"optional": true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
85
99
|
"scripts": {
|
|
86
100
|
"dev": "vite build --watch",
|
|
87
101
|
"build": "tsc -b && vite build",
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useLocation } from "@solidjs/router";
|
|
2
|
+
import { createMemo, Show, splitProps, type JSX } from "solid-js";
|
|
3
|
+
import { Dynamic } from "solid-js/web";
|
|
4
|
+
|
|
5
|
+
export interface RouteBoundaryState {
|
|
6
|
+
id: string;
|
|
7
|
+
key?: string | number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type SsgoiRouteBoundaryProps = JSX.HTMLAttributes<HTMLElement> & {
|
|
11
|
+
as?: keyof JSX.IntrinsicElements;
|
|
12
|
+
routeKey?: string | number;
|
|
13
|
+
resolve?: (location: { pathname: string }) => RouteBoundaryState;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Solid Router boundary, including SolidStart. */
|
|
17
|
+
export function SsgoiRouteBoundary(props: SsgoiRouteBoundaryProps) {
|
|
18
|
+
const location = useLocation();
|
|
19
|
+
const [local, rest] = splitProps(props, [
|
|
20
|
+
"children",
|
|
21
|
+
"as",
|
|
22
|
+
"resolve",
|
|
23
|
+
"routeKey",
|
|
24
|
+
]);
|
|
25
|
+
const boundary = createMemo(
|
|
26
|
+
() =>
|
|
27
|
+
local.resolve?.({ pathname: location.pathname }) ?? {
|
|
28
|
+
id: location.pathname,
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
// Show uses truthiness. A token also supports valid keys such as 0 and "".
|
|
32
|
+
const lifetime = createMemo<{ key: string | number }>((previous) => {
|
|
33
|
+
const current = boundary();
|
|
34
|
+
const key = local.routeKey ?? current.key ?? current.id;
|
|
35
|
+
return previous?.key === key ? previous : { key };
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Show when={lifetime()} keyed>
|
|
40
|
+
{(_lifetime) => (
|
|
41
|
+
<Dynamic
|
|
42
|
+
component={local.as ?? "div"}
|
|
43
|
+
{...rest}
|
|
44
|
+
data-ssgoi-transition={boundary().id}
|
|
45
|
+
>
|
|
46
|
+
{local.children}
|
|
47
|
+
</Dynamic>
|
|
48
|
+
)}
|
|
49
|
+
</Show>
|
|
50
|
+
);
|
|
51
|
+
}
|