@dxos/plugin-deck 0.7.5-main.9d2a38b → 0.7.5-main.e94eead
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/dist/lib/browser/{app-graph-builder-67VRUD5K.mjs → app-graph-builder-IYHAGFA3.mjs} +61 -31
- package/dist/lib/browser/app-graph-builder-IYHAGFA3.mjs.map +7 -0
- package/dist/lib/browser/{check-app-scheme-GEX6W2R5.mjs → check-app-scheme-S3EYUPMF.mjs} +3 -3
- package/dist/lib/browser/{check-app-scheme-GEX6W2R5.mjs.map → check-app-scheme-S3EYUPMF.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-5VFDMW5M.mjs → chunk-22AQ5IVX.mjs} +2 -2
- package/dist/lib/browser/chunk-22AQ5IVX.mjs.map +7 -0
- package/dist/lib/browser/chunk-FT33W5CI.mjs +128 -0
- package/dist/lib/browser/chunk-FT33W5CI.mjs.map +7 -0
- package/dist/lib/browser/chunk-G2X3ZDCE.mjs +24 -0
- package/dist/lib/browser/chunk-G2X3ZDCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-KANJBSIX.mjs +97 -0
- package/dist/lib/browser/chunk-KANJBSIX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JQJ5UWVB.mjs → chunk-N7TEPFVR.mjs} +3 -2
- package/dist/lib/browser/{chunk-JQJ5UWVB.mjs.map → chunk-N7TEPFVR.mjs.map} +3 -3
- package/dist/lib/browser/chunk-O4RFYYQ6.mjs +1114 -0
- package/dist/lib/browser/chunk-O4RFYYQ6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +45 -78
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-ZD67BRUI.mjs +488 -0
- package/dist/lib/browser/intent-resolver-ZD67BRUI.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-root-UL7ZDRVZ.mjs → react-root-6ILKHD5J.mjs} +12 -17
- package/dist/lib/browser/react-root-6ILKHD5J.mjs.map +7 -0
- package/dist/lib/browser/react-surface-O75FKXAI.mjs +39 -0
- package/dist/lib/browser/react-surface-O75FKXAI.mjs.map +7 -0
- package/dist/lib/browser/{settings-FNWW6WIJ.mjs → settings-H35U6NHE.mjs} +6 -7
- package/dist/lib/browser/settings-H35U6NHE.mjs.map +7 -0
- package/dist/lib/browser/state-U4SHOPJW.mjs +129 -0
- package/dist/lib/browser/state-U4SHOPJW.mjs.map +7 -0
- package/dist/lib/browser/tools-64LXGLYR.mjs +59 -0
- package/dist/lib/browser/tools-64LXGLYR.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +16 -4
- package/dist/lib/browser/url-handler-MVHTKUYA.mjs +72 -0
- package/dist/lib/browser/url-handler-MVHTKUYA.mjs.map +7 -0
- package/dist/types/src/DeckPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +137 -8
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/check-app-scheme.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +188 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +79 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/tools.d.ts +10 -0
- package/dist/types/src/capabilities/tools.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/DeckLayout/ActiveNode.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/ActiveNode.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Banner.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts +1 -4
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +2 -7
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Fallback.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/Fallback.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Fullscreen.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/Fullscreen.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +3 -3
- package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Plank.d.ts +8 -6
- package/dist/types/src/components/DeckLayout/Plank.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/PlankControls.d.ts +2 -2
- package/dist/types/src/components/DeckLayout/PlankControls.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/PlankError.d.ts +6 -6
- package/dist/types/src/components/DeckLayout/PlankError.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/PlankLoading.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/PlankLoading.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Sidebar.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/Sidebar.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/SidebarButton.d.ts +6 -5
- package/dist/types/src/components/DeckLayout/SidebarButton.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/StatusBar.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/StatusBar.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Toast.d.ts +2 -3
- package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Topbar.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/Topbar.d.ts.map +1 -1
- package/dist/types/src/components/LayoutSettings.d.ts +1 -2
- package/dist/types/src/components/LayoutSettings.d.ts.map +1 -1
- package/dist/types/src/components/fragments.d.ts +2 -0
- package/dist/types/src/components/fragments.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -0
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/useMainSize.d.ts +2 -2
- package/dist/types/src/hooks/useNode.d.ts.map +1 -1
- package/dist/types/src/layout.d.ts +5 -19
- package/dist/types/src/layout.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -3
- package/dist/types/src/types.d.ts +117 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +3 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/layoutAppliesTopbar.d.ts +2 -0
- package/dist/types/src/util/layoutAppliesTopbar.d.ts.map +1 -0
- package/dist/types/src/util/set-active.d.ts +9 -0
- package/dist/types/src/util/set-active.d.ts.map +1 -0
- package/dist/types/src/util/useHoistStatusbar.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/DeckPlugin.ts +23 -59
- package/src/capabilities/{layout/app-graph-builder.ts → app-graph-builder.ts} +40 -28
- package/src/capabilities/capabilities.ts +5 -7
- package/src/capabilities/{navigation/check-app-scheme.ts → check-app-scheme.ts} +2 -2
- package/src/capabilities/index.ts +12 -3
- package/src/capabilities/intent-resolver.ts +368 -0
- package/src/capabilities/{layout/react-root.tsx → react-root.tsx} +8 -14
- package/src/capabilities/react-surface.tsx +31 -0
- package/src/capabilities/{settings/settings.ts → settings.ts} +4 -5
- package/src/capabilities/state.ts +108 -0
- package/src/capabilities/tools.ts +66 -0
- package/src/capabilities/url-handler.ts +65 -0
- package/src/components/DeckLayout/ActiveNode.tsx +2 -3
- package/src/components/DeckLayout/ComplementarySidebar.tsx +185 -77
- package/src/components/DeckLayout/ContentEmpty.tsx +7 -10
- package/src/components/DeckLayout/DeckLayout.tsx +141 -84
- package/src/components/DeckLayout/Fullscreen.tsx +2 -3
- package/src/components/DeckLayout/NodePlankHeading.tsx +57 -65
- package/src/components/DeckLayout/Plank.tsx +33 -41
- package/src/components/DeckLayout/PlankControls.tsx +12 -11
- package/src/components/DeckLayout/PlankError.tsx +6 -5
- package/src/components/DeckLayout/Sidebar.tsx +17 -20
- package/src/components/DeckLayout/SidebarButton.tsx +25 -31
- package/src/components/DeckLayout/StatusBar.tsx +5 -11
- package/src/components/DeckLayout/Toast.tsx +2 -2
- package/src/components/LayoutSettings.tsx +8 -8
- package/src/components/fragments.ts +8 -0
- package/src/components/index.ts +0 -2
- package/src/events.ts +1 -0
- package/src/hooks/useMainSize.ts +3 -3
- package/src/hooks/useNode.ts +3 -1
- package/src/layout.ts +43 -212
- package/src/meta.ts +1 -0
- package/src/translations.ts +8 -8
- package/src/types.ts +103 -4
- package/src/util/index.ts +3 -1
- package/src/util/layoutAppliesTopbar.ts +7 -0
- package/src/util/set-active.ts +47 -0
- package/src/util/useHoistStatusbar.ts +13 -8
- package/dist/lib/browser/app-graph-builder-67VRUD5K.mjs.map +0 -7
- package/dist/lib/browser/chunk-2M4PXYNB.mjs +0 -1052
- package/dist/lib/browser/chunk-2M4PXYNB.mjs.map +0 -7
- package/dist/lib/browser/chunk-2PJNBVCY.mjs +0 -39
- package/dist/lib/browser/chunk-2PJNBVCY.mjs.map +0 -7
- package/dist/lib/browser/chunk-4C2AFTET.mjs +0 -186
- package/dist/lib/browser/chunk-4C2AFTET.mjs.map +0 -7
- package/dist/lib/browser/chunk-5VFDMW5M.mjs.map +0 -7
- package/dist/lib/browser/chunk-KY5WXIXY.mjs +0 -44
- package/dist/lib/browser/chunk-KY5WXIXY.mjs.map +0 -7
- package/dist/lib/browser/deck-PLCSKPGL.mjs +0 -26
- package/dist/lib/browser/deck-PLCSKPGL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FVOQSTBX.mjs +0 -152
- package/dist/lib/browser/intent-resolver-FVOQSTBX.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-K7GW4A2I.mjs +0 -249
- package/dist/lib/browser/intent-resolver-K7GW4A2I.mjs.map +0 -7
- package/dist/lib/browser/location-QHRBQBQN.mjs +0 -35
- package/dist/lib/browser/location-QHRBQBQN.mjs.map +0 -7
- package/dist/lib/browser/react-context-3BDW7W2N.mjs +0 -32
- package/dist/lib/browser/react-context-3BDW7W2N.mjs.map +0 -7
- package/dist/lib/browser/react-root-UL7ZDRVZ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-VPNOGGNN.mjs +0 -28
- package/dist/lib/browser/react-surface-VPNOGGNN.mjs.map +0 -7
- package/dist/lib/browser/settings-FNWW6WIJ.mjs.map +0 -7
- package/dist/lib/browser/state-7I5BD7SE.mjs +0 -34
- package/dist/lib/browser/state-7I5BD7SE.mjs.map +0 -7
- package/dist/lib/browser/url-handler-Z5B7LD3N.mjs +0 -76
- package/dist/lib/browser/url-handler-Z5B7LD3N.mjs.map +0 -7
- package/dist/types/src/capabilities/layout/app-graph-builder.d.ts +0 -181
- package/dist/types/src/capabilities/layout/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/layout/deck.d.ts +0 -4
- package/dist/types/src/capabilities/layout/deck.d.ts.map +0 -1
- package/dist/types/src/capabilities/layout/index.d.ts +0 -229
- package/dist/types/src/capabilities/layout/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/layout/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/layout/react-context.d.ts +0 -8
- package/dist/types/src/capabilities/layout/react-context.d.ts.map +0 -1
- package/dist/types/src/capabilities/layout/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/layout/state.d.ts +0 -42
- package/dist/types/src/capabilities/layout/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/navigation/check-app-scheme.d.ts.map +0 -1
- package/dist/types/src/capabilities/navigation/index.d.ts +0 -5
- package/dist/types/src/capabilities/navigation/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/navigation/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/navigation/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/navigation/location.d.ts +0 -4
- package/dist/types/src/capabilities/navigation/location.d.ts.map +0 -1
- package/dist/types/src/capabilities/navigation/set-location.d.ts +0 -10
- package/dist/types/src/capabilities/navigation/set-location.d.ts.map +0 -1
- package/dist/types/src/capabilities/navigation/url-handler.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/index.d.ts +0 -3
- package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
- package/dist/types/src/components/DeckContext.d.ts +0 -11
- package/dist/types/src/components/DeckContext.d.ts.map +0 -1
- package/dist/types/src/components/LayoutContext.d.ts +0 -5
- package/dist/types/src/components/LayoutContext.d.ts.map +0 -1
- package/dist/types/src/layout.test.d.ts +0 -2
- package/dist/types/src/layout.test.d.ts.map +0 -1
- package/dist/types/src/util/layout-parts.d.ts +0 -7
- package/dist/types/src/util/layout-parts.d.ts.map +0 -1
- package/src/capabilities/layout/deck.ts +0 -25
- package/src/capabilities/layout/index.ts +0 -12
- package/src/capabilities/layout/intent-resolver.ts +0 -128
- package/src/capabilities/layout/react-context.tsx +0 -26
- package/src/capabilities/layout/state.ts +0 -32
- package/src/capabilities/navigation/index.ts +0 -10
- package/src/capabilities/navigation/intent-resolver.ts +0 -216
- package/src/capabilities/navigation/location.ts +0 -28
- package/src/capabilities/navigation/set-location.ts +0 -38
- package/src/capabilities/navigation/url-handler.ts +0 -67
- package/src/capabilities/settings/index.ts +0 -8
- package/src/capabilities/settings/react-surface.tsx +0 -23
- package/src/components/DeckContext.ts +0 -19
- package/src/components/LayoutContext.ts +0 -12
- package/src/layout.test.ts +0 -380
- package/src/util/layout-parts.ts +0 -12
- /package/dist/types/src/capabilities/{navigation/check-app-scheme.d.ts → check-app-scheme.d.ts} +0 -0
- /package/dist/types/src/capabilities/{layout/intent-resolver.d.ts → intent-resolver.d.ts} +0 -0
- /package/dist/types/src/capabilities/{layout/react-root.d.ts → react-root.d.ts} +0 -0
- /package/dist/types/src/capabilities/{settings/react-surface.d.ts → react-surface.d.ts} +0 -0
- /package/dist/types/src/capabilities/{settings/settings.d.ts → settings.d.ts} +0 -0
- /package/dist/types/src/capabilities/{navigation/url-handler.d.ts → url-handler.d.ts} +0 -0
package/src/layout.ts
CHANGED
|
@@ -4,245 +4,76 @@
|
|
|
4
4
|
|
|
5
5
|
import { produce } from 'immer';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
type LayoutAdjustment,
|
|
9
|
-
type LayoutCoordinate,
|
|
10
|
-
type LayoutEntry,
|
|
11
|
-
type LayoutPart,
|
|
12
|
-
type LayoutParts,
|
|
13
|
-
SLUG_ENTRY_SEPARATOR,
|
|
14
|
-
SLUG_KEY_VALUE_SEPARATOR,
|
|
15
|
-
SLUG_LIST_SEPARATOR,
|
|
16
|
-
SLUG_PATH_SEPARATOR,
|
|
17
|
-
} from '@dxos/app-framework';
|
|
7
|
+
import { type DeckAction, type NewPlankPositioning } from './types';
|
|
18
8
|
|
|
19
|
-
|
|
9
|
+
type OpenLayoutEntryOptions = { key?: string; positioning?: NewPlankPositioning; pivotId?: string };
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// --- Layout Parts Manipulation ----------------------------------------------
|
|
26
|
-
|
|
27
|
-
type OpenLayoutEntryOptions = { positioning?: NewPlankPositioning; pivotId?: string };
|
|
28
|
-
|
|
29
|
-
export const openEntry = (
|
|
30
|
-
layout: LayoutParts,
|
|
31
|
-
part: LayoutPart,
|
|
32
|
-
entry: LayoutEntry,
|
|
33
|
-
options?: OpenLayoutEntryOptions,
|
|
34
|
-
): LayoutParts => {
|
|
35
|
-
return produce(layout, (draft) => {
|
|
36
|
-
const layoutPart = draft[part];
|
|
37
|
-
// If the part doesn't exist, create it.
|
|
38
|
-
if (!layoutPart) {
|
|
39
|
-
draft[part] = [entry];
|
|
11
|
+
export const openEntry = (deck: string[], entryId: string, options?: OpenLayoutEntryOptions): string[] => {
|
|
12
|
+
return produce(deck, (draft) => {
|
|
13
|
+
// Check that the entry is not already in the part
|
|
14
|
+
if (draft.find((id) => id === entryId)) {
|
|
40
15
|
return;
|
|
41
16
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
|
|
18
|
+
const key = options?.key;
|
|
19
|
+
const plankPositioning = options?.positioning ?? 'start';
|
|
20
|
+
const pivotId = options?.pivotId;
|
|
21
|
+
|
|
22
|
+
if (key) {
|
|
23
|
+
const index = draft.findIndex((id) => id.split('+')[0] === key);
|
|
24
|
+
if (index !== -1) {
|
|
25
|
+
draft.splice(index, 1, entryId);
|
|
45
26
|
return;
|
|
46
27
|
}
|
|
28
|
+
}
|
|
47
29
|
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
layoutPart.splice(pivotIndex, 0, entry);
|
|
56
|
-
} else {
|
|
57
|
-
layoutPart.splice(pivotIndex + 1, 0, entry);
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
30
|
+
if (pivotId) {
|
|
31
|
+
const pivotIndex = draft.findIndex((id) => id === pivotId);
|
|
32
|
+
if (pivotIndex !== -1) {
|
|
33
|
+
if (plankPositioning === 'start') {
|
|
34
|
+
draft.splice(pivotIndex, 0, entryId);
|
|
35
|
+
} else {
|
|
36
|
+
draft.splice(pivotIndex + 1, 0, entryId);
|
|
60
37
|
}
|
|
38
|
+
return;
|
|
61
39
|
}
|
|
40
|
+
}
|
|
62
41
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} else {
|
|
67
|
-
layoutPart.push(entry);
|
|
68
|
-
}
|
|
42
|
+
// If no pivot found or provided, fall back to original behavior
|
|
43
|
+
if (plankPositioning === 'start') {
|
|
44
|
+
draft.unshift(entryId);
|
|
69
45
|
} else {
|
|
70
|
-
|
|
71
|
-
draft[part] = [entry];
|
|
46
|
+
draft.push(entryId);
|
|
72
47
|
}
|
|
73
48
|
});
|
|
74
49
|
};
|
|
75
50
|
|
|
76
|
-
export const closeEntry = (
|
|
77
|
-
return produce(
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const index = layoutPart.findIndex((entry) => entry.id === slugId);
|
|
85
|
-
if (index === -1) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// If there's only one entry in the layout part, remove the whole part from the layout.
|
|
90
|
-
if (layoutPart.length === 1) {
|
|
91
|
-
delete draft[part];
|
|
92
|
-
} else {
|
|
93
|
-
layoutPart.splice(index, 1);
|
|
51
|
+
export const closeEntry = (deck: string[], entryId: string): string[] => {
|
|
52
|
+
return produce(deck, (draft) => {
|
|
53
|
+
const index = draft.findIndex((id) => id === entryId);
|
|
54
|
+
if (index !== -1) {
|
|
55
|
+
draft.splice(index, 1);
|
|
94
56
|
}
|
|
95
57
|
});
|
|
96
58
|
};
|
|
97
59
|
|
|
98
|
-
export const incrementPlank = (
|
|
99
|
-
return produce(
|
|
100
|
-
const
|
|
101
|
-
const { part, entryId } = layoutCoordinate;
|
|
102
|
-
|
|
103
|
-
// Only allow adjustments in the 'main' part
|
|
104
|
-
if (partsThatSupportIncrement.includes(part) === false) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const layoutPart = draft[part];
|
|
109
|
-
if (!layoutPart) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const index = layoutPart.findIndex((entry) => entry.id === entryId);
|
|
60
|
+
export const incrementPlank = (deck: string[], adjustment: DeckAction.Adjustment): string[] => {
|
|
61
|
+
return produce(deck, (draft) => {
|
|
62
|
+
const index = draft.findIndex((id) => id === adjustment.id);
|
|
113
63
|
if (
|
|
114
64
|
index === -1 ||
|
|
115
|
-
(type === 'increment-start' && index === 0) ||
|
|
116
|
-
(type === 'increment-end' && index ===
|
|
65
|
+
(adjustment.type === 'increment-start' && index === 0) ||
|
|
66
|
+
(adjustment.type === 'increment-end' && index === draft.length - 1)
|
|
117
67
|
) {
|
|
118
68
|
return;
|
|
119
69
|
}
|
|
120
70
|
|
|
121
|
-
if (type === 'increment-start') {
|
|
71
|
+
if (adjustment.type === 'increment-start') {
|
|
122
72
|
// Swap the current item with the previous item.
|
|
123
|
-
[
|
|
124
|
-
} else if (type === 'increment-end') {
|
|
73
|
+
[draft[index - 1], draft[index]] = [draft[index], draft[index - 1]];
|
|
74
|
+
} else if (adjustment.type === 'increment-end') {
|
|
125
75
|
// Swap the current item with the next item.
|
|
126
|
-
[
|
|
76
|
+
[draft[index], draft[index + 1]] = [draft[index + 1], draft[index]];
|
|
127
77
|
}
|
|
128
78
|
});
|
|
129
79
|
};
|
|
130
|
-
|
|
131
|
-
export const removePart = (layout: LayoutParts, part: LayoutPart): LayoutParts => {
|
|
132
|
-
return produce(layout, (draft) => {
|
|
133
|
-
delete draft[part];
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export const mergeLayoutParts = (...layoutParts: LayoutParts[]): LayoutParts => {
|
|
138
|
-
return layoutParts.reduce(
|
|
139
|
-
(merged, current) =>
|
|
140
|
-
produce(merged, (draft) => {
|
|
141
|
-
Object.entries(current).forEach(([part, entries]) => {
|
|
142
|
-
const typedPart = part as LayoutPart;
|
|
143
|
-
|
|
144
|
-
if (!draft[typedPart]) {
|
|
145
|
-
draft[typedPart] = [];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const partEntries = draft[typedPart] as LayoutEntry[];
|
|
149
|
-
|
|
150
|
-
entries.forEach((entry) => {
|
|
151
|
-
const existingIndex = partEntries.findIndex((e) => e.id === entry.id);
|
|
152
|
-
if (existingIndex !== -1) {
|
|
153
|
-
partEntries[existingIndex] = entry;
|
|
154
|
-
} else {
|
|
155
|
-
partEntries.push(entry);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}),
|
|
160
|
-
{} as LayoutParts,
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
//
|
|
165
|
-
// URI Projection
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
const parseLayoutEntry = (itemString: string): LayoutEntry => {
|
|
169
|
-
// Layout entries are in the form of 'id~path' or just 'id'
|
|
170
|
-
const [id, path] = itemString.split(SLUG_PATH_SEPARATOR);
|
|
171
|
-
const entry: LayoutEntry = { id };
|
|
172
|
-
if (path) {
|
|
173
|
-
entry.path = path;
|
|
174
|
-
}
|
|
175
|
-
return entry;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const uriToSoloPart = (uri: string): LayoutParts | undefined => {
|
|
179
|
-
// Now after the domain part, there will be a single ID with an optional path
|
|
180
|
-
const parts = uri.split('/');
|
|
181
|
-
const slug = parts[parts.length - 1]; // Take the last part of the URI
|
|
182
|
-
|
|
183
|
-
if (slug.length > 0) {
|
|
184
|
-
return {
|
|
185
|
-
solo: [parseLayoutEntry(slug)],
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return undefined;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const soloPartToUri = (layout: LayoutParts): string => {
|
|
193
|
-
const soloPart = layout?.solo;
|
|
194
|
-
if (!soloPart || soloPart.length === 0) {
|
|
195
|
-
return '';
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const entry = soloPart[0];
|
|
199
|
-
return `${entry.id}${entry.path ? SLUG_PATH_SEPARATOR + entry.path : ''}`;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Converts a URI string into a LayoutParts object.
|
|
204
|
-
* @deprecated Keeping these as a reference for now. We should remove these once we're sure we don't need them.
|
|
205
|
-
*/
|
|
206
|
-
export const uriToActiveParts = (uri: string): LayoutParts => {
|
|
207
|
-
const parts = uri.split('/');
|
|
208
|
-
const slug = parts[parts.length - 1]; // Take the last part of the URI
|
|
209
|
-
|
|
210
|
-
if (!slug) {
|
|
211
|
-
return {}; // Return an empty object if the slug is empty
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return slug.split(SLUG_ENTRY_SEPARATOR).reduce((acc: LayoutParts, partDescriptor) => {
|
|
215
|
-
const [part, layoutEntry] = partDescriptor.split(SLUG_KEY_VALUE_SEPARATOR);
|
|
216
|
-
if (part && layoutEntry) {
|
|
217
|
-
// TODO(Zan): Remove this cast.
|
|
218
|
-
acc[part as LayoutPart] = layoutEntry.split(SLUG_LIST_SEPARATOR).map(parseLayoutEntry);
|
|
219
|
-
}
|
|
220
|
-
return acc;
|
|
221
|
-
}, {} as LayoutParts);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const formatLayoutEntry = ({ id, path }: LayoutEntry): string => {
|
|
225
|
-
// NOTE(Zan): Format = `[SOLO_INDICATOR] ID [PATH_SEPARATOR PATH]`.
|
|
226
|
-
let entry = '';
|
|
227
|
-
entry += id;
|
|
228
|
-
if (path) {
|
|
229
|
-
entry += `${SLUG_PATH_SEPARATOR}${path}`;
|
|
230
|
-
}
|
|
231
|
-
return entry;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const formatPartDescriptor = (part: LayoutPart, layoutEntries: LayoutEntry[]): string => {
|
|
235
|
-
const formattedEntries = layoutEntries.map(formatLayoutEntry).join(SLUG_LIST_SEPARATOR);
|
|
236
|
-
return `${part}${SLUG_KEY_VALUE_SEPARATOR}${formattedEntries}`;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Converts a LayoutParts object into a URI string.
|
|
241
|
-
* @deprecated Keeping these as a reference for now. We should remove these once we're sure we don't need them.
|
|
242
|
-
*/
|
|
243
|
-
export const activePartsToUri = (activeParts: LayoutParts): string => {
|
|
244
|
-
return Object.entries(activeParts)
|
|
245
|
-
.filter(([, layoutEntries]) => layoutEntries.length > 0) // Only include non-empty parts
|
|
246
|
-
.map(([part, layoutEntries]) => formatPartDescriptor(part as LayoutPart, layoutEntries))
|
|
247
|
-
.join(SLUG_ENTRY_SEPARATOR);
|
|
248
|
-
};
|
package/src/meta.ts
CHANGED
package/src/translations.ts
CHANGED
|
@@ -8,11 +8,12 @@ export default [
|
|
|
8
8
|
{
|
|
9
9
|
'en-US': {
|
|
10
10
|
[DECK_PLUGIN]: {
|
|
11
|
+
'plugin name': 'Deck',
|
|
11
12
|
'main header label': 'Main header',
|
|
12
|
-
'open navigation sidebar label': 'Open
|
|
13
|
-
'
|
|
14
|
-
'open complementary sidebar label': 'Open sidebar',
|
|
15
|
-
'close complementary sidebar label': 'Minimize sidebar',
|
|
13
|
+
'open navigation sidebar label': 'Open sidebar',
|
|
14
|
+
'collapse navigation sidebar label': 'Minimize sidebar',
|
|
15
|
+
'open complementary sidebar label': 'Open context sidebar',
|
|
16
|
+
'close complementary sidebar label': 'Minimize context sidebar',
|
|
16
17
|
'plugin error message': 'Content failed to render.',
|
|
17
18
|
'content fallback message': 'Unsupported',
|
|
18
19
|
'content fallback description':
|
|
@@ -20,7 +21,6 @@ export default [
|
|
|
20
21
|
'toggle fullscreen label': 'Toggle fullscreen',
|
|
21
22
|
'settings show hints label': 'Show hints',
|
|
22
23
|
'settings native redirect label': 'Enable native url redirect (experimental)',
|
|
23
|
-
'settings custom slots': 'Theme option (experimental)',
|
|
24
24
|
'settings new plank position start label': 'Start',
|
|
25
25
|
'settings new plank position end label': 'End',
|
|
26
26
|
'select new plank positioning placeholder': 'Select new plank positioning',
|
|
@@ -32,7 +32,7 @@ export default [
|
|
|
32
32
|
'error fallback message': 'Unable to open this item',
|
|
33
33
|
'plank heading fallback label': 'Untitled',
|
|
34
34
|
'actions menu label': 'Options',
|
|
35
|
-
'settings deck label': 'Disable
|
|
35
|
+
'settings deck label': 'Disable deck',
|
|
36
36
|
'reload required message': 'Reload required.',
|
|
37
37
|
'pending heading': 'Loading…',
|
|
38
38
|
'insert plank label': 'Open',
|
|
@@ -45,11 +45,11 @@ export default [
|
|
|
45
45
|
'show solo plank label': 'Maximize',
|
|
46
46
|
'close label': 'Close',
|
|
47
47
|
'minify label': 'Minify',
|
|
48
|
-
'settings overscroll label': 'Plank
|
|
48
|
+
'settings overscroll label': 'Plank overscrolling',
|
|
49
49
|
'select overscroll placeholder': 'Select plank overscrolling behavior',
|
|
50
50
|
'settings overscroll centering label': 'Centering',
|
|
51
51
|
'settings overscroll none label': 'None',
|
|
52
|
-
'settings
|
|
52
|
+
'settings enable ide-style statusbar label': 'IDE-style statusbar',
|
|
53
53
|
'close current label': 'Close current plank',
|
|
54
54
|
'close others label': 'Close other planks',
|
|
55
55
|
'close all label': 'Close all planks',
|
package/src/types.ts
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { LayoutAction } from '@dxos/app-framework';
|
|
5
6
|
import { S } from '@dxos/echo-schema';
|
|
7
|
+
import { type Node } from '@dxos/plugin-graph';
|
|
6
8
|
import { type Label } from '@dxos/react-ui';
|
|
9
|
+
import { type Position } from '@dxos/util';
|
|
7
10
|
|
|
8
11
|
import { DECK_PLUGIN } from './meta';
|
|
9
12
|
|
|
@@ -14,15 +17,23 @@ export type NewPlankPositioning = (typeof NewPlankPositions)[number];
|
|
|
14
17
|
export const OverscrollOptions = ['none', 'centering'] as const;
|
|
15
18
|
export type Overscroll = (typeof OverscrollOptions)[number];
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
export type Panel = {
|
|
21
|
+
id: string;
|
|
22
|
+
label: Label;
|
|
23
|
+
icon: string;
|
|
24
|
+
position?: Position;
|
|
25
|
+
/**
|
|
26
|
+
* If true, the panel will now be wrapped in a scroll area.
|
|
27
|
+
*/
|
|
28
|
+
fixed?: boolean;
|
|
29
|
+
filter?: (node: Node) => boolean;
|
|
30
|
+
};
|
|
19
31
|
|
|
20
32
|
export const DeckSettingsSchema = S.mutable(
|
|
21
33
|
S.Struct({
|
|
22
34
|
showHints: S.Boolean,
|
|
23
|
-
customSlots: S.Boolean,
|
|
24
|
-
flatDeck: S.Boolean,
|
|
25
35
|
enableNativeRedirect: S.Boolean,
|
|
36
|
+
enableIdeStyleStatusbar: S.Boolean,
|
|
26
37
|
newPlankPositioning: S.Literal(...NewPlankPositions),
|
|
27
38
|
overscroll: S.Literal(...OverscrollOptions),
|
|
28
39
|
}),
|
|
@@ -30,9 +41,97 @@ export const DeckSettingsSchema = S.mutable(
|
|
|
30
41
|
|
|
31
42
|
export type DeckSettingsProps = S.Schema.Type<typeof DeckSettingsSchema>;
|
|
32
43
|
|
|
44
|
+
const LayoutMode = S.Union(S.Literal('deck'), S.Literal('solo'), S.Literal('fullscreen'));
|
|
45
|
+
export const isLayoutMode = (value: any): value is LayoutMode => S.is(LayoutMode)(value);
|
|
46
|
+
export type LayoutMode = S.Schema.Type<typeof LayoutMode>;
|
|
47
|
+
|
|
48
|
+
export const PlankSizing = S.Record({ key: S.String, value: S.Number });
|
|
49
|
+
export type PlankSizing = S.Schema.Type<typeof PlankSizing>;
|
|
50
|
+
|
|
51
|
+
export const Deck = S.Struct({
|
|
52
|
+
initialized: S.Boolean.annotations({
|
|
53
|
+
description: "If false, the deck has not yet left solo mode and new planks should be solo'd.",
|
|
54
|
+
}),
|
|
55
|
+
active: S.mutable(S.Array(S.String)),
|
|
56
|
+
inactive: S.mutable(S.Array(S.String)),
|
|
57
|
+
solo: S.optional(S.String),
|
|
58
|
+
fullscreen: S.Boolean,
|
|
59
|
+
plankSizing: S.mutable(PlankSizing),
|
|
60
|
+
});
|
|
61
|
+
export type Deck = S.Schema.Type<typeof Deck>;
|
|
62
|
+
|
|
63
|
+
export const DeckState = S.mutable(
|
|
64
|
+
S.Struct({
|
|
65
|
+
sidebarState: S.Literal('closed', 'collapsed', 'expanded'),
|
|
66
|
+
complementarySidebarState: S.Literal('closed', 'collapsed', 'expanded'),
|
|
67
|
+
complementarySidebarPanel: S.optional(S.String),
|
|
68
|
+
|
|
69
|
+
dialogOpen: S.Boolean,
|
|
70
|
+
/**
|
|
71
|
+
* Data to be passed to the dialog Surface.
|
|
72
|
+
*/
|
|
73
|
+
dialogContent: S.optional(S.Any),
|
|
74
|
+
dialogBlockAlign: S.optional(S.Literal('start', 'center', 'end')),
|
|
75
|
+
dialogType: S.optional(S.Literal('default', 'alert')),
|
|
76
|
+
|
|
77
|
+
popoverOpen: S.Boolean,
|
|
78
|
+
popoverSide: S.optional(S.Literal('top', 'right', 'bottom', 'left')),
|
|
79
|
+
/**
|
|
80
|
+
* Data to be passed to the popover Surface.
|
|
81
|
+
*/
|
|
82
|
+
popoverContent: S.optional(S.Any),
|
|
83
|
+
popoverAnchorId: S.optional(S.String),
|
|
84
|
+
|
|
85
|
+
toasts: S.mutable(S.Array(LayoutAction.Toast)),
|
|
86
|
+
currentUndoId: S.optional(S.String),
|
|
87
|
+
|
|
88
|
+
activeDeck: S.String,
|
|
89
|
+
previousDeck: S.String,
|
|
90
|
+
decks: S.mutable(S.Record({ key: S.String, value: S.mutable(Deck) })),
|
|
91
|
+
previousMode: S.mutable(S.Record({ key: S.String, value: LayoutMode })),
|
|
92
|
+
deck: S.mutable(Deck),
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The identifier of a component to scroll into view when it is mounted.
|
|
96
|
+
*/
|
|
97
|
+
scrollIntoView: S.optional(S.String),
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export type DeckState = S.Schema.Type<typeof DeckState>;
|
|
102
|
+
|
|
103
|
+
export const getMode = (deck: Deck): LayoutMode => {
|
|
104
|
+
if (deck.solo) {
|
|
105
|
+
return deck.fullscreen ? 'fullscreen' : 'solo';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return 'deck';
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// NOTE: Chosen from RFC 1738’s `safe` characters: http://www.faqs.org/rfcs/rfc1738.html
|
|
112
|
+
export const SLUG_PATH_SEPARATOR = '~';
|
|
113
|
+
|
|
33
114
|
export const DECK_ACTION = `${DECK_PLUGIN}/action`;
|
|
34
115
|
|
|
35
116
|
export namespace DeckAction {
|
|
117
|
+
const PartAdjustmentSchema = S.Union(
|
|
118
|
+
S.Literal('close').annotations({ description: 'Close the plank.' }),
|
|
119
|
+
S.Literal('solo').annotations({ description: 'Solo the plank.' }),
|
|
120
|
+
S.Literal('increment-start').annotations({ description: 'Move the plank towards the start of the deck.' }),
|
|
121
|
+
S.Literal('increment-end').annotations({ description: 'Move the plank towards the end of the deck.' }),
|
|
122
|
+
);
|
|
123
|
+
export type PartAdjustment = S.Schema.Type<typeof PartAdjustmentSchema>;
|
|
124
|
+
export const Adjustment = S.mutable(S.Struct({ id: S.String, type: PartAdjustmentSchema }));
|
|
125
|
+
export type Adjustment = S.Schema.Type<typeof Adjustment>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* An atomic transaction to apply to the deck, describing which element to move to which location.
|
|
129
|
+
*/
|
|
130
|
+
export class Adjust extends S.TaggedClass<Adjust>()(`${DECK_ACTION}/adjust`, {
|
|
131
|
+
input: Adjustment,
|
|
132
|
+
output: S.Void,
|
|
133
|
+
}) {}
|
|
134
|
+
|
|
36
135
|
export class UpdatePlankSize extends S.TaggedClass<UpdatePlankSize>()(`${DECK_ACTION}/update-plank-size`, {
|
|
37
136
|
input: S.Struct({
|
|
38
137
|
id: S.String,
|
package/src/util/index.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { batch } from '@preact/signals-core';
|
|
6
|
+
|
|
7
|
+
import { type AttentionManager } from '@dxos/plugin-attention';
|
|
8
|
+
|
|
9
|
+
import { type DeckState } from '../types';
|
|
10
|
+
|
|
11
|
+
export type SetActiveOptions = {
|
|
12
|
+
next: string[];
|
|
13
|
+
state: DeckState;
|
|
14
|
+
attention?: AttentionManager;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const setActive = ({ next, state, attention }: SetActiveOptions) => {
|
|
18
|
+
return batch(() => {
|
|
19
|
+
const active = state.deck.solo ? [state.deck.solo] : state.deck.active;
|
|
20
|
+
const removed = active.filter((id) => !next.includes(id));
|
|
21
|
+
const closed = Array.from(new Set([...state.deck.inactive.filter((id) => !next.includes(id)), ...removed]));
|
|
22
|
+
|
|
23
|
+
state.deck.inactive = closed;
|
|
24
|
+
|
|
25
|
+
if (state.deck.solo || !state.deck.initialized) {
|
|
26
|
+
state.deck.solo = next[0];
|
|
27
|
+
} else {
|
|
28
|
+
state.deck.active = next;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (state.deck.fullscreen && !state.deck.solo) {
|
|
32
|
+
state.deck.fullscreen = false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (attention) {
|
|
36
|
+
const attended = attention.current;
|
|
37
|
+
const [attendedId] = Array.from(attended);
|
|
38
|
+
const isAttendedAvailable = !!attendedId && next.includes(attendedId);
|
|
39
|
+
if (!isAttendedAvailable) {
|
|
40
|
+
const attendedIndex = active.indexOf(attendedId);
|
|
41
|
+
// If outside of bounds, focus on the first/last plank, otherwise focus on the new plank in the same position.
|
|
42
|
+
const index = attendedIndex === -1 ? 0 : attendedIndex >= next.length ? next.length - 1 : attendedIndex;
|
|
43
|
+
return next[index];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { useThemeContext } from '@dxos/react-ui';
|
|
9
|
+
|
|
10
|
+
import { DECK_PLUGIN } from '../meta';
|
|
11
|
+
import type { DeckSettingsProps } from '../types';
|
|
6
12
|
|
|
7
13
|
export const useHoistStatusbar = (breakpoint: string) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
14
|
-
return Number.isFinite(safeAreaBottom) && safeAreaBottom < 1 && breakpoint === 'desktop';
|
|
14
|
+
const enableIdeStyleStatusbar = useCapability(Capabilities.SettingsStore).getStore<DeckSettingsProps>(DECK_PLUGIN)!
|
|
15
|
+
.value.enableIdeStyleStatusbar;
|
|
16
|
+
const { safeAreaPadding } = useThemeContext();
|
|
17
|
+
return useMemo(() => {
|
|
18
|
+
return breakpoint === 'desktop' && enableIdeStyleStatusbar && safeAreaPadding?.bottom === 0;
|
|
19
|
+
}, [enableIdeStyleStatusbar, breakpoint, safeAreaPadding?.bottom]);
|
|
15
20
|
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/layout/app-graph-builder.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n Capabilities,\n contributes,\n createIntent,\n LayoutAction,\n NavigationAction,\n openIds,\n type PluginsContext,\n} from '@dxos/app-framework';\nimport { AttentionCapabilities } from '@dxos/plugin-attention';\nimport { createExtension, type Node, ROOT_ID } from '@dxos/plugin-graph';\n\nimport { DECK_PLUGIN } from '../../meta';\n\nexport default (context: PluginsContext) =>\n contributes(\n Capabilities.AppGraphBuilder,\n createExtension({\n id: DECK_PLUGIN,\n filter: (node): node is Node<null> => node.id === ROOT_ID,\n actions: () => {\n // NOTE(Zan): This is currently disabled.\n // TODO(Zan): Fullscreen needs to know the active node and provide that to the layout part.\n const _fullscreen = {\n id: `${LayoutAction.SetLayoutMode._tag}/fullscreen`,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(createIntent(LayoutAction.SetLayoutMode, { layoutMode: 'fullscreen' }));\n },\n properties: {\n label: ['toggle fullscreen label', { ns: DECK_PLUGIN }],\n icon: 'ph--arrows-out--regular',\n keyBinding: {\n macos: 'ctrl+meta+f',\n windows: 'shift+ctrl+f',\n },\n },\n };\n\n const closeCurrent = {\n id: `${NavigationAction.Close._tag}/current`,\n data: async () => {\n const attention = context.requestCapability(AttentionCapabilities.Attention);\n const attended = attention.current.at(-1);\n if (attended) {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(createIntent(NavigationAction.Close, { activeParts: { main: [attended] } }));\n }\n },\n properties: {\n label: ['close current label', { ns: DECK_PLUGIN }],\n icon: 'ph--x--regular',\n },\n };\n\n const closeOthers = {\n id: `${NavigationAction.Close._tag}/others`,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n const location = context.requestCapability(Capabilities.Location);\n const attention = context.requestCapability(AttentionCapabilities.Attention);\n const attended = attention.current.at(-1);\n const ids = openIds(location.active, ['main']).filter((id) => id !== attended);\n await dispatch(\n createIntent(NavigationAction.Close, {\n activeParts: { main: ids },\n }),\n );\n },\n properties: {\n label: ['close others label', { ns: DECK_PLUGIN }],\n icon: 'ph--x-square--regular',\n },\n };\n\n const closeAll = {\n id: `${NavigationAction.Close._tag}/all`,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n const location = context.requestCapability(Capabilities.Location);\n await dispatch(\n createIntent(NavigationAction.Close, {\n activeParts: { main: openIds(location.active, ['main']) },\n }),\n );\n },\n properties: {\n label: ['close all label', { ns: DECK_PLUGIN }],\n icon: 'ph--x-circle--regular',\n },\n };\n\n const layoutMode = context.requestCapabilities(Capabilities.Layout)[0]?.layoutMode;\n return layoutMode === 'deck' ? [closeCurrent, closeOthers, closeAll] : [];\n },\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SACEA,cACAC,aACAC,cACAC,cACAC,kBACAC,eAEK;AACP,SAASC,6BAA6B;AACtC,SAASC,iBAA4BC,eAAe;AAIpD,IAAA,4BAAe,CAACC,YACdC,YACEC,aAAaC,iBACbC,gBAAgB;EACdC,IAAIC;EACJC,QAAQ,CAACC,SAA6BA,KAAKH,OAAOI;EAClDC,SAAS,MAAA;AAGP,UAAMC,cAAc;MAClBN,IAAI,GAAGO,aAAaC,cAAcC,IAAI;MACtCC,MAAM,YAAA;AACJ,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKjB,QAAQkB,kBAAkBhB,aAAaiB,gBAAgB;AAC7F,cAAMF,SAASG,aAAaR,aAAaC,eAAe;UAAEQ,YAAY;QAAa,CAAA,CAAA;MACrF;MACAC,YAAY;QACVC,OAAO;UAAC;UAA2B;YAAEC,IAAIlB;UAAY;;QACrDmB,MAAM;QACNC,YAAY;UACVC,OAAO;UACPC,SAAS;QACX;MACF;IACF;AAEA,UAAMC,eAAe;MACnBxB,IAAI,GAAGyB,iBAAiBC,MAAMjB,IAAI;MAClCC,MAAM,YAAA;AACJ,cAAMiB,YAAYhC,QAAQkB,kBAAkBe,sBAAsBC,SAAS;AAC3E,cAAMC,WAAWH,UAAUI,QAAQC,GAAG,EAAC;AACvC,YAAIF,UAAU;AACZ,gBAAM,EAAEnB,iBAAiBC,SAAQ,IAAKjB,QAAQkB,kBAAkBhB,aAAaiB,gBAAgB;AAC7F,gBAAMF,SAASG,aAAaU,iBAAiBC,OAAO;YAAEO,aAAa;cAAEC,MAAM;gBAACJ;;YAAU;UAAE,CAAA,CAAA;QAC1F;MACF;MACAb,YAAY;QACVC,OAAO;UAAC;UAAuB;YAAEC,IAAIlB;UAAY;;QACjDmB,MAAM;MACR;IACF;AAEA,UAAMe,cAAc;MAClBnC,IAAI,GAAGyB,iBAAiBC,MAAMjB,IAAI;MAClCC,MAAM,YAAA;AACJ,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKjB,QAAQkB,kBAAkBhB,aAAaiB,gBAAgB;AAC7F,cAAMsB,WAAWzC,QAAQkB,kBAAkBhB,aAAawC,QAAQ;AAChE,cAAMV,YAAYhC,QAAQkB,kBAAkBe,sBAAsBC,SAAS;AAC3E,cAAMC,WAAWH,UAAUI,QAAQC,GAAG,EAAC;AACvC,cAAMM,MAAMC,QAAQH,SAASI,QAAQ;UAAC;SAAO,EAAEtC,OAAO,CAACF,OAAOA,OAAO8B,QAAAA;AACrE,cAAMlB,SACJG,aAAaU,iBAAiBC,OAAO;UACnCO,aAAa;YAAEC,MAAMI;UAAI;QAC3B,CAAA,CAAA;MAEJ;MACArB,YAAY;QACVC,OAAO;UAAC;UAAsB;YAAEC,IAAIlB;UAAY;;QAChDmB,MAAM;MACR;IACF;AAEA,UAAMqB,WAAW;MACfzC,IAAI,GAAGyB,iBAAiBC,MAAMjB,IAAI;MAClCC,MAAM,YAAA;AACJ,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKjB,QAAQkB,kBAAkBhB,aAAaiB,gBAAgB;AAC7F,cAAMsB,WAAWzC,QAAQkB,kBAAkBhB,aAAawC,QAAQ;AAChE,cAAMzB,SACJG,aAAaU,iBAAiBC,OAAO;UACnCO,aAAa;YAAEC,MAAMK,QAAQH,SAASI,QAAQ;cAAC;aAAO;UAAE;QAC1D,CAAA,CAAA;MAEJ;MACAvB,YAAY;QACVC,OAAO;UAAC;UAAmB;YAAEC,IAAIlB;UAAY;;QAC7CmB,MAAM;MACR;IACF;AAEA,UAAMJ,aAAarB,QAAQ+C,oBAAoB7C,aAAa8C,MAAM,EAAE,CAAA,GAAI3B;AACxE,WAAOA,eAAe,SAAS;MAACQ;MAAcW;MAAaM;QAAY,CAAA;EACzE;AACF,CAAA,CAAA;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createIntent", "LayoutAction", "NavigationAction", "openIds", "AttentionCapabilities", "createExtension", "ROOT_ID", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "DECK_PLUGIN", "filter", "node", "ROOT_ID", "actions", "_fullscreen", "LayoutAction", "SetLayoutMode", "_tag", "data", "dispatchPromise", "dispatch", "requestCapability", "IntentDispatcher", "createIntent", "layoutMode", "properties", "label", "ns", "icon", "keyBinding", "macos", "windows", "closeCurrent", "NavigationAction", "Close", "attention", "AttentionCapabilities", "Attention", "attended", "current", "at", "activeParts", "main", "closeOthers", "location", "Location", "ids", "openIds", "active", "closeAll", "requestCapabilities", "Layout"]
|
|
7
|
-
}
|