rask-ui 0.29.2 → 0.29.4

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/component.d.ts.map +1 -1
  2. package/dist/component.js +0 -4
  3. package/dist/render.d.ts.map +1 -1
  4. package/dist/render.js +21 -17
  5. package/package.json +1 -1
  6. package/swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm +0 -0
  7. package/dist/compiler.d.ts +0 -4
  8. package/dist/compiler.d.ts.map +0 -1
  9. package/dist/compiler.js +0 -7
  10. package/dist/createAsync.d.ts +0 -39
  11. package/dist/createAsync.d.ts.map +0 -1
  12. package/dist/createAsync.js +0 -47
  13. package/dist/createComputed.d.ts +0 -4
  14. package/dist/createComputed.d.ts.map +0 -1
  15. package/dist/createComputed.js +0 -69
  16. package/dist/createEffect.d.ts +0 -2
  17. package/dist/createEffect.d.ts.map +0 -1
  18. package/dist/createEffect.js +0 -29
  19. package/dist/createMutation.d.ts +0 -43
  20. package/dist/createMutation.d.ts.map +0 -1
  21. package/dist/createMutation.js +0 -76
  22. package/dist/createQuery.d.ts +0 -42
  23. package/dist/createQuery.d.ts.map +0 -1
  24. package/dist/createQuery.js +0 -80
  25. package/dist/createRouter.d.ts +0 -8
  26. package/dist/createRouter.d.ts.map +0 -1
  27. package/dist/createRouter.js +0 -27
  28. package/dist/createState.d.ts +0 -28
  29. package/dist/createState.d.ts.map +0 -1
  30. package/dist/createState.js +0 -129
  31. package/dist/createTask.d.ts +0 -31
  32. package/dist/createTask.d.ts.map +0 -1
  33. package/dist/createTask.js +0 -79
  34. package/dist/createView.d.ts +0 -28
  35. package/dist/createView.d.ts.map +0 -1
  36. package/dist/createView.js +0 -77
  37. package/dist/error.d.ts +0 -5
  38. package/dist/error.d.ts.map +0 -1
  39. package/dist/error.js +0 -16
  40. package/dist/jsx.d.ts +0 -11
  41. package/dist/patchInferno.d.ts +0 -6
  42. package/dist/patchInferno.d.ts.map +0 -1
  43. package/dist/patchInferno.js +0 -53
  44. package/dist/tests/batch.test.d.ts +0 -2
  45. package/dist/tests/batch.test.d.ts.map +0 -1
  46. package/dist/tests/batch.test.js +0 -434
  47. package/dist/tests/createComputed.test.d.ts +0 -2
  48. package/dist/tests/createComputed.test.d.ts.map +0 -1
  49. package/dist/tests/createComputed.test.js +0 -257
  50. package/dist/tests/createContext.test.d.ts +0 -2
  51. package/dist/tests/createContext.test.d.ts.map +0 -1
  52. package/dist/tests/createContext.test.js +0 -149
  53. package/dist/tests/createEffect.test.d.ts +0 -2
  54. package/dist/tests/createEffect.test.d.ts.map +0 -1
  55. package/dist/tests/createEffect.test.js +0 -467
  56. package/dist/tests/createState.test.d.ts +0 -2
  57. package/dist/tests/createState.test.d.ts.map +0 -1
  58. package/dist/tests/createState.test.js +0 -144
  59. package/dist/tests/createTask.test.d.ts +0 -2
  60. package/dist/tests/createTask.test.d.ts.map +0 -1
  61. package/dist/tests/createTask.test.js +0 -322
  62. package/dist/tests/createView.test.d.ts +0 -2
  63. package/dist/tests/createView.test.d.ts.map +0 -1
  64. package/dist/tests/createView.test.js +0 -203
  65. package/dist/tests/error.test.d.ts +0 -2
  66. package/dist/tests/error.test.d.ts.map +0 -1
  67. package/dist/tests/error.test.js +0 -181
  68. package/dist/tests/observation.test.d.ts +0 -2
  69. package/dist/tests/observation.test.d.ts.map +0 -1
  70. package/dist/tests/observation.test.js +0 -341
  71. package/dist/tests/renderCount.test.d.ts +0 -2
  72. package/dist/tests/renderCount.test.d.ts.map +0 -1
  73. package/dist/tests/renderCount.test.js +0 -95
  74. package/dist/tests/scopeEnforcement.test.d.ts +0 -2
  75. package/dist/tests/scopeEnforcement.test.d.ts.map +0 -1
  76. package/dist/tests/scopeEnforcement.test.js +0 -157
  77. package/dist/tests/useAction.test.d.ts +0 -2
  78. package/dist/tests/useAction.test.d.ts.map +0 -1
  79. package/dist/tests/useAction.test.js +0 -132
  80. package/dist/tests/useAsync.test.d.ts +0 -2
  81. package/dist/tests/useAsync.test.d.ts.map +0 -1
  82. package/dist/tests/useAsync.test.js +0 -499
  83. package/dist/tests/useDerived.test.d.ts +0 -2
  84. package/dist/tests/useDerived.test.d.ts.map +0 -1
  85. package/dist/tests/useDerived.test.js +0 -407
  86. package/dist/tests/useEffect.test.d.ts +0 -2
  87. package/dist/tests/useEffect.test.d.ts.map +0 -1
  88. package/dist/tests/useEffect.test.js +0 -600
  89. package/dist/tests/useLookup.test.d.ts +0 -2
  90. package/dist/tests/useLookup.test.d.ts.map +0 -1
  91. package/dist/tests/useLookup.test.js +0 -299
  92. package/dist/tests/useRef.test.d.ts +0 -2
  93. package/dist/tests/useRef.test.d.ts.map +0 -1
  94. package/dist/tests/useRef.test.js +0 -189
  95. package/dist/tests/useState.test.d.ts +0 -2
  96. package/dist/tests/useState.test.d.ts.map +0 -1
  97. package/dist/tests/useState.test.js +0 -178
  98. package/dist/tests/useSuspend.test.d.ts +0 -2
  99. package/dist/tests/useSuspend.test.d.ts.map +0 -1
  100. package/dist/tests/useSuspend.test.js +0 -752
  101. package/dist/tests/useView.test.d.ts +0 -2
  102. package/dist/tests/useView.test.d.ts.map +0 -1
  103. package/dist/tests/useView.test.js +0 -305
  104. package/dist/useComputed.d.ts +0 -5
  105. package/dist/useComputed.d.ts.map +0 -1
  106. package/dist/useComputed.js +0 -69
  107. package/dist/useQuery.d.ts +0 -25
  108. package/dist/useQuery.d.ts.map +0 -1
  109. package/dist/useQuery.js +0 -25
  110. package/dist/useSuspendAsync.d.ts +0 -18
  111. package/dist/useSuspendAsync.d.ts.map +0 -1
  112. package/dist/useSuspendAsync.js +0 -37
  113. package/dist/useTask.d.ts +0 -25
  114. package/dist/useTask.d.ts.map +0 -1
  115. package/dist/useTask.js +0 -70
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,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C,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAQ;IACnC,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,QAAQ,CAAmC;IAEnD,WAAW,UAAS;IACpB,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAM;IAC3D,QAAQ,gBAAa;IACrB,UAAU,CAAC,OAAO,EAAE,OAAO;IAS3B,eAAe;IAMf,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IACjC,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IAEnC,iBAAiB,IAAI,IAAI;IAGzB,oBAAoB,IAAI,IAAI;IAI5B,yBAAyB,CACvB,SAAS,EAAE,QAAQ,CAAC;QAAE,QAAQ,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,CAAC,CAAC,GAClD,IAAI;IAQP,qBAAqB,IAAI,OAAO;IAMhC,MAAM;CA+DP"}
package/dist/component.js CHANGED
@@ -106,14 +106,10 @@ export class RaskComponent extends Component {
106
106
  const component = this.props.__component;
107
107
  const renderFn = component(this.reactiveProps);
108
108
  if (typeof renderFn === "function") {
109
- // Since we ran a setup function we need to clear any signals accessed
110
- this.reaction.dispose();
111
- this.reaction = this.createReaction();
112
109
  this.renderFn = renderFn;
113
110
  }
114
111
  else {
115
112
  this.renderFn = component;
116
- return renderFn;
117
113
  }
118
114
  }
119
115
  let result = null;
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,QAkEjE"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,QA2FjE"}
package/dist/render.js CHANGED
@@ -13,8 +13,9 @@ export function render(...params) {
13
13
  * Temporarily patches document.addEventListener during render to capture
14
14
  * and wrap Inferno's delegated event listeners with syncBatch
15
15
  */
16
- const originalAddEventListener = document.addEventListener.bind(document);
17
- const patchedEvents = new Set();
16
+ const originalAddEventListener = EventTarget.prototype.addEventListener;
17
+ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
18
+ const wrappedListeners = new WeakMap();
18
19
  // Inferno's delegated events
19
20
  const INFERNO_EVENTS = [
20
21
  "click",
@@ -35,28 +36,31 @@ export function render(...params) {
35
36
  "submit",
36
37
  ];
37
38
  // Temporarily replace addEventListener
38
- document.addEventListener = function (type, listener, options) {
39
+ EventTarget.prototype.addEventListener = function (type, listener, options) {
39
40
  // Only wrap Inferno's delegated event listeners
40
- if (INFERNO_EVENTS.includes(type) &&
41
- typeof listener === "function" &&
42
- !patchedEvents.has(type)) {
43
- patchedEvents.add(type);
41
+ if (INFERNO_EVENTS.includes(type) && typeof listener === "function") {
44
42
  const wrappedListener = function (event) {
45
43
  transaction(() => {
46
44
  listener.call(this, event);
47
45
  });
48
46
  };
49
- return originalAddEventListener(type, wrappedListener, options);
47
+ wrappedListeners.set(listener, wrappedListener);
48
+ return originalAddEventListener.call(this, type, wrappedListener, options);
50
49
  }
51
50
  // @ts-ignore
52
- return originalAddEventListener(type, listener, options);
51
+ return originalAddEventListener.call(this, type, listener, options);
53
52
  };
54
- try {
55
- // Call render - Inferno will synchronously attach its listeners
56
- return infernoRender(...params);
57
- }
58
- finally {
59
- // Restore original addEventListener
60
- document.addEventListener = originalAddEventListener;
61
- }
53
+ EventTarget.prototype.removeEventListener = function (type, listener, options) {
54
+ if (INFERNO_EVENTS.includes(type) &&
55
+ typeof listener === "function" &&
56
+ wrappedListeners.has(listener)) {
57
+ const wrappedListener = wrappedListeners.get(listener);
58
+ wrappedListeners.delete(listener);
59
+ // @ts-ignore
60
+ return originalRemoveEventListener.call(this, type, wrappedListener, options);
61
+ }
62
+ // @ts-ignore
63
+ return originalRemoveEventListener.call(this, type, listener, options);
64
+ };
65
+ return infernoRender(...params);
62
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rask-ui",
3
- "version": "0.29.2",
3
+ "version": "0.29.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,4 +0,0 @@
1
- export { createVNode, createFragment, createTextVNode, normalizeProps, Component, } from "inferno";
2
- import { VNode } from "inferno";
3
- export declare function createComponentVNode(_: any, component: any, props: any | undefined, key: any, ref: any): VNode;
4
- //# sourceMappingURL=compiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,GACV,MAAM,SAAS,CAAC;AAEjB,OAAO,EAGL,KAAK,EACN,MAAM,SAAS,CAAC;AAIjB,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,GAAG,EACN,SAAS,EAAE,GAAG,EACd,KAAK,EAAE,GAAG,YAAK,EACf,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,GACP,KAAK,CASP"}
package/dist/compiler.js DELETED
@@ -1,7 +0,0 @@
1
- export { createVNode, createFragment, createTextVNode, normalizeProps, Component, } from "inferno";
2
- import { createComponentVNode as infernoCreateComponentVnode, } from "inferno";
3
- import { RaskComponent } from "./component";
4
- export function createComponentVNode(_, component, props = {}, key, ref) {
5
- props.__component = component;
6
- return infernoCreateComponentVnode(4 /* VNodeFlags.ComponentClass */, RaskComponent, props, key, ref);
7
- }
@@ -1,39 +0,0 @@
1
- type AsyncState<T> = {
2
- isPending: true;
3
- value: null;
4
- error: null;
5
- } | {
6
- isPending: false;
7
- value: T;
8
- error: null;
9
- } | {
10
- isPending: false;
11
- value: null;
12
- error: string;
13
- };
14
- /**
15
- * Creates a reactive async state that tracks the lifecycle of a promise.
16
- *
17
- * @warning **Do not destructure the returned reactive object!** Destructuring breaks reactivity.
18
- * Access properties directly in your render function instead.
19
- *
20
- * @example
21
- * // ❌ Bad - destructuring loses reactivity
22
- * function Component() {
23
- * const async = createAsync(fetchData());
24
- * const { isPending, value, error } = async; // Don't do this!
25
- * return () => <div>{isPending ? "Loading..." : value}</div>; // Won't update!
26
- * }
27
- *
28
- * // ✅ Good - access properties directly
29
- * function Component() {
30
- * const async = createAsync(fetchData());
31
- * return () => <div>{async.isPending ? "Loading..." : async.value}</div>;
32
- * }
33
- *
34
- * @param promise - The promise to track
35
- * @returns Reactive state with isPending, value, and error properties
36
- */
37
- export declare function createAsync<T>(promise: Promise<T>): AsyncState<T>;
38
- export {};
39
- //# sourceMappingURL=createAsync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAsync.d.ts","sourceRoot":"","sources":["../src/createAsync.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,CAAC,CAAC,IACb;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,iBAwBjD"}
@@ -1,47 +0,0 @@
1
- import { createState } from "./createState";
2
- /**
3
- * Creates a reactive async state that tracks the lifecycle of a promise.
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 async = createAsync(fetchData());
12
- * const { isPending, value, error } = async; // Don't do this!
13
- * return () => <div>{isPending ? "Loading..." : value}</div>; // Won't update!
14
- * }
15
- *
16
- * // ✅ Good - access properties directly
17
- * function Component() {
18
- * const async = createAsync(fetchData());
19
- * return () => <div>{async.isPending ? "Loading..." : async.value}</div>;
20
- * }
21
- *
22
- * @param promise - The promise to track
23
- * @returns Reactive state with isPending, value, and error properties
24
- */
25
- export function createAsync(promise) {
26
- const state = createState({
27
- isPending: true,
28
- error: null,
29
- value: null,
30
- });
31
- promise
32
- .then((value) => {
33
- Object.assign(state, {
34
- value,
35
- error: null,
36
- isPending: false,
37
- });
38
- })
39
- .catch((error) => {
40
- Object.assign(state, {
41
- value: null,
42
- error: String(error),
43
- isPending: false,
44
- });
45
- });
46
- return state;
47
- }
@@ -1,4 +0,0 @@
1
- export declare function createComputed<T extends Record<string, () => any>>(computed: T): {
2
- [K in keyof T]: ReturnType<T[K]>;
3
- };
4
- //# sourceMappingURL=createComputed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createComputed.d.ts","sourceRoot":"","sources":["../src/createComputed.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAChE,QAAQ,EAAE,CAAC,GACV;KACA,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACjC,CA0EA"}
@@ -1,69 +0,0 @@
1
- import { getCurrentComponent, createCleanup } from "./component";
2
- import { INSPECT_MARKER, INSPECTOR_ENABLED } from "./inspect";
3
- import { getCurrentObserver, Observer, Signal } from "./observation";
4
- export function createComputed(computed) {
5
- const currentComponent = getCurrentComponent();
6
- const proxy = {};
7
- let notifyInspectorRef = {};
8
- for (const prop in computed) {
9
- let isDirty = true;
10
- let value;
11
- const signal = new Signal();
12
- const computedObserver = new Observer(() => {
13
- isDirty = true;
14
- signal.notify();
15
- if (INSPECTOR_ENABLED) {
16
- notifyInspectorRef.current?.notify({
17
- type: "computed",
18
- path: notifyInspectorRef.current.path.concat(prop),
19
- isDirty: true,
20
- value,
21
- });
22
- }
23
- });
24
- createCleanup(() => computedObserver.dispose());
25
- Object.defineProperty(proxy, prop, {
26
- enumerable: true,
27
- configurable: true,
28
- get() {
29
- const currentObserver = getCurrentObserver();
30
- if (currentObserver) {
31
- currentObserver.subscribeSignal(signal);
32
- }
33
- if (isDirty) {
34
- const stopObserving = computedObserver.observe();
35
- value = computed[prop]();
36
- stopObserving();
37
- isDirty = false;
38
- if (INSPECTOR_ENABLED) {
39
- notifyInspectorRef.current?.notify({
40
- type: "computed",
41
- path: notifyInspectorRef.current.path.concat(prop),
42
- isDirty: false,
43
- value,
44
- });
45
- }
46
- return value;
47
- }
48
- return value;
49
- },
50
- });
51
- }
52
- if (INSPECTOR_ENABLED) {
53
- Object.defineProperty(proxy, INSPECT_MARKER, {
54
- enumerable: false,
55
- configurable: false,
56
- get() {
57
- return !notifyInspectorRef.current;
58
- },
59
- set: (value) => {
60
- Object.defineProperty(notifyInspectorRef, "current", {
61
- get() {
62
- return value.current;
63
- },
64
- });
65
- },
66
- });
67
- }
68
- return proxy;
69
- }
@@ -1,2 +0,0 @@
1
- export declare function createEffect(cb: () => void | (() => void)): void;
2
- //# sourceMappingURL=createEffect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createEffect.d.ts","sourceRoot":"","sources":["../src/createEffect.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,QA2BzD"}
@@ -1,29 +0,0 @@
1
- import { syncBatch } from "./batch";
2
- import { createCleanup, getCurrentComponent } from "./component";
3
- import { Observer } from "./observation";
4
- export function createEffect(cb) {
5
- const component = getCurrentComponent();
6
- if (!component || component.isRendering) {
7
- throw new Error("Only use createEffect in component setup");
8
- }
9
- let disposer;
10
- const observer = new Observer(() => {
11
- syncBatch(runEffect);
12
- });
13
- const runEffect = () => {
14
- try {
15
- disposer?.();
16
- }
17
- catch (error) {
18
- console.error("Error in effect dispose function:", error);
19
- }
20
- const stopObserving = observer.observe();
21
- disposer = cb();
22
- stopObserving();
23
- };
24
- createCleanup(() => {
25
- observer.dispose();
26
- disposer?.();
27
- });
28
- runEffect();
29
- }
@@ -1,43 +0,0 @@
1
- type MutationState<T> = {
2
- isPending: true;
3
- params: T;
4
- error: null;
5
- } | {
6
- isPending: false;
7
- params: null;
8
- error: null;
9
- } | {
10
- isPending: false;
11
- params: null;
12
- error: string;
13
- };
14
- export type Mutation<T> = MutationState<T> & {
15
- mutate(): void;
16
- mutate(params: T): void;
17
- };
18
- /**
19
- * Creates a reactive mutation that manages async mutations with loading and error states.
20
- *
21
- * @warning **Do not destructure the returned reactive object!** Destructuring breaks reactivity.
22
- * Access properties directly in your render function instead.
23
- *
24
- * @example
25
- * // ❌ Bad - destructuring loses reactivity
26
- * function Component() {
27
- * const mutation = createMutation((params) => updateUser(params));
28
- * const { isPending, error } = mutation; // Don't do this!
29
- * return () => <button disabled={isPending}>Save</button>; // Won't update!
30
- * }
31
- *
32
- * // ✅ Good - access properties directly
33
- * function Component() {
34
- * const mutation = createMutation((params) => updateUser(params));
35
- * return () => <button disabled={mutation.isPending}>Save</button>;
36
- * }
37
- *
38
- * @param mutator - Function that performs the mutation and returns a promise
39
- * @returns Reactive mutation object with isPending, params, error properties and mutate method
40
- */
41
- export declare function createMutation<T>(mutator: (params: T) => Promise<T>): Mutation<T>;
42
- export {};
43
- //# sourceMappingURL=createMutation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMutation.d.ts","sourceRoot":"","sources":["../src/createMutation.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,CAAC,CAAC,IAChB;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IAC3C,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GACjC,QAAQ,CAAC,CAAC,CAAC,CA0Db"}
@@ -1,76 +0,0 @@
1
- import { createState } from "./createState";
2
- /**
3
- * Creates a reactive mutation that manages async mutations 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 mutation = createMutation((params) => updateUser(params));
12
- * const { isPending, error } = mutation; // Don't do this!
13
- * return () => <button disabled={isPending}>Save</button>; // Won't update!
14
- * }
15
- *
16
- * // ✅ Good - access properties directly
17
- * function Component() {
18
- * const mutation = createMutation((params) => updateUser(params));
19
- * return () => <button disabled={mutation.isPending}>Save</button>;
20
- * }
21
- *
22
- * @param mutator - Function that performs the mutation and returns a promise
23
- * @returns Reactive mutation object with isPending, params, error properties and mutate method
24
- */
25
- export function createMutation(mutator) {
26
- const state = createState({
27
- isPending: false,
28
- params: null,
29
- error: null,
30
- });
31
- const assign = (newState) => {
32
- Object.assign(state, newState);
33
- };
34
- let currentAbortController;
35
- return {
36
- get isPending() {
37
- return state.isPending;
38
- },
39
- get params() {
40
- return state.params;
41
- },
42
- get error() {
43
- return state.error;
44
- },
45
- mutate(params) {
46
- currentAbortController?.abort();
47
- const abortController = (currentAbortController = new AbortController());
48
- assign({
49
- isPending: true,
50
- params,
51
- error: null,
52
- });
53
- mutator(params)
54
- .then(() => {
55
- if (abortController.signal.aborted) {
56
- return;
57
- }
58
- assign({
59
- isPending: false,
60
- params: null,
61
- error: null,
62
- });
63
- })
64
- .catch((error) => {
65
- if (abortController.signal.aborted) {
66
- return;
67
- }
68
- assign({
69
- isPending: false,
70
- params: null,
71
- error: String(error),
72
- });
73
- });
74
- },
75
- };
76
- }
@@ -1,42 +0,0 @@
1
- type QueryState<T> = {
2
- isPending: true;
3
- data: T | null;
4
- error: null;
5
- } | {
6
- isPending: false;
7
- data: T;
8
- error: null;
9
- } | {
10
- isPending: false;
11
- data: null;
12
- error: string;
13
- };
14
- export type Query<T> = QueryState<T> & {
15
- fetch(force?: boolean): void;
16
- };
17
- /**
18
- * Creates a reactive query that manages data fetching with loading and error states.
19
- *
20
- * @warning **Do not destructure the returned reactive object!** Destructuring breaks reactivity.
21
- * Access properties directly in your render function instead.
22
- *
23
- * @example
24
- * // ❌ Bad - destructuring loses reactivity
25
- * function Component() {
26
- * const query = createQuery(() => fetchUsers());
27
- * const { isPending, data, error } = query; // Don't do this!
28
- * return () => <div>{isPending ? "Loading..." : data.length}</div>; // Won't update!
29
- * }
30
- *
31
- * // ✅ Good - access properties directly
32
- * function Component() {
33
- * const query = createQuery(() => fetchUsers());
34
- * return () => <div>{query.isPending ? "Loading..." : query.data.length}</div>;
35
- * }
36
- *
37
- * @param fetcher - Function that returns a promise with the data to fetch
38
- * @returns Reactive query object with isPending, data, error properties and fetch method
39
- */
40
- export declare function createQuery<T>(fetcher: () => Promise<T>): Query<T>;
41
- export {};
42
- //# sourceMappingURL=createQuery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createQuery.d.ts","sourceRoot":"","sources":["../src/createQuery.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,CAAC,CAAC,IACb;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG;IACrC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CA+DlE"}
@@ -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"}