@primate/solid 0.10.0 → 0.12.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 +0 -1
- package/lib/private/Head/browser.d.ts +7 -6
- package/lib/private/Head/default.d.ts +7 -6
- package/lib/private/Head.d.ts +6 -6
- package/lib/private/client/form.d.ts +7 -2
- package/lib/private/client/form.js +3 -0
- package/lib/private/context/app.d.ts +1 -1
- package/lib/private/create-root.d.ts +1 -1
- package/lib/private/create-root.js +5 -19
- package/lib/private/i18n.d.ts +3 -0
- package/lib/private/i18n.js +51 -0
- package/lib/public/browser.d.ts +5 -2
- package/lib/public/browser.js +7 -2
- package/lib/public/client.d.ts +2 -0
- package/lib/public/client.js +2 -0
- package/lib/public/i18n.d.ts +2 -0
- package/lib/public/i18n.js +2 -0
- package/lib/public/runtime.d.ts +0 -1
- package/lib/public/runtime.js +0 -1
- package/package.json +10 -18
- package/lib/private/i18n/Bridge.browser.d.ts +0 -8
- package/lib/private/i18n/Bridge.browser.js +0 -25
- package/lib/private/i18n/Bridge.default.d.ts +0 -8
- package/lib/private/i18n/Bridge.default.js +0 -12
- package/lib/public/i18n/Bridge/browser.d.ts +0 -2
- package/lib/public/i18n/Bridge/browser.js +0 -2
- package/lib/public/i18n/Bridge/default.d.ts +0 -2
- package/lib/public/i18n/Bridge/default.js +0 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type Child from "#Head/ClientChild";
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
2
|
+
declare function Head(props: {
|
|
3
|
+
children: Child[];
|
|
4
|
+
}): null;
|
|
5
|
+
declare namespace Head {
|
|
6
|
+
var _a: (data_value?: string) => void;
|
|
7
|
+
export { _a as clear };
|
|
8
|
+
}
|
|
8
9
|
export default Head;
|
|
9
10
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type Child from "#Head/ServerChild";
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
2
|
+
declare function Head(props: {
|
|
3
|
+
children: Child[];
|
|
4
|
+
}): null;
|
|
5
|
+
declare namespace Head {
|
|
6
|
+
var _a: (data_value?: string) => void;
|
|
7
|
+
export { _a as clear };
|
|
8
|
+
}
|
|
8
9
|
export default Head;
|
|
9
10
|
//# sourceMappingURL=default.d.ts.map
|
package/lib/private/Head.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
clear: (data_value?: string) => void;
|
|
6
|
-
}
|
|
1
|
+
declare function Head(props: {
|
|
2
|
+
children: any[];
|
|
3
|
+
}): null;
|
|
4
|
+
declare namespace Head {
|
|
5
|
+
var clear: (data_value?: string) => void;
|
|
6
|
+
}
|
|
7
7
|
export default Head;
|
|
8
8
|
//# sourceMappingURL=Head.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ClientMethod, FormInit } from "@primate/core/client";
|
|
2
2
|
import type { Dict } from "@rcompat/type";
|
|
3
|
-
type FormView<Values extends Dict> = {
|
|
3
|
+
type FormView<Values extends Dict, Result = unknown> = {
|
|
4
4
|
id: string;
|
|
5
5
|
submitting: boolean;
|
|
6
6
|
submitted: boolean;
|
|
7
|
+
result: Result | null;
|
|
7
8
|
submit: (event?: Event) => Promise<void>;
|
|
8
9
|
errors: string[];
|
|
9
10
|
field: <K extends keyof Values & string>(name: K) => {
|
|
@@ -16,7 +17,11 @@ type FormView<Values extends Dict> = {
|
|
|
16
17
|
type Initial<Values extends Dict> = FormInit & {
|
|
17
18
|
initial?: Values;
|
|
18
19
|
};
|
|
19
|
-
declare function form<Values extends Dict>(action: ClientMethod<Values
|
|
20
|
+
declare function form<Values extends Dict, Path extends Dict, Result = unknown>(action: ClientMethod<Values, Path> & {
|
|
21
|
+
_result?: Result;
|
|
22
|
+
}, init?: Initial<Values> & {
|
|
23
|
+
path?: Path;
|
|
24
|
+
}): FormView<Values, Result>;
|
|
20
25
|
declare function form<Values extends Dict>(init: Initial<Values>): FormView<Values>;
|
|
21
26
|
declare function form(init?: FormInit): FormView<Dict>;
|
|
22
27
|
export default form;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default (length
|
|
1
|
+
export default (length) => {
|
|
2
2
|
const n = length;
|
|
3
3
|
const body = Array.from({ length: n }, (_, i) => i - 1).reduceRight((child, _, i) => `views[${i + 1}] !== undefined
|
|
4
4
|
? createComponent(views[${i}], { ...props[${i}],
|
|
@@ -6,31 +6,17 @@ export default (length, i18n_active) => {
|
|
|
6
6
|
})
|
|
7
7
|
: createComponent(views[${i}], props[${i}])
|
|
8
8
|
`, `createComponent(views[${n}], props[${n}])`);
|
|
9
|
-
const i18n_imports = i18n_active
|
|
10
|
-
? `
|
|
11
|
-
import I18nBridge from "@primate/solid/i18n/Bridge";
|
|
12
|
-
import t from "#i18n";`
|
|
13
|
-
: "";
|
|
14
|
-
const tree = i18n_active
|
|
15
|
-
? `<I18nBridge t={t}>{${body}}</I18nBridge>`
|
|
16
|
-
: `{${body}}`;
|
|
17
9
|
return `
|
|
18
|
-
import { createSignal } from "solid-js";
|
|
19
10
|
import { createComponent } from "solid-js/web";
|
|
20
11
|
import { setRequest } from "@primate/solid/app";
|
|
21
|
-
import
|
|
22
|
-
import HeadContext from "@primate/solid/context/head";${i18n_imports}
|
|
12
|
+
import HeadContext from "@primate/solid/context/head";
|
|
23
13
|
|
|
24
14
|
export default ({ views, props, request, push_heads: value }) => {
|
|
25
15
|
setRequest(request);
|
|
26
|
-
const [context, setContext] = createSignal(request.context);
|
|
27
|
-
const $value = { context, setContext };
|
|
28
16
|
|
|
29
|
-
return <
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</HeadContext.Provider>
|
|
33
|
-
</AppContext.Provider>
|
|
17
|
+
return <HeadContext.Provider value={value}>
|
|
18
|
+
{${body}}
|
|
19
|
+
</HeadContext.Provider>
|
|
34
20
|
}
|
|
35
21
|
`;
|
|
36
22
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { request } from "#request/store";
|
|
2
|
+
import { createSignal } from "solid-js";
|
|
3
|
+
export default function i18n(source) {
|
|
4
|
+
const [version, setVersion] = createSignal(0);
|
|
5
|
+
let restored = false;
|
|
6
|
+
let restored_request;
|
|
7
|
+
const current_request = () => request();
|
|
8
|
+
const restore_from_request = () => {
|
|
9
|
+
const next = current_request();
|
|
10
|
+
if (restored && next === restored_request)
|
|
11
|
+
return;
|
|
12
|
+
restored = true;
|
|
13
|
+
restored_request = next;
|
|
14
|
+
source.restore(next);
|
|
15
|
+
};
|
|
16
|
+
const depend = () => {
|
|
17
|
+
version();
|
|
18
|
+
restore_from_request();
|
|
19
|
+
};
|
|
20
|
+
const restore = (next = current_request()) => {
|
|
21
|
+
const before = source.locale.get();
|
|
22
|
+
restored = true;
|
|
23
|
+
restored_request = next;
|
|
24
|
+
source.restore(next);
|
|
25
|
+
if (source.locale.get() !== before)
|
|
26
|
+
setVersion(v => v + 1);
|
|
27
|
+
};
|
|
28
|
+
const get = () => {
|
|
29
|
+
depend();
|
|
30
|
+
return source.locale.get();
|
|
31
|
+
};
|
|
32
|
+
const set = (locale) => {
|
|
33
|
+
const before = source.locale.get();
|
|
34
|
+
source.locale.set(locale);
|
|
35
|
+
if (source.locale.get() !== before)
|
|
36
|
+
setVersion(v => v + 1);
|
|
37
|
+
};
|
|
38
|
+
const value = ((...args) => {
|
|
39
|
+
depend();
|
|
40
|
+
return source(...args);
|
|
41
|
+
});
|
|
42
|
+
value.defaultLocale = source.defaultLocale;
|
|
43
|
+
value.locales = source.locales;
|
|
44
|
+
value.catalogs = source.catalogs;
|
|
45
|
+
value.currency = source.currency;
|
|
46
|
+
value.locale = { get, set };
|
|
47
|
+
value.restore = restore;
|
|
48
|
+
restore();
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=i18n.js.map
|
package/lib/public/browser.d.ts
CHANGED
package/lib/public/browser.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export default function solid() {
|
|
2
|
+
return {
|
|
3
|
+
name: "solid",
|
|
4
|
+
setup() { },
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export { default as app } from "#client/app";
|
|
3
8
|
//# sourceMappingURL=browser.js.map
|
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.12.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,25 +18,20 @@
|
|
|
18
18
|
],
|
|
19
19
|
"types": "lib/index.d.ts",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@rcompat/type": "^0.
|
|
21
|
+
"@rcompat/type": "^0.18.0",
|
|
22
22
|
"@types/babel__core": "^7.20.5"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@babel/core": "^7.
|
|
26
|
-
"@rcompat/
|
|
27
|
-
"@rcompat/runtime": "^0.16.0",
|
|
25
|
+
"@babel/core": "^7.29.7",
|
|
26
|
+
"@rcompat/runtime": "^0.17.0",
|
|
28
27
|
"babel-preset-solid": "^1.9.12",
|
|
29
|
-
"@primate/core": "^0.
|
|
28
|
+
"@primate/core": "^0.9.0"
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
31
|
"solid-js": "1",
|
|
33
|
-
"primate": "^0.
|
|
32
|
+
"primate": "^0.40.0"
|
|
34
33
|
},
|
|
35
34
|
"imports": {
|
|
36
|
-
"#i18n/Bridge.default": {
|
|
37
|
-
"@primate/source": "./src/private/i18n/Bridge.default.tsx",
|
|
38
|
-
"default": "./lib/private/i18n/Bridge.default.js"
|
|
39
|
-
},
|
|
40
35
|
"#*": {
|
|
41
36
|
"@primate/source": "./src/private/*.ts",
|
|
42
37
|
"default": "./lib/private/*.js"
|
|
@@ -50,25 +45,22 @@
|
|
|
50
45
|
"exports": {
|
|
51
46
|
".": {
|
|
52
47
|
"types": "./lib/index.d.ts",
|
|
48
|
+
"browser": {
|
|
49
|
+
"@primate/source": "./src/public/browser.ts",
|
|
50
|
+
"default": "./lib/public/browser.js"
|
|
51
|
+
},
|
|
53
52
|
"@primate/runtime": "./src/public/runtime.ts",
|
|
54
53
|
"@primate/source": "./src/public/default.ts",
|
|
55
|
-
"browser": "./lib/public/browser.js",
|
|
56
54
|
"runtime": "./lib/public/runtime.js",
|
|
57
55
|
"default": "./lib/public/default.js"
|
|
58
56
|
},
|
|
59
57
|
"./*": {
|
|
60
58
|
"@primate/source": "./src/public/*.ts",
|
|
61
59
|
"default": "./lib/public/*.js"
|
|
62
|
-
},
|
|
63
|
-
"./i18n/Bridge": {
|
|
64
|
-
"@primate/source": "./src/public/i18n/Bridge/default.ts",
|
|
65
|
-
"browser": "./lib/public/i18n/Bridge/browser.js",
|
|
66
|
-
"default": "./lib/public/i18n/Bridge/default.js"
|
|
67
60
|
}
|
|
68
61
|
},
|
|
69
62
|
"scripts": {
|
|
70
63
|
"build": "npm run clean && tsc && cp src/types/{app,index}.d.ts lib",
|
|
71
|
-
"postbuild": "node scripts/compile-jsx.js",
|
|
72
64
|
"clean": "rm -rf ./lib",
|
|
73
65
|
"lint": "eslint ."
|
|
74
66
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type API from "@primate/core/i18n/API";
|
|
2
|
-
import type Catalogs from "@primate/core/i18n/Catalogs";
|
|
3
|
-
import { type JSX } from "solid-js";
|
|
4
|
-
export default function I18nBridge<C extends Catalogs>(props: {
|
|
5
|
-
t: API<C>;
|
|
6
|
-
children?: JSX.Element;
|
|
7
|
-
}): any;
|
|
8
|
-
//# sourceMappingURL=Bridge.browser.d.ts.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { memo as _$memo } from "solid-js/web";
|
|
2
|
-
import AppContext from "#context/app";
|
|
3
|
-
import sInternal from "@primate/core/i18n/sInternal";
|
|
4
|
-
import { createSignal, onCleanup, onMount, useContext } from "solid-js";
|
|
5
|
-
function I18nBridge(props) {
|
|
6
|
-
const {
|
|
7
|
-
context
|
|
8
|
-
} = useContext(AppContext);
|
|
9
|
-
const server = context().i18n.locale;
|
|
10
|
-
if (server !== void 0 && server !== props.t.locale.get()) {
|
|
11
|
-
props.t[sInternal].init(server);
|
|
12
|
-
}
|
|
13
|
-
const [version, setVersion] = createSignal(props.t[sInternal].version);
|
|
14
|
-
const removeDepend = props.t[sInternal].depend(() => {
|
|
15
|
-
version();
|
|
16
|
-
});
|
|
17
|
-
const off = props.t.subscribe(() => setVersion(v => v + 1));
|
|
18
|
-
onMount(() => props.t[sInternal].restore());
|
|
19
|
-
onCleanup(() => {
|
|
20
|
-
off();
|
|
21
|
-
removeDepend();
|
|
22
|
-
});
|
|
23
|
-
return _$memo(() => props.children);
|
|
24
|
-
}
|
|
25
|
-
export { I18nBridge as default };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type API from "@primate/core/i18n/API";
|
|
2
|
-
import type Catalogs from "@primate/core/i18n/Catalogs";
|
|
3
|
-
import { type JSX } from "solid-js";
|
|
4
|
-
export default function I18nBridge<C extends Catalogs>(props: {
|
|
5
|
-
t: API<C>;
|
|
6
|
-
children?: JSX.Element;
|
|
7
|
-
}): any;
|
|
8
|
-
//# sourceMappingURL=Bridge.default.d.ts.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { memo as _$memo } from "solid-js/web";
|
|
2
|
-
import AppContext from "#context/app";
|
|
3
|
-
import sInternal from "@primate/core/i18n/sInternal";
|
|
4
|
-
import { useContext } from "solid-js";
|
|
5
|
-
function I18nBridge(props) {
|
|
6
|
-
const {
|
|
7
|
-
context
|
|
8
|
-
} = useContext(AppContext);
|
|
9
|
-
props.t[sInternal].init(context().i18n.locale);
|
|
10
|
-
return _$memo(() => props.children);
|
|
11
|
-
}
|
|
12
|
-
export { I18nBridge as default };
|