@dxos/app-framework 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48

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.
@@ -2,6 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import type { IconProps } from '@phosphor-icons/react';
5
6
  import type { FC, PropsWithChildren } from 'react';
6
7
 
7
8
  /**
@@ -63,10 +64,16 @@ export type Plugin<TProvides = {}> = {
63
64
  */
64
65
  tags?: string[];
65
66
 
67
+ /**
68
+ * Component to render icon for the plugin when displayed in a list.
69
+ * @deprecated
70
+ */
71
+ iconComponent?: FC<IconProps>;
72
+
66
73
  /**
67
74
  * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
68
75
  */
69
- icon?: string;
76
+ iconSymbol?: string;
70
77
  };
71
78
 
72
79
  /**
@@ -19,6 +19,7 @@ export const SLUG_COLLECTION_INDICATOR = '';
19
19
  const LayoutEntrySchema = S.mutable(S.Struct({ id: S.String, path: S.optional(S.String) }));
20
20
  export type LayoutEntry = S.Schema.Type<typeof LayoutEntrySchema>;
21
21
 
22
+ // TODO(Zan): Consider making solo it's own part. It's not really a function of the 'main' part?
22
23
  // TODO(Zan): Consider renaming the 'main' part to 'deck' part now that we are throwing out the old layout plugin.
23
24
  // TODO(Zan): Extend to all strings?
24
25
  const LayoutPartSchema = S.Union(
@@ -55,7 +56,7 @@ export type LayoutContainerProps<T> = T & { role?: string; coordinate?: LayoutCo
55
56
  * Basic state provided by a navigation plugin.
56
57
  */
57
58
  export const Attention = z.object({
58
- attended: z.set(z.string()).describe('Ids of items which have focus.'),
59
+ attended: z.set(z.string()).optional().describe('Ids of items which have focus.'),
59
60
  });
60
61
  export type Attention = z.infer<typeof Attention>;
61
62
 
@@ -1,28 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts
4
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
5
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
6
-
7
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
8
- import { createContext, useContext } from "react";
9
- var SurfaceRootContext = /* @__PURE__ */ createContext({
10
- components: {}
11
- });
12
- var useSurfaceRoot = () => useContext(SurfaceRootContext);
13
- var SurfaceProvider = SurfaceRootContext.Provider;
14
-
15
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts
16
- var SurfaceMeta = {
17
- id: "dxos.org/plugin/surface"
18
- };
19
- var meta_default = SurfaceMeta;
20
-
21
- export {
22
- parseRootSurfacePlugin,
23
- parseSurfacePlugin,
24
- useSurfaceRoot,
25
- SurfaceProvider,
26
- meta_default
27
- };
28
- //# sourceMappingURL=chunk-ERPIGFBI.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/provides.ts", "../../../src/plugins/SurfacePlugin/SurfaceRootContext.tsx", "../../../src/plugins/SurfacePlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../PluginHost';\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type Context, type JSX, type Provider, type ForwardedRef } from 'react';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n};\n\nconst SurfaceRootContext: Context<SurfaceRootContext> = createContext<SurfaceRootContext>({ components: {} });\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext);\n\nexport const SurfaceProvider: Provider<SurfaceRootContext> = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n"],
5
- "mappings": ";;;AAoBO,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;;;ACpBxF,SAASG,eAAeC,kBAA4E;AAmCpG,IAAMC,qBAAkDC,8BAAkC;EAAEC,YAAY,CAAC;AAAE,CAAA;AAEpG,IAAMC,iBAAiB,MAAMC,WAAWJ,kBAAAA;AAExC,IAAMK,kBAAgDL,mBAAmBM;;;ACvChF,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "createContext", "useContext", "SurfaceRootContext", "createContext", "components", "useSurfaceRoot", "useContext", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
- }
@@ -1,22 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/sdk/app-framework/src/plugins/helpers.ts
4
- import { raise } from "@dxos/debug";
5
- var definePlugin = (plugin) => plugin;
6
- var findPlugin = (plugins, id) => {
7
- return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
8
- };
9
- var getPlugin = (plugins, id) => {
10
- return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
11
- };
12
- var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
13
- var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
14
-
15
- export {
16
- definePlugin,
17
- findPlugin,
18
- getPlugin,
19
- filterPlugins,
20
- resolvePlugin
21
- };
22
- //# sourceMappingURL=chunk-IY7HCP4K.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/helpers.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { raise } from '@dxos/debug';\n\nimport { type Plugin } from './PluginHost';\n\n/**\n * Define a plugin\n */\nexport const definePlugin = <TProvides>(plugin: Plugin<TProvides>): Plugin<TProvides> => plugin;\n\n/**\n * Find a plugin by ID.\n */\nexport const findPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> | undefined => {\n return plugins.find(\n (plugin) => plugin.meta.id === id || (typeof plugin.meta.shortId === 'string' && plugin.meta.shortId === id),\n ) as Plugin<T>;\n};\n\n/**\n * Find a plugin by ID, or raise an error if not found.\n */\nexport const getPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> => {\n return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));\n};\n\n/**\n * Filter a list of plugins to only those that match a predicate.\n */\nexport const filterPlugins = <T>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T>[] => plugins.map((plugin) => predicate(plugin)).filter((plugin): plugin is Plugin<T> => !!plugin);\n\n/**\n * Resolves a plugin by predicate.\n *\n * @example\n * import { parseIntentPlugin, resolvePlugin } from '@dxos/app-framework';\n * const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);\n */\nexport const resolvePlugin = <T>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T> | undefined => filterPlugins(plugins, predicate)[0];\n"],
5
- "mappings": ";;;AAIA,SAASA,aAAa;AAOf,IAAMC,eAAe,CAAYC,WAAiDA;AAKlF,IAAMC,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACJ,WAAWA,OAAOK,KAAKF,OAAOA,MAAO,OAAOH,OAAOK,KAAKC,YAAY,YAAYN,OAAOK,KAAKC,YAAYH,EAAAA;AAE7G;AAKO,IAAMI,YAAY,CAAIL,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,KAAOK,MAAM,IAAIC,MAAM,qBAAqBN,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMO,gBAAgB,CAC3BR,SACAS,cACgBT,QAAQU,IAAI,CAACZ,WAAWW,UAAUX,MAAAA,CAAAA,EAASa,OAAO,CAACb,WAAgC,CAAC,CAACA,MAAAA;AAShG,IAAMc,gBAAgB,CAC3BZ,SACAS,cAC0BD,cAAcR,SAASS,SAAAA,EAAW,CAAA;",
6
- "names": ["raise", "definePlugin", "plugin", "findPlugin", "plugins", "id", "find", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin"]
7
- }
@@ -1,54 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts
4
- var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
5
- var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
6
- var INTENT_ACTION = "dxos.org/plugin/intent";
7
- var IntentAction;
8
- (function(IntentAction2) {
9
- IntentAction2[IntentAction2["SHOW_UNDO"] = `${INTENT_ACTION}/show-undo`] = "SHOW_UNDO";
10
- })(IntentAction || (IntentAction = {}));
11
-
12
- // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
13
- import { createContext, useContext } from "react";
14
- import { useEffect } from "react";
15
- var IntentContext = /* @__PURE__ */ createContext({
16
- dispatch: async () => ({}),
17
- undo: async () => ({}),
18
- history: [],
19
- registerResolver: () => () => {
20
- }
21
- });
22
- var useIntent = () => useContext(IntentContext);
23
- var useIntentDispatcher = () => {
24
- const { dispatch } = useIntent();
25
- return dispatch;
26
- };
27
- var useIntentResolver = (plugin, resolver) => {
28
- const { registerResolver } = useIntent();
29
- useEffect(() => {
30
- return registerResolver(plugin, resolver);
31
- }, [
32
- plugin,
33
- resolver
34
- ]);
35
- };
36
- var IntentProvider = IntentContext.Provider;
37
-
38
- // packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts
39
- var IntentMeta = {
40
- id: "dxos.org/plugin/intent"
41
- };
42
- var meta_default = IntentMeta;
43
-
44
- export {
45
- parseIntentPlugin,
46
- parseIntentResolverPlugin,
47
- IntentAction,
48
- useIntent,
49
- useIntentDispatcher,
50
- useIntentResolver,
51
- IntentProvider,
52
- meta_default
53
- };
54
- //# sourceMappingURL=chunk-P2TQLXZR.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/IntentPlugin/provides.ts", "../../../src/plugins/IntentPlugin/IntentContext.tsx", "../../../src/plugins/IntentPlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type IntentContext } from './IntentContext';\nimport { type IntentResolver } from './intent';\nimport { type Plugin } from '../PluginHost';\n\nexport type IntentResolverProvides = {\n intent: {\n resolver: IntentResolver;\n };\n};\n\nexport type IntentPluginProvides = {\n intent: IntentContext;\n};\n\nexport const parseIntentPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.dispatch ? (plugin as Plugin<IntentPluginProvides>) : undefined;\n\nexport const parseIntentResolverPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.resolver ? (plugin as Plugin<IntentResolverProvides>) : undefined;\n\n//\n// Intents\n//\n\nconst INTENT_ACTION = 'dxos.org/plugin/intent';\nexport enum IntentAction {\n /**\n * Fired after an intent is dispatched if the intent is undoable.\n */\n SHOW_UNDO = `${INTENT_ACTION}/show-undo`,\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider } from 'react';\nimport { useEffect } from 'react';\n\nimport type { UnsubscribeCallback } from '@dxos/async';\n\nimport type { Intent, IntentDispatcher, IntentResolver, IntentResult } from './intent';\n\nexport type IntentExecution = {\n intent: Intent;\n result: IntentResult;\n};\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n undo: () => Promise<IntentResult | void>;\n history: IntentExecution[][];\n registerResolver: (pluginId: string, resolver: IntentResolver) => UnsubscribeCallback;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n});\n\n/**\n * @deprecated Prefer granular hooks.\n */\n// TODO(burdon): Remove. Use useIntentDispatcher.\nexport const useIntent = () => useContext(IntentContext);\n\nexport const useIntentDispatcher = (): IntentDispatcher => {\n const { dispatch } = useIntent();\n return dispatch;\n};\n\nexport const useIntentResolver = (plugin: string, resolver: IntentResolver) => {\n const { registerResolver } = useIntent();\n useEffect(() => {\n return registerResolver(plugin, resolver);\n }, [plugin, resolver]);\n};\n\nexport const IntentProvider: Provider<IntentContext> = IntentContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst IntentMeta = {\n id: 'dxos.org/plugin/intent',\n};\n\nexport default IntentMeta;\n"],
5
- "mappings": ";;;AAkBO,IAAMA,oBAAoB,CAACC,WAC/BA,OAAOC,SAAiBC,QAAQC,WAAYH,SAA0CI;AAElF,IAAMC,4BAA4B,CAACL,WACvCA,OAAOC,SAAiBC,QAAQI,WAAYN,SAA4CI;AAM3F,IAAMG,gBAAgB;;UACVC,eAAAA;AAGT,EAAAA,cAAAA,cAAA,WAAA,IACW,GAAGD,aAAAA,YAAyB,IAAA;GAJ9BC,iBAAAA,eAAAA,CAAAA,EAAAA;;;ACzBZ,SAAuBC,eAAeC,kBAAiC;AACvE,SAASC,iBAAiB;AAkB1B,IAAMC,gBAAwCC,8BAA6B;EACzEC,UAAU,aAAa,CAAC;EACxBC,MAAM,aAAa,CAAC;EACpBC,SAAS,CAAA;EACTC,kBAAkB,MAAM,MAAA;EAAO;AACjC,CAAA;AAMO,IAAMC,YAAY,MAAMC,WAAWP,aAAAA;AAEnC,IAAMQ,sBAAsB,MAAA;AACjC,QAAM,EAAEN,SAAQ,IAAKI,UAAAA;AACrB,SAAOJ;AACT;AAEO,IAAMO,oBAAoB,CAACC,QAAgBC,aAAAA;AAChD,QAAM,EAAEN,iBAAgB,IAAKC,UAAAA;AAC7BM,YAAU,MAAA;AACR,WAAOP,iBAAiBK,QAAQC,QAAAA;EAClC,GAAG;IAACD;IAAQC;GAAS;AACvB;AAEO,IAAME,iBAA0Cb,cAAcc;;;AC5CrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "INTENT_ACTION", "IntentAction", "createContext", "useContext", "useEffect", "IntentContext", "createContext", "dispatch", "undo", "history", "registerResolver", "useIntent", "useContext", "useIntentDispatcher", "useIntentResolver", "plugin", "resolver", "useEffect", "IntentProvider", "Provider", "IntentMeta", "id"]
7
- }