@gustavolmo/react-window-manager 0.4.1 → 0.4.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.
- package/README.md +76 -130
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +564 -221
- package/dist/index.js.map +1 -1
- package/dist/window-manager/internal/features/cursor/cursor-move-listener.d.ts.map +1 -1
- package/dist/window-manager/internal/features/cursor/cursor-state.d.ts +5 -2
- package/dist/window-manager/internal/features/cursor/cursor-state.d.ts.map +1 -1
- package/dist/window-manager/internal/features/docking/docking-area-orchestrator.d.ts +1 -0
- package/dist/window-manager/internal/features/docking/docking-area-orchestrator.d.ts.map +1 -0
- package/dist/window-manager/internal/features/docking/docking-controls.d.ts.map +1 -1
- package/dist/window-manager/internal/features/drag/drag-api.d.ts.map +1 -1
- package/dist/window-manager/internal/features/grid/grid-orchestrator.d.ts +3 -2
- package/dist/window-manager/internal/features/grid/grid-orchestrator.d.ts.map +1 -1
- package/dist/window-manager/internal/features/history/history-api.d.ts +6 -0
- package/dist/window-manager/internal/features/history/history-api.d.ts.map +1 -0
- package/dist/window-manager/internal/features/history/history-keys-listener.d.ts +2 -0
- package/dist/window-manager/internal/features/history/history-keys-listener.d.ts.map +1 -0
- package/dist/window-manager/internal/features/resizing/resizing-api.d.ts.map +1 -1
- package/dist/window-manager/internal/features/resizing/resizing-controls.d.ts.map +1 -1
- package/dist/window-manager/internal/features/window-layout.d.ts.map +1 -1
- package/dist/window-manager/internal/features/workspace/workspace-api.d.ts +2 -2
- package/dist/window-manager/internal/features/workspace/workspace-api.d.ts.map +1 -1
- package/dist/window-manager/internal/features/workspace/workspace-resize-listener.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/dock-resolver/dock-commands.d.ts +0 -3
- package/dist/window-manager/internal/runtime/dock-resolver/dock-commands.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/drag-resolver/drag-commands.d.ts +0 -1
- package/dist/window-manager/internal/runtime/drag-resolver/drag-commands.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/history-resolver/app-history.d.ts +13 -0
- package/dist/window-manager/internal/runtime/history-resolver/app-history.d.ts.map +1 -0
- package/dist/window-manager/internal/runtime/history-resolver/history-commands.d.ts +6 -0
- package/dist/window-manager/internal/runtime/history-resolver/history-commands.d.ts.map +1 -0
- package/dist/window-manager/internal/runtime/resize-resolver/resize-loop-rules.d.ts +3 -0
- package/dist/window-manager/internal/runtime/resize-resolver/resize-loop-rules.d.ts.map +1 -0
- package/dist/window-manager/internal/runtime/resize-resolver/resize-loop.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/rwm-runtime.d.ts +18 -6
- package/dist/window-manager/internal/runtime/rwm-runtime.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/workspace-resolver/workspace-commands.d.ts +4 -4
- package/dist/window-manager/internal/runtime/workspace-resolver/workspace-commands.d.ts.map +1 -1
- package/dist/window-manager/model/window-types.d.ts +5 -6
- package/dist/window-manager/model/window-types.d.ts.map +1 -1
- package/dist/window-manager/model/workspace-types.d.ts +1 -1
- package/dist/window-manager/model/workspace-types.d.ts.map +1 -1
- package/dist/window-manager/registration/window-store-factory.d.ts.map +1 -1
- package/dist/window-manager/rwm.d.ts +4 -7
- package/dist/window-manager/rwm.d.ts.map +1 -1
- package/dist/window-manager/workspace-layout.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/window-manager/internal/features/stack/stack-api.d.ts +0 -4
- package/dist/window-manager/internal/features/stack/stack-api.d.ts.map +0 -1
- package/dist/window-manager/internal/runtime/stack-resolver/stack-commands.d.ts +0 -6
- package/dist/window-manager/internal/runtime/stack-resolver/stack-commands.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var useWorkspaceState = create((set, get) => ({
|
|
|
7
7
|
wsElement: null,
|
|
8
8
|
setWsElement: (el) => set({ wsElement: el }),
|
|
9
9
|
isGridEnabled: true,
|
|
10
|
-
|
|
10
|
+
isDockPanelEnabled: true,
|
|
11
11
|
responsiveBreak: "sm",
|
|
12
12
|
isBelowBreakPoint: false,
|
|
13
13
|
activeWindowId: "react-dynamic-window-instance0",
|
|
@@ -169,23 +169,21 @@ var dockCommandResolver = {
|
|
|
169
169
|
];
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
var getDockDependencies = () => {
|
|
173
|
-
const { wsRect } = useWorkspaceState.getState();
|
|
174
|
-
return { wsRect };
|
|
175
|
-
};
|
|
176
172
|
|
|
177
173
|
// src/window-manager/internal/features/cursor/cursor-state.ts
|
|
178
|
-
|
|
179
|
-
var useCursorState = create2((set) => ({
|
|
174
|
+
var cursorPosition = {
|
|
180
175
|
x: 10,
|
|
181
|
-
y: 10
|
|
182
|
-
|
|
183
|
-
})
|
|
176
|
+
y: 10
|
|
177
|
+
};
|
|
178
|
+
var setCursorPosition = ({ x, y }) => {
|
|
179
|
+
cursorPosition.x = x;
|
|
180
|
+
cursorPosition.y = y;
|
|
181
|
+
};
|
|
184
182
|
|
|
185
183
|
// src/window-manager/internal/runtime/drag-resolver/drag-loop.ts
|
|
186
184
|
var rafDragLoopResolver = {
|
|
187
185
|
LOOP_DRAG: (targetWinId, commit) => {
|
|
188
|
-
const { x, y } =
|
|
186
|
+
const { x, y } = cursorPosition;
|
|
189
187
|
const { winCoord, isDragging, windowId } = windowRegistry[targetWinId].getState();
|
|
190
188
|
if (!isDragging)
|
|
191
189
|
throw new Error(`LOOP_DRAG called with isDragging false for winId: ${windowId}`);
|
|
@@ -199,7 +197,7 @@ var rafDragLoopResolver = {
|
|
|
199
197
|
var dragLoop = (targetWinId, pointerOffset, commit) => {
|
|
200
198
|
const { winCoord, isDragging } = windowRegistry[targetWinId].getState();
|
|
201
199
|
const { wsRect } = useWorkspaceState.getState();
|
|
202
|
-
const { x, y } =
|
|
200
|
+
const { x, y } = cursorPosition;
|
|
203
201
|
if (!isDragging)
|
|
204
202
|
return;
|
|
205
203
|
let adjustedX = Math.round(x - pointerOffset.left);
|
|
@@ -249,9 +247,6 @@ var dragCommandResolver = {
|
|
|
249
247
|
];
|
|
250
248
|
}
|
|
251
249
|
};
|
|
252
|
-
var isDragAllowed = () => {
|
|
253
|
-
return !useWorkspaceState.getState().isBelowBreakPoint;
|
|
254
|
-
};
|
|
255
250
|
|
|
256
251
|
// src/window-manager/internal/runtime/focus-resolver/focus-commands.ts
|
|
257
252
|
var focusCommandResolver = {
|
|
@@ -328,30 +323,12 @@ var focusCommandResolver = {
|
|
|
328
323
|
}
|
|
329
324
|
};
|
|
330
325
|
|
|
331
|
-
// src/window-manager/internal/runtime/stack-resolver/stack-commands.ts
|
|
332
|
-
var stackCommandResolver = {
|
|
333
|
-
RESET_STACK: () => {
|
|
334
|
-
const batchUpdate = [];
|
|
335
|
-
for (const key of Object.keys(windowRegistry)) {
|
|
336
|
-
const { resetFlag } = windowRegistry[key].getState();
|
|
337
|
-
batchUpdate.push({
|
|
338
|
-
winId: key,
|
|
339
|
-
patch: {
|
|
340
|
-
resetFlag: !resetFlag,
|
|
341
|
-
// FIND ME: reset flag is anti-pattern
|
|
342
|
-
isWindowClosed: true,
|
|
343
|
-
isActive: false
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
return batchUpdate;
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
|
|
351
326
|
// src/window-manager/internal/runtime/workspace-resolver/workspace-commands.ts
|
|
352
327
|
var workspaceCommandResolver = {
|
|
353
|
-
|
|
328
|
+
UPDATE_WORKSPACE_SIZE: () => {
|
|
329
|
+
const prevRect = useWorkspaceState.getState().wsRect;
|
|
354
330
|
const rect = useWorkspaceState.getState().wsElement?.getBoundingClientRect();
|
|
331
|
+
const breakPoint = useWorkspaceState.getState().responsiveBreak;
|
|
355
332
|
const top = rect?.top ?? 0;
|
|
356
333
|
const left = rect?.left ?? 0;
|
|
357
334
|
const innerHeight = rect?.height ?? 0;
|
|
@@ -360,10 +337,8 @@ var workspaceCommandResolver = {
|
|
|
360
337
|
const right = left + innerWidth;
|
|
361
338
|
const centerX = left + innerWidth / 2;
|
|
362
339
|
const centerY = top + innerHeight / 2;
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
return {
|
|
366
|
-
isBelowBreakPoint,
|
|
340
|
+
const workspaceUpdate = {
|
|
341
|
+
isBelowBreakPoint: innerWidth < responsiveBreakInPx(breakPoint),
|
|
367
342
|
wsRect: {
|
|
368
343
|
top,
|
|
369
344
|
left,
|
|
@@ -375,20 +350,50 @@ var workspaceCommandResolver = {
|
|
|
375
350
|
centerY
|
|
376
351
|
}
|
|
377
352
|
};
|
|
353
|
+
const windowBatchUpdate = [];
|
|
354
|
+
const { innerHeight: prevWsHeight, innerWidth: prevWsWidth } = prevRect;
|
|
355
|
+
const currWsHeight = innerHeight;
|
|
356
|
+
const currWsWidth = innerWidth;
|
|
357
|
+
const widthChangeRatio = currWsWidth / prevWsWidth;
|
|
358
|
+
const heightChangeRatio = currWsHeight / prevWsHeight;
|
|
359
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
360
|
+
const win = windowRegistry[key].getState();
|
|
361
|
+
windowBatchUpdate.push({
|
|
362
|
+
winId: key,
|
|
363
|
+
patch: {
|
|
364
|
+
winWidth: win.winWidth * widthChangeRatio,
|
|
365
|
+
winHeight: win.winHeight * heightChangeRatio,
|
|
366
|
+
winCoord: {
|
|
367
|
+
pointX: win.winCoord.pointX * widthChangeRatio,
|
|
368
|
+
pointY: win.winCoord.pointY * heightChangeRatio
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
win: windowBatchUpdate,
|
|
375
|
+
ws: workspaceUpdate
|
|
376
|
+
};
|
|
378
377
|
},
|
|
379
378
|
SET_WORKSPACE_FEATURES: (_, ctx) => {
|
|
380
|
-
if (ctx?.isGridEnabled === void 0 || ctx?.
|
|
379
|
+
if (ctx?.isGridEnabled === void 0 || ctx?.isDockPanelEnabled === void 0)
|
|
381
380
|
throw new Error(`SET_WORKSPACE_FEATURES called without a ctx value`);
|
|
382
381
|
return {
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
win: [],
|
|
383
|
+
ws: {
|
|
384
|
+
isGridEnabled: ctx.isGridEnabled,
|
|
385
|
+
isDockPanelEnabled: ctx.isDockPanelEnabled
|
|
386
|
+
}
|
|
385
387
|
};
|
|
386
388
|
},
|
|
387
389
|
SET_RESPONSIVE_BREAK: (_, ctx) => {
|
|
388
390
|
if (ctx?.responsiveBreak === void 0 || ctx?.responsiveBreak === null)
|
|
389
391
|
throw new Error(`SET_RESPONSIVE_BREAK called without a ctx value`);
|
|
390
392
|
return {
|
|
391
|
-
|
|
393
|
+
win: [],
|
|
394
|
+
ws: {
|
|
395
|
+
responsiveBreak: ctx.responsiveBreak
|
|
396
|
+
}
|
|
392
397
|
};
|
|
393
398
|
}
|
|
394
399
|
};
|
|
@@ -416,7 +421,7 @@ var resizeCommandResolver = {
|
|
|
416
421
|
ENABLE_RESIZE: (targetWinId, direction) => {
|
|
417
422
|
const currentResizeAction = windowRegistry[targetWinId].getState().resizeAction;
|
|
418
423
|
if (currentResizeAction)
|
|
419
|
-
throw new Error(`ENABLE_RESIZE called on a window that is already
|
|
424
|
+
throw new Error(`ENABLE_RESIZE called on a window that is already resizing`);
|
|
420
425
|
return [
|
|
421
426
|
{
|
|
422
427
|
winId: targetWinId,
|
|
@@ -440,6 +445,108 @@ var resizeCommandResolver = {
|
|
|
440
445
|
}
|
|
441
446
|
};
|
|
442
447
|
|
|
448
|
+
// src/window-manager/internal/runtime/resize-resolver/resize-loop-rules.ts
|
|
449
|
+
var resolveNeighbourResizeLimit = (activeWinId, direction) => {
|
|
450
|
+
switch (direction) {
|
|
451
|
+
case "e":
|
|
452
|
+
return neighbourResizeLimit.e(activeWinId);
|
|
453
|
+
case "w":
|
|
454
|
+
return neighbourResizeLimit.w(activeWinId);
|
|
455
|
+
case "n":
|
|
456
|
+
return neighbourResizeLimit.n(activeWinId);
|
|
457
|
+
case "s":
|
|
458
|
+
return neighbourResizeLimit.s(activeWinId);
|
|
459
|
+
default:
|
|
460
|
+
return void 0;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var neighbourResizeLimit = {
|
|
464
|
+
e: (activeWinId) => {
|
|
465
|
+
let leftMostXAtMinWidth = void 0;
|
|
466
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
467
|
+
const neighbourWin = windowRegistry[key].getState();
|
|
468
|
+
if (key === activeWinId)
|
|
469
|
+
continue;
|
|
470
|
+
if (neighbourWin.resizeAction !== "w")
|
|
471
|
+
continue;
|
|
472
|
+
if (neighbourWin.isWindowClosed)
|
|
473
|
+
continue;
|
|
474
|
+
const winBox = neighbourWin.winElement?.getBoundingClientRect();
|
|
475
|
+
if (!winBox)
|
|
476
|
+
continue;
|
|
477
|
+
const xAtMinWidth = winBox.right - neighbourWin.WIN_MIN_WIDTH;
|
|
478
|
+
if (leftMostXAtMinWidth === void 0)
|
|
479
|
+
leftMostXAtMinWidth = xAtMinWidth;
|
|
480
|
+
if (leftMostXAtMinWidth > xAtMinWidth)
|
|
481
|
+
leftMostXAtMinWidth = xAtMinWidth;
|
|
482
|
+
}
|
|
483
|
+
return leftMostXAtMinWidth;
|
|
484
|
+
},
|
|
485
|
+
w: (activeWinId) => {
|
|
486
|
+
let rightMostXAtMinWidth = void 0;
|
|
487
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
488
|
+
const neighbourWin = windowRegistry[key].getState();
|
|
489
|
+
if (key === activeWinId)
|
|
490
|
+
continue;
|
|
491
|
+
if (neighbourWin.resizeAction !== "e")
|
|
492
|
+
continue;
|
|
493
|
+
if (neighbourWin.isWindowClosed)
|
|
494
|
+
continue;
|
|
495
|
+
const winBox = neighbourWin.winElement?.getBoundingClientRect();
|
|
496
|
+
if (!winBox)
|
|
497
|
+
continue;
|
|
498
|
+
const xAtMinWidth = winBox.left + neighbourWin.WIN_MIN_WIDTH;
|
|
499
|
+
if (rightMostXAtMinWidth === void 0)
|
|
500
|
+
rightMostXAtMinWidth = xAtMinWidth;
|
|
501
|
+
if (rightMostXAtMinWidth < xAtMinWidth)
|
|
502
|
+
rightMostXAtMinWidth = xAtMinWidth;
|
|
503
|
+
}
|
|
504
|
+
return rightMostXAtMinWidth;
|
|
505
|
+
},
|
|
506
|
+
n: (currentWinId) => {
|
|
507
|
+
let bottomMostYAtMinWidth = void 0;
|
|
508
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
509
|
+
const remoteWin = windowRegistry[key].getState();
|
|
510
|
+
if (key === currentWinId)
|
|
511
|
+
continue;
|
|
512
|
+
if (remoteWin.resizeAction !== "s")
|
|
513
|
+
continue;
|
|
514
|
+
if (remoteWin.isWindowClosed)
|
|
515
|
+
continue;
|
|
516
|
+
const winBox = remoteWin.winElement?.getBoundingClientRect();
|
|
517
|
+
if (!winBox)
|
|
518
|
+
continue;
|
|
519
|
+
const yAtMinWidth = winBox.top + remoteWin.WIN_MIN_HEIGHT;
|
|
520
|
+
if (bottomMostYAtMinWidth === void 0)
|
|
521
|
+
bottomMostYAtMinWidth = yAtMinWidth;
|
|
522
|
+
if (bottomMostYAtMinWidth < yAtMinWidth)
|
|
523
|
+
bottomMostYAtMinWidth = yAtMinWidth;
|
|
524
|
+
}
|
|
525
|
+
return bottomMostYAtMinWidth;
|
|
526
|
+
},
|
|
527
|
+
s: (currentWinId) => {
|
|
528
|
+
let topMostYAtMinWidth = void 0;
|
|
529
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
530
|
+
const remoteWin = windowRegistry[key].getState();
|
|
531
|
+
if (key === currentWinId)
|
|
532
|
+
continue;
|
|
533
|
+
if (remoteWin.resizeAction !== "n")
|
|
534
|
+
continue;
|
|
535
|
+
if (remoteWin.isWindowClosed)
|
|
536
|
+
continue;
|
|
537
|
+
const winBox = remoteWin.winElement?.getBoundingClientRect();
|
|
538
|
+
if (!winBox)
|
|
539
|
+
continue;
|
|
540
|
+
const yAtMinWidth = winBox.bottom - remoteWin.WIN_MIN_HEIGHT;
|
|
541
|
+
if (topMostYAtMinWidth === void 0)
|
|
542
|
+
topMostYAtMinWidth = yAtMinWidth;
|
|
543
|
+
if (topMostYAtMinWidth > yAtMinWidth)
|
|
544
|
+
topMostYAtMinWidth = yAtMinWidth;
|
|
545
|
+
}
|
|
546
|
+
return topMostYAtMinWidth;
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
|
|
443
550
|
// src/window-manager/internal/runtime/resize-resolver/resize-loop.ts
|
|
444
551
|
var rafResizeLoopResolver = {
|
|
445
552
|
LOOP_RESIZE: (targetWinId, commitCb) => {
|
|
@@ -450,95 +557,198 @@ var rafResizeLoopResolver = {
|
|
|
450
557
|
const winElementBox = dep.winBox;
|
|
451
558
|
if (!winElementBox)
|
|
452
559
|
throw new Error(`LOOP_RESIZE called with null window element for winId: ${targetWinId}`);
|
|
453
|
-
requestAnimationFrame(
|
|
454
|
-
|
|
455
|
-
|
|
560
|
+
requestAnimationFrame(() => {
|
|
561
|
+
const neighbourLimit = resolveNeighbourResizeLimit(dep.win.windowId, resizeDirection);
|
|
562
|
+
resizer[resizeDirection](getRafResizeDependencies(targetWinId), commitCb, neighbourLimit);
|
|
563
|
+
});
|
|
456
564
|
}
|
|
457
565
|
};
|
|
458
566
|
var resizer = {
|
|
459
|
-
e: (resizeDep, commit) => {
|
|
567
|
+
e: (resizeDep, commit, neighbourLimit) => {
|
|
460
568
|
const { wsRect, win, winBox, x } = resizeDep;
|
|
461
569
|
if (!win.resizeAction)
|
|
462
570
|
return;
|
|
463
571
|
if (!winBox)
|
|
464
572
|
return;
|
|
465
573
|
const cursorOutOfBounds = x > wsRect.right || x < wsRect.left;
|
|
466
|
-
const minWinWidth = x - winBox.left < win.WIN_MIN_WIDTH;
|
|
467
574
|
const sizeDiff = x - winBox.right;
|
|
468
|
-
|
|
575
|
+
const isResizeActive = !cursorOutOfBounds && sizeDiff !== 0;
|
|
576
|
+
const minWinWidth = x - winBox.left < win.WIN_MIN_WIDTH;
|
|
577
|
+
const leftMostXAtMinWidth = neighbourLimit;
|
|
578
|
+
const isNeighbourLimit = leftMostXAtMinWidth && x > leftMostXAtMinWidth;
|
|
579
|
+
if (isNeighbourLimit && isResizeActive) {
|
|
580
|
+
commit([
|
|
581
|
+
{
|
|
582
|
+
winId: win.windowId,
|
|
583
|
+
patch: { winWidth: leftMostXAtMinWidth - win.winCoord.pointX }
|
|
584
|
+
}
|
|
585
|
+
]);
|
|
586
|
+
} else if (!minWinWidth && isResizeActive) {
|
|
587
|
+
commit([
|
|
588
|
+
{
|
|
589
|
+
winId: win.windowId,
|
|
590
|
+
patch: { winWidth: win.winWidth + sizeDiff }
|
|
591
|
+
}
|
|
592
|
+
]);
|
|
593
|
+
} else if (minWinWidth && isResizeActive) {
|
|
469
594
|
commit([
|
|
470
595
|
{
|
|
471
596
|
winId: win.windowId,
|
|
472
|
-
patch: { winWidth:
|
|
597
|
+
patch: { winWidth: win.WIN_MIN_WIDTH }
|
|
473
598
|
}
|
|
474
599
|
]);
|
|
475
600
|
}
|
|
476
|
-
requestAnimationFrame(
|
|
601
|
+
requestAnimationFrame(
|
|
602
|
+
() => resizer.e(getRafResizeDependencies(win.windowId), commit, neighbourLimit)
|
|
603
|
+
);
|
|
477
604
|
},
|
|
478
|
-
w: (resizeDep, commit) => {
|
|
605
|
+
w: (resizeDep, commit, neighbourLimit) => {
|
|
479
606
|
const { wsRect, win, winBox, x } = resizeDep;
|
|
480
607
|
if (!win.resizeAction)
|
|
481
608
|
return;
|
|
482
609
|
if (!winBox)
|
|
483
610
|
return;
|
|
484
|
-
const minWinWidth = winBox.right - x <= win.WIN_MIN_WIDTH;
|
|
485
611
|
const cursorOutOfBounds = x > wsRect.right || x < wsRect.left;
|
|
486
612
|
const sizeDiff = winBox.left - x;
|
|
487
|
-
|
|
613
|
+
const isResizeActive = !cursorOutOfBounds && sizeDiff !== 0;
|
|
614
|
+
const minWinWidth = winBox.right - x <= win.WIN_MIN_WIDTH;
|
|
615
|
+
const rightMostXAtMinWidth = neighbourLimit;
|
|
616
|
+
const isNeighbourLimit = rightMostXAtMinWidth && x < rightMostXAtMinWidth;
|
|
617
|
+
if (isNeighbourLimit) {
|
|
488
618
|
commit([
|
|
489
619
|
{
|
|
490
620
|
winId: win.windowId,
|
|
491
621
|
patch: {
|
|
492
|
-
winWidth:
|
|
622
|
+
winWidth: win.winCoord.pointX - rightMostXAtMinWidth + win.winWidth,
|
|
623
|
+
winCoord: {
|
|
624
|
+
pointX: rightMostXAtMinWidth,
|
|
625
|
+
pointY: win.winCoord.pointY
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
]);
|
|
630
|
+
} else if (!minWinWidth && isResizeActive) {
|
|
631
|
+
commit([
|
|
632
|
+
{
|
|
633
|
+
winId: win.windowId,
|
|
634
|
+
patch: {
|
|
635
|
+
winWidth: win.winWidth + sizeDiff,
|
|
493
636
|
winCoord: { pointX: x, pointY: win.winCoord.pointY }
|
|
494
637
|
}
|
|
495
638
|
}
|
|
496
639
|
]);
|
|
640
|
+
} else if (minWinWidth && isResizeActive) {
|
|
641
|
+
commit([
|
|
642
|
+
{
|
|
643
|
+
winId: win.windowId,
|
|
644
|
+
patch: {
|
|
645
|
+
winCoord: {
|
|
646
|
+
pointX: win.winCoord.pointX + win.winWidth - win.WIN_MIN_WIDTH,
|
|
647
|
+
pointY: win.winCoord.pointY
|
|
648
|
+
},
|
|
649
|
+
winWidth: win.WIN_MIN_WIDTH
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
]);
|
|
497
653
|
}
|
|
498
|
-
requestAnimationFrame(
|
|
654
|
+
requestAnimationFrame(
|
|
655
|
+
() => resizer.w(getRafResizeDependencies(win.windowId), commit, neighbourLimit)
|
|
656
|
+
);
|
|
499
657
|
},
|
|
500
|
-
n: (resizeDep, commit) => {
|
|
658
|
+
n: (resizeDep, commit, neighbourLimit) => {
|
|
501
659
|
const { wsRect, win, winBox, y } = resizeDep;
|
|
502
660
|
if (!win.resizeAction)
|
|
503
661
|
return;
|
|
504
662
|
if (!winBox)
|
|
505
663
|
return;
|
|
506
|
-
const minWinHeight = winBox.bottom - y <= win.WIN_MIN_HEIGHT;
|
|
507
664
|
const cursorOutOfBounds = y > wsRect.bottom || y < wsRect.top;
|
|
508
665
|
const sizeDiff = winBox.top - y;
|
|
509
|
-
|
|
666
|
+
const isResizeActive = !cursorOutOfBounds && sizeDiff !== 0;
|
|
667
|
+
const minWinHeight = winBox.bottom - y <= win.WIN_MIN_HEIGHT;
|
|
668
|
+
const bottomMostYAtMinWidth = neighbourLimit;
|
|
669
|
+
const isNeighbourLimit = bottomMostYAtMinWidth && y < bottomMostYAtMinWidth;
|
|
670
|
+
if (isNeighbourLimit && isResizeActive) {
|
|
510
671
|
commit([
|
|
511
672
|
{
|
|
512
673
|
winId: win.windowId,
|
|
513
674
|
patch: {
|
|
514
|
-
winHeight:
|
|
675
|
+
winHeight: win.winCoord.pointY - bottomMostYAtMinWidth + win.winHeight,
|
|
676
|
+
winCoord: {
|
|
677
|
+
pointX: win.winCoord.pointX,
|
|
678
|
+
pointY: bottomMostYAtMinWidth
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
]);
|
|
683
|
+
} else if (!minWinHeight && isResizeActive) {
|
|
684
|
+
commit([
|
|
685
|
+
{
|
|
686
|
+
winId: win.windowId,
|
|
687
|
+
patch: {
|
|
688
|
+
winHeight: win.winHeight + sizeDiff,
|
|
515
689
|
winCoord: { pointX: win.winCoord.pointX, pointY: y }
|
|
516
690
|
}
|
|
517
691
|
}
|
|
518
692
|
]);
|
|
693
|
+
} else if (minWinHeight && isResizeActive) {
|
|
694
|
+
commit([
|
|
695
|
+
{
|
|
696
|
+
winId: win.windowId,
|
|
697
|
+
patch: {
|
|
698
|
+
winHeight: win.WIN_MIN_HEIGHT,
|
|
699
|
+
winCoord: {
|
|
700
|
+
pointX: win.winCoord.pointX,
|
|
701
|
+
pointY: win.winCoord.pointY + win.winHeight - win.WIN_MIN_HEIGHT
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
]);
|
|
519
706
|
}
|
|
520
|
-
requestAnimationFrame(
|
|
707
|
+
requestAnimationFrame(
|
|
708
|
+
() => resizer.n(getRafResizeDependencies(win.windowId), commit, neighbourLimit)
|
|
709
|
+
);
|
|
521
710
|
},
|
|
522
|
-
s: (resizeDep, commit) => {
|
|
711
|
+
s: (resizeDep, commit, neighbourLimit) => {
|
|
523
712
|
const { wsRect, win, winBox, y } = resizeDep;
|
|
524
713
|
if (!win.resizeAction)
|
|
525
714
|
return;
|
|
526
715
|
if (!winBox)
|
|
527
716
|
return;
|
|
528
|
-
const minWinHeight = y - winBox.top < win.WIN_MIN_HEIGHT;
|
|
529
717
|
const cursorOutOfBounds = y > wsRect.bottom || y < wsRect.top;
|
|
530
718
|
const sizeDiff = y - winBox.bottom;
|
|
531
|
-
|
|
719
|
+
const isResizeActive = !cursorOutOfBounds && sizeDiff !== 0;
|
|
720
|
+
const minWinHeight = y - winBox.top < win.WIN_MIN_HEIGHT;
|
|
721
|
+
const topMostYAtMinWidth = neighbourLimit;
|
|
722
|
+
const isNeighbourLimit = topMostYAtMinWidth && y > topMostYAtMinWidth;
|
|
723
|
+
if (isNeighbourLimit && isResizeActive) {
|
|
532
724
|
commit([
|
|
533
725
|
{
|
|
534
726
|
winId: win.windowId,
|
|
535
727
|
patch: {
|
|
536
|
-
winHeight:
|
|
728
|
+
winHeight: topMostYAtMinWidth - win.winCoord.pointY
|
|
537
729
|
}
|
|
538
730
|
}
|
|
539
731
|
]);
|
|
732
|
+
} else if (!minWinHeight && isResizeActive) {
|
|
733
|
+
commit([
|
|
734
|
+
{
|
|
735
|
+
winId: win.windowId,
|
|
736
|
+
patch: {
|
|
737
|
+
winHeight: win.winHeight + sizeDiff
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
]);
|
|
741
|
+
} else if (minWinHeight && isResizeActive) {
|
|
742
|
+
commit([
|
|
743
|
+
{
|
|
744
|
+
winId: win.windowId,
|
|
745
|
+
patch: { winHeight: win.WIN_MIN_HEIGHT }
|
|
746
|
+
}
|
|
747
|
+
]);
|
|
540
748
|
}
|
|
541
|
-
requestAnimationFrame(
|
|
749
|
+
requestAnimationFrame(
|
|
750
|
+
() => resizer.s(getRafResizeDependencies(win.windowId), commit, neighbourLimit)
|
|
751
|
+
);
|
|
542
752
|
},
|
|
543
753
|
nw: (resizeDep, commit) => {
|
|
544
754
|
const { wsRect, win, winBox, x, y } = resizeDep;
|
|
@@ -550,37 +760,27 @@ var resizer = {
|
|
|
550
760
|
const cursorOutOfBoundsX = x > wsRect.right || x < wsRect.left;
|
|
551
761
|
const isCursorOutOfBounds = cursorOutOfBoundsY || cursorOutOfBoundsX;
|
|
552
762
|
if (isCursorOutOfBounds) {
|
|
553
|
-
|
|
763
|
+
return;
|
|
554
764
|
}
|
|
555
765
|
const minWinHeight = winBox.bottom - y <= win.WIN_MIN_HEIGHT;
|
|
556
766
|
const minWinWidth = winBox.right - x <= win.WIN_MIN_WIDTH;
|
|
557
767
|
const sizeDiffY = winBox.top - y;
|
|
558
768
|
const sizeDiffX = winBox.left - x;
|
|
559
|
-
const stagedChagnes = [];
|
|
560
769
|
if (sizeDiffY !== 0 || sizeDiffX !== 0) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
770
|
+
commit([
|
|
771
|
+
{
|
|
772
|
+
winId: win.windowId,
|
|
773
|
+
patch: {
|
|
774
|
+
winWidth: minWinWidth ? win.WIN_MIN_WIDTH : win.winWidth + sizeDiffX,
|
|
775
|
+
winHeight: minWinHeight ? win.WIN_MIN_HEIGHT : win.winHeight + sizeDiffY,
|
|
776
|
+
winCoord: {
|
|
777
|
+
pointX: minWinWidth ? win.winCoord.pointX + win.winWidth - win.WIN_MIN_WIDTH : x,
|
|
778
|
+
pointY: minWinHeight ? win.winCoord.pointY + win.winHeight - win.WIN_MIN_HEIGHT : y
|
|
779
|
+
}
|
|
567
780
|
}
|
|
568
781
|
}
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
if (!minWinHeight && sizeDiffY !== 0) {
|
|
572
|
-
stagedChagnes.push({
|
|
573
|
-
winId: win.windowId,
|
|
574
|
-
patch: { winHeight: Math.round(win.winHeight + sizeDiffY) }
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
if (!minWinWidth && sizeDiffX !== 0) {
|
|
578
|
-
stagedChagnes.push({
|
|
579
|
-
winId: win.windowId,
|
|
580
|
-
patch: { winWidth: Math.round(win.winWidth + sizeDiffX) }
|
|
581
|
-
});
|
|
782
|
+
]);
|
|
582
783
|
}
|
|
583
|
-
commit(stagedChagnes);
|
|
584
784
|
requestAnimationFrame(() => resizer.nw(getRafResizeDependencies(win.windowId), commit));
|
|
585
785
|
},
|
|
586
786
|
se: (resizeDep, commit) => {
|
|
@@ -600,28 +800,139 @@ var getRafResizeDependencies = (winId) => {
|
|
|
600
800
|
const win = windowRegistry[winId].getState();
|
|
601
801
|
const winBox = win.winElement?.getBoundingClientRect();
|
|
602
802
|
const wsRect = useWorkspaceState.getState().wsRect;
|
|
603
|
-
const { x, y } =
|
|
803
|
+
const { x, y } = cursorPosition;
|
|
604
804
|
return { wsRect, win, winBox, x, y };
|
|
605
805
|
};
|
|
606
806
|
|
|
807
|
+
// src/window-manager/internal/runtime/history-resolver/app-history.ts
|
|
808
|
+
var MAX_HISTORY = 100;
|
|
809
|
+
var excludedCommands = [
|
|
810
|
+
"UPDATE_WORKSPACE_SIZE",
|
|
811
|
+
"SET_RESPONSIVE_BREAK",
|
|
812
|
+
"SET_WORKSPACE_FEATURES",
|
|
813
|
+
"APPLY_PREVIOUS",
|
|
814
|
+
"APPLY_NEXT",
|
|
815
|
+
"ENABLE_DRAG",
|
|
816
|
+
"ENABLE_RESIZE"
|
|
817
|
+
];
|
|
818
|
+
var appHistory = {
|
|
819
|
+
snapshots: [],
|
|
820
|
+
ptr: -1
|
|
821
|
+
};
|
|
822
|
+
function saveSnapshot(cmd) {
|
|
823
|
+
if (excludedCommands.includes(cmd))
|
|
824
|
+
return;
|
|
825
|
+
const snapshot = getSnapshot();
|
|
826
|
+
if (!snapshot)
|
|
827
|
+
return;
|
|
828
|
+
if (appHistory.ptr < appHistory.snapshots.length - 1) {
|
|
829
|
+
appHistory.snapshots = appHistory.snapshots.slice(0, appHistory.ptr + 1);
|
|
830
|
+
}
|
|
831
|
+
appHistory.snapshots.push(snapshot);
|
|
832
|
+
if (appHistory.snapshots.length > MAX_HISTORY) {
|
|
833
|
+
appHistory.snapshots.shift();
|
|
834
|
+
}
|
|
835
|
+
appHistory.ptr = appHistory.snapshots.length - 1;
|
|
836
|
+
}
|
|
837
|
+
var getSnapshot = () => {
|
|
838
|
+
const { wsElement, setWsElement, ...wsSnapshot } = useWorkspaceState.getState();
|
|
839
|
+
const wsUpdate = structuredClone(wsSnapshot);
|
|
840
|
+
const winStateSnapshots = [];
|
|
841
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
842
|
+
const { winElement, setWinElement, isDragging, resizeAction, ...windowSnapshot } = windowRegistry[key].getState();
|
|
843
|
+
winStateSnapshots.push(structuredClone(windowSnapshot));
|
|
844
|
+
}
|
|
845
|
+
if (!isValidSnapshot(winStateSnapshots)) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
ws: wsUpdate,
|
|
850
|
+
winState: winStateSnapshots
|
|
851
|
+
};
|
|
852
|
+
};
|
|
853
|
+
var isValidSnapshot = (winStateSnapshots) => {
|
|
854
|
+
if (appHistory.ptr < 0)
|
|
855
|
+
return true;
|
|
856
|
+
const prevSnapshot = appHistory.snapshots[appHistory.ptr].winState;
|
|
857
|
+
for (const newWinState of winStateSnapshots) {
|
|
858
|
+
for (const prevWinState of prevSnapshot) {
|
|
859
|
+
if (newWinState.windowId !== prevWinState.windowId)
|
|
860
|
+
continue;
|
|
861
|
+
if (newWinState.zIndex !== prevWinState.zIndex || newWinState.winVisualState !== prevWinState.winVisualState || newWinState.isWindowClosed !== prevWinState.isWindowClosed || newWinState.winCoord?.pointX !== prevWinState.winCoord?.pointX || newWinState.winCoord?.pointY !== prevWinState.winCoord?.pointY || newWinState.winWidth !== prevWinState.winWidth || newWinState.winHeight !== prevWinState.winHeight)
|
|
862
|
+
return true;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return false;
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
// src/window-manager/internal/runtime/history-resolver/history-commands.ts
|
|
869
|
+
var historyCommandResolver = {
|
|
870
|
+
APPLY_PREVIOUS: () => {
|
|
871
|
+
if (appHistory.ptr <= 0)
|
|
872
|
+
return { ws: {}, win: [] };
|
|
873
|
+
appHistory.ptr -= 1;
|
|
874
|
+
const snapshot = appHistory.snapshots[appHistory.ptr];
|
|
875
|
+
const wsUpdate = snapshot.ws;
|
|
876
|
+
const winBatchUpdate = [];
|
|
877
|
+
snapshot.winState.forEach((win) => {
|
|
878
|
+
const { windowId, setWinElement, ...state } = win;
|
|
879
|
+
winBatchUpdate.push({
|
|
880
|
+
winId: windowId,
|
|
881
|
+
patch: { ...state }
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
return {
|
|
885
|
+
ws: wsUpdate,
|
|
886
|
+
win: winBatchUpdate
|
|
887
|
+
};
|
|
888
|
+
},
|
|
889
|
+
APPLY_NEXT: () => {
|
|
890
|
+
if (appHistory.ptr >= appHistory.snapshots.length - 1)
|
|
891
|
+
return { ws: {}, win: [] };
|
|
892
|
+
appHistory.ptr += 1;
|
|
893
|
+
const snapshot = appHistory.snapshots[appHistory.ptr];
|
|
894
|
+
const wsUpdate = snapshot.ws;
|
|
895
|
+
const winBatchUpdate = [];
|
|
896
|
+
snapshot.winState.forEach((win) => {
|
|
897
|
+
const { windowId, setWinElement, ...state } = win;
|
|
898
|
+
winBatchUpdate.push({
|
|
899
|
+
winId: windowId,
|
|
900
|
+
patch: { ...state }
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
return {
|
|
904
|
+
ws: wsUpdate,
|
|
905
|
+
win: winBatchUpdate
|
|
906
|
+
};
|
|
907
|
+
},
|
|
908
|
+
CLEAR_HISTORY: () => {
|
|
909
|
+
appHistory.ptr = -1;
|
|
910
|
+
appHistory.snapshots = [];
|
|
911
|
+
return {
|
|
912
|
+
ws: {},
|
|
913
|
+
win: []
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
|
|
607
918
|
// src/window-manager/internal/runtime/rwm-runtime.ts
|
|
608
919
|
var rwmRuntime = {
|
|
609
920
|
dispatch: ({ subsystem, cmd, targetWinId, ctx }) => {
|
|
610
921
|
switch (subsystem) {
|
|
611
922
|
case "WORKSPACE": {
|
|
612
923
|
const stagedChanges = workspaceCommandResolver[cmd](targetWinId, ctx);
|
|
613
|
-
|
|
924
|
+
commitBatch(stagedChanges);
|
|
614
925
|
break;
|
|
615
926
|
}
|
|
616
927
|
case "DRAG": {
|
|
617
|
-
if (
|
|
928
|
+
if (useWorkspaceState.getState().isBelowBreakPoint)
|
|
618
929
|
return;
|
|
619
930
|
const stagedChanges = dragCommandResolver[cmd](targetWinId);
|
|
620
931
|
commitToWindow(stagedChanges);
|
|
621
932
|
break;
|
|
622
933
|
}
|
|
623
934
|
case "DOCK": {
|
|
624
|
-
const { wsRect } =
|
|
935
|
+
const { wsRect } = useWorkspaceState.getState();
|
|
625
936
|
const stagedChanges = dockCommandResolver[cmd](targetWinId, wsRect);
|
|
626
937
|
commitToWindow(stagedChanges);
|
|
627
938
|
break;
|
|
@@ -631,24 +942,29 @@ var rwmRuntime = {
|
|
|
631
942
|
commitToWindow(stagedChanges);
|
|
632
943
|
break;
|
|
633
944
|
}
|
|
634
|
-
case "STACK": {
|
|
635
|
-
const stagedChanges = stackCommandResolver[cmd](targetWinId);
|
|
636
|
-
commitToWindow(stagedChanges);
|
|
637
|
-
break;
|
|
638
|
-
}
|
|
639
945
|
case "FOCUS": {
|
|
640
946
|
const stagedChanges = focusCommandResolver[cmd](targetWinId);
|
|
641
947
|
commitBatch(stagedChanges);
|
|
642
948
|
break;
|
|
643
949
|
}
|
|
950
|
+
case "HISTORY": {
|
|
951
|
+
const stagedChanges = historyCommandResolver[cmd]();
|
|
952
|
+
commitBatch(stagedChanges);
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
default:
|
|
956
|
+
throw new Error(
|
|
957
|
+
`Unregistered rwmRuntime subsystem called: ${{ subsystem, cmd, targetWinId, ctx }}`
|
|
958
|
+
);
|
|
644
959
|
}
|
|
960
|
+
saveSnapshot(cmd);
|
|
645
961
|
}
|
|
646
962
|
};
|
|
647
963
|
var rafRuntime = {
|
|
648
964
|
dispatch: ({ subsystem, cmd, targetWinId }) => {
|
|
649
965
|
switch (subsystem) {
|
|
650
966
|
case "RAF_DRAG": {
|
|
651
|
-
if (
|
|
967
|
+
if (useWorkspaceState.getState().isBelowBreakPoint)
|
|
652
968
|
return;
|
|
653
969
|
rafDragLoopResolver[cmd](targetWinId, commitToWindow);
|
|
654
970
|
break;
|
|
@@ -657,6 +973,10 @@ var rafRuntime = {
|
|
|
657
973
|
rafResizeLoopResolver[cmd](targetWinId, commitToWindow);
|
|
658
974
|
break;
|
|
659
975
|
}
|
|
976
|
+
default:
|
|
977
|
+
throw new Error(
|
|
978
|
+
`Unregistered rafRuntime subsystem called: ${{ subsystem, cmd, targetWinId }}`
|
|
979
|
+
);
|
|
660
980
|
}
|
|
661
981
|
}
|
|
662
982
|
};
|
|
@@ -747,13 +1067,6 @@ var focusApi = {
|
|
|
747
1067
|
}
|
|
748
1068
|
};
|
|
749
1069
|
|
|
750
|
-
// src/window-manager/internal/features/stack/stack-api.ts
|
|
751
|
-
var stackApi = {
|
|
752
|
-
resetStack: () => {
|
|
753
|
-
rwmRuntime.dispatch({ subsystem: "STACK", cmd: "RESET_STACK" });
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
|
|
757
1070
|
// src/window-manager/internal/features/workspace/workspace-api.ts
|
|
758
1071
|
var wsApi = {
|
|
759
1072
|
/**
|
|
@@ -773,36 +1086,35 @@ var wsApi = {
|
|
|
773
1086
|
ctx: { responsiveBreak: breakPoint }
|
|
774
1087
|
});
|
|
775
1088
|
},
|
|
776
|
-
setWsFeatures: ({
|
|
1089
|
+
setWsFeatures: ({ isDockPanelEnabled = true, isGridEnabled = true }) => {
|
|
777
1090
|
rwmRuntime.dispatch({
|
|
778
1091
|
subsystem: "WORKSPACE",
|
|
779
1092
|
cmd: "SET_WORKSPACE_FEATURES",
|
|
780
|
-
ctx: {
|
|
1093
|
+
ctx: { isDockPanelEnabled, isGridEnabled }
|
|
781
1094
|
});
|
|
782
1095
|
},
|
|
783
|
-
|
|
784
|
-
rwmRuntime.dispatch({ subsystem: "WORKSPACE", cmd: "
|
|
1096
|
+
updateWsSize: () => {
|
|
1097
|
+
rwmRuntime.dispatch({ subsystem: "WORKSPACE", cmd: "UPDATE_WORKSPACE_SIZE" });
|
|
785
1098
|
}
|
|
786
1099
|
};
|
|
787
1100
|
|
|
788
1101
|
// src/window-manager/rwm.ts
|
|
789
|
-
var {
|
|
1102
|
+
var { updateWsSize, ...publicWsApi } = wsApi;
|
|
790
1103
|
var rwm = {
|
|
791
1104
|
dockApi,
|
|
792
1105
|
focusApi,
|
|
793
|
-
stackApi,
|
|
794
1106
|
workspaceApi: publicWsApi,
|
|
795
1107
|
/**
|
|
796
1108
|
* @about
|
|
797
1109
|
* Zustand hook, can be used to access the current state of the workspace by either
|
|
798
|
-
* calling `const { <someState> } =
|
|
799
|
-
* `
|
|
1110
|
+
* calling `const { <someState> } = workspaceState()` inside a component or by calling
|
|
1111
|
+
* `workspaceState.getState()` anywhere.
|
|
800
1112
|
*
|
|
801
1113
|
* @note
|
|
802
1114
|
* The hook also exposes the `setState()` method, however, this is highly discouraged. Prefer calling
|
|
803
1115
|
* the exposed apis in rwm for state mutation.
|
|
804
1116
|
*/
|
|
805
|
-
|
|
1117
|
+
workspaceState: useWorkspaceState,
|
|
806
1118
|
/**
|
|
807
1119
|
* @about
|
|
808
1120
|
* use the syntax `const { <someState> } = windowRegistry[<winId>]()` inside a component to access
|
|
@@ -817,14 +1129,14 @@ var rwm = {
|
|
|
817
1129
|
var rwm_default = rwm;
|
|
818
1130
|
|
|
819
1131
|
// src/window-manager/workspace-layout.tsx
|
|
820
|
-
import { useEffect as
|
|
1132
|
+
import { useEffect as useEffect4, useRef } from "react";
|
|
821
1133
|
|
|
822
1134
|
// src/window-manager/internal/features/docking/docking-controls.tsx
|
|
823
1135
|
import { useState } from "react";
|
|
824
1136
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
825
1137
|
function DockingControls() {
|
|
826
1138
|
const [isHovering, setIsHovering] = useState(false);
|
|
827
|
-
const { activeWindowId,
|
|
1139
|
+
const { activeWindowId, isDockPanelEnabled, isBelowBreakPoint } = useWorkspaceState();
|
|
828
1140
|
const { isDragging } = windowRegistry[activeWindowId]();
|
|
829
1141
|
const cornerDockControl = /* @__PURE__ */ jsxs("div", { className: `flex xl:p-0 shrink-0 gap-0.5`, children: [
|
|
830
1142
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center gap-0.5", children: [
|
|
@@ -892,7 +1204,7 @@ function DockingControls() {
|
|
|
892
1204
|
}
|
|
893
1205
|
)
|
|
894
1206
|
] });
|
|
895
|
-
const
|
|
1207
|
+
const windowDockPanel = /* @__PURE__ */ jsx(
|
|
896
1208
|
"span",
|
|
897
1209
|
{
|
|
898
1210
|
className: "pointer-events-auto px-4 pb-3",
|
|
@@ -916,7 +1228,7 @@ function DockingControls() {
|
|
|
916
1228
|
);
|
|
917
1229
|
if (isBelowBreakPoint)
|
|
918
1230
|
return;
|
|
919
|
-
if (!
|
|
1231
|
+
if (!isDockPanelEnabled)
|
|
920
1232
|
return;
|
|
921
1233
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
922
1234
|
"div",
|
|
@@ -926,7 +1238,7 @@ function DockingControls() {
|
|
|
926
1238
|
transition-all duration-500
|
|
927
1239
|
absolute z-50 flex items-center justify-center
|
|
928
1240
|
w-full mx-auto pointer-events-none`,
|
|
929
|
-
children:
|
|
1241
|
+
children: windowDockPanel
|
|
930
1242
|
}
|
|
931
1243
|
) });
|
|
932
1244
|
}
|
|
@@ -943,6 +1255,9 @@ var resizeApi = {
|
|
|
943
1255
|
rafRuntime.dispatch({ targetWinId: winId, subsystem: "RAF_RESIZE", cmd: "LOOP_RESIZE" });
|
|
944
1256
|
},
|
|
945
1257
|
stopResize: (winId) => {
|
|
1258
|
+
const isNotResizing = !windowRegistry[winId].getState().resizeAction;
|
|
1259
|
+
if (isNotResizing)
|
|
1260
|
+
return;
|
|
946
1261
|
rwmRuntime.dispatch({
|
|
947
1262
|
targetWinId: winId,
|
|
948
1263
|
subsystem: "RESIZE",
|
|
@@ -956,20 +1271,34 @@ var resizeApi = {
|
|
|
956
1271
|
import { useEffect } from "react";
|
|
957
1272
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
958
1273
|
function CursorMoveListener() {
|
|
959
|
-
const { setXY } = useCursorState();
|
|
960
1274
|
useEffect(() => {
|
|
961
1275
|
const handlePointerMove = (e) => {
|
|
962
1276
|
e.preventDefault();
|
|
963
|
-
|
|
1277
|
+
setCursorPosition({ x: e.clientX, y: e.clientY });
|
|
964
1278
|
};
|
|
965
1279
|
window.addEventListener("pointermove", handlePointerMove);
|
|
966
1280
|
return () => window.removeEventListener("pointermove", handlePointerMove);
|
|
967
|
-
}, [
|
|
1281
|
+
}, []);
|
|
968
1282
|
return /* @__PURE__ */ jsx2(Fragment2, {});
|
|
969
1283
|
}
|
|
970
1284
|
|
|
971
1285
|
// src/window-manager/internal/features/workspace/workspace-resize-listener.tsx
|
|
972
1286
|
import { useEffect as useEffect2 } from "react";
|
|
1287
|
+
|
|
1288
|
+
// src/window-manager/internal/features/history/history-api.ts
|
|
1289
|
+
var appHistoryApi = {
|
|
1290
|
+
moveToPreviousSnapshot: () => {
|
|
1291
|
+
rwmRuntime.dispatch({ subsystem: "HISTORY", cmd: "APPLY_PREVIOUS" });
|
|
1292
|
+
},
|
|
1293
|
+
moveToNextSnapshot: () => {
|
|
1294
|
+
rwmRuntime.dispatch({ subsystem: "HISTORY", cmd: "APPLY_NEXT" });
|
|
1295
|
+
},
|
|
1296
|
+
clearHistory: () => {
|
|
1297
|
+
rwmRuntime.dispatch({ subsystem: "HISTORY", cmd: "CLEAR_HISTORY" });
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
// src/window-manager/internal/features/workspace/workspace-resize-listener.tsx
|
|
973
1302
|
import { Fragment as Fragment3, jsx as jsx3 } from "react/jsx-runtime";
|
|
974
1303
|
function WorkspaceResizeListener() {
|
|
975
1304
|
const { wsElement } = useWorkspaceState();
|
|
@@ -977,8 +1306,8 @@ function WorkspaceResizeListener() {
|
|
|
977
1306
|
if (!wsElement)
|
|
978
1307
|
return;
|
|
979
1308
|
const onResize = () => {
|
|
980
|
-
wsApi.
|
|
981
|
-
|
|
1309
|
+
wsApi.updateWsSize();
|
|
1310
|
+
appHistoryApi.clearHistory();
|
|
982
1311
|
};
|
|
983
1312
|
onResize();
|
|
984
1313
|
const observer = new ResizeObserver(onResize);
|
|
@@ -999,6 +1328,9 @@ var dragApi = {
|
|
|
999
1328
|
rafRuntime.dispatch({ targetWinId, subsystem: "RAF_DRAG", cmd: "LOOP_DRAG" });
|
|
1000
1329
|
},
|
|
1001
1330
|
stopDrag: (targetWinId) => {
|
|
1331
|
+
const isNotDragging = !windowRegistry[targetWinId].getState().isDragging;
|
|
1332
|
+
if (isNotDragging)
|
|
1333
|
+
return;
|
|
1002
1334
|
rwmRuntime.dispatch({
|
|
1003
1335
|
targetWinId,
|
|
1004
1336
|
subsystem: "DRAG",
|
|
@@ -1007,12 +1339,36 @@ var dragApi = {
|
|
|
1007
1339
|
}
|
|
1008
1340
|
};
|
|
1009
1341
|
|
|
1342
|
+
// src/window-manager/internal/features/history/history-keys-listener.tsx
|
|
1343
|
+
import { useEffect as useEffect3 } from "react";
|
|
1344
|
+
import { Fragment as Fragment4, jsx as jsx4 } from "react/jsx-runtime";
|
|
1345
|
+
function HistoryKeysListener() {
|
|
1346
|
+
useEffect3(() => {
|
|
1347
|
+
const handleKeyDown = (e) => {
|
|
1348
|
+
const ctrlOrCmd = e.metaKey || e.ctrlKey;
|
|
1349
|
+
if (!ctrlOrCmd)
|
|
1350
|
+
return;
|
|
1351
|
+
if (e.key.toLowerCase() === "z" && !e.shiftKey) {
|
|
1352
|
+
e.preventDefault();
|
|
1353
|
+
appHistoryApi.moveToPreviousSnapshot();
|
|
1354
|
+
}
|
|
1355
|
+
if (e.key.toLowerCase() === "z" && e.shiftKey) {
|
|
1356
|
+
e.preventDefault();
|
|
1357
|
+
appHistoryApi.moveToNextSnapshot();
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1361
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1362
|
+
}, []);
|
|
1363
|
+
return /* @__PURE__ */ jsx4(Fragment4, {});
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1010
1366
|
// src/window-manager/workspace-layout.tsx
|
|
1011
|
-
import { jsx as
|
|
1367
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1012
1368
|
function WorkspaceLayout({ children, className }) {
|
|
1013
1369
|
const { setWsElement, wsElement, isBelowBreakPoint, activeWindowId } = useWorkspaceState();
|
|
1014
1370
|
const workspaceRef = useRef(null);
|
|
1015
|
-
|
|
1371
|
+
useEffect4(() => {
|
|
1016
1372
|
if (!workspaceRef.current)
|
|
1017
1373
|
return;
|
|
1018
1374
|
setWsElement(workspaceRef.current);
|
|
@@ -1030,10 +1386,11 @@ function WorkspaceLayout({ children, className }) {
|
|
|
1030
1386
|
onPointerUp: disabledDragAndResize,
|
|
1031
1387
|
className: className ? className : "fixed overflow-hidden h-full w-full touch-none -z-50",
|
|
1032
1388
|
children: [
|
|
1033
|
-
/* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ jsx5(WorkspaceResizeListener, {}),
|
|
1390
|
+
/* @__PURE__ */ jsx5(HistoryKeysListener, {}),
|
|
1391
|
+
/* @__PURE__ */ jsx5(CursorMoveListener, {}),
|
|
1035
1392
|
/* @__PURE__ */ jsxs2("div", { className: " w-full h-full relative overflow-hidden", children: [
|
|
1036
|
-
!isBelowBreakPoint && /* @__PURE__ */
|
|
1393
|
+
!isBelowBreakPoint && /* @__PURE__ */ jsx5(DockingControls, {}),
|
|
1037
1394
|
children
|
|
1038
1395
|
] })
|
|
1039
1396
|
]
|
|
@@ -1042,15 +1399,15 @@ function WorkspaceLayout({ children, className }) {
|
|
|
1042
1399
|
}
|
|
1043
1400
|
|
|
1044
1401
|
// src/window-manager/registration/window-store-factory.tsx
|
|
1045
|
-
import { create as
|
|
1402
|
+
import { create as create2 } from "zustand";
|
|
1046
1403
|
|
|
1047
1404
|
// src/window-manager/internal/features/window-layout.tsx
|
|
1048
|
-
import { useEffect as
|
|
1405
|
+
import { useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
1049
1406
|
|
|
1050
1407
|
// src/window-manager/internal/assets/svg-win-icons.tsx
|
|
1051
|
-
import { jsx as
|
|
1408
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1052
1409
|
function IconWinMaximize({ color }) {
|
|
1053
|
-
return /* @__PURE__ */
|
|
1410
|
+
return /* @__PURE__ */ jsx6(
|
|
1054
1411
|
"svg",
|
|
1055
1412
|
{
|
|
1056
1413
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1062,7 +1419,7 @@ function IconWinMaximize({ color }) {
|
|
|
1062
1419
|
stroke: color ? color : "#cccccc",
|
|
1063
1420
|
color: color ? color : "#cccccc",
|
|
1064
1421
|
className: "size-6",
|
|
1065
|
-
children: /* @__PURE__ */
|
|
1422
|
+
children: /* @__PURE__ */ jsx6(
|
|
1066
1423
|
"path",
|
|
1067
1424
|
{
|
|
1068
1425
|
strokeLinecap: "round",
|
|
@@ -1074,7 +1431,7 @@ function IconWinMaximize({ color }) {
|
|
|
1074
1431
|
);
|
|
1075
1432
|
}
|
|
1076
1433
|
function IconWinDemaximize({ color }) {
|
|
1077
|
-
return /* @__PURE__ */
|
|
1434
|
+
return /* @__PURE__ */ jsx6(
|
|
1078
1435
|
"svg",
|
|
1079
1436
|
{
|
|
1080
1437
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1086,7 +1443,7 @@ function IconWinDemaximize({ color }) {
|
|
|
1086
1443
|
stroke: color ? color : "#cccccc",
|
|
1087
1444
|
color: color ? color : "#cccccc",
|
|
1088
1445
|
className: "size-6",
|
|
1089
|
-
children: /* @__PURE__ */
|
|
1446
|
+
children: /* @__PURE__ */ jsx6(
|
|
1090
1447
|
"path",
|
|
1091
1448
|
{
|
|
1092
1449
|
strokeLinecap: "round",
|
|
@@ -1098,7 +1455,7 @@ function IconWinDemaximize({ color }) {
|
|
|
1098
1455
|
);
|
|
1099
1456
|
}
|
|
1100
1457
|
function IconWinMinimize({ color }) {
|
|
1101
|
-
return /* @__PURE__ */
|
|
1458
|
+
return /* @__PURE__ */ jsx6(
|
|
1102
1459
|
"svg",
|
|
1103
1460
|
{
|
|
1104
1461
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1110,31 +1467,30 @@ function IconWinMinimize({ color }) {
|
|
|
1110
1467
|
stroke: color ? color : "#cccccc",
|
|
1111
1468
|
color: color ? color : "#cccccc",
|
|
1112
1469
|
className: "size-6",
|
|
1113
|
-
children: /* @__PURE__ */
|
|
1470
|
+
children: /* @__PURE__ */ jsx6("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18 18 6M6 6l12 12" })
|
|
1114
1471
|
}
|
|
1115
1472
|
);
|
|
1116
1473
|
}
|
|
1117
1474
|
|
|
1118
1475
|
// src/window-manager/internal/features/grid/grid-orchestrator.ts
|
|
1119
1476
|
var tolerance = 4;
|
|
1120
|
-
var
|
|
1121
|
-
|
|
1477
|
+
var resizeOrchestrator = {
|
|
1478
|
+
initializeResize: (winId, direction) => {
|
|
1122
1479
|
if (!useWorkspaceState.getState().isGridEnabled)
|
|
1123
1480
|
return;
|
|
1124
1481
|
if (getOpenWinCount() < 1)
|
|
1125
1482
|
throw new Error(`gridOrchestrator initalized but all windows are closed`);
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
attachAdjacentGridBehavior(winId);
|
|
1483
|
+
initNeighbourResizeBehavior(winId, /* @__PURE__ */ new Set(), direction);
|
|
1484
|
+
resizeApi.startResize(winId, direction);
|
|
1129
1485
|
}
|
|
1130
1486
|
};
|
|
1131
|
-
var
|
|
1487
|
+
var initNeighbourResizeBehavior = (winId, visited, direction) => {
|
|
1132
1488
|
if (visited.has(winId))
|
|
1133
1489
|
return;
|
|
1134
1490
|
else
|
|
1135
1491
|
visited.add(winId);
|
|
1136
1492
|
const thisWin = windowRegistry[winId].getState();
|
|
1137
|
-
const currentResize = thisWin.resizeAction;
|
|
1493
|
+
const currentResize = direction ? direction : thisWin.resizeAction;
|
|
1138
1494
|
for (const key of Object.keys(windowRegistry)) {
|
|
1139
1495
|
const remoteWin = windowRegistry[key].getState();
|
|
1140
1496
|
if (remoteWin.windowId === thisWin.windowId)
|
|
@@ -1149,22 +1505,22 @@ var attachAdjacentGridBehavior = (winId, visited = /* @__PURE__ */ new Set()) =>
|
|
|
1149
1505
|
if (currentResize === "e") {
|
|
1150
1506
|
const isRemoteConneted = resizeCase.whenDraggingEast(dependencies);
|
|
1151
1507
|
if (isRemoteConneted)
|
|
1152
|
-
|
|
1508
|
+
initNeighbourResizeBehavior(remoteWin.windowId, visited);
|
|
1153
1509
|
}
|
|
1154
1510
|
if (currentResize === "w") {
|
|
1155
1511
|
const isRemoteConneted = resizeCase.whenDragginWest(dependencies);
|
|
1156
1512
|
if (isRemoteConneted)
|
|
1157
|
-
|
|
1513
|
+
initNeighbourResizeBehavior(remoteWin.windowId, visited);
|
|
1158
1514
|
}
|
|
1159
1515
|
if (currentResize === "n") {
|
|
1160
1516
|
const isRemoteConneted = resizeCase.whenDragginNorth(dependencies);
|
|
1161
1517
|
if (isRemoteConneted)
|
|
1162
|
-
|
|
1518
|
+
initNeighbourResizeBehavior(remoteWin.windowId, visited);
|
|
1163
1519
|
}
|
|
1164
1520
|
if (currentResize === "s") {
|
|
1165
1521
|
const isRemoteConneted = resizeCase.whenDraggingSouth(dependencies);
|
|
1166
1522
|
if (isRemoteConneted)
|
|
1167
|
-
|
|
1523
|
+
initNeighbourResizeBehavior(remoteWin.windowId, visited);
|
|
1168
1524
|
}
|
|
1169
1525
|
}
|
|
1170
1526
|
};
|
|
@@ -1261,13 +1617,6 @@ var buildDependencies = (thisWin, remoteWin) => {
|
|
|
1261
1617
|
isRemoteOutside
|
|
1262
1618
|
};
|
|
1263
1619
|
};
|
|
1264
|
-
var getDraggingWinCount = () => {
|
|
1265
|
-
let isWindowResizingCount = 0;
|
|
1266
|
-
for (const key of Object.keys(windowRegistry))
|
|
1267
|
-
if (windowRegistry[key].getState().resizeAction)
|
|
1268
|
-
isWindowResizingCount++;
|
|
1269
|
-
return isWindowResizingCount;
|
|
1270
|
-
};
|
|
1271
1620
|
var getOpenWinCount = () => {
|
|
1272
1621
|
let openWnidowCount = 0;
|
|
1273
1622
|
for (const key of Object.keys(windowRegistry))
|
|
@@ -1277,18 +1626,17 @@ var getOpenWinCount = () => {
|
|
|
1277
1626
|
};
|
|
1278
1627
|
|
|
1279
1628
|
// src/window-manager/internal/features/resizing/resizing-controls.tsx
|
|
1280
|
-
import { Fragment as
|
|
1629
|
+
import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1281
1630
|
function ResizingControls({ winId }) {
|
|
1282
1631
|
const { winCoord, winWidth, winHeight, resizeAction } = windowRegistry[winId]();
|
|
1283
1632
|
const startResize = (direction) => {
|
|
1284
|
-
|
|
1285
|
-
gridOrchestrator.attachAdjacentGridBehavior(winId);
|
|
1633
|
+
resizeOrchestrator.initializeResize(winId, direction);
|
|
1286
1634
|
};
|
|
1287
1635
|
const stopResize = () => {
|
|
1288
1636
|
resizeApi.stopResize(winId);
|
|
1289
1637
|
};
|
|
1290
|
-
return /* @__PURE__ */ jsxs3(
|
|
1291
|
-
/* @__PURE__ */
|
|
1638
|
+
return /* @__PURE__ */ jsxs3(Fragment5, { children: [
|
|
1639
|
+
/* @__PURE__ */ jsx7(
|
|
1292
1640
|
"span",
|
|
1293
1641
|
{
|
|
1294
1642
|
onPointerUp: stopResize,
|
|
@@ -1300,10 +1648,10 @@ function ResizingControls({ winId }) {
|
|
|
1300
1648
|
left: `${winCoord.pointX + winWidth - 4}px`,
|
|
1301
1649
|
height: `${winHeight}px`
|
|
1302
1650
|
},
|
|
1303
|
-
children: /* @__PURE__ */
|
|
1651
|
+
children: /* @__PURE__ */ jsx7("div", { className: `w-1 h-full bg-zinc-50` })
|
|
1304
1652
|
}
|
|
1305
1653
|
),
|
|
1306
|
-
/* @__PURE__ */
|
|
1654
|
+
/* @__PURE__ */ jsx7(
|
|
1307
1655
|
"span",
|
|
1308
1656
|
{
|
|
1309
1657
|
onPointerUp: stopResize,
|
|
@@ -1315,10 +1663,10 @@ function ResizingControls({ winId }) {
|
|
|
1315
1663
|
left: `${winCoord.pointX - 4}px`,
|
|
1316
1664
|
height: `${winHeight}px`
|
|
1317
1665
|
},
|
|
1318
|
-
children: /* @__PURE__ */
|
|
1666
|
+
children: /* @__PURE__ */ jsx7("div", { className: `w-1 h-full bg-zinc-50` })
|
|
1319
1667
|
}
|
|
1320
1668
|
),
|
|
1321
|
-
/* @__PURE__ */
|
|
1669
|
+
/* @__PURE__ */ jsx7(
|
|
1322
1670
|
"span",
|
|
1323
1671
|
{
|
|
1324
1672
|
onPointerUp: stopResize,
|
|
@@ -1330,10 +1678,10 @@ function ResizingControls({ winId }) {
|
|
|
1330
1678
|
left: `${winCoord.pointX}px`,
|
|
1331
1679
|
width: `${winWidth}px`
|
|
1332
1680
|
},
|
|
1333
|
-
children: /* @__PURE__ */
|
|
1681
|
+
children: /* @__PURE__ */ jsx7("div", { className: `w-full h-1 bg-zinc-50` })
|
|
1334
1682
|
}
|
|
1335
1683
|
),
|
|
1336
|
-
/* @__PURE__ */
|
|
1684
|
+
/* @__PURE__ */ jsx7(
|
|
1337
1685
|
"span",
|
|
1338
1686
|
{
|
|
1339
1687
|
onPointerUp: stopResize,
|
|
@@ -1345,10 +1693,10 @@ function ResizingControls({ winId }) {
|
|
|
1345
1693
|
left: `${winCoord.pointX}px`,
|
|
1346
1694
|
width: `${winWidth}px`
|
|
1347
1695
|
},
|
|
1348
|
-
children: /* @__PURE__ */
|
|
1696
|
+
children: /* @__PURE__ */ jsx7("div", { className: `w-full h-1 bg-zinc-50` })
|
|
1349
1697
|
}
|
|
1350
1698
|
),
|
|
1351
|
-
/* @__PURE__ */
|
|
1699
|
+
/* @__PURE__ */ jsx7(
|
|
1352
1700
|
"span",
|
|
1353
1701
|
{
|
|
1354
1702
|
onPointerUp: stopResize,
|
|
@@ -1361,7 +1709,7 @@ function ResizingControls({ winId }) {
|
|
|
1361
1709
|
}
|
|
1362
1710
|
}
|
|
1363
1711
|
),
|
|
1364
|
-
/* @__PURE__ */
|
|
1712
|
+
/* @__PURE__ */ jsx7(
|
|
1365
1713
|
"span",
|
|
1366
1714
|
{
|
|
1367
1715
|
onPointerUp: stopResize,
|
|
@@ -1374,7 +1722,7 @@ function ResizingControls({ winId }) {
|
|
|
1374
1722
|
}
|
|
1375
1723
|
}
|
|
1376
1724
|
),
|
|
1377
|
-
/* @__PURE__ */
|
|
1725
|
+
/* @__PURE__ */ jsx7(
|
|
1378
1726
|
"span",
|
|
1379
1727
|
{
|
|
1380
1728
|
onPointerUp: stopResize,
|
|
@@ -1382,12 +1730,12 @@ function ResizingControls({ winId }) {
|
|
|
1382
1730
|
id: "win-resize-top-right-all",
|
|
1383
1731
|
className: "fixed h-3 w-3 opacity-60 cursor-ne-resize z-20",
|
|
1384
1732
|
style: {
|
|
1385
|
-
top: `${winCoord.pointY -
|
|
1386
|
-
left: `${winCoord.pointX + winWidth -
|
|
1733
|
+
top: `${winCoord.pointY - 8}px`,
|
|
1734
|
+
left: `${winCoord.pointX + winWidth - 8}px`
|
|
1387
1735
|
}
|
|
1388
1736
|
}
|
|
1389
1737
|
),
|
|
1390
|
-
/* @__PURE__ */
|
|
1738
|
+
/* @__PURE__ */ jsx7(
|
|
1391
1739
|
"span",
|
|
1392
1740
|
{
|
|
1393
1741
|
onPointerUp: stopResize,
|
|
@@ -1395,8 +1743,8 @@ function ResizingControls({ winId }) {
|
|
|
1395
1743
|
id: "win-resize-top-left-all",
|
|
1396
1744
|
className: "fixed h-3 w-3 opacity-60 cursor-nw-resize z-20",
|
|
1397
1745
|
style: {
|
|
1398
|
-
top: `${winCoord.pointY -
|
|
1399
|
-
left: `${winCoord.pointX -
|
|
1746
|
+
top: `${winCoord.pointY - 8}px`,
|
|
1747
|
+
left: `${winCoord.pointX - 8}px`
|
|
1400
1748
|
}
|
|
1401
1749
|
}
|
|
1402
1750
|
)
|
|
@@ -1404,9 +1752,9 @@ function ResizingControls({ winId }) {
|
|
|
1404
1752
|
}
|
|
1405
1753
|
|
|
1406
1754
|
// src/window-manager/internal/features/drag/drag-handle.tsx
|
|
1407
|
-
import { jsx as
|
|
1755
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1408
1756
|
function DragHandle({ winId }) {
|
|
1409
|
-
return /* @__PURE__ */
|
|
1757
|
+
return /* @__PURE__ */ jsx8(
|
|
1410
1758
|
"div",
|
|
1411
1759
|
{
|
|
1412
1760
|
onPointerDown: () => dragApi.startDrag(winId),
|
|
@@ -1420,7 +1768,7 @@ function DragHandle({ winId }) {
|
|
|
1420
1768
|
}
|
|
1421
1769
|
|
|
1422
1770
|
// src/window-manager/internal/features/window-layout.tsx
|
|
1423
|
-
import { Fragment as
|
|
1771
|
+
import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1424
1772
|
function WindowLayout({
|
|
1425
1773
|
children,
|
|
1426
1774
|
windowName,
|
|
@@ -1434,28 +1782,24 @@ function WindowLayout({
|
|
|
1434
1782
|
const { wsElement, wsRect, isBelowBreakPoint } = useWorkspaceState();
|
|
1435
1783
|
const windowRef = useRef2(null);
|
|
1436
1784
|
const {
|
|
1785
|
+
setWinElement,
|
|
1437
1786
|
windowId,
|
|
1438
1787
|
zIndex,
|
|
1439
1788
|
isActive,
|
|
1440
|
-
setWinElement,
|
|
1441
|
-
resetFlag,
|
|
1442
1789
|
winVisualState,
|
|
1443
1790
|
isWindowClosed,
|
|
1444
1791
|
winCoord,
|
|
1445
1792
|
winWidth,
|
|
1446
1793
|
winHeight
|
|
1447
1794
|
} = windowRegistry[winId]();
|
|
1448
|
-
|
|
1795
|
+
useEffect5(() => {
|
|
1449
1796
|
setWinElement(windowRef.current);
|
|
1450
|
-
}, [setWinElement
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
}, [wsElement, resetFlag]);
|
|
1458
|
-
const dockingRoutes = {
|
|
1797
|
+
}, [setWinElement]);
|
|
1798
|
+
useEffect5(() => {
|
|
1799
|
+
dockingResolver[defaultDock](winId);
|
|
1800
|
+
appHistoryApi.clearHistory();
|
|
1801
|
+
}, [wsElement]);
|
|
1802
|
+
const dockingResolver = {
|
|
1459
1803
|
right: dockApi.dockWindowRight,
|
|
1460
1804
|
left: dockApi.dockWindowLeft,
|
|
1461
1805
|
full: dockApi.maximizeWindow,
|
|
@@ -1467,30 +1811,30 @@ function WindowLayout({
|
|
|
1467
1811
|
"bottom-left": dockApi.dockWindowBottomLeft,
|
|
1468
1812
|
default: dockApi.demaximizeWindow
|
|
1469
1813
|
};
|
|
1470
|
-
const maximizeControl = winVisualState === "maximized" ? /* @__PURE__ */
|
|
1814
|
+
const maximizeControl = winVisualState === "maximized" ? /* @__PURE__ */ jsx9(
|
|
1471
1815
|
"button",
|
|
1472
1816
|
{
|
|
1473
1817
|
className: `block hover:bg-gray-500 hover:bg-opacity-10 px-5 h-full`,
|
|
1474
1818
|
onClick: () => dockApi.demaximizeWindow(winId),
|
|
1475
|
-
children: /* @__PURE__ */
|
|
1819
|
+
children: /* @__PURE__ */ jsx9(IconWinDemaximize, { color: style?.navControlsColor })
|
|
1476
1820
|
}
|
|
1477
|
-
) : /* @__PURE__ */
|
|
1821
|
+
) : /* @__PURE__ */ jsx9(
|
|
1478
1822
|
"button",
|
|
1479
1823
|
{
|
|
1480
1824
|
className: `block hover:bg-gray-500 hover:bg-opacity-10 px-5 h-full`,
|
|
1481
1825
|
onClick: () => dockApi.maximizeWindow(winId),
|
|
1482
|
-
children: /* @__PURE__ */
|
|
1826
|
+
children: /* @__PURE__ */ jsx9(IconWinMaximize, { color: style?.navControlsColor })
|
|
1483
1827
|
}
|
|
1484
1828
|
);
|
|
1485
|
-
const closeControl = /* @__PURE__ */
|
|
1829
|
+
const closeControl = /* @__PURE__ */ jsx9(
|
|
1486
1830
|
"button",
|
|
1487
1831
|
{
|
|
1488
1832
|
className: "hover:bg-red-500 hover:bg-opacity-20 px-5 h-full",
|
|
1489
1833
|
onClick: () => focusApi.closeWindowAndRefocus(winId),
|
|
1490
|
-
children: /* @__PURE__ */
|
|
1834
|
+
children: /* @__PURE__ */ jsx9(IconWinMinimize, { color: style?.navControlsColor })
|
|
1491
1835
|
}
|
|
1492
1836
|
);
|
|
1493
|
-
return /* @__PURE__ */ jsxs4(
|
|
1837
|
+
return /* @__PURE__ */ jsxs4(Fragment6, { children: [
|
|
1494
1838
|
/* @__PURE__ */ jsxs4(
|
|
1495
1839
|
"div",
|
|
1496
1840
|
{
|
|
@@ -1500,10 +1844,10 @@ function WindowLayout({
|
|
|
1500
1844
|
onPointerDown: () => focusApi.bringWindowToFocus(windowId),
|
|
1501
1845
|
style: {
|
|
1502
1846
|
backgroundColor: style?.windowBackgroundColor,
|
|
1503
|
-
top: `${winCoord.pointY}px`,
|
|
1504
|
-
left: `${winCoord.pointX}px`,
|
|
1505
|
-
width: `${winWidth}px`,
|
|
1506
|
-
height: `${winHeight}px`,
|
|
1847
|
+
top: isBelowBreakPoint ? wsRect.top : `${winCoord.pointY}px`,
|
|
1848
|
+
left: isBelowBreakPoint ? wsRect.left : `${winCoord.pointX}px`,
|
|
1849
|
+
width: isBelowBreakPoint ? wsRect.innerWidth : `${winWidth}px`,
|
|
1850
|
+
height: isBelowBreakPoint ? wsRect.innerHeight : `${winHeight}px`,
|
|
1507
1851
|
zIndex: `${zIndex}`,
|
|
1508
1852
|
/* MINIMIZE LOGIC */
|
|
1509
1853
|
transition: "transform 0.2s ease-in-out, opacity 0.3s ease-in-out",
|
|
@@ -1522,16 +1866,16 @@ function WindowLayout({
|
|
|
1522
1866
|
${navbarClassName ? navbarClassName : `bg-neutral-800 ${isActive ? "brightness-100" : "brightness-150"}`}
|
|
1523
1867
|
`,
|
|
1524
1868
|
children: [
|
|
1525
|
-
/* @__PURE__ */
|
|
1526
|
-
/* @__PURE__ */
|
|
1527
|
-
/* @__PURE__ */
|
|
1869
|
+
/* @__PURE__ */ jsx9("div", { className: "shrink h-8 px-2 text-white flex items-center text-sm truncate min-w-0", children: windowName }),
|
|
1870
|
+
/* @__PURE__ */ jsx9("div", { className: "h-8 px-2 text-white flex items-center text-sm truncate min-w-0", children: navbarChildren }),
|
|
1871
|
+
/* @__PURE__ */ jsx9(DragHandle, { winId }),
|
|
1528
1872
|
!isBelowBreakPoint && maximizeControl,
|
|
1529
1873
|
closeControl
|
|
1530
1874
|
]
|
|
1531
1875
|
}
|
|
1532
1876
|
),
|
|
1533
|
-
/* @__PURE__ */
|
|
1534
|
-
/* @__PURE__ */
|
|
1877
|
+
!isBelowBreakPoint && /* @__PURE__ */ jsx9(ResizingControls, { winId }),
|
|
1878
|
+
/* @__PURE__ */ jsx9("div", { className: `relative w-full h-[calc(100%-32px)] overflow-auto select-text`, children })
|
|
1535
1879
|
]
|
|
1536
1880
|
}
|
|
1537
1881
|
),
|
|
@@ -1540,7 +1884,7 @@ function WindowLayout({
|
|
|
1540
1884
|
}
|
|
1541
1885
|
|
|
1542
1886
|
// src/window-manager/internal/features/window-button.tsx
|
|
1543
|
-
import { jsx as
|
|
1887
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1544
1888
|
function WindowButton({
|
|
1545
1889
|
children,
|
|
1546
1890
|
winId,
|
|
@@ -1557,7 +1901,7 @@ function WindowButton({
|
|
|
1557
1901
|
focusApi.bringWindowToFocus(windowId);
|
|
1558
1902
|
}
|
|
1559
1903
|
};
|
|
1560
|
-
return /* @__PURE__ */
|
|
1904
|
+
return /* @__PURE__ */ jsx10(
|
|
1561
1905
|
"button",
|
|
1562
1906
|
{
|
|
1563
1907
|
id: `${windowId}_button`,
|
|
@@ -1572,26 +1916,25 @@ function WindowButton({
|
|
|
1572
1916
|
}
|
|
1573
1917
|
|
|
1574
1918
|
// src/window-manager/registration/window-store-factory.tsx
|
|
1575
|
-
import { jsx as
|
|
1576
|
-
var defaultMinWidth =
|
|
1577
|
-
var defaultMinHeight =
|
|
1919
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1920
|
+
var defaultMinWidth = 256;
|
|
1921
|
+
var defaultMinHeight = 64;
|
|
1578
1922
|
var createWindowStore = () => {
|
|
1579
1923
|
const zIndexAtLaunch = Object.keys(windowRegistry).length + 1;
|
|
1580
1924
|
const windowInstanceId = `react-dynamic-window-instance${Object.keys(windowRegistry).length}`;
|
|
1581
|
-
const storeInstance =
|
|
1925
|
+
const storeInstance = create2((set) => ({
|
|
1582
1926
|
setWinElement: (ref) => set({ winElement: ref }),
|
|
1583
1927
|
winElement: void 0,
|
|
1584
1928
|
windowId: windowInstanceId,
|
|
1585
|
-
resetFlag: false,
|
|
1586
1929
|
zIndex: zIndexAtLaunch,
|
|
1587
1930
|
winCoord: { pointX: 40, pointY: 40 },
|
|
1931
|
+
winWidth: defaultMinWidth,
|
|
1932
|
+
winHeight: defaultMinHeight,
|
|
1588
1933
|
winVisualState: "demaximized",
|
|
1589
1934
|
isActive: false,
|
|
1590
|
-
isDragging: false,
|
|
1591
1935
|
isWindowClosed: true,
|
|
1936
|
+
isDragging: false,
|
|
1592
1937
|
resizeAction: false,
|
|
1593
|
-
winWidth: defaultMinWidth,
|
|
1594
|
-
winHeight: defaultMinHeight,
|
|
1595
1938
|
WIN_MIN_WIDTH: defaultMinWidth,
|
|
1596
1939
|
WIN_MIN_HEIGHT: defaultMinHeight
|
|
1597
1940
|
}));
|
|
@@ -1599,8 +1942,8 @@ var createWindowStore = () => {
|
|
|
1599
1942
|
return {
|
|
1600
1943
|
id: storeInstance.getState().windowId,
|
|
1601
1944
|
store: storeInstance,
|
|
1602
|
-
Window: (props) => /* @__PURE__ */
|
|
1603
|
-
Button: (props) => /* @__PURE__ */
|
|
1945
|
+
Window: (props) => /* @__PURE__ */ jsx11(WindowLayout, { ...props, winId: windowInstanceId }),
|
|
1946
|
+
Button: (props) => /* @__PURE__ */ jsx11(WindowButton, { ...props, winId: windowInstanceId })
|
|
1604
1947
|
};
|
|
1605
1948
|
};
|
|
1606
1949
|
export {
|