@aiquants/virtualscroll 1.18.0 → 1.18.3

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 (56) hide show
  1. package/README.md +85 -16
  2. package/dist/ScrollBar.d.cts +100 -0
  3. package/dist/ScrollBar.d.ts.map +1 -0
  4. package/dist/ScrollPane.d.cts +93 -0
  5. package/dist/ScrollPane.d.ts.map +1 -0
  6. package/dist/TapScrollCircle.d.cts +62 -0
  7. package/dist/TapScrollCircle.d.ts.map +1 -0
  8. package/dist/VirtualScroll.d.cts +155 -0
  9. package/dist/{src/VirtualScroll.d.ts → VirtualScroll.d.ts} +46 -3
  10. package/dist/VirtualScroll.d.ts.map +1 -0
  11. package/dist/cli.js +97 -24
  12. package/dist/cli.server.d.cts +13 -0
  13. package/dist/cli.server.d.ts +14 -0
  14. package/dist/cli.server.d.ts.map +1 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/{src/index.d.ts → index.d.cts} +9 -10
  17. package/dist/index.d.ts +10 -2
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +1862 -1352
  20. package/dist/{src/logger.d.ts → logger.d.cts} +48 -1
  21. package/dist/logger.d.ts +146 -0
  22. package/dist/logger.d.ts.map +1 -0
  23. package/dist/tapScrollCircleSampleVisual.d.cts +2 -0
  24. package/dist/tapScrollCircleSampleVisual.d.ts.map +1 -0
  25. package/dist/{src/useFenwickMapTree.d.ts → useFenwickMapTree.d.cts} +138 -16
  26. package/dist/useFenwickMapTree.d.ts +451 -0
  27. package/dist/useFenwickMapTree.d.ts.map +1 -0
  28. package/dist/useHeightCache.d.cts +15 -0
  29. package/dist/useHeightCache.d.ts.map +1 -0
  30. package/dist/{src/useLruCache.d.ts → useLruCache.d.cts} +8 -2
  31. package/dist/useLruCache.d.ts +24 -0
  32. package/dist/useLruCache.d.ts.map +1 -0
  33. package/dist/{src/utils.d.ts → utils.d.cts} +3 -1
  34. package/dist/utils.d.ts +15 -0
  35. package/dist/{src/utils.d.ts.map → utils.d.ts.map} +1 -1
  36. package/package.json +12 -6
  37. package/dist/src/ScrollBar.d.ts.map +0 -1
  38. package/dist/src/ScrollPane.d.ts.map +0 -1
  39. package/dist/src/TapScrollCircle.d.ts.map +0 -1
  40. package/dist/src/VirtualScroll.d.ts.map +0 -1
  41. package/dist/src/cli.server.d.ts +0 -2
  42. package/dist/src/cli.server.d.ts.map +0 -1
  43. package/dist/src/index.d.ts.map +0 -1
  44. package/dist/src/logger.d.ts.map +0 -1
  45. package/dist/src/tapScrollCircleSampleVisual.d.ts.map +0 -1
  46. package/dist/src/useFenwickMapTree.d.ts.map +0 -1
  47. package/dist/src/useHeightCache.d.ts.map +0 -1
  48. package/dist/src/useLruCache.d.ts.map +0 -1
  49. package/dist/virtualscroll.css +0 -1
  50. package/dist/vite.config.d.ts +0 -3
  51. package/dist/vite.config.d.ts.map +0 -1
  52. /package/dist/{src/ScrollBar.d.ts → ScrollBar.d.ts} +0 -0
  53. /package/dist/{src/ScrollPane.d.ts → ScrollPane.d.ts} +0 -0
  54. /package/dist/{src/TapScrollCircle.d.ts → TapScrollCircle.d.ts} +0 -0
  55. /package/dist/{src/tapScrollCircleSampleVisual.d.ts → tapScrollCircleSampleVisual.d.ts} +0 -0
  56. /package/dist/{src/useHeightCache.d.ts → useHeightCache.d.ts} +0 -0
@@ -0,0 +1,451 @@
1
+ type MaterializeRange = {
2
+ from: number;
3
+ to: number;
4
+ };
5
+ type MaterializeOption = {
6
+ materialize: boolean;
7
+ ranges?: MaterializeRange[];
8
+ };
9
+ type MaterializeConfig = {
10
+ materializeOption?: MaterializeOption;
11
+ };
12
+ type DeltaUpdate = {
13
+ index: number;
14
+ change: number;
15
+ };
16
+ type ValueUpdate = {
17
+ index: number;
18
+ value: number;
19
+ };
20
+ /**
21
+ * @class FenwickTree
22
+ * @classdesc Implements a Fenwick Tree (or Binary Indexed Tree).
23
+ * This data structure efficiently calculates prefix sums and performs updates in logarithmic time.
24
+ * It is particularly useful for virtual scrolling, where it can manage the offsets of variably sized items.
25
+ *
26
+ * @classdesc Fenwick Tree (バイナリインデックスツリー) の実装。
27
+ * このデータ構造は、接頭辞和の計算と更新を対数時間で効率的に実行。
28
+ * 可変サイズのアイテムのオフセットを管理できるため、特に仮想スクロールで有用。
29
+ *
30
+ * @remarks Memory: exact offsets are the design priority, so every materialized/updated row keeps
31
+ * an entry in `tree` and `deltas`. Memory therefore grows with the number of materialized elements,
32
+ * not with `size`. Rows equal to `baseValue` are pruned (zero-delta), but there is no eviction of
33
+ * measured deltas — evicting one would silently snap that row back to the estimated `baseValue` and
34
+ * corrupt `total`, which is incompatible with the exact-offset guarantee. If a hard memory ceiling
35
+ * is required, discard off-screen measured heights in the consumer layer (e.g. an LRU height cache)
36
+ * and let those rows fall back to the estimate there, rather than inside this tree.
37
+ * @remarks メモリ: 厳密オフセットを設計上の最優先とするため、具現化/更新された行はすべて `tree` と
38
+ * `deltas` にエントリを保持する。よってメモリは `size` ではなく具現化済み要素数に比例して増える。
39
+ * `baseValue` と一致する行は zero-delta 枝刈りされるが、計測済み delta の evict は行わない。evict すると
40
+ * その行が黙って推定値 `baseValue` へ戻り `total` が破損し、厳密オフセット保証と両立しないためである。
41
+ * ハードなメモリ上限が必要な場合は、この木の内部ではなく消費側 (LRU 高さキャッシュ等) で可視域外の
42
+ * 実測値を破棄し、そこで既定推定へ委ねる設計とすること。
43
+ */
44
+ export declare class FenwickMapTree {
45
+ /**
46
+ * @private
47
+ * @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
48
+ * @property {Map<number, number>} tree - Fenwick Tree 構造を格納する Map。特に差分の合計を保持する。1-indexed。
49
+ */
50
+ private tree;
51
+ /**
52
+ * @private
53
+ * @property {Map<number, number>} deltas - The Map storing the differences (deltas) from the base value at each index.
54
+ * @property {Map<number, number>} deltas - 各インデックスにおける基準値との差分 (delta) を格納する Map。
55
+ */
56
+ private deltas;
57
+ /**
58
+ * @private
59
+ * @property {number} size - The number of elements the tree manages.
60
+ * @property {number} size - ツリーが管理する要素数。
61
+ */
62
+ private size;
63
+ /**
64
+ * @private
65
+ * @property {number} baseValue - The uniform base value for all elements, used to optimize memory.
66
+ * @property {number} baseValue - 全要素の均一な基準値。メモリ最適化のために使用。
67
+ */
68
+ private baseValue;
69
+ /**
70
+ * @private
71
+ * @property {((index: number) => number) | undefined} valueFn - A function to generate values, stored for lazy initialization.
72
+ * @property {((index: number) => number) | undefined} valueFn - 値を生成するための関数。遅延初期化のために保存される。
73
+ */
74
+ private valueFn?;
75
+ private total?;
76
+ /**
77
+ * @constructor
78
+ * @description Initializes the Fenwick Tree.
79
+ * @description Fenwick Tree の初期化。
80
+ * @param {number} size - The total number of items.
81
+ * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
82
+ * @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
83
+ */
84
+ constructor(size: number, valueOrFn: number | ((index: number) => number), options?: {
85
+ sampleRange?: {
86
+ from: number;
87
+ to: number;
88
+ };
89
+ materialize?: boolean;
90
+ });
91
+ /**
92
+ * @method reset
93
+ * @description Resets the Fenwick Tree with a new size and initial values. The size is
94
+ * normalized on entry (non-finite/negative sizes collapse to 0, fractions are truncated).
95
+ * When `valueOrFn` is a function, all sampling/materialization values are computed and
96
+ * validated (finite-only) before the tree state is mutated, so a `valueFn` returning
97
+ * NaN/Infinity throws while leaving the previous tree state intact instead of a half-built one.
98
+ * @description Fenwick Tree を新しいサイズと初期値でリセット。size は入口で正規化する
99
+ * (非有限/負は 0 に縮退、小数は切り捨て)。`valueOrFn` が関数の場合、サンプリング/具現化の値は
100
+ * 木の状態を変異させる前に計算・検証 (有限数のみ) するため、NaN/Infinity を返す `valueFn` は
101
+ * throw しつつ木を半構築で残さず直前の状態を無傷に保つ方針。
102
+ * @param {number} size - The total number of items.
103
+ * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
104
+ * @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
105
+ */
106
+ reset(size: number, valueOrFn: number | ((index: number) => number), options?: {
107
+ sampleRange?: {
108
+ from: number;
109
+ to: number;
110
+ };
111
+ materialize?: boolean;
112
+ }): void;
113
+ /**
114
+ * @method setValueFn
115
+ * @description Updates the value function and re-initializes the tree.
116
+ * @description 値関数を更新し、ツリーを再初期化する。
117
+ * @param {number | ((index: number) => number)} valueOrFn - The new value for all elements, or a function to generate values.
118
+ * @param {{ reset?: boolean }} [options] - Optional settings. If reset is true, the tree is reset with the new value function.
119
+ */
120
+ setValueFn(valueOrFn: number | ((index: number) => number), options?: {
121
+ reset?: boolean;
122
+ }): void;
123
+ /**
124
+ * @private
125
+ * @method _collectValidatedValues
126
+ * @description Evaluates `valueFn` over the inclusive `[from, to]` range and returns the values, throwing on any non-finite result. Validation happens here, before any tree mutation, so a poisoned `valueFn` can never leave the tree half-built.
127
+ * @description `valueFn` を閉区間 `[from, to]` で評価して値配列を返す。非有限値は throw で拒否。検証を木の変異前 (このメソッド内) で行うことで、汚染された `valueFn` が木を半構築のまま残す事態の防止。
128
+ * @param {(index: number) => number} valueFn - The value-generating function to evaluate.
129
+ * @param {number} from - The starting index of the range (inclusive).
130
+ * @param {number} to - The ending index of the range (inclusive).
131
+ * @returns {number[]} The validated (finite-only) values in index order.
132
+ */
133
+ private static _collectValidatedValues;
134
+ /**
135
+ * @private
136
+ * @method _modeOrMedian
137
+ * @description Reduces a sample of generated values to a single representative height: the mode when it is frequent enough to be trustworthy, otherwise the median. A value is only accepted as the mode when its frequency exceeds 20% of the sample; this prevents periodic or near-uniform data (where sampling bias can make an arbitrary value momentarily frequent) from picking an unrepresentative base. Multiple co-modes are averaged.
138
+ * @description サンプル値を 1 つの代表的な高さへ縮約する。信頼できるほど頻出する場合は最頻値を、そうでなければ中央値を返す。最頻値はサンプルの 20% を超える頻度のときのみ採用し、周期的/ほぼ一様なデータ (サンプリング偏りで任意の値が一時的に頻出しうる) が非代表値を選ぶのを防ぐ。同率最頻値が複数ある場合は平均する。
139
+ * @param {number[]} values - The sampled values (mutated in place by sorting).
140
+ * @returns {number} The representative base value.
141
+ */
142
+ private static _modeOrMedian;
143
+ /**
144
+ * @private
145
+ * @method _sampleBaseValueStrided
146
+ * @description Estimates `baseValue` by evaluating `valueFn` at up to `sampleCount` points spread across the entire `[0, size-1]` range, then reducing them via `_modeOrMedian`. Spanning the whole list (rather than a fixed head window) makes the majority height win even when the first items are atypical (hero/heading rows). The stride uses `ceil(size / sampleCount)` so the samples always span the whole range — `floor` would collapse to stride 1 for `sampleCount < size < 2 * sampleCount` and only ever look at the head. The stride is also forced odd to avoid aliasing against common even-period layouts (e.g. alternating or 20-row cycles), which a stride that shares a factor with the period would otherwise collapse into a single residue. For a uniform list every sample is identical, so the estimate is unchanged. Non-finite sample values throw before any state is touched.
147
+ * @description `valueFn` を `[0, size-1]` 全域に散らした最大 `sampleCount` 点で評価し、`_modeOrMedian` で縮約して `baseValue` を推定する。先頭固定ウィンドウではなくリスト全体を跨ぐことで、先頭が非典型 (ヒーロー/見出し行) でも多数派の高さが選ばれる。ストライドは `ceil(size / sampleCount)` を用いて常に全域を跨がせる (`floor` だと `sampleCount < size < 2 * sampleCount` で stride=1 に潰れ先頭しか見ない盲点が生じる)。さらに奇数へ強制し、周期と公約数を持つストライドがサンプルを 1 剰余類へ潰してしまう周期レイアウト (交互・20行周期など) とのエイリアシングを避ける。一様リストでは全サンプルが同一なので推定値は不変。非有限のサンプル値は状態を変異させる前に throw で拒否。
148
+ * @param {(index: number) => number} valueFn - The value-generating function to sample.
149
+ * @param {number} size - The total number of items the tree will manage.
150
+ * @param {number} sampleCount - Maximum number of points to evaluate.
151
+ * @returns {number} The estimated base value.
152
+ */
153
+ private static _sampleBaseValueStrided;
154
+ /**
155
+ * @method update
156
+ * @description Updates the value at a given index.
157
+ * @description 指定されたインデックスの値を更新。
158
+ * @param {number} index - The 0-based index to update.
159
+ * @param {number} value - The new value.
160
+ */
161
+ update(index: number, value: number): number | undefined;
162
+ /**
163
+ * @method updates
164
+ * @description Updates the values at given indices.
165
+ * @description 指定されたインデックスの値を更新。
166
+ * @param {ValueUpdate[]} updates - An array of updates, each with an index and the new value.
167
+ */
168
+ updates(updates: ValueUpdate[]): number | undefined;
169
+ /**
170
+ * @method updateDelta
171
+ * @description Updates the delta at a given index and propagates the change through the tree. A change that would make the effective value (`baseValue` + delta) negative is rejected with an error, mirroring the negative-value rejection of `update`/`updates`.
172
+ * @description 指定されたインデックスのデルタを更新し、変更をツリーに伝播させる。適用後の実効値 (`baseValue` + delta) が負になる変更は `update`/`updates` の負値拒否と対称に throw で拒否する方針。
173
+ * @param {number} index - The 0-based index to update.
174
+ * @param {number} change - The value to add to the delta at the given index.
175
+ */
176
+ updateDelta(index: number, change: number): number | undefined;
177
+ /**
178
+ * @method updateDeltas
179
+ * @description Updates the deltas at given indices and propagates the changes through the tree. All entries are validated up front (atomicity): out-of-range or non-integer indices, non-finite changes, and changes whose resulting effective value (`baseValue` + delta) would turn negative are rejected with an error before anything is applied. Negative effective values would break the monotonic prefix sums that `_descend`/`_findIndexLarge` rely on.
180
+ * @description 指定されたインデックスのデルタを更新し、変更をツリーに伝播させる。全件を先に検証してから適用する (アトミック性): 範囲外/非整数の index、非有限の change、適用後の実効値 (`baseValue` + delta) が負になる変更はいずれも適用前に throw で拒否。負の実効値は `_descend`/`_findIndexLarge` が前提とする累積和の単調性を破壊するため。
181
+ * @param {DeltaUpdate[]} updates - An array of updates, each with an index and the change to apply.
182
+ */
183
+ updateDeltas(updates: DeltaUpdate[]): number | undefined;
184
+ /**
185
+ * @private
186
+ * @method _updateTree
187
+ * @description Updates the Fenwick tree and the total sum with a given change.
188
+ * @description Fenwick Tree と合計値を指定された変更で更新する。
189
+ * @param {number} index - The 0-based index that changed.
190
+ * @param {number} change - The change in value.
191
+ */
192
+ private _updateTree;
193
+ /**
194
+ * @private
195
+ * @method _buildDeltaUpdates
196
+ * @description Converts value updates into delta updates while preserving validation logic.
197
+ * @description 値更新入力を検証しつつデルタ更新へ変換する。
198
+ * @param {ValueUpdate[]} updates - Requested value updates.
199
+ * @returns {DeltaUpdate[]} Sanitized delta updates ready to apply.
200
+ */
201
+ private _buildDeltaUpdates;
202
+ /**
203
+ * @private
204
+ * @method _computeTreeTotal
205
+ * @description Calculates the total height represented by the current Fenwick tree structure, reproducing the same traversal used by `prefixSum` at the last index to avoid floating-point drift.
206
+ * @description Fenwick 木が保持する合計値を算出する。末尾インデックスでの `prefixSum` と同一の走査手順を再現し、浮動小数点の誤差を防ぐ。
207
+ * @returns {number} The total height encoded in the Fenwick tree.
208
+ */
209
+ private _computeTreeTotal;
210
+ /**
211
+ * @private
212
+ * @method _materialize
213
+ * @description Materializes the value at a specific index if it hasn't been already. A non-finite `valueFn` result throws before any mutation, symmetric with the update-path validation, so the tree is never poisoned.
214
+ * @description 特定のインデックスの値がまだ具現化されていない場合に具現化する。`valueFn` の非有限な返値は変異前に throw で拒否 (update 系の検証と対称) し、木を汚染させない方針。
215
+ * @param {number} index - The 0-based index to materialize.
216
+ * @param {boolean} [updateTree=true] - Whether to update the Fenwick tree after materialization.
217
+ */
218
+ private _materialize;
219
+ /**
220
+ * @private
221
+ * @method _materializeRanges
222
+ * @description Materializes values for provided ranges and optionally a target index, keeping existing semantics for each caller.
223
+ * @description 指定された範囲とターゲットインデックスを既存仕様通りに具現化する。
224
+ * @param {MaterializeOption | undefined} option - Materialization option wrapper.
225
+ * @param {number | undefined} index - Target index for materialization.
226
+ * @param {boolean} [forceIndex=false] - When true, materializes the index even if it is outside the provided ranges.
227
+ */
228
+ private _materializeRanges;
229
+ /**
230
+ * @private
231
+ * @method _findIndex
232
+ * @description Executes a binary search over prefix sums to find the first index satisfying a boundary condition.
233
+ * @description 累積和に対する二分探索を行い、境界条件を満たす最初のインデックスを求める。
234
+ * @param {number} target - Target cumulative value.
235
+ * @param {MaterializeConfig} options - Materialization setting wrapper.
236
+ * @param {boolean} chooseLowerBound - When true, finds the smallest index meeting or exceeding the target; otherwise finds the largest index not exceeding it.
237
+ * @returns {{ index: number; total: number | undefined; cumulative: number | undefined; currentValue: number | undefined; safeIndex: number | undefined }} Binary search result.
238
+ */
239
+ private _findIndex;
240
+ /**
241
+ * @private
242
+ * @method _descend
243
+ * @description Performs a single bitwise descent over the current tree state, returning the candidate index for the boundary condition without mutating the tree.
244
+ * @description 現在の木の状態に対してビット降下を 1 回実行し、木を変異させずに境界条件の候補インデックスを返す。
245
+ * @param {number} target - Target cumulative value.
246
+ * @param {boolean} chooseLowerBound - When true, finds the smallest index meeting or exceeding the target; otherwise finds the largest index not exceeding it.
247
+ * @returns {number} The candidate index (may be out of range when no index satisfies the condition).
248
+ */
249
+ private _descend;
250
+ /**
251
+ * Executes a binary search using bigint arithmetic for extremely large sizes.
252
+ *
253
+ * 非常に大きなサイズに対して bigint 演算を用いた二分探索を実施。
254
+ */
255
+ private _findIndexLarge;
256
+ /**
257
+ * @method prefixSum
258
+ * @description Calculates the cumulative sum up to a given index (inclusive) in O(log n) time.
259
+ * @description 指定されたインデックスまでの累積和を O(log n) で計算。
260
+ * @param {number} index - The 0-based index to prefixSum up to.
261
+ * @param {MaterializeConfig} [options] - Optional settings for materializing values.
262
+ * @returns {{ cumulative: number; total: number | undefined; currentValue: number; safeIndex: number }} The cumulative sum of values from index 0 to the given index, the total sum, and the value at the given index.
263
+ */
264
+ prefixSum(index: number, options?: MaterializeConfig): {
265
+ cumulative: number;
266
+ total: number | undefined;
267
+ currentValue: number;
268
+ safeIndex: number;
269
+ };
270
+ /**
271
+ * @method get
272
+ * @description Gets the value at a specific index.
273
+ * @description 特定のインデックスの値を取得。
274
+ * @param {number} index - The 0-based index to get.
275
+ * @param {MaterializeConfig} [options] - Optional settings for materializing values.
276
+ * @returns {number} The value at the given index.
277
+ */
278
+ get(index: number, options?: MaterializeConfig): number;
279
+ /**
280
+ * @method getTotal
281
+ * @description Gets the total sum of all values in the tree.
282
+ * @description ツリー内のすべての値の合計を取得。
283
+ * @param {MaterializeConfig} [options] - Optional settings for materializing values.
284
+ * @returns {number} The total sum of all values.
285
+ */
286
+ getTotal(options?: MaterializeConfig): number;
287
+ /**
288
+ * @method rebuildTree
289
+ * @description Rebuilds the Fenwick Tree from the existing `baseValue` and `deltas`. This corrects any discrepancies in the tree's internal state, such as those caused by floating-point errors, by recalculating the tree structure and the total sum from the source `deltas`. This method does not re-materialize values from `valueFn`.
290
+ * @description 既存の `baseValue` と `deltas` から Fenwick Tree を再構築します。これにより、`deltas` からツリー構造と合計値を再計算することで、浮動小数点誤差などによって生じた内部状態の不一致を修正します。このメソッドは `valueFn` から値を再具現化しません。
291
+ * @param {object} [options] - Optional settings for rebuilding.
292
+ * @param {boolean} [options.materialize=false] - If true and `valueFn` is provided, re-materializes all values, recalculating `deltas` and `baseValue`.
293
+ */
294
+ rebuildTree(options?: {
295
+ materialize?: boolean;
296
+ }): void;
297
+ /**
298
+ * @method calculateAccumulatedError
299
+ * @description Compares the cached total sum with a theoretical total calculated directly from the source values (`deltas` and `baseValue`, or `valueFn`). This helps detect any discrepancy in the tree's cached state, which might be caused by floating-point errors or other inconsistencies.
300
+ * @description キャッシュされている合計値と、元の値 (`deltas` と `baseValue`、または `valueFn`) から直接計算した理論上の合計値とを比較します。これにより、浮動小数点数の累積誤差やその他の不整合によって生じる可能性のある、ツリーのキャッシュ状態の不一致を検出できます。
301
+ * @returns {number} The difference between the cached total and the theoretical total.
302
+ */
303
+ calculateAccumulatedError(): number;
304
+ /**
305
+ * @method changeSize
306
+ * @description Changes the size of the Fenwick Tree. Only tail growth/shrink is modelled: this
307
+ * method receives a size delta, not an index mapping, so it assumes items are appended to or
308
+ * removed from the tail. Existing rows keep their index-to-height association. It therefore
309
+ * cannot represent a middle insertion/deletion — after such a structural change the index↔height
310
+ * mapping is no longer preserved and the tree's deltas would apply to the wrong rows. Consumers
311
+ * that insert or remove items in the middle must instead reset the tree (see
312
+ * `useFenwickMapTree`'s `resetOnValueFnChange`, surfaced as `resetOnGetItemHeightChange` in
313
+ * VirtualScroll) or remount the component with a new `key`.
314
+ * @description Fenwick Tree のサイズを変更する。モデル化するのは末尾の伸長/縮小のみ: 本メソッドは
315
+ * サイズ差分のみを受け取りインデックスの対応表は受け取らないため、要素は末尾に追加/末尾から削除
316
+ * されると仮定する。既存行は index↔高さ の対応を保つ。したがって中間挿入/削除は表現できず、その
317
+ * ような構造変更の後は index↔高さ の対応が保存されず、木の delta が誤った行へ適用されてしまう。
318
+ * 中間で要素を挿入/削除する消費側は、代わりに木をリセットするか (`useFenwickMapTree` の
319
+ * `resetOnValueFnChange`。VirtualScroll では `resetOnGetItemHeightChange` として公開) 、新しい
320
+ * `key` でコンポーネントを再マウントすること。
321
+ * @remarks Validation: a non-finite `newSize` (NaN/Infinity) throws because it would poison
322
+ * `size`/`total` irrecoverably. Fractional sizes are truncated and negative sizes collapse to 0,
323
+ * matching the normalization rule of `reset`.
324
+ * @remarks 検証: 非有限の `newSize` (NaN/Infinity) は `size`/`total` を復旧不能に汚染するため
325
+ * throw。小数は切り捨て、負値は 0 に縮退 (`reset` の正規化規則と同一)。
326
+ * @param {number} newSize - The new size of the tree.
327
+ */
328
+ changeSize(newSize: number): void;
329
+ /**
330
+ * @private
331
+ * @method _minCoveredLowBound
332
+ * @description Computes `min(t - lowestSetBit(t))` over the newly-activated node range `t in (oldSize, newSize]`. Any delta whose 1-based tree index is at or below this bound cannot be covered by any newly-activated node and can be skipped during an incremental grow.
333
+ * @description 新規有効化ノード範囲 `t in (oldSize, newSize]` にわたる `min(t - lowestSetBit(t))` を算出する。1 始まりの木インデックスがこの下限以下の delta はどの新規ノードにも覆われないため、増分伸長時にスキップできる。
334
+ * @param {number} oldSize - The previous size (exclusive lower bound of the new node range).
335
+ * @param {number} newSize - The new size (inclusive upper bound of the new node range).
336
+ * @returns {number} The minimum left boundary `t - lowestSetBit(t)` of the newly-activated nodes.
337
+ */
338
+ private static _minCoveredLowBound;
339
+ /**
340
+ * @private
341
+ * @method _propagateDeltaToGrownNodes
342
+ * @description Propagates a single delta into the tree nodes newly activated by a tail growth, i.e. parent-chain nodes in `(oldSize, newSize]`.
343
+ * @description 末尾伸長で新規有効化されたノード ((oldSize, newSize] にある親チェーンノード) へ単一 delta を伝播する。
344
+ * @param {number} index - The 0-based delta index.
345
+ * @param {number} delta - The delta value to propagate.
346
+ * @param {number} oldSize - The previous size.
347
+ * @param {number} newSize - The new (larger) size.
348
+ */
349
+ private _propagateDeltaToGrownNodes;
350
+ /**
351
+ * @private
352
+ * @method _growSize
353
+ * @description Extends the tree to a larger size incrementally, propagating existing deltas into newly-activated higher-order tree nodes only. Candidate deltas are narrowed via `_minCoveredLowBound`, so a typical `+1` tail append costs amortized O(log n) instead of O(D log n) (D = number of materialized deltas).
354
+ * @description ツリーを末尾方向に増分的に拡張する。既存 delta を新たに有効化された上位ノードにのみ伝播する。候補 delta は `_minCoveredLowBound` で絞り込むため、通常の +1 末尾追記は O(D log n) (D = 具現化済み delta 数) ではなく償却 O(log n) で済む。
355
+ * @param {number} oldSize - The previous size.
356
+ * @param {number} newSize - The new (larger) size.
357
+ */
358
+ private _growSize;
359
+ /**
360
+ * @method getSize
361
+ * @description Gets the size of the tree.
362
+ * @description ツリーのサイズを取得。
363
+ * @returns {number} The total number of items.
364
+ */
365
+ getSize(): number;
366
+ /**
367
+ * @method findIndexAtOrAfter
368
+ * @description Finds the first index where the cumulative sum is greater than or equal to a target value.
369
+ * @description 累積和がターゲット値以上になる最初のインデックスを検索。
370
+ * @param {number} target - The target cumulative sum.
371
+ * @param {MaterializeConfig} [options] - Optional settings for materializing values.
372
+ * @param {MaterializeOption} [options.materializeOption] - Options to control materialization.
373
+ * @param {boolean} [options.materializeOption.materialize=false] - Whether to materialize values.
374
+ * @param {MaterializeRange[]} [options.materializeOption.ranges] - Optional ranges for eager materialization.
375
+ * @returns {{ index: number, total: number | undefined, cumulative: number | undefined, currentValue: number | undefined, safeIndex: number | undefined }} The 0-based index and the total sum, or -1 if not found.
376
+ */
377
+ findIndexAtOrAfter(target: number, options?: MaterializeConfig): {
378
+ index: number;
379
+ total: number | undefined;
380
+ cumulative: number | undefined;
381
+ currentValue: number | undefined;
382
+ safeIndex: number | undefined;
383
+ };
384
+ /**
385
+ * @method findIndexAtOrBefore
386
+ * @description Finds the last index where the cumulative sum is less than or equal to a target value.
387
+ * @description 累積和がターゲット値以下になる最後のインデックスを検索。
388
+ * @param {number} target - The target cumulative sum.
389
+ * @param {MaterializeConfig} [options] - Optional settings for materializing values.
390
+ * @param {MaterializeOption} [options.materializeOption] - Options to control materialization。
391
+ * @param {boolean} [options.materializeOption.materialize=false] - Whether to materialize values。
392
+ * @param {MaterializeRange[]} [options.materializeOption.ranges] - Optional ranges for eager materialization。
393
+ * @returns {{ index: number, total: number | undefined, cumulative: number | undefined, currentValue: number | undefined, safeIndex: number | undefined }} The 0-based index and the total sum, or -1 if not found.
394
+ */
395
+ findIndexAtOrBefore(target: number, options?: MaterializeConfig): {
396
+ index: number;
397
+ total: number | undefined;
398
+ cumulative: number | undefined;
399
+ currentValue: number | undefined;
400
+ safeIndex: number | undefined;
401
+ };
402
+ }
403
+ /**
404
+ * @hook useFenwickMapTree
405
+ * @description A React hook that creates and manages a `FenwickMapTree` instance.
406
+ * The tree instance is stable across re-renders. A new tree instance is created
407
+ * if `size` or `valueOrFn` changes.
408
+ * @description `FenwickMapTree` インスタンスを作成・管理する React フック。
409
+ * ツリーインスタンスは再レンダリングされても同一性を維持する。`size` または `valueOrFn` が
410
+ * 変更された場合に新しいインスタンスが作成される。
411
+ *
412
+ * @remarks Structural changes: `size` changes are treated as tail append/remove (see
413
+ * `FenwickMapTree.changeSize`). If a `size`/`itemCount` change actually reflects a middle
414
+ * insertion or deletion, the `valueOrFn` index↔height association is not preserved by an
415
+ * incremental resize; set `resetOnValueFnChange` to `true` (so the tree fully re-samples on
416
+ * every `valueOrFn` change) or remount with a new `key` when the list structure changes.
417
+ * @remarks 構造変更: `size` 変更は末尾追加/削除として扱う (`FenwickMapTree.changeSize` 参照)。
418
+ * `size`/`itemCount` の変更が実は中間挿入/削除を表す場合、増分リサイズでは `valueOrFn` の
419
+ * index↔高さ 対応が保存されないため、`resetOnValueFnChange` を `true` にする (毎回の `valueOrFn`
420
+ * 変更で木を全面再サンプリング) か、リスト構造変更時に新しい `key` で再マウントすること。
421
+ *
422
+ * @remarks Render-phase design constraint: this hook applies tree changes synchronously during
423
+ * render (not in an effect) because VirtualScroll reads `getTotal()` synchronously right after a
424
+ * size change. A consequence is that React concurrent's discarded renders are not undone — a
425
+ * shrink (deltas deletion) is irreversible if the render is thrown away. To stay safe, always pass
426
+ * a memoized `options`/`sampleRange` (e.g. `useMemo`) and a memoized `valueOrFn` (e.g. `useCallback`)
427
+ * so an unstable reference does not trigger a destructive reset every render.
428
+ * @remarks render フェーズの設計上の制約: 本フックはツリー変更を effect ではなく render 中に同期的に
429
+ * 適用する。VirtualScroll がサイズ変更直後に `getTotal()` を同期的に読む契約に依存するためである。
430
+ * 結果として React concurrent の破棄されたレンダーは巻き戻されず、縮小 (deltas 削除) はレンダーが
431
+ * 破棄されると不可逆になる。安全のため `options`/`sampleRange` は必ずメモ化して渡し (`useMemo`)、
432
+ * `valueOrFn` もメモ化する (`useCallback`) こと。不安定な参照は毎レンダーの破壊的 reset を招く。
433
+ *
434
+ * @param {number} size - The total number of items.
435
+ * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
436
+ * @param {number | ((index: number) => number)} valueOrFn - 全要素の均一な値、または値を生成する関数。不要なツリーの再作成を防ぐため、この関数は `useCallback` でメモ化すること。
437
+ * @param {{ sampleRange?: { from: number; to: number }, resetOnValueFnChange?: boolean, debug?: boolean }} [options] - Optional settings.
438
+ * @param {{ sampleRange?: { from: number; to: number } }} [options] - 初期化時のオプション設定。不要なツリーの再作成を防ぐため、このオブジェクトは `useMemo` でメモ化すること。
439
+ * @returns {FenwickMapTree} The FenwickMapTree instance.
440
+ * @returns {FenwickMapTree} FenwickMapTree インスタンス。
441
+ */
442
+ export declare const useFenwickMapTree: (size: number, valueOrFn: number | ((index: number) => number), options?: {
443
+ sampleRange?: {
444
+ from: number;
445
+ to: number;
446
+ };
447
+ debug?: boolean;
448
+ resetOnValueFnChange?: boolean;
449
+ }) => FenwickMapTree;
450
+ export {};
451
+ //# sourceMappingURL=useFenwickMapTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFenwickMapTree.d.ts","sourceRoot":"","sources":["../src/useFenwickMapTree.ts"],"names":[],"mappings":"AA4BA,KAAK,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AACpD,KAAK,iBAAiB,GAAG;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAAA;AAC9E,KAAK,iBAAiB,GAAG;IAAE,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAClE,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AACpD,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AA+DnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,cAAc;IACvB;;;;OAIG;IACH,OAAO,CAAC,IAAI,CAAsB;IAElC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAsB;IAEpC;;;;OAIG;IACH,OAAO,CAAC,IAAI,CAAS;IAErB;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAS;IAE1B;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAC,CAA2B;IAC3C,OAAO,CAAC,KAAK,CAAC,CAAQ;IAEtB;;;;;;;OAOG;gBACS,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG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kB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;IAI9M;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;CAGlN;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,EAAE,UAAU;IAAE,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,cA0E5M,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A custom hook that provides a cache for storing the heights of items, backed by an LRU cache.
3
+ * This helps in optimizing virtual scrolling by avoiding re-computation of item heights.
4
+ * The key is the item's index (number), and the value is its height (number).
5
+ *
6
+ * LRU キャッシュを利用して、アイテムの高さを保存するためのキャッシュを提供するカスタムフック。
7
+ * これにより、アイテムの高さの再計算を回避し、仮想スクロールを最適化します。
8
+ * キーはアイテムのインデックス (number)、値はその高さ (number) です。
9
+ */
10
+ export declare const useHeightCache: () => {
11
+ get: (key: number) => number | undefined;
12
+ set: (key: number, value: number) => void;
13
+ has: (key: number) => boolean;
14
+ clear: () => void;
15
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeightCache.d.ts","sourceRoot":"","sources":["../src/useHeightCache.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;;;;;CAQ1B,CAAA"}
@@ -2,9 +2,16 @@
2
2
  * @hook useLruCache
3
3
  * @description A custom hook that provides a Least Recently Used (LRU) cache of a specified capacity.
4
4
  * It returns an object with methods to interact with the cache (`get`, `set`, `has`, `remove`, `clear`).
5
+ * `Infinity` is treated as an unbounded cache (entries are stored and never evicted),
6
+ * while `NaN` or a negative capacity is invalid (nothing is stored, existing entries are cleared, and a warning is logged).
7
+ * A fractional capacity is normalized with `Math.floor` so that both the set path and the pruning
8
+ * effect share the same effective capacity.
5
9
  * @description 指定された容量の LRU (Least Recently Used) キャッシュを提供するカスタムフック。
6
10
  * キャッシュを操作するためのメソッド (`get`, `set`, `has`, `remove`, `clear`) を持つオブジェクトを返します。
7
- * @param {number} capacity - The maximum capacity of the cache.
11
+ * `Infinity` は無制限キャッシュ (格納し、evict しない)、`NaN` / 負値は無効容量
12
+ * (格納せず、既存エントリも全消去し、警告をログ) として扱う仕様。
13
+ * 小数の capacity は `Math.floor` で正規化し、set 経路と刈り込み effect が同じ実効容量を共有する。
14
+ * @param {number} capacity - The maximum capacity of the cache. `Infinity` means unbounded; `NaN` / negative values are invalid; fractional values are floored.
8
15
  * @returns {{ get: (key: K) => V | undefined, set: (key: K, value: V) => void, has: (key: K) => boolean, remove: (key: K) => void, clear: () => void }} An object with methods to interact with the cache.
9
16
  */
10
17
  export declare function useLruCache<K, V>(capacity: number): {
@@ -14,4 +21,3 @@ export declare function useLruCache<K, V>(capacity: number): {
14
21
  remove: (key: K) => void;
15
22
  clear: () => void;
16
23
  };
17
- //# sourceMappingURL=useLruCache.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @hook useLruCache
3
+ * @description A custom hook that provides a Least Recently Used (LRU) cache of a specified capacity.
4
+ * It returns an object with methods to interact with the cache (`get`, `set`, `has`, `remove`, `clear`).
5
+ * `Infinity` is treated as an unbounded cache (entries are stored and never evicted),
6
+ * while `NaN` or a negative capacity is invalid (nothing is stored, existing entries are cleared, and a warning is logged).
7
+ * A fractional capacity is normalized with `Math.floor` so that both the set path and the pruning
8
+ * effect share the same effective capacity.
9
+ * @description 指定された容量の LRU (Least Recently Used) キャッシュを提供するカスタムフック。
10
+ * キャッシュを操作するためのメソッド (`get`, `set`, `has`, `remove`, `clear`) を持つオブジェクトを返します。
11
+ * `Infinity` は無制限キャッシュ (格納し、evict しない)、`NaN` / 負値は無効容量
12
+ * (格納せず、既存エントリも全消去し、警告をログ) として扱う仕様。
13
+ * 小数の capacity は `Math.floor` で正規化し、set 経路と刈り込み effect が同じ実効容量を共有する。
14
+ * @param {number} capacity - The maximum capacity of the cache. `Infinity` means unbounded; `NaN` / negative values are invalid; fractional values are floored.
15
+ * @returns {{ get: (key: K) => V | undefined, set: (key: K, value: V) => void, has: (key: K) => boolean, remove: (key: K) => void, clear: () => void }} An object with methods to interact with the cache.
16
+ */
17
+ export declare function useLruCache<K, V>(capacity: number): {
18
+ get: (key: K) => V | undefined;
19
+ set: (key: K, value: V) => void;
20
+ has: (key: K) => boolean;
21
+ remove: (key: K) => void;
22
+ clear: () => void;
23
+ };
24
+ //# sourceMappingURL=useLruCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLruCache.d.ts","sourceRoot":"","sources":["../src/useLruCache.ts"],"names":[],"mappings":"AA4HA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM;eAwDhB,CAAC,KAAG,CAAC,GAAG,SAAS;eAqBjB,CAAC,SAAS,CAAC;eA6CX,CAAC,KAAG,OAAO;kBAWR,CAAC;;EA2BrC"}
@@ -3,10 +3,12 @@
3
3
  *
4
4
  * 指定された値が最小値と最大値の範囲内に収まるように調整。
5
5
  *
6
+ * min > max のような退化した入力でも、下限 (min) を下回る値を返さない。
7
+ * (Math.min を内側に置くことで、min > max のときは常に min を返す。)
8
+ *
6
9
  * @param value The value to clamp. / クランプする値。
7
10
  * @param min The minimum value. / 最小値。
8
11
  * @param max The maximum value. / 最大値。
9
12
  * @returns The clamped value. / クランプされた値。
10
13
  */
11
14
  export declare const minmax: (value: number, min: number, max: number) => number;
12
- //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Clamps a value between a minimum and maximum value.
3
+ *
4
+ * 指定された値が最小値と最大値の範囲内に収まるように調整。
5
+ *
6
+ * min > max のような退化した入力でも、下限 (min) を下回る値を返さない。
7
+ * (Math.min を内側に置くことで、min > max のときは常に min を返す。)
8
+ *
9
+ * @param value The value to clamp. / クランプする値。
10
+ * @param min The minimum value. / 最小値。
11
+ * @param max The maximum value. / 最大値。
12
+ * @returns The clamped value. / クランプされた値。
13
+ */
14
+ export declare const minmax: (value: number, min: number, max: number) => number;
15
+ //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAEhE,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAEhE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/virtualscroll",
3
- "version": "1.18.0",
3
+ "version": "1.18.3",
4
4
  "description": "High-performance virtual scrolling component for React with variable item heights",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -11,9 +11,14 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "exports": {
13
13
  ".": {
14
- "types": "./dist/index.d.ts",
15
- "import": "./dist/index.js",
16
- "require": "./dist/index.cjs",
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.cts",
20
+ "default": "./dist/index.cjs"
21
+ },
17
22
  "default": "./dist/index.js"
18
23
  },
19
24
  "./styles/virtualscroll.css": "./dist/styles/virtualscroll.css"
@@ -31,7 +36,7 @@
31
36
  "react-dom": "^19.2.7"
32
37
  },
33
38
  "dependencies": {
34
- "tailwind-merge": "^2.6.0"
39
+ "tailwind-merge": "^3.4.0"
35
40
  },
36
41
  "devDependencies": {
37
42
  "@playwright/test": "^1.59.1",
@@ -75,8 +80,9 @@
75
80
  "access": "public"
76
81
  },
77
82
  "scripts": {
78
- "build": "vite build && vite build --config vite.config.cli.ts && pnpm build:css",
83
+ "build": "vite build && vite build --config vite.config.cli.ts && pnpm build:css && pnpm build:cts",
79
84
  "build:css": "tailwindcss -i src/styles/tailwind.css -o dist/styles/virtualscroll.css --minify",
85
+ "build:cts": "node -e \"const fs=require('node:fs');const re=/(from\\s+')(\\.{1,2}\\/[^']+)\\.(?:tsx|ts)(')/g;for(const f of fs.readdirSync('dist')){if(!f.endsWith('.d.ts'))continue;const s=fs.readFileSync('dist/'+f,'utf8').replace(re,(_m,p,spec,q)=>p+spec+'.cjs'+q).replace(/^\\/\\/# sourceMappingURL=.*(\\r?\\n)?/gm,'');fs.writeFileSync('dist/'+f.slice(0,-5)+'.d.cts',s)}\"",
80
86
  "dev": "vite build --watch",
81
87
  "watch": "vite build --watch",
82
88
  "watch:css": "pnpm build:css --watch",
@@ -1 +0,0 @@
1
- {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