@dxos/app-framework 0.3.8-next.f4e0086 → 0.3.9-main.27aafd0
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/{chunk-WDA7VA54.mjs → chunk-MNFAM2GF.mjs} +1 -1
- package/dist/lib/browser/{chunk-WDA7VA54.mjs.map → chunk-MNFAM2GF.mjs.map} +2 -2
- package/dist/lib/browser/index.mjs +33 -7
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{plugin-XEJ5RYCP.mjs → plugin-JDIMDLDU.mjs} +2 -2
- package/dist/lib/node/chunk-BOQBLWMX.cjs +49 -0
- package/dist/lib/node/chunk-BOQBLWMX.cjs.map +7 -0
- package/dist/lib/node/chunk-DC3GU6QR.cjs +48 -0
- package/dist/lib/node/chunk-DC3GU6QR.cjs.map +7 -0
- package/dist/lib/node/chunk-VDKZ7AAF.cjs +43 -0
- package/dist/lib/node/chunk-VDKZ7AAF.cjs.map +7 -0
- package/dist/lib/node/index.cjs +90 -299
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/plugin-JGSJGRMS.cjs +61 -0
- package/dist/lib/node/plugin-JGSJGRMS.cjs.map +7 -0
- package/dist/lib/node/plugin-WDNRX2SR.cjs +84 -0
- package/dist/lib/node/plugin-WDNRX2SR.cjs.map +7 -0
- package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts +2 -0
- package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +1 -1
- package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts +10 -2
- package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts.map +1 -1
- package/dist/types/src/plugins/SurfacePlugin/helpers.d.ts +21 -0
- package/dist/types/src/plugins/SurfacePlugin/helpers.d.ts.map +1 -0
- package/dist/types/src/plugins/SurfacePlugin/index.d.ts +1 -0
- package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +1 -1
- package/dist/types/src/plugins/common/graph.d.ts +2 -2
- package/dist/types/src/plugins/common/graph.d.ts.map +1 -1
- package/dist/types/src/plugins/common/layout.d.ts +6 -6
- package/package.json +8 -8
- package/project.json +5 -47
- package/src/plugins/SurfacePlugin/Surface.tsx +34 -5
- package/src/plugins/SurfacePlugin/SurfaceRootContext.tsx +15 -2
- package/src/plugins/SurfacePlugin/helpers.ts +22 -0
- package/src/plugins/SurfacePlugin/index.ts +1 -0
- package/src/plugins/common/graph.ts +2 -2
- /package/dist/lib/browser/{plugin-XEJ5RYCP.mjs.map → plugin-JDIMDLDU.mjs.map} +0 -0
|
@@ -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
|
+
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,207 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
26
|
mod
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var import_debug, findPlugin, getPlugin, filterPlugins, resolvePlugin;
|
|
35
|
-
var init_helpers = __esm({
|
|
36
|
-
"packages/sdk/app-framework/src/plugins/helpers.ts"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
import_debug = require("@dxos/debug");
|
|
39
|
-
findPlugin = (plugins, id) => {
|
|
40
|
-
return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
|
|
41
|
-
};
|
|
42
|
-
getPlugin = (plugins, id) => {
|
|
43
|
-
return findPlugin(plugins, id) ?? (0, import_debug.raise)(new Error(`Plugin not found: ${id}`));
|
|
44
|
-
};
|
|
45
|
-
filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
|
|
46
|
-
resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts
|
|
51
|
-
var parseIntentPlugin, parseIntentResolverPlugin;
|
|
52
|
-
var init_provides = __esm({
|
|
53
|
-
"packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts"() {
|
|
54
|
-
"use strict";
|
|
55
|
-
parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
|
|
56
|
-
parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
|
|
61
|
-
var import_react, IntentContext, useIntent, IntentProvider;
|
|
62
|
-
var init_IntentContext = __esm({
|
|
63
|
-
"packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx"() {
|
|
64
|
-
"use strict";
|
|
65
|
-
import_react = require("react");
|
|
66
|
-
IntentContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
67
|
-
dispatch: async () => {
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
useIntent = () => (0, import_react.useContext)(IntentContext);
|
|
71
|
-
IntentProvider = IntentContext.Provider;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts
|
|
76
|
-
var parseRootSurfacePlugin, parseSurfacePlugin;
|
|
77
|
-
var init_provides2 = __esm({
|
|
78
|
-
"packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts"() {
|
|
79
|
-
"use strict";
|
|
80
|
-
parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
|
|
81
|
-
parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
|
|
86
|
-
var import_react6, SurfaceRootContext, useSurface, SurfaceProvider;
|
|
87
|
-
var init_SurfaceRootContext = __esm({
|
|
88
|
-
"packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx"() {
|
|
89
|
-
"use strict";
|
|
90
|
-
import_react6 = require("react");
|
|
91
|
-
SurfaceRootContext = /* @__PURE__ */ (0, import_react6.createContext)({
|
|
92
|
-
components: {}
|
|
93
|
-
});
|
|
94
|
-
useSurface = () => (0, import_react6.useContext)(SurfaceRootContext);
|
|
95
|
-
SurfaceProvider = SurfaceRootContext.Provider;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts
|
|
100
|
-
var IntentMeta, meta_default;
|
|
101
|
-
var init_meta = __esm({
|
|
102
|
-
"packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts"() {
|
|
103
|
-
"use strict";
|
|
104
|
-
IntentMeta = {
|
|
105
|
-
id: "dxos.org/plugin/intent"
|
|
106
|
-
};
|
|
107
|
-
meta_default = IntentMeta;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts
|
|
112
|
-
var SurfaceMeta, meta_default2;
|
|
113
|
-
var init_meta2 = __esm({
|
|
114
|
-
"packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts"() {
|
|
115
|
-
"use strict";
|
|
116
|
-
SurfaceMeta = {
|
|
117
|
-
id: "dxos.org/plugin/surface"
|
|
118
|
-
};
|
|
119
|
-
meta_default2 = SurfaceMeta;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/plugin.tsx
|
|
124
|
-
var plugin_exports = {};
|
|
125
|
-
__export(plugin_exports, {
|
|
126
|
-
default: () => plugin_default
|
|
127
|
-
});
|
|
128
|
-
var import_react9, import_react10, SurfacePlugin, plugin_default;
|
|
129
|
-
var init_plugin = __esm({
|
|
130
|
-
"packages/sdk/app-framework/src/plugins/SurfacePlugin/plugin.tsx"() {
|
|
131
|
-
"use strict";
|
|
132
|
-
import_react9 = require("deepsignal/react");
|
|
133
|
-
import_react10 = __toESM(require("react"));
|
|
134
|
-
init_SurfaceRootContext();
|
|
135
|
-
init_meta2();
|
|
136
|
-
init_provides2();
|
|
137
|
-
init_helpers();
|
|
138
|
-
SurfacePlugin = () => {
|
|
139
|
-
const state = (0, import_react9.deepSignal)({
|
|
140
|
-
components: {}
|
|
141
|
-
});
|
|
142
|
-
return {
|
|
143
|
-
meta: meta_default2,
|
|
144
|
-
ready: async (plugins) => {
|
|
145
|
-
state.components = (0, import_react9.shallow)(filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
|
|
146
|
-
return {
|
|
147
|
-
...acc,
|
|
148
|
-
[plugin.meta.id]: plugin.provides.surface.component
|
|
149
|
-
};
|
|
150
|
-
}, {}));
|
|
151
|
-
},
|
|
152
|
-
provides: {
|
|
153
|
-
surface: state,
|
|
154
|
-
context: ({ children }) => /* @__PURE__ */ import_react10.default.createElement(SurfaceProvider, {
|
|
155
|
-
value: state
|
|
156
|
-
}, children)
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
plugin_default = SurfacePlugin;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// packages/sdk/app-framework/src/plugins/IntentPlugin/plugin.tsx
|
|
165
|
-
var plugin_exports2 = {};
|
|
166
|
-
__export(plugin_exports2, {
|
|
167
|
-
default: () => plugin_default2
|
|
168
|
-
});
|
|
169
|
-
var import_react11, import_react12, IntentPlugin, plugin_default2;
|
|
170
|
-
var init_plugin2 = __esm({
|
|
171
|
-
"packages/sdk/app-framework/src/plugins/IntentPlugin/plugin.tsx"() {
|
|
172
|
-
"use strict";
|
|
173
|
-
import_react11 = require("deepsignal/react");
|
|
174
|
-
import_react12 = __toESM(require("react"));
|
|
175
|
-
init_IntentContext();
|
|
176
|
-
init_meta();
|
|
177
|
-
init_provides();
|
|
178
|
-
init_helpers();
|
|
179
|
-
IntentPlugin = () => {
|
|
180
|
-
const state = (0, import_react11.deepSignal)({
|
|
181
|
-
dispatch: async () => {
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
return {
|
|
185
|
-
meta: meta_default,
|
|
186
|
-
ready: async (plugins) => {
|
|
187
|
-
const dispatch = async (intent) => {
|
|
188
|
-
if (intent.plugin) {
|
|
189
|
-
const plugin = findPlugin(plugins, intent.plugin);
|
|
190
|
-
return plugin?.provides.intent.resolver(intent, plugins);
|
|
191
|
-
}
|
|
192
|
-
for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {
|
|
193
|
-
const result = await plugin.provides.intent.resolver(intent, plugins);
|
|
194
|
-
if (result) {
|
|
195
|
-
return result;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
state.dispatch = async (intentOrArray) => {
|
|
200
|
-
let result = null;
|
|
201
|
-
for (const intent of Array.isArray(intentOrArray) ? intentOrArray : [
|
|
202
|
-
intentOrArray
|
|
203
|
-
]) {
|
|
204
|
-
const data = intent.data ? {
|
|
205
|
-
...result,
|
|
206
|
-
...intent.data
|
|
207
|
-
} : result;
|
|
208
|
-
result = await dispatch({
|
|
209
|
-
...intent,
|
|
210
|
-
data
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
return result;
|
|
214
|
-
};
|
|
215
|
-
},
|
|
216
|
-
provides: {
|
|
217
|
-
intent: state,
|
|
218
|
-
context: ({ children }) => /* @__PURE__ */ import_react12.default.createElement(IntentProvider, {
|
|
219
|
-
value: state
|
|
220
|
-
}, children)
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
plugin_default2 = IntentPlugin;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// packages/sdk/app-framework/src/index.ts
|
|
229
|
-
var src_exports = {};
|
|
230
|
-
__export(src_exports, {
|
|
29
|
+
var node_exports = {};
|
|
30
|
+
__export(node_exports, {
|
|
231
31
|
ErrorBoundary: () => ErrorBoundary,
|
|
232
|
-
IntentProvider: () => IntentProvider,
|
|
32
|
+
IntentProvider: () => import_chunk_BOQBLWMX.IntentProvider,
|
|
233
33
|
Layout: () => Layout,
|
|
234
34
|
LayoutAction: () => LayoutAction,
|
|
235
35
|
Plugin: () => Plugin,
|
|
@@ -239,39 +39,50 @@ __export(src_exports, {
|
|
|
239
39
|
ResourceKey: () => ResourceKey,
|
|
240
40
|
ResourceLanguage: () => ResourceLanguage,
|
|
241
41
|
Surface: () => Surface,
|
|
242
|
-
SurfaceProvider: () => SurfaceProvider,
|
|
42
|
+
SurfaceProvider: () => import_chunk_DC3GU6QR.SurfaceProvider,
|
|
243
43
|
createApp: () => createApp,
|
|
244
|
-
filterPlugins: () => filterPlugins,
|
|
245
|
-
findPlugin: () => findPlugin,
|
|
246
|
-
getPlugin: () => getPlugin,
|
|
44
|
+
filterPlugins: () => import_chunk_VDKZ7AAF.filterPlugins,
|
|
45
|
+
findPlugin: () => import_chunk_VDKZ7AAF.findPlugin,
|
|
46
|
+
getPlugin: () => import_chunk_VDKZ7AAF.getPlugin,
|
|
247
47
|
initializePlugin: () => initializePlugin,
|
|
48
|
+
isObject: () => isObject,
|
|
248
49
|
parseGraphBuilderPlugin: () => parseGraphBuilderPlugin,
|
|
249
50
|
parseGraphPlugin: () => parseGraphPlugin,
|
|
250
|
-
parseIntentPlugin: () => parseIntentPlugin,
|
|
251
|
-
parseIntentResolverPlugin: () => parseIntentResolverPlugin,
|
|
51
|
+
parseIntentPlugin: () => import_chunk_BOQBLWMX.parseIntentPlugin,
|
|
52
|
+
parseIntentResolverPlugin: () => import_chunk_BOQBLWMX.parseIntentResolverPlugin,
|
|
252
53
|
parseLayoutPlugin: () => parseLayoutPlugin,
|
|
253
54
|
parseMetadataRecordsPlugin: () => parseMetadataRecordsPlugin,
|
|
254
55
|
parseMetadataResolverPlugin: () => parseMetadataResolverPlugin,
|
|
255
56
|
parsePluginHost: () => parsePluginHost,
|
|
256
|
-
parseRootSurfacePlugin: () => parseRootSurfacePlugin,
|
|
257
|
-
parseSurfacePlugin: () => parseSurfacePlugin,
|
|
57
|
+
parseRootSurfacePlugin: () => import_chunk_DC3GU6QR.parseRootSurfacePlugin,
|
|
58
|
+
parseSurfacePlugin: () => import_chunk_DC3GU6QR.parseSurfacePlugin,
|
|
258
59
|
parseTranslationsPlugin: () => parseTranslationsPlugin,
|
|
259
60
|
pluginMeta: () => pluginMeta,
|
|
260
|
-
resolvePlugin: () => resolvePlugin,
|
|
261
|
-
useIntent: () => useIntent,
|
|
61
|
+
resolvePlugin: () => import_chunk_VDKZ7AAF.resolvePlugin,
|
|
62
|
+
useIntent: () => import_chunk_BOQBLWMX.useIntent,
|
|
262
63
|
usePlugin: () => usePlugin,
|
|
263
64
|
usePlugins: () => usePlugins,
|
|
264
65
|
useResolvePlugin: () => useResolvePlugin,
|
|
265
|
-
useSurface: () => useSurface
|
|
66
|
+
useSurface: () => import_chunk_DC3GU6QR.useSurface
|
|
266
67
|
});
|
|
267
|
-
module.exports = __toCommonJS(
|
|
268
|
-
|
|
269
|
-
|
|
68
|
+
module.exports = __toCommonJS(node_exports);
|
|
69
|
+
var import_chunk_DC3GU6QR = require("./chunk-DC3GU6QR.cjs");
|
|
70
|
+
var import_chunk_BOQBLWMX = require("./chunk-BOQBLWMX.cjs");
|
|
71
|
+
var import_chunk_VDKZ7AAF = require("./chunk-VDKZ7AAF.cjs");
|
|
72
|
+
var import_zod = require("zod");
|
|
73
|
+
var import_zod2 = require("zod");
|
|
74
|
+
var import_react = require("react");
|
|
75
|
+
var import_react2 = require("deepsignal/react");
|
|
76
|
+
var import_react3 = __toESM(require("react"));
|
|
77
|
+
var import_local_storage = require("@dxos/local-storage");
|
|
78
|
+
var import_log = require("@dxos/log");
|
|
79
|
+
var import_react4 = __toESM(require("react"));
|
|
80
|
+
var import_react5 = __toESM(require("react"));
|
|
81
|
+
var import_react6 = require("react");
|
|
82
|
+
var import_react7 = __toESM(require("react"));
|
|
83
|
+
var import_invariant = require("@dxos/invariant");
|
|
270
84
|
var parseGraphPlugin = (plugin) => plugin.provides.graph?.root ? plugin : void 0;
|
|
271
85
|
var parseGraphBuilderPlugin = (plugin) => plugin.provides.graph?.builder ? plugin : void 0;
|
|
272
|
-
|
|
273
|
-
// packages/sdk/app-framework/src/plugins/common/layout.ts
|
|
274
|
-
var import_zod = require("zod");
|
|
275
86
|
var Layout = import_zod.z.object({
|
|
276
87
|
fullscreen: import_zod.z.boolean(),
|
|
277
88
|
sidebarOpen: import_zod.z.boolean(),
|
|
@@ -302,17 +113,12 @@ var LayoutAction;
|
|
|
302
113
|
LayoutAction2[LayoutAction2["CLOSE_POPOVER"] = `${LAYOUT_ACTION}/close-popover`] = "CLOSE_POPOVER";
|
|
303
114
|
LayoutAction2[LayoutAction2["ACTIVATE"] = `${LAYOUT_ACTION}/activate`] = "ACTIVATE";
|
|
304
115
|
})(LayoutAction || (LayoutAction = {}));
|
|
305
|
-
|
|
306
|
-
// packages/sdk/app-framework/src/plugins/common/metadata.ts
|
|
307
116
|
var parseMetadataRecordsPlugin = (plugin) => {
|
|
308
117
|
return plugin.provides.metadata?.records ? plugin : void 0;
|
|
309
118
|
};
|
|
310
119
|
var parseMetadataResolverPlugin = (plugin) => {
|
|
311
120
|
return plugin.provides.metadata?.resolver ? plugin : void 0;
|
|
312
121
|
};
|
|
313
|
-
|
|
314
|
-
// packages/sdk/app-framework/src/plugins/common/translations.ts
|
|
315
|
-
var import_zod2 = require("zod");
|
|
316
122
|
var ResourceKey = import_zod2.z.union([
|
|
317
123
|
import_zod2.z.string(),
|
|
318
124
|
import_zod2.z.record(import_zod2.z.any())
|
|
@@ -323,15 +129,6 @@ var parseTranslationsPlugin = (plugin) => {
|
|
|
323
129
|
const { success } = import_zod2.z.array(Resource).safeParse(plugin.provides.translations);
|
|
324
130
|
return success ? plugin : void 0;
|
|
325
131
|
};
|
|
326
|
-
|
|
327
|
-
// packages/sdk/app-framework/src/plugins/index.ts
|
|
328
|
-
init_helpers();
|
|
329
|
-
|
|
330
|
-
// packages/sdk/app-framework/src/plugins/IntentPlugin/index.ts
|
|
331
|
-
init_provides();
|
|
332
|
-
init_IntentContext();
|
|
333
|
-
|
|
334
|
-
// packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
|
|
335
132
|
var pluginMeta = (meta) => meta;
|
|
336
133
|
var Plugin;
|
|
337
134
|
(function(Plugin2) {
|
|
@@ -341,11 +138,7 @@ var Plugin;
|
|
|
341
138
|
});
|
|
342
139
|
};
|
|
343
140
|
})(Plugin || (Plugin = {}));
|
|
344
|
-
|
|
345
|
-
// packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
|
|
346
|
-
var import_react2 = require("react");
|
|
347
|
-
init_helpers();
|
|
348
|
-
var PluginContext = /* @__PURE__ */ (0, import_react2.createContext)({
|
|
141
|
+
var PluginContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
349
142
|
ready: false,
|
|
350
143
|
enabled: [],
|
|
351
144
|
plugins: [],
|
|
@@ -355,22 +148,16 @@ var PluginContext = /* @__PURE__ */ (0, import_react2.createContext)({
|
|
|
355
148
|
disablePlugin: () => {
|
|
356
149
|
}
|
|
357
150
|
});
|
|
358
|
-
var usePlugins = () => (0,
|
|
151
|
+
var usePlugins = () => (0, import_react.useContext)(PluginContext);
|
|
359
152
|
var usePlugin = (id) => {
|
|
360
153
|
const { plugins } = usePlugins();
|
|
361
|
-
return findPlugin(plugins, id);
|
|
154
|
+
return (0, import_chunk_VDKZ7AAF.findPlugin)(plugins, id);
|
|
362
155
|
};
|
|
363
156
|
var useResolvePlugin = (predicate) => {
|
|
364
157
|
const { plugins } = usePlugins();
|
|
365
|
-
return resolvePlugin(plugins, predicate);
|
|
158
|
+
return (0, import_chunk_VDKZ7AAF.resolvePlugin)(plugins, predicate);
|
|
366
159
|
};
|
|
367
160
|
var PluginProvider = PluginContext.Provider;
|
|
368
|
-
|
|
369
|
-
// packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
|
|
370
|
-
var import_react3 = require("deepsignal/react");
|
|
371
|
-
var import_react4 = __toESM(require("react"));
|
|
372
|
-
var import_local_storage = require("@dxos/local-storage");
|
|
373
|
-
var import_log = require("@dxos/log");
|
|
374
161
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
|
|
375
162
|
var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
|
|
376
163
|
var PLUGIN_HOST = "dxos.org/plugin/host";
|
|
@@ -400,11 +187,11 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
400
187
|
},
|
|
401
188
|
provides: {
|
|
402
189
|
plugins: state.values,
|
|
403
|
-
context: ({ children }) => /* @__PURE__ */
|
|
190
|
+
context: ({ children }) => /* @__PURE__ */ import_react3.default.createElement(PluginProvider, {
|
|
404
191
|
value: state.values
|
|
405
192
|
}, children),
|
|
406
193
|
root: () => {
|
|
407
|
-
(0,
|
|
194
|
+
(0, import_react3.useEffect)(() => {
|
|
408
195
|
(0, import_log.log)("initializing plugins", {
|
|
409
196
|
enabled: state.values.enabled
|
|
410
197
|
}, {
|
|
@@ -449,7 +236,7 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
449
236
|
S: void 0,
|
|
450
237
|
C: (f, a) => f(...a)
|
|
451
238
|
});
|
|
452
|
-
state.values.plugins = (0,
|
|
239
|
+
state.values.plugins = (0, import_react2.shallow)(plugins);
|
|
453
240
|
state.values.ready = true;
|
|
454
241
|
});
|
|
455
242
|
return () => {
|
|
@@ -458,10 +245,10 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
458
245
|
};
|
|
459
246
|
}, []);
|
|
460
247
|
if (!state.values.ready) {
|
|
461
|
-
return /* @__PURE__ */
|
|
248
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, fallback);
|
|
462
249
|
}
|
|
463
250
|
const ComposedContext = composeContext(state.values.plugins);
|
|
464
|
-
return /* @__PURE__ */
|
|
251
|
+
return /* @__PURE__ */ import_react3.default.createElement(ComposedContext, null, rootComponents(state.values.plugins));
|
|
465
252
|
}
|
|
466
253
|
}
|
|
467
254
|
};
|
|
@@ -480,7 +267,7 @@ var rootComponents = (plugins) => {
|
|
|
480
267
|
return plugins.map((plugin) => {
|
|
481
268
|
const Component2 = plugin.provides.root;
|
|
482
269
|
if (Component2) {
|
|
483
|
-
return /* @__PURE__ */
|
|
270
|
+
return /* @__PURE__ */ import_react3.default.createElement(Component2, {
|
|
484
271
|
key: plugin.meta.id
|
|
485
272
|
});
|
|
486
273
|
} else {
|
|
@@ -494,15 +281,10 @@ var composeContext = (plugins) => {
|
|
|
494
281
|
var compose = (contexts) => {
|
|
495
282
|
return [
|
|
496
283
|
...contexts
|
|
497
|
-
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */
|
|
284
|
+
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react3.default.createElement(Acc, null, /* @__PURE__ */ import_react3.default.createElement(Next, null, children)));
|
|
498
285
|
};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
init_provides2();
|
|
502
|
-
|
|
503
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
|
|
504
|
-
var import_react5 = __toESM(require("react"));
|
|
505
|
-
var ErrorBoundary = class extends import_react5.Component {
|
|
286
|
+
var isObject = (data) => !!data && typeof data === "object";
|
|
287
|
+
var ErrorBoundary = class extends import_react4.Component {
|
|
506
288
|
constructor(props) {
|
|
507
289
|
super(props);
|
|
508
290
|
this.state = {
|
|
@@ -521,7 +303,7 @@ var ErrorBoundary = class extends import_react5.Component {
|
|
|
521
303
|
}
|
|
522
304
|
render() {
|
|
523
305
|
if (this.state.error) {
|
|
524
|
-
return /* @__PURE__ */
|
|
306
|
+
return /* @__PURE__ */ import_react4.default.createElement(this.props.fallback, {
|
|
525
307
|
error: this.state.error,
|
|
526
308
|
reset: this.resetError
|
|
527
309
|
});
|
|
@@ -534,35 +316,30 @@ var ErrorBoundary = class extends import_react5.Component {
|
|
|
534
316
|
});
|
|
535
317
|
}
|
|
536
318
|
};
|
|
537
|
-
|
|
538
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
|
|
539
|
-
var import_react7 = __toESM(require("react"));
|
|
540
|
-
var import_react8 = require("react");
|
|
541
|
-
init_SurfaceRootContext();
|
|
542
|
-
var Surface = /* @__PURE__ */ (0, import_react7.forwardRef)(({ role, name = role, fallback, ...rest }, forwardedRef) => {
|
|
319
|
+
var Surface = /* @__PURE__ */ (0, import_react5.forwardRef)(({ role, name = role, fallback, ...rest }, forwardedRef) => {
|
|
543
320
|
const props = {
|
|
544
321
|
role,
|
|
545
322
|
name,
|
|
546
323
|
fallback,
|
|
547
324
|
...rest
|
|
548
325
|
};
|
|
549
|
-
const context = (0,
|
|
326
|
+
const context = (0, import_react6.useContext)(SurfaceContext);
|
|
550
327
|
const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
|
|
551
|
-
return /* @__PURE__ */
|
|
328
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, fallback ? /* @__PURE__ */ import_react5.default.createElement(ErrorBoundary, {
|
|
552
329
|
data,
|
|
553
330
|
fallback
|
|
554
|
-
}, /* @__PURE__ */
|
|
331
|
+
}, /* @__PURE__ */ import_react5.default.createElement(SurfaceResolver, {
|
|
555
332
|
...props,
|
|
556
333
|
ref: forwardedRef
|
|
557
|
-
})) : /* @__PURE__ */
|
|
334
|
+
})) : /* @__PURE__ */ import_react5.default.createElement(SurfaceResolver, {
|
|
558
335
|
...props,
|
|
559
336
|
ref: forwardedRef
|
|
560
337
|
}));
|
|
561
338
|
});
|
|
562
|
-
var SurfaceContext = /* @__PURE__ */ (0,
|
|
563
|
-
var SurfaceResolver = /* @__PURE__ */ (0,
|
|
564
|
-
const { components } = useSurface();
|
|
565
|
-
const parent = (0,
|
|
339
|
+
var SurfaceContext = /* @__PURE__ */ (0, import_react6.createContext)(null);
|
|
340
|
+
var SurfaceResolver = /* @__PURE__ */ (0, import_react5.forwardRef)((props, forwardedRef) => {
|
|
341
|
+
const { components } = (0, import_chunk_DC3GU6QR.useSurface)();
|
|
342
|
+
const parent = (0, import_react6.useContext)(SurfaceContext);
|
|
566
343
|
const nodes = resolveNodes(components, props, parent, forwardedRef);
|
|
567
344
|
const currentContext = {
|
|
568
345
|
...props,
|
|
@@ -571,9 +348,9 @@ var SurfaceResolver = /* @__PURE__ */ (0, import_react7.forwardRef)((props, forw
|
|
|
571
348
|
...props.surfaces
|
|
572
349
|
}
|
|
573
350
|
};
|
|
574
|
-
return /* @__PURE__ */
|
|
351
|
+
return /* @__PURE__ */ import_react5.default.createElement(SurfaceContext.Provider, {
|
|
575
352
|
value: currentContext
|
|
576
|
-
}, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */
|
|
353
|
+
}, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ import_react5.default.createElement(props.contentFallback, null) : null);
|
|
577
354
|
});
|
|
578
355
|
var resolveNodes = (components, props, context, forwardedRef) => {
|
|
579
356
|
const data = {
|
|
@@ -585,37 +362,50 @@ var resolveNodes = (components, props, context, forwardedRef) => {
|
|
|
585
362
|
...props,
|
|
586
363
|
data
|
|
587
364
|
}, forwardedRef);
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
365
|
+
if (!result || typeof result !== "object") {
|
|
366
|
+
return void 0;
|
|
367
|
+
}
|
|
368
|
+
return "node" in result ? [
|
|
369
|
+
key,
|
|
370
|
+
result
|
|
371
|
+
] : /* @__PURE__ */ (0, import_react5.isValidElement)(result) ? [
|
|
372
|
+
key,
|
|
373
|
+
{
|
|
374
|
+
node: result
|
|
375
|
+
}
|
|
376
|
+
] : void 0;
|
|
377
|
+
}).filter((result) => Boolean(result)).sort(([, a], [, b]) => {
|
|
378
|
+
const aDisposition = a.disposition ?? "default";
|
|
379
|
+
const bDisposition = b.disposition ?? "default";
|
|
380
|
+
if (aDisposition === bDisposition) {
|
|
381
|
+
return 0;
|
|
382
|
+
} else if (aDisposition === "hoist" || bDisposition === "fallback") {
|
|
383
|
+
return -1;
|
|
384
|
+
} else if (bDisposition === "hoist" || aDisposition === "fallback") {
|
|
385
|
+
return 1;
|
|
386
|
+
}
|
|
387
|
+
return 0;
|
|
388
|
+
}).map(([key, result]) => /* @__PURE__ */ import_react5.default.createElement(import_react5.Fragment, {
|
|
389
|
+
key
|
|
390
|
+
}, result.node));
|
|
592
391
|
return props.limit ? nodes.slice(0, props.limit) : nodes;
|
|
593
392
|
};
|
|
594
|
-
|
|
595
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/index.ts
|
|
596
|
-
init_SurfaceRootContext();
|
|
597
|
-
|
|
598
|
-
// packages/sdk/app-framework/src/App.tsx
|
|
599
|
-
var import_react13 = __toESM(require("react"));
|
|
600
|
-
var import_invariant = require("@dxos/invariant");
|
|
601
|
-
init_meta();
|
|
602
|
-
init_meta2();
|
|
603
393
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
|
|
604
394
|
var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }) => {
|
|
605
395
|
const host = PluginHost({
|
|
606
396
|
order: [
|
|
607
|
-
|
|
608
|
-
meta_default,
|
|
397
|
+
import_chunk_DC3GU6QR.meta_default,
|
|
398
|
+
import_chunk_BOQBLWMX.meta_default,
|
|
609
399
|
...order
|
|
610
400
|
],
|
|
611
401
|
plugins: {
|
|
612
402
|
...plugins,
|
|
613
|
-
[
|
|
614
|
-
[meta_default.id]: Plugin.lazy(() =>
|
|
403
|
+
[import_chunk_DC3GU6QR.meta_default.id]: Plugin.lazy(() => import("./plugin-JGSJGRMS.cjs")),
|
|
404
|
+
[import_chunk_BOQBLWMX.meta_default.id]: Plugin.lazy(() => import("./plugin-WDNRX2SR.cjs"))
|
|
615
405
|
},
|
|
616
406
|
core: [
|
|
617
|
-
|
|
618
|
-
meta_default.id,
|
|
407
|
+
import_chunk_DC3GU6QR.meta_default.id,
|
|
408
|
+
import_chunk_BOQBLWMX.meta_default.id,
|
|
619
409
|
...core
|
|
620
410
|
],
|
|
621
411
|
...params
|
|
@@ -640,7 +430,7 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
|
|
|
640
430
|
});
|
|
641
431
|
const Context = host.provides.context;
|
|
642
432
|
const Root = host.provides.root;
|
|
643
|
-
return () => /* @__PURE__ */
|
|
433
|
+
return () => /* @__PURE__ */ import_react7.default.createElement(Context, null, /* @__PURE__ */ import_react7.default.createElement(Root, null));
|
|
644
434
|
};
|
|
645
435
|
// Annotate the CommonJS export names for ESM import in node:
|
|
646
436
|
0 && (module.exports = {
|
|
@@ -661,6 +451,7 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
|
|
|
661
451
|
findPlugin,
|
|
662
452
|
getPlugin,
|
|
663
453
|
initializePlugin,
|
|
454
|
+
isObject,
|
|
664
455
|
parseGraphBuilderPlugin,
|
|
665
456
|
parseGraphPlugin,
|
|
666
457
|
parseIntentPlugin,
|