@dxos/app-framework 0.3.7-main.8c7953e → 0.3.7-main.fcec8cd
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-C2K6M6WC.mjs +27 -0
- package/dist/lib/browser/chunk-C2K6M6WC.mjs.map +7 -0
- package/dist/lib/browser/chunk-CFZ5JAJF.mjs +18 -0
- package/dist/lib/browser/chunk-CFZ5JAJF.mjs.map +7 -0
- package/dist/lib/browser/chunk-T6Z4W7BV.mjs +26 -0
- package/dist/lib/browser/chunk-T6Z4W7BV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +123 -181
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/plugin-CBPJO5NB.mjs +63 -0
- package/dist/lib/browser/plugin-CBPJO5NB.mjs.map +7 -0
- package/dist/lib/browser/plugin-T5H34MVA.mjs +39 -0
- package/dist/lib/browser/plugin-T5H34MVA.mjs.map +7 -0
- package/dist/lib/node/index.cjs +315 -179
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/App.d.ts +13 -3
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/plugins/IntentPlugin/index.d.ts +1 -1
- package/dist/types/src/plugins/IntentPlugin/index.d.ts.map +1 -1
- package/dist/types/src/plugins/IntentPlugin/meta.d.ts +5 -0
- package/dist/types/src/plugins/IntentPlugin/meta.d.ts.map +1 -0
- package/dist/types/src/plugins/IntentPlugin/plugin.d.ts +9 -0
- package/dist/types/src/plugins/IntentPlugin/plugin.d.ts.map +1 -0
- package/dist/types/src/plugins/IntentPlugin/{IntentPlugin.d.ts → provides.d.ts} +2 -7
- package/dist/types/src/plugins/IntentPlugin/provides.d.ts.map +1 -0
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +27 -3
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +7 -4
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/plugin.d.ts +49 -1
- package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
- package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +1 -1
- package/dist/types/src/plugins/SurfacePlugin/index.d.ts +1 -1
- package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +1 -1
- package/dist/types/src/plugins/SurfacePlugin/meta.d.ts +5 -0
- package/dist/types/src/plugins/SurfacePlugin/meta.d.ts.map +1 -0
- package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts +8 -0
- package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts.map +1 -0
- package/dist/types/src/plugins/SurfacePlugin/{SurfacePlugin.d.ts → provides.d.ts} +2 -6
- package/dist/types/src/plugins/SurfacePlugin/provides.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/App.tsx +24 -6
- package/src/plugins/IntentPlugin/index.ts +2 -1
- package/src/plugins/IntentPlugin/meta.ts +9 -0
- package/src/plugins/IntentPlugin/{IntentPlugin.tsx → plugin.tsx} +8 -22
- package/src/plugins/IntentPlugin/provides.ts +23 -0
- package/src/plugins/PluginHost/PluginContext.tsx +36 -5
- package/src/plugins/PluginHost/PluginHost.tsx +58 -98
- package/src/plugins/PluginHost/plugin.ts +31 -1
- package/src/plugins/SurfacePlugin/Surface.tsx +2 -4
- package/src/plugins/SurfacePlugin/index.ts +2 -1
- package/src/plugins/SurfacePlugin/meta.ts +9 -0
- package/src/plugins/SurfacePlugin/plugin.tsx +36 -0
- package/src/plugins/SurfacePlugin/provides.ts +25 -0
- package/tsconfig.json +3 -0
- package/dist/types/src/plugins/IntentPlugin/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/SurfacePlugin.d.ts.map +0 -1
- package/src/plugins/SurfacePlugin/SurfacePlugin.tsx +0 -53
package/dist/lib/node/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ 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
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,21 +30,215 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// packages/sdk/app-framework/src/plugins/helpers.ts
|
|
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
|
+
|
|
30
228
|
// packages/sdk/app-framework/src/index.ts
|
|
31
229
|
var src_exports = {};
|
|
32
230
|
__export(src_exports, {
|
|
33
231
|
ErrorBoundary: () => ErrorBoundary,
|
|
34
|
-
IntentPlugin: () => IntentPlugin,
|
|
35
232
|
IntentProvider: () => IntentProvider,
|
|
36
233
|
Layout: () => Layout,
|
|
37
234
|
LayoutAction: () => LayoutAction,
|
|
235
|
+
Plugin: () => Plugin,
|
|
38
236
|
PluginHost: () => PluginHost,
|
|
39
237
|
PluginProvider: () => PluginProvider,
|
|
40
238
|
Resource: () => Resource,
|
|
41
239
|
ResourceKey: () => ResourceKey,
|
|
42
240
|
ResourceLanguage: () => ResourceLanguage,
|
|
43
241
|
Surface: () => Surface,
|
|
44
|
-
SurfacePlugin: () => SurfacePlugin,
|
|
45
242
|
SurfaceProvider: () => SurfaceProvider,
|
|
46
243
|
createApp: () => createApp,
|
|
47
244
|
filterPlugins: () => filterPlugins,
|
|
@@ -59,6 +256,7 @@ __export(src_exports, {
|
|
|
59
256
|
parseRootSurfacePlugin: () => parseRootSurfacePlugin,
|
|
60
257
|
parseSurfacePlugin: () => parseSurfacePlugin,
|
|
61
258
|
parseTranslationsPlugin: () => parseTranslationsPlugin,
|
|
259
|
+
pluginMeta: () => pluginMeta,
|
|
62
260
|
resolvePlugin: () => resolvePlugin,
|
|
63
261
|
useIntent: () => useIntent,
|
|
64
262
|
usePlugin: () => usePlugin,
|
|
@@ -126,88 +324,38 @@ var parseTranslationsPlugin = (plugin) => {
|
|
|
126
324
|
return success ? plugin : void 0;
|
|
127
325
|
};
|
|
128
326
|
|
|
129
|
-
// packages/sdk/app-framework/src/plugins/
|
|
130
|
-
|
|
131
|
-
var findPlugin = (plugins, id) => {
|
|
132
|
-
return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
|
|
133
|
-
};
|
|
134
|
-
var getPlugin = (plugins, id) => {
|
|
135
|
-
return findPlugin(plugins, id) ?? (0, import_debug.raise)(new Error(`Plugin not found: ${id}`));
|
|
136
|
-
};
|
|
137
|
-
var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
|
|
138
|
-
var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
|
|
327
|
+
// packages/sdk/app-framework/src/plugins/index.ts
|
|
328
|
+
init_helpers();
|
|
139
329
|
|
|
140
|
-
// packages/sdk/app-framework/src/plugins/IntentPlugin/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
dispatch: async () => {
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
var useIntent = () => (0, import_react.useContext)(IntentContext);
|
|
147
|
-
var IntentProvider = IntentContext.Provider;
|
|
330
|
+
// packages/sdk/app-framework/src/plugins/IntentPlugin/index.ts
|
|
331
|
+
init_provides();
|
|
332
|
+
init_IntentContext();
|
|
148
333
|
|
|
149
|
-
// packages/sdk/app-framework/src/plugins/
|
|
150
|
-
var
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return {
|
|
160
|
-
meta: {
|
|
161
|
-
id: "dxos.org/plugin/intent"
|
|
162
|
-
},
|
|
163
|
-
ready: async (plugins) => {
|
|
164
|
-
const dispatch = async (intent) => {
|
|
165
|
-
if (intent.plugin) {
|
|
166
|
-
const plugin = findPlugin(plugins, intent.plugin);
|
|
167
|
-
return plugin?.provides.intent.resolver(intent, plugins);
|
|
168
|
-
}
|
|
169
|
-
for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {
|
|
170
|
-
const result = await plugin.provides.intent.resolver(intent, plugins);
|
|
171
|
-
if (result) {
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
state.dispatch = async (intentOrArray) => {
|
|
177
|
-
let result = null;
|
|
178
|
-
for (const intent of Array.isArray(intentOrArray) ? intentOrArray : [
|
|
179
|
-
intentOrArray
|
|
180
|
-
]) {
|
|
181
|
-
const data = intent.data ? {
|
|
182
|
-
...result,
|
|
183
|
-
...intent.data
|
|
184
|
-
} : result;
|
|
185
|
-
result = await dispatch({
|
|
186
|
-
...intent,
|
|
187
|
-
data
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
};
|
|
192
|
-
},
|
|
193
|
-
provides: {
|
|
194
|
-
intent: state,
|
|
195
|
-
context: ({ children }) => /* @__PURE__ */ import_react3.default.createElement(IntentProvider, {
|
|
196
|
-
value: state
|
|
197
|
-
}, children)
|
|
198
|
-
}
|
|
334
|
+
// packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
|
|
335
|
+
var pluginMeta = (meta) => meta;
|
|
336
|
+
var Plugin;
|
|
337
|
+
(function(Plugin2) {
|
|
338
|
+
var lazy = Plugin2.lazy = (p, props) => {
|
|
339
|
+
return () => p().then(({ default: definition }) => {
|
|
340
|
+
return definition(props);
|
|
341
|
+
});
|
|
199
342
|
};
|
|
200
|
-
};
|
|
343
|
+
})(Plugin || (Plugin = {}));
|
|
201
344
|
|
|
202
345
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
|
|
203
|
-
var
|
|
204
|
-
|
|
346
|
+
var import_react2 = require("react");
|
|
347
|
+
init_helpers();
|
|
348
|
+
var PluginContext = /* @__PURE__ */ (0, import_react2.createContext)({
|
|
205
349
|
ready: false,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
350
|
+
enabled: [],
|
|
351
|
+
plugins: [],
|
|
352
|
+
available: [],
|
|
353
|
+
enablePlugin: () => {
|
|
354
|
+
},
|
|
355
|
+
disablePlugin: () => {
|
|
356
|
+
}
|
|
209
357
|
});
|
|
210
|
-
var usePlugins = () => (0,
|
|
358
|
+
var usePlugins = () => (0, import_react2.useContext)(PluginContext);
|
|
211
359
|
var usePlugin = (id) => {
|
|
212
360
|
const { plugins } = usePlugins();
|
|
213
361
|
return findPlugin(plugins, id);
|
|
@@ -219,90 +367,100 @@ var useResolvePlugin = (predicate) => {
|
|
|
219
367
|
var PluginProvider = PluginContext.Provider;
|
|
220
368
|
|
|
221
369
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
|
|
222
|
-
var
|
|
223
|
-
var
|
|
370
|
+
var import_react3 = require("deepsignal/react");
|
|
371
|
+
var import_react4 = __toESM(require("react"));
|
|
372
|
+
var import_local_storage = require("@dxos/local-storage");
|
|
224
373
|
var import_log = require("@dxos/log");
|
|
225
374
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
|
|
226
375
|
var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
|
|
227
|
-
var
|
|
228
|
-
|
|
376
|
+
var PLUGIN_HOST = "dxos.org/plugin/host";
|
|
377
|
+
var PluginHost = ({ order, plugins: definitions, core = order.map(({ id }) => id), defaults = [], fallback = null }) => {
|
|
378
|
+
const state = new import_local_storage.LocalStorageStore(PLUGIN_HOST, {
|
|
229
379
|
ready: false,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
380
|
+
enabled: [
|
|
381
|
+
...defaults
|
|
382
|
+
],
|
|
383
|
+
plugins: [],
|
|
384
|
+
available: order.filter(({ id }) => !core.includes(id)),
|
|
385
|
+
enablePlugin: (id) => {
|
|
386
|
+
state.values.enabled = [
|
|
387
|
+
...state.values.enabled,
|
|
388
|
+
id
|
|
389
|
+
];
|
|
390
|
+
},
|
|
391
|
+
disablePlugin: (id) => {
|
|
392
|
+
state.values.enabled = state.values.enabled.filter((enabled) => enabled !== id);
|
|
393
|
+
}
|
|
233
394
|
});
|
|
395
|
+
state.prop(state.values.$enabled, "enabled", import_local_storage.LocalStorageStore.json);
|
|
234
396
|
return {
|
|
235
397
|
meta: {
|
|
236
|
-
id:
|
|
398
|
+
id: PLUGIN_HOST
|
|
237
399
|
},
|
|
238
400
|
provides: {
|
|
239
|
-
plugins: state,
|
|
240
|
-
context: ({ children }) => /* @__PURE__ */
|
|
241
|
-
value: state
|
|
401
|
+
plugins: state.values,
|
|
402
|
+
context: ({ children }) => /* @__PURE__ */ import_react4.default.createElement(PluginProvider, {
|
|
403
|
+
value: state.values
|
|
242
404
|
}, children),
|
|
243
405
|
root: () => {
|
|
244
|
-
(0,
|
|
406
|
+
(0, import_react4.useEffect)(() => {
|
|
245
407
|
(0, import_log.log)("initializing plugins", {
|
|
246
|
-
|
|
408
|
+
enabled: state.values.enabled
|
|
247
409
|
}, {
|
|
248
410
|
F: __dxlog_file,
|
|
249
|
-
L:
|
|
411
|
+
L: 65,
|
|
250
412
|
S: void 0,
|
|
251
413
|
C: (f, a) => f(...a)
|
|
252
414
|
});
|
|
253
415
|
const timeout = setTimeout(async () => {
|
|
254
|
-
|
|
255
|
-
|
|
416
|
+
const enabledIds = [
|
|
417
|
+
...core,
|
|
418
|
+
...state.values.enabled
|
|
419
|
+
].sort((a, b) => {
|
|
420
|
+
const indexA = order.findIndex(({ id }) => id === a);
|
|
421
|
+
const indexB = order.findIndex(({ id }) => id === b);
|
|
422
|
+
return indexA - indexB;
|
|
423
|
+
});
|
|
424
|
+
const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
|
|
425
|
+
const plugins = await Promise.all(enabled.map(async (definition) => {
|
|
256
426
|
const plugin = await initializePlugin(definition).catch((err) => {
|
|
257
427
|
console.error("Failed to initialize plugin:", definition.meta.id, err);
|
|
258
428
|
return void 0;
|
|
259
429
|
});
|
|
260
|
-
state.initializing = (0, import_react5.shallow)(state.initializing.filter((plugin2) => plugin2 !== definition));
|
|
261
430
|
return plugin;
|
|
262
431
|
})).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
|
|
263
432
|
(0, import_log.log)("plugins initialized", {
|
|
264
433
|
plugins
|
|
265
434
|
}, {
|
|
266
435
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
436
|
+
L: 90,
|
|
268
437
|
S: void 0,
|
|
269
438
|
C: (f, a) => f(...a)
|
|
270
439
|
});
|
|
271
|
-
|
|
272
|
-
await Promise.all(definitions.map(async (pluginDefinition) => {
|
|
440
|
+
await Promise.all(enabled.map(async (pluginDefinition) => {
|
|
273
441
|
await pluginDefinition.ready?.(plugins);
|
|
274
|
-
state.loading = (0, import_react5.shallow)(state.loading.filter((plugin) => plugin !== pluginDefinition));
|
|
275
442
|
}));
|
|
276
443
|
(0, import_log.log)("plugins ready", {
|
|
277
444
|
plugins
|
|
278
445
|
}, {
|
|
279
446
|
F: __dxlog_file,
|
|
280
|
-
L:
|
|
447
|
+
L: 97,
|
|
281
448
|
S: void 0,
|
|
282
449
|
C: (f, a) => f(...a)
|
|
283
450
|
});
|
|
284
|
-
state.plugins = (0,
|
|
285
|
-
state.ready = true;
|
|
451
|
+
state.values.plugins = (0, import_react3.shallow)(plugins);
|
|
452
|
+
state.values.ready = true;
|
|
286
453
|
});
|
|
287
454
|
return () => {
|
|
288
455
|
clearTimeout(timeout);
|
|
289
|
-
state.ready = false;
|
|
290
|
-
void Promise.all(definitions.map((definition) => definition.unload?.()));
|
|
456
|
+
state.values.ready = false;
|
|
291
457
|
};
|
|
292
458
|
}, []);
|
|
293
|
-
if (!state.ready) {
|
|
294
|
-
|
|
295
|
-
const FallbackComponent = fallback;
|
|
296
|
-
return /* @__PURE__ */ import_react6.default.createElement(FallbackComponent, {
|
|
297
|
-
initializing: state.initializing,
|
|
298
|
-
loading: state.loading,
|
|
299
|
-
plugins: state.plugins
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, fallback ?? null);
|
|
459
|
+
if (!state.values.ready) {
|
|
460
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, fallback);
|
|
303
461
|
}
|
|
304
|
-
const ComposedContext = composeContext(state.plugins);
|
|
305
|
-
return /* @__PURE__ */
|
|
462
|
+
const ComposedContext = composeContext(state.values.plugins);
|
|
463
|
+
return /* @__PURE__ */ import_react4.default.createElement(ComposedContext, null, rootComponents(state.values.plugins));
|
|
306
464
|
}
|
|
307
465
|
}
|
|
308
466
|
};
|
|
@@ -321,7 +479,7 @@ var rootComponents = (plugins) => {
|
|
|
321
479
|
return plugins.map((plugin) => {
|
|
322
480
|
const Component2 = plugin.provides.root;
|
|
323
481
|
if (Component2) {
|
|
324
|
-
return /* @__PURE__ */
|
|
482
|
+
return /* @__PURE__ */ import_react4.default.createElement(Component2, {
|
|
325
483
|
key: plugin.meta.id
|
|
326
484
|
});
|
|
327
485
|
} else {
|
|
@@ -335,12 +493,15 @@ var composeContext = (plugins) => {
|
|
|
335
493
|
var compose = (contexts) => {
|
|
336
494
|
return [
|
|
337
495
|
...contexts
|
|
338
|
-
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */
|
|
496
|
+
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react4.default.createElement(Acc, null, /* @__PURE__ */ import_react4.default.createElement(Next, null, children)));
|
|
339
497
|
};
|
|
340
498
|
|
|
499
|
+
// packages/sdk/app-framework/src/plugins/SurfacePlugin/index.ts
|
|
500
|
+
init_provides2();
|
|
501
|
+
|
|
341
502
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
|
|
342
|
-
var
|
|
343
|
-
var ErrorBoundary = class extends
|
|
503
|
+
var import_react5 = __toESM(require("react"));
|
|
504
|
+
var ErrorBoundary = class extends import_react5.Component {
|
|
344
505
|
constructor(props) {
|
|
345
506
|
super(props);
|
|
346
507
|
this.state = {
|
|
@@ -359,7 +520,7 @@ var ErrorBoundary = class extends import_react7.Component {
|
|
|
359
520
|
}
|
|
360
521
|
render() {
|
|
361
522
|
if (this.state.error) {
|
|
362
|
-
return /* @__PURE__ */
|
|
523
|
+
return /* @__PURE__ */ import_react5.default.createElement(this.props.fallback, {
|
|
363
524
|
error: this.state.error,
|
|
364
525
|
reset: this.resetError
|
|
365
526
|
});
|
|
@@ -374,18 +535,9 @@ var ErrorBoundary = class extends import_react7.Component {
|
|
|
374
535
|
};
|
|
375
536
|
|
|
376
537
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
|
|
377
|
-
var
|
|
378
|
-
var import_react10 = require("react");
|
|
379
|
-
|
|
380
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
|
|
538
|
+
var import_react7 = __toESM(require("react"));
|
|
381
539
|
var import_react8 = require("react");
|
|
382
|
-
|
|
383
|
-
components: {}
|
|
384
|
-
});
|
|
385
|
-
var useSurface = () => (0, import_react8.useContext)(SurfaceRootContext);
|
|
386
|
-
var SurfaceProvider = SurfaceRootContext.Provider;
|
|
387
|
-
|
|
388
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
|
|
540
|
+
init_SurfaceRootContext();
|
|
389
541
|
var Surface = ({ role, name = role, fallback, ...rest }) => {
|
|
390
542
|
const props = {
|
|
391
543
|
role,
|
|
@@ -393,17 +545,17 @@ var Surface = ({ role, name = role, fallback, ...rest }) => {
|
|
|
393
545
|
fallback,
|
|
394
546
|
...rest
|
|
395
547
|
};
|
|
396
|
-
const context = (0,
|
|
548
|
+
const context = (0, import_react8.useContext)(SurfaceContext);
|
|
397
549
|
const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
|
|
398
|
-
return /* @__PURE__ */
|
|
550
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, fallback ? /* @__PURE__ */ import_react7.default.createElement(ErrorBoundary, {
|
|
399
551
|
data,
|
|
400
552
|
fallback
|
|
401
|
-
}, /* @__PURE__ */
|
|
553
|
+
}, /* @__PURE__ */ import_react7.default.createElement(SurfaceResolver, props)) : /* @__PURE__ */ import_react7.default.createElement(SurfaceResolver, props));
|
|
402
554
|
};
|
|
403
|
-
var SurfaceContext = /* @__PURE__ */ (0,
|
|
555
|
+
var SurfaceContext = /* @__PURE__ */ (0, import_react8.createContext)(null);
|
|
404
556
|
var SurfaceResolver = (props) => {
|
|
405
557
|
const { components } = useSurface();
|
|
406
|
-
const parent = (0,
|
|
558
|
+
const parent = (0, import_react8.useContext)(SurfaceContext);
|
|
407
559
|
const nodes = resolveNodes(components, props, parent);
|
|
408
560
|
const currentContext = {
|
|
409
561
|
...props,
|
|
@@ -412,9 +564,9 @@ var SurfaceResolver = (props) => {
|
|
|
412
564
|
...props.surfaces
|
|
413
565
|
}
|
|
414
566
|
};
|
|
415
|
-
return /* @__PURE__ */
|
|
567
|
+
return /* @__PURE__ */ import_react7.default.createElement(SurfaceContext.Provider, {
|
|
416
568
|
value: currentContext
|
|
417
|
-
}, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */
|
|
569
|
+
}, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ import_react7.default.createElement(props.contentFallback, null) : null);
|
|
418
570
|
};
|
|
419
571
|
var resolveNodes = (components, props, context) => {
|
|
420
572
|
const data = {
|
|
@@ -423,60 +575,44 @@ var resolveNodes = (components, props, context) => {
|
|
|
423
575
|
};
|
|
424
576
|
const nodes = Object.entries(components).map(([key, component]) => {
|
|
425
577
|
const result = component(data, props.role);
|
|
426
|
-
return result ? /* @__PURE__ */
|
|
578
|
+
return result ? /* @__PURE__ */ import_react7.default.createElement(import_react7.Fragment, {
|
|
427
579
|
key
|
|
428
580
|
}, result) : void 0;
|
|
429
581
|
}).filter((Component2) => Boolean(Component2));
|
|
430
582
|
return props.limit ? nodes.slice(0, props.limit) : nodes;
|
|
431
583
|
};
|
|
432
|
-
var Wrapper = ({ children }) => /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, children);
|
|
433
584
|
|
|
434
|
-
// packages/sdk/app-framework/src/plugins/SurfacePlugin/
|
|
435
|
-
|
|
436
|
-
var import_react12 = __toESM(require("react"));
|
|
437
|
-
var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
|
|
438
|
-
var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
|
|
439
|
-
var SurfacePlugin = () => {
|
|
440
|
-
const state = (0, import_react11.deepSignal)({
|
|
441
|
-
components: {}
|
|
442
|
-
});
|
|
443
|
-
return {
|
|
444
|
-
meta: {
|
|
445
|
-
id: "dxos.org/plugin/surface"
|
|
446
|
-
},
|
|
447
|
-
ready: async (plugins) => {
|
|
448
|
-
state.components = (0, import_react11.shallow)(filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
|
|
449
|
-
return {
|
|
450
|
-
...acc,
|
|
451
|
-
[plugin.meta.id]: plugin.provides.surface.component
|
|
452
|
-
};
|
|
453
|
-
}, {}));
|
|
454
|
-
},
|
|
455
|
-
provides: {
|
|
456
|
-
surface: state,
|
|
457
|
-
context: ({ children }) => /* @__PURE__ */ import_react12.default.createElement(SurfaceProvider, {
|
|
458
|
-
value: state
|
|
459
|
-
}, children)
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
};
|
|
585
|
+
// packages/sdk/app-framework/src/plugins/SurfacePlugin/index.ts
|
|
586
|
+
init_SurfaceRootContext();
|
|
463
587
|
|
|
464
588
|
// packages/sdk/app-framework/src/App.tsx
|
|
465
589
|
var import_react13 = __toESM(require("react"));
|
|
466
590
|
var import_invariant = require("@dxos/invariant");
|
|
591
|
+
init_meta();
|
|
592
|
+
init_meta2();
|
|
467
593
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
|
|
468
|
-
var createApp = ({ plugins,
|
|
594
|
+
var createApp = ({ order, plugins, core = [], ...params }) => {
|
|
469
595
|
const host = PluginHost({
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
...
|
|
596
|
+
order: [
|
|
597
|
+
meta_default2,
|
|
598
|
+
meta_default,
|
|
599
|
+
...order
|
|
474
600
|
],
|
|
475
|
-
|
|
601
|
+
plugins: {
|
|
602
|
+
...plugins,
|
|
603
|
+
[meta_default2.id]: Plugin.lazy(() => Promise.resolve().then(() => (init_plugin(), plugin_exports))),
|
|
604
|
+
[meta_default.id]: Plugin.lazy(() => Promise.resolve().then(() => (init_plugin2(), plugin_exports2)))
|
|
605
|
+
},
|
|
606
|
+
core: [
|
|
607
|
+
meta_default2.id,
|
|
608
|
+
meta_default.id,
|
|
609
|
+
...core
|
|
610
|
+
],
|
|
611
|
+
...params
|
|
476
612
|
});
|
|
477
613
|
(0, import_invariant.invariant)(host.provides?.context, void 0, {
|
|
478
614
|
F: __dxlog_file2,
|
|
479
|
-
L:
|
|
615
|
+
L: 51,
|
|
480
616
|
S: void 0,
|
|
481
617
|
A: [
|
|
482
618
|
"host.provides?.context",
|
|
@@ -485,7 +621,7 @@ var createApp = ({ plugins, fallback }) => {
|
|
|
485
621
|
});
|
|
486
622
|
(0, import_invariant.invariant)(host.provides?.root, void 0, {
|
|
487
623
|
F: __dxlog_file2,
|
|
488
|
-
L:
|
|
624
|
+
L: 52,
|
|
489
625
|
S: void 0,
|
|
490
626
|
A: [
|
|
491
627
|
"host.provides?.root",
|
|
@@ -499,17 +635,16 @@ var createApp = ({ plugins, fallback }) => {
|
|
|
499
635
|
// Annotate the CommonJS export names for ESM import in node:
|
|
500
636
|
0 && (module.exports = {
|
|
501
637
|
ErrorBoundary,
|
|
502
|
-
IntentPlugin,
|
|
503
638
|
IntentProvider,
|
|
504
639
|
Layout,
|
|
505
640
|
LayoutAction,
|
|
641
|
+
Plugin,
|
|
506
642
|
PluginHost,
|
|
507
643
|
PluginProvider,
|
|
508
644
|
Resource,
|
|
509
645
|
ResourceKey,
|
|
510
646
|
ResourceLanguage,
|
|
511
647
|
Surface,
|
|
512
|
-
SurfacePlugin,
|
|
513
648
|
SurfaceProvider,
|
|
514
649
|
createApp,
|
|
515
650
|
filterPlugins,
|
|
@@ -527,6 +662,7 @@ var createApp = ({ plugins, fallback }) => {
|
|
|
527
662
|
parseRootSurfacePlugin,
|
|
528
663
|
parseSurfacePlugin,
|
|
529
664
|
parseTranslationsPlugin,
|
|
665
|
+
pluginMeta,
|
|
530
666
|
resolvePlugin,
|
|
531
667
|
useIntent,
|
|
532
668
|
usePlugin,
|