rask-ui 0.5.1 → 0.6.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 +19 -74
- package/dist/component.d.ts +2 -2
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +4 -4
- package/dist/createComputed.js +2 -2
- package/dist/createEffect.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,79 +68,24 @@ RASK gives you:
|
|
|
68
68
|
|
|
69
69
|
## Getting Started
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
The fastest way to get started is using `create-rask-ui`:
|
|
72
72
|
|
|
73
73
|
```bash
|
|
74
|
-
npm
|
|
74
|
+
npm create rask-ui my-app
|
|
75
|
+
cd my-app
|
|
76
|
+
npm run dev
|
|
75
77
|
```
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
RASK uses a custom Vite plugin powered by SWC for optimal JSX transformation. This plugin transforms JSX to Inferno's highly optimized `createVNode` calls and automatically converts function components to RASK's reactive component pattern.
|
|
80
|
-
|
|
81
|
-
#### 1. Configure Vite
|
|
82
|
-
|
|
83
|
-
Create or update your `vite.config.ts`:
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
import { defineConfig } from 'vite';
|
|
87
|
-
import { raskPlugin } from 'rask-ui/plugin';
|
|
88
|
-
|
|
89
|
-
export default defineConfig({
|
|
90
|
-
plugins: [raskPlugin()],
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**Plugin Options:**
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
raskPlugin({
|
|
98
|
-
// Enable/disable function component transformation
|
|
99
|
-
// Default: true
|
|
100
|
-
transformComponents: true,
|
|
101
|
-
|
|
102
|
-
// Add imports for Inferno utilities (usually not needed)
|
|
103
|
-
// Default: false
|
|
104
|
-
imports: false,
|
|
79
|
+
This will scaffold a new Vite project with RASK UI pre-configured and ready to go. You'll be prompted to choose between TypeScript or JavaScript.
|
|
105
80
|
|
|
106
|
-
|
|
107
|
-
// Default: "rask-ui"
|
|
108
|
-
importSource: "rask-ui",
|
|
81
|
+
### What's Included
|
|
109
82
|
|
|
110
|
-
|
|
111
|
-
// Default: false
|
|
112
|
-
defineAllArguments: false,
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### 2. Configure TypeScript
|
|
117
|
-
|
|
118
|
-
Update your `tsconfig.json`:
|
|
119
|
-
|
|
120
|
-
```json
|
|
121
|
-
{
|
|
122
|
-
"compilerOptions": {
|
|
123
|
-
"jsx": "react-jsx",
|
|
124
|
-
"jsxImportSource": "rask-ui",
|
|
125
|
-
"moduleResolution": "bundler",
|
|
126
|
-
"target": "ES2022",
|
|
127
|
-
"module": "ESNext",
|
|
128
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Key settings:**
|
|
134
|
-
|
|
135
|
-
- `"jsx": "react-jsx"` - Tells TypeScript to use the new JSX transform for type checking
|
|
136
|
-
- `"jsxImportSource": "rask-ui"` - Points to RASK's JSX runtime for type definitions
|
|
137
|
-
- `"moduleResolution": "bundler"` - Required for Vite
|
|
138
|
-
|
|
139
|
-
**How it works:**
|
|
83
|
+
The scaffolded project includes:
|
|
140
84
|
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
85
|
+
- ✅ Vite configured with the RASK plugin
|
|
86
|
+
- ✅ TypeScript or JavaScript with proper JSX configuration
|
|
87
|
+
- ✅ Hot Module Replacement (HMR) working out of the box
|
|
88
|
+
- ✅ Sample counter component to get you started
|
|
144
89
|
|
|
145
90
|
### Basic Example
|
|
146
91
|
|
|
@@ -173,7 +118,7 @@ function MyComponent(props) {
|
|
|
173
118
|
// SETUP PHASE - Runs once when component is created
|
|
174
119
|
const state = createState({ value: props.initial });
|
|
175
120
|
|
|
176
|
-
|
|
121
|
+
createMountEffect(() => {
|
|
177
122
|
console.log("Component mounted!");
|
|
178
123
|
});
|
|
179
124
|
|
|
@@ -614,15 +559,15 @@ function BatchingExample() {
|
|
|
614
559
|
|
|
615
560
|
### Lifecycle Hooks
|
|
616
561
|
|
|
617
|
-
#### `
|
|
562
|
+
#### `createMountEffect(callback)`
|
|
618
563
|
|
|
619
564
|
Registers a callback to run after the component is mounted to the DOM.
|
|
620
565
|
|
|
621
566
|
```tsx
|
|
622
|
-
import {
|
|
567
|
+
import { createMountEffect } from "rask-ui";
|
|
623
568
|
|
|
624
569
|
function Example() {
|
|
625
|
-
|
|
570
|
+
createMountEffect(() => {
|
|
626
571
|
console.log("Component mounted!");
|
|
627
572
|
});
|
|
628
573
|
|
|
@@ -641,12 +586,12 @@ function Example() {
|
|
|
641
586
|
|
|
642
587
|
---
|
|
643
588
|
|
|
644
|
-
#### `
|
|
589
|
+
#### `createCleanup(callback)`
|
|
645
590
|
|
|
646
591
|
Registers a callback to run when the component is unmounted.
|
|
647
592
|
|
|
648
593
|
```tsx
|
|
649
|
-
import {
|
|
594
|
+
import { createCleanup } from "rask-ui";
|
|
650
595
|
|
|
651
596
|
function Example() {
|
|
652
597
|
const state = createState({ time: Date.now() });
|
|
@@ -655,7 +600,7 @@ function Example() {
|
|
|
655
600
|
state.time = Date.now();
|
|
656
601
|
}, 1000);
|
|
657
602
|
|
|
658
|
-
|
|
603
|
+
createCleanup(() => {
|
|
659
604
|
clearInterval(interval);
|
|
660
605
|
});
|
|
661
606
|
|
|
@@ -1223,4 +1168,4 @@ MIT
|
|
|
1223
1168
|
|
|
1224
1169
|
## Why "RASK"?
|
|
1225
1170
|
|
|
1226
|
-
The name comes from Norwegian
|
|
1171
|
+
The name comes from Norwegian meaning "fast" - which captures the essence of this library: fast to write, fast to understand, and fast to run.
|
package/dist/component.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VNode, Component, Props } from "inferno";
|
|
2
2
|
export declare function getCurrentComponent(): RaskComponent<any>;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
3
|
+
export declare function createMountEffect(cb: () => void): void;
|
|
4
|
+
export declare function createCleanup(cb: () => void): void;
|
|
5
5
|
export type RaskFunctionComponent<P extends Props<any>> = (() => () => VNode) | ((props: P) => () => VNode);
|
|
6
6
|
export declare class RaskComponent<P extends Props<any>> extends Component<P> {
|
|
7
7
|
setup: RaskFunctionComponent<P>;
|
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,EAEN,MAAM,SAAS,CAAC;AAQjB,wBAAgB,mBAAmB,uBAMlC;AAED,wBAAgB,
|
|
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;AAQjB,wBAAgB,mBAAmB,uBAMlC;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI,QAM/C;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,IAAI,QAM3C;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,qBAAa,aAAa,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC3D,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,QAAQ,CAAC,CAAc;IAC/B,OAAO,CAAC,aAAa,CAAC,CAAa;IACnC,OAAO,CAAC,QAAQ,CAEb;IACH,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAM;IAC3D,QAAQ,gBAAa;IACrB,eAAe;IAUf,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IACjC,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IACnC,OAAO,CAAC,mBAAmB;IA2D3B,iBAAiB,IAAI,IAAI;IAGzB,oBAAoB,IAAI,IAAI;IAG5B;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,GAAG;IAYlC,yBAAyB,IAAI,IAAI;IACjC,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO;IAerD,MAAM;CAyCP;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,SAO9D"}
|
package/dist/component.js
CHANGED
|
@@ -8,15 +8,15 @@ export function getCurrentComponent() {
|
|
|
8
8
|
}
|
|
9
9
|
return currentComponent;
|
|
10
10
|
}
|
|
11
|
-
export function
|
|
11
|
+
export function createMountEffect(cb) {
|
|
12
12
|
if (!currentComponent) {
|
|
13
|
-
throw new Error("Only use
|
|
13
|
+
throw new Error("Only use createMountEffect in component setup");
|
|
14
14
|
}
|
|
15
15
|
currentComponent.onMounts.push(cb);
|
|
16
16
|
}
|
|
17
|
-
export function
|
|
17
|
+
export function createCleanup(cb) {
|
|
18
18
|
if (!currentComponent) {
|
|
19
|
-
throw new Error("Only use
|
|
19
|
+
throw new Error("Only use createCleanup in component setup");
|
|
20
20
|
}
|
|
21
21
|
currentComponent.onCleanups.push(cb);
|
|
22
22
|
}
|
package/dist/createComputed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentComponent,
|
|
1
|
+
import { getCurrentComponent, createCleanup } from "./component";
|
|
2
2
|
import { getCurrentObserver, Observer, Signal } from "./observation";
|
|
3
3
|
export function createComputed(computed) {
|
|
4
4
|
let currentComponent;
|
|
@@ -18,7 +18,7 @@ export function createComputed(computed) {
|
|
|
18
18
|
signal.notify();
|
|
19
19
|
});
|
|
20
20
|
if (currentComponent) {
|
|
21
|
-
|
|
21
|
+
createCleanup(() => computedObserver.dispose());
|
|
22
22
|
}
|
|
23
23
|
Object.defineProperty(proxy, prop, {
|
|
24
24
|
get() {
|
package/dist/createEffect.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentComponent,
|
|
1
|
+
import { getCurrentComponent, createCleanup } from "./component";
|
|
2
2
|
import { Observer } from "./observation";
|
|
3
3
|
export function createEffect(cb) {
|
|
4
4
|
let currentComponent;
|
|
@@ -19,7 +19,7 @@ export function createEffect(cb) {
|
|
|
19
19
|
stopObserving();
|
|
20
20
|
};
|
|
21
21
|
if (currentComponent) {
|
|
22
|
-
|
|
22
|
+
createCleanup(() => observer.dispose());
|
|
23
23
|
}
|
|
24
24
|
runEffect();
|
|
25
25
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { render } from "./render";
|
|
2
|
-
export {
|
|
2
|
+
export { createCleanup, createMountEffect, RaskComponent } from "./component";
|
|
3
3
|
export { createContext } from "./createContext";
|
|
4
4
|
export { createState } from "./createState";
|
|
5
5
|
export { createAsync } from "./createAsync";
|
|
@@ -11,4 +11,5 @@ export { createView } from "./createView";
|
|
|
11
11
|
export { createEffect } from "./createEffect";
|
|
12
12
|
export { createComputed } from "./createComputed";
|
|
13
13
|
export { syncBatch } from "./batch";
|
|
14
|
+
export { createVNode, createComponentVNode, createFragment, createTextVNode, normalizeProps, } from "inferno";
|
|
14
15
|
//# 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,UAAU,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9E,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;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { render } from "./render";
|
|
2
|
-
export {
|
|
2
|
+
export { createCleanup, createMountEffect, RaskComponent } from "./component";
|
|
3
3
|
export { createContext } from "./createContext";
|
|
4
4
|
export { createState } from "./createState";
|
|
5
5
|
export { createAsync } from "./createAsync";
|
|
@@ -11,3 +11,5 @@ export { createView } from "./createView";
|
|
|
11
11
|
export { createEffect } from "./createEffect";
|
|
12
12
|
export { createComputed } from "./createComputed";
|
|
13
13
|
export { syncBatch } from "./batch";
|
|
14
|
+
// Re-export Inferno JSX runtime functions so users don't need to install Inferno directly
|
|
15
|
+
export { createVNode, createComponentVNode, createFragment, createTextVNode, normalizeProps, } from "inferno";
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ const require = createRequire(import.meta.url);
|
|
|
8
8
|
* Vite plugin for transforming JSX to Inferno and function components to RaskComponent classes
|
|
9
9
|
*/
|
|
10
10
|
export function raskPlugin(options = {}) {
|
|
11
|
-
const { transformComponents = true, imports =
|
|
11
|
+
const { transformComponents = true, imports = true, importSource = 'rask-ui', defineAllArguments = false, } = options;
|
|
12
12
|
// Resolve the path to swc-plugin-inferno WASM file
|
|
13
13
|
const infernoPluginPath = require.resolve('swc-plugin-inferno/swc_plugin_inferno.wasm');
|
|
14
14
|
// Resolve the path to our RaskComponent plugin
|