@assistant-ui/tap 0.5.11 → 0.5.12

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/README.md +21 -364
  2. package/dist/core/ResourceFiber.d.ts +9 -5
  3. package/dist/core/ResourceFiber.d.ts.map +1 -1
  4. package/dist/core/ResourceFiber.js +47 -45
  5. package/dist/core/ResourceFiber.js.map +1 -1
  6. package/dist/core/context.d.ts +7 -5
  7. package/dist/core/context.d.ts.map +1 -1
  8. package/dist/core/context.js +16 -15
  9. package/dist/core/context.js.map +1 -1
  10. package/dist/core/createResourceRoot.d.ts +8 -4
  11. package/dist/core/createResourceRoot.d.ts.map +1 -1
  12. package/dist/core/createResourceRoot.js +25 -26
  13. package/dist/core/createResourceRoot.js.map +1 -1
  14. package/dist/core/helpers/callResourceFn.d.ts +1 -2
  15. package/dist/core/helpers/callResourceFn.js +15 -13
  16. package/dist/core/helpers/callResourceFn.js.map +1 -1
  17. package/dist/core/helpers/commit.d.ts +7 -3
  18. package/dist/core/helpers/commit.d.ts.map +1 -1
  19. package/dist/core/helpers/commit.js +33 -50
  20. package/dist/core/helpers/commit.js.map +1 -1
  21. package/dist/core/helpers/env.d.ts +4 -1
  22. package/dist/core/helpers/env.d.ts.map +1 -1
  23. package/dist/core/helpers/env.js +5 -2
  24. package/dist/core/helpers/env.js.map +1 -1
  25. package/dist/core/helpers/execution-context.d.ts +8 -4
  26. package/dist/core/helpers/execution-context.d.ts.map +1 -1
  27. package/dist/core/helpers/execution-context.js +22 -27
  28. package/dist/core/helpers/execution-context.js.map +1 -1
  29. package/dist/core/helpers/root.d.ts +10 -6
  30. package/dist/core/helpers/root.d.ts.map +1 -1
  31. package/dist/core/helpers/root.js +45 -48
  32. package/dist/core/helpers/root.js.map +1 -1
  33. package/dist/core/resource.d.ts +8 -4
  34. package/dist/core/resource.d.ts.map +1 -1
  35. package/dist/core/resource.js +13 -9
  36. package/dist/core/resource.js.map +1 -1
  37. package/dist/core/scheduler.d.ts +11 -9
  38. package/dist/core/scheduler.d.ts.map +1 -1
  39. package/dist/core/scheduler.js +70 -83
  40. package/dist/core/scheduler.js.map +1 -1
  41. package/dist/core/types.d.ts +56 -55
  42. package/dist/core/types.d.ts.map +1 -1
  43. package/dist/core/types.js +0 -2
  44. package/dist/core/withKey.d.ts +6 -2
  45. package/dist/core/withKey.d.ts.map +1 -1
  46. package/dist/core/withKey.js +9 -2
  47. package/dist/core/withKey.js.map +1 -1
  48. package/dist/hooks/tap-callback.d.ts +4 -1
  49. package/dist/hooks/tap-callback.d.ts.map +1 -1
  50. package/dist/hooks/tap-callback.js +6 -3
  51. package/dist/hooks/tap-callback.js.map +1 -1
  52. package/dist/hooks/tap-const.d.ts +4 -1
  53. package/dist/hooks/tap-const.d.ts.map +1 -1
  54. package/dist/hooks/tap-const.js +7 -3
  55. package/dist/hooks/tap-const.js.map +1 -1
  56. package/dist/hooks/tap-effect-event.d.ts +4 -1
  57. package/dist/hooks/tap-effect-event.d.ts.map +1 -1
  58. package/dist/hooks/tap-effect-event.js +31 -29
  59. package/dist/hooks/tap-effect-event.js.map +1 -1
  60. package/dist/hooks/tap-effect.d.ts +8 -5
  61. package/dist/hooks/tap-effect.d.ts.map +1 -1
  62. package/dist/hooks/tap-effect.js +35 -45
  63. package/dist/hooks/tap-effect.js.map +1 -1
  64. package/dist/hooks/tap-memo.d.ts +4 -1
  65. package/dist/hooks/tap-memo.d.ts.map +1 -1
  66. package/dist/hooks/tap-memo.js +17 -13
  67. package/dist/hooks/tap-memo.js.map +1 -1
  68. package/dist/hooks/tap-reducer.d.ts +7 -5
  69. package/dist/hooks/tap-reducer.d.ts.map +1 -1
  70. package/dist/hooks/tap-reducer.js +70 -76
  71. package/dist/hooks/tap-reducer.js.map +1 -1
  72. package/dist/hooks/tap-ref.d.ts +9 -6
  73. package/dist/hooks/tap-ref.d.ts.map +1 -1
  74. package/dist/hooks/tap-ref.js +7 -5
  75. package/dist/hooks/tap-ref.js.map +1 -1
  76. package/dist/hooks/tap-resource.d.ts +7 -3
  77. package/dist/hooks/tap-resource.d.ts.map +1 -1
  78. package/dist/hooks/tap-resource.js +31 -22
  79. package/dist/hooks/tap-resource.js.map +1 -1
  80. package/dist/hooks/tap-resources.d.ts +6 -2
  81. package/dist/hooks/tap-resources.d.ts.map +1 -1
  82. package/dist/hooks/tap-resources.js +74 -96
  83. package/dist/hooks/tap-resources.js.map +1 -1
  84. package/dist/hooks/tap-state.d.ts +7 -7
  85. package/dist/hooks/tap-state.d.ts.map +1 -1
  86. package/dist/hooks/tap-state.js +7 -5
  87. package/dist/hooks/tap-state.js.map +1 -1
  88. package/dist/hooks/utils/depsShallowEqual.d.ts +4 -1
  89. package/dist/hooks/utils/depsShallowEqual.d.ts.map +1 -1
  90. package/dist/hooks/utils/depsShallowEqual.js +8 -8
  91. package/dist/hooks/utils/depsShallowEqual.js.map +1 -1
  92. package/dist/hooks/utils/tapHook.d.ts +8 -4
  93. package/dist/hooks/utils/tapHook.d.ts.map +1 -1
  94. package/dist/hooks/utils/tapHook.js +17 -20
  95. package/dist/hooks/utils/tapHook.js.map +1 -1
  96. package/dist/index.d.ts +18 -18
  97. package/dist/index.js +17 -23
  98. package/dist/react/index.d.ts +2 -2
  99. package/dist/react/index.js +2 -2
  100. package/dist/react/use-resource.d.ts +6 -2
  101. package/dist/react/use-resource.d.ts.map +1 -1
  102. package/dist/react/use-resource.js +41 -36
  103. package/dist/react/use-resource.js.map +1 -1
  104. package/dist/tapResourceRoot.d.ts +18 -14
  105. package/dist/tapResourceRoot.d.ts.map +1 -1
  106. package/dist/tapResourceRoot.js +68 -77
  107. package/dist/tapResourceRoot.js.map +1 -1
  108. package/package.json +8 -8
  109. package/src/core/types.ts +1 -2
  110. package/dist/core/helpers/callResourceFn.d.ts.map +0 -1
  111. package/dist/core/types.js.map +0 -1
  112. package/dist/index.d.ts.map +0 -1
  113. package/dist/index.js.map +0 -1
  114. package/dist/react/index.d.ts.map +0 -1
  115. package/dist/react/index.js.map +0 -1
@@ -1,32 +1,31 @@
1
- import { createResourceFiber, unmountResourceFiber, renderResourceFiber, commitResourceFiber, } from "./ResourceFiber.js";
2
- import { tapResourceRoot } from "../tapResourceRoot.js";
3
1
  import { resource } from "./resource.js";
4
2
  import { isDevelopment } from "./helpers/env.js";
5
- import { flushResourcesSync, UpdateScheduler } from "./scheduler.js";
6
3
  import { createResourceFiberRoot } from "./helpers/root.js";
4
+ import { commitResourceFiber, createResourceFiber, renderResourceFiber, unmountResourceFiber } from "./ResourceFiber.js";
5
+ import { UpdateScheduler, flushResourcesSync } from "./scheduler.js";
6
+ import { tapResourceRoot } from "../tapResourceRoot.js";
7
+ //#region src/core/createResourceRoot.ts
7
8
  const SubscribableResource = resource(tapResourceRoot);
8
- export const createResourceRoot = () => {
9
- const fiber = createResourceFiber(SubscribableResource, createResourceFiberRoot((callback) => {
10
- new UpdateScheduler(() => {
11
- if (callback()) {
12
- throw new Error("Unexpected rerender of createResourceRoot outer fiber");
13
- }
14
- return false;
15
- }).markDirty();
16
- }), undefined, isDevelopment ? "root" : null);
17
- return {
18
- render: (element) => {
19
- // In strict mode, render twice to detect side effects
20
- if (isDevelopment && fiber.devStrictMode === "root") {
21
- void renderResourceFiber(fiber, element);
22
- }
23
- const render = renderResourceFiber(fiber, element);
24
- flushResourcesSync(() => commitResourceFiber(fiber, render));
25
- return render.output;
26
- },
27
- unmount: () => {
28
- unmountResourceFiber(fiber);
29
- },
30
- };
9
+ const createResourceRoot = () => {
10
+ const fiber = createResourceFiber(SubscribableResource, createResourceFiberRoot((callback) => {
11
+ new UpdateScheduler(() => {
12
+ if (callback()) throw new Error("Unexpected rerender of createResourceRoot outer fiber");
13
+ return false;
14
+ }).markDirty();
15
+ }), void 0, isDevelopment ? "root" : null);
16
+ return {
17
+ render: (element) => {
18
+ if (isDevelopment && fiber.devStrictMode === "root") renderResourceFiber(fiber, element);
19
+ const render = renderResourceFiber(fiber, element);
20
+ flushResourcesSync(() => commitResourceFiber(fiber, render));
21
+ return render.output;
22
+ },
23
+ unmount: () => {
24
+ unmountResourceFiber(fiber);
25
+ }
26
+ };
31
27
  };
28
+ //#endregion
29
+ export { createResourceRoot };
30
+
32
31
  //# sourceMappingURL=createResourceRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createResourceRoot.js","sourceRoot":"","sources":["../../src/core/createResourceRoot.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,2BAAwB;AACzB,OAAO,EAAE,eAAe,EAAE,8BAA2B;AACrD,OAAO,EAAE,QAAQ,EAAE,sBAAmB;AACtC,OAAO,EAAE,aAAa,EAAE,yBAAsB;AAC9C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,uBAAoB;AAClE,OAAO,EAAE,uBAAuB,EAAE,0BAAuB;AAEzD,MAAM,oBAAoB,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,KAAK,GAAG,mBAAmB,CAI/B,oBAAoB,EACpB,uBAAuB,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnC,IAAI,eAAe,CAAC,GAAG,EAAE;YACvB,IAAI,QAAQ,EAAE,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;YACJ,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IACjB,CAAC,CAAC,EACF,SAAS,EACT,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAC9B,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,CAAO,OAA8B,EAAE,EAAE;YAC/C,sDAAsD;YACtD,IAAI,aAAa,IAAI,KAAK,CAAC,aAAa,KAAK,MAAM,EAAE,CAAC;gBACpD,KAAK,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC3C,CAAC;YAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAEnD,kBAAkB,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;YAE7D,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"createResourceRoot.js","names":[],"sources":["../../src/core/createResourceRoot.ts"],"sourcesContent":["import type { ResourceElement } from \"./types\";\nimport {\n createResourceFiber,\n unmountResourceFiber,\n renderResourceFiber,\n commitResourceFiber,\n} from \"./ResourceFiber\";\nimport { tapResourceRoot } from \"../tapResourceRoot\";\nimport { resource } from \"./resource\";\nimport { isDevelopment } from \"./helpers/env\";\nimport { flushResourcesSync, UpdateScheduler } from \"./scheduler\";\nimport { createResourceFiberRoot } from \"./helpers/root\";\n\nconst SubscribableResource = resource(tapResourceRoot);\n\nexport const createResourceRoot = () => {\n const fiber = createResourceFiber<\n tapResourceRoot.SubscribableResource<any>,\n ResourceElement<any>\n >(\n SubscribableResource,\n createResourceFiberRoot((callback) => {\n new UpdateScheduler(() => {\n if (callback()) {\n throw new Error(\n \"Unexpected rerender of createResourceRoot outer fiber\",\n );\n }\n return false;\n }).markDirty();\n }),\n undefined,\n isDevelopment ? \"root\" : null,\n );\n\n return {\n render: <R, P>(element: ResourceElement<R, P>) => {\n // In strict mode, render twice to detect side effects\n if (isDevelopment && fiber.devStrictMode === \"root\") {\n void renderResourceFiber(fiber, element);\n }\n\n const render = renderResourceFiber(fiber, element);\n\n flushResourcesSync(() => commitResourceFiber(fiber, render));\n\n return render.output;\n },\n unmount: () => {\n unmountResourceFiber(fiber);\n },\n };\n};\n"],"mappings":";;;;;;;AAaA,MAAM,uBAAuB,SAAS,eAAe;AAErD,MAAa,2BAA2B;CACtC,MAAM,QAAQ,oBAIZ,sBACA,yBAAyB,aAAa;EACpC,IAAI,sBAAsB;GACxB,IAAI,SAAS,GACX,MAAM,IAAI,MACR,uDACF;GAEF,OAAO;EACT,CAAC,EAAE,UAAU;CACf,CAAC,GACD,KAAA,GACA,gBAAgB,SAAS,IAC3B;CAEA,OAAO;EACL,SAAe,YAAmC;GAEhD,IAAI,iBAAiB,MAAM,kBAAkB,QAC3C,oBAAyB,OAAO,OAAO;GAGzC,MAAM,SAAS,oBAAoB,OAAO,OAAO;GAEjD,yBAAyB,oBAAoB,OAAO,MAAM,CAAC;GAE3D,OAAO,OAAO;EAChB;EACA,eAAe;GACb,qBAAqB,KAAK;EAC5B;CACF;AACF"}
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=callResourceFn.d.ts.map
1
+ export { };
@@ -1,17 +1,19 @@
1
+ //#region src/core/helpers/callResourceFn.ts
1
2
  /**
2
- * Renders a resource with the given props.
3
- * @internal This is for internal use only.
4
- */
5
- export function callResourceFn(resource, props) {
6
- const fn = resource[fnSymbol];
7
- if (!fn) {
8
- throw new Error("ResourceElement.type is not a valid Resource");
9
- }
10
- return fn(props);
3
+ * Renders a resource with the given props.
4
+ * @internal This is for internal use only.
5
+ */
6
+ function callResourceFn(resource, props) {
7
+ const fn = resource[fnSymbol];
8
+ if (!fn) throw new Error("ResourceElement.type is not a valid Resource");
9
+ return fn(props);
11
10
  }
12
11
  /**
13
- * Symbol used to store the ResourceFn in the Resource constructor.
14
- * @internal This is for internal use only.
15
- */
16
- export const fnSymbol = Symbol("fnSymbol");
12
+ * Symbol used to store the ResourceFn in the Resource constructor.
13
+ * @internal This is for internal use only.
14
+ */
15
+ const fnSymbol = Symbol("fnSymbol");
16
+ //#endregion
17
+ export { callResourceFn, fnSymbol };
18
+
17
19
  //# sourceMappingURL=callResourceFn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callResourceFn.js","sourceRoot":"","sources":["../../../src/core/helpers/callResourceFn.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAO,QAAwB,EAAE,KAAQ;IACrE,MAAM,EAAE,GAAI,QAAwD,CAClE,QAAQ,CACT,CAAC;IACF,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"callResourceFn.js","names":[],"sources":["../../../src/core/helpers/callResourceFn.ts"],"sourcesContent":["import type { Resource } from \"../types\";\n\n/**\n * Renders a resource with the given props.\n * @internal This is for internal use only.\n */\nexport function callResourceFn<R, P>(resource: Resource<R, P>, props: P): R {\n const fn = (resource as unknown as { [fnSymbol]?: (props: P) => R })[\n fnSymbol\n ];\n if (!fn) {\n throw new Error(\"ResourceElement.type is not a valid Resource\");\n }\n return fn(props);\n}\n\n/**\n * Symbol used to store the ResourceFn in the Resource constructor.\n * @internal This is for internal use only.\n */\nexport const fnSymbol = Symbol(\"fnSymbol\");\n"],"mappings":";;;;;AAMA,SAAgB,eAAqB,UAA0B,OAAa;CAC1E,MAAM,KAAM,SACV;CAEF,IAAI,CAAC,IACH,MAAM,IAAI,MAAM,8CAA8C;CAEhE,OAAO,GAAG,KAAK;AACjB;;;;;AAMA,MAAa,WAAW,OAAO,UAAU"}
@@ -1,4 +1,8 @@
1
- import type { ResourceFiber, RenderResult } from "../types.js";
2
- export declare function commitAllEffects(renderResult: RenderResult): void;
3
- export declare function cleanupAllEffects<R, P>(executionContext: ResourceFiber<R, P>): void;
1
+ import { RenderResult, ResourceFiber } from "../types.js";
2
+
3
+ //#region src/core/helpers/commit.d.ts
4
+ declare function commitAllEffects(renderResult: RenderResult): void;
5
+ declare function cleanupAllEffects<R, P>(executionContext: ResourceFiber<R, P>): void;
6
+ //#endregion
7
+ export { cleanupAllEffects, commitAllEffects };
4
8
  //# sourceMappingURL=commit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAiB;AAE5D,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAqBjE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,QA2B5E"}
1
+ {"version":3,"file":"commit.d.ts","names":[],"sources":["../../../src/core/helpers/commit.ts"],"mappings":";;;iBAEgB,gBAAA,CAAiB,YAA0B,EAAZ,YAAY;AAAA,iBAuB3C,iBAAA,MAAA,CAAwB,gBAAA,EAAkB,aAAA,CAAc,CAAA,EAAG,CAAA"}
@@ -1,53 +1,36 @@
1
- export function commitAllEffects(renderResult) {
2
- const errors = [];
3
- for (const task of renderResult.effectTasks) {
4
- try {
5
- task();
6
- }
7
- catch (error) {
8
- errors.push(error);
9
- }
10
- }
11
- if (errors.length > 0) {
12
- if (errors.length === 1) {
13
- throw errors[0];
14
- }
15
- else {
16
- for (const error of errors) {
17
- console.error(error);
18
- }
19
- throw new AggregateError(errors, "Errors during commit");
20
- }
21
- }
1
+ //#region src/core/helpers/commit.ts
2
+ function commitAllEffects(renderResult) {
3
+ const errors = [];
4
+ for (const task of renderResult.effectTasks) try {
5
+ task();
6
+ } catch (error) {
7
+ errors.push(error);
8
+ }
9
+ if (errors.length > 0) if (errors.length === 1) throw errors[0];
10
+ else {
11
+ for (const error of errors) console.error(error);
12
+ throw new AggregateError(errors, "Errors during commit");
13
+ }
22
14
  }
23
- export function cleanupAllEffects(executionContext) {
24
- const errors = [];
25
- for (const cell of executionContext.cells) {
26
- if (cell?.type === "effect") {
27
- cell.deps = null; // Reset deps so effect runs again on next mount
28
- if (cell.cleanup) {
29
- try {
30
- cell.cleanup?.();
31
- }
32
- catch (e) {
33
- errors.push(e);
34
- }
35
- finally {
36
- cell.cleanup = undefined;
37
- }
38
- }
39
- }
40
- }
41
- if (errors.length > 0) {
42
- if (errors.length === 1) {
43
- throw errors[0];
44
- }
45
- else {
46
- for (const error of errors) {
47
- console.error(error);
48
- }
49
- throw new AggregateError(errors, "Errors during cleanup");
50
- }
51
- }
15
+ function cleanupAllEffects(executionContext) {
16
+ const errors = [];
17
+ for (const cell of executionContext.cells) if (cell?.type === "effect") {
18
+ cell.deps = null;
19
+ if (cell.cleanup) try {
20
+ cell.cleanup?.();
21
+ } catch (e) {
22
+ errors.push(e);
23
+ } finally {
24
+ cell.cleanup = void 0;
25
+ }
26
+ }
27
+ if (errors.length > 0) if (errors.length === 1) throw errors[0];
28
+ else {
29
+ for (const error of errors) console.error(error);
30
+ throw new AggregateError(errors, "Errors during cleanup");
31
+ }
52
32
  }
33
+ //#endregion
34
+ export { cleanupAllEffects, commitAllEffects };
35
+
53
36
  //# sourceMappingURL=commit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commit.js","sourceRoot":"","sources":["../../../src/core/helpers/commit.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,YAA0B;IACzD,MAAM,MAAM,GAAc,EAAE,CAAC;IAE7B,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YACD,MAAM,IAAI,cAAc,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAO,gBAAqC;IAC3E,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC1C,IAAI,IAAI,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,gDAAgD;YAElE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC;oBACH,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;gBACnB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACjB,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YACD,MAAM,IAAI,cAAc,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"commit.js","names":[],"sources":["../../../src/core/helpers/commit.ts"],"sourcesContent":["import type { ResourceFiber, RenderResult } from \"../types\";\n\nexport function commitAllEffects(renderResult: RenderResult): void {\n const errors: unknown[] = [];\n\n for (const task of renderResult.effectTasks) {\n try {\n task();\n } catch (error) {\n errors.push(error);\n }\n }\n\n if (errors.length > 0) {\n if (errors.length === 1) {\n throw errors[0];\n } else {\n for (const error of errors) {\n console.error(error);\n }\n throw new AggregateError(errors, \"Errors during commit\");\n }\n }\n}\n\nexport function cleanupAllEffects<R, P>(executionContext: ResourceFiber<R, P>) {\n const errors: unknown[] = [];\n for (const cell of executionContext.cells) {\n if (cell?.type === \"effect\") {\n cell.deps = null; // Reset deps so effect runs again on next mount\n\n if (cell.cleanup) {\n try {\n cell.cleanup?.();\n } catch (e) {\n errors.push(e);\n } finally {\n cell.cleanup = undefined;\n }\n }\n }\n }\n if (errors.length > 0) {\n if (errors.length === 1) {\n throw errors[0];\n } else {\n for (const error of errors) {\n console.error(error);\n }\n throw new AggregateError(errors, \"Errors during cleanup\");\n }\n }\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,cAAkC;CACjE,MAAM,SAAoB,CAAC;CAE3B,KAAK,MAAM,QAAQ,aAAa,aAC9B,IAAI;EACF,KAAK;CACP,SAAS,OAAO;EACd,OAAO,KAAK,KAAK;CACnB;CAGF,IAAI,OAAO,SAAS,GAClB,IAAI,OAAO,WAAW,GACpB,MAAM,OAAO;MACR;EACL,KAAK,MAAM,SAAS,QAClB,QAAQ,MAAM,KAAK;EAErB,MAAM,IAAI,eAAe,QAAQ,sBAAsB;CACzD;AAEJ;AAEA,SAAgB,kBAAwB,kBAAuC;CAC7E,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,iBAAiB,OAClC,IAAI,MAAM,SAAS,UAAU;EAC3B,KAAK,OAAO;EAEZ,IAAI,KAAK,SACP,IAAI;GACF,KAAK,UAAU;EACjB,SAAS,GAAG;GACV,OAAO,KAAK,CAAC;EACf,UAAU;GACR,KAAK,UAAU,KAAA;EACjB;CAEJ;CAEF,IAAI,OAAO,SAAS,GAClB,IAAI,OAAO,WAAW,GACpB,MAAM,OAAO;MACR;EACL,KAAK,MAAM,SAAS,QAClB,QAAQ,MAAM,KAAK;EAErB,MAAM,IAAI,eAAe,QAAQ,uBAAuB;CAC1D;AAEJ"}
@@ -1,2 +1,5 @@
1
- export declare const isDevelopment: boolean;
1
+ //#region src/core/helpers/env.d.ts
2
+ declare const isDevelopment: boolean;
3
+ //#endregion
4
+ export { isDevelopment };
2
5
  //# sourceMappingURL=env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,SAEmD,CAAC"}
1
+ {"version":3,"file":"env.d.ts","names":[],"sources":["../../../src/core/helpers/env.ts"],"mappings":";cAAa,aAAA"}
@@ -1,3 +1,6 @@
1
- export const isDevelopment = typeof process !== "undefined" &&
2
- (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test");
1
+ //#region src/core/helpers/env.ts
2
+ const isDevelopment = typeof process !== "undefined" && (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test");
3
+ //#endregion
4
+ export { isDevelopment };
5
+
3
6
  //# sourceMappingURL=env.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/core/helpers/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GACxB,OAAO,OAAO,KAAK,WAAW;IAC9B,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"env.js","names":[],"sources":["../../../src/core/helpers/env.ts"],"sourcesContent":["export const isDevelopment =\n typeof process !== \"undefined\" &&\n (process.env.NODE_ENV === \"development\" || process.env.NODE_ENV === \"test\");\n"],"mappings":";AAAA,MAAa,gBACX,OAAO,YAAY,gBAClB,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,aAAa"}
@@ -1,5 +1,9 @@
1
- import type { ResourceFiber } from "../types.js";
2
- export declare function withResourceFiber<R, P>(fiber: ResourceFiber<R, P>, fn: () => void): void;
3
- export declare function getCurrentResourceFiber(): ResourceFiber<unknown, unknown>;
4
- export declare function getDevStrictMode(enable: boolean): "root" | "child" | null;
1
+ import { ResourceFiber } from "../types.js";
2
+
3
+ //#region src/core/helpers/execution-context.d.ts
4
+ declare function withResourceFiber<R, P>(fiber: ResourceFiber<R, P>, fn: () => void): void;
5
+ declare function getCurrentResourceFiber(): ResourceFiber<unknown, unknown>;
6
+ declare function getDevStrictMode(enable: boolean): "root" | "child" | null;
7
+ //#endregion
8
+ export { getCurrentResourceFiber, getDevStrictMode, withResourceFiber };
5
9
  //# sourceMappingURL=execution-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/execution-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAiB;AAI9C,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EACpC,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,EAAE,EAAE,MAAM,IAAI,GACb,IAAI,CAoBN;AACD,wBAAgB,uBAAuB,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAKzE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,2BAM/C"}
1
+ {"version":3,"file":"execution-context.d.ts","names":[],"sources":["../../../src/core/helpers/execution-context.ts"],"mappings":";;;iBAKgB,iBAAA,MAAA,CACd,KAAA,EAAO,aAAA,CAAc,CAAA,EAAG,CAAA,GACxB,EAAA;AAAA,iBAsBc,uBAAA,CAAA,GAA2B,aAAa;AAAA,iBAOxC,gBAAA,CAAiB,MAAe"}
@@ -1,33 +1,28 @@
1
1
  import { isDevelopment } from "./env.js";
2
+ //#region src/core/helpers/execution-context.ts
2
3
  let currentResourceFiber = null;
3
- export function withResourceFiber(fiber, fn) {
4
- fiber.currentIndex = 0;
5
- const previousContext = currentResourceFiber;
6
- currentResourceFiber = fiber;
7
- try {
8
- fn();
9
- fiber.isFirstRender = false;
10
- // ensure hook count matches
11
- if (fiber.cells.length !== fiber.currentIndex) {
12
- throw new Error(`Rendered ${fiber.currentIndex} hooks but expected ${fiber.cells.length}. ` +
13
- "Hooks must be called in the exact same order in every render.");
14
- }
15
- }
16
- finally {
17
- currentResourceFiber = previousContext;
18
- }
4
+ function withResourceFiber(fiber, fn) {
5
+ fiber.currentIndex = 0;
6
+ const previousContext = currentResourceFiber;
7
+ currentResourceFiber = fiber;
8
+ try {
9
+ fn();
10
+ fiber.isFirstRender = false;
11
+ if (fiber.cells.length !== fiber.currentIndex) throw new Error(`Rendered ${fiber.currentIndex} hooks but expected ${fiber.cells.length}. Hooks must be called in the exact same order in every render.`);
12
+ } finally {
13
+ currentResourceFiber = previousContext;
14
+ }
19
15
  }
20
- export function getCurrentResourceFiber() {
21
- if (!currentResourceFiber) {
22
- throw new Error("No resource fiber available");
23
- }
24
- return currentResourceFiber;
16
+ function getCurrentResourceFiber() {
17
+ if (!currentResourceFiber) throw new Error("No resource fiber available");
18
+ return currentResourceFiber;
25
19
  }
26
- export function getDevStrictMode(enable) {
27
- if (!isDevelopment)
28
- return null;
29
- if (currentResourceFiber?.devStrictMode)
30
- return currentResourceFiber.isFirstRender ? "child" : "root";
31
- return enable ? "root" : null;
20
+ function getDevStrictMode(enable) {
21
+ if (!isDevelopment) return null;
22
+ if (currentResourceFiber?.devStrictMode) return currentResourceFiber.isFirstRender ? "child" : "root";
23
+ return enable ? "root" : null;
32
24
  }
25
+ //#endregion
26
+ export { getCurrentResourceFiber, getDevStrictMode, withResourceFiber };
27
+
33
28
  //# sourceMappingURL=execution-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-context.js","sourceRoot":"","sources":["../../../src/core/helpers/execution-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAc;AAGtC,IAAI,oBAAoB,GAAmC,IAAI,CAAC;AAEhE,MAAM,UAAU,iBAAiB,CAC/B,KAA0B,EAC1B,EAAc;IAEd,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;IAEvB,MAAM,eAAe,GAAG,oBAAoB,CAAC;IAC7C,oBAAoB,GAAG,KAAK,CAAC;IAC7B,IAAI,CAAC;QACH,EAAE,EAAE,CAAC;QAEL,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC;QAE5B,4BAA4B;QAC5B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,YAAY,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,YAAY,KAAK,CAAC,YAAY,uBAAuB,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI;gBACzE,+DAA+D,CAClE,CAAC;QACJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,oBAAoB,GAAG,eAAe,CAAC;IACzC,CAAC;AACH,CAAC;AACD,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,oBAAoB,EAAE,aAAa;QACrC,OAAO,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAE/D,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"execution-context.js","names":[],"sources":["../../../src/core/helpers/execution-context.ts"],"sourcesContent":["import { isDevelopment } from \"./env\";\nimport type { ResourceFiber } from \"../types\";\n\nlet currentResourceFiber: ResourceFiber<any, any> | null = null;\n\nexport function withResourceFiber<R, P>(\n fiber: ResourceFiber<R, P>,\n fn: () => void,\n): void {\n fiber.currentIndex = 0;\n\n const previousContext = currentResourceFiber;\n currentResourceFiber = fiber;\n try {\n fn();\n\n fiber.isFirstRender = false;\n\n // ensure hook count matches\n if (fiber.cells.length !== fiber.currentIndex) {\n throw new Error(\n `Rendered ${fiber.currentIndex} hooks but expected ${fiber.cells.length}. ` +\n \"Hooks must be called in the exact same order in every render.\",\n );\n }\n } finally {\n currentResourceFiber = previousContext;\n }\n}\nexport function getCurrentResourceFiber(): ResourceFiber<unknown, unknown> {\n if (!currentResourceFiber) {\n throw new Error(\"No resource fiber available\");\n }\n return currentResourceFiber;\n}\n\nexport function getDevStrictMode(enable: boolean) {\n if (!isDevelopment) return null;\n if (currentResourceFiber?.devStrictMode)\n return currentResourceFiber.isFirstRender ? \"child\" : \"root\";\n\n return enable ? \"root\" : null;\n}\n"],"mappings":";;AAGA,IAAI,uBAAuD;AAE3D,SAAgB,kBACd,OACA,IACM;CACN,MAAM,eAAe;CAErB,MAAM,kBAAkB;CACxB,uBAAuB;CACvB,IAAI;EACF,GAAG;EAEH,MAAM,gBAAgB;EAGtB,IAAI,MAAM,MAAM,WAAW,MAAM,cAC/B,MAAM,IAAI,MACR,YAAY,MAAM,aAAa,sBAAsB,MAAM,MAAM,OAAO,gEAE1E;CAEJ,UAAU;EACR,uBAAuB;CACzB;AACF;AACA,SAAgB,0BAA2D;CACzE,IAAI,CAAC,sBACH,MAAM,IAAI,MAAM,6BAA6B;CAE/C,OAAO;AACT;AAEA,SAAgB,iBAAiB,QAAiB;CAChD,IAAI,CAAC,eAAe,OAAO;CAC3B,IAAI,sBAAsB,eACxB,OAAO,qBAAqB,gBAAgB,UAAU;CAExD,OAAO,SAAS,SAAS;AAC3B"}
@@ -1,8 +1,12 @@
1
- import type { Cell, ResourceFiber, ResourceFiberRoot } from "../types.js";
2
- export declare const createResourceFiberRoot: (dispatchUpdate: (cb: () => boolean) => void) => ResourceFiberRoot;
3
- export declare const commitRoot: (root: ResourceFiberRoot) => void;
4
- export declare const setRootVersion: (root: ResourceFiberRoot, version: number) => void;
5
- export declare const markCellDirty: (fiber: ResourceFiber<any, any>, cell: Cell & {
6
- type: "reducer";
1
+ import { Cell, ResourceFiber, ResourceFiberRoot } from "../types.js";
2
+
3
+ //#region src/core/helpers/root.d.ts
4
+ declare const createResourceFiberRoot: (dispatchUpdate: (cb: () => boolean) => void) => ResourceFiberRoot;
5
+ declare const commitRoot: (root: ResourceFiberRoot) => void;
6
+ declare const setRootVersion: (root: ResourceFiberRoot, version: number) => void;
7
+ declare const markCellDirty: (fiber: ResourceFiber<any, any>, cell: Cell & {
8
+ type: "reducer";
7
9
  }) => void;
10
+ //#endregion
11
+ export { commitRoot, createResourceFiberRoot, markCellDirty, setRootVersion };
8
12
  //# sourceMappingURL=root.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAiB;AAEvE,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,CAAC,EAAE,EAAE,MAAM,OAAO,KAAK,IAAI,KAC1C,iBAQF,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,iBAAiB,KAAG,IASpD,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,MAAM,iBAAiB,EACvB,SAAS,MAAM,KACd,IA4BF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9B,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,KAC/B,IAMF,CAAC"}
1
+ {"version":3,"file":"root.d.ts","names":[],"sources":["../../../src/core/helpers/root.ts"],"mappings":";;;cAEa,uBAAA,GACX,cAAA,GAAiB,EAAA,6BAChB,iBAQF;AAAA,cAEY,UAAA,GAAc,IAAuB,EAAjB,iBAAiB;AAAA,cAWrC,cAAA,GACX,IAAA,EAAM,iBAAiB,EACvB,OAAA;AAAA,cA+BW,aAAA,GACX,KAAA,EAAO,aAAA,YACP,IAAA,EAAM,IAAI;EAAK,IAAA;AAAA"}
@@ -1,53 +1,50 @@
1
- export const createResourceFiberRoot = (dispatchUpdate) => {
2
- return {
3
- version: 0,
4
- committedVersion: 0,
5
- dispatchUpdate,
6
- changelog: [],
7
- dirtyCells: [],
8
- };
1
+ //#region src/core/helpers/root.ts
2
+ const createResourceFiberRoot = (dispatchUpdate) => {
3
+ return {
4
+ version: 0,
5
+ committedVersion: 0,
6
+ dispatchUpdate,
7
+ changelog: [],
8
+ dirtyCells: []
9
+ };
9
10
  };
10
- export const commitRoot = (root) => {
11
- for (const cell of root.dirtyCells) {
12
- cell.dirty = false;
13
- cell.queue.clear();
14
- cell.current = cell.workInProgress;
15
- }
16
- root.committedVersion = root.version;
17
- root.changelog.length = 0;
18
- root.dirtyCells.length = 0;
11
+ const commitRoot = (root) => {
12
+ for (const cell of root.dirtyCells) {
13
+ cell.dirty = false;
14
+ cell.queue.clear();
15
+ cell.current = cell.workInProgress;
16
+ }
17
+ root.committedVersion = root.version;
18
+ root.changelog.length = 0;
19
+ root.dirtyCells.length = 0;
19
20
  };
20
- export const setRootVersion = (root, version) => {
21
- const rollback = root.version > version;
22
- root.version = version;
23
- if (rollback) {
24
- for (const cell of root.dirtyCells) {
25
- cell.dirty = false;
26
- cell.queue.clear();
27
- cell.workInProgress = cell.current;
28
- }
29
- root.dirtyCells.length = 0;
30
- if (version === root.committedVersion) {
31
- root.changelog.length = 0;
32
- }
33
- else {
34
- // commit happened without a useEffect update (offscreen API)
35
- if (root.committedVersion > version)
36
- throw new Error("Version is less than committed version");
37
- while (root.committedVersion + root.changelog.length > version) {
38
- root.changelog.pop();
39
- }
40
- // biome-ignore lint/suspicious/useIterableCallbackReturn: forEach callback intentionally has no return
41
- root.changelog.forEach((apply) => apply());
42
- commitRoot(root);
43
- }
44
- }
21
+ const setRootVersion = (root, version) => {
22
+ const rollback = root.version > version;
23
+ root.version = version;
24
+ if (rollback) {
25
+ for (const cell of root.dirtyCells) {
26
+ cell.dirty = false;
27
+ cell.queue.clear();
28
+ cell.workInProgress = cell.current;
29
+ }
30
+ root.dirtyCells.length = 0;
31
+ if (version === root.committedVersion) root.changelog.length = 0;
32
+ else {
33
+ if (root.committedVersion > version) throw new Error("Version is less than committed version");
34
+ while (root.committedVersion + root.changelog.length > version) root.changelog.pop();
35
+ root.changelog.forEach((apply) => apply());
36
+ commitRoot(root);
37
+ }
38
+ }
45
39
  };
46
- export const markCellDirty = (fiber, cell) => {
47
- if (!cell.dirty) {
48
- cell.dirty = true;
49
- fiber.markDirty?.();
50
- fiber.root.dirtyCells.push(cell);
51
- }
40
+ const markCellDirty = (fiber, cell) => {
41
+ if (!cell.dirty) {
42
+ cell.dirty = true;
43
+ fiber.markDirty?.();
44
+ fiber.root.dirtyCells.push(cell);
45
+ }
52
46
  };
47
+ //#endregion
48
+ export { commitRoot, createResourceFiberRoot, markCellDirty, setRootVersion };
49
+
53
50
  //# sourceMappingURL=root.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/core/helpers/root.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,cAA2C,EACxB,EAAE;IACrB,OAAO;QACL,OAAO,EAAE,CAAC;QACV,gBAAgB,EAAE,CAAC;QACnB,cAAc;QACd,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,EAAE;KACf,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAuB,EAAQ,EAAE;IAC1D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC;IACrC,CAAC;IACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAuB,EACvB,OAAe,EACT,EAAE;IACR,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACvB,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAE3B,IAAI,OAAO,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,6DAA6D;YAE7D,IAAI,IAAI,CAAC,gBAAgB,GAAG,OAAO;gBACjC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAE5D,OAAO,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;gBAC/D,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACvB,CAAC;YAED,uGAAuG;YACvG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;YAC3C,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAA8B,EAC9B,IAAgC,EAC1B,EAAE;IACR,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;AACH,CAAC,CAAC"}
1
+ {"version":3,"file":"root.js","names":[],"sources":["../../../src/core/helpers/root.ts"],"sourcesContent":["import type { Cell, ResourceFiber, ResourceFiberRoot } from \"../types\";\n\nexport const createResourceFiberRoot = (\n dispatchUpdate: (cb: () => boolean) => void,\n): ResourceFiberRoot => {\n return {\n version: 0,\n committedVersion: 0,\n dispatchUpdate,\n changelog: [],\n dirtyCells: [],\n };\n};\n\nexport const commitRoot = (root: ResourceFiberRoot): void => {\n for (const cell of root.dirtyCells) {\n cell.dirty = false;\n cell.queue.clear();\n cell.current = cell.workInProgress;\n }\n root.committedVersion = root.version;\n root.changelog.length = 0;\n root.dirtyCells.length = 0;\n};\n\nexport const setRootVersion = (\n root: ResourceFiberRoot,\n version: number,\n): void => {\n const rollback = root.version > version;\n root.version = version;\n if (rollback) {\n for (const cell of root.dirtyCells) {\n cell.dirty = false;\n cell.queue.clear();\n cell.workInProgress = cell.current;\n }\n root.dirtyCells.length = 0;\n\n if (version === root.committedVersion) {\n root.changelog.length = 0;\n } else {\n // commit happened without a useEffect update (offscreen API)\n\n if (root.committedVersion > version)\n throw new Error(\"Version is less than committed version\");\n\n while (root.committedVersion + root.changelog.length > version) {\n root.changelog.pop();\n }\n\n // biome-ignore lint/suspicious/useIterableCallbackReturn: forEach callback intentionally has no return\n root.changelog.forEach((apply) => apply());\n commitRoot(root);\n }\n }\n};\n\nexport const markCellDirty = (\n fiber: ResourceFiber<any, any>,\n cell: Cell & { type: \"reducer\" },\n): void => {\n if (!cell.dirty) {\n cell.dirty = true;\n fiber.markDirty?.();\n fiber.root.dirtyCells.push(cell);\n }\n};\n"],"mappings":";AAEA,MAAa,2BACX,mBACsB;CACtB,OAAO;EACL,SAAS;EACT,kBAAkB;EAClB;EACA,WAAW,CAAC;EACZ,YAAY,CAAC;CACf;AACF;AAEA,MAAa,cAAc,SAAkC;CAC3D,KAAK,MAAM,QAAQ,KAAK,YAAY;EAClC,KAAK,QAAQ;EACb,KAAK,MAAM,MAAM;EACjB,KAAK,UAAU,KAAK;CACtB;CACA,KAAK,mBAAmB,KAAK;CAC7B,KAAK,UAAU,SAAS;CACxB,KAAK,WAAW,SAAS;AAC3B;AAEA,MAAa,kBACX,MACA,YACS;CACT,MAAM,WAAW,KAAK,UAAU;CAChC,KAAK,UAAU;CACf,IAAI,UAAU;EACZ,KAAK,MAAM,QAAQ,KAAK,YAAY;GAClC,KAAK,QAAQ;GACb,KAAK,MAAM,MAAM;GACjB,KAAK,iBAAiB,KAAK;EAC7B;EACA,KAAK,WAAW,SAAS;EAEzB,IAAI,YAAY,KAAK,kBACnB,KAAK,UAAU,SAAS;OACnB;GAGL,IAAI,KAAK,mBAAmB,SAC1B,MAAM,IAAI,MAAM,wCAAwC;GAE1D,OAAO,KAAK,mBAAmB,KAAK,UAAU,SAAS,SACrD,KAAK,UAAU,IAAI;GAIrB,KAAK,UAAU,SAAS,UAAU,MAAM,CAAC;GACzC,WAAW,IAAI;EACjB;CACF;AACF;AAEA,MAAa,iBACX,OACA,SACS;CACT,IAAI,CAAC,KAAK,OAAO;EACf,KAAK,QAAQ;EACb,MAAM,YAAY;EAClB,MAAM,KAAK,WAAW,KAAK,IAAI;CACjC;AACF"}
@@ -1,5 +1,9 @@
1
- import type { ResourceElement } from "./types.js";
2
- export declare function resource<R>(fn: () => R): () => ResourceElement<R, undefined>;
3
- export declare function resource<R, P>(fn: (props: P) => R): (props: P) => ResourceElement<R, P>;
4
- export declare function resource<R, P>(fn: (props?: P) => R): (props?: P) => ResourceElement<R, P | undefined>;
1
+ import { ResourceElement } from "./types.js";
2
+
3
+ //#region src/core/resource.d.ts
4
+ declare function resource<R>(fn: () => R): () => ResourceElement<R, undefined>;
5
+ declare function resource<R, P>(fn: (props: P) => R): (props: P) => ResourceElement<R, P>;
6
+ declare function resource<R, P>(fn: (props?: P) => R): (props?: P) => ResourceElement<R, P | undefined>;
7
+ //#endregion
8
+ export { resource };
5
9
  //# sourceMappingURL=resource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/core/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAgB;AAG/C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,MAAM,eAAe,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAC9E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAClB,CAAC,KAAK,EAAE,CAAC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GACnB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"resource.d.ts","names":[],"sources":["../../src/core/resource.ts"],"mappings":";;;iBAGgB,QAAA,GAAA,CAAY,EAAA,QAAU,CAAA,SAAU,eAAA,CAAgB,CAAA;AAAA,iBAChD,QAAA,MAAA,CACd,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,CAAA,IAChB,KAAA,EAAO,CAAA,KAAM,eAAA,CAAgB,CAAA,EAAG,CAAA;AAAA,iBACpB,QAAA,MAAA,CACd,EAAA,GAAK,KAAA,GAAQ,CAAA,KAAM,CAAA,IACjB,KAAA,GAAQ,CAAA,KAAM,eAAA,CAAgB,CAAA,EAAG,CAAA"}
@@ -1,12 +1,16 @@
1
1
  import { fnSymbol } from "./helpers/callResourceFn.js";
2
- export function resource(fn) {
3
- const type = (props) => {
4
- return {
5
- type,
6
- props: props,
7
- };
8
- };
9
- type[fnSymbol] = fn;
10
- return type;
2
+ //#region src/core/resource.ts
3
+ function resource(fn) {
4
+ const type = (props) => {
5
+ return {
6
+ type,
7
+ props
8
+ };
9
+ };
10
+ type[fnSymbol] = fn;
11
+ return type;
11
12
  }
13
+ //#endregion
14
+ export { resource };
15
+
12
16
  //# sourceMappingURL=resource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/core/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AASpD,MAAM,UAAU,QAAQ,CAAmB,EAAmB;IAC5D,MAAM,IAAI,GAAG,CAAC,KAAS,EAAE,EAAE;QACzB,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,KAAM;SACkB,CAAC;IACpC,CAAC,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAEpB,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"resource.js","names":[],"sources":["../../src/core/resource.ts"],"sourcesContent":["import type { ResourceElement } from \"./types\";\nimport { fnSymbol } from \"./helpers/callResourceFn\";\n\nexport function resource<R>(fn: () => R): () => ResourceElement<R, undefined>;\nexport function resource<R, P>(\n fn: (props: P) => R,\n): (props: P) => ResourceElement<R, P>;\nexport function resource<R, P>(\n fn: (props?: P) => R,\n): (props?: P) => ResourceElement<R, P | undefined>;\nexport function resource<R, P = undefined>(fn: (props: P) => R) {\n const type = (props?: P) => {\n return {\n type,\n props: props!,\n } satisfies ResourceElement<R, P>;\n };\n\n type[fnSymbol] = fn;\n\n return type;\n}\n"],"mappings":";;AAUA,SAAgB,SAA2B,IAAqB;CAC9D,MAAM,QAAQ,UAAc;EAC1B,OAAO;GACL;GACO;EACT;CACF;CAEA,KAAK,YAAY;CAEjB,OAAO;AACT"}
@@ -1,12 +1,14 @@
1
+ //#region src/core/scheduler.d.ts
1
2
  type Task = () => void;
2
- export declare class UpdateScheduler {
3
- private readonly _task;
4
- private _isDirty;
5
- constructor(_task: Task);
6
- get isDirty(): boolean;
7
- markDirty(): void;
8
- runTask(): void;
3
+ declare class UpdateScheduler {
4
+ private readonly _task;
5
+ private _isDirty;
6
+ constructor(_task: Task);
7
+ get isDirty(): boolean;
8
+ markDirty(): void;
9
+ runTask(): void;
9
10
  }
10
- export declare const flushResourcesSync: <T>(callback: () => T) => T;
11
- export {};
11
+ declare const flushResourcesSync: <T>(callback: () => T) => T;
12
+ //#endregion
13
+ export { UpdateScheduler, flushResourcesSync };
12
14
  //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/core/scheduler.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;AAavB,qBAAa,eAAe;IAGd,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,QAAQ,CAAS;gBAEI,KAAK,EAAE,IAAI;IAExC,IAAI,OAAO,YAEV;IAED,SAAS;IAOT,OAAO;CAIR;AA6DD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,UAAU,MAAM,CAAC,KAAG,CAezD,CAAC"}
1
+ {"version":3,"file":"scheduler.d.ts","names":[],"sources":["../../src/core/scheduler.ts"],"mappings":";KAAK,IAAA;AAAA,cAaQ,eAAA;EAAA,iBAGkB,KAAA;EAAA,QAFrB,QAAA;cAEqB,KAAA,EAAO,IAAI;EAAA,IAEpC,OAAA,CAAA;EAIJ,SAAA,CAAA;EAOA,OAAA,CAAA;AAAA;AAAA,cAiEW,kBAAA,MAAyB,QAAA,QAAgB,CAAA,KAAI,CAezD"}