@headless-tree/core 0.0.0-20250918201417 → 0.0.0-20250921145249

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @headless-tree/core
2
2
 
3
- ## 0.0.0-20250918201417
3
+ ## 0.0.0-20250921145249
4
4
 
5
5
  ### Minor Changes
6
6
 
package/dist/index.js CHANGED
@@ -546,8 +546,8 @@ var createTree = (initialConfig) => {
546
546
  },
547
547
  setMounted: ({}, isMounted) => {
548
548
  var _a2;
549
- const ref = treeDataRef;
550
- treeDataRef.current.isMounted = isMounted;
549
+ const ref = treeDataRef.current;
550
+ ref.isMounted = isMounted;
551
551
  if (isMounted) {
552
552
  (_a2 = ref.waitingForMount) == null ? void 0 : _a2.forEach((cb) => cb());
553
553
  ref.waitingForMount = [];
@@ -570,9 +570,19 @@ var createTree = (initialConfig) => {
570
570
  },
571
571
  // TODO rebuildSubTree: (itemId: string) => void;
572
572
  rebuildTree: () => {
573
- var _a2;
574
- rebuildItemMeta();
575
- (_a2 = config.setState) == null ? void 0 : _a2.call(config, state);
573
+ var _a2, _b2;
574
+ const ref = treeDataRef.current;
575
+ if (ref.isMounted) {
576
+ rebuildItemMeta();
577
+ (_a2 = config.setState) == null ? void 0 : _a2.call(config, state);
578
+ } else {
579
+ (_b2 = ref.waitingForMount) != null ? _b2 : ref.waitingForMount = [];
580
+ ref.waitingForMount.push(() => {
581
+ var _a3;
582
+ rebuildItemMeta();
583
+ (_a3 = config.setState) == null ? void 0 : _a3.call(config, state);
584
+ });
585
+ }
576
586
  },
577
587
  scheduleRebuildTree: () => {
578
588
  rebuildScheduled = true;
package/dist/index.mjs CHANGED
@@ -502,8 +502,8 @@ var createTree = (initialConfig) => {
502
502
  },
503
503
  setMounted: ({}, isMounted) => {
504
504
  var _a2;
505
- const ref = treeDataRef;
506
- treeDataRef.current.isMounted = isMounted;
505
+ const ref = treeDataRef.current;
506
+ ref.isMounted = isMounted;
507
507
  if (isMounted) {
508
508
  (_a2 = ref.waitingForMount) == null ? void 0 : _a2.forEach((cb) => cb());
509
509
  ref.waitingForMount = [];
@@ -526,9 +526,19 @@ var createTree = (initialConfig) => {
526
526
  },
527
527
  // TODO rebuildSubTree: (itemId: string) => void;
528
528
  rebuildTree: () => {
529
- var _a2;
530
- rebuildItemMeta();
531
- (_a2 = config.setState) == null ? void 0 : _a2.call(config, state);
529
+ var _a2, _b2;
530
+ const ref = treeDataRef.current;
531
+ if (ref.isMounted) {
532
+ rebuildItemMeta();
533
+ (_a2 = config.setState) == null ? void 0 : _a2.call(config, state);
534
+ } else {
535
+ (_b2 = ref.waitingForMount) != null ? _b2 : ref.waitingForMount = [];
536
+ ref.waitingForMount.push(() => {
537
+ var _a3;
538
+ rebuildItemMeta();
539
+ (_a3 = config.setState) == null ? void 0 : _a3.call(config, state);
540
+ });
541
+ }
532
542
  },
533
543
  scheduleRebuildTree: () => {
534
544
  rebuildScheduled = true;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "checkbox",
14
14
  "hook"
15
15
  ],
16
- "version": "0.0.0-20250918201417",
16
+ "version": "0.0.0-20250921145249",
17
17
  "main": "dist/index.d.ts",
18
18
  "module": "dist/index.mjs",
19
19
  "types": "dist/index.d.mts",
@@ -163,8 +163,8 @@ export const createTree = <T>(
163
163
  // TODO this is never used, remove
164
164
  },
165
165
  setMounted: ({}, isMounted) => {
166
- const ref = treeDataRef as TreeDataRef;
167
- treeDataRef.current.isMounted = isMounted;
166
+ const ref = treeDataRef.current as TreeDataRef;
167
+ ref.isMounted = isMounted;
168
168
  if (isMounted) {
169
169
  ref.waitingForMount?.forEach((cb) => cb());
170
170
  ref.waitingForMount = [];
@@ -193,8 +193,17 @@ export const createTree = <T>(
193
193
  },
194
194
  // TODO rebuildSubTree: (itemId: string) => void;
195
195
  rebuildTree: () => {
196
- rebuildItemMeta();
197
- config.setState?.(state);
196
+ const ref = treeDataRef.current as TreeDataRef;
197
+ if (ref.isMounted) {
198
+ rebuildItemMeta();
199
+ config.setState?.(state);
200
+ } else {
201
+ ref.waitingForMount ??= [];
202
+ ref.waitingForMount.push(() => {
203
+ rebuildItemMeta();
204
+ config.setState?.(state);
205
+ });
206
+ }
198
207
  },
199
208
  scheduleRebuildTree: () => {
200
209
  rebuildScheduled = true;