@dynamix-layout/core 1.0.1 → 1.1.1

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.
@@ -0,0 +1,472 @@
1
+ /** @deprecated Internal; removed in 2.0. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
2
+ export declare function areNodeOptionsEqual(a: NodeOptions, b: NodeOptions): boolean;
3
+
4
+ /** @deprecated Internal; removed in 2.0. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
5
+ export declare function areNodeOptionsMapEqual(mapA: Map<string, NodeOptions>, mapB: Map<string, NodeOptions>): boolean;
6
+
7
+ export declare interface BaseNode {
8
+ typNode: NodeTypeWithBond;
9
+ nodName: string;
10
+ uidNode: string;
11
+ nodPart: number;
12
+ nodeDir: boolean;
13
+ nodDims: Dimension;
14
+ nodOpen?: string | boolean;
15
+ }
16
+
17
+ /** @deprecated Internal; removed in 2.0. Splitters are `snapshot.splitters`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
18
+ export declare class Bond {
19
+ dims: Dimension;
20
+ unId: string;
21
+ next: Node_2 | null;
22
+ prev: Node_2 | null;
23
+ host: Node_2 | null;
24
+ constructor(parent?: Node_2 | null, next?: Node_2 | null, prev?: Node_2 | null);
25
+ toJSON(): LayoutTree;
26
+ }
27
+
28
+ export declare type ChangeListener<T> = (newValue: T) => void;
29
+
30
+ /**
31
+ * Coalesces bursts of updates (pointer events can fire several times per
32
+ * frame) into at most one `onFlush` call per animation frame.
33
+ */
34
+ export declare function createFrameScheduler<T>(onFlush: (value: T) => void): FrameScheduler<T>;
35
+
36
+ /** @deprecated Internal; removed in 2.0. Use `layout.subscribe()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
37
+ export declare function createReactiveState<T>(initialValue: T, comparator?: (a: T, b: T) => boolean): ReactiveValue<T>;
38
+
39
+ /** @deprecated Replaced in 2.0 by `Rect { x, y, width, height }`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
40
+ export declare type Dimension = {
41
+ w: number;
42
+ h: number;
43
+ x: number;
44
+ y: number;
45
+ };
46
+
47
+ export declare type DropArea = 'top' | 'bottom' | 'left' | 'right' | 'contain';
48
+
49
+ /** Where a dragged tab or tabset would land, in viewport coordinates. */
50
+ export declare interface DropPreview {
51
+ area: DropArea;
52
+ left: number;
53
+ top: number;
54
+ width: number;
55
+ height: number;
56
+ }
57
+
58
+ /** @deprecated Replaced in 2.0 by `createLayout(options)`, which returns an independent instance (no static state). See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
59
+ export declare class DynamixLayoutCore {
60
+ static get _root(): Node_2;
61
+ static set _root(value: Node_2);
62
+ static get _tree(): LayoutTree | null;
63
+ static set _tree(value: LayoutTree | null);
64
+ static get _minW(): number;
65
+ static set _minW(value: number);
66
+ static get _minH(): number;
67
+ static set _minH(value: number);
68
+ static get _bond(): number;
69
+ static set _bond(value: number);
70
+ static get _inst(): DynamixLayoutCore | null;
71
+ static set _inst(value: DynamixLayoutCore | null);
72
+ nodeOps: ReactiveValue<Map<string, NodeOptions>>;
73
+ cntdown: ReturnType<typeof setTimeout> | null;
74
+ tabsIds: TabsIds;
75
+ constructor(options?: {
76
+ tabs?: string[];
77
+ tree?: LayoutTree | null;
78
+ minW?: number;
79
+ minH?: number;
80
+ bond?: number;
81
+ uqid?: string;
82
+ tabsIds?: TabsIds;
83
+ /** Generates ids for new nodes and bonds (default `crypto.randomUUID`). */
84
+ createId?: () => string;
85
+ /** Schedules deferred updates (default `setTimeout`/`clearTimeout`). */
86
+ timer?: Timer;
87
+ });
88
+ JSONLayoutIterator(root: LayoutTree): IterableIterator<LayoutTree>;
89
+ NodeLayoutIterator(root: Node_2): IterableIterator<Node_2>;
90
+ NodeLayoutRecursiveIterator(root: Node_2): IterableIterator<Node_2>;
91
+ updateChildDirections(parent: Node_2): void;
92
+ createNodeLayout(root?: LayoutTree | null): void;
93
+ createNodeTreeFromJSONTree(json: LayoutTree, host: Node_2): void;
94
+ createBinaryNodeTreeFromQueue(queue: Queue<string>, host?: Node_2): void;
95
+ createNodeFromJSON(json: LayoutTree): Node_2;
96
+ calcTabsetCountAndMinDim(root?: Node_2, clear?: boolean): void;
97
+ pruneStaleDirections(): void;
98
+ calculateRootAdjustment(): RootAdjustment;
99
+ calcDimensions(root?: Node_2, supress?: boolean): void;
100
+ updateDimension(dim: Dimension, disableTimeout?: boolean, timeout?: number): void;
101
+ updateSlider(id: string, dim: {
102
+ x: number;
103
+ y: number;
104
+ }, disableTimeout?: boolean, timeout?: number): void;
105
+ updateSliderDimension(id: string, dim: {
106
+ x: number;
107
+ y: number;
108
+ }): void;
109
+ updateTree(src: string, des: string, layout: 'top' | 'bottom' | 'left' | 'right' | 'contain'): boolean;
110
+ isOnlyContent(node: Node_2): boolean;
111
+ moveNodeAsTab(src: Node_2, des: Node_2, layout: 'left' | 'right' | 'contain'): void;
112
+ moveRelativeToRoot(src: Node_2, des: Node_2, layout: 'top' | 'bottom' | 'left' | 'right'): void;
113
+ moveRelativeToTabset(src: Node_2, des: Node_2, layout: 'top' | 'bottom' | 'left' | 'right'): void;
114
+ insertNode(des: Node_2, src: Node_2, flag: boolean): void;
115
+ insertNodeWithNewParent(src: Node_2, des: Node_2, flag: boolean): void;
116
+ moveAdjacentNodeToGrandParent(src: Node_2): void;
117
+ removeRelation(src: Node_2, fix?: boolean): Node_2 | undefined;
118
+ removeNode(src: Node_2): void;
119
+ removeKid(kid: Node_2): void;
120
+ clearAllCache(): void;
121
+ }
122
+
123
+ export declare interface FrameScheduler<T> {
124
+ /** Remember `value`; `onFlush` runs with the latest value on the next frame. */
125
+ schedule: (value: T) => void;
126
+ /** Run a pending flush now (e.g. on pointer up). */
127
+ flush: () => void;
128
+ /** Drop a pending flush (e.g. on unmount). */
129
+ cancel: () => void;
130
+ }
131
+
132
+ /**
133
+ * Insertion marker between the tabs of a tab bar. `index` is the tab the
134
+ * marker sits next to. Returns null when the pointer is above or below the bar.
135
+ * @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
136
+ */
137
+ export declare function getNavbarDropPreview(navbarRect: PreviewRect, tabRects: PreviewRect[], clientX: number, clientY: number): (DropPreview & {
138
+ index: number;
139
+ }) | null;
140
+
141
+ /**
142
+ * The half of the whole layout a root-edge drop would take.
143
+ * @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
144
+ */
145
+ export declare function getRootSplitPreview(container: Dimension, side: RootSide): DropPreview;
146
+
147
+ /**
148
+ * Area of a tabset below its tab bar; never negative when squeezed.
149
+ * @deprecated Replaced in 2.0 by `getTabContentRect(tabsetRect, tabBarHeight)`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
150
+ */
151
+ export declare function getTabBodyRect(tabset: Dimension, tabbarHeight: number): Dimension;
152
+
153
+ /**
154
+ * Splits a tabset into thirds: the outer thirds drop beside it, the middle
155
+ * drops into it as a tab.
156
+ * @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
157
+ */
158
+ export declare function getTabsetDropPreview(rect: PreviewRect, clientX: number, clientY: number): DropPreview;
159
+
160
+ /** @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
161
+ export declare function isSameDropPreview(a: Partial<DropPreview>, b: DropPreview): boolean;
162
+
163
+ /** @deprecated Replaced in 2.0 by `LayoutJSON` (v1 trees load automatically; `LayoutTreeV1` describes this shape). See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
164
+ export declare type LayoutTree = Omit<BaseNode, 'nodeDir' | 'nodDims'> & {
165
+ nodKids?: LayoutTree[];
166
+ };
167
+
168
+ /** @deprecated Internal; removed in 2.0. Read layout state from `layout.getSnapshot()` / `subscribe()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
169
+ declare class Node_2 {
170
+ static cache: NodeCache;
171
+ kids: Queue<Node_2>;
172
+ dims: Dimension;
173
+ unId: string;
174
+ next: Bond | null;
175
+ prev: Bond | null;
176
+ type: 'row' | 'tabset' | 'tab' | 'bond';
177
+ name: string;
178
+ part: number;
179
+ host: Node_2 | null;
180
+ open: string;
181
+ constructor(options?: {
182
+ type?: 'row' | 'tabset' | 'tab' | 'bond';
183
+ host?: Node_2 | null;
184
+ name?: string;
185
+ part?: number;
186
+ dims?: Dimension;
187
+ unId?: string;
188
+ open?: string;
189
+ });
190
+ addBond(parent: Node_2 | null, prev?: Node_2 | null): void;
191
+ getReqDimension(): {
192
+ width: number;
193
+ height: number;
194
+ };
195
+ calcDimensions(): void;
196
+ toJSON(): LayoutTree;
197
+ }
198
+ export { Node_2 as Node }
199
+
200
+ export declare interface NodeCache {
201
+ dimMins: Map<string, {
202
+ minWidth: number;
203
+ minHeight: number;
204
+ }>;
205
+ mapDirs: Map<string, boolean>;
206
+ tabCnts: Map<string, {
207
+ horizontal: number;
208
+ vertical: number;
209
+ }>;
210
+ mapElem: Map<string, Node_2 | Bond>;
211
+ nodOpts: ReactiveValue<Map<string, NodeOptions>>;
212
+ bndOpts: ReactiveValue<Map<string, NodeOptions>>;
213
+ tabOpts: ReactiveValue<Map<string, NodeOptions>>;
214
+ }
215
+
216
+ /** @deprecated Replaced in 2.0 by `TabsetState`, `SplitterState`, `TabState` and `snapshot.rects`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
217
+ export declare interface NodeOptions extends BaseNode {
218
+ nodKids?: BaseNode[];
219
+ }
220
+
221
+ export declare type NodeType = 'row' | 'tabset' | 'tab';
222
+
223
+ export declare type NodeTypeWithBond = NodeType | 'bond';
224
+
225
+ export declare type PreviewRect = Pick<DOMRect, 'left' | 'top' | 'right' | 'bottom' | 'width' | 'height'>;
226
+
227
+ /** @deprecated Internal; removed in 2.0. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
228
+ export declare class Queue<T> {
229
+ private buffer;
230
+ private head;
231
+ private tail;
232
+ private count;
233
+ private capacity;
234
+ constructor(initialCapacity?: number, array?: T[]);
235
+ /**
236
+ * Add element to the back of the queue - O(1) amortized
237
+ * Used for FIFO and FILO patterns
238
+ */
239
+ enqueue(item: T): void;
240
+ /**
241
+ * Add element to the front of the queue - O(1) amortized
242
+ * Used for LIFO and LILO patterns
243
+ */
244
+ enqueueFront(item: T): void;
245
+ /**
246
+ * Insert element at specific logical index - O(n)
247
+ * All elements at and after the index are shifted right
248
+ * @param index - Logical index (0 = front of queue)
249
+ * @param item - Element to insert
250
+ * @returns true if insertion successful, false if index out of bounds
251
+ */
252
+ insert(index: number, item: T): boolean;
253
+ /**
254
+ * Insert array of elements at specific logical index - O(n + m) where n is elements to shift, m is array length
255
+ * All elements at and after the index are shifted right to make room for the entire array
256
+ * @param index - Logical index (0 = front of queue)
257
+ * @param items - Array of elements to insert
258
+ * @returns true if insertion successful, false if index out of bounds
259
+ */
260
+ insertArray(index: number, items: T[]): boolean;
261
+ /**
262
+ * Insert another queue at specific logical index - O(n + m) where n is elements to shift, m is queue size
263
+ * All elements at and after the index are shifted right to make room for the entire queue
264
+ * @param index - Logical index (0 = front of queue)
265
+ * @param queue - Queue to insert
266
+ * @returns true if insertion successful, false if index out of bounds
267
+ */
268
+ insertQueue(index: number, queue: Queue<T>): boolean;
269
+ /**
270
+ * Alias for enqueue (add to back)
271
+ */
272
+ push(item: T): void;
273
+ /**
274
+ * Alias for enqueueFront (add to front)
275
+ */
276
+ unshift(item: T): void;
277
+ /**
278
+ * Remove and return element from front of queue - O(1)
279
+ * Used for FIFO and LIFO patterns
280
+ */
281
+ dequeue(): T | undefined;
282
+ /**
283
+ * Remove and return element from back of queue - O(1)
284
+ * Used for FILO and LILO patterns
285
+ */
286
+ dequeueBack(): T | undefined;
287
+ indexOf(item: T): number;
288
+ remove(item: T): boolean;
289
+ /**
290
+ * Remove element at specific logical index - O(n)
291
+ * All elements after the index are shifted left
292
+ * @param index - Logical index (0 = front of queue)
293
+ * @returns The removed element, or undefined if index out of bounds
294
+ */
295
+ removeAt(index: number): T | undefined;
296
+ /**
297
+ * Alias for dequeue (remove from front)
298
+ */
299
+ shift(): T | undefined;
300
+ /**
301
+ * Alias for dequeueBack (remove from back)
302
+ */
303
+ pop(): T | undefined;
304
+ /**
305
+ * FIFO: First In, First Out
306
+ * Add to back, remove from front
307
+ */
308
+ fifoAdd(item: T): void;
309
+ fifoRemove(): T | undefined;
310
+ /**
311
+ * FILO: First In, Last Out
312
+ * Add to back, remove from back
313
+ */
314
+ filoAdd(item: T): void;
315
+ filoRemove(): T | undefined;
316
+ /**
317
+ * LIFO: Last In, First Out
318
+ * Add to front, remove from front
319
+ */
320
+ lifoAdd(item: T): void;
321
+ lifoRemove(): T | undefined;
322
+ /**
323
+ * LILO: Last In, Last Out
324
+ * Add to front, remove from back
325
+ */
326
+ liloAdd(item: T): void;
327
+ liloRemove(): T | undefined;
328
+ /**
329
+ * Get element at logical index (0 = front of queue) - O(1)
330
+ */
331
+ get(index: number): T | undefined;
332
+ /**
333
+ * Set element at logical index - O(1)
334
+ */
335
+ set(index: number, item: T): boolean;
336
+ /**
337
+ * Get the front element without removing it - O(1)
338
+ */
339
+ peek(): T | undefined;
340
+ /**
341
+ * Get the back element without removing it - O(1)
342
+ */
343
+ peekBack(): T | undefined;
344
+ /**
345
+ * Alias for peek (front element)
346
+ */
347
+ front(): T | undefined;
348
+ /**
349
+ * Alias for peekBack (back element)
350
+ */
351
+ back(): T | undefined;
352
+ /**
353
+ * Get current size of queue - O(1)
354
+ */
355
+ size(): number;
356
+ /**
357
+ * Get current capacity - O(1)
358
+ */
359
+ getCapacity(): number;
360
+ /**
361
+ * Check if queue is empty - O(1)
362
+ */
363
+ isEmpty(): boolean;
364
+ /**
365
+ * Check if queue is full - O(1)
366
+ */
367
+ isFull(): boolean;
368
+ /**
369
+ * Clear all elements from queue - O(1)
370
+ */
371
+ clear(): void;
372
+ /**
373
+ * Convert queue to array (maintains order from front to back) - O(n)
374
+ */
375
+ toArray(): T[];
376
+ /**
377
+ * Forward iterator support for for...of loops - O(n) total
378
+ * Iterates from front to back
379
+ */
380
+ [Symbol.iterator](): IterableIterator<T>;
381
+ /**
382
+ * Forward iterator (same as Symbol.iterator) - O(n) total
383
+ * Iterates from front to back
384
+ */
385
+ forward(): IterableIterator<T>;
386
+ /**
387
+ * Reverse iterator - O(n) total
388
+ * Iterates from back to front
389
+ */
390
+ reverse(): IterableIterator<T>;
391
+ /**
392
+ * Iterator with index information - O(n) total
393
+ * Returns [index, value] pairs from front to back
394
+ */
395
+ entries(): IterableIterator<[number, T]>;
396
+ /**
397
+ * Iterator for keys (indices) - O(n) total
398
+ */
399
+ keys(): IterableIterator<number>;
400
+ /**
401
+ * Iterator for values only - O(n) total
402
+ * Same as Symbol.iterator but more explicit
403
+ */
404
+ values(): IterableIterator<T>;
405
+ /**
406
+ * Get string representation - O(n)
407
+ */
408
+ toString(): string;
409
+ /**
410
+ * Private method to resize buffer when capacity is exceeded
411
+ */
412
+ private resize;
413
+ /**
414
+ * Shift elements left (towards head) to make room for insertion
415
+ * Used when inserting closer to head
416
+ */
417
+ private shiftLeft;
418
+ /**
419
+ * Shift elements right (towards tail) to make room for insertion
420
+ * Used when inserting closer to tail
421
+ */
422
+ private shiftRight;
423
+ /**
424
+ * Shift elements right (towards tail) to fill gap after removal
425
+ * Used when removing closer to head
426
+ */
427
+ private shiftRightForRemoval;
428
+ /**
429
+ * Shift elements left (towards head) to fill gap after removal
430
+ * Used when removing closer to tail
431
+ */
432
+ private shiftLeftForRemoval;
433
+ /**
434
+ * Shift elements left (towards head) to make room for array insertion
435
+ * Used when inserting array closer to head
436
+ */
437
+ private shiftLeftArray;
438
+ /**
439
+ * Shift elements right (towards tail) to make room for array insertion
440
+ * Used when inserting array closer to tail
441
+ */
442
+ private shiftRightArray;
443
+ }
444
+
445
+ export declare interface ReactiveValue<T> {
446
+ get: () => T;
447
+ set: (newValue: T, flag?: boolean) => void;
448
+ onChange: (listener: ChangeListener<T>) => () => void;
449
+ nextChange: () => Promise<T>;
450
+ onChangePromise: (listener: ChangeListener<T>) => () => void;
451
+ triggerChange: () => void;
452
+ }
453
+
454
+ export declare interface RootAdjustment {
455
+ adjustedW: number;
456
+ adjustedH: number;
457
+ wasAdjusted: boolean;
458
+ }
459
+
460
+ export declare type RootSide = Exclude<DropArea, 'contain'>;
461
+
462
+ /** @deprecated Replaced in 2.0 by `applyRect(element, rect)`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
463
+ export declare function setElementRect(el: HTMLElement, { x, y, w, h }: Dimension): void;
464
+
465
+ export declare type TabsIds = Map<string, string>;
466
+
467
+ declare type Timer = {
468
+ set: (callback: () => void, ms: number) => ReturnType<typeof setTimeout>;
469
+ clear: (handle: ReturnType<typeof setTimeout>) => void;
470
+ };
471
+
472
+ export { }