rask-ui 0.3.2 → 0.3.3
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 +3 -3
- package/dist/component.d.ts +3 -7
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +10 -16
- package/dist/createState.js +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ Solid offers a simpler mental model with fine-grained reactivity. Updates don't
|
|
|
46
46
|
|
|
47
47
|
- Requires understanding special compiler transformations
|
|
48
48
|
- Special components for expressing dynamic UIs (`<Show>`, `<For>`, etc.)
|
|
49
|
-
-
|
|
49
|
+
- Different signatures for accessing reactive values: `count()` VS `state.count`
|
|
50
50
|
|
|
51
51
|
### RASK: Best of Both Worlds
|
|
52
52
|
|
|
@@ -66,6 +66,8 @@ RASK gives you:
|
|
|
66
66
|
- **No compiler magic** - Plain JavaScript/TypeScript
|
|
67
67
|
- **Simple mental model** - State updates trigger only affected components
|
|
68
68
|
|
|
69
|
+
Built on [Inferno JS](https://github.com/infernojs/inferno).
|
|
70
|
+
|
|
69
71
|
## Getting Started
|
|
70
72
|
|
|
71
73
|
### Installation
|
|
@@ -233,8 +235,6 @@ Reactive objects are implemented using JavaScript Proxies. When you access a pro
|
|
|
233
235
|
- `createMutation()` - Never destructure mutation objects
|
|
234
236
|
- `createView()` - Never destructure view objects
|
|
235
237
|
|
|
236
|
-
**Learn more:** This is the same design decision as [Solid.js reactive primitives](https://www.solidjs.com/tutorial/introduction_signals), which also use this pattern for fine-grained reactivity.
|
|
237
|
-
|
|
238
238
|
## API Reference
|
|
239
239
|
|
|
240
240
|
### Core Functions
|
package/dist/component.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VNode, Component, Props
|
|
1
|
+
import { VNode, Component, Props } from "inferno";
|
|
2
2
|
export declare function getCurrentComponent(): RaskComponent<any>;
|
|
3
3
|
export declare function onMount(cb: () => void): void;
|
|
4
4
|
export declare function onCleanup(cb: () => void): void;
|
|
@@ -10,18 +10,14 @@ declare class RaskComponent<P extends Props<any>> extends Component<P & {
|
|
|
10
10
|
private reactiveProps?;
|
|
11
11
|
private prevChildren;
|
|
12
12
|
private observer;
|
|
13
|
+
private hasDirtyProps;
|
|
13
14
|
contexts: Map<any, any>;
|
|
14
15
|
getChildContext(): any;
|
|
15
16
|
onMounts: Array<() => void>;
|
|
16
17
|
onCleanups: Array<() => void>;
|
|
17
18
|
componentDidMount(): void;
|
|
18
|
-
componentWillReceiveProps(nextProps: Readonly<{
|
|
19
|
-
children?: InfernoNode;
|
|
20
|
-
} & P & {
|
|
21
|
-
__component: RaskFunctionComponent<P>;
|
|
22
|
-
}>): void;
|
|
23
19
|
componentWillUnmount(): void;
|
|
24
|
-
shouldComponentUpdate(): boolean;
|
|
20
|
+
shouldComponentUpdate(nextProps: Props<any>): boolean;
|
|
25
21
|
render(): any;
|
|
26
22
|
}
|
|
27
23
|
export declare function createComponent(props: Props<any>, key?: string): VNode;
|
package/dist/component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,SAAS,EACT,KAAK,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,SAAS,EACT,KAAK,EAEN,MAAM,SAAS,CAAC;AAMjB,wBAAgB,mBAAmB,uBAMlC;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,IAAI,QAMrC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,QAMvC;AAED,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAClD,CAAC,MAAM,MAAM,KAAK,CAAC,GACnB,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AAEhC,cAAM,aAAa,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,CAAE,SAAQ,SAAS,CACzD,CAAC,GAAG;IAAE,WAAW,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAA;CAAE,CAC9C;IACC,OAAO,CAAC,QAAQ,CAAC,CAAc;IAC/B,OAAO,CAAC,aAAa,CAAC,CAAa;IACnC,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,QAAQ,CAEb;IACH,OAAO,CAAC,aAAa,CAAS;IAC9B,QAAQ,gBAAa;IACrB,eAAe;IAUf,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IACjC,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IACnC,iBAAiB,IAAI,IAAI;IAIzB,oBAAoB,IAAI,IAAI;IAG5B,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO;IAYrD,MAAM;CAuCP;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,SAO9D"}
|
package/dist/component.js
CHANGED
|
@@ -26,6 +26,7 @@ class RaskComponent extends Component {
|
|
|
26
26
|
observer = new Observer(() => {
|
|
27
27
|
this.forceUpdate();
|
|
28
28
|
});
|
|
29
|
+
hasDirtyProps = false;
|
|
29
30
|
contexts = new Map();
|
|
30
31
|
getChildContext() {
|
|
31
32
|
const parentGetContext = this.context.getContext;
|
|
@@ -41,25 +42,18 @@ class RaskComponent extends Component {
|
|
|
41
42
|
componentDidMount() {
|
|
42
43
|
this.onMounts.forEach((cb) => cb());
|
|
43
44
|
}
|
|
44
|
-
componentWillReceiveProps(nextProps) {
|
|
45
|
-
if (this.props.children === nextProps.children) {
|
|
46
|
-
for (const prop in nextProps) {
|
|
47
|
-
if (prop === "children") {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
this.reactiveProps[prop] = nextProps[prop];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
this.prevChildren = this.props.children;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
45
|
componentWillUnmount() {
|
|
59
46
|
this.onCleanups.forEach((cb) => cb());
|
|
60
47
|
}
|
|
61
|
-
shouldComponentUpdate() {
|
|
62
|
-
|
|
48
|
+
shouldComponentUpdate(nextProps) {
|
|
49
|
+
for (const prop in nextProps) {
|
|
50
|
+
if (prop === "__component") {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
this.reactiveProps[prop] = nextProps[prop];
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
63
57
|
}
|
|
64
58
|
render() {
|
|
65
59
|
if (!this.renderFn) {
|
package/dist/createState.js
CHANGED
|
@@ -27,7 +27,7 @@ export function createState(state) {
|
|
|
27
27
|
return getProxy(state);
|
|
28
28
|
}
|
|
29
29
|
const proxyCache = new WeakMap();
|
|
30
|
-
const PROXY_MARKER = Symbol(
|
|
30
|
+
const PROXY_MARKER = Symbol("isProxy");
|
|
31
31
|
function getProxy(value) {
|
|
32
32
|
// Check if already a proxy to avoid double-wrapping
|
|
33
33
|
if (PROXY_MARKER in value) {
|
|
@@ -70,12 +70,13 @@ function getProxy(value) {
|
|
|
70
70
|
return Reflect.set(target, key, newValue);
|
|
71
71
|
}
|
|
72
72
|
const oldValue = Reflect.get(target, key);
|
|
73
|
+
const setResult = Reflect.set(target, key, newValue);
|
|
73
74
|
// We only notify if actual change, though array length actually updates under the hood
|
|
74
75
|
if (newValue !== oldValue || (Array.isArray(value) && key === "length")) {
|
|
75
76
|
const signal = signals[key];
|
|
76
77
|
signal?.notify();
|
|
77
78
|
}
|
|
78
|
-
return
|
|
79
|
+
return setResult;
|
|
79
80
|
},
|
|
80
81
|
deleteProperty(target, key) {
|
|
81
82
|
if (typeof key === "symbol") {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,aAEjC;AAKD,qBAAa,MAAM;IACjB,OAAO,CAAC,WAAW,CAAyB;IAC5C,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI;IAOxB,MAAM;
|
|
1
|
+
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,aAEjC;AAKD,qBAAa,MAAM;IACjB,OAAO,CAAC,WAAW,CAAyB;IAC5C,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI;IAOxB,MAAM;CAIP;AAED,qBAAa,QAAQ;IACnB,UAAU,UAAS;IACnB,OAAO,CAAC,eAAe,CAAyB;IAChD,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ,CAAa;gBACjB,QAAQ,EAAE,MAAM,IAAI;IAGhC,eAAe,CAAC,MAAM,EAAE,MAAM;IAG9B,OAAO;IAOP,OAAO;CAIR"}
|
package/dist/observation.js
CHANGED
|
@@ -14,18 +14,7 @@ export class Signal {
|
|
|
14
14
|
}
|
|
15
15
|
notify() {
|
|
16
16
|
const currentSubscribers = Array.from(this.subscribers);
|
|
17
|
-
|
|
18
|
-
currentSubscribers.forEach((cb) => cb());
|
|
19
|
-
});
|
|
20
|
-
if (!isQueuingNotify) {
|
|
21
|
-
isQueuingNotify = true;
|
|
22
|
-
queueMicrotask(() => {
|
|
23
|
-
isQueuingNotify = false;
|
|
24
|
-
const queue = notifyQueue;
|
|
25
|
-
notifyQueue = [];
|
|
26
|
-
queue.forEach((cb) => cb());
|
|
27
|
-
});
|
|
28
|
-
}
|
|
17
|
+
currentSubscribers.forEach((cb) => cb());
|
|
29
18
|
}
|
|
30
19
|
}
|
|
31
20
|
export class Observer {
|