rask-ui 0.3.0 → 0.3.2
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/dist/component.d.ts +1 -3
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +26 -13
- package/dist/createContext.d.ts.map +1 -1
- package/dist/createContext.js +8 -1
- package/dist/error.d.ts +4 -3
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +4 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx-runtime.d.ts +2 -1
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -966,7 +966,7 @@ RASK is designed for performance:
|
|
|
966
966
|
|
|
967
967
|
- **Fine-grained reactivity**: Only components that access changed state re-render
|
|
968
968
|
- **No wasted renders**: Components skip re-render if reactive dependencies haven't changed
|
|
969
|
-
- **Efficient DOM updates**: Powered by
|
|
969
|
+
- **Efficient DOM updates**: Powered by Inferno's highly optimized virtual DOM reconciler
|
|
970
970
|
- **No reconciler overhead for state**: State changes are direct, no diffing required
|
|
971
971
|
- **Automatic cleanup**: Components and effects cleaned up automatically
|
|
972
972
|
|
|
@@ -977,7 +977,7 @@ RASK is designed for performance:
|
|
|
977
977
|
| State management | Complex (hooks, closures) | Simple (signals) | Simple (proxies) |
|
|
978
978
|
| UI expression | Excellent | Limited | Excellent |
|
|
979
979
|
| Reactivity | Coarse (component level) | Fine-grained | Fine-grained |
|
|
980
|
-
| Reconciler | Yes | Limited | Yes (
|
|
980
|
+
| Reconciler | Yes | Limited | Yes (Inferno) |
|
|
981
981
|
| Syntax | JSX | JSX + special components | JSX |
|
|
982
982
|
| Compiler required | No | Yes | No |
|
|
983
983
|
| Learning curve | Steep | Moderate | Gentle |
|
package/dist/component.d.ts
CHANGED
|
@@ -11,9 +11,7 @@ declare class RaskComponent<P extends Props<any>> extends Component<P & {
|
|
|
11
11
|
private prevChildren;
|
|
12
12
|
private observer;
|
|
13
13
|
contexts: Map<any, any>;
|
|
14
|
-
getChildContext():
|
|
15
|
-
getContext: (context: any) => any;
|
|
16
|
-
};
|
|
14
|
+
getChildContext(): any;
|
|
17
15
|
onMounts: Array<() => void>;
|
|
18
16
|
onCleanups: Array<() => void>;
|
|
19
17
|
componentDidMount(): void;
|
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,EACL,WAAW,EACZ,MAAM,SAAS,CAAC;AAMjB,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,SAAS,EACT,KAAK,EACL,WAAW,EACZ,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,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;IAGzB,yBAAyB,CACvB,SAAS,EAAE,QAAQ,CACjB;QAAE,QAAQ,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,CAAC,GAAG;QAAE,WAAW,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAA;KAAE,CAC3E,GACA,IAAI;IAaP,oBAAoB,IAAI,IAAI;IAG5B,qBAAqB,IAAI,OAAO;IAGhC,MAAM;CAuCP;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,SAO9D"}
|
package/dist/component.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { createComponentVNode, Component, } from "inferno";
|
|
2
2
|
import { getCurrentObserver, Observer, Signal } from "./observation";
|
|
3
|
-
|
|
3
|
+
let currentComponent;
|
|
4
4
|
export function getCurrentComponent() {
|
|
5
|
-
const currentComponent = componentStack[0];
|
|
6
5
|
if (!currentComponent) {
|
|
7
6
|
throw new Error("No current component");
|
|
8
7
|
}
|
|
9
8
|
return currentComponent;
|
|
10
9
|
}
|
|
11
10
|
export function onMount(cb) {
|
|
12
|
-
|
|
13
|
-
if (!current) {
|
|
11
|
+
if (!currentComponent) {
|
|
14
12
|
throw new Error("Only use onCleanup in component setup");
|
|
15
13
|
}
|
|
16
|
-
|
|
14
|
+
currentComponent.onMounts.push(cb);
|
|
17
15
|
}
|
|
18
16
|
export function onCleanup(cb) {
|
|
19
|
-
|
|
20
|
-
if (!current) {
|
|
17
|
+
if (!currentComponent) {
|
|
21
18
|
throw new Error("Only use onCleanup in component setup");
|
|
22
19
|
}
|
|
23
|
-
|
|
20
|
+
currentComponent.onCleanups.push(cb);
|
|
24
21
|
}
|
|
25
22
|
class RaskComponent extends Component {
|
|
26
23
|
renderFn;
|
|
@@ -31,9 +28,11 @@ class RaskComponent extends Component {
|
|
|
31
28
|
});
|
|
32
29
|
contexts = new Map();
|
|
33
30
|
getChildContext() {
|
|
31
|
+
const parentGetContext = this.context.getContext;
|
|
34
32
|
return {
|
|
33
|
+
...this.context,
|
|
35
34
|
getContext: (context) => {
|
|
36
|
-
return this.contexts.get(context);
|
|
35
|
+
return this.contexts.get(context) || parentGetContext(context);
|
|
37
36
|
},
|
|
38
37
|
};
|
|
39
38
|
}
|
|
@@ -64,10 +63,22 @@ class RaskComponent extends Component {
|
|
|
64
63
|
}
|
|
65
64
|
render() {
|
|
66
65
|
if (!this.renderFn) {
|
|
67
|
-
componentStack.unshift(this);
|
|
68
66
|
this.reactiveProps = createReactiveProps(this.props);
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
currentComponent = this;
|
|
68
|
+
try {
|
|
69
|
+
this.renderFn = this.props.__component(this.reactiveProps);
|
|
70
|
+
if (typeof this.renderFn !== "function") {
|
|
71
|
+
throw new Error("Component must return a render function");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (typeof this.context.notifyError !== "function") {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
this.context.notifyError(error);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
currentComponent = undefined;
|
|
71
82
|
}
|
|
72
83
|
const stopObserving = this.observer.observe();
|
|
73
84
|
let result = null;
|
|
@@ -75,6 +86,9 @@ class RaskComponent extends Component {
|
|
|
75
86
|
result = this.renderFn();
|
|
76
87
|
}
|
|
77
88
|
catch (error) {
|
|
89
|
+
if (typeof this.context.notifyError !== "function") {
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
78
92
|
this.context.notifyError(error);
|
|
79
93
|
}
|
|
80
94
|
finally {
|
|
@@ -84,7 +98,6 @@ class RaskComponent extends Component {
|
|
|
84
98
|
}
|
|
85
99
|
}
|
|
86
100
|
export function createComponent(props, key) {
|
|
87
|
-
console.log(props);
|
|
88
101
|
return createComponentVNode(4 /* VNodeFlags.ComponentClass */, RaskComponent, props, key);
|
|
89
102
|
}
|
|
90
103
|
function createReactiveProps(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContext.d.ts","sourceRoot":"","sources":["../src/createContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,wBAAgB,aAAa,CAAC,CAAC;kBAEb,CAAC;WASR,CAAC;
|
|
1
|
+
{"version":3,"file":"createContext.d.ts","sourceRoot":"","sources":["../src/createContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,wBAAgB,aAAa,CAAC,CAAC;kBAEb,CAAC;WASR,CAAC;EA0BX"}
|
package/dist/createContext.js
CHANGED
|
@@ -37,7 +37,14 @@ export function createContext() {
|
|
|
37
37
|
if (!currentComponent) {
|
|
38
38
|
throw new Error("You can not get context outside component setup");
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
if (typeof currentComponent.context.getContext !== "function") {
|
|
41
|
+
throw new Error("There is no parent context");
|
|
42
|
+
}
|
|
43
|
+
const contextValue = currentComponent.context.getContext(context);
|
|
44
|
+
if (!contextValue) {
|
|
45
|
+
throw new Error("There is a parent context, but not the one you are using");
|
|
46
|
+
}
|
|
47
|
+
return contextValue;
|
|
41
48
|
},
|
|
42
49
|
};
|
|
43
50
|
return context;
|
package/dist/error.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Component } from "inferno";
|
|
1
|
+
import { Component, VNode } from "inferno";
|
|
2
2
|
export declare class ErrorBoundary extends Component<{
|
|
3
3
|
children: any;
|
|
4
|
+
error: (error: unknown) => VNode;
|
|
4
5
|
}, {
|
|
5
|
-
|
|
6
|
+
error: unknown;
|
|
6
7
|
}> {
|
|
7
8
|
getChildContext(): {
|
|
8
9
|
notifyError: (error: unknown) => void;
|
|
9
10
|
};
|
|
10
11
|
state: {
|
|
11
|
-
|
|
12
|
+
error: null;
|
|
12
13
|
};
|
|
13
14
|
render(): any;
|
|
14
15
|
}
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,qBAAa,aAAc,SAAQ,SAAS,CAC1C;IAAE,QAAQ,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,CAAA;CAAE,EACnD;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CACnB;IACC,eAAe;6BAEU,OAAO;;IAKhC,KAAK;;MAAmB;IAExB,MAAM;CAOP"}
|
package/dist/error.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx } from "./jsx-runtime";
|
|
2
1
|
import { Component } from "inferno";
|
|
3
2
|
export class ErrorBoundary extends Component {
|
|
4
3
|
getChildContext() {
|
|
5
4
|
return {
|
|
6
5
|
notifyError: (error) => {
|
|
7
|
-
this.setState({
|
|
6
|
+
this.setState({ error });
|
|
8
7
|
},
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
|
-
state = {
|
|
10
|
+
state = { error: null };
|
|
12
11
|
render() {
|
|
13
|
-
if (this.state.
|
|
14
|
-
return
|
|
12
|
+
if (this.state.error) {
|
|
13
|
+
return this.props.error(this.state.error);
|
|
15
14
|
}
|
|
16
15
|
return this.props.children;
|
|
17
16
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export { createAsync } from "./createAsync";
|
|
|
6
6
|
export { ErrorBoundary } from "./error";
|
|
7
7
|
export { createQuery } from "./createQuery";
|
|
8
8
|
export { createMutation } from "./createMutation";
|
|
9
|
-
export { createRef } from "
|
|
9
|
+
export { createRef } from "inferno";
|
|
10
10
|
export { createView } from "./createView";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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"}
|
package/dist/index.js
CHANGED
|
@@ -6,5 +6,5 @@ export { createAsync } from "./createAsync";
|
|
|
6
6
|
export { ErrorBoundary } from "./error";
|
|
7
7
|
export { createQuery } from "./createQuery";
|
|
8
8
|
export { createMutation } from "./createMutation";
|
|
9
|
-
export { createRef } from "
|
|
9
|
+
export { createRef } from "inferno";
|
|
10
10
|
export { createView } from "./createView";
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Component } from "inferno";
|
|
1
2
|
import type { JSXInternal } from "./jsx";
|
|
2
3
|
export { Fragment } from "inferno";
|
|
3
4
|
export declare function jsx(type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any>, key?: string): any;
|
|
4
|
-
export declare function jsx<P>(type: (props: P) => any, props: P & {
|
|
5
|
+
export declare function jsx<P>(type: ((props: P) => any) | (new () => Component), props: P & {
|
|
5
6
|
children?: any;
|
|
6
7
|
}, key?: string): any;
|
|
7
8
|
export declare function jsxs(type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any>, key?: string): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,GAAG,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,cAAc,GAC/B,WAAW,CAAC,aAAa,GACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrB,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AACP,wBAAgB,GAAG,CAAC,CAAC,EACnB,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,UAAU,SAAS,CAAC,EACjD,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,EAC7B,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AAsBP,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,cAAc,GAC/B,WAAW,CAAC,aAAa,GACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrB,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AACP,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,EACvB,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAA;CAAE,EAC/B,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AAMP,YAAY,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -6,10 +6,9 @@ import { ErrorBoundary } from "./error";
|
|
|
6
6
|
export { Fragment } from "inferno";
|
|
7
7
|
export function jsx(type, { children, ...props }, key) {
|
|
8
8
|
if (typeof type === "string") {
|
|
9
|
-
return createElement(type, { ...props, key }, ...children);
|
|
9
|
+
return createElement(type, { ...props, key }, ...(Array.isArray(children) ? children : [children]));
|
|
10
10
|
}
|
|
11
11
|
if (type === ErrorBoundary) {
|
|
12
|
-
console.log("WTF");
|
|
13
12
|
return createComponentVNode(14 /* VNodeFlags.Component */, ErrorBoundary, { ...props, children }, key);
|
|
14
13
|
}
|
|
15
14
|
return createComponent({ ...props, children, __component: type }, key);
|