rask-ui 0.23.0 → 0.24.1

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.
Files changed (115) hide show
  1. package/dist/compiler.d.ts +3 -1
  2. package/dist/compiler.d.ts.map +1 -1
  3. package/dist/compiler.js +7 -1
  4. package/dist/component.d.ts +4 -18
  5. package/dist/component.d.ts.map +1 -1
  6. package/dist/component.js +19 -78
  7. package/dist/createComputed.d.ts +4 -0
  8. package/dist/createComputed.d.ts.map +1 -0
  9. package/dist/createComputed.js +69 -0
  10. package/dist/createEffect.d.ts +2 -0
  11. package/dist/createEffect.d.ts.map +1 -0
  12. package/dist/createEffect.js +29 -0
  13. package/dist/createRouter.d.ts +8 -0
  14. package/dist/createRouter.d.ts.map +1 -0
  15. package/dist/createRouter.js +27 -0
  16. package/dist/createState.d.ts +2 -0
  17. package/dist/createState.d.ts.map +1 -1
  18. package/dist/createState.js +40 -5
  19. package/dist/createTask.d.ts +31 -0
  20. package/dist/createTask.d.ts.map +1 -0
  21. package/dist/createTask.js +79 -0
  22. package/dist/createView.d.ts +18 -44
  23. package/dist/createView.d.ts.map +1 -1
  24. package/dist/createView.js +57 -48
  25. package/dist/error.d.ts +3 -14
  26. package/dist/error.d.ts.map +1 -1
  27. package/dist/error.js +14 -15
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/jsx.d.ts +10 -256
  32. package/dist/observation.d.ts +1 -1
  33. package/dist/observation.d.ts.map +1 -1
  34. package/dist/patchInferno.d.ts +6 -0
  35. package/dist/patchInferno.d.ts.map +1 -0
  36. package/dist/patchInferno.js +53 -0
  37. package/dist/plugin.d.ts +1 -1
  38. package/dist/plugin.d.ts.map +1 -1
  39. package/dist/plugin.js +14 -26
  40. package/dist/scheduler.d.ts +4 -0
  41. package/dist/scheduler.d.ts.map +1 -0
  42. package/dist/scheduler.js +107 -0
  43. package/dist/tests/batch.test.d.ts +2 -0
  44. package/dist/tests/batch.test.d.ts.map +1 -0
  45. package/dist/tests/batch.test.js +244 -0
  46. package/dist/tests/createComputed.test.d.ts +2 -0
  47. package/dist/tests/createComputed.test.d.ts.map +1 -0
  48. package/dist/tests/createComputed.test.js +257 -0
  49. package/dist/tests/createContext.test.d.ts +2 -0
  50. package/dist/tests/createContext.test.d.ts.map +1 -0
  51. package/dist/tests/createContext.test.js +136 -0
  52. package/dist/tests/createEffect.test.d.ts +2 -0
  53. package/dist/tests/createEffect.test.d.ts.map +1 -0
  54. package/dist/tests/createEffect.test.js +467 -0
  55. package/dist/tests/createState.test.d.ts.map +1 -0
  56. package/dist/tests/createState.test.js +144 -0
  57. package/dist/tests/createTask.test.d.ts +2 -0
  58. package/dist/tests/createTask.test.d.ts.map +1 -0
  59. package/dist/tests/createTask.test.js +322 -0
  60. package/dist/tests/createView.test.d.ts.map +1 -0
  61. package/dist/{createView.test.js → tests/createView.test.js} +40 -40
  62. package/dist/tests/error.test.d.ts +2 -0
  63. package/dist/tests/error.test.d.ts.map +1 -0
  64. package/dist/tests/error.test.js +168 -0
  65. package/dist/tests/observation.test.d.ts.map +1 -0
  66. package/dist/tests/observation.test.js +341 -0
  67. package/dist/useComputed.d.ts +5 -0
  68. package/dist/useComputed.d.ts.map +1 -0
  69. package/dist/useComputed.js +69 -0
  70. package/dist/useQuery.d.ts +25 -0
  71. package/dist/useQuery.d.ts.map +1 -0
  72. package/dist/useQuery.js +25 -0
  73. package/dist/useSuspendAsync.d.ts +18 -0
  74. package/dist/useSuspendAsync.d.ts.map +1 -0
  75. package/dist/useSuspendAsync.js +37 -0
  76. package/dist/useTask.d.ts +25 -0
  77. package/dist/useTask.d.ts.map +1 -0
  78. package/dist/useTask.js +70 -0
  79. package/package.json +1 -1
  80. package/swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm +0 -0
  81. package/dist/asyncState.d.ts +0 -16
  82. package/dist/asyncState.d.ts.map +0 -1
  83. package/dist/asyncState.js +0 -24
  84. package/dist/context.d.ts +0 -5
  85. package/dist/context.d.ts.map +0 -1
  86. package/dist/context.js +0 -29
  87. package/dist/createAsync.test.d.ts +0 -2
  88. package/dist/createAsync.test.d.ts.map +0 -1
  89. package/dist/createAsync.test.js +0 -110
  90. package/dist/createMutation.test.d.ts +0 -2
  91. package/dist/createMutation.test.d.ts.map +0 -1
  92. package/dist/createMutation.test.js +0 -168
  93. package/dist/createQuery.test.d.ts +0 -2
  94. package/dist/createQuery.test.d.ts.map +0 -1
  95. package/dist/createQuery.test.js +0 -156
  96. package/dist/createRef.d.ts +0 -6
  97. package/dist/createRef.d.ts.map +0 -1
  98. package/dist/createRef.js +0 -8
  99. package/dist/createState.test.d.ts.map +0 -1
  100. package/dist/createState.test.js +0 -111
  101. package/dist/createView.test.d.ts.map +0 -1
  102. package/dist/observation.test.d.ts.map +0 -1
  103. package/dist/observation.test.js +0 -150
  104. package/dist/suspense.d.ts +0 -25
  105. package/dist/suspense.d.ts.map +0 -1
  106. package/dist/suspense.js +0 -97
  107. package/dist/test-setup.d.ts +0 -16
  108. package/dist/test-setup.d.ts.map +0 -1
  109. package/dist/test-setup.js +0 -40
  110. package/dist/test.d.ts +0 -2
  111. package/dist/test.d.ts.map +0 -1
  112. package/dist/test.js +0 -24
  113. /package/dist/{createState.test.d.ts → tests/createState.test.d.ts} +0 -0
  114. /package/dist/{createView.test.d.ts → tests/createView.test.d.ts} +0 -0
  115. /package/dist/{observation.test.d.ts → tests/observation.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"createView.d.ts","sourceRoot":"","sources":["../src/createView.ts"],"names":[],"mappings":"AAAA,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,C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AM;IACtB,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE;CAC5B,GACG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAClB,EAAE,CAAC;AAEP,KAAK,YAAY,CAAC,GAAG,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EAAE,IAAI,IAAI,SAAS;IAC1E,MAAM,CAAC,SAAS,MAAM;IACtB,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE;CAC5B,GACG,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GACjC,GAAG,CAAC;AAER;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACtD,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC3D,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,GACH,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,wBAAgB,UAAU,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EACpD,GAAG,IAAI,EAAE,CAAC,GACT,SAAS,CAAC,CAAC,CAAC,CAAC"}
@@ -1,68 +1,77 @@
1
- /**
2
- * Creates a view that merges multiple objects (reactive or not) into a single object while
3
- * maintaining reactivity through getters. Properties from later arguments override earlier ones.
4
- *
5
- * @warning **Do not destructure the returned view object!** Destructuring breaks reactivity
6
- * because it extracts plain values instead of maintaining getter access. This is the same rule
7
- * as other reactive primitives.
8
- *
9
- * @example
10
- * // ❌ Bad - destructuring loses reactivity
11
- * function Component() {
12
- * const state = createState({ count: 0 });
13
- * const helpers = { increment: () => state.count++ };
14
- * const view = createView(state, helpers);
15
- * const { count, increment } = view; // Don't do this!
16
- * return () => <button onClick={increment}>{count}</button>; // Won't update!
17
- * }
18
- *
19
- * // ✅ Good - access properties directly in render
20
- * function Component() {
21
- * const state = createState({ count: 0 });
22
- * const helpers = { increment: () => state.count++ };
23
- * const view = createView(state, helpers);
24
- * return () => <button onClick={view.increment}>{view.count}</button>; // Reactive!
25
- * }
26
- *
27
- * @example
28
- * // Merge multiple reactive objects
29
- * const state = createState({ count: 0 });
30
- * const user = createState({ name: "Alice" });
31
- * const view = createView(state, user);
32
- * // view has both count and name properties, maintaining reactivity
33
- *
34
- * @example
35
- * // Later arguments override earlier ones
36
- * const a = { x: 1, y: 2 };
37
- * const b = { y: 3, z: 4 };
38
- * const view = createView(a, b);
39
- * // view.x === 1, view.y === 3, view.z === 4
40
- *
41
- * @param args - Objects to merge (reactive or plain objects)
42
- * @returns A view object with getters for all properties, maintaining reactivity
43
- */
1
+ import { getCurrentComponent } from "./component";
2
+ import { INSPECT_MARKER, INSPECTOR_ENABLED } from "./inspect";
44
3
  export function createView(...args) {
4
+ if (!getCurrentComponent()) {
5
+ throw new Error("Only use createView in component setup");
6
+ }
45
7
  const result = {};
46
8
  const seen = new Set();
9
+ let notifyInspectorRef = {};
47
10
  for (let i = args.length - 1; i >= 0; i--) {
48
11
  const src = args[i];
49
- // mimic Object.assign: only enumerable own property keys
12
+ if (!src)
13
+ continue;
14
+ if (INSPECTOR_ENABLED && src[INSPECT_MARKER]) {
15
+ src[INSPECT_MARKER] = notifyInspectorRef;
16
+ }
17
+ // Mimic Object.assign: only enumerable own property keys
50
18
  for (const key of Reflect.ownKeys(src)) {
51
19
  if (seen.has(key))
52
20
  continue;
53
21
  const desc = Object.getOwnPropertyDescriptor(src, key);
54
22
  if (!desc || !desc.enumerable)
55
23
  continue;
56
- // Capture the current source for this key (last write wins).
57
24
  Object.defineProperty(result, key, {
58
25
  enumerable: true,
59
26
  configurable: true,
60
- get: () => src[key],
61
- // Optional write-through (commented out by default):
62
- // set: (value) => { (src as any)[key as any] = value; },
27
+ get: () => {
28
+ const value = src[key];
29
+ if (!INSPECTOR_ENABLED || !notifyInspectorRef.current) {
30
+ return value;
31
+ }
32
+ // Propagate inspector marker into nested observables
33
+ if (value?.[INSPECT_MARKER]) {
34
+ value[INSPECT_MARKER] = {
35
+ current: {
36
+ notify: notifyInspectorRef.current.notify,
37
+ path: notifyInspectorRef.current.path.concat(key),
38
+ },
39
+ };
40
+ }
41
+ else if (typeof value === "function") {
42
+ // Wrap actions to notify inspector
43
+ return (...params) => {
44
+ notifyInspectorRef.current.notify({
45
+ type: "action",
46
+ path: notifyInspectorRef.current.path.concat(key),
47
+ params,
48
+ });
49
+ return value(...params);
50
+ };
51
+ }
52
+ return value;
53
+ },
63
54
  });
64
55
  seen.add(key);
65
56
  }
66
57
  }
58
+ if (INSPECTOR_ENABLED) {
59
+ Object.defineProperty(result, INSPECT_MARKER, {
60
+ enumerable: false,
61
+ configurable: false,
62
+ get() {
63
+ return !notifyInspectorRef.current;
64
+ },
65
+ set: (value) => {
66
+ Object.defineProperty(notifyInspectorRef, "current", {
67
+ configurable: true,
68
+ get() {
69
+ return value.current;
70
+ },
71
+ });
72
+ },
73
+ });
74
+ }
75
+ // The overload signatures expose a precise type; this is the shared impl.
67
76
  return result;
68
77
  }
package/dist/error.d.ts CHANGED
@@ -1,16 +1,5 @@
1
- import { Component, VNode } from "inferno";
2
- export declare class ErrorBoundary extends Component<{
3
- children: any;
4
- error: (error: unknown) => VNode;
5
- }, {
1
+ export declare const CatchErrorContext: import("./createContext").Context<(error: unknown) => void>;
2
+ export declare function useCatchError(): {
6
3
  error: unknown;
7
- }> {
8
- getChildContext(): {
9
- notifyError: (error: unknown) => void;
10
- };
11
- state: {
12
- error: null;
13
- };
14
- render(): any;
15
- }
4
+ };
16
5
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,4CAAyB,OAAO,KAAK,IAAI,CAAG,CAAC;AAE3E,wBAAgB,aAAa;WAQK,OAAO;EAOxC"}
package/dist/error.js CHANGED
@@ -1,17 +1,16 @@
1
- import { Component } from "inferno";
2
- export class ErrorBoundary extends Component {
3
- getChildContext() {
4
- return {
5
- notifyError: (error) => {
6
- this.setState({ error });
7
- },
8
- };
9
- }
10
- state = { error: null };
11
- render() {
12
- if (this.state.error) {
13
- return this.props.error(this.state.error);
14
- }
15
- return this.props.children;
1
+ import { useState } from "./useState";
2
+ import { createContext, useInjectContext } from "./createContext";
3
+ import { getCurrentComponent } from "./component";
4
+ export const CatchErrorContext = createContext();
5
+ export function useCatchError() {
6
+ const currentComponent = getCurrentComponent();
7
+ if (!currentComponent || currentComponent.isRendering) {
8
+ throw new Error("Only use the useCatchError hook in setup");
16
9
  }
10
+ const inject = useInjectContext(CatchErrorContext);
11
+ const state = useState({
12
+ error: null,
13
+ });
14
+ inject((error) => (state.error = error));
15
+ return state;
17
16
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./types";
2
2
  export { render } from "./render";
3
- export { useCleanup, useMountEffect, RaskStatefulComponent, RaskStatelessComponent, } from "./component";
3
+ export { useCleanup, useMountEffect } from "./component";
4
4
  export { createContext } from "./createContext";
5
5
  export { useState, assignState } from "./useState";
6
6
  export { useAsync, Async } from "./useAsync";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,CAAC;AAEjB,OAAO,EAAE,MAAM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a,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Import global types - this makes the Rask namespace available globally
2
2
  import "./types";
3
3
  export { render } from "./render";
4
- export { useCleanup, useMountEffect, RaskStatefulComponent, RaskStatelessComponent, } from "./component";
4
+ export { useCleanup, useMountEffect } from "./component";
5
5
  export { createContext } from "./createContext";
6
6
  export { useState, assignState } from "./useState";
7
7
  export { useAsync } from "./useAsync";
package/dist/jsx.d.ts CHANGED
@@ -1,257 +1,11 @@
1
1
  // JSX type definitions
2
- // Note: This is JSXInternal, which gets renamed to JSX on export from jsx-runtime
3
- import type { Ref } from "./state";
4
-
5
- export namespace JSXInternal {
6
- export type Element = any;
7
-
8
- export interface ElementAttributesProperty {
9
- props: {};
10
- }
11
-
12
- export interface ElementChildrenAttribute {
13
- children: {};
14
- }
15
-
16
- export interface IntrinsicAttributes {
17
- key?: any;
18
- }
19
-
20
- // CSS Properties
21
- export type CSSProperties = {
22
- [key: string]: string | number | undefined;
23
- };
24
-
25
- // Common HTML Attributes
26
- export interface HTMLAttributes<T = HTMLElement> {
27
- ref?: Ref<T> | ((element: T | null) => void);
28
- id?: string;
29
- class?: string | Record<string, boolean>;
30
- style?: string | CSSProperties;
31
- title?: string;
32
- role?: string;
33
- tabIndex?: number;
34
-
35
- onClick?: (event: MouseEvent) => void;
36
- onDblClick?: (event: MouseEvent) => void;
37
- onChange?: (event: Event) => void;
38
- onInput?: (event: Event) => void;
39
- onSubmit?: (event: Event) => void;
40
- onFocus?: (event: FocusEvent) => void;
41
- onBlur?: (event: FocusEvent) => void;
42
- onKeyDown?: (event: KeyboardEvent) => void;
43
- onKeyUp?: (event: KeyboardEvent) => void;
44
- onKeyPress?: (event: KeyboardEvent) => void;
45
- onMouseDown?: (event: MouseEvent) => void;
46
- onMouseUp?: (event: MouseEvent) => void;
47
- onMouseEnter?: (event: MouseEvent) => void;
48
- onMouseLeave?: (event: MouseEvent) => void;
49
- onMouseMove?: (event: MouseEvent) => void;
50
- onMouseOver?: (event: MouseEvent) => void;
51
- onMouseOut?: (event: MouseEvent) => void;
52
- onWheel?: (event: WheelEvent) => void;
53
- onScroll?: (event: Event) => void;
54
- onTouchStart?: (event: TouchEvent) => void;
55
- onTouchEnd?: (event: TouchEvent) => void;
56
- onTouchMove?: (event: TouchEvent) => void;
57
- onTouchCancel?: (event: TouchEvent) => void;
58
-
59
- [key: `aria-${string}`]: string | boolean | number | undefined;
60
- [key: `data-${string}`]: string | boolean | number | undefined;
61
-
62
- children?: any;
63
- }
64
-
65
- export interface AnchorHTMLAttributes<T = HTMLAnchorElement>
66
- extends HTMLAttributes<T> {
67
- href?: string;
68
- target?: "_blank" | "_self" | "_parent" | "_top";
69
- rel?: string;
70
- download?: string;
71
- }
72
-
73
- export interface ButtonHTMLAttributes<T = HTMLButtonElement>
74
- extends HTMLAttributes<T> {
75
- type?: "button" | "submit" | "reset";
76
- disabled?: boolean;
77
- name?: string;
78
- value?: string;
79
- }
80
-
81
- export interface FormHTMLAttributes<T = HTMLFormElement>
82
- extends HTMLAttributes<T> {
83
- action?: string;
84
- method?: "get" | "post";
85
- enctype?: string;
86
- target?: string;
87
- noValidate?: boolean;
88
- }
89
-
90
- export interface InputHTMLAttributes<T = HTMLInputElement>
91
- extends HTMLAttributes<T> {
92
- type?:
93
- | "button"
94
- | "checkbox"
95
- | "color"
96
- | "date"
97
- | "datetime-local"
98
- | "email"
99
- | "file"
100
- | "hidden"
101
- | "image"
102
- | "month"
103
- | "number"
104
- | "password"
105
- | "radio"
106
- | "range"
107
- | "reset"
108
- | "search"
109
- | "submit"
110
- | "tel"
111
- | "text"
112
- | "time"
113
- | "url"
114
- | "week";
115
- value?: string | number;
116
- defaultValue?: string | number;
117
- placeholder?: string;
118
- disabled?: boolean;
119
- required?: boolean;
120
- readOnly?: boolean;
121
- name?: string;
122
- checked?: boolean;
123
- defaultChecked?: boolean;
124
- min?: string | number;
125
- max?: string | number;
126
- step?: string | number;
127
- pattern?: string;
128
- accept?: string;
129
- multiple?: boolean;
130
- autoComplete?: string;
131
- autoFocus?: boolean;
132
- }
133
-
134
- export interface LabelHTMLAttributes<T = HTMLLabelElement>
135
- extends HTMLAttributes<T> {
136
- htmlFor?: string;
137
- for?: string;
138
- }
139
-
140
- export interface SelectHTMLAttributes<T = HTMLSelectElement>
141
- extends HTMLAttributes<T> {
142
- value?: string | string[];
143
- defaultValue?: string | string[];
144
- disabled?: boolean;
145
- required?: boolean;
146
- name?: string;
147
- multiple?: boolean;
148
- size?: number;
149
- }
150
-
151
- export interface OptionHTMLAttributes<T = HTMLOptionElement>
152
- extends HTMLAttributes<T> {
153
- value?: string | number;
154
- selected?: boolean;
155
- disabled?: boolean;
156
- label?: string;
157
- }
158
-
159
- export interface TextareaHTMLAttributes<T = HTMLTextAreaElement>
160
- extends HTMLAttributes<T> {
161
- value?: string;
162
- defaultValue?: string;
163
- placeholder?: string;
164
- disabled?: boolean;
165
- required?: boolean;
166
- readOnly?: boolean;
167
- name?: string;
168
- rows?: number;
169
- cols?: number;
170
- maxLength?: number;
171
- wrap?: "soft" | "hard";
172
- }
173
-
174
- export interface FieldsetHTMLAttributes<T = HTMLFieldSetElement>
175
- extends HTMLAttributes<T> {
176
- disabled?: boolean;
177
- name?: string;
178
- }
179
-
180
- export interface ImgHTMLAttributes<T = HTMLImageElement>
181
- extends HTMLAttributes<T> {
182
- src?: string;
183
- alt?: string;
184
- width?: number | string;
185
- height?: number | string;
186
- loading?: "eager" | "lazy";
187
- crossOrigin?: "anonymous" | "use-credentials";
188
- }
189
-
190
- export interface SVGAttributes<T = SVGElement> extends HTMLAttributes<T> {
191
- xmlns?: string;
192
- viewBox?: string;
193
- width?: number | string;
194
- height?: number | string;
195
- fill?: string;
196
- stroke?: string;
197
- strokeWidth?: number | string;
198
- }
199
-
200
- // Intrinsic Elements
201
- export interface IntrinsicElements {
202
- a: AnchorHTMLAttributes<HTMLAnchorElement>;
203
- abbr: HTMLAttributes<HTMLElement>;
204
- address: HTMLAttributes<HTMLElement>;
205
- article: HTMLAttributes<HTMLElement>;
206
- aside: HTMLAttributes<HTMLElement>;
207
- b: HTMLAttributes<HTMLElement>;
208
- blockquote: HTMLAttributes<HTMLQuoteElement>;
209
- body: HTMLAttributes<HTMLBodyElement>;
210
- br: HTMLAttributes<HTMLBRElement>;
211
- button: ButtonHTMLAttributes<HTMLButtonElement>;
212
- canvas: HTMLAttributes<HTMLCanvasElement>;
213
- code: HTMLAttributes<HTMLElement>;
214
- div: HTMLAttributes<HTMLDivElement>;
215
- em: HTMLAttributes<HTMLElement>;
216
- fieldset: FieldsetHTMLAttributes<HTMLFieldSetElement>;
217
- footer: HTMLAttributes<HTMLElement>;
218
- form: FormHTMLAttributes<HTMLFormElement>;
219
- h1: HTMLAttributes<HTMLHeadingElement>;
220
- h2: HTMLAttributes<HTMLHeadingElement>;
221
- h3: HTMLAttributes<HTMLHeadingElement>;
222
- h4: HTMLAttributes<HTMLHeadingElement>;
223
- h5: HTMLAttributes<HTMLHeadingElement>;
224
- h6: HTMLAttributes<HTMLHeadingElement>;
225
- head: HTMLAttributes<HTMLHeadElement>;
226
- header: HTMLAttributes<HTMLElement>;
227
- hr: HTMLAttributes<HTMLHRElement>;
228
- html: HTMLAttributes<HTMLHtmlElement>;
229
- i: HTMLAttributes<HTMLElement>;
230
- img: ImgHTMLAttributes<HTMLImageElement>;
231
- input: InputHTMLAttributes<HTMLInputElement>;
232
- label: LabelHTMLAttributes<HTMLLabelElement>;
233
- legend: HTMLAttributes<HTMLLegendElement>;
234
- li: HTMLAttributes<HTMLLIElement>;
235
- main: HTMLAttributes<HTMLElement>;
236
- nav: HTMLAttributes<HTMLElement>;
237
- ol: HTMLAttributes<HTMLOListElement>;
238
- option: OptionHTMLAttributes<HTMLOptionElement>;
239
- p: HTMLAttributes<HTMLParagraphElement>;
240
- pre: HTMLAttributes<HTMLPreElement>;
241
- section: HTMLAttributes<HTMLElement>;
242
- select: SelectHTMLAttributes<HTMLSelectElement>;
243
- small: HTMLAttributes<HTMLElement>;
244
- span: HTMLAttributes<HTMLSpanElement>;
245
- strong: HTMLAttributes<HTMLElement>;
246
- style: HTMLAttributes<HTMLStyleElement>;
247
- textarea: TextareaHTMLAttributes<HTMLTextAreaElement>;
248
- ul: HTMLAttributes<HTMLUListElement>;
249
-
250
- // SVG
251
- svg: SVGAttributes<SVGSVGElement>;
252
- circle: SVGAttributes<SVGCircleElement>;
253
- line: SVGAttributes<SVGLineElement>;
254
- path: SVGAttributes<SVGPathElement>;
255
- rect: SVGAttributes<SVGRectElement>;
256
- }
257
- }
2
+ // Re-export Inferno's comprehensive JSX types
3
+ import 'inferno';
4
+
5
+ // Re-export useful Inferno types for convenience
6
+ export type {
7
+ InfernoNode,
8
+ InfernoChild,
9
+ Component,
10
+ ComponentType,
11
+ } from 'inferno';
@@ -83,7 +83,7 @@ export declare class Observer {
83
83
  /** Subscribe this observer to a signal */
84
84
  subscribeSignal(signal: Signal): void;
85
85
  /** Remove all signal subscriptions (fast + safe) */
86
- private clearSignals;
86
+ clearSignals(): void;
87
87
  /** Begin dependency collection */
88
88
  observe(): () => void;
89
89
  /** Dispose the observer completely */
@@ -1 +1 @@
1
- {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"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eners with syncBatch
4
+ */
5
+ export declare function patchInfernoEventHandling(renderFn: () => void): void;
6
+ //# sourceMappingURL=patchInferno.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchInferno.d.ts","sourceRoot":"","sources":["../src/patchInferno.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,IAAI,QA0D7D"}
@@ -0,0 +1,53 @@
1
+ import { syncBatch } from "./batch";
2
+ /**
3
+ * Temporarily patches document.addEventListener during render to capture
4
+ * and wrap Inferno's delegated event listeners with syncBatch
5
+ */
6
+ export function patchInfernoEventHandling(renderFn) {
7
+ const originalAddEventListener = document.addEventListener.bind(document);
8
+ const patchedEvents = new Set();
9
+ // Inferno's delegated events
10
+ const INFERNO_EVENTS = [
11
+ "click",
12
+ "dblclick",
13
+ "focusin",
14
+ "focusout",
15
+ "keydown",
16
+ "keypress",
17
+ "keyup",
18
+ "mousedown",
19
+ "mousemove",
20
+ "mouseup",
21
+ "touchend",
22
+ "touchmove",
23
+ "touchstart",
24
+ "change",
25
+ "input",
26
+ "submit",
27
+ ];
28
+ // Temporarily replace addEventListener
29
+ document.addEventListener = function (type, listener, options) {
30
+ // Only wrap Inferno's delegated event listeners
31
+ if (INFERNO_EVENTS.includes(type) &&
32
+ typeof listener === "function" &&
33
+ !patchedEvents.has(type)) {
34
+ patchedEvents.add(type);
35
+ const wrappedListener = function (event) {
36
+ syncBatch(() => {
37
+ listener.call(this, event);
38
+ });
39
+ };
40
+ return originalAddEventListener(type, wrappedListener, options);
41
+ }
42
+ // @ts-ignore
43
+ return originalAddEventListener(type, listener, options);
44
+ };
45
+ try {
46
+ // Call render - Inferno will synchronously attach its listeners
47
+ renderFn();
48
+ }
49
+ finally {
50
+ // Restore original addEventListener
51
+ document.addEventListener = originalAddEventListener;
52
+ }
53
+ }
package/dist/plugin.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface RaskPluginOptions {
8
8
  importSource?: string;
9
9
  }
10
10
  /**
11
- * Vite plugin for transforming JSX to Inferno and function components to RaskComponent classes
11
+ * Vite plugin for transforming JSX to Inferno with rask-ui/compiler imports
12
12
  */
13
13
  export default function raskPlugin(options?: RaskPluginOptions): Plugin;
14
14
  //# sourceMappingURL=plugin.d.ts.map
@@ -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;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAiF1E"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAsE1E"}
package/dist/plugin.js CHANGED
@@ -1,18 +1,12 @@
1
- import path from "path";
2
- import { fileURLToPath } from "url";
3
1
  import { createRequire } from "module";
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = path.dirname(__filename);
6
2
  const require = createRequire(import.meta.url);
7
3
  /**
8
- * Vite plugin for transforming JSX to Inferno and function components to RaskComponent classes
4
+ * Vite plugin for transforming JSX to Inferno with rask-ui/compiler imports
9
5
  */
10
6
  export default function raskPlugin(options = {}) {
11
7
  const importSource = options.importSource || "rask-ui";
12
8
  // Resolve the path to swc-plugin-inferno WASM file
13
9
  const infernoPluginPath = require.resolve("swc-plugin-inferno/swc_plugin_inferno.wasm");
14
- // Resolve the path to our RaskComponent plugin
15
- const componentPluginPath = path.resolve(__dirname, "../swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm");
16
10
  return {
17
11
  name: "rask-plugin",
18
12
  enforce: "pre",
@@ -35,23 +29,7 @@ export default function raskPlugin(options = {}) {
35
29
  }
36
30
  // Use SWC for transformation
37
31
  const swc = await import("@swc/core");
38
- const plugins = [
39
- // 1. FIRST: Inferno JSX transformation
40
- [
41
- infernoPluginPath,
42
- {
43
- importSource: `${importSource}/compiler`,
44
- defineAllArguments: false,
45
- },
46
- ],
47
- ];
48
- // 2. SECOND: RaskComponent transformation (if enabled)
49
- plugins.push([
50
- componentPluginPath,
51
- {
52
- importSource: importSource,
53
- },
54
- ]);
32
+ // First, run the inferno plugin to transform JSX
55
33
  const result = await swc.transform(code, {
56
34
  filename: id,
57
35
  jsc: {
@@ -62,13 +40,23 @@ export default function raskPlugin(options = {}) {
62
40
  },
63
41
  target: "es2020",
64
42
  experimental: {
65
- plugins,
43
+ plugins: [
44
+ // Inferno JSX transformation
45
+ [
46
+ infernoPluginPath,
47
+ {
48
+ defineAllArguments: false,
49
+ },
50
+ ],
51
+ ],
66
52
  },
67
53
  },
68
54
  sourceMaps: true,
69
55
  });
56
+ // Then, replace inferno imports with rask-ui/compiler
57
+ const transformedCode = result.code.replace(/from\s+(['"])inferno\1/g, `from $1${importSource}/compiler$1`);
70
58
  return {
71
- code: result.code,
59
+ code: transformedCode,
72
60
  map: result.map,
73
61
  };
74
62
  },
@@ -0,0 +1,4 @@
1
+ export declare function markDirty(): void;
2
+ export declare function enqueueUpdateFromSetter(): void;
3
+ export declare function installGlobalBatching(target?: EventTarget): () => void;
4
+ //# sourceMappingURL=scheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,SAExB;AAeD,wBAAgB,uBAAuB,SAWtC;AAmED,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,WAAoB,cAoBjE"}