rask-ui 0.29.3 → 0.30.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.
Files changed (124) hide show
  1. package/dist/jsx-runtime.d.ts +1 -4
  2. package/dist/jsx-runtime.d.ts.map +1 -1
  3. package/dist/jsx-runtime.js +5 -7
  4. package/dist/render.d.ts.map +1 -1
  5. package/dist/render.js +21 -17
  6. package/dist/types.d.ts +3 -1
  7. package/dist/types.d.ts.map +1 -1
  8. package/package.json +1 -1
  9. package/swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm +0 -0
  10. package/dist/batch.d.ts +0 -6
  11. package/dist/batch.d.ts.map +0 -1
  12. package/dist/batch.js +0 -84
  13. package/dist/compiler.d.ts +0 -4
  14. package/dist/compiler.d.ts.map +0 -1
  15. package/dist/compiler.js +0 -7
  16. package/dist/createAsync.d.ts +0 -39
  17. package/dist/createAsync.d.ts.map +0 -1
  18. package/dist/createAsync.js +0 -47
  19. package/dist/createComputed.d.ts +0 -4
  20. package/dist/createComputed.d.ts.map +0 -1
  21. package/dist/createComputed.js +0 -69
  22. package/dist/createEffect.d.ts +0 -2
  23. package/dist/createEffect.d.ts.map +0 -1
  24. package/dist/createEffect.js +0 -29
  25. package/dist/createMutation.d.ts +0 -43
  26. package/dist/createMutation.d.ts.map +0 -1
  27. package/dist/createMutation.js +0 -76
  28. package/dist/createQuery.d.ts +0 -42
  29. package/dist/createQuery.d.ts.map +0 -1
  30. package/dist/createQuery.js +0 -80
  31. package/dist/createRouter.d.ts +0 -8
  32. package/dist/createRouter.d.ts.map +0 -1
  33. package/dist/createRouter.js +0 -27
  34. package/dist/createState.d.ts +0 -28
  35. package/dist/createState.d.ts.map +0 -1
  36. package/dist/createState.js +0 -129
  37. package/dist/createTask.d.ts +0 -31
  38. package/dist/createTask.d.ts.map +0 -1
  39. package/dist/createTask.js +0 -79
  40. package/dist/createView.d.ts +0 -28
  41. package/dist/createView.d.ts.map +0 -1
  42. package/dist/createView.js +0 -77
  43. package/dist/error.d.ts +0 -5
  44. package/dist/error.d.ts.map +0 -1
  45. package/dist/error.js +0 -16
  46. package/dist/jsx.d.ts +0 -11
  47. package/dist/observation.d.ts +0 -93
  48. package/dist/observation.d.ts.map +0 -1
  49. package/dist/observation.js +0 -200
  50. package/dist/patchInferno.d.ts +0 -6
  51. package/dist/patchInferno.d.ts.map +0 -1
  52. package/dist/patchInferno.js +0 -53
  53. package/dist/tests/batch.test.d.ts +0 -2
  54. package/dist/tests/batch.test.d.ts.map +0 -1
  55. package/dist/tests/batch.test.js +0 -434
  56. package/dist/tests/createComputed.test.d.ts +0 -2
  57. package/dist/tests/createComputed.test.d.ts.map +0 -1
  58. package/dist/tests/createComputed.test.js +0 -257
  59. package/dist/tests/createContext.test.d.ts +0 -2
  60. package/dist/tests/createContext.test.d.ts.map +0 -1
  61. package/dist/tests/createContext.test.js +0 -149
  62. package/dist/tests/createEffect.test.d.ts +0 -2
  63. package/dist/tests/createEffect.test.d.ts.map +0 -1
  64. package/dist/tests/createEffect.test.js +0 -467
  65. package/dist/tests/createState.test.d.ts +0 -2
  66. package/dist/tests/createState.test.d.ts.map +0 -1
  67. package/dist/tests/createState.test.js +0 -144
  68. package/dist/tests/createTask.test.d.ts +0 -2
  69. package/dist/tests/createTask.test.d.ts.map +0 -1
  70. package/dist/tests/createTask.test.js +0 -322
  71. package/dist/tests/createView.test.d.ts +0 -2
  72. package/dist/tests/createView.test.d.ts.map +0 -1
  73. package/dist/tests/createView.test.js +0 -203
  74. package/dist/tests/error.test.d.ts +0 -2
  75. package/dist/tests/error.test.d.ts.map +0 -1
  76. package/dist/tests/error.test.js +0 -181
  77. package/dist/tests/observation.test.d.ts +0 -2
  78. package/dist/tests/observation.test.d.ts.map +0 -1
  79. package/dist/tests/observation.test.js +0 -341
  80. package/dist/tests/renderCount.test.d.ts +0 -2
  81. package/dist/tests/renderCount.test.d.ts.map +0 -1
  82. package/dist/tests/renderCount.test.js +0 -95
  83. package/dist/tests/scopeEnforcement.test.d.ts +0 -2
  84. package/dist/tests/scopeEnforcement.test.d.ts.map +0 -1
  85. package/dist/tests/scopeEnforcement.test.js +0 -157
  86. package/dist/tests/useAction.test.d.ts +0 -2
  87. package/dist/tests/useAction.test.d.ts.map +0 -1
  88. package/dist/tests/useAction.test.js +0 -132
  89. package/dist/tests/useAsync.test.d.ts +0 -2
  90. package/dist/tests/useAsync.test.d.ts.map +0 -1
  91. package/dist/tests/useAsync.test.js +0 -499
  92. package/dist/tests/useDerived.test.d.ts +0 -2
  93. package/dist/tests/useDerived.test.d.ts.map +0 -1
  94. package/dist/tests/useDerived.test.js +0 -407
  95. package/dist/tests/useEffect.test.d.ts +0 -2
  96. package/dist/tests/useEffect.test.d.ts.map +0 -1
  97. package/dist/tests/useEffect.test.js +0 -600
  98. package/dist/tests/useLookup.test.d.ts +0 -2
  99. package/dist/tests/useLookup.test.d.ts.map +0 -1
  100. package/dist/tests/useLookup.test.js +0 -299
  101. package/dist/tests/useRef.test.d.ts +0 -2
  102. package/dist/tests/useRef.test.d.ts.map +0 -1
  103. package/dist/tests/useRef.test.js +0 -189
  104. package/dist/tests/useState.test.d.ts +0 -2
  105. package/dist/tests/useState.test.d.ts.map +0 -1
  106. package/dist/tests/useState.test.js +0 -178
  107. package/dist/tests/useSuspend.test.d.ts +0 -2
  108. package/dist/tests/useSuspend.test.d.ts.map +0 -1
  109. package/dist/tests/useSuspend.test.js +0 -752
  110. package/dist/tests/useView.test.d.ts +0 -2
  111. package/dist/tests/useView.test.d.ts.map +0 -1
  112. package/dist/tests/useView.test.js +0 -305
  113. package/dist/useComputed.d.ts +0 -5
  114. package/dist/useComputed.d.ts.map +0 -1
  115. package/dist/useComputed.js +0 -69
  116. package/dist/useQuery.d.ts +0 -25
  117. package/dist/useQuery.d.ts.map +0 -1
  118. package/dist/useQuery.js +0 -25
  119. package/dist/useSuspendAsync.d.ts +0 -18
  120. package/dist/useSuspendAsync.d.ts.map +0 -1
  121. package/dist/useSuspendAsync.js +0 -37
  122. package/dist/useTask.d.ts +0 -25
  123. package/dist/useTask.d.ts.map +0 -1
  124. package/dist/useTask.js +0 -70
@@ -1,80 +0,0 @@
1
- import { createState } from "./createState";
2
- /**
3
- * Creates a reactive query that manages data fetching with loading and error states.
4
- *
5
- * @warning **Do not destructure the returned reactive object!** Destructuring breaks reactivity.
6
- * Access properties directly in your render function instead.
7
- *
8
- * @example
9
- * // ❌ Bad - destructuring loses reactivity
10
- * function Component() {
11
- * const query = createQuery(() => fetchUsers());
12
- * const { isPending, data, error } = query; // Don't do this!
13
- * return () => <div>{isPending ? "Loading..." : data.length}</div>; // Won't update!
14
- * }
15
- *
16
- * // ✅ Good - access properties directly
17
- * function Component() {
18
- * const query = createQuery(() => fetchUsers());
19
- * return () => <div>{query.isPending ? "Loading..." : query.data.length}</div>;
20
- * }
21
- *
22
- * @param fetcher - Function that returns a promise with the data to fetch
23
- * @returns Reactive query object with isPending, data, error properties and fetch method
24
- */
25
- export function createQuery(fetcher) {
26
- const state = createState({
27
- isPending: true,
28
- data: null,
29
- error: null,
30
- });
31
- const assign = (newState) => {
32
- Object.assign(state, newState);
33
- };
34
- let currentAbortController;
35
- const fetch = () => {
36
- currentAbortController?.abort();
37
- const abortController = (currentAbortController = new AbortController());
38
- fetcher()
39
- .then((data) => {
40
- if (abortController.signal.aborted) {
41
- return;
42
- }
43
- assign({
44
- isPending: false,
45
- data,
46
- error: null,
47
- });
48
- })
49
- .catch((error) => {
50
- if (abortController.signal.aborted) {
51
- return;
52
- }
53
- assign({
54
- isPending: false,
55
- data: null,
56
- error: String(error),
57
- });
58
- });
59
- };
60
- fetch();
61
- return {
62
- get isPending() {
63
- return state.isPending;
64
- },
65
- get data() {
66
- return state.data;
67
- },
68
- get error() {
69
- return state.error;
70
- },
71
- fetch(force) {
72
- assign({
73
- isPending: true,
74
- data: force ? null : state.data,
75
- error: null,
76
- });
77
- fetch();
78
- },
79
- };
80
- }
@@ -1,8 +0,0 @@
1
- import { RoutesConfig, TRouter, TRoutes } from "typed-client-router";
2
- export type Router<T extends RoutesConfig> = Omit<TRouter<T>, "current" | "listen" | "pathname"> & {
3
- route?: TRoutes<T>;
4
- };
5
- export declare function createRouter<const T extends RoutesConfig>(config: T, options?: {
6
- base?: string;
7
- }): Router<T>;
8
- //# sourceMappingURL=createRouter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../src/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,OAAO,EACP,OAAO,EACR,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,YAAY,IAAI,IAAI,CAC/C,OAAO,CAAC,CAAC,CAAC,EACV,SAAS,GAAG,QAAQ,GAAG,UAAU,CAClC,GAAG;IACF,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EACvD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACA,MAAM,CAAC,CAAC,CAAC,CA4BX"}
@@ -1,27 +0,0 @@
1
- import { createRouter as internalCreateRouter, } from "typed-client-router";
2
- import { getCurrentObserver, Signal } from "./observation";
3
- import { createCleanup, getCurrentComponent } from "./component";
4
- export function createRouter(config, options) {
5
- if (!getCurrentComponent()) {
6
- throw new Error("Only use createRouter in component setup");
7
- }
8
- const router = internalCreateRouter(config, options);
9
- const signal = new Signal();
10
- createCleanup(router.listen(() => signal.notify()));
11
- return {
12
- get route() {
13
- const observer = getCurrentObserver();
14
- if (observer) {
15
- observer.subscribeSignal(signal);
16
- }
17
- return router.current;
18
- },
19
- get queries() {
20
- return router.queries;
21
- },
22
- setQuery: router.setQuery,
23
- push: router.push,
24
- replace: router.replace,
25
- url: router.url,
26
- };
27
- }
@@ -1,28 +0,0 @@
1
- export declare function assignState<T extends object>(state: T, newState: T): T;
2
- /**
3
- * Creates a reactive state object that tracks property access and notifies observers on changes.
4
- *
5
- * @warning **Do not destructure the returned reactive object!** Destructuring breaks reactivity
6
- * because it extracts plain values instead of maintaining proxy access. This is the same rule
7
- * as Solid.js signals.
8
- *
9
- * @example
10
- * // ❌ Bad - destructuring loses reactivity
11
- * function Component(props) {
12
- * const state = createState({ count: 0, name: "foo" });
13
- * const { count, name } = state; // Don't do this!
14
- * return () => <div>{count} {name}</div>; // Won't update!
15
- * }
16
- *
17
- * // ✅ Good - access properties directly in render
18
- * function Component(props) {
19
- * const state = createState({ count: 0, name: "foo" });
20
- * return () => <div>{state.count} {state.name}</div>; // Reactive!
21
- * }
22
- *
23
- * @param state - The initial state object to make reactive
24
- * @returns A reactive proxy of the state object
25
- */
26
- export declare function createState<T extends object>(state: T): T;
27
- export declare const PROXY_MARKER: unique symbol;
28
- //# sourceMappingURL=createState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createState.d.ts","sourceRoot":"","sources":["../src/createState.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAElE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAOzD;AAGD,eAAO,MAAM,YAAY,eAAoB,CAAC"}
@@ -1,129 +0,0 @@
1
- import { getCurrentComponent } from "./component";
2
- import { INSPECT_MARKER, INSPECTOR_ENABLED } from "./inspect";
3
- import { getCurrentObserver, Signal } from "./observation";
4
- export function assignState(state, newState) {
5
- return Object.assign(state, newState);
6
- }
7
- /**
8
- * Creates a reactive state object that tracks property access and notifies observers on changes.
9
- *
10
- * @warning **Do not destructure the returned reactive object!** Destructuring breaks reactivity
11
- * because it extracts plain values instead of maintaining proxy access. This is the same rule
12
- * as Solid.js signals.
13
- *
14
- * @example
15
- * // ❌ Bad - destructuring loses reactivity
16
- * function Component(props) {
17
- * const state = createState({ count: 0, name: "foo" });
18
- * const { count, name } = state; // Don't do this!
19
- * return () => <div>{count} {name}</div>; // Won't update!
20
- * }
21
- *
22
- * // ✅ Good - access properties directly in render
23
- * function Component(props) {
24
- * const state = createState({ count: 0, name: "foo" });
25
- * return () => <div>{state.count} {state.name}</div>; // Reactive!
26
- * }
27
- *
28
- * @param state - The initial state object to make reactive
29
- * @returns A reactive proxy of the state object
30
- */
31
- export function createState(state) {
32
- if (getCurrentComponent()?.isRendering) {
33
- throw new Error("createState cannot be called during render. Call it in component setup or globally.");
34
- }
35
- return getProxy(state, {});
36
- }
37
- const proxyCache = new WeakMap();
38
- export const PROXY_MARKER = Symbol("isProxy");
39
- function getProxy(value, notifyInspectorRef) {
40
- // Check if already a proxy to avoid double-wrapping
41
- if (PROXY_MARKER in value) {
42
- return value;
43
- }
44
- if (proxyCache.has(value)) {
45
- return proxyCache.get(value);
46
- }
47
- const signals = {};
48
- const proxy = new Proxy(value, {
49
- has(target, key) {
50
- // Support the "in" operator check for PROXY_MARKER
51
- if (key === PROXY_MARKER) {
52
- return true;
53
- }
54
- if (INSPECTOR_ENABLED && key === INSPECT_MARKER) {
55
- return true;
56
- }
57
- return Reflect.has(target, key);
58
- },
59
- get(target, key) {
60
- // Mark this as a proxy to prevent double-wrapping
61
- if (key === PROXY_MARKER) {
62
- return true;
63
- }
64
- if (INSPECTOR_ENABLED && key === INSPECT_MARKER) {
65
- return !notifyInspectorRef.current;
66
- }
67
- const value = Reflect.get(target, key);
68
- if (typeof key === "symbol" || typeof value === "function") {
69
- return value;
70
- }
71
- const observer = getCurrentObserver();
72
- if (observer) {
73
- const signal = (signals[key] = signals[key] || new Signal());
74
- observer.subscribeSignal(signal);
75
- }
76
- if (Array.isArray(value) ||
77
- (typeof value === "object" && value !== null)) {
78
- return getProxy(value, INSPECTOR_ENABLED && notifyInspectorRef.current
79
- ? {
80
- current: {
81
- notify: notifyInspectorRef.current.notify,
82
- path: notifyInspectorRef.current.path.concat(key),
83
- },
84
- }
85
- : notifyInspectorRef);
86
- }
87
- return value;
88
- },
89
- set(target, key, newValue) {
90
- if (INSPECTOR_ENABLED && key === INSPECT_MARKER) {
91
- Object.defineProperty(notifyInspectorRef, "current", {
92
- get() {
93
- return newValue.current;
94
- },
95
- });
96
- return Reflect.set(target, key, newValue);
97
- }
98
- if (typeof key === "symbol") {
99
- return Reflect.set(target, key, newValue);
100
- }
101
- const oldValue = Reflect.get(target, key);
102
- const setResult = Reflect.set(target, key, newValue);
103
- // We only notify if actual change, though array length actually updates under the hood
104
- if (newValue !== oldValue || (Array.isArray(value) && key === "length")) {
105
- const signal = signals[key];
106
- signal?.notify();
107
- }
108
- if (INSPECTOR_ENABLED) {
109
- notifyInspectorRef.current?.notify({
110
- type: "mutation",
111
- path: notifyInspectorRef.current.path,
112
- value: newValue,
113
- });
114
- }
115
- return setResult;
116
- },
117
- deleteProperty(target, key) {
118
- if (typeof key === "symbol") {
119
- return Reflect.deleteProperty(target, key);
120
- }
121
- const signal = signals[key];
122
- signal?.notify();
123
- delete signals[key];
124
- return Reflect.deleteProperty(target, key);
125
- },
126
- });
127
- proxyCache.set(value, proxy);
128
- return proxy;
129
- }
@@ -1,31 +0,0 @@
1
- export type TaskState<P, T> = {
2
- isRunning: false;
3
- params: null;
4
- result: null;
5
- error: null;
6
- } | {
7
- isRunning: true;
8
- result: T | null;
9
- params: P;
10
- error: null;
11
- } | {
12
- isRunning: false;
13
- params: null;
14
- result: T;
15
- error: null;
16
- } | {
17
- isRunning: false;
18
- params: null;
19
- result: null;
20
- error: string;
21
- };
22
- export type Task<A, B = never> = [B] extends [never] ? TaskState<null, A> & {
23
- run(): Promise<A>;
24
- rerun(): Promise<A>;
25
- } : TaskState<A, B> & {
26
- run(params: A): Promise<B>;
27
- rerun(params: A): Promise<B>;
28
- };
29
- export declare function createTask<T>(task: (params: undefined, signal: AbortSignal) => Promise<T>): Task<T>;
30
- export declare function createTask<P, T>(task: (params: P, signal: AbortSignal) => Promise<T>): Task<P, T>;
31
- //# sourceMappingURL=createTask.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTask.d.ts","sourceRoot":"","sources":["../src/createTask.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IACtB;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAChD,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG;IACnB,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB,GACD,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAChB,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEN,wBAAgB,UAAU,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3D,IAAI,CAAC,CAAC,CAAC,CAAC;AACX,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACnD,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1,79 +0,0 @@
1
- import { createCleanup, getCurrentComponent } from "./component";
2
- import { assignState, createState } from "./createState";
3
- export function createTask(task) {
4
- const currentComponent = getCurrentComponent();
5
- if (!currentComponent || currentComponent.isRendering) {
6
- throw new Error("Only use createTask in component setup");
7
- }
8
- const state = createState({
9
- isRunning: false,
10
- result: null,
11
- error: null,
12
- params: null,
13
- });
14
- let currentAbortController;
15
- const fetch = (params) => {
16
- currentAbortController?.abort();
17
- const abortController = (currentAbortController = new AbortController());
18
- const promise = task(params, abortController.signal);
19
- promise
20
- .then((result) => {
21
- if (abortController.signal.aborted) {
22
- return;
23
- }
24
- assignState(state, {
25
- isRunning: false,
26
- result,
27
- error: null,
28
- params: null,
29
- });
30
- })
31
- .catch((error) => {
32
- if (abortController.signal.aborted) {
33
- return;
34
- }
35
- assignState(state, {
36
- isRunning: false,
37
- result: null,
38
- error: String(error),
39
- params: null,
40
- });
41
- });
42
- return promise;
43
- };
44
- createCleanup(() => currentAbortController?.abort());
45
- return {
46
- get isRunning() {
47
- return state.isRunning;
48
- },
49
- get result() {
50
- return state.result;
51
- },
52
- get error() {
53
- return state.error;
54
- },
55
- get params() {
56
- return state.params;
57
- },
58
- run(params) {
59
- const promise = fetch(params);
60
- assignState(state, {
61
- isRunning: true,
62
- result: null,
63
- error: null,
64
- params: (params || null),
65
- });
66
- return promise;
67
- },
68
- rerun(params) {
69
- const promise = fetch(params);
70
- assignState(state, {
71
- isRunning: true,
72
- result: state.result,
73
- error: null,
74
- params: (params || null),
75
- });
76
- return promise;
77
- },
78
- };
79
- }
@@ -1,28 +0,0 @@
1
- type Simplify<T> = T extends any ? {
2
- [K in keyof T]: T[K];
3
- } : never;
4
- type UndefinedKeys<T> = {
5
- [K in keyof T]-?: [T[K]] extends [undefined] ? K : never;
6
- }[keyof T];
7
- type MergeTwo<A extends object, B extends object> = A extends any ? Simplify<Omit<A, keyof B> & Omit<B, UndefinedKeys<B>>> : never;
8
- type MergeMany<T extends readonly object[]> = T extends [
9
- infer H extends object,
10
- ...infer R extends object[]
11
- ] ? MergeManyAcc<H, R> : {};
12
- type MergeManyAcc<Acc extends object, Rest extends object[]> = Rest extends [
13
- infer H extends object,
14
- ...infer R extends object[]
15
- ] ? MergeManyAcc<MergeTwo<Acc, H>, R> : Acc;
16
- /**
17
- * Creates a view that merges multiple objects (reactive or not) into a single
18
- * object while maintaining reactivity through getters. Properties from later
19
- * arguments override earlier ones.
20
- *
21
- * ⚠️ Do not destructure the returned view object; always read properties
22
- * directly from the view to preserve reactivity.
23
- */
24
- export declare function createView<A extends object>(a: A): A;
25
- export declare function createView<A extends object, B extends object>(a: A, b: B): MergeTwo<A, B>;
26
- export declare function createView<T extends readonly object[]>(...args: T): MergeMany<T>;
27
- export {};
28
- //# sourceMappingURL=createView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createView.d.ts","sourceRoot":"","sources":["../src/createView.ts"],"names":[],"mappings":"AAGA,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,KAAK,CAAC;AAEpE,KAAK,aAAa,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK;CACzD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,GAC7D,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GACtD,KAAK,CAAC;AAEV,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,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,77 +0,0 @@
1
- import { getCurrentComponent } from "./component";
2
- import { INSPECT_MARKER, INSPECTOR_ENABLED } from "./inspect";
3
- export function createView(...args) {
4
- if (!getCurrentComponent()) {
5
- throw new Error("Only use createView in component setup");
6
- }
7
- const result = {};
8
- const seen = new Set();
9
- let notifyInspectorRef = {};
10
- for (let i = args.length - 1; i >= 0; i--) {
11
- const src = args[i];
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
18
- for (const key of Reflect.ownKeys(src)) {
19
- if (seen.has(key))
20
- continue;
21
- const desc = Object.getOwnPropertyDescriptor(src, key);
22
- if (!desc || !desc.enumerable)
23
- continue;
24
- Object.defineProperty(result, key, {
25
- enumerable: true,
26
- configurable: true,
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
- },
54
- });
55
- seen.add(key);
56
- }
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.
76
- return result;
77
- }
package/dist/error.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare const CatchErrorContext: import("./createContext").Context<(error: unknown) => void>;
2
- export declare function useCatchError(): {
3
- error: unknown;
4
- };
5
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,16 +0,0 @@
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");
9
- }
10
- const inject = useInjectContext(CatchErrorContext);
11
- const state = useState({
12
- error: null,
13
- });
14
- inject((error) => (state.error = error));
15
- return state;
16
- }
package/dist/jsx.d.ts DELETED
@@ -1,11 +0,0 @@
1
- // JSX type definitions
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';
@@ -1,93 +0,0 @@
1
- /**
2
- * ---------------------------------------------------------------------------
3
- * OBSERVER–SIGNAL SYSTEM (OPTIMIZED / LOW MEMORY / ZERO PENDING ARRAYS)
4
- * ---------------------------------------------------------------------------
5
- *
6
- * STRATEGY OVERVIEW
7
- * -----------------
8
- * Instead of storing subscriber callbacks and disposer closures,
9
- * we model the connection between an Observer and a Signal using a
10
- * lightweight Subscription node.
11
- *
12
- * Each Subscription is owned *by both sides*:
13
- * - Signal keeps a doubly-linked list of all Subscriptions.
14
- * - Observer keeps a doubly-linked list of all Subscriptions it has made.
15
- *
16
- * This gives several important advantages:
17
- *
18
- * ✔ NO per-subscription closures (disposers)
19
- * ✔ NO Set allocations in Signal or Observer
20
- * ✔ NO Array copies during notify()
21
- * ✔ Unsubscribing while iterating is safe (linked-list + cached "next")
22
- * ✔ New subscriptions inside notify() DO NOT fire in the same notify pass
23
- * (using an epoch barrier)
24
- * ✔ Observer.clearSignals() is O(n) with real O(1) unlink
25
- * ✔ Memory overhead is extremely small (one node with 4 pointers)
26
- *
27
- * NOTIFY BARRIER
28
- * --------------
29
- * A global integer `epoch` increments for each notify().
30
- * New subscriptions created during notify() store `createdAtEpoch = epoch+1`.
31
- * During traversal, we only fire subscriptions where:
32
- *
33
- * sub.createdAtEpoch <= epoch
34
- *
35
- * This guarantees consistency and prevents "late" subscribers from firing too early.
36
- *
37
- * ---------------------------------------------------------------------------
38
- */
39
- export declare function getCurrentObserver(): Observer | undefined;
40
- /**
41
- * A lightweight link connecting ONE observer ↔ ONE signal.
42
- * Stored in a linked list on both sides.
43
- */
44
- declare class Subscription {
45
- signal: Signal;
46
- observer: Observer;
47
- prevInSignal: Subscription | null;
48
- nextInSignal: Subscription | null;
49
- prevInObserver: Subscription | null;
50
- nextInObserver: Subscription | null;
51
- active: boolean;
52
- createdAtEpoch: number;
53
- constructor(signal: Signal, observer: Observer, epoch: number);
54
- }
55
- /**
56
- * SIGNAL — Notifies subscribed observers.
57
- */
58
- export declare class Signal {
59
- private head;
60
- private tail;
61
- private epoch;
62
- /** INTERNAL: Create a subscription from observer → signal. */
63
- _subscribe(observer: Observer): Subscription;
64
- /** INTERNAL: Unlink a subscription from this signal. */
65
- _unsubscribe(sub: Subscription): void;
66
- /** Notify all observers.
67
- * Safe even if observers unsubscribe themselves or subscribe new ones mid-run.
68
- */
69
- notify(): void;
70
- }
71
- /**
72
- * OBSERVER — Reacts to signal changes.
73
- * Typically wraps a computation or component.
74
- */
75
- export declare class Observer {
76
- isDisposed: boolean;
77
- private subsHead;
78
- private subsTail;
79
- private readonly onNotify;
80
- constructor(onNotify: () => void, shouldQueue?: boolean);
81
- /** Called from Signal.notify() */
82
- _notify(): void;
83
- /** Subscribe this observer to a signal */
84
- subscribeSignal(signal: Signal): void;
85
- /** Remove all signal subscriptions (fast + safe) */
86
- clearSignals(): void;
87
- /** Begin dependency collection */
88
- observe(): () => void;
89
- /** Dispose the observer completely */
90
- dispose(): void;
91
- }
92
- export {};
93
- //# sourceMappingURL=observation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AASH,wBAAgB,kBAAkB,yBAEjC;AAED;;;GAGG;AACH,cAAM,YAAY;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IAGnB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IACzC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IAGzC,cAAc,EAAE,YAAY,GAAG,IAAI,CAAQ;IAC3C,cAAc,EAAE,YAAY,GAAG,IAAI,CAAQ;IAG3C,MAAM,UAAQ;IAGd,cAAc,EAAE,MAAM,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM;CAK9D;AAED;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,IAAI,CAA6B;IACzC,OAAO,CAAC,IAAI,CAA6B;IAGzC,OAAO,CAAC,KAAK,CAAK;IAElB,8DAA8D;IAC9D,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY;IAe5C,wDAAwD;IACxD,YAAY,CAAC,GAAG,EAAE,YAAY;IAe9B;;OAEG;IACH,MAAM;CAgBP;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,UAAU,UAAS;IAGnB,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,QAAQ,CAA6B;IAG7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;gBAE1B,QAAQ,EAAE,MAAM,IAAI,EAAE,WAAW,UAAO;IAcpD,kCAAkC;IAClC,OAAO;IAMP,0CAA0C;IAC1C,eAAe,CAAC,MAAM,EAAE,MAAM;IAe9B,oDAAoD;IACpD,YAAY;IAiBZ,kCAAkC;IAClC,OAAO;IAUP,sCAAsC;IACtC,OAAO;CAKR"}