@dxos/app-framework 0.6.12 → 0.6.13-main.548ca8d

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.
Files changed (43) hide show
  1. package/dist/lib/browser/index.mjs +169 -163
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +183 -182
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/chunk-ERPIGFBI.mjs +28 -0
  8. package/dist/lib/node-esm/chunk-ERPIGFBI.mjs.map +7 -0
  9. package/dist/lib/node-esm/chunk-IY7HCP4K.mjs +22 -0
  10. package/dist/lib/node-esm/chunk-IY7HCP4K.mjs.map +7 -0
  11. package/dist/lib/node-esm/chunk-P2TQLXZR.mjs +54 -0
  12. package/dist/lib/node-esm/chunk-P2TQLXZR.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +683 -0
  14. package/dist/lib/node-esm/index.mjs.map +7 -0
  15. package/dist/lib/node-esm/meta.json +1 -0
  16. package/dist/lib/node-esm/plugin-24ZP3LDU.mjs +40 -0
  17. package/dist/lib/node-esm/plugin-24ZP3LDU.mjs.map +7 -0
  18. package/dist/lib/node-esm/plugin-5AAUGDB3.mjs +168 -0
  19. package/dist/lib/node-esm/plugin-5AAUGDB3.mjs.map +7 -0
  20. package/dist/types/src/App.d.ts +4 -4
  21. package/dist/types/src/App.d.ts.map +1 -1
  22. package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts +14 -0
  23. package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts.map +1 -0
  24. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +4 -4
  25. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +1 -1
  26. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +4 -8
  27. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
  28. package/dist/types/src/plugins/PluginHost/plugin.d.ts +37 -83
  29. package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
  30. package/dist/types/src/plugins/PluginHost/plugin.test.d.ts.map +1 -1
  31. package/dist/types/src/plugins/common/navigation.d.ts +1 -12
  32. package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
  33. package/package.json +14 -11
  34. package/project.json +3 -8
  35. package/src/App.tsx +10 -9
  36. package/src/plugins/PluginHost/PluginContainer.tsx +120 -0
  37. package/src/plugins/PluginHost/PluginContext.tsx +8 -14
  38. package/src/plugins/PluginHost/PluginHost.tsx +18 -121
  39. package/src/plugins/PluginHost/plugin.test.ts +1 -2
  40. package/src/plugins/PluginHost/plugin.ts +45 -52
  41. package/src/plugins/common/navigation.ts +4 -12
  42. package/tsconfig.json +1 -29
  43. package/vitest.config.ts +9 -0
@@ -1,4 +1,3 @@
1
- import type { IconProps } from '@phosphor-icons/react';
2
1
  import type { FC, PropsWithChildren } from 'react';
3
2
  /**
4
3
  * Capabilities provided by a plugin.
@@ -11,52 +10,48 @@ export type PluginProvides<TProvides> = TProvides & {
11
10
  context?: FC<PropsWithChildren>;
12
11
  root?: FC<PropsWithChildren>;
13
12
  };
13
+ export type PluginMeta = {
14
+ /**
15
+ * Globally unique ID.
16
+ *
17
+ * Expected to be in the form of a valid URL.
18
+ *
19
+ * @example dxos.org/plugin/example
20
+ */
21
+ id: string;
22
+ /**
23
+ * Short ID for use in URLs.
24
+ *
25
+ * NOTE: This is especially experimental and likely to change.
26
+ */
27
+ shortId?: string;
28
+ /**
29
+ * Human-readable name.
30
+ */
31
+ name?: string;
32
+ /**
33
+ * Short description of plugin functionality.
34
+ */
35
+ description?: string;
36
+ /**
37
+ * URL of home page.
38
+ */
39
+ homePage?: string;
40
+ /**
41
+ * Tags to help categorize the plugin.
42
+ */
43
+ tags?: string[];
44
+ /**
45
+ * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
46
+ */
47
+ icon?: string;
48
+ };
14
49
  /**
15
50
  * A unit of containment of modular functionality that can be provided to an application.
16
51
  * Plugins provide things like components, state, actions, etc. to the application.
17
52
  */
18
53
  export type Plugin<TProvides = {}> = {
19
- meta: {
20
- /**
21
- * Globally unique ID.
22
- *
23
- * Expected to be in the form of a valid URL.
24
- *
25
- * @example dxos.org/plugin/example
26
- */
27
- id: string;
28
- /**
29
- * Short ID for use in URLs.
30
- *
31
- * NOTE: This is especially experimental and likely to change.
32
- */
33
- shortId?: string;
34
- /**
35
- * Human-readable name.
36
- */
37
- name?: string;
38
- /**
39
- * Short description of plugin functionality.
40
- */
41
- description?: string;
42
- /**
43
- * URL of home page.
44
- */
45
- homePage?: string;
46
- /**
47
- * Tags to help categorize the plugin.
48
- */
49
- tags?: string[];
50
- /**
51
- * Component to render icon for the plugin when displayed in a list.
52
- * @deprecated
53
- */
54
- iconComponent?: FC<IconProps>;
55
- /**
56
- * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
57
- */
58
- iconSymbol?: string;
59
- };
54
+ meta: PluginMeta;
60
55
  /**
61
56
  * Capabilities provided by the plugin.
62
57
  */
@@ -89,47 +84,6 @@ export type PluginDefinition<TProvides = {}, TInitializeProvides = {}> = Omit<Pl
89
84
  */
90
85
  unload?: () => Promise<void>;
91
86
  };
92
- export declare const pluginMeta: (meta: Plugin["meta"]) => {
93
- /**
94
- * Globally unique ID.
95
- *
96
- * Expected to be in the form of a valid URL.
97
- *
98
- * @example dxos.org/plugin/example
99
- */
100
- id: string;
101
- /**
102
- * Short ID for use in URLs.
103
- *
104
- * NOTE: This is especially experimental and likely to change.
105
- */
106
- shortId?: string;
107
- /**
108
- * Human-readable name.
109
- */
110
- name?: string;
111
- /**
112
- * Short description of plugin functionality.
113
- */
114
- description?: string;
115
- /**
116
- * URL of home page.
117
- */
118
- homePage?: string;
119
- /**
120
- * Tags to help categorize the plugin.
121
- */
122
- tags?: string[];
123
- /**
124
- * Component to render icon for the plugin when displayed in a list.
125
- * @deprecated
126
- */
127
- iconComponent?: FC<IconProps>;
128
- /**
129
- * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
130
- */
131
- iconSymbol?: string;
132
- };
133
87
  type LazyPlugin<T> = () => Promise<{
134
88
  default: (props: T) => PluginDefinition;
135
89
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/PluginHost/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,SAAS,IAAI,SAAS,GAAG;IAClD;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC;IAKhC,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,SAAS,GAAG,EAAE,IAAI;IACnC,IAAI,EAAE;QACJ;;;;;;WAMG;QACH,EAAE,EAAE,MAAM,CAAC;QAEX;;;;WAIG;QAEH,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAEhB;;;WAGG;QACH,aAAa,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;QAE9B;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC,SAAS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,CAAC,KAAG,CAAC,GAAG,SAAS,CAAkC;CACvF;AAYD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,SAAS,CAAwB,CAAC;AAEpE,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;CACvD;AAED,eAAO,MAAM,UAAU,EAAE,SAAS,CAAC,UAAU,CAAyB,CAAC;AAGvE,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;CAAE,CAAC,CAAC;AAE1F,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,OAAO,CAAmB,CAAC"}
@@ -1,5 +1,5 @@
1
+ import { Schema as S } from '@effect/schema';
1
2
  import { z } from 'zod';
2
- import { S } from '@dxos/echo-schema';
3
3
  import type { IntentData } from '../IntentPlugin';
4
4
  import type { Plugin } from '../PluginHost';
5
5
  export declare const SLUG_LIST_SEPARATOR = "+";
@@ -80,17 +80,6 @@ export type LayoutContainerProps<T> = T & {
80
80
  role?: string;
81
81
  coordinate?: LayoutCoordinate;
82
82
  };
83
- /**
84
- * Basic state provided by a navigation plugin.
85
- */
86
- export declare const Attention: z.ZodObject<{
87
- attended: z.ZodOptional<z.ZodSet<z.ZodString>>;
88
- }, "strip", z.ZodTypeAny, {
89
- attended?: Set<string> | undefined;
90
- }, {
91
- attended?: Set<string> | undefined;
92
- }>;
93
- export type Attention = z.infer<typeof Attention>;
94
83
  /**
95
84
  * Provides for a plugin that can manage the app navigation.
96
85
  */
@@ -1 +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CAAA;KAAE,CAAC,CAAC;IAE5D;;OAEG;IACH,KAAY,WAAW,GAAG,UAAU,CAAC;QACnC,IAAI,EAAE,UAAU,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;KAC/B,CAAC,CAAC;IAEH;;OAEG;IACH,KAAY,KAAK,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAEjF;;OAEG;IACH,KAAY,GAAG,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAE3D;;OAEG;IACH,KAAY,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;CACnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/app-framework",
3
- "version": "0.6.12",
3
+ "version": "0.6.13-main.548ca8d",
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",
@@ -10,7 +10,8 @@
10
10
  ".": {
11
11
  "browser": "./dist/lib/browser/index.mjs",
12
12
  "node": {
13
- "default": "./dist/lib/node/index.cjs"
13
+ "require": "./dist/lib/node/index.cjs",
14
+ "default": "./dist/lib/node-esm/index.mjs"
14
15
  },
15
16
  "types": "./dist/types/src/index.d.ts"
16
17
  }
@@ -20,24 +21,26 @@
20
21
  "*": {}
21
22
  },
22
23
  "dependencies": {
24
+ "@effect/schema": "^0.75.1",
23
25
  "@phosphor-icons/react": "^2.1.5",
24
26
  "@preact/signals-core": "^1.6.0",
25
27
  "zod": "^3.22.4",
26
- "@dxos/app-graph": "0.6.12",
27
- "@dxos/async": "0.6.12",
28
- "@dxos/debug": "0.6.12",
29
- "@dxos/client-protocol": "0.6.12",
30
- "@dxos/echo-schema": "0.6.12",
31
- "@dxos/local-storage": "0.6.12",
32
- "@dxos/log": "0.6.12",
33
- "@dxos/util": "0.6.12",
34
- "@dxos/invariant": "0.6.12"
28
+ "@dxos/app-graph": "0.6.13-main.548ca8d",
29
+ "@dxos/async": "0.6.13-main.548ca8d",
30
+ "@dxos/client-protocol": "0.6.13-main.548ca8d",
31
+ "@dxos/echo-schema": "0.6.13-main.548ca8d",
32
+ "@dxos/invariant": "0.6.13-main.548ca8d",
33
+ "@dxos/debug": "0.6.13-main.548ca8d",
34
+ "@dxos/log": "0.6.13-main.548ca8d",
35
+ "@dxos/util": "0.6.13-main.548ca8d",
36
+ "@dxos/local-storage": "0.6.13-main.548ca8d"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@types/react": "~18.2.0",
38
40
  "react": "~18.2.0"
39
41
  },
40
42
  "peerDependencies": {
43
+ "@phosphor-icons/react": "^2.1.5",
41
44
  "react": "~18.2.0"
42
45
  },
43
46
  "publishConfig": {
package/project.json CHANGED
@@ -16,15 +16,10 @@
16
16
  }
17
17
  },
18
18
  "lint": {},
19
- "test": {
20
- "options": {
21
- "ciEnvironments": [
22
- "nodejs"
23
- ]
24
- }
25
- }
19
+ "test": {}
26
20
  },
27
21
  "implicitDependencies": [
28
- "test"
22
+ "esbuild",
23
+ "node-std"
29
24
  ]
30
25
  }
package/src/App.tsx CHANGED
@@ -15,7 +15,7 @@ import SurfaceMeta from './plugins/SurfacePlugin/meta';
15
15
  * Initializes plugins and renders the root components.
16
16
  *
17
17
  * @example
18
- * const order = [LayoutMeta, MyPluginMeta];
18
+ * const meta = [LayoutMeta, MyPluginMeta];
19
19
  * const plugins = {
20
20
  * [LayoutMeta.id]: Plugin.lazy(() => import('./plugins/LayoutPlugin/plugin')),
21
21
  * [MyPluginMeta.id]: Plugin.lazy(() => import('./plugins/MyPlugin/plugin')),
@@ -30,28 +30,29 @@ import SurfaceMeta from './plugins/SurfacePlugin/meta';
30
30
  * </StrictMode>,
31
31
  * );
32
32
  *
33
- * @param params.order Total ordering of plugins.
34
33
  * @param params.plugins All plugins available to the application.
34
+ * @param params.meta All plugin metadata.
35
35
  * @param params.core Core plugins which will always be enabled.
36
- * @param params.default Default plugins are enabled by default but can be disabled by the user.
36
+ * @param params.defaults Default plugins are enabled by default but can be disabled by the user.
37
37
  * @param params.fallback Fallback component to render while plugins are initializing.
38
38
  */
39
- export const createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }: BootstrapPluginsParams) => {
39
+ export const createApp = ({ meta, plugins, core, ...params }: BootstrapPluginsParams) => {
40
40
  const host = PluginHost({
41
- order: [SurfaceMeta, IntentMeta, ...order],
42
41
  plugins: {
43
42
  ...plugins,
44
43
  [SurfaceMeta.id]: Plugin.lazy(() => import('./plugins/SurfacePlugin/plugin')),
45
44
  [IntentMeta.id]: Plugin.lazy(() => import('./plugins/IntentPlugin/plugin')),
46
45
  },
46
+ // TODO(burdon): Why not include in core?
47
+ meta: [SurfaceMeta, IntentMeta, ...meta],
47
48
  core: [SurfaceMeta.id, IntentMeta.id, ...core],
48
49
  ...params,
49
50
  });
50
51
 
51
- invariant(host.provides?.context);
52
- invariant(host.provides?.root);
53
- const Context = host.provides.context;
54
- const Root = host.provides.root;
52
+ invariant(host.provides);
53
+ const { context: Context, root: Root } = host.provides;
54
+ invariant(Context);
55
+ invariant(Root);
55
56
 
56
57
  return () => (
57
58
  <Context>
@@ -0,0 +1,120 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { type JSX, type FC, type PropsWithChildren, type ReactNode, useEffect, useState } from 'react';
6
+
7
+ import { log } from '@dxos/log';
8
+
9
+ import { type PluginContext } from './PluginContext';
10
+ import { type BootstrapPluginsParams } from './PluginHost';
11
+ import { type Plugin, type PluginDefinition, type PluginProvides } from './plugin';
12
+
13
+ export type PluginContainerProps = Pick<BootstrapPluginsParams, 'core'> & {
14
+ plugins: Record<string, () => Promise<PluginDefinition>>;
15
+ state: PluginContext;
16
+ placeholder: ReactNode;
17
+ };
18
+
19
+ /**
20
+ * Root component initializes plugins.
21
+ */
22
+ export const PluginContainer = ({ plugins: definitions, core, state, placeholder }: PluginContainerProps) => {
23
+ const [error, setError] = useState<unknown>();
24
+
25
+ useEffect(() => {
26
+ log('initializing plugins', { enabled: state.enabled });
27
+ const t = setTimeout(async () => {
28
+ try {
29
+ const enabledIds = [...core, ...state.enabled];
30
+ const enabled = await Promise.all(
31
+ enabledIds
32
+ .map((id) => definitions[id])
33
+ // If local storage indicates a plugin is enabled, but it is not available, ignore it.
34
+ .filter((definition): definition is () => Promise<PluginDefinition> => Boolean(definition))
35
+ .map((definition) => definition()),
36
+ );
37
+
38
+ const plugins = await Promise.all(
39
+ enabled.map(async (definition) => {
40
+ const plugin = await initializePlugin(definition).catch((err) => {
41
+ log.error('Failed to initialize plugin:', { id: definition.meta.id, err });
42
+ });
43
+
44
+ log('initialized', { plugin: definition.meta.id });
45
+ return plugin;
46
+ }),
47
+ );
48
+
49
+ const initialized = plugins.filter((plugin): plugin is Plugin => Boolean(plugin));
50
+ log('plugins initialized', { plugins: initialized });
51
+
52
+ await Promise.all(enabled.map((plugin) => plugin.ready?.(initialized)));
53
+ log('plugins ready', { plugins: initialized });
54
+
55
+ state.plugins = initialized;
56
+ state.ready = true;
57
+ } catch (err) {
58
+ setError(err);
59
+ }
60
+ });
61
+
62
+ return () => {
63
+ clearTimeout(t);
64
+ state.ready = false;
65
+ // TODO(wittjosiah): Does this ever need to be called prior to having dynamic plugins?
66
+ // void Promise.all(enabled.map((definition) => definition.unload?.()));
67
+ };
68
+ }, []);
69
+
70
+ if (error) {
71
+ throw error;
72
+ }
73
+
74
+ if (!state.ready) {
75
+ return <>{placeholder}</>;
76
+ }
77
+
78
+ const ComposedContext = composeContext(state.plugins);
79
+
80
+ return <ComposedContext>{rootComponents(state.plugins)}</ComposedContext>;
81
+ };
82
+
83
+ /**
84
+ * Resolve a `PluginDefinition` into a fully initialized `Plugin`.
85
+ */
86
+ const initializePlugin = async <T, U>(pluginDefinition: PluginDefinition<T, U>): Promise<Plugin<T & U>> => {
87
+ const provides = await pluginDefinition.initialize?.();
88
+ return {
89
+ ...pluginDefinition,
90
+ provides: {
91
+ ...pluginDefinition.provides,
92
+ ...provides,
93
+ } as PluginProvides<T & U>,
94
+ };
95
+ };
96
+
97
+ const rootComponents = (plugins: Plugin[]) => {
98
+ return plugins
99
+ .map((plugin) => {
100
+ const Component = plugin.provides.root;
101
+ if (Component) {
102
+ return <Component key={plugin.meta.id} />;
103
+ } else {
104
+ return null;
105
+ }
106
+ })
107
+ .filter((node): node is JSX.Element => Boolean(node));
108
+ };
109
+
110
+ const composeContext = (plugins: Plugin[]) => {
111
+ return compose(plugins.map((p) => p.provides.context!).filter(Boolean));
112
+ };
113
+
114
+ const compose = (contexts: FC<PropsWithChildren>[]) => {
115
+ return [...contexts].reduce((Acc, Next) => ({ children }) => (
116
+ <Acc>
117
+ <Next>{children}</Next>
118
+ </Acc>
119
+ ));
120
+ };
@@ -2,11 +2,12 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type Context, type Provider, createContext, useContext, useMemo } from 'react';
5
+ import { createContext, useContext, useMemo } from 'react';
6
6
 
7
+ import { raise } from '@dxos/debug';
7
8
  import { nonNullable } from '@dxos/util';
8
9
 
9
- import { type Plugin } from './plugin';
10
+ import { type Plugin, type PluginMeta } from './plugin';
10
11
  import { findPlugin, resolvePlugin } from '../helpers';
11
12
 
12
13
  export type PluginContext = {
@@ -32,9 +33,9 @@ export type PluginContext = {
32
33
 
33
34
  /**
34
35
  * All available plugins.
36
+ * NOTE: This is metadata rather than just ids because it includes plugins which have not been fully loaded yet.
35
37
  */
36
- // This is metadata rather then just ids because it includes plugins which have not been fully loaded yet.
37
- available: Plugin['meta'][];
38
+ available: PluginMeta[];
38
39
 
39
40
  /**
40
41
  * Mark plugin as enabled.
@@ -43,19 +44,12 @@ export type PluginContext = {
43
44
  setPlugin: (id: string, enabled: boolean) => void;
44
45
  };
45
46
 
46
- const PluginContext: Context<PluginContext> = createContext<PluginContext>({
47
- ready: false,
48
- core: [],
49
- enabled: [],
50
- plugins: [],
51
- available: [],
52
- setPlugin: () => {},
53
- });
47
+ const PluginContext = createContext<PluginContext | undefined>(undefined);
54
48
 
55
49
  /**
56
50
  * Get all plugins.
57
51
  */
58
- export const usePlugins = (): PluginContext => useContext(PluginContext);
52
+ export const usePlugins = (): PluginContext => useContext(PluginContext) ?? raise(new Error('Missing PluginContext'));
59
53
 
60
54
  /**
61
55
  * Get a plugin by ID.
@@ -81,4 +75,4 @@ export const useResolvePlugins = <T,>(predicate: (plugin: Plugin) => Plugin<T> |
81
75
  return useMemo(() => plugins.map(predicate).filter(nonNullable), [plugins, predicate]);
82
76
  };
83
77
 
84
- export const PluginProvider: Provider<PluginContext> = PluginContext.Provider;
78
+ export const PluginProvider = PluginContext.Provider;