@dxos/app-framework 0.3.8-main.918578 → 0.3.8-main.9a32253

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.
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_BOQBLWMX_exports = {};
20
+ __export(chunk_BOQBLWMX_exports, {
21
+ IntentProvider: () => IntentProvider,
22
+ meta_default: () => meta_default,
23
+ parseIntentPlugin: () => parseIntentPlugin,
24
+ parseIntentResolverPlugin: () => parseIntentResolverPlugin,
25
+ useIntent: () => useIntent
26
+ });
27
+ module.exports = __toCommonJS(chunk_BOQBLWMX_exports);
28
+ var import_react = require("react");
29
+ var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
30
+ var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
31
+ var IntentContext = /* @__PURE__ */ (0, import_react.createContext)({
32
+ dispatch: async () => {
33
+ }
34
+ });
35
+ var useIntent = () => (0, import_react.useContext)(IntentContext);
36
+ var IntentProvider = IntentContext.Provider;
37
+ var IntentMeta = {
38
+ id: "dxos.org/plugin/intent"
39
+ };
40
+ var meta_default = IntentMeta;
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ IntentProvider,
44
+ meta_default,
45
+ parseIntentPlugin,
46
+ parseIntentResolverPlugin,
47
+ useIntent
48
+ });
49
+ //# sourceMappingURL=chunk-BOQBLWMX.cjs.map
@@ -0,0 +1,7 @@
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 Intent } from './intent';\nimport { type Plugin } from '../PluginHost';\n\nexport type IntentResolverProvides = {\n intent: {\n resolver: (intent: Intent, plugins: Plugin[]) => any;\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// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider } from 'react';\n\nimport { type DispatchIntent } from './intent';\n\nexport type IntentContext = {\n dispatch: DispatchIntent;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({ dispatch: async () => {} });\n\nexport const useIntent = () => useContext(IntentContext);\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAAuE;ADchE,IAAMA,oBAAoB,CAACC,WAC/BA,OAAOC,SAAiBC,QAAQC,WAAYH,SAA0CI;AAElF,IAAMC,4BAA4B,CAACL,WACvCA,OAAOC,SAAiBC,QAAQI,WAAYN,SAA4CI;ACV3F,IAAMG,gBAAwCC,gDAA6B;EAAEL,UAAU,YAAA;EAAa;AAAE,CAAA;AAE/F,IAAMM,YAAY,UAAMC,yBAAWH,aAAAA;AAEnC,IAAMI,iBAA0CJ,cAAcK;ACZrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
+ "names": ["parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "IntentContext", "createContext", "useIntent", "useContext", "IntentProvider", "Provider", "IntentMeta", "id"]
7
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_VDKZ7AAF_exports = {};
20
+ __export(chunk_VDKZ7AAF_exports, {
21
+ filterPlugins: () => filterPlugins,
22
+ findPlugin: () => findPlugin,
23
+ getPlugin: () => getPlugin,
24
+ resolvePlugin: () => resolvePlugin
25
+ });
26
+ module.exports = __toCommonJS(chunk_VDKZ7AAF_exports);
27
+ var import_debug = require("@dxos/debug");
28
+ var findPlugin = (plugins, id) => {
29
+ return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
30
+ };
31
+ var getPlugin = (plugins, id) => {
32
+ return findPlugin(plugins, id) ?? (0, import_debug.raise)(new Error(`Plugin not found: ${id}`));
33
+ };
34
+ var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
35
+ var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ filterPlugins,
39
+ findPlugin,
40
+ getPlugin,
41
+ resolvePlugin
42
+ });
43
+ //# sourceMappingURL=chunk-VDKZ7AAF.cjs.map
@@ -0,0 +1,7 @@
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 * 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,mBAAsB;AAOf,IAAMA,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACC,WAAWA,OAAOC,KAAKH,OAAOA,MAAO,OAAOE,OAAOC,KAAKC,YAAY,YAAYF,OAAOC,KAAKC,YAAYJ,EAAAA;AAE7G;AAKO,IAAMK,YAAY,CAAIN,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,SAAOM,oBAAM,IAAIC,MAAM,qBAAqBP,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMQ,gBAAgB,CAC3BT,SACAU,cACgBV,QAAQW,IAAI,CAACR,WAAWO,UAAUP,MAAAA,CAAAA,EAASS,OAAO,CAACT,WAAgC,CAAC,CAACA,MAAAA;AAShG,IAAMU,gBAAgB,CAC3Bb,SACAU,cAC0BD,cAAcT,SAASU,SAAAA,EAAW,CAAA;",
6
+ "names": ["findPlugin", "plugins", "id", "find", "plugin", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin"]
7
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_YDKX45O3_exports = {};
20
+ __export(chunk_YDKX45O3_exports, {
21
+ SurfaceProvider: () => SurfaceProvider,
22
+ meta_default: () => meta_default,
23
+ parseRootSurfacePlugin: () => parseRootSurfacePlugin,
24
+ parseSurfacePlugin: () => parseSurfacePlugin,
25
+ useSurface: () => useSurface
26
+ });
27
+ module.exports = __toCommonJS(chunk_YDKX45O3_exports);
28
+ var import_react = require("react");
29
+ var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
30
+ var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
31
+ var SurfaceRootContext = /* @__PURE__ */ (0, import_react.createContext)({
32
+ components: {}
33
+ });
34
+ var useSurface = () => (0, import_react.useContext)(SurfaceRootContext);
35
+ var SurfaceProvider = SurfaceRootContext.Provider;
36
+ var SurfaceMeta = {
37
+ id: "dxos.org/plugin/surface"
38
+ };
39
+ var meta_default = SurfaceMeta;
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ SurfaceProvider,
43
+ meta_default,
44
+ parseRootSurfacePlugin,
45
+ parseSurfacePlugin,
46
+ useSurface
47
+ });
48
+ //# sourceMappingURL=chunk-YDKX45O3.cjs.map
@@ -0,0 +1,7 @@
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 Provider, type ReactNode, 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 * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (props: SurfaceComponentProps, forwardedRef: ForwardedRef<HTMLElement>) => ReactNode;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n};\n\nconst SurfaceRootContext: Context<SurfaceRootContext> = createContext<SurfaceRootContext>({ components: {} });\n\nexport const useSurface = () => 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAA0G;ADgBnG,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;ACExF,IAAMG,qBAAkDC,gDAAkC;EAAEL,YAAY,CAAC;AAAE,CAAA;AAEpG,IAAMM,aAAa,UAAMC,yBAAWH,kBAAAA;AAEpC,IAAMI,kBAAgDJ,mBAAmBK;AC1BhF,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
+ "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "SurfaceRootContext", "createContext", "useSurface", "useContext", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
+ }