@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 CHANGED
@@ -1,2 +1,3 @@
1
1
  import "./app.d.ts";
2
- export { default } from "./public/default";
2
+ export { default } from "#default";
3
+ export { default as client } from "#client/index";
@@ -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.spa) {
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 { type FormInit } from "@primate/core/client";
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: readonly string[];
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: readonly string[];
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(init) {
4
- const { initial, ...form_init } = (init ?? {});
5
- const controller = core.createForm(form_init);
6
- const values = (initial ?? {});
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 unsub = controller.subscribe((next) => setSnapshot(next));
9
- onCleanup(unsub);
19
+ const unsubscribe = controller.subscribe(next => setSnapshot(next));
20
+ onCleanup(unsubscribe);
10
21
  return {
11
22
  get id() {
12
23
  return snapshot().id;
@@ -1,6 +1,6 @@
1
1
  declare const _default: (input?: {
2
2
  extensions?: string[] | undefined;
3
- spa?: boolean | undefined;
3
+ csr?: boolean | undefined;
4
4
  ssr?: boolean | undefined;
5
5
  } | undefined) => import("@primate/core/frontend").Module;
6
6
  export default _default;
@@ -1,6 +1,6 @@
1
1
  declare const _default: (input?: {
2
2
  extensions?: string[] | undefined;
3
- spa?: boolean | undefined;
3
+ csr?: boolean | undefined;
4
4
  ssr?: boolean | undefined;
5
5
  } | undefined) => import("@primate/core/frontend").Module;
6
6
  export default _default;
@@ -1,2 +1,3 @@
1
1
  export { default } from "#client/app";
2
+ export { default as client } from "#client/index";
2
3
  //# sourceMappingURL=browser.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export { default } from "#client/app";
2
+ export { default as client } from "#client/index";
2
3
  //# sourceMappingURL=browser.js.map
@@ -1,2 +1,3 @@
1
+ export { default as client } from "#client/index";
1
2
  export { default } from "#runtime";
2
3
  //# sourceMappingURL=runtime.d.ts.map
@@ -1,2 +1,3 @@
1
+ export { default as client } from "#client/index";
1
2
  export { default } from "#runtime";
2
3
  //# sourceMappingURL=runtime.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/solid",
3
- "version": "0.9.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.11.1",
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.1",
28
- "@rcompat/runtime": "^0.11.1",
26
+ "@rcompat/fs": "^0.33.2",
27
+ "@rcompat/runtime": "^0.16.0",
29
28
  "babel-preset-solid": "^1.9.12",
30
- "@primate/core": "^0.6.0"
29
+ "@primate/core": "^0.7.0"
31
30
  },
32
31
  "peerDependencies": {
33
32
  "solid-js": "1",
34
- "primate": "^0.37.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
  }
@@ -1,2 +0,0 @@
1
- export { default } from "#client/index";
2
- //# sourceMappingURL=client.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "#client/index";
2
- //# sourceMappingURL=client.js.map