@dxos/plugin-deck 0.8.4-main.1da679c → 0.8.4-main.21d9917
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-DTVCULQ4.mjs +120 -0
- package/dist/lib/browser/app-graph-builder-DTVCULQ4.mjs.map +7 -0
- package/dist/lib/browser/{check-app-scheme-BKIOCWXT.mjs → check-app-scheme-JSRXXIYF.mjs} +9 -9
- package/dist/lib/browser/check-app-scheme-JSRXXIYF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-F5BQOOEG.mjs → chunk-ATFPDN6J.mjs} +155 -23
- package/dist/lib/browser/chunk-ATFPDN6J.mjs.map +7 -0
- package/dist/lib/browser/chunk-EREEXCHO.mjs +1448 -0
- package/dist/lib/browser/chunk-EREEXCHO.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CNTGBCMK.mjs → chunk-NHABISX2.mjs} +40 -33
- package/dist/lib/browser/chunk-NHABISX2.mjs.map +7 -0
- package/dist/lib/browser/chunk-UNG4CLLP.mjs +161 -0
- package/dist/lib/browser/chunk-UNG4CLLP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +73 -68
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-CDYBLZJ4.mjs +595 -0
- package/dist/lib/browser/operation-resolver-CDYBLZJ4.mjs.map +7 -0
- package/dist/lib/browser/react-root-LYNEKGHM.mjs +47 -0
- package/dist/lib/browser/react-root-LYNEKGHM.mjs.map +7 -0
- package/dist/lib/browser/react-surface-RPKD7XUR.mjs +42 -0
- package/dist/lib/browser/react-surface-RPKD7XUR.mjs.map +7 -0
- package/dist/lib/browser/settings-OMHVGZ6V.mjs +37 -0
- package/dist/lib/browser/settings-OMHVGZ6V.mjs.map +7 -0
- package/dist/lib/browser/state-OC3BSB6E.mjs +103 -0
- package/dist/lib/browser/state-OC3BSB6E.mjs.map +7 -0
- package/dist/lib/browser/toolkit-R53LD3EA.mjs +53 -0
- package/dist/lib/browser/toolkit-R53LD3EA.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +11 -4
- package/dist/lib/browser/url-handler-53TE6JZO.mjs +93 -0
- package/dist/lib/browser/url-handler-53TE6JZO.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-473BNZDJ.mjs +121 -0
- package/dist/lib/node-esm/app-graph-builder-473BNZDJ.mjs.map +7 -0
- package/dist/lib/node-esm/check-app-scheme-IVYRHKRH.mjs +33 -0
- package/dist/lib/node-esm/check-app-scheme-IVYRHKRH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ADPMWKLL.mjs +154 -0
- package/dist/lib/node-esm/chunk-ADPMWKLL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SKEVPQ7E.mjs +162 -0
- package/dist/lib/node-esm/chunk-SKEVPQ7E.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-V6VEXRD4.mjs +1449 -0
- package/dist/lib/node-esm/chunk-V6VEXRD4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XAKTY3EB.mjs +294 -0
- package/dist/lib/node-esm/chunk-XAKTY3EB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +181 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/operation-resolver-WUOE33ID.mjs +596 -0
- package/dist/lib/node-esm/operation-resolver-WUOE33ID.mjs.map +7 -0
- package/dist/lib/node-esm/react-root-L7H43AS3.mjs +48 -0
- package/dist/lib/node-esm/react-root-L7H43AS3.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-77DKVMDV.mjs +43 -0
- package/dist/lib/node-esm/react-surface-77DKVMDV.mjs.map +7 -0
- package/dist/lib/node-esm/settings-2HB6FKIK.mjs +38 -0
- package/dist/lib/node-esm/settings-2HB6FKIK.mjs.map +7 -0
- package/dist/lib/node-esm/state-JRQ45ACJ.mjs +104 -0
- package/dist/lib/node-esm/state-JRQ45ACJ.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-JLPZNNKB.mjs +54 -0
- package/dist/lib/node-esm/toolkit-JLPZNNKB.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +40 -0
- package/dist/lib/node-esm/url-handler-QGF2R24T.mjs +94 -0
- package/dist/lib/node-esm/url-handler-QGF2R24T.mjs.map +7 -0
- package/dist/types/src/DeckPlugin.d.ts +2 -1
- package/dist/types/src/DeckPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/check-app-scheme/check-app-scheme.d.ts +5 -0
- package/dist/types/src/capabilities/check-app-scheme/check-app-scheme.d.ts.map +1 -0
- package/dist/types/src/capabilities/check-app-scheme/index.d.ts +3 -0
- package/dist/types/src/capabilities/check-app-scheme/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -13
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/index.d.ts +6 -0
- package/dist/types/src/capabilities/react-root/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts +9 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +19 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +21 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +172 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +175 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
- package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts +26 -0
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
- package/dist/types/src/capabilities/tools/index.d.ts +3 -0
- package/dist/types/src/capabilities/tools/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/tools/tools.d.ts +12 -0
- package/dist/types/src/capabilities/tools/tools.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/index.d.ts +3 -0
- package/dist/types/src/capabilities/url-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +5 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +2 -3
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.stories.d.ts +74 -0
- package/dist/types/src/components/DeckLayout/DeckLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/DeckLayout/DeckMain.d.ts +3 -0
- package/dist/types/src/components/DeckLayout/DeckMain.d.ts.map +1 -0
- package/dist/types/src/components/DeckLayout/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Popover.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Toast.d.ts +7 -2
- package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
- package/dist/types/src/components/DeckSettings/DeckSettings.d.ts +4 -2
- package/dist/types/src/components/DeckSettings/DeckSettings.d.ts.map +1 -1
- package/dist/types/src/components/Plank/Plank.d.ts +3 -3
- package/dist/types/src/components/Plank/Plank.d.ts.map +1 -1
- package/dist/types/src/components/Plank/Plank.stories.d.ts +25 -6
- package/dist/types/src/components/Plank/Plank.stories.d.ts.map +1 -1
- package/dist/types/src/components/Plank/PlankControls.d.ts +1 -1
- package/dist/types/src/components/Plank/PlankControls.d.ts.map +1 -1
- package/dist/types/src/components/Plank/PlankError.d.ts +1 -1
- package/dist/types/src/components/Plank/PlankError.d.ts.map +1 -1
- package/dist/types/src/components/Plank/PlankHeading.d.ts +2 -2
- package/dist/types/src/components/Plank/PlankHeading.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/ComplementarySidebar.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/SidebarButton.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDeckCompanions.d.ts +3 -3
- package/dist/types/src/hooks/useDeckCompanions.d.ts.map +1 -1
- package/dist/types/src/hooks/useDeckState.d.ts +17 -0
- package/dist/types/src/hooks/useDeckState.d.ts.map +1 -0
- package/dist/types/src/hooks/useHoistStatusbar.d.ts +1 -1
- package/dist/types/src/hooks/useHoistStatusbar.d.ts.map +1 -1
- package/dist/types/src/hooks/useNodeActionExpander.d.ts +1 -1
- package/dist/types/src/hooks/useNodeActionExpander.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +96 -90
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +7 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +90 -30
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/set-active.d.ts +18 -3
- package/dist/types/src/util/set-active.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +54 -48
- package/src/DeckPlugin.ts +44 -66
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +118 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{check-app-scheme.ts → check-app-scheme/check-app-scheme.ts} +12 -11
- package/src/capabilities/check-app-scheme/index.ts +7 -0
- package/src/capabilities/index.ts +9 -14
- package/src/capabilities/operation-resolver/index.ts +10 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +555 -0
- package/src/capabilities/react-root/index.ts +7 -0
- package/src/capabilities/react-root/react-root.tsx +47 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +37 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +38 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +104 -0
- package/src/capabilities/toolkit/index.ts +7 -0
- package/src/capabilities/toolkit/toolkit.ts +63 -0
- package/src/capabilities/tools/index.ts +7 -0
- package/src/capabilities/tools/tools.ts +92 -0
- package/src/capabilities/url-handler/index.ts +7 -0
- package/src/capabilities/url-handler/url-handler.ts +95 -0
- package/src/components/DeckLayout/ActiveNode.tsx +1 -1
- package/src/components/DeckLayout/Banner.tsx +5 -5
- package/src/components/DeckLayout/ContentEmpty.tsx +3 -4
- package/src/components/DeckLayout/DeckLayout.stories.tsx +51 -0
- package/src/components/DeckLayout/DeckLayout.tsx +17 -285
- package/src/components/DeckLayout/DeckMain.tsx +286 -0
- package/src/components/DeckLayout/Dialog.tsx +13 -10
- package/src/components/DeckLayout/Fallback.tsx +4 -4
- package/src/components/DeckLayout/Popover.tsx +44 -32
- package/src/components/DeckLayout/StatusBar.tsx +1 -1
- package/src/components/DeckLayout/Toast.tsx +30 -5
- package/src/components/DeckSettings/DeckSettings.tsx +26 -10
- package/src/components/Plank/Plank.stories.tsx +17 -11
- package/src/components/Plank/Plank.tsx +86 -54
- package/src/components/Plank/PlankControls.tsx +9 -9
- package/src/components/Plank/PlankError.tsx +4 -4
- package/src/components/Plank/PlankHeading.tsx +35 -40
- package/src/components/Sidebar/ComplementarySidebar.tsx +58 -31
- package/src/components/Sidebar/Sidebar.tsx +6 -6
- package/src/components/Sidebar/SidebarButton.tsx +39 -32
- package/src/components/fragments.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCompanions.ts +1 -1
- package/src/hooks/useDeckCompanions.ts +6 -4
- package/src/hooks/useDeckState.ts +82 -0
- package/src/hooks/useHoistStatusbar.ts +4 -5
- package/src/hooks/useNodeActionExpander.ts +4 -4
- package/src/index.ts +1 -2
- package/src/meta.ts +8 -5
- package/src/translations.ts +2 -1
- package/src/types/capabilities.ts +33 -0
- package/src/types/events.ts +20 -0
- package/src/types/index.ts +2 -0
- package/src/types/schema.ts +86 -14
- package/src/util/layoutAppliesTopbar.ts +1 -1
- package/src/util/set-active.ts +49 -29
- package/dist/lib/browser/app-graph-builder-DD2EJBLZ.mjs +0 -152
- package/dist/lib/browser/app-graph-builder-DD2EJBLZ.mjs.map +0 -7
- package/dist/lib/browser/check-app-scheme-BKIOCWXT.mjs.map +0 -7
- package/dist/lib/browser/chunk-CNTGBCMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-F5BQOOEG.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMGWFTHR.mjs +0 -1498
- package/dist/lib/browser/chunk-FMGWFTHR.mjs.map +0 -7
- package/dist/lib/browser/chunk-KCXWTPSU.mjs +0 -127
- package/dist/lib/browser/chunk-KCXWTPSU.mjs.map +0 -7
- package/dist/lib/browser/chunk-M57WD3V6.mjs +0 -16
- package/dist/lib/browser/chunk-M57WD3V6.mjs.map +0 -7
- package/dist/lib/browser/chunk-NRCPV6AV.mjs +0 -129
- package/dist/lib/browser/chunk-NRCPV6AV.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z5KITAZW.mjs +0 -13
- package/dist/lib/browser/chunk-Z5KITAZW.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-XSCCU7JI.mjs +0 -521
- package/dist/lib/browser/intent-resolver-XSCCU7JI.mjs.map +0 -7
- package/dist/lib/browser/react-root-E54PO26O.mjs +0 -43
- package/dist/lib/browser/react-root-E54PO26O.mjs.map +0 -7
- package/dist/lib/browser/react-surface-DIZC3J4P.mjs +0 -40
- package/dist/lib/browser/react-surface-DIZC3J4P.mjs.map +0 -7
- package/dist/lib/browser/settings-RNPLZT5S.mjs +0 -29
- package/dist/lib/browser/settings-RNPLZT5S.mjs.map +0 -7
- package/dist/lib/browser/state-CRXR7X63.mjs +0 -12
- package/dist/lib/browser/toolkit-HPFRHY67.mjs +0 -61
- package/dist/lib/browser/toolkit-HPFRHY67.mjs.map +0 -7
- package/dist/lib/browser/url-handler-6IJME37M.mjs +0 -70
- package/dist/lib/browser/url-handler-6IJME37M.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/check-app-scheme.d.ts +0 -4
- package/dist/types/src/capabilities/check-app-scheme.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root.d.ts +0 -7
- package/dist/types/src/capabilities/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -101
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit.d.ts +0 -5
- package/dist/types/src/capabilities/toolkit.d.ts.map +0 -1
- package/dist/types/src/capabilities/tools.d.ts +0 -11
- package/dist/types/src/capabilities/tools.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler.d.ts +0 -4
- package/dist/types/src/capabilities/url-handler.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -142
- package/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/intent-resolver.ts +0 -469
- package/src/capabilities/react-root.tsx +0 -39
- package/src/capabilities/react-surface.tsx +0 -30
- package/src/capabilities/settings.ts +0 -26
- package/src/capabilities/state.ts +0 -105
- package/src/capabilities/toolkit.ts +0 -55
- package/src/capabilities/tools.ts +0 -84
- package/src/capabilities/url-handler.ts +0 -60
- package/src/events.ts +0 -11
- /package/dist/lib/{browser/state-CRXR7X63.mjs.map → node-esm/types/index.mjs.map} +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import { useCallback, useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Common } from '@dxos/app-framework';
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/react';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
DeckCapabilities,
|
|
14
|
+
type DeckEphemeralStateProps,
|
|
15
|
+
type DeckPluginState,
|
|
16
|
+
type DeckState,
|
|
17
|
+
type DeckStateProps,
|
|
18
|
+
} from '../types';
|
|
19
|
+
|
|
20
|
+
export type DeckStateHook = {
|
|
21
|
+
/** Combined state value (reactive). Includes both persisted and ephemeral state. */
|
|
22
|
+
state: DeckPluginState;
|
|
23
|
+
/** The active deck, computed from decks[activeDeck]. */
|
|
24
|
+
deck: DeckState;
|
|
25
|
+
/** Update persisted state. */
|
|
26
|
+
updateState: (fn: (current: DeckStateProps) => DeckStateProps) => void;
|
|
27
|
+
/** Update ephemeral state. */
|
|
28
|
+
updateEphemeral: (fn: (current: DeckEphemeralStateProps) => DeckEphemeralStateProps) => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Hook to access the deck plugin state reactively.
|
|
33
|
+
* Returns the combined state, the active deck, and update functions for each atom.
|
|
34
|
+
*/
|
|
35
|
+
export const useDeckState = (): DeckStateHook => {
|
|
36
|
+
const registry = useCapability(Common.Capability.AtomRegistry);
|
|
37
|
+
const stateAtom = useCapability(DeckCapabilities.State);
|
|
38
|
+
const ephemeralAtom = useCapability(DeckCapabilities.EphemeralState);
|
|
39
|
+
|
|
40
|
+
const persistedState = useAtomValue(stateAtom);
|
|
41
|
+
const ephemeralState = useAtomValue(ephemeralAtom);
|
|
42
|
+
|
|
43
|
+
// Compute deck from decks[activeDeck] to ensure it's always current.
|
|
44
|
+
const deck = useMemo(() => {
|
|
45
|
+
const d = persistedState.decks[persistedState.activeDeck];
|
|
46
|
+
invariant(d, `Deck not found: ${persistedState.activeDeck}`);
|
|
47
|
+
return d;
|
|
48
|
+
}, [persistedState.decks, persistedState.activeDeck]);
|
|
49
|
+
|
|
50
|
+
// Combine persisted and ephemeral state into a unified view.
|
|
51
|
+
const state = useMemo(
|
|
52
|
+
(): DeckPluginState => ({
|
|
53
|
+
...persistedState,
|
|
54
|
+
...ephemeralState,
|
|
55
|
+
}),
|
|
56
|
+
[persistedState, ephemeralState],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const updateState = useCallback(
|
|
60
|
+
(fn: (current: DeckStateProps) => DeckStateProps) => {
|
|
61
|
+
registry.set(stateAtom, fn(registry.get(stateAtom)));
|
|
62
|
+
},
|
|
63
|
+
[registry, stateAtom],
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const updateEphemeral = useCallback(
|
|
67
|
+
(fn: (current: DeckEphemeralStateProps) => DeckEphemeralStateProps) => {
|
|
68
|
+
registry.set(ephemeralAtom, fn(registry.get(ephemeralAtom)));
|
|
69
|
+
},
|
|
70
|
+
[registry, ephemeralAtom],
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return useMemo(
|
|
74
|
+
() => ({
|
|
75
|
+
state,
|
|
76
|
+
deck,
|
|
77
|
+
updateState,
|
|
78
|
+
updateEphemeral,
|
|
79
|
+
}),
|
|
80
|
+
[state, deck, updateState, updateEphemeral],
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useAtomCapability } from '@dxos/app-framework/react';
|
|
8
8
|
import { useThemeContext } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import type { DeckSettingsProps, LayoutMode } from '../types';
|
|
10
|
+
import { DeckCapabilities, type LayoutMode } from '../types';
|
|
12
11
|
|
|
13
12
|
export const useHoistStatusbar = (breakpoint: string, layoutMode?: LayoutMode): boolean => {
|
|
14
|
-
const enableStatusbar = useCapability(Capabilities.SettingsStore).getStore<DeckSettingsProps>(DECK_PLUGIN)!.value
|
|
15
|
-
.enableStatusbar;
|
|
16
13
|
const { safeAreaPadding } = useThemeContext();
|
|
14
|
+
const enableStatusbar = useAtomCapability(DeckCapabilities.Settings).enableStatusbar;
|
|
15
|
+
|
|
17
16
|
return useMemo(() => {
|
|
18
17
|
return (
|
|
19
18
|
breakpoint === 'desktop' &&
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Node
|
|
7
|
+
import { Graph, type Node } from '@dxos/plugin-graph';
|
|
8
8
|
|
|
9
|
-
export const useNodeActionExpander = (node?: Node) => {
|
|
9
|
+
export const useNodeActionExpander = (node?: Node.Node) => {
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
if (node) {
|
|
12
12
|
const frame = requestAnimationFrame(() => {
|
|
13
|
-
const graph = getGraph(node);
|
|
14
|
-
void
|
|
13
|
+
const graph = Graph.getGraph(node);
|
|
14
|
+
void Graph.expand(graph, node.id);
|
|
15
15
|
});
|
|
16
16
|
return () => cancelAnimationFrame(frame);
|
|
17
17
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export { DeckCapabilities } from './
|
|
6
|
-
export { DeckEvents } from './events';
|
|
5
|
+
export { DeckCapabilities, DeckEvents } from './types';
|
|
7
6
|
export * from './DeckPlugin';
|
|
8
7
|
export * from './meta';
|
|
9
8
|
export { useCompanions } from './hooks';
|
package/src/meta.ts
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: DECK_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'dxos.org/plugin/deck',
|
|
11
10
|
name: 'Layout',
|
|
11
|
+
description: trim`
|
|
12
|
+
Flexible layout system for arranging workspace views in tabs, splits, and panels.
|
|
13
|
+
Customize your workspace organization with drag-and-drop layout management.
|
|
14
|
+
`,
|
|
12
15
|
icon: 'ph--layout--regular',
|
|
13
16
|
};
|
package/src/translations.ts
CHANGED
|
@@ -34,7 +34,7 @@ export const translations = [
|
|
|
34
34
|
'undo action label': 'Undo',
|
|
35
35
|
'undo action alt': 'Undo previous action',
|
|
36
36
|
'undo close label': 'Dismiss',
|
|
37
|
-
'error fallback message': 'Unable to open this
|
|
37
|
+
'error fallback message': 'Unable to open this object',
|
|
38
38
|
'plank heading fallback label': 'Untitled',
|
|
39
39
|
'actions menu label': 'Options',
|
|
40
40
|
'settings deck label': 'Disable deck',
|
|
@@ -59,6 +59,7 @@ export const translations = [
|
|
|
59
59
|
'settings overscroll none label': 'None',
|
|
60
60
|
'settings enable statusbar label': 'Show status bar',
|
|
61
61
|
'settings enable deck label': 'Enable Deck',
|
|
62
|
+
'settings encapsulated planks label': 'Encapsulated planks',
|
|
62
63
|
'close current label': 'Close current plank',
|
|
63
64
|
'close others label': 'Close other planks',
|
|
64
65
|
'close all label': 'Close all planks',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
import { type DeckEphemeralStateProps, type DeckSettingsProps, type DeckState, type DeckStateProps } from '../types';
|
|
13
|
+
|
|
14
|
+
export namespace DeckCapabilities {
|
|
15
|
+
export const Settings = Capability.make<Atom.Writable<DeckSettingsProps>>(`${meta.id}/capability/settings`);
|
|
16
|
+
|
|
17
|
+
/** Persisted state (stored in KVS/localStorage). */
|
|
18
|
+
export const State = Capability.make<Atom.Writable<DeckStateProps>>(`${meta.id}/capability/state`);
|
|
19
|
+
|
|
20
|
+
/** Transient/ephemeral state (not persisted). */
|
|
21
|
+
export const EphemeralState = Capability.make<Atom.Writable<DeckEphemeralStateProps>>(
|
|
22
|
+
`${meta.id}/capability/ephemeral-state`,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/** Get the current active deck from state. */
|
|
26
|
+
export const getDeck = (): Effect.Effect<DeckState, Error, Capability.Service> =>
|
|
27
|
+
Effect.gen(function* () {
|
|
28
|
+
const state = yield* Common.Capability.getAtomValue(State);
|
|
29
|
+
const deck = state.decks[state.activeDeck];
|
|
30
|
+
invariant(deck, `Deck not found: ${state.activeDeck}`);
|
|
31
|
+
return deck;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ActivationEvent, Common } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from '../meta';
|
|
8
|
+
|
|
9
|
+
import { DeckCapabilities } from './capabilities';
|
|
10
|
+
|
|
11
|
+
export namespace DeckEvents {
|
|
12
|
+
export const StateReady: ActivationEvent.ActivationEvent = Common.ActivationEvent.createStateEvent(
|
|
13
|
+
`${meta.id}/state-ready`,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/** Fired when DeckSettings capability is ready. */
|
|
17
|
+
export const SettingsReady: ActivationEvent.ActivationEvent = Common.ActivationEvent.createSettingsEvent(
|
|
18
|
+
DeckCapabilities.Settings.identifier,
|
|
19
|
+
);
|
|
20
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/schema.ts
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
8
9
|
import { type DeepReadonly } from '@dxos/util';
|
|
9
10
|
|
|
10
11
|
import { meta } from '../meta';
|
|
11
12
|
|
|
12
13
|
export { ATTENDABLE_PATH_SEPARATOR } from '@dxos/react-ui-attention';
|
|
13
14
|
|
|
14
|
-
export const PLANK_COMPANION_TYPE =
|
|
15
|
-
export const DECK_COMPANION_TYPE =
|
|
15
|
+
export const PLANK_COMPANION_TYPE = `${meta.id}/plank-companion`;
|
|
16
|
+
export const DECK_COMPANION_TYPE = `${meta.id}/deck-companion`;
|
|
16
17
|
|
|
17
18
|
// TODO(Zan): In the future we should consider adding new planks adjacent to the attended plank.
|
|
18
19
|
export const NewPlankPositions = ['start', 'end'] as const;
|
|
@@ -31,6 +32,8 @@ export const DeckSettingsSchema = Schema.Struct({
|
|
|
31
32
|
enableNativeRedirect: Schema.optional(Schema.Boolean),
|
|
32
33
|
newPlankPositioning: Schema.optional(Schema.Literal(...NewPlankPositions)),
|
|
33
34
|
overscroll: Schema.optional(Schema.Literal(...OverscrollOptions)),
|
|
35
|
+
// TODO(burdon): Rename layoutMode? (e.g., bento | encapsulated?)
|
|
36
|
+
encapsulatedPlanks: Schema.optional(Schema.Boolean),
|
|
34
37
|
}).pipe(Schema.mutable);
|
|
35
38
|
export type DeckSettingsProps = Schema.Schema.Type<typeof DeckSettingsSchema>;
|
|
36
39
|
|
|
@@ -75,12 +78,20 @@ export const getMode = (deck: DeckState | DeepReadonly<DeckState>): LayoutMode =
|
|
|
75
78
|
return 'deck';
|
|
76
79
|
};
|
|
77
80
|
|
|
78
|
-
//
|
|
79
|
-
export const
|
|
81
|
+
// Persisted plugin state (stored in KVS/localStorage).
|
|
82
|
+
export const DeckStateSchema = Schema.Struct({
|
|
80
83
|
sidebarState: Schema.Literal('closed', 'collapsed', 'expanded'),
|
|
81
84
|
complementarySidebarState: Schema.Literal('closed', 'collapsed', 'expanded'),
|
|
82
85
|
complementarySidebarPanel: Schema.optional(Schema.String),
|
|
86
|
+
activeDeck: Schema.String,
|
|
87
|
+
previousDeck: Schema.String,
|
|
88
|
+
decks: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(DeckState) })),
|
|
89
|
+
previousMode: Schema.mutable(Schema.Record({ key: Schema.String, value: LayoutMode })),
|
|
90
|
+
}).pipe(Schema.mutable);
|
|
91
|
+
export type DeckStateProps = Schema.Schema.Type<typeof DeckStateSchema>;
|
|
83
92
|
|
|
93
|
+
// Transient/ephemeral plugin state (not persisted).
|
|
94
|
+
export const DeckEphemeralStateSchema = Schema.Struct({
|
|
84
95
|
dialogOpen: Schema.Boolean,
|
|
85
96
|
dialogType: Schema.optional(Schema.Literal('default', 'alert')),
|
|
86
97
|
dialogBlockAlign: Schema.optional(Schema.Literal('start', 'center', 'end')),
|
|
@@ -93,23 +104,21 @@ export const DeckPluginState = Schema.Struct({
|
|
|
93
104
|
popoverSide: Schema.optional(Schema.Literal('top', 'right', 'bottom', 'left')),
|
|
94
105
|
popoverAnchor: Schema.optional(Schema.Any),
|
|
95
106
|
popoverAnchorId: Schema.optional(Schema.String),
|
|
107
|
+
popoverKind: Schema.optional(Schema.Literal('base', 'card')),
|
|
108
|
+
popoverTitle: Schema.optional(Common.Label.annotations({ description: 'The title of the popover.' })),
|
|
96
109
|
/** Data to be passed to the popover Surface. */
|
|
97
110
|
popoverContent: Schema.optional(Schema.Any),
|
|
98
111
|
|
|
99
|
-
toasts: Schema.mutable(Schema.Array(
|
|
112
|
+
toasts: Schema.mutable(Schema.Array(Common.LayoutOperation.Toast)),
|
|
100
113
|
currentUndoId: Schema.optional(Schema.String),
|
|
101
114
|
|
|
102
|
-
activeDeck: Schema.String,
|
|
103
|
-
previousDeck: Schema.String,
|
|
104
|
-
decks: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(DeckState) })),
|
|
105
|
-
previousMode: Schema.mutable(Schema.Record({ key: Schema.String, value: LayoutMode })),
|
|
106
|
-
deck: Schema.mutable(DeckState),
|
|
107
|
-
|
|
108
115
|
/** The identifier of a component to scroll into view when it is mounted. */
|
|
109
116
|
scrollIntoView: Schema.optional(Schema.String),
|
|
110
117
|
}).pipe(Schema.mutable);
|
|
118
|
+
export type DeckEphemeralStateProps = Schema.Schema.Type<typeof DeckEphemeralStateSchema>;
|
|
111
119
|
|
|
112
|
-
|
|
120
|
+
// Combined state type (for convenience in components that need both).
|
|
121
|
+
export type DeckPluginState = DeckStateProps & DeckEphemeralStateProps;
|
|
113
122
|
|
|
114
123
|
export namespace DeckAction {
|
|
115
124
|
const PartAdjustmentSchema = Schema.Union(
|
|
@@ -146,3 +155,66 @@ export namespace DeckAction {
|
|
|
146
155
|
output: Schema.Void,
|
|
147
156
|
}) {}
|
|
148
157
|
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Operations for the Deck plugin.
|
|
161
|
+
*/
|
|
162
|
+
export namespace DeckOperation {
|
|
163
|
+
const PartAdjustmentSchema = Schema.Union(
|
|
164
|
+
Schema.Literal('close').annotations({ description: 'Close the plank.' }),
|
|
165
|
+
Schema.Literal('companion').annotations({ description: 'Open the companion plank.' }),
|
|
166
|
+
Schema.Literal('solo').annotations({ description: 'Solo the plank.' }),
|
|
167
|
+
Schema.Literal('solo--fullscreen').annotations({ description: 'Fullscreen the plank.' }),
|
|
168
|
+
Schema.Literal('increment-start').annotations({ description: 'Move the plank towards the start of the deck.' }),
|
|
169
|
+
Schema.Literal('increment-end').annotations({ description: 'Move the plank towards the end of the deck.' }),
|
|
170
|
+
);
|
|
171
|
+
export type PartAdjustment = Schema.Schema.Type<typeof PartAdjustmentSchema>;
|
|
172
|
+
|
|
173
|
+
export const Adjust = Operation.make({
|
|
174
|
+
meta: {
|
|
175
|
+
key: `${meta.id}/operation/adjust`,
|
|
176
|
+
name: 'Adjust',
|
|
177
|
+
description: 'Adjust the layout of a plank.',
|
|
178
|
+
},
|
|
179
|
+
services: [Capability.Service],
|
|
180
|
+
schema: {
|
|
181
|
+
input: Schema.Struct({
|
|
182
|
+
id: Schema.String.annotations({ description: 'The id of the plank to adjust.' }),
|
|
183
|
+
type: PartAdjustmentSchema.annotations({ description: 'The type of adjustment to make.' }),
|
|
184
|
+
}),
|
|
185
|
+
output: Schema.Void,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
export const UpdatePlankSize = Operation.make({
|
|
190
|
+
meta: {
|
|
191
|
+
key: `${meta.id}/operation/update-plank-size`,
|
|
192
|
+
name: 'Update Plank Size',
|
|
193
|
+
description: 'Update the size of a plank.',
|
|
194
|
+
},
|
|
195
|
+
services: [Capability.Service],
|
|
196
|
+
schema: {
|
|
197
|
+
input: Schema.Struct({
|
|
198
|
+
id: Schema.String.annotations({ description: 'The id of the plank to resize.' }),
|
|
199
|
+
size: Schema.Number.annotations({ description: 'The new size of the plank.' }),
|
|
200
|
+
}),
|
|
201
|
+
output: Schema.Void,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
export const ChangeCompanion = Operation.make({
|
|
206
|
+
meta: {
|
|
207
|
+
key: `${meta.id}/operation/change-companion`,
|
|
208
|
+
name: 'Change Companion',
|
|
209
|
+
description: 'Change the companion plank for a primary plank.',
|
|
210
|
+
},
|
|
211
|
+
services: [Capability.Service],
|
|
212
|
+
schema: {
|
|
213
|
+
input: Schema.Struct({
|
|
214
|
+
primary: Schema.String,
|
|
215
|
+
companion: Schema.Union(Schema.String, Schema.Null),
|
|
216
|
+
}),
|
|
217
|
+
output: Schema.Void,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
}
|
|
@@ -6,7 +6,7 @@ import { type LayoutMode } from '../types';
|
|
|
6
6
|
|
|
7
7
|
export const layoutAppliesTopbar = (breakpoint: string, layoutMode?: LayoutMode) => {
|
|
8
8
|
return (
|
|
9
|
-
document.body.getAttribute('data-platform') === '
|
|
9
|
+
document.body.getAttribute('data-platform') === 'windows' &&
|
|
10
10
|
breakpoint === 'desktop' &&
|
|
11
11
|
layoutMode !== 'solo--fullscreen'
|
|
12
12
|
);
|
package/src/util/set-active.ts
CHANGED
|
@@ -2,46 +2,66 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { batch } from '@preact/signals-core';
|
|
6
|
-
|
|
7
5
|
import { type AttentionManager } from '@dxos/plugin-attention';
|
|
8
6
|
|
|
9
|
-
import { type
|
|
7
|
+
import { type DeckState } from '../types';
|
|
10
8
|
|
|
11
9
|
export type SetActiveOptions = {
|
|
12
10
|
next: string[];
|
|
13
|
-
|
|
11
|
+
deck: DeckState;
|
|
14
12
|
attention?: AttentionManager;
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
export type SetActiveResult = {
|
|
16
|
+
/** Updates to apply to the deck. */
|
|
17
|
+
deckUpdates: {
|
|
18
|
+
inactive: string[];
|
|
19
|
+
solo: string | undefined;
|
|
20
|
+
active: string[];
|
|
21
|
+
fullscreen: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** ID of the item to attend (scroll into view) if attention changed. */
|
|
24
|
+
toAttend?: string;
|
|
25
|
+
};
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Computes the new active state for the deck without mutating.
|
|
29
|
+
* Returns the updates to apply and optionally an item to attend.
|
|
30
|
+
*/
|
|
31
|
+
export const computeActiveUpdates = ({ next, deck, attention }: SetActiveOptions): SetActiveResult => {
|
|
32
|
+
const active = deck.solo ? [deck.solo] : deck.active;
|
|
33
|
+
const removed = active.filter((id) => !next.includes(id));
|
|
34
|
+
const closed = Array.from(new Set([...deck.inactive.filter((id) => !next.includes(id)), ...removed]));
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const updates = {
|
|
37
|
+
inactive: closed,
|
|
38
|
+
solo: deck.solo,
|
|
39
|
+
active: deck.active,
|
|
40
|
+
fullscreen: deck.fullscreen,
|
|
41
|
+
};
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
if (deck.solo || !deck.initialized) {
|
|
44
|
+
updates.solo = next[0];
|
|
45
|
+
} else {
|
|
46
|
+
updates.active = next;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (deck.fullscreen && !updates.solo) {
|
|
50
|
+
updates.fullscreen = false;
|
|
51
|
+
}
|
|
34
52
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
let toAttend: string | undefined;
|
|
54
|
+
if (attention) {
|
|
55
|
+
const attended = attention.getCurrent();
|
|
56
|
+
const [attendedId] = Array.from(attended);
|
|
57
|
+
const isAttendedAvailable = !!attendedId && next.includes(attendedId);
|
|
58
|
+
if (!isAttendedAvailable) {
|
|
59
|
+
const attendedIndex = active.indexOf(attendedId);
|
|
60
|
+
// If outside of bounds, focus on the first/last plank, otherwise focus on the new plank in the same position.
|
|
61
|
+
const index = attendedIndex === -1 ? 0 : attendedIndex >= next.length ? next.length - 1 : attendedIndex;
|
|
62
|
+
toAttend = next[index];
|
|
45
63
|
}
|
|
46
|
-
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return { deckUpdates: updates, toAttend };
|
|
47
67
|
};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DeckCapabilities
|
|
3
|
-
} from "./chunk-M57WD3V6.mjs";
|
|
4
|
-
import {
|
|
5
|
-
DECK_PLUGIN
|
|
6
|
-
} from "./chunk-Z5KITAZW.mjs";
|
|
7
|
-
|
|
8
|
-
// src/capabilities/app-graph-builder.ts
|
|
9
|
-
import { Rx } from "@effect-rx/rx-react";
|
|
10
|
-
import { Option, pipe } from "effect";
|
|
11
|
-
import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
|
|
12
|
-
import { AttentionCapabilities } from "@dxos/plugin-attention";
|
|
13
|
-
import { ROOT_ID, createExtension, rxFromSignal } from "@dxos/plugin-graph";
|
|
14
|
-
var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphBuilder, createExtension({
|
|
15
|
-
id: DECK_PLUGIN,
|
|
16
|
-
actions: (node) => Rx.make((get) => pipe(get(node), Option.flatMap((node2) => node2.id === ROOT_ID ? Option.some(node2) : Option.none()), Option.map(() => {
|
|
17
|
-
const state = context.getCapability(DeckCapabilities.MutableDeckState);
|
|
18
|
-
const _fullscreen = {
|
|
19
|
-
id: `${LayoutAction.UpdateLayout._tag}/fullscreen`,
|
|
20
|
-
data: async () => {
|
|
21
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
22
|
-
await dispatch(createIntent(LayoutAction.SetLayoutMode, {
|
|
23
|
-
part: "mode",
|
|
24
|
-
options: {
|
|
25
|
-
mode: "fullscreen"
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
28
|
-
},
|
|
29
|
-
properties: {
|
|
30
|
-
label: [
|
|
31
|
-
"toggle fullscreen label",
|
|
32
|
-
{
|
|
33
|
-
ns: DECK_PLUGIN
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
icon: "ph--arrows-out--regular",
|
|
37
|
-
keyBinding: {
|
|
38
|
-
macos: "ctrl+meta+f",
|
|
39
|
-
windows: "shift+ctrl+f"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const closeCurrent = {
|
|
44
|
-
id: `${LayoutAction.Close._tag}/current`,
|
|
45
|
-
data: async () => {
|
|
46
|
-
const attention = context.getCapability(AttentionCapabilities.Attention);
|
|
47
|
-
const attended = attention.current.at(-1);
|
|
48
|
-
if (attended) {
|
|
49
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
50
|
-
await dispatch(createIntent(LayoutAction.Close, {
|
|
51
|
-
part: "main",
|
|
52
|
-
subject: [
|
|
53
|
-
attended
|
|
54
|
-
],
|
|
55
|
-
options: {
|
|
56
|
-
state: false
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
properties: {
|
|
62
|
-
label: [
|
|
63
|
-
"close current label",
|
|
64
|
-
{
|
|
65
|
-
ns: DECK_PLUGIN
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
icon: "ph--x--regular"
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const closeOthers = {
|
|
72
|
-
id: `${LayoutAction.Close._tag}/others`,
|
|
73
|
-
data: async () => {
|
|
74
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
75
|
-
const attention = context.getCapability(AttentionCapabilities.Attention);
|
|
76
|
-
const attended = attention.current.at(-1);
|
|
77
|
-
const ids = state.deck.active.filter((id) => id !== attended) ?? [];
|
|
78
|
-
await dispatch(createIntent(LayoutAction.Close, {
|
|
79
|
-
part: "main",
|
|
80
|
-
subject: ids,
|
|
81
|
-
options: {
|
|
82
|
-
state: false
|
|
83
|
-
}
|
|
84
|
-
}));
|
|
85
|
-
},
|
|
86
|
-
properties: {
|
|
87
|
-
label: [
|
|
88
|
-
"close others label",
|
|
89
|
-
{
|
|
90
|
-
ns: DECK_PLUGIN
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
icon: "ph--x-square--regular"
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const closeAll = {
|
|
97
|
-
id: `${LayoutAction.Close._tag}/all`,
|
|
98
|
-
data: async () => {
|
|
99
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
100
|
-
await dispatch(createIntent(LayoutAction.Close, {
|
|
101
|
-
part: "main",
|
|
102
|
-
subject: state.deck.active,
|
|
103
|
-
options: {
|
|
104
|
-
state: false
|
|
105
|
-
}
|
|
106
|
-
}));
|
|
107
|
-
},
|
|
108
|
-
properties: {
|
|
109
|
-
label: [
|
|
110
|
-
"close all label",
|
|
111
|
-
{
|
|
112
|
-
ns: DECK_PLUGIN
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
icon: "ph--x-circle--regular"
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const toggleSidebar = {
|
|
119
|
-
id: `${LayoutAction.UpdateSidebar._tag}/nav`,
|
|
120
|
-
data: async () => {
|
|
121
|
-
state.sidebarState = state.sidebarState === "expanded" ? "collapsed" : "expanded";
|
|
122
|
-
},
|
|
123
|
-
properties: {
|
|
124
|
-
label: [
|
|
125
|
-
get(rxFromSignal(() => state.sidebarState === "expanded" ? "collapse navigation sidebar label" : "open navigation sidebar label")),
|
|
126
|
-
{
|
|
127
|
-
ns: DECK_PLUGIN
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
icon: "ph--sidebar--regular",
|
|
131
|
-
keyBinding: {
|
|
132
|
-
macos: "meta+'"
|
|
133
|
-
},
|
|
134
|
-
disposition: "pin-end",
|
|
135
|
-
position: "hoist",
|
|
136
|
-
l0Breakpoint: "lg"
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
return get(rxFromSignal(() => !state.deck.solo ? [
|
|
140
|
-
closeCurrent,
|
|
141
|
-
closeOthers,
|
|
142
|
-
closeAll,
|
|
143
|
-
toggleSidebar
|
|
144
|
-
] : [
|
|
145
|
-
toggleSidebar
|
|
146
|
-
]));
|
|
147
|
-
}), Option.getOrElse(() => [])))
|
|
148
|
-
})));
|
|
149
|
-
export {
|
|
150
|
-
app_graph_builder_default as default
|
|
151
|
-
};
|
|
152
|
-
//# sourceMappingURL=app-graph-builder-DD2EJBLZ.mjs.map
|