@dxos/app-framework 0.5.1-next.7f021b8 → 0.5.1-next.823fe3b
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/index.mjs +47 -5
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +58 -5
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/plugins/common/layout.d.ts +3 -0
- package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
- package/dist/types/src/plugins/common/navigation.d.ts +45 -17
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/plugins/common/layout.ts +8 -1
- package/src/plugins/common/navigation.ts +66 -16
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { IntentData } from '../IntentPlugin';
|
|
3
3
|
import type { Plugin } from '../PluginHost';
|
|
4
|
+
export declare const SLUG_LIST_SEPARATOR = ".";
|
|
5
|
+
export declare const SLUG_ENTRY_SEPARATOR = "_";
|
|
6
|
+
export declare const SLUG_KEY_VALUE_SEPARATOR = "-";
|
|
7
|
+
export declare const SLUG_PATH_SEPARATOR = "~";
|
|
8
|
+
export declare const SLUG_COLLECTION_INDICATOR = "";
|
|
9
|
+
export declare const ActiveParts: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
4
10
|
/**
|
|
5
11
|
* Basic state provided by a navigation plugin.
|
|
6
12
|
*/
|
|
7
13
|
export declare const Location: z.ZodObject<{
|
|
8
|
-
active: z.ZodOptional<z.ZodString
|
|
9
|
-
|
|
14
|
+
active: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>]>>;
|
|
15
|
+
closed: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
10
16
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
active?: string | undefined;
|
|
12
|
-
|
|
17
|
+
active?: string | Record<string, string | string[]> | undefined;
|
|
18
|
+
closed?: string | string[] | undefined;
|
|
13
19
|
}, {
|
|
14
|
-
active?: string | undefined;
|
|
15
|
-
|
|
20
|
+
active?: string | Record<string, string | string[]> | undefined;
|
|
21
|
+
closed?: string | string[] | undefined;
|
|
16
22
|
}>;
|
|
23
|
+
export type ActiveParts = z.infer<typeof ActiveParts>;
|
|
17
24
|
export type Location = z.infer<typeof Location>;
|
|
25
|
+
/**
|
|
26
|
+
* Composed of [ part name, index within the part, size of the part ]
|
|
27
|
+
*/
|
|
28
|
+
export type PartIdentifier = [string, number, number];
|
|
29
|
+
export type NavigationAdjustmentType = `${'pin' | 'increment'}-${'start' | 'end'}`;
|
|
30
|
+
export type NavigationAdjustment = {
|
|
31
|
+
part: PartIdentifier;
|
|
32
|
+
type: NavigationAdjustmentType;
|
|
33
|
+
};
|
|
34
|
+
export declare const isActiveParts: (active: string | ActiveParts | undefined) => active is Record<string, string | string[]>;
|
|
35
|
+
export declare const isAdjustTransaction: (data: IntentData | undefined) => data is NavigationAdjustment;
|
|
36
|
+
export declare const firstMainId: (active: Location['active']) => string;
|
|
37
|
+
export declare const activeIds: (active: string | ActiveParts | undefined) => Set<string>;
|
|
38
|
+
export declare const isIdActive: (active: string | ActiveParts | undefined, id: string) => boolean;
|
|
18
39
|
/**
|
|
19
40
|
* Provides for a plugin that can manage the app navigation.
|
|
20
41
|
*/
|
|
@@ -26,22 +47,29 @@ export type LocationProvides = {
|
|
|
26
47
|
*/
|
|
27
48
|
export declare const parseNavigationPlugin: (plugin: Plugin) => Plugin<LocationProvides> | undefined;
|
|
28
49
|
export declare enum NavigationAction {
|
|
29
|
-
|
|
50
|
+
OPEN = "dxos.org/plugin/navigation/open",
|
|
51
|
+
ADJUST = "dxos.org/plugin/navigation/adjust",
|
|
52
|
+
CLOSE = "dxos.org/plugin/navigation/close"
|
|
30
53
|
}
|
|
31
54
|
/**
|
|
32
55
|
* Expected payload for navigation actions.
|
|
33
56
|
*/
|
|
34
57
|
export declare namespace NavigationAction {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
58
|
+
/**
|
|
59
|
+
* An additive overlay to apply to `location.active` (i.e. the result is a union of previous active and the argument)
|
|
60
|
+
*/
|
|
61
|
+
type Open = IntentData<{
|
|
62
|
+
activeParts: ActiveParts;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
|
|
66
|
+
*/
|
|
67
|
+
type Close = IntentData<{
|
|
68
|
+
activeParts: ActiveParts;
|
|
45
69
|
}>;
|
|
70
|
+
/**
|
|
71
|
+
* An atomic transaction to apply to `location.active`, describing which element to (attempt to) move to which location.
|
|
72
|
+
*/
|
|
73
|
+
type Adjust = IntentData<NavigationAdjustment>;
|
|
46
74
|
}
|
|
47
75
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/navigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C;;GAEG;AAGH,eAAO,MAAM,QAAQ;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/navigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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MAAM,KAAG,OAMjF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,WAAY,MAAM,yCAGnD,CAAC;AAOF,oBAAY,gBAAgB;IAC1B,IAAI,oCAA8B;IAClC,MAAM,sCAAgC;IACtC,KAAK,qCAA+B;CACrC;AAED;;GAEG;AACH,yBAAiB,gBAAgB,CAAC;IAChC;;OAEG;IACH,KAAY,IAAI,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAC5D;;OAEG;IACH,KAAY,KAAK,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAC7D;;OAEG;IACH,KAAY,MAAM,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;CACvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-framework",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.823fe3b",
|
|
4
4
|
"description": "A framework for building applications from composible plugins.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"@phosphor-icons/react": "^2.1.5",
|
|
16
16
|
"@preact/signals-core": "^1.6.0",
|
|
17
17
|
"zod": "^3.22.4",
|
|
18
|
-
"@dxos/app-graph": "0.5.1-next.
|
|
19
|
-
"@dxos/
|
|
20
|
-
"@dxos/
|
|
21
|
-
"@dxos/echo-schema": "0.5.1-next.
|
|
22
|
-
"@dxos/invariant": "0.5.1-next.
|
|
23
|
-
"@dxos/local-storage": "0.5.1-next.
|
|
24
|
-
"@dxos/log": "0.5.1-next.
|
|
25
|
-
"@dxos/util": "0.5.1-next.
|
|
18
|
+
"@dxos/app-graph": "0.5.1-next.823fe3b",
|
|
19
|
+
"@dxos/async": "0.5.1-next.823fe3b",
|
|
20
|
+
"@dxos/debug": "0.5.1-next.823fe3b",
|
|
21
|
+
"@dxos/echo-schema": "0.5.1-next.823fe3b",
|
|
22
|
+
"@dxos/invariant": "0.5.1-next.823fe3b",
|
|
23
|
+
"@dxos/local-storage": "0.5.1-next.823fe3b",
|
|
24
|
+
"@dxos/log": "0.5.1-next.823fe3b",
|
|
25
|
+
"@dxos/util": "0.5.1-next.823fe3b"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/react": "^18.0.21",
|
|
@@ -36,10 +36,17 @@ export type Toast = z.infer<typeof Toast>;
|
|
|
36
36
|
// TODO(wittjosiah): Replace Zod w/ Effect Schema to align with ECHO.
|
|
37
37
|
export const Layout = z.object({
|
|
38
38
|
fullscreen: z.boolean(),
|
|
39
|
+
|
|
39
40
|
sidebarOpen: z.boolean(),
|
|
40
41
|
|
|
41
42
|
complementarySidebarOpen: z.boolean(),
|
|
42
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated
|
|
45
|
+
*/
|
|
46
|
+
complementarySidebarContent: z
|
|
47
|
+
.any()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('DEPRECATED. Data to be passed to the complementary sidebar Surface.'),
|
|
43
50
|
|
|
44
51
|
dialogOpen: z.boolean(),
|
|
45
52
|
dialogContent: z.any().optional().describe('Data to be passed to the dialog Surface.'),
|
|
@@ -7,22 +7,70 @@ import { z } from 'zod';
|
|
|
7
7
|
import type { IntentData } from '../IntentPlugin';
|
|
8
8
|
import type { Plugin } from '../PluginHost';
|
|
9
9
|
|
|
10
|
+
// NOTE(thure): These are chosen from RFC 1738’s `safe` characters: http://www.faqs.org/rfcs/rfc1738.html
|
|
11
|
+
export const SLUG_LIST_SEPARATOR = '.';
|
|
12
|
+
export const SLUG_ENTRY_SEPARATOR = '_';
|
|
13
|
+
export const SLUG_KEY_VALUE_SEPARATOR = '-';
|
|
14
|
+
export const SLUG_PATH_SEPARATOR = '~';
|
|
15
|
+
export const SLUG_COLLECTION_INDICATOR = '';
|
|
16
|
+
|
|
10
17
|
//
|
|
11
18
|
// Provides
|
|
12
19
|
//
|
|
13
20
|
|
|
21
|
+
export const ActiveParts = z.record(z.string(), z.union([z.string(), z.array(z.string())]));
|
|
22
|
+
|
|
14
23
|
/**
|
|
15
24
|
* Basic state provided by a navigation plugin.
|
|
16
25
|
*/
|
|
17
26
|
// TODO(wittjosiah): Replace Zod w/ Effect Schema to align with ECHO.
|
|
18
27
|
// TODO(wittjosiah): We should align this more with `window.location` along the lines of what React Router does.
|
|
19
28
|
export const Location = z.object({
|
|
20
|
-
active: z
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
active: z
|
|
30
|
+
.union([z.string(), ActiveParts])
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Id of currently active item, or record of item id(s) keyed by the app part in which they are active.'),
|
|
33
|
+
closed: z
|
|
34
|
+
.union([z.string(), z.array(z.string())])
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Id or ids of recently closed items, in order of when they were closed.'),
|
|
23
37
|
});
|
|
24
38
|
|
|
39
|
+
export type ActiveParts = z.infer<typeof ActiveParts>;
|
|
25
40
|
export type Location = z.infer<typeof Location>;
|
|
41
|
+
/**
|
|
42
|
+
* Composed of [ part name, index within the part, size of the part ]
|
|
43
|
+
*/
|
|
44
|
+
export type PartIdentifier = [string, number, number];
|
|
45
|
+
export type NavigationAdjustmentType = `${'pin' | 'increment'}-${'start' | 'end'}`;
|
|
46
|
+
export type NavigationAdjustment = { part: PartIdentifier; type: NavigationAdjustmentType };
|
|
47
|
+
|
|
48
|
+
export const isActiveParts = (active: string | ActiveParts | undefined): active is ActiveParts =>
|
|
49
|
+
!!active && typeof active !== 'string';
|
|
50
|
+
|
|
51
|
+
export const isAdjustTransaction = (data: IntentData | undefined): data is NavigationAdjustment =>
|
|
52
|
+
!!data && 'part' in data && 'type' in data;
|
|
53
|
+
|
|
54
|
+
export const firstMainId = (active: Location['active']): string =>
|
|
55
|
+
isActiveParts(active) ? (Array.isArray(active.main) ? active.main[0] : active.main) : active ?? '';
|
|
56
|
+
|
|
57
|
+
export const activeIds = (active: string | ActiveParts | undefined): Set<string> =>
|
|
58
|
+
active
|
|
59
|
+
? isActiveParts(active)
|
|
60
|
+
? Object.values(active).reduce((acc, ids) => {
|
|
61
|
+
Array.isArray(ids) ? ids.forEach((id) => acc.add(id)) : acc.add(ids);
|
|
62
|
+
return acc;
|
|
63
|
+
}, new Set<string>())
|
|
64
|
+
: new Set([active])
|
|
65
|
+
: new Set();
|
|
66
|
+
|
|
67
|
+
export const isIdActive = (active: string | ActiveParts | undefined, id: string): boolean => {
|
|
68
|
+
return active
|
|
69
|
+
? isActiveParts(active)
|
|
70
|
+
? Object.values(active).findIndex((ids) => (Array.isArray(ids) ? ids.indexOf(id) > -1 : ids === id)) > -1
|
|
71
|
+
: active === id
|
|
72
|
+
: false;
|
|
73
|
+
};
|
|
26
74
|
|
|
27
75
|
/**
|
|
28
76
|
* Provides for a plugin that can manage the app navigation.
|
|
@@ -45,23 +93,25 @@ export const parseNavigationPlugin = (plugin: Plugin) => {
|
|
|
45
93
|
|
|
46
94
|
const NAVIGATION_ACTION = 'dxos.org/plugin/navigation';
|
|
47
95
|
export enum NavigationAction {
|
|
48
|
-
|
|
96
|
+
OPEN = `${NAVIGATION_ACTION}/open`,
|
|
97
|
+
ADJUST = `${NAVIGATION_ACTION}/adjust`,
|
|
98
|
+
CLOSE = `${NAVIGATION_ACTION}/close`,
|
|
49
99
|
}
|
|
50
100
|
|
|
51
101
|
/**
|
|
52
102
|
* Expected payload for navigation actions.
|
|
53
103
|
*/
|
|
54
104
|
export namespace NavigationAction {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
105
|
+
/**
|
|
106
|
+
* An additive overlay to apply to `location.active` (i.e. the result is a union of previous active and the argument)
|
|
107
|
+
*/
|
|
108
|
+
export type Open = IntentData<{ activeParts: ActiveParts }>;
|
|
109
|
+
/**
|
|
110
|
+
* A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
|
|
111
|
+
*/
|
|
112
|
+
export type Close = IntentData<{ activeParts: ActiveParts }>;
|
|
113
|
+
/**
|
|
114
|
+
* An atomic transaction to apply to `location.active`, describing which element to (attempt to) move to which location.
|
|
115
|
+
*/
|
|
116
|
+
export type Adjust = IntentData<NavigationAdjustment>;
|
|
67
117
|
}
|