@primate/solid 0.9.0 → 0.10.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/lib/index.d.ts +2 -1
- package/lib/private/client/app.js +4 -1
- package/lib/private/client/form.d.ts +4 -3
- package/lib/private/client/form.js +17 -6
- package/lib/private/default.d.ts +1 -1
- package/lib/private/runtime.d.ts +1 -1
- package/lib/public/browser.d.ts +1 -0
- package/lib/public/browser.js +1 -0
- package/lib/public/runtime.d.ts +1 -0
- package/lib/public/runtime.js +1 -0
- package/package.json +13 -10
- package/lib/public/client.d.ts +0 -2
- package/lib/public/client.js +0 -2
package/lib/index.d.ts
CHANGED
|
@@ -7,9 +7,12 @@ const { body } = globalThis.window.document;
|
|
|
7
7
|
SolidHead.clear();
|
|
8
8
|
export default class SolidApp {
|
|
9
9
|
static mount(_view, data) {
|
|
10
|
+
const interactive = !data.ssr || data.csr;
|
|
11
|
+
if (!interactive)
|
|
12
|
+
return;
|
|
10
13
|
const mount = () => Root(root.toProps(data));
|
|
11
14
|
let dispose = root[data.ssr ? "ssr" : "csr"](mount, body);
|
|
12
|
-
if (data.
|
|
15
|
+
if (data.csr) {
|
|
13
16
|
const start = () => client.boot((_data, update) => {
|
|
14
17
|
dispose();
|
|
15
18
|
dispose = root.csr(() => Root(root.toProps(_data, update)), body);
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ClientMethod, FormInit } from "@primate/core/client";
|
|
2
2
|
import type { Dict } from "@rcompat/type";
|
|
3
3
|
type FormView<Values extends Dict> = {
|
|
4
4
|
id: string;
|
|
5
5
|
submitting: boolean;
|
|
6
6
|
submitted: boolean;
|
|
7
7
|
submit: (event?: Event) => Promise<void>;
|
|
8
|
-
errors:
|
|
8
|
+
errors: string[];
|
|
9
9
|
field: <K extends keyof Values & string>(name: K) => {
|
|
10
10
|
name: string;
|
|
11
11
|
value: Values[K];
|
|
12
12
|
error: string | null;
|
|
13
|
-
errors:
|
|
13
|
+
errors: string[];
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
type Initial<Values extends Dict> = FormInit & {
|
|
17
17
|
initial?: Values;
|
|
18
18
|
};
|
|
19
|
+
declare function form<Values extends Dict>(action: ClientMethod<Values>, init?: Initial<Values>): FormView<Values>;
|
|
19
20
|
declare function form<Values extends Dict>(init: Initial<Values>): FormView<Values>;
|
|
20
21
|
declare function form(init?: FormInit): FormView<Dict>;
|
|
21
22
|
export default form;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import core from "@primate/core/client";
|
|
2
2
|
import { createSignal, onCleanup } from "solid-js";
|
|
3
|
-
function form(
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
function form(action_or_init, maybe_init) {
|
|
4
|
+
const is_action = typeof action_or_init === "function";
|
|
5
|
+
const { initial, ...form_init } = (is_action ? (maybe_init ?? {}) : (action_or_init ?? {}));
|
|
6
|
+
const action = is_action ? action_or_init : undefined;
|
|
7
|
+
const contentType = is_action
|
|
8
|
+
? action_or_init.contentType
|
|
9
|
+
: undefined;
|
|
10
|
+
const controller = core.createForm({
|
|
11
|
+
...form_init,
|
|
12
|
+
...action !== undefined && {
|
|
13
|
+
action: action,
|
|
14
|
+
contentType,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const values = initial ?? {};
|
|
7
18
|
const [snapshot, setSnapshot] = createSignal(controller.read());
|
|
8
|
-
const
|
|
9
|
-
onCleanup(
|
|
19
|
+
const unsubscribe = controller.subscribe(next => setSnapshot(next));
|
|
20
|
+
onCleanup(unsubscribe);
|
|
10
21
|
return {
|
|
11
22
|
get id() {
|
|
12
23
|
return snapshot().id;
|
package/lib/private/default.d.ts
CHANGED
package/lib/private/runtime.d.ts
CHANGED
package/lib/public/browser.d.ts
CHANGED
package/lib/public/browser.js
CHANGED
package/lib/public/runtime.d.ts
CHANGED
package/lib/public/runtime.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/solid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "SolidJS for Primate",
|
|
5
5
|
"homepage": "https://primate.run/docs/frontend/solid",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
@@ -18,22 +18,25 @@
|
|
|
18
18
|
],
|
|
19
19
|
"types": "lib/index.d.ts",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@rcompat/type": "^0.
|
|
22
|
-
"@types/babel__core": "^7.20.5"
|
|
23
|
-
"@primate/test": "^0.0.0"
|
|
21
|
+
"@rcompat/type": "^0.17.0",
|
|
22
|
+
"@types/babel__core": "^7.20.5"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@babel/core": "^7.28.6",
|
|
27
|
-
"@rcompat/fs": "^0.
|
|
28
|
-
"@rcompat/runtime": "^0.
|
|
26
|
+
"@rcompat/fs": "^0.33.2",
|
|
27
|
+
"@rcompat/runtime": "^0.16.0",
|
|
29
28
|
"babel-preset-solid": "^1.9.12",
|
|
30
|
-
"@primate/core": "^0.
|
|
29
|
+
"@primate/core": "^0.7.0"
|
|
31
30
|
},
|
|
32
31
|
"peerDependencies": {
|
|
33
32
|
"solid-js": "1",
|
|
34
|
-
"primate": "^0.
|
|
33
|
+
"primate": "^0.38.0"
|
|
35
34
|
},
|
|
36
35
|
"imports": {
|
|
36
|
+
"#i18n/Bridge.default": {
|
|
37
|
+
"@primate/source": "./src/private/i18n/Bridge.default.tsx",
|
|
38
|
+
"default": "./lib/private/i18n/Bridge.default.js"
|
|
39
|
+
},
|
|
37
40
|
"#*": {
|
|
38
41
|
"@primate/source": "./src/private/*.ts",
|
|
39
42
|
"default": "./lib/private/*.js"
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
"exports": {
|
|
48
51
|
".": {
|
|
49
52
|
"types": "./lib/index.d.ts",
|
|
53
|
+
"@primate/runtime": "./src/public/runtime.ts",
|
|
50
54
|
"@primate/source": "./src/public/default.ts",
|
|
51
55
|
"browser": "./lib/public/browser.js",
|
|
52
56
|
"runtime": "./lib/public/runtime.js",
|
|
@@ -66,7 +70,6 @@
|
|
|
66
70
|
"build": "npm run clean && tsc && cp src/types/{app,index}.d.ts lib",
|
|
67
71
|
"postbuild": "node scripts/compile-jsx.js",
|
|
68
72
|
"clean": "rm -rf ./lib",
|
|
69
|
-
"lint": "eslint ."
|
|
70
|
-
"test": "npx proby"
|
|
73
|
+
"lint": "eslint ."
|
|
71
74
|
}
|
|
72
75
|
}
|
package/lib/public/client.d.ts
DELETED
package/lib/public/client.js
DELETED