@davidcal/frosth 1.0.3 → 1.1.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 +2 -2
- package/package.json +2 -1
- package/src/create_memo.js +11 -0
- package/src/create_signal.js +1 -1
- package/src/create_signal_raw.js +1 -0
- package/src/h.js +22 -4
- package/src/sigew.js +2 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Frosth - Yet another UI framework
|
|
2
2
|
|
|
3
|
-
**Latest version**: v1.0
|
|
3
|
+
**Latest version**: v1.1.0
|
|
4
4
|
|
|
5
5
|
## Motivation
|
|
6
6
|
|
|
@@ -200,7 +200,7 @@ const Component = obtain(async ({ t, s }) => {
|
|
|
200
200
|
|
|
201
201
|
installed.set(() => [
|
|
202
202
|
(s) => s.$h1({
|
|
203
|
-
ref:
|
|
203
|
+
ref: ["on_create", ref_text.set],
|
|
204
204
|
}, "Click the button to change my color"),
|
|
205
205
|
(s) => s.$button({
|
|
206
206
|
onclick: () => () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@davidcal/frosth",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Async-first CRUD-last UI framework that treats encapsulation as a solved problem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/sigew.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"author": "David P. Callanan",
|
|
21
21
|
"license": "MIT",
|
|
22
|
+
"homepage": "https://frosth.condensis.com",
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|
|
24
25
|
"url": "https://github.com/davidcallanan/frosth"
|
package/src/create_signal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create_signal_raw } from "./create_signal_raw.js";
|
|
2
2
|
|
|
3
3
|
const error_value = () => {
|
|
4
|
-
throw new Error("Signal value must be a reactive function. Wrap the value in either `() =>` or `(
|
|
4
|
+
throw new Error("Signal value must be a reactive function. Wrap the value in either `() =>` or `(s) =>` depending on whether or not the current value should be reactive, beyond the mere reactivity of the signal.");
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const create_signal = (initial) => {
|
package/src/create_signal_raw.js
CHANGED
package/src/h.js
CHANGED
|
@@ -21,10 +21,28 @@ export const h = (s, tag, props, children) => {
|
|
|
21
21
|
prev = handler;
|
|
22
22
|
});
|
|
23
23
|
} else if (key === "ref") {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (typeof props[key] === "function") {
|
|
25
|
+
console.warn("[Frosth] Deprecated: Instead of `ref: () => signal.set`, use `ref: [\"on_create\", signal.set]`");
|
|
26
|
+
|
|
27
|
+
s.create_effect(() => {
|
|
28
|
+
const ref_set = props[key](s);
|
|
29
|
+
ref_set(() => el);
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
if (!Array.isArray(props[key])) {
|
|
33
|
+
throw new Error("[Frosth] Ref must be an array, either `[\"on_create\", signal.set]` or `[\"on_mount\", signal.set]`");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [when, ref_set] = props[key];
|
|
37
|
+
|
|
38
|
+
if (when === "on_create") {
|
|
39
|
+
ref_set(() => el);
|
|
40
|
+
} else if (when === "on_mount") {
|
|
41
|
+
throw new Error("[Frosth] Ref \"on_mount\" strategy not yet implemented.");
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error(`[Frosth] Invalid ref strategy "${when}"`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
28
46
|
} else {
|
|
29
47
|
s.create_effect((s) => {
|
|
30
48
|
const prop$ = props[key](s);
|
package/src/sigew.js
CHANGED
|
@@ -5,10 +5,12 @@ import { create_signal } from "./create_signal.js";
|
|
|
5
5
|
import { h } from "./h.js";
|
|
6
6
|
import { render } from "./render.js";
|
|
7
7
|
import { MARK_INSTALLABLE } from "./constants.js";
|
|
8
|
+
import { create_memo } from "./create_memo.js";
|
|
8
9
|
|
|
9
10
|
export { create_self };
|
|
10
11
|
export { create_signal };
|
|
11
12
|
export { h };
|
|
13
|
+
export { create_memo };
|
|
12
14
|
|
|
13
15
|
export const installarea = (s) => {
|
|
14
16
|
const storage = s.create_housed_signal(() => undefined);
|