rask-ui 0.7.0 → 0.8.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/dist/createState.d.ts.map +1 -1
- package/dist/createState.js +14 -3
- package/dist/createTask.js +0 -1
- package/dist/createView.d.ts.map +1 -1
- package/dist/createView.js +35 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/inspect.d.ts +13 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +7 -0
- package/dist/plugin.d.ts +2 -7
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +12 -4
- package/package.json +1 -1
- package/swc-plugin/src/lib.rs +26 -0
- package/swc-plugin/target/wasm32-wasip1/release/deps/libswc_plugin_rask_component.rlib +0 -0
- package/swc-plugin/target/wasm32-wasip1/release/deps/swc_plugin_rask_component.d +3 -3
- package/swc-plugin/target/wasm32-wasip1/release/deps/swc_plugin_rask_component.wasm +0 -0
- package/swc-plugin/target/wasm32-wasip1/release/libswc_plugin_rask_component.rlib +0 -0
- package/swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createState.d.ts","sourceRoot":"","sources":["../src/createState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createState.d.ts","sourceRoot":"","sources":["../src/createState.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEzD;AAGD,eAAO,MAAM,YAAY,eAAoB,CAAC"}
|
package/dist/createState.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { INSPECT_MARKER } from "./inspect";
|
|
1
2
|
import { getCurrentObserver, Signal } from "./observation";
|
|
2
3
|
/**
|
|
3
4
|
* Creates a reactive state object that tracks property access and notifies observers on changes.
|
|
@@ -28,7 +29,7 @@ export function createState(state) {
|
|
|
28
29
|
}
|
|
29
30
|
const proxyCache = new WeakMap();
|
|
30
31
|
export const PROXY_MARKER = Symbol("isProxy");
|
|
31
|
-
function getProxy(value) {
|
|
32
|
+
function getProxy(value, notifyInspector, path) {
|
|
32
33
|
// Check if already a proxy to avoid double-wrapping
|
|
33
34
|
if (PROXY_MARKER in value) {
|
|
34
35
|
return value;
|
|
@@ -47,7 +48,7 @@ function getProxy(value) {
|
|
|
47
48
|
},
|
|
48
49
|
get(target, key) {
|
|
49
50
|
// Mark this as a proxy to prevent double-wrapping
|
|
50
|
-
if (key === PROXY_MARKER) {
|
|
51
|
+
if (key === PROXY_MARKER || key === INSPECT_MARKER) {
|
|
51
52
|
return true;
|
|
52
53
|
}
|
|
53
54
|
const value = Reflect.get(target, key);
|
|
@@ -61,11 +62,16 @@ function getProxy(value) {
|
|
|
61
62
|
}
|
|
62
63
|
if (Array.isArray(value) ||
|
|
63
64
|
(typeof value === "object" && value !== null)) {
|
|
64
|
-
return getProxy(value);
|
|
65
|
+
return getProxy(value, notifyInspector, notifyInspector ? (path ? path.concat(key) : [key]) : undefined);
|
|
65
66
|
}
|
|
66
67
|
return value;
|
|
67
68
|
},
|
|
68
69
|
set(target, key, newValue) {
|
|
70
|
+
if (key === INSPECT_MARKER) {
|
|
71
|
+
notifyInspector = newValue.fn;
|
|
72
|
+
path = newValue.path;
|
|
73
|
+
return Reflect.set(target, key, newValue);
|
|
74
|
+
}
|
|
69
75
|
if (typeof key === "symbol") {
|
|
70
76
|
return Reflect.set(target, key, newValue);
|
|
71
77
|
}
|
|
@@ -76,6 +82,11 @@ function getProxy(value) {
|
|
|
76
82
|
const signal = signals[key];
|
|
77
83
|
signal?.notify();
|
|
78
84
|
}
|
|
85
|
+
notifyInspector?.({
|
|
86
|
+
type: "mutation",
|
|
87
|
+
path: path ? path.concat(key) : [key],
|
|
88
|
+
value: newValue,
|
|
89
|
+
});
|
|
79
90
|
return setResult;
|
|
80
91
|
},
|
|
81
92
|
deleteProperty(target, key) {
|
package/dist/createTask.js
CHANGED
package/dist/createView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createView.d.ts","sourceRoot":"","sources":["../src/createView.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createView.d.ts","sourceRoot":"","sources":["../src/createView.ts"],"names":[],"mappings":"AAGA,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAEjD,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,QAAQ,CAC1D,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CACrB,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI,CAAC,SAAS;IACtD,MAAM,CAAC,SAAS,MAAM;IACtB,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE;CAC5B,GACG,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GACzB,EAAE,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EACpD,GAAG,IAAI,EAAE,CAAC,GACT,SAAS,CAAC,CAAC,CAAC,CA4Dd"}
|
package/dist/createView.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { INSPECT_MARKER } from "./inspect";
|
|
1
2
|
/**
|
|
2
3
|
* Creates a view that merges multiple objects (reactive or not) into a single object while
|
|
3
4
|
* maintaining reactivity through getters. Properties from later arguments override earlier ones.
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
export function createView(...args) {
|
|
45
46
|
const result = {};
|
|
46
47
|
const seen = new Set();
|
|
48
|
+
let notifyInspector;
|
|
47
49
|
for (let i = args.length - 1; i >= 0; i--) {
|
|
48
50
|
const src = args[i];
|
|
49
51
|
// mimic Object.assign: only enumerable own property keys
|
|
@@ -57,12 +59,42 @@ export function createView(...args) {
|
|
|
57
59
|
Object.defineProperty(result, key, {
|
|
58
60
|
enumerable: true,
|
|
59
61
|
configurable: true,
|
|
60
|
-
get: () =>
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
get: () => {
|
|
63
|
+
const value = src[key];
|
|
64
|
+
if (!notifyInspector) {
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
if (value?.[INSPECT_MARKER]) {
|
|
68
|
+
value[INSPECT_MARKER] = {
|
|
69
|
+
fn: notifyInspector.fn,
|
|
70
|
+
path: notifyInspector.path.concat(key),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else if (typeof value === "function") {
|
|
74
|
+
return (...params) => {
|
|
75
|
+
notifyInspector.fn({
|
|
76
|
+
type: "action",
|
|
77
|
+
path: notifyInspector.path.concat(key),
|
|
78
|
+
params,
|
|
79
|
+
});
|
|
80
|
+
return value(...params);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
},
|
|
63
85
|
});
|
|
64
86
|
seen.add(key);
|
|
65
87
|
}
|
|
66
88
|
}
|
|
89
|
+
Object.defineProperty(result, INSPECT_MARKER, {
|
|
90
|
+
enumerable: false,
|
|
91
|
+
configurable: false,
|
|
92
|
+
get() {
|
|
93
|
+
return true;
|
|
94
|
+
},
|
|
95
|
+
set: (value) => {
|
|
96
|
+
notifyInspector = value;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
67
99
|
return result;
|
|
68
100
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export { createView } from "./createView";
|
|
|
9
9
|
export { createEffect } from "./createEffect";
|
|
10
10
|
export { createComputed } from "./createComputed";
|
|
11
11
|
export { syncBatch } from "./batch";
|
|
12
|
-
export {
|
|
12
|
+
export { inspect } from "./inspect";
|
|
13
|
+
export { createVNode, createComponentVNode, createFragment, createTextVNode, normalizeProps, Component, } from "inferno";
|
|
13
14
|
//# 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,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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,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,
|
|
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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,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;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,GACV,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,6 @@ export { createView } from "./createView";
|
|
|
9
9
|
export { createEffect } from "./createEffect";
|
|
10
10
|
export { createComputed } from "./createComputed";
|
|
11
11
|
export { syncBatch } from "./batch";
|
|
12
|
+
export { inspect } from "./inspect";
|
|
12
13
|
// Re-export Inferno JSX runtime functions so users don't need to install Inferno directly
|
|
13
|
-
export { createVNode, createComponentVNode, createFragment, createTextVNode, normalizeProps, } from "inferno";
|
|
14
|
+
export { createVNode, createComponentVNode, createFragment, createTextVNode, normalizeProps, Component, } from "inferno";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const INSPECT_MARKER: unique symbol;
|
|
2
|
+
export type InspectEvent = {
|
|
3
|
+
type: "mutation";
|
|
4
|
+
path: string[];
|
|
5
|
+
value: any;
|
|
6
|
+
} | {
|
|
7
|
+
type: "action";
|
|
8
|
+
path: string[];
|
|
9
|
+
params: any[];
|
|
10
|
+
};
|
|
11
|
+
export type InspectorCallback = (event: InspectEvent) => void;
|
|
12
|
+
export declare function inspect(root: any, cb: InspectorCallback): void;
|
|
13
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAAoB,CAAC;AAEhD,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;CACZ,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAE9D,wBAAgB,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,iBAAiB,QAKvD"}
|
package/dist/inspect.js
ADDED
package/dist/plugin.d.ts
CHANGED
|
@@ -6,12 +6,7 @@ export interface RaskPluginOptions {
|
|
|
6
6
|
*/
|
|
7
7
|
transformComponents?: boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Import source for Inferno
|
|
10
|
-
* @default true (imports from rask-ui)
|
|
11
|
-
*/
|
|
12
|
-
imports?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Import source for RaskComponent
|
|
9
|
+
* Import source for Inferno JSX runtime functions
|
|
15
10
|
* @default "rask-ui"
|
|
16
11
|
*/
|
|
17
12
|
importSource?: string;
|
|
@@ -24,5 +19,5 @@ export interface RaskPluginOptions {
|
|
|
24
19
|
/**
|
|
25
20
|
* Vite plugin for transforming JSX to Inferno and function components to RaskComponent classes
|
|
26
21
|
*/
|
|
27
|
-
export
|
|
22
|
+
export default function raskPlugin(options?: RaskPluginOptions): Plugin;
|
|
28
23
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAMnC,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAMnC,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAsF1E"}
|
package/dist/plugin.js
CHANGED
|
@@ -7,8 +7,8 @@ const require = createRequire(import.meta.url);
|
|
|
7
7
|
/**
|
|
8
8
|
* Vite plugin for transforming JSX to Inferno and function components to RaskComponent classes
|
|
9
9
|
*/
|
|
10
|
-
export function raskPlugin(options = {}) {
|
|
11
|
-
const { transformComponents = true,
|
|
10
|
+
export default function raskPlugin(options = {}) {
|
|
11
|
+
const { transformComponents = 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
|
|
@@ -16,9 +16,17 @@ export function raskPlugin(options = {}) {
|
|
|
16
16
|
return {
|
|
17
17
|
name: 'rask-plugin',
|
|
18
18
|
enforce: 'pre',
|
|
19
|
-
config() {
|
|
19
|
+
config(config, { mode }) {
|
|
20
20
|
return {
|
|
21
21
|
esbuild: false, // Disable esbuild to use SWC
|
|
22
|
+
resolve: {
|
|
23
|
+
alias: {
|
|
24
|
+
// In development mode, use Inferno's development build to avoid the warning
|
|
25
|
+
...(mode === 'development' && {
|
|
26
|
+
inferno: 'inferno/dist/index.dev.mjs',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
22
30
|
};
|
|
23
31
|
},
|
|
24
32
|
async transform(code, id) {
|
|
@@ -33,7 +41,7 @@ export function raskPlugin(options = {}) {
|
|
|
33
41
|
[
|
|
34
42
|
infernoPluginPath,
|
|
35
43
|
{
|
|
36
|
-
|
|
44
|
+
importSource,
|
|
37
45
|
defineAllArguments,
|
|
38
46
|
},
|
|
39
47
|
],
|
package/package.json
CHANGED
package/swc-plugin/src/lib.rs
CHANGED
|
@@ -181,6 +181,29 @@ impl RaskComponentTransform {
|
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/// Rewrite imports from "inferno" to the configured import source
|
|
185
|
+
fn rewrite_inferno_imports(&mut self, module: &mut Module) {
|
|
186
|
+
let import_source = self
|
|
187
|
+
.config
|
|
188
|
+
.import_source
|
|
189
|
+
.as_ref()
|
|
190
|
+
.map(|s| s.as_str())
|
|
191
|
+
.unwrap_or("rask-ui");
|
|
192
|
+
|
|
193
|
+
for item in &mut module.body {
|
|
194
|
+
if let ModuleItem::ModuleDecl(ModuleDecl::Import(import)) = item {
|
|
195
|
+
if &*import.src.value == "inferno" {
|
|
196
|
+
// Rewrite the import source from "inferno" to the configured source
|
|
197
|
+
import.src = Box::new(Str {
|
|
198
|
+
span: Default::default(),
|
|
199
|
+
value: Wtf8Atom::from(import_source),
|
|
200
|
+
raw: None,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
184
207
|
/// Inject the RaskComponent import at the top of the module
|
|
185
208
|
fn inject_runtime(&mut self, module: &mut Module) {
|
|
186
209
|
if self.import_rask_component.is_none() {
|
|
@@ -245,6 +268,9 @@ impl VisitMut for RaskComponentTransform {
|
|
|
245
268
|
// First visit all items to transform them
|
|
246
269
|
module.visit_mut_children_with(self);
|
|
247
270
|
|
|
271
|
+
// Rewrite any "inferno" imports to use the configured import source
|
|
272
|
+
self.rewrite_inferno_imports(module);
|
|
273
|
+
|
|
248
274
|
// Then inject imports if needed
|
|
249
275
|
self.inject_runtime(module);
|
|
250
276
|
}
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/Users/christianalfoni/Development/
|
|
1
|
+
/Users/christianalfoni/Development/rask-ui/packages/core/swc-plugin/target/wasm32-wasip1/release/deps/swc_plugin_rask_component.d: src/lib.rs
|
|
2
2
|
|
|
3
|
-
/Users/christianalfoni/Development/
|
|
3
|
+
/Users/christianalfoni/Development/rask-ui/packages/core/swc-plugin/target/wasm32-wasip1/release/deps/swc_plugin_rask_component.wasm: src/lib.rs
|
|
4
4
|
|
|
5
|
-
/Users/christianalfoni/Development/
|
|
5
|
+
/Users/christianalfoni/Development/rask-ui/packages/core/swc-plugin/target/wasm32-wasip1/release/deps/libswc_plugin_rask_component.rlib: src/lib.rs
|
|
6
6
|
|
|
7
7
|
src/lib.rs:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|