@dxos/app-framework 0.8.4-main.c85a9c8dae → 0.8.4-main.d05673bc65
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/{capability-2GL5JAGJ.mjs → capability-6YMUBS54.mjs} +7 -7
- package/dist/lib/browser/{capability-7RLVE42K.mjs → capability-LF3OXSCV.mjs} +8 -8
- package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-272IPLHQ.mjs} +1 -1
- package/dist/lib/browser/{chunk-PKQT6C53.mjs.map → chunk-272IPLHQ.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-HE27PNNQ.mjs → chunk-2UI6ACB5.mjs} +3 -3
- package/dist/lib/browser/{chunk-FNKT2QQ2.mjs → chunk-7M4467QR.mjs} +2 -2
- package/dist/lib/browser/{chunk-FNKT2QQ2.mjs.map → chunk-7M4467QR.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-ZRWBPIZG.mjs → chunk-JGWCBVKJ.mjs} +2 -2
- package/dist/lib/browser/chunk-M5IC326L.mjs +34 -0
- package/dist/lib/browser/{chunk-NPUEVX42.mjs.map → chunk-M5IC326L.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-4CTRO67U.mjs → chunk-NQPYE365.mjs} +8 -8
- package/dist/lib/browser/{chunk-4CTRO67U.mjs.map → chunk-NQPYE365.mjs.map} +1 -1
- package/dist/lib/browser/chunk-TGX63LTL.mjs +8 -0
- package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-TGX63LTL.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs → chunk-TIEBZMTF.mjs} +3 -3
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs.map → chunk-TIEBZMTF.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-REORGDJT.mjs → chunk-WEBSGU5L.mjs} +15 -15
- package/dist/lib/browser/{chunk-REORGDJT.mjs.map → chunk-WEBSGU5L.mjs.map} +1 -1
- package/dist/lib/browser/cli/index.mjs +8 -8
- package/dist/lib/browser/cli/index.mjs.map +1 -1
- package/dist/lib/browser/common/activation-events.mjs +4 -4
- package/dist/lib/browser/common/capabilities.mjs +4 -4
- package/dist/lib/browser/core/activation-event.mjs +1 -1
- package/dist/lib/browser/core/plugin-manager.mjs +3 -3
- package/dist/lib/browser/core/plugin.mjs +1 -1
- package/dist/lib/browser/index.mjs +13 -13
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/{invoker-capability-BNLVNYHU.mjs → invoker-capability-4AUGUMM5.mjs} +7 -7
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +12 -12
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/browser/ui/index.mjs +8 -8
- package/dist/lib/node-esm/{capability-CHIMU6LX.mjs → capability-R5O2OYX4.mjs} +7 -7
- package/dist/lib/node-esm/{capability-EVZK4REM.mjs → capability-SA6LPYGL.mjs} +8 -8
- package/dist/lib/node-esm/{chunk-2A4PRBIX.mjs → chunk-3D66SZHP.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs → chunk-6REV5DE7.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs.map → chunk-6REV5DE7.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-7CPNAEGV.mjs → chunk-FHWPWQRJ.mjs} +8 -8
- package/dist/lib/node-esm/{chunk-7CPNAEGV.mjs.map → chunk-FHWPWQRJ.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-FKE4Z3D6.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-FKE4Z3D6.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-CJCQS2YL.mjs → chunk-JHFY3HTS.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-CJCQS2YL.mjs.map → chunk-JHFY3HTS.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-DTCHT2X2.mjs → chunk-JIVXIJ2T.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-JAZVHID3.mjs → chunk-NHXBSAQR.mjs} +8 -8
- package/dist/lib/node-esm/{chunk-JAZVHID3.mjs.map → chunk-NHXBSAQR.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs → chunk-SCDGIGGU.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs.map → chunk-SCDGIGGU.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-UFW652GS.mjs → chunk-SQICGJBW.mjs} +15 -15
- package/dist/lib/node-esm/{chunk-UFW652GS.mjs.map → chunk-SQICGJBW.mjs.map} +1 -1
- package/dist/lib/node-esm/cli/index.mjs +8 -8
- package/dist/lib/node-esm/cli/index.mjs.map +1 -1
- package/dist/lib/node-esm/common/activation-events.mjs +4 -4
- package/dist/lib/node-esm/common/capabilities.mjs +4 -4
- package/dist/lib/node-esm/core/activation-event.mjs +1 -1
- package/dist/lib/node-esm/core/plugin-manager.mjs +3 -3
- package/dist/lib/node-esm/core/plugin.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +13 -13
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/{invoker-capability-VF6SP44V.mjs → invoker-capability-3YDIVDWV.mjs} +7 -7
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +12 -12
- package/dist/lib/node-esm/testing/index.mjs.map +1 -1
- package/dist/lib/node-esm/ui/index.mjs +8 -8
- package/dist/types/src/common/operations.d.ts +1 -1
- package/dist/types/src/core/activation-event.d.ts +1 -1
- package/dist/types/src/core/plugin.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/cli/cli.ts +2 -2
- package/src/common/activation-events.ts +6 -6
- package/src/common/capabilities.ts +14 -14
- package/src/common/operations.ts +2 -2
- package/src/context.ts +1 -1
- package/src/core/activation-event.ts +1 -1
- package/src/core/plugin-manager.test.ts +22 -22
- package/src/core/plugin.ts +2 -2
- package/src/plugin-operation/meta.ts +1 -1
- package/src/plugin-runtime/meta.ts +1 -1
- package/src/testing/service.ts +2 -2
- package/src/testing/withPluginManager.tsx +2 -2
- package/src/ui/components/App/App.stories.tsx +2 -2
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +4 -4
- package/src/ui/hooks/useApp.tsx +3 -3
- package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
- package/dist/lib/browser/chunk-NPUEVX42.mjs +0 -34
- /package/dist/lib/browser/{capability-2GL5JAGJ.mjs.map → capability-6YMUBS54.mjs.map} +0 -0
- /package/dist/lib/browser/{capability-7RLVE42K.mjs.map → capability-LF3OXSCV.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-HE27PNNQ.mjs.map → chunk-2UI6ACB5.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-ZRWBPIZG.mjs.map → chunk-JGWCBVKJ.mjs.map} +0 -0
- /package/dist/lib/browser/{invoker-capability-BNLVNYHU.mjs.map → invoker-capability-4AUGUMM5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{capability-CHIMU6LX.mjs.map → capability-R5O2OYX4.mjs.map} +0 -0
- /package/dist/lib/node-esm/{capability-EVZK4REM.mjs.map → capability-SA6LPYGL.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-2A4PRBIX.mjs.map → chunk-3D66SZHP.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-DTCHT2X2.mjs.map → chunk-JIVXIJ2T.mjs.map} +0 -0
- /package/dist/lib/node-esm/{invoker-capability-VF6SP44V.mjs.map → invoker-capability-3YDIVDWV.mjs.map} +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-TIEBZMTF.mjs";
|
|
2
2
|
import {
|
|
3
3
|
capabilities_exports
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WEBSGU5L.mjs";
|
|
5
5
|
import {
|
|
6
6
|
activation_events_exports
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-M5IC326L.mjs";
|
|
8
8
|
import "./chunk-YAFEA4GV.mjs";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-2UI6ACB5.mjs";
|
|
10
|
+
import "./chunk-272IPLHQ.mjs";
|
|
11
11
|
import {
|
|
12
12
|
plugin_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7M4467QR.mjs";
|
|
14
14
|
import {
|
|
15
15
|
capability_exports
|
|
16
16
|
} from "./chunk-YNFPIQGB.mjs";
|
|
@@ -34,4 +34,4 @@ var capability_default = capability_exports.makeModule(Effect.fnUntraced(functio
|
|
|
34
34
|
export {
|
|
35
35
|
capability_default as default
|
|
36
36
|
};
|
|
37
|
-
//# sourceMappingURL=capability-
|
|
37
|
+
//# sourceMappingURL=capability-6YMUBS54.mjs.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
make,
|
|
3
3
|
make2
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-JGWCBVKJ.mjs";
|
|
5
|
+
import "./chunk-TIEBZMTF.mjs";
|
|
6
6
|
import {
|
|
7
7
|
capabilities_exports
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-WEBSGU5L.mjs";
|
|
9
|
+
import "./chunk-M5IC326L.mjs";
|
|
10
10
|
import "./chunk-YAFEA4GV.mjs";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-2UI6ACB5.mjs";
|
|
12
|
+
import "./chunk-272IPLHQ.mjs";
|
|
13
|
+
import "./chunk-7M4467QR.mjs";
|
|
14
14
|
import {
|
|
15
15
|
capability_exports
|
|
16
16
|
} from "./chunk-YNFPIQGB.mjs";
|
|
@@ -31,4 +31,4 @@ var capability_default = capability_exports.makeModule(Effect.fnUntraced(functio
|
|
|
31
31
|
export {
|
|
32
32
|
capability_default as default
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=capability-
|
|
34
|
+
//# sourceMappingURL=capability-LF3OXSCV.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/activation-event.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * A unique string identifier representing an event.\n * This is expected to be a URI, where initial parts are often the id of the plugin whose package defines the event.\n *\n * @example dxos.
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * A unique string identifier representing an event.\n * This is expected to be a URI, where initial parts are often the id of the plugin whose package defines the event.\n *\n * @example org.dxos.plugin.example.event.ready\n */\nexport type ActivationEvent = {\n id: string;\n specifier?: string;\n};\n\n/**\n * An activation event that can be a single event, or a combination of events.\n */\nexport type Events =\n | ActivationEvent\n | { type: 'one-of'; events: ActivationEvent[] }\n | { type: 'all-of'; events: ActivationEvent[] };\n\n/**\n * Helper to define an activation event.\n */\nexport const make = (id: string, specifier?: string) => {\n return { id, specifier } as ActivationEvent;\n};\n\n/**\n * Helper to create an activation event key.\n */\nexport const eventKey = (event: ActivationEvent) => (event.specifier ? `${event.id}:${event.specifier}` : event.id);\n\n/**\n * Helper to create an activation event that triggers when any of the given events are activated.\n */\nexport const oneOf = (...events: ActivationEvent[]) => ({ type: 'one-of' as const, events });\n\n/**\n * Helper to create an activation event that triggers when all of the given events are activated.\n */\nexport const allOf = (...events: ActivationEvent[]) => ({ type: 'all-of' as const, events });\n\n/**\n * Helper to check if an activation event is a one-of event.\n */\nexport const isOneOf = (events: Events): events is { type: 'one-of'; events: ActivationEvent[] } =>\n 'type' in events && events.type === 'one-of';\n\n/**\n * Helper to check if an activation event is an all-of event.\n */\nexport const isAllOf = (events: Events): events is { type: 'all-of'; events: ActivationEvent[] } =>\n 'type' in events && events.type === 'all-of';\n\n/**\n * Helper to get the events from an activation event.\n */\nexport const getEvents = (events: Events) => ('type' in events ? events.events : [events]);\n"],
|
|
5
5
|
"mappings": ";;;;;AAAA;;;;;;;;;;AA0BO,IAAMA,OAAO,CAACC,IAAYC,cAAAA;AAC/B,SAAO;IAAED;IAAIC;EAAU;AACzB;AAKO,IAAMC,WAAW,CAACC,UAA4BA,MAAMF,YAAY,GAAGE,MAAMH,EAAE,IAAIG,MAAMF,SAAS,KAAKE,MAAMH;AAKzG,IAAMI,QAAQ,IAAIC,YAA+B;EAAEC,MAAM;EAAmBD;AAAO;AAKnF,IAAME,QAAQ,IAAIF,YAA+B;EAAEC,MAAM;EAAmBD;AAAO;AAKnF,IAAMG,UAAU,CAACH,WACtB,UAAUA,UAAUA,OAAOC,SAAS;AAK/B,IAAMG,UAAU,CAACJ,WACtB,UAAUA,UAAUA,OAAOC,SAAS;AAK/B,IAAMI,YAAY,CAACL,WAAoB,UAAUA,SAASA,OAAOA,SAAS;EAACA;;",
|
|
6
6
|
"names": ["make", "id", "specifier", "eventKey", "event", "oneOf", "events", "type", "allOf", "isOneOf", "isAllOf", "getEvents"]
|
|
7
7
|
}
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
eventKey,
|
|
3
3
|
getEvents,
|
|
4
4
|
isAllOf
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-272IPLHQ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
Service as Service2
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7M4467QR.mjs";
|
|
9
9
|
import {
|
|
10
10
|
Service
|
|
11
11
|
} from "./chunk-YNFPIQGB.mjs";
|
|
@@ -821,4 +821,4 @@ export {
|
|
|
821
821
|
make5 as make,
|
|
822
822
|
plugin_manager_exports
|
|
823
823
|
};
|
|
824
|
-
//# sourceMappingURL=chunk-
|
|
824
|
+
//# sourceMappingURL=chunk-2UI6ACB5.mjs.map
|
|
@@ -30,7 +30,7 @@ var Service = class extends Context.Tag("@dxos/app-framework/PluginManager")() {
|
|
|
30
30
|
var activate = (event) => Effect.flatMap(Service, (manager) => manager.activate(event));
|
|
31
31
|
var reset = (event) => Effect.flatMap(Service, (manager) => manager.reset(event));
|
|
32
32
|
var computeModuleId = (pluginId, moduleName) => {
|
|
33
|
-
return `${pluginId}
|
|
33
|
+
return `${pluginId}.module.${moduleName}`;
|
|
34
34
|
};
|
|
35
35
|
var PluginModuleTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/PluginModule");
|
|
36
36
|
var isPluginModule = (value) => {
|
|
@@ -142,4 +142,4 @@ export {
|
|
|
142
142
|
make,
|
|
143
143
|
plugin_exports
|
|
144
144
|
};
|
|
145
|
-
//# sourceMappingURL=chunk-
|
|
145
|
+
//# sourceMappingURL=chunk-7M4467QR.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/plugin.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\n\nimport { invariant } from '@dxos/invariant';\n\nimport type * as ActivationEvent from './activation-event';\nimport * as Capability from './capability';\nimport type * as PluginManager from './plugin-manager';\n\n//\n// Plugin Service Layer\n//\n\n/**\n * Effect Context.Tag for accessing PluginManager via the Effect layer system.\n * This allows lifecycle operations to access the plugin manager without having it passed as an argument.\n */\nexport class Service extends Context.Tag('@dxos/app-framework/PluginManager')<Service, PluginManager.PluginManager>() {}\n\n//\n// Lifecycle Functions\n//\n\n/**\n * Activates plugins based on the activation event.\n * Accesses the PluginManager via the Effect layer system.\n * @param event The activation event.\n * @returns Whether the activation was successful.\n */\nexport const activate = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.activate(event));\n\n/**\n * Re-activates the modules that were activated by the event.\n * Accesses the PluginManager via the Effect layer system.\n * @param event The activation event.\n * @returns Whether the reset was successful.\n */\nexport const reset = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.reset(event));\n\n/**\n * Computes a module ID from plugin ID and export name.\n */\nconst computeModuleId = (pluginId: string, moduleName: string): string => {\n return `${pluginId}/module/${moduleName}`;\n};\n\n/**\n * Identifier denoting a PluginModule.\n */\nexport const PluginModuleTypeId: unique symbol = Symbol.for('@dxos/app-framework/PluginModule');\nexport type PluginModuleTypeId = typeof PluginModuleTypeId;\n\n/**\n * Type guard to check if a value is a PluginModule.\n */\nexport const isPluginModule = (value: unknown): value is PluginModule => {\n return typeof value === 'object' && value !== null && PluginModuleTypeId in value;\n};\n\n/**\n * A unit of containment of modular functionality that can be provided to an application.\n * Activation of a module is async allowing for code to split and loaded lazily.\n */\nexport interface PluginModule {\n readonly [PluginModuleTypeId]: PluginModuleTypeId;\n /**\n * Unique id of the module.\n */\n id: string;\n\n /**\n * Events for which the module will be activated.\n */\n activatesOn: ActivationEvent.Events;\n\n /**\n * Events which the plugin depends on being activated.\n * Plugin is marked as needing reset a plugin activated by a dependent event is removed.\n * Events are automatically activated before activation of the plugin.\n */\n activatesBefore?: ActivationEvent.ActivationEvent[];\n\n /**\n * Events which this plugin triggers upon activation.\n */\n activatesAfter?: ActivationEvent.ActivationEvent[];\n\n /**\n * Called when the module is activated.\n * CapabilityManager is accessed via the Effect layer system (Capability.Service).\n * PluginManager is accessed via Plugin.Service.\n * @param props Optional props passed to the module.\n * @returns The capabilities of the module.\n */\n activate: (props?: any) => Effect.Effect<Capability.ModuleReturn, Error, Capability.Service | Service | never>;\n}\n\nexport type PluginModuleOptions = Omit<PluginModule, 'id' | typeof PluginModuleTypeId> & { id?: string };\n\nclass PluginModuleImpl implements PluginModule {\n readonly [PluginModuleTypeId]: PluginModuleTypeId = PluginModuleTypeId;\n readonly id: PluginModule['id'];\n readonly activatesOn: PluginModule['activatesOn'];\n readonly activatesBefore?: PluginModule['activatesBefore'];\n readonly activatesAfter?: PluginModule['activatesAfter'];\n readonly activate: PluginModule['activate'];\n\n constructor(options: Omit<PluginModule, typeof PluginModuleTypeId>) {\n this.id = options.id;\n this.activatesOn = options.activatesOn;\n this.activatesBefore = options.activatesBefore;\n this.activatesAfter = options.activatesAfter;\n this.activate = options.activate;\n }\n}\n\nexport type Meta = {\n /**\n * Globally unique ID.\n *\n * Expected to be in the form of a valid URL.\n *\n * @example dxos.org/plugin/example\n */\n id: string;\n\n /**\n * Human-readable name.\n */\n name: string;\n\n /**\n * Short description of plugin functionality.\n */\n description?: string;\n\n /**\n * URL of home page.\n */\n homePage?: string;\n\n /**\n * URL of source code.\n */\n source?: string;\n\n /**\n * URL of screenshot.\n */\n screenshots?: string[];\n\n /**\n * Tags to help categorize the plugin.\n */\n tags?: string[];\n\n /**\n * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.\n */\n icon?: string;\n\n /**\n * Icon hue (ChromaticPalette).\n */\n iconHue?: string;\n};\n\n/**\n * Identifier denoting a Plugin.\n */\nexport const PluginTypeId: unique symbol = Symbol.for('@dxos/app-framework/Plugin');\nexport type PluginTypeId = typeof PluginTypeId;\n\n/**\n * Type guard to check if a value is a Plugin.\n */\nexport const isPlugin = (value: unknown): value is Plugin => {\n return typeof value === 'object' && value !== null && PluginTypeId in value;\n};\n\n/**\n * A collection of modules that are be enabled/disabled as a unit.\n * Plugins provide things such as components, state, actions, etc. to the application.\n */\n// TODO(burdon): Convert to ECHO schema.\nexport interface Plugin {\n readonly [PluginTypeId]: PluginTypeId;\n readonly meta: Readonly<Meta>;\n readonly modules: ReadonlyArray<PluginModule>;\n}\n\n/**\n * Internal implementation of Plugin.\n * @internal\n */\nclass PluginImpl implements Plugin {\n readonly [PluginTypeId]: PluginTypeId = PluginTypeId;\n\n constructor(\n private readonly _meta: Meta,\n private readonly _modules: PluginModule[],\n ) {}\n\n get meta(): Readonly<Meta> {\n return this._meta;\n }\n\n get modules(): ReadonlyArray<PluginModule> {\n return this._modules;\n }\n}\n\n/**\n * Builder interface for creating plugins incrementally.\n */\nexport interface PluginBuilder<T = void> extends Pipeable.Pipeable {\n readonly meta: Meta;\n readonly modules: ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)>;\n addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T>;\n}\n\n/**\n * Builder implementation for creating plugins incrementally.\n */\nclass PluginBuilderImpl<T = void> implements PluginBuilder<T> {\n readonly meta: Meta;\n private readonly _modules: Array<PluginModuleOptions | ((options: T) => PluginModuleOptions)> = [];\n\n constructor(meta: Meta) {\n this.meta = meta;\n }\n\n get modules(): ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)> {\n return this._modules;\n }\n\n addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T> {\n this._modules.push(moduleOptions);\n return this;\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Creates a new PluginBuilder to start building a plugin.\n */\nexport const define = <T = void>(meta: Meta): PluginBuilder<T> => new PluginBuilderImpl<T>(meta);\n\n/**\n * Adds a module to a plugin builder.\n * Supports both pipeline and direct call styles.\n * Modules can be either PluginModuleOptions or functions that receive options.\n */\nexport function addModule<T>(\n moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): (builder: PluginBuilder<T>) => PluginBuilder<T>;\nexport function addModule<T>(\n builder: PluginBuilder<T>,\n moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): PluginBuilder<T>;\nexport function addModule<T>(\n moduleOptionsOrBuilder: PluginModuleOptions | ((options: T) => PluginModuleOptions) | PluginBuilder<T>,\n moduleOptions?: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): ((builder: PluginBuilder<T>) => PluginBuilder<T>) | PluginBuilder<T> {\n // If second arg is provided, it's the direct call style: addModule(builder, moduleOptions)\n if (moduleOptions !== undefined) {\n return (moduleOptionsOrBuilder as PluginBuilder<T>).addModule(moduleOptions);\n }\n // Otherwise it's pipeline style: addModule(moduleOptions) returns a function\n const moduleOpts = moduleOptionsOrBuilder as PluginModuleOptions | ((options: T) => PluginModuleOptions);\n return (builder: PluginBuilder<T>) => builder.addModule(moduleOpts);\n}\n\nexport type PluginFactory<T = void> = ((options: T) => Plugin) & { meta: Meta };\n\n/**\n * Resolves a module from either PluginModuleOptions or a function that returns PluginModuleOptions.\n */\nconst resolveModule = (\n meta: Meta,\n module: PluginModuleOptions | ((options: any) => PluginModuleOptions),\n options?: any,\n): PluginModuleImpl => {\n const moduleOptions = typeof module === 'function' ? module(options) : module;\n const id = Option.fromNullable(moduleOptions.id).pipe(\n Option.match({\n onNone: () => {\n const exportName = Capability.getModuleTag(moduleOptions.activate);\n invariant(exportName, `Plugin module missing name. Plugin: ${meta.id}`);\n return computeModuleId(meta.id, exportName);\n },\n onSome: (id) => computeModuleId(meta.id, id),\n }),\n );\n return new PluginModuleImpl({ ...moduleOptions, id });\n};\n\n/**\n * Creates a Plugin from a builder.\n * Supports both pipeline and direct call styles.\n * Always returns a factory function (options: T) => Plugin.\n * When T is void, the function takes no arguments: () => Plugin.\n */\nexport function make<T>(builder: PluginBuilder<T>): PluginFactory<T>;\nexport function make<T>(builder: PluginBuilder<T>): PluginFactory<T> {\n const meta = builder.meta;\n\n const factory = (options: T) => {\n const modules = builder.modules.map((module) => resolveModule(meta, module, options));\n return new PluginImpl(meta, modules);\n };\n\n return Object.assign(factory, { meta });\n}\n"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\n\nimport { invariant } from '@dxos/invariant';\n\nimport type * as ActivationEvent from './activation-event';\nimport * as Capability from './capability';\nimport type * as PluginManager from './plugin-manager';\n\n//\n// Plugin Service Layer\n//\n\n/**\n * Effect Context.Tag for accessing PluginManager via the Effect layer system.\n * This allows lifecycle operations to access the plugin manager without having it passed as an argument.\n */\nexport class Service extends Context.Tag('@dxos/app-framework/PluginManager')<Service, PluginManager.PluginManager>() {}\n\n//\n// Lifecycle Functions\n//\n\n/**\n * Activates plugins based on the activation event.\n * Accesses the PluginManager via the Effect layer system.\n * @param event The activation event.\n * @returns Whether the activation was successful.\n */\nexport const activate = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.activate(event));\n\n/**\n * Re-activates the modules that were activated by the event.\n * Accesses the PluginManager via the Effect layer system.\n * @param event The activation event.\n * @returns Whether the reset was successful.\n */\nexport const reset = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.reset(event));\n\n/**\n * Computes a module ID from plugin ID and export name.\n */\nconst computeModuleId = (pluginId: string, moduleName: string): string => {\n return `${pluginId}.module.${moduleName}`;\n};\n\n/**\n * Identifier denoting a PluginModule.\n */\nexport const PluginModuleTypeId: unique symbol = Symbol.for('@dxos/app-framework/PluginModule');\nexport type PluginModuleTypeId = typeof PluginModuleTypeId;\n\n/**\n * Type guard to check if a value is a PluginModule.\n */\nexport const isPluginModule = (value: unknown): value is PluginModule => {\n return typeof value === 'object' && value !== null && PluginModuleTypeId in value;\n};\n\n/**\n * A unit of containment of modular functionality that can be provided to an application.\n * Activation of a module is async allowing for code to split and loaded lazily.\n */\nexport interface PluginModule {\n readonly [PluginModuleTypeId]: PluginModuleTypeId;\n /**\n * Unique id of the module.\n */\n id: string;\n\n /**\n * Events for which the module will be activated.\n */\n activatesOn: ActivationEvent.Events;\n\n /**\n * Events which the plugin depends on being activated.\n * Plugin is marked as needing reset a plugin activated by a dependent event is removed.\n * Events are automatically activated before activation of the plugin.\n */\n activatesBefore?: ActivationEvent.ActivationEvent[];\n\n /**\n * Events which this plugin triggers upon activation.\n */\n activatesAfter?: ActivationEvent.ActivationEvent[];\n\n /**\n * Called when the module is activated.\n * CapabilityManager is accessed via the Effect layer system (Capability.Service).\n * PluginManager is accessed via Plugin.Service.\n * @param props Optional props passed to the module.\n * @returns The capabilities of the module.\n */\n activate: (props?: any) => Effect.Effect<Capability.ModuleReturn, Error, Capability.Service | Service | never>;\n}\n\nexport type PluginModuleOptions = Omit<PluginModule, 'id' | typeof PluginModuleTypeId> & { id?: string };\n\nclass PluginModuleImpl implements PluginModule {\n readonly [PluginModuleTypeId]: PluginModuleTypeId = PluginModuleTypeId;\n readonly id: PluginModule['id'];\n readonly activatesOn: PluginModule['activatesOn'];\n readonly activatesBefore?: PluginModule['activatesBefore'];\n readonly activatesAfter?: PluginModule['activatesAfter'];\n readonly activate: PluginModule['activate'];\n\n constructor(options: Omit<PluginModule, typeof PluginModuleTypeId>) {\n this.id = options.id;\n this.activatesOn = options.activatesOn;\n this.activatesBefore = options.activatesBefore;\n this.activatesAfter = options.activatesAfter;\n this.activate = options.activate;\n }\n}\n\nexport type Meta = {\n /**\n * Globally unique ID.\n *\n * Expected to be in the form of a valid URL.\n *\n * @example org.dxos.plugin.example\n */\n id: string;\n\n /**\n * Human-readable name.\n */\n name: string;\n\n /**\n * Short description of plugin functionality.\n */\n description?: string;\n\n /**\n * URL of home page.\n */\n homePage?: string;\n\n /**\n * URL of source code.\n */\n source?: string;\n\n /**\n * URL of screenshot.\n */\n screenshots?: string[];\n\n /**\n * Tags to help categorize the plugin.\n */\n tags?: string[];\n\n /**\n * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.\n */\n icon?: string;\n\n /**\n * Icon hue (ChromaticPalette).\n */\n iconHue?: string;\n};\n\n/**\n * Identifier denoting a Plugin.\n */\nexport const PluginTypeId: unique symbol = Symbol.for('@dxos/app-framework/Plugin');\nexport type PluginTypeId = typeof PluginTypeId;\n\n/**\n * Type guard to check if a value is a Plugin.\n */\nexport const isPlugin = (value: unknown): value is Plugin => {\n return typeof value === 'object' && value !== null && PluginTypeId in value;\n};\n\n/**\n * A collection of modules that are be enabled/disabled as a unit.\n * Plugins provide things such as components, state, actions, etc. to the application.\n */\n// TODO(burdon): Convert to ECHO schema.\nexport interface Plugin {\n readonly [PluginTypeId]: PluginTypeId;\n readonly meta: Readonly<Meta>;\n readonly modules: ReadonlyArray<PluginModule>;\n}\n\n/**\n * Internal implementation of Plugin.\n * @internal\n */\nclass PluginImpl implements Plugin {\n readonly [PluginTypeId]: PluginTypeId = PluginTypeId;\n\n constructor(\n private readonly _meta: Meta,\n private readonly _modules: PluginModule[],\n ) {}\n\n get meta(): Readonly<Meta> {\n return this._meta;\n }\n\n get modules(): ReadonlyArray<PluginModule> {\n return this._modules;\n }\n}\n\n/**\n * Builder interface for creating plugins incrementally.\n */\nexport interface PluginBuilder<T = void> extends Pipeable.Pipeable {\n readonly meta: Meta;\n readonly modules: ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)>;\n addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T>;\n}\n\n/**\n * Builder implementation for creating plugins incrementally.\n */\nclass PluginBuilderImpl<T = void> implements PluginBuilder<T> {\n readonly meta: Meta;\n private readonly _modules: Array<PluginModuleOptions | ((options: T) => PluginModuleOptions)> = [];\n\n constructor(meta: Meta) {\n this.meta = meta;\n }\n\n get modules(): ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)> {\n return this._modules;\n }\n\n addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T> {\n this._modules.push(moduleOptions);\n return this;\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Creates a new PluginBuilder to start building a plugin.\n */\nexport const define = <T = void>(meta: Meta): PluginBuilder<T> => new PluginBuilderImpl<T>(meta);\n\n/**\n * Adds a module to a plugin builder.\n * Supports both pipeline and direct call styles.\n * Modules can be either PluginModuleOptions or functions that receive options.\n */\nexport function addModule<T>(\n moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): (builder: PluginBuilder<T>) => PluginBuilder<T>;\nexport function addModule<T>(\n builder: PluginBuilder<T>,\n moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): PluginBuilder<T>;\nexport function addModule<T>(\n moduleOptionsOrBuilder: PluginModuleOptions | ((options: T) => PluginModuleOptions) | PluginBuilder<T>,\n moduleOptions?: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): ((builder: PluginBuilder<T>) => PluginBuilder<T>) | PluginBuilder<T> {\n // If second arg is provided, it's the direct call style: addModule(builder, moduleOptions)\n if (moduleOptions !== undefined) {\n return (moduleOptionsOrBuilder as PluginBuilder<T>).addModule(moduleOptions);\n }\n // Otherwise it's pipeline style: addModule(moduleOptions) returns a function\n const moduleOpts = moduleOptionsOrBuilder as PluginModuleOptions | ((options: T) => PluginModuleOptions);\n return (builder: PluginBuilder<T>) => builder.addModule(moduleOpts);\n}\n\nexport type PluginFactory<T = void> = ((options: T) => Plugin) & { meta: Meta };\n\n/**\n * Resolves a module from either PluginModuleOptions or a function that returns PluginModuleOptions.\n */\nconst resolveModule = (\n meta: Meta,\n module: PluginModuleOptions | ((options: any) => PluginModuleOptions),\n options?: any,\n): PluginModuleImpl => {\n const moduleOptions = typeof module === 'function' ? module(options) : module;\n const id = Option.fromNullable(moduleOptions.id).pipe(\n Option.match({\n onNone: () => {\n const exportName = Capability.getModuleTag(moduleOptions.activate);\n invariant(exportName, `Plugin module missing name. Plugin: ${meta.id}`);\n return computeModuleId(meta.id, exportName);\n },\n onSome: (id) => computeModuleId(meta.id, id),\n }),\n );\n return new PluginModuleImpl({ ...moduleOptions, id });\n};\n\n/**\n * Creates a Plugin from a builder.\n * Supports both pipeline and direct call styles.\n * Always returns a factory function (options: T) => Plugin.\n * When T is void, the function takes no arguments: () => Plugin.\n */\nexport function make<T>(builder: PluginBuilder<T>): PluginFactory<T>;\nexport function make<T>(builder: PluginBuilder<T>): PluginFactory<T> {\n const meta = builder.meta;\n\n const factory = (options: T) => {\n const modules = builder.modules.map((module) => resolveModule(meta, module, options));\n return new PluginImpl(meta, modules);\n };\n\n return Object.assign(factory, { meta });\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;AAAA;;;;;;;;;;;;;AAIA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAE1B,SAASC,iBAAiB;;AAcnB,IAAMC,UAAN,cAA8BC,YAAI,mCAAA,EAAA,EAAA;AAA8E;AAYhH,IAAMC,WAAW,CAACC,UAChBC,eAAQJ,SAAS,CAACK,YAAYA,QAAQH,SAASC,KAAAA,CAAAA;AAQjD,IAAMG,QAAQ,CAACH,UACbC,eAAQJ,SAAS,CAACK,YAAYA,QAAQC,MAAMH,KAAAA,CAAAA;AAKrD,IAAMI,kBAAkB,CAACC,UAAkBC,eAAAA;AACzC,SAAO,GAAGD,QAAAA,WAAmBC,UAAAA;AAC/B;AAKO,IAAMC,qBAAoCC,uBAAOC,IAAI,kCAAA;AAMrD,IAAMC,iBAAiB,CAACC,UAAAA;AAC7B,SAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQJ,sBAAsBI;AAC9E;AA0CA,IAAMC,mBAAN,MAAMA;EACK,CAACL,kBAAAA,IAA0CA;EAC3CM;EACAC;EACAC;EACAC;EACAjB;EAET,YAAYkB,SAAwD;AAClE,SAAKJ,KAAKI,QAAQJ;AAClB,SAAKC,cAAcG,QAAQH;AAC3B,SAAKC,kBAAkBE,QAAQF;AAC/B,SAAKC,iBAAiBC,QAAQD;AAC9B,SAAK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KAAKV,IAAI6B,UAAAA;IAClC;IACAG,QAAQ,CAAChC,QAAOT,gBAAgBmB,KAAKV,IAAIA,GAAAA;EAC3C,CAAA,CAAA;AAEF,SAAO,IAAID,iBAAiB;IAAE,GAAGe;IAAed;EAAG,CAAA;AACrD;AASO,SAASiC,KAAQV,SAAyB;AAC/C,QAAMb,OAAOa,QAAQb;AAErB,QAAMwB,UAAU,CAAC9B,YAAAA;AACf,UAAMO,UAAUY,QAAQZ,QAAQwB,IAAI,CAACV,WAAWD,cAAcd,MAAMe,QAAQrB,OAAAA,CAAAA;AAC5E,WAAO,IAAIG,WAAWG,MAAMC,OAAAA;EAC9B;AAEA,SAAOyB,OAAOC,OAAOH,SAAS;IAAExB;EAAK,CAAA;AACvC;",
|
|
6
6
|
"names": ["Context", "Effect", "Option", "Pipeable", "invariant", "Service", "Tag", "activate", "event", "flatMap", "manager", "reset", "computeModuleId", "pluginId", "moduleName", "PluginModuleTypeId", "Symbol", "for", "isPluginModule", "value", "PluginModuleImpl", "id", "activatesOn", "activatesBefore", "activatesAfter", "options", "PluginTypeId", "isPlugin", "PluginImpl", "_meta", "_modules", "meta", "modules", "PluginBuilderImpl", "addModule", "moduleOptions", "push", "pipe", "pipeArguments", "arguments", "define", "moduleOptionsOrBuilder", "undefined", "moduleOpts", "builder", "resolveModule", "module", "fromNullable", "match", "onNone", "exportName", "getModuleTag", "invariant", "onSome", "make", "factory", "map", "Object", "assign"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UndoOperation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TIEBZMTF.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
6
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -167,4 +167,4 @@ export {
|
|
|
167
167
|
make3 as make2,
|
|
168
168
|
history_tracker_exports
|
|
169
169
|
};
|
|
170
|
-
//# sourceMappingURL=chunk-
|
|
170
|
+
//# sourceMappingURL=chunk-JGWCBVKJ.mjs.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activation_event_exports
|
|
3
|
+
} from "./chunk-272IPLHQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/common/activation-events.ts
|
|
9
|
+
var activation_events_exports = {};
|
|
10
|
+
__export(activation_events_exports, {
|
|
11
|
+
ManagedRuntimeReady: () => ManagedRuntimeReady,
|
|
12
|
+
OperationInvokerReady: () => OperationInvokerReady,
|
|
13
|
+
SetupLayer: () => SetupLayer,
|
|
14
|
+
SetupOperationResolver: () => SetupOperationResolver,
|
|
15
|
+
SetupReactSurface: () => SetupReactSurface,
|
|
16
|
+
Startup: () => Startup
|
|
17
|
+
});
|
|
18
|
+
var Startup = activation_event_exports.make("org.dxos.app-framework.event.startup");
|
|
19
|
+
var SetupReactSurface = activation_event_exports.make("org.dxos.app-framework.event.setup-react-surface");
|
|
20
|
+
var SetupOperationResolver = activation_event_exports.make("org.dxos.app-framework.event.setup-operation-resolver");
|
|
21
|
+
var SetupLayer = activation_event_exports.make("org.dxos.app-framework.event.setup-layer");
|
|
22
|
+
var OperationInvokerReady = activation_event_exports.make("org.dxos.app-framework.event.operation-invoker-ready");
|
|
23
|
+
var ManagedRuntimeReady = activation_event_exports.make("org.dxos.app-framework.event.managed-runtime-ready");
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
Startup,
|
|
27
|
+
SetupReactSurface,
|
|
28
|
+
SetupOperationResolver,
|
|
29
|
+
SetupLayer,
|
|
30
|
+
OperationInvokerReady,
|
|
31
|
+
ManagedRuntimeReady,
|
|
32
|
+
activation_events_exports
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=chunk-M5IC326L.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/common/activation-events.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { ActivationEvent as ActivationEvent$ } from '../core';\n\n/**\n * Fired when the app is started.\n */\nexport const Startup = ActivationEvent$.make('dxos.
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { ActivationEvent as ActivationEvent$ } from '../core';\n\n/**\n * Fired when the app is started.\n */\nexport const Startup = ActivationEvent$.make('org.dxos.app-framework.event.startup');\n\n//\n// Dependent Events\n//\n\n/**\n * Fired to load any newly available surfaces.\n */\nexport const SetupReactSurface = ActivationEvent$.make('org.dxos.app-framework.event.setup-react-surface');\n\n/**\n * Fired before the operation invoker is activated.\n */\nexport const SetupOperationResolver = ActivationEvent$.make('org.dxos.app-framework.event.setup-operation-resolver');\n\n/**\n * Fired before the managed runtime is created.\n * Plugins should contribute their Layer capabilities before this event.\n */\nexport const SetupLayer = ActivationEvent$.make('org.dxos.app-framework.event.setup-layer');\n\n//\n// Triggered Events\n//\n\n/**\n * Fired after the operation invoker is ready.\n */\nexport const OperationInvokerReady = ActivationEvent$.make('org.dxos.app-framework.event.operation-invoker-ready');\n\n/**\n * Fired after the managed runtime is ready.\n */\nexport const ManagedRuntimeReady = ActivationEvent$.make('org.dxos.app-framework.event.managed-runtime-ready');\n"],
|
|
5
5
|
"mappings": ";;;;;;;;AAAA;;;;;;;;;AASO,IAAMA,UAAUC,yBAAiBC,KAAK,sCAAA;AAStC,IAAMC,oBAAoBF,yBAAiBC,KAAK,kDAAA;AAKhD,IAAME,yBAAyBH,yBAAiBC,KAAK,uDAAA;AAMrD,IAAMG,aAAaJ,yBAAiBC,KAAK,0CAAA;AASzC,IAAMI,wBAAwBL,yBAAiBC,KAAK,sDAAA;AAKpD,IAAMK,sBAAsBN,yBAAiBC,KAAK,oDAAA;",
|
|
6
6
|
"names": ["Startup", "ActivationEvent$", "make", "SetupReactSurface", "SetupOperationResolver", "SetupLayer", "OperationInvokerReady", "ManagedRuntimeReady"]
|
|
7
7
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PluginManagerContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TGX63LTL.mjs";
|
|
4
4
|
import {
|
|
5
5
|
capabilities_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WEBSGU5L.mjs";
|
|
7
7
|
import {
|
|
8
8
|
activation_events_exports
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-M5IC326L.mjs";
|
|
10
10
|
import {
|
|
11
11
|
plugin_manager_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-2UI6ACB5.mjs";
|
|
13
13
|
|
|
14
14
|
// src/ui/components/App/App.tsx
|
|
15
15
|
import React2 from "react";
|
|
@@ -59,7 +59,7 @@ import { ErrorBoundary, ErrorFallback } from "@dxos/react-error-boundary";
|
|
|
59
59
|
import { useAsyncEffect, useDefaultValue } from "@dxos/react-hooks";
|
|
60
60
|
import { ContextProtocolProvider } from "@dxos/web-context-react";
|
|
61
61
|
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/ui/hooks/useApp.tsx";
|
|
62
|
-
var ENABLED_KEY = "dxos.
|
|
62
|
+
var ENABLED_KEY = "org.dxos.app-framework.enabled";
|
|
63
63
|
var useApp = ({ pluginManager, pluginLoader: pluginLoaderProp, plugins: pluginsProp, core: coreProp, defaults: defaultsProp, setupEvents: setupEventsProp, placeholder, fallback = ErrorFallback, cacheEnabled = false, safeMode = false, debounce = 0, timeout = 3e4 }) => {
|
|
64
64
|
const plugins = useDefaultValue(pluginsProp, () => []);
|
|
65
65
|
const core = useDefaultValue(coreProp, () => plugins.map(({ meta }) => meta.id));
|
|
@@ -124,12 +124,12 @@ var useApp = ({ pluginManager, pluginLoader: pluginLoaderProp, plugins: pluginsP
|
|
|
124
124
|
manager.capabilities.contribute({
|
|
125
125
|
interface: capabilities_exports.PluginManager,
|
|
126
126
|
implementation: manager,
|
|
127
|
-
module: "dxos.
|
|
127
|
+
module: "org.dxos.app-framework.plugin-manager"
|
|
128
128
|
});
|
|
129
129
|
manager.capabilities.contribute({
|
|
130
130
|
interface: capabilities_exports.AtomRegistry,
|
|
131
131
|
implementation: manager.registry,
|
|
132
|
-
module: "dxos.
|
|
132
|
+
module: "org.dxos.app-framework.atom-registry"
|
|
133
133
|
});
|
|
134
134
|
const fiber = Effect.gen(function* () {
|
|
135
135
|
const queue = yield* PubSub.subscribe(manager.activation);
|
|
@@ -700,4 +700,4 @@ export {
|
|
|
700
700
|
PluginManagerProvider,
|
|
701
701
|
Surface
|
|
702
702
|
};
|
|
703
|
-
//# sourceMappingURL=chunk-
|
|
703
|
+
//# sourceMappingURL=chunk-NQPYE365.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ui/components/App/App.tsx", "../../../src/helpers.ts", "../../../src/ui/hooks/useApp.tsx", "../../../src/ui/hooks/useCapabilities.ts", "../../../src/ui/hooks/useLoading.tsx", "../../../src/ui/hooks/useOperationResolver.ts", "../../../src/ui/hooks/useSettingsState.ts", "../../../src/ui/hooks/useSurface.ts", "../../../src/ui/components/PluginManager/PluginManagerProvider.ts", "../../../src/ui/components/Surface/context.ts", "../../../src/ui/components/Surface/SurfaceComponent.tsx", "../../../src/ui/components/Surface/SurfaceInfo.tsx", "../../../src/ui/components/Surface/types.ts", "../../../src/ui/components/Surface/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Capabilities } from '../../../common';\nimport { topologicalSort } from '../../../helpers';\nimport { LoadingState, type UseAppOptions, useCapabilities, useLoading } from '../../hooks';\n\nexport type AppProps = Pick<UseAppOptions, 'placeholder' | 'debounce'> & {\n ready: boolean;\n error: unknown;\n};\n\nexport const App = ({ placeholder: Placeholder, ready, error, debounce }: AppProps) => {\n const reactContexts = useCapabilities(Capabilities.ReactContext);\n const reactRoots = useCapabilities(Capabilities.ReactRoot);\n const stage = useLoading(ready, debounce);\n\n if (error) {\n // This triggers the error boundary to provide UI feedback for the startup error.\n throw error;\n }\n\n // TODO(wittjosiah): Consider using Suspense instead.\n if (stage < LoadingState.Done) {\n if (!Placeholder) {\n return null;\n }\n\n return <Placeholder stage={stage} />;\n }\n\n const ComposedContext = composeContexts(reactContexts);\n return (\n <ComposedContext>\n {reactRoots.map(({ id, root: Component }) => (\n <Component key={id} />\n ))}\n </ComposedContext>\n );\n};\n\nconst composeContexts = (contexts: Capabilities.ReactContext[]) => {\n if (contexts.length === 0) {\n return ({ children }: PropsWithChildren) => <>{children}</>;\n }\n\n return topologicalSort(contexts)\n .map(({ context }) => context)\n .reduce((Acc, Next) => ({ children }) => (\n <Acc>\n <Next>{children}</Next>\n </Acc>\n ));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\ntype DependencyNode = {\n id: string;\n dependsOn?: string[];\n};\n\n/**\n * Topologically sorts a list of nodes based on their dependencies.\n */\n// TODO(wittjosiah): Factor out?\nexport const topologicalSort = <T extends DependencyNode>(nodes: T[]): T[] => {\n const getDependencies = (nodeId: string, seen = new Set<string>(), path = new Set<string>()): string[] => {\n if (path.has(nodeId)) {\n throw new Error(`Circular dependency detected involving ${nodeId}`);\n }\n if (seen.has(nodeId)) {\n return [];\n }\n\n const node = nodes.find((n) => n.id === nodeId);\n if (!node) {\n throw new Error(`Node ${nodeId} not found but is listed as a dependency`);\n }\n\n const newPath = new Set([...path, nodeId]);\n const newSeen = new Set([...seen, nodeId]);\n\n const dependsOn = node.dependsOn ?? [];\n return [...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)), nodeId];\n };\n\n // Get all unique dependencies.\n const allDependencies = nodes\n .map((node) => node.id)\n .flatMap((id) => getDependencies(id))\n .filter((id, index, self) => self.indexOf(id) === index);\n\n // Map back to original nodes\n return allDependencies\n .map((id) => nodes.find((node) => node.id === id))\n .filter((node): node is T => node !== undefined);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as PubSub from 'effect/PubSub';\nimport * as Queue from 'effect/Queue';\nimport React, { type FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { ErrorBoundary, ErrorFallback, type FallbackProps } from '@dxos/react-error-boundary';\nimport { useAsyncEffect, useDefaultValue } from '@dxos/react-hooks';\nimport { ContextProtocolProvider } from '@dxos/web-context-react';\n\nimport { ActivationEvents, Capabilities } from '../../common';\nimport { PluginManagerContext } from '../../context';\nimport { type ActivationEvent, type Plugin, PluginManager } from '../../core';\nimport { App, PluginManagerProvider } from '../components';\n\nconst ENABLED_KEY = 'dxos.org/app-framework/enabled';\n\nexport type UseAppOptions = {\n pluginManager?: PluginManager.PluginManager;\n pluginLoader?: PluginManager.ManagerOptions['pluginLoader'];\n plugins?: Plugin.Plugin[];\n core?: string[];\n defaults?: string[];\n /**\n * Additional activation events to fire before startup.\n * These are fired alongside SetupReactSurface before the Startup event.\n */\n setupEvents?: ActivationEvent.ActivationEvent[];\n cacheEnabled?: boolean;\n safeMode?: boolean;\n debounce?: number;\n timeout?: number;\n fallback?: FC<FallbackProps>;\n placeholder?: FC<{ stage: number }>;\n};\n\n/**\n * Expected usage is for this to be the entrypoint of the application.\n * Initializes plugins and renders the root components.\n *\n * @example\n * const plugins = [LayoutPlugin(), MyPlugin()];\n * const core = [LayoutPluginId];\n * const default = [MyPluginId];\n * const fallback = <div>Initializing Plugins...</div>;\n * const App = useApp({ plugins, core, default, fallback });\n * createRoot(document.getElementById('root')!).render(\n * <StrictMode>\n * <App />\n * </StrictMode>,\n * );\n *\n * @param params.pluginLoader A function which loads new plugins.\n * @param params.plugins All plugins available to the application.\n * @param params.core Core plugins which will always be enabled.\n * @param params.defaults Default plugins are enabled by default but can be disabled by the user.\n * @param params.cacheEnabled Whether to cache enabled plugins in localStorage.\n * @param params.safeMode Whether to enable safe mode, which disables optional plugins.\n * @param params.fallback Fallback component to render if an error occurs during startup.\n * @param params.placeholder Placeholder component to render during startup.\n */\nexport const useApp = ({\n pluginManager,\n pluginLoader: pluginLoaderProp,\n plugins: pluginsProp,\n core: coreProp,\n defaults: defaultsProp,\n setupEvents: setupEventsProp,\n placeholder,\n fallback = ErrorFallback,\n cacheEnabled = false,\n safeMode = false,\n debounce = 0,\n timeout = 30_000,\n}: UseAppOptions) => {\n const plugins = useDefaultValue(pluginsProp, () => []);\n const core = useDefaultValue(coreProp, () => plugins.map(({ meta }) => meta.id));\n const defaults = useDefaultValue(defaultsProp, () => []);\n const setupEvents = useDefaultValue(setupEventsProp, () => []);\n\n // TODO(wittjosiah): Provide a custom plugin loader which supports loading via url.\n const pluginLoader = useMemo(\n () =>\n pluginLoaderProp ??\n ((id: string) =>\n Effect.sync(() => {\n const plugin = plugins.find((plugin) => plugin.meta.id === id);\n invariant(plugin, `Plugin not found: ${id}`);\n return plugin;\n })),\n [pluginLoaderProp, plugins],\n );\n\n const readyRef = useRef(false);\n const [ready, setReady] = useState(false);\n const errorRef = useRef<unknown>(null);\n const [error, setError] = useState<unknown>(null);\n // TODO(wittjosiah): Migrate to Atom.kvs for isomorphic storage.\n const cached: string[] = useMemo(() => JSON.parse(localStorage.getItem(ENABLED_KEY) ?? '[]'), []);\n const enabled = useMemo(\n () => (safeMode ? [] : cacheEnabled && cached.length > 0 ? cached : defaults),\n [safeMode, cacheEnabled, cached, defaults],\n );\n const manager = useMemo(\n () => pluginManager ?? PluginManager.make({ pluginLoader, plugins, core, enabled }),\n [pluginManager, pluginLoader, plugins, core, enabled],\n );\n\n useEffect(() => {\n if (!cacheEnabled) {\n return;\n }\n return manager.registry.subscribe(manager.enabled, (value) => {\n localStorage.setItem(ENABLED_KEY, JSON.stringify(value));\n });\n }, [cacheEnabled, manager]);\n\n useEffect(() => {\n setupDevtools(manager);\n }, [manager]);\n\n useAsyncEffect(async () => {\n manager.capabilities.contribute({\n interface: Capabilities.PluginManager,\n implementation: manager,\n module: 'dxos.org/app-framework/plugin-manager',\n });\n\n manager.capabilities.contribute({\n interface: Capabilities.AtomRegistry,\n implementation: manager.registry,\n module: 'dxos.org/app-framework/atom-registry',\n });\n\n const fiber = Effect.gen(function* () {\n const queue = yield* PubSub.subscribe(manager.activation);\n const listener = yield* Effect.forkDaemon(\n Queue.take(queue).pipe(\n Effect.tap(({ event, state, error: error$ }) =>\n Effect.sync(() => {\n if (event === ActivationEvents.Startup.id && state === 'activated') {\n clearTimeout(timeoutId);\n setReady(true);\n readyRef.current = true;\n }\n if (error$ && !readyRef.current) {\n setError(error$);\n errorRef.current = error$;\n }\n }),\n ),\n Effect.forever,\n ),\n );\n\n yield* Effect.all([\n ...setupEvents.map((event) => manager.activate(event)),\n manager.activate(ActivationEvents.SetupReactSurface),\n manager.activate(ActivationEvents.Startup),\n ]);\n\n return yield* Fiber.join(listener);\n }).pipe(Effect.scoped, Effect.runFork);\n\n // Set up a timeout for startup.\n const timeoutId = setTimeout(() => {\n if (!readyRef.current && !errorRef.current) {\n log.warn('startup timeout diagnostic', {\n eventsFired: manager.getEventsFired(),\n activeModules: manager.getActive(),\n pendingReset: manager.getPendingReset(),\n });\n void runAndForwardErrors(Fiber.interrupt(fiber));\n setError(new Error(`Startup timed out after ${timeout}ms`));\n }\n }, timeout);\n\n return () => {\n clearTimeout(timeoutId);\n void runAndForwardErrors(Fiber.interrupt(fiber));\n manager.capabilities.remove(Capabilities.PluginManager, manager);\n manager.capabilities.remove(Capabilities.AtomRegistry, manager.registry);\n };\n }, [manager]);\n\n return useCallback(\n () => (\n <ErrorBoundary name='app' FallbackComponent={fallback}>\n <PluginManagerProvider value={manager}>\n <ContextProtocolProvider value={manager} context={PluginManagerContext}>\n <RegistryContext.Provider value={manager.registry}>\n <App placeholder={placeholder} ready={ready} error={error} debounce={debounce} />\n </RegistryContext.Provider>\n </ContextProtocolProvider>\n </PluginManagerProvider>\n </ErrorBoundary>\n ),\n [fallback, manager, placeholder, ready, error],\n );\n};\n\nconst setupDevtools = (manager: PluginManager.PluginManager) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.manager = manager;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, useAtomValue } from '@effect-atom/atom-react';\nimport { useCallback } from 'react';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { Capabilities } from '../../common';\nimport { type Capability } from '../../core';\nimport { usePluginManager } from '../components';\n\n/**\n * Hook to request capabilities from the plugin context.\n * @returns An array of capabilities.\n */\nexport const useCapabilities = <T>(interfaceDef: Capability.InterfaceDef<T>) => {\n const manager = usePluginManager();\n return useAtomValue(manager.capabilities.atom(interfaceDef));\n};\n\n/**\n * Hook to request a capability from the plugin context.\n * @returns The capability.\n * @throws If no capability is found.\n */\nexport const useCapability = <T>(interfaceDef: Capability.InterfaceDef<T>) => {\n const capabilities = useCapabilities(interfaceDef);\n invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`);\n return capabilities[0];\n};\n\n/**\n * Hook to get the current value of an atom capability.\n * Automatically subscribes to changes.\n * @example const settings = useAtomCapability(ThreadCapabilities.Settings);\n */\nexport const useAtomCapability = <T>(atomCapability: Capability.InterfaceDef<Atom.Atom<T>>): T => {\n const atom = useCapability(atomCapability);\n return useAtomValue(atom);\n};\n\n/**\n * Hook to get value and updater for an atom capability.\n * Returns [currentValue, updateFn] similar to useState.\n * @example const [settings, updateSettings] = useAtomCapabilityState(ThreadCapabilities.Settings);\n */\nexport const useAtomCapabilityState = <T>(\n atomCapability: Capability.InterfaceDef<Atom.Writable<T>>,\n): [T, (fn: (current: T) => T) => void] => {\n const registry = useCapability(Capabilities.AtomRegistry);\n const atom = useCapability(atomCapability);\n const value = useAtomValue(atom);\n const update = useCallback(\n (fn: (current: T) => T) => {\n registry.set(atom, fn(registry.get(atom)));\n },\n [registry, atom],\n );\n return [value, update];\n};\n\n/**\n * Hook to get the operation invoker capability.\n */\nexport const useOperationInvoker = (): Capabilities.OperationInvoker => useCapability(Capabilities.OperationInvoker);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nexport enum LoadingState {\n Loading = 0,\n FadeIn = 1,\n FadeOut = 2,\n Done = 3,\n}\n\n/**\n * To avoid \"flashing\" the placeholder, we wait a period of time before starting the loading animation.\n * If loading completes during this time the placehoder is not shown, otherwise is it displayed for a minimum period of time.\n *\n * States:\n * 0: Loading - Wait for a period of time before starting the loading animation.\n * 1: Fade-in - Display a loading animation.\n * 2: Fade-out - Fade out the loading animation.\n * 3: Done - Remove the placeholder.\n */\nexport const useLoading = (ready: boolean, debounce = 0) => {\n const [stage, setStage] = useState<LoadingState>(LoadingState.Loading);\n useEffect(() => {\n if (!debounce) {\n return;\n }\n\n const i = setInterval(() => {\n setStage((stage) => {\n switch (stage) {\n case LoadingState.Loading: {\n if (!ready) {\n return LoadingState.FadeIn;\n } else {\n clearInterval(i);\n return LoadingState.Done;\n }\n }\n\n case LoadingState.FadeIn: {\n if (ready) {\n return LoadingState.FadeOut;\n }\n break;\n }\n\n case LoadingState.FadeOut: {\n clearInterval(i);\n return LoadingState.Done;\n }\n }\n\n return stage;\n });\n }, debounce);\n\n return () => clearInterval(i);\n }, [debounce]);\n\n if (!debounce) {\n return ready ? LoadingState.Done : LoadingState.Loading;\n }\n\n return stage;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useMemo } from 'react';\n\nimport { Capabilities } from '../../common';\nimport { usePluginManager } from '../components';\n\n/**\n * Hook to dynamically register an operation resolver (handler) within a React component.\n * The resolver is added when the component mounts and removed when it unmounts.\n *\n * @example\n * ```tsx\n * const scrollHandler = useMemo(() => OperationResolver.make({\n * operation: LayoutOperation.ScrollIntoView,\n * handler: (input) => Effect.sync(() => {\n * // Handle scroll\n * }),\n * }), [deps]);\n *\n * useOperationResolver(meta.id, scrollHandler);\n * ```\n */\nexport const useOperationResolver = (module: string, resolver: Capabilities.OperationResolver) => {\n const manager = usePluginManager();\n // Wrap single resolver in array as the capability expects an array.\n const resolverArray = useMemo(() => [resolver], [resolver]);\n\n useEffect(() => {\n manager.capabilities.contribute({\n module,\n interface: Capabilities.OperationResolver,\n implementation: resolverArray,\n });\n\n return () => manager.capabilities.remove(Capabilities.OperationResolver, resolverArray);\n }, [module, resolverArray]);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, RegistryContext, useAtomValue } from '@effect-atom/atom-react';\nimport { useCallback, useContext } from 'react';\n\n/**\n * Hook to read and update a settings atom.\n * Returns the current value and an update function.\n */\nexport const useSettingsState = <T>(\n atom: Atom.Writable<T>,\n): { settings: T; updateSettings: (fn: (current: T) => T) => void } => {\n const registry = useContext(RegistryContext);\n const settings = useAtomValue(atom);\n\n const updateSettings = useCallback(\n (fn: (current: T) => T) => {\n registry.set(atom, fn(registry.get(atom)));\n },\n [registry, atom],\n );\n\n return { settings, updateSettings };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { Surface } from '../components';\n\nexport const useSurface = (): Surface.Context => {\n return useContext(Surface.Context) ?? raise(new Error('Missing SurfaceContext'));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type PluginManager } from '../../../core';\n\nconst PluginManagerContext = createContext<PluginManager.PluginManager | undefined>(undefined);\n\n/**\n * Get the plugin manager.\n */\nexport const usePluginManager = (): PluginManager.PluginManager =>\n useContext(PluginManagerContext) ?? raise(new Error('Missing PluginManagerContext'));\n\n/**\n * Context provider for a plugin manager.\n */\nexport const PluginManagerProvider = PluginManagerContext.Provider;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Props } from './types';\n\nexport type SurfaceContext = Pick<Props, 'id' | 'role' | 'data'>;\n\n// TODO(burdon): Use @radix-ui/react-context\nexport const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, {\n Fragment,\n type NamedExoticComponent,\n type RefAttributes,\n Suspense,\n forwardRef,\n memo,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { log } from '@dxos/log';\nimport { ErrorBoundary } from '@dxos/react-error-boundary';\nimport { useDefaultValue } from '@dxos/react-hooks';\nimport { byPosition } from '@dxos/util';\n\nimport { Capabilities } from '../../../common';\nimport { type CapabilityManager } from '../../../core';\nimport { useCapabilities } from '../../hooks';\n\nimport { SurfaceContext } from './context';\nimport { SurfaceInfo } from './SurfaceInfo';\nimport { type Definition, type Props, type WebComponentDefinition } from './types';\n\nconst DEFAULT_PLACEHOLDER = <Fragment />;\n\nconst DEBUG = import.meta.env.VITE_DEBUG;\n\n/**\n * Wrapper component for rendering Web Component surfaces.\n * Handles creation, prop setting, and cleanup of Web Components.\n */\nconst WebComponentWrapper = memo(\n forwardRef<HTMLElement, Props & { definition: WebComponentDefinition }>(\n ({ id, role, data, limit, definition, ...rest }, forwardedRef) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const elementRef = useRef<HTMLElement | null>(null);\n const propsRef = useRef({ id, role, data, limit, ...rest });\n\n // Update props ref on every render\n propsRef.current = { id, role, data, limit, ...rest };\n\n // Create element only once\n useEffect(() => {\n if (!containerRef.current || elementRef.current) {\n return;\n }\n\n // Create the Web Component\n const element = document.createElement(definition.tagName);\n elementRef.current = element;\n\n // Set initial properties on the Web Component\n Object.assign(element, propsRef.current);\n\n // Append to container\n containerRef.current.appendChild(element);\n\n // Setup ref forwarding if provided\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n\n // Cleanup on unmount to prevent memory leaks\n return () => {\n if (elementRef.current && containerRef.current?.contains(elementRef.current)) {\n containerRef.current.removeChild(elementRef.current);\n }\n if (typeof forwardedRef === 'function') {\n forwardedRef(null);\n } else if (forwardedRef) {\n forwardedRef.current = null;\n }\n elementRef.current = null;\n };\n }, [definition.tagName, forwardedRef]);\n\n // Update props on existing element without recreating it\n // This runs on every render to ensure all props (including those in `rest`) are kept up to date\n useEffect(() => {\n const element = elementRef.current;\n if (!element) {\n return;\n }\n\n // Update properties on the existing Web Component\n Object.assign(element, propsRef.current);\n });\n\n return <div ref={containerRef} />;\n },\n ),\n);\n\nWebComponentWrapper.displayName = 'WebComponentWrapper';\n\n/**\n * Wrapper component that provides context for a surface.\n */\n// TODO(burdon): Allow DebugPlugin to provide different fallback using react-ui ErrorFallback.\nconst SurfaceContextProvider = memo(\n forwardRef<HTMLElement, Props & { definition: Definition }>(\n ({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {\n const contextValue = useMemo(() => ({ id, role, data }), [id, role, data]);\n\n // Handle Web Component surfaces\n if (definition.kind === 'web-component') {\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <SurfaceContext.Provider value={contextValue}>\n <WebComponentWrapper\n id={id}\n role={role}\n data={data}\n limit={limit}\n definition={definition}\n ref={forwardedRef}\n {...rest}\n />\n </SurfaceContext.Provider>\n </ErrorBoundary>\n );\n }\n\n // Handle React component surfaces\n const Component = definition.component;\n\n // TODO(burdon): Remove from production build?\n const debug = DEBUG || '__DX_DEBUG__' in window;\n if (debug) {\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <div role='none' className='contents' data-id={id} data-role={role}>\n <SurfaceContext.Provider value={contextValue}>\n <SurfaceInfo ref={forwardedRef}>\n <Component id={id} role={role} data={data} limit={limit} {...rest} />\n </SurfaceInfo>\n </SurfaceContext.Provider>\n </div>\n </ErrorBoundary>\n );\n }\n\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <div role='none' className='contents' data-id={id} data-role={role}>\n <SurfaceContext.Provider value={contextValue}>\n <Component id={id} role={role} data={data} limit={limit} {...rest} ref={forwardedRef} />\n </SurfaceContext.Provider>\n </div>\n </ErrorBoundary>\n );\n },\n ),\n);\n\nSurfaceContextProvider.displayName = 'SurfaceContextProvider';\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\n// TODO(burdon): Remove `ref` since relying on this would be error prone.\nexport const SurfaceComponent: NamedExoticComponent<Props & RefAttributes<HTMLElement>> = memo(\n forwardRef(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {\n const data = useDefaultValue(dataProp, () => ({}));\n\n // TODO(wittjosiah): This will make all surfaces depend on a single signal.\n // This isn't ideal because it means that any change to the data will cause all surfaces to re-render.\n // This effectively means that plugin modules which contribute surfaces need to all be activated at startup.\n // This should be fine for now because it's how it worked prior to capabilities api anyway.\n // In the future, it would be nice to be able to bucket the surface contributions by role.\n const surfaces = useSurfaces();\n\n // NOTE: Memoizing the candidates makes the surface not re-render based on reactivity within data.\n const definitions = findCandidates(surfaces, { role, data });\n const candidates = limit ? definitions.slice(0, limit) : definitions;\n if (DEBUG && candidates.length === 0) {\n log.warn('no candidates for surface', { role, data });\n return null;\n }\n\n return (\n <Suspense fallback={placeholder}>\n {candidates.map((definition) => (\n <SurfaceContextProvider\n key={definition.id}\n id={definition.id}\n role={role}\n data={data}\n limit={limit}\n definition={definition}\n ref={forwardedRef}\n {...rest}\n />\n ))}\n </Suspense>\n );\n }),\n);\n\nSurfaceComponent.displayName = 'Surface';\n\n// TODO(burdon): Make user facing, with telemetry.\nconst ErrorFallback = ({ error }: Props) => {\n const { message } = error instanceof Error ? error : { message: String(error) };\n return (\n <div role='alert' data-testid='error-boundary-fallback'>\n <h1 className='flex gap-2 text-sm mt-2 text-info-text'>{message}</h1>\n </div>\n );\n};\n\nconst findCandidates = (surfaces: Definition[], { role, data }: Pick<Props, 'role' | 'data'>) => {\n return Object.values(surfaces)\n .filter((definition) =>\n Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,\n )\n .filter(({ filter }) => (filter ? filter(data ?? {}) : true))\n .toSorted(byPosition);\n};\n\n/**\n * @internal\n */\nexport const useSurfaces = () => {\n const surfaces = useCapabilities(Capabilities.ReactSurface);\n return useMemo(() => surfaces.flat(), [surfaces]);\n};\n\n/**\n * @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.\n */\nexport const isSurfaceAvailable = (\n capabilityManager: CapabilityManager.CapabilityManager,\n { role, data }: Pick<Props, 'role' | 'data'>,\n) => {\n const surfaces = capabilityManager.getAll(Capabilities.ReactSurface);\n const candidates = findCandidates(surfaces.flat(), { role, data });\n return candidates.length > 0;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, {\n type ReactElement,\n type Ref,\n cloneElement,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { addEventListener, combine } from '@dxos/async';\nimport { useMergeRefs } from '@dxos/react-hooks';\n\nimport { useSurface } from '../../hooks';\n\nexport type SurfaceInfoProps = {\n children: ReactElement<{ ref?: Ref<HTMLElement> }>;\n};\n\n/**\n * Debug wrapper for surfaces.\n */\nexport const SurfaceInfo = forwardRef<HTMLElement, SurfaceInfoProps>(({ children }, forwardedRef) => {\n const [rect, setRect] = useState<DOMRect | null>(null);\n const [expand, setExpand] = useState(false);\n const info = useSurface();\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n const measureRef = useCallback((node: HTMLElement | null) => setRoot(node), []);\n const mergedRef = useMergeRefs([measureRef, forwardedRef]);\n const childWithRef = cloneElement(children, { ref: mergedRef });\n\n useLayoutEffect(() => {\n if (!root) {\n setRect(null);\n return;\n }\n\n const measure = () => {\n setRect(root.getBoundingClientRect());\n };\n\n const observer = new ResizeObserver(measure);\n observer.observe(root);\n measure();\n\n return combine(\n addEventListener(window, 'scroll', measure, true),\n addEventListener(window, 'resize', measure),\n () => {\n observer.disconnect();\n },\n );\n }, [root]);\n\n const padding = 0;\n return (\n <>\n {childWithRef}\n {rect &&\n createPortal(\n <div\n role='none'\n className='z-[100] fixed flex flex-col-reverse scrollbar-none overflow-auto pointer-events-none'\n style={{\n top: rect.top + padding,\n left: rect.left + padding,\n width: rect.width - padding * 2,\n height: rect.height - padding * 2,\n }}\n >\n {expand ? (\n <div\n className='absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n setExpand(false);\n }}\n >\n <pre className='p-2 text-xs text-description font-mono'>{JSON.stringify({ info }, null, 2)}</pre>\n </div>\n ) : (\n <span\n className='absolute right-1 bottom-0 flex items-center p-1 text-green-500 opacity-80 hover:opacity-100 text-xl cursor-pointer pointer-events-auto'\n title={info.id}\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n setExpand(true);\n }}\n >\n ⓘ\n </span>\n )}\n </div>,\n // TODO(burdon): Create well-known element to gather all debug portals.\n document.body,\n )}\n </>\n );\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { FC, PropsWithChildren, ReactNode, RefCallback } from 'react';\n\nimport type { MakeOptional, Position } from '@dxos/util';\n\n/**\n * Props that are passed to the Surface component.\n */\nexport type Props<T extends Record<string, any> = Record<string, unknown>> = {\n /**\n * If specified, the Surface will be wrapped in an error boundary.\n * The fallback component will be rendered if an error occurs.\n */\n fallback?: FC<{ error: Error; data?: any }>;\n\n /**\n * If specified, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\n} & MakeOptional<CoreProps<T>, 'id' | 'data'> &\n /**\n * Additional props to pass to the component.\n * These props are not used by Surface itself but may be used by components which resolve the surface.\n * Exclude known prop names to prevent overriding well-defined props.\n */\n {\n [K in keyof Record<string, any>]: K extends keyof CoreProps<T> | 'fallback' | 'placeholder' ? never : any;\n };\n\n/**\n * NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.\n */\nexport type CoreProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{\n /**\n * ID for debugging.\n */\n id: string;\n\n /**\n * Role defines how the data should be rendered.\n */\n role: string;\n\n /**\n * The data to be rendered by the surface.\n * NOTE: This must be a stable value.\n */\n data: T;\n\n /**\n * If more than one component is resolved, the limit determines how many are rendered.\n */\n limit?: number | undefined;\n}>;\n\n// TODO(burdon): Remove ref since relying on this would be error prone.\nexport type ComponentProps<T extends Record<string, any> = Record<string, any>> = CoreProps<T> & {\n ref?: RefCallback<HTMLElement>;\n} & Record<string, any>;\n\n/**\n * React component used to render a surface once is has matched.\n */\nexport type ComponentFunction<T extends Record<string, any> = Record<string, any>> = (\n props: ComponentProps<T>,\n) => ReactNode;\n\n/**\n * Definition of when a React component surface should be rendered.\n */\nexport type ReactDefinition<T extends Record<string, any> = any> = Readonly<{\n kind: 'react';\n id: string;\n role: string | string[];\n position?: Position;\n component: ComponentFunction<T>;\n filter?: (data: Record<string, unknown>) => data is T;\n}>;\n\n/**\n * Definition of when a Web Component surface should be rendered.\n */\nexport type WebComponentDefinition<T extends Record<string, any> = any> = Readonly<{\n kind: 'web-component';\n id: string;\n role: string | string[];\n position?: Position;\n /**\n * The tag name of the Web Component to render.\n * The Web Component will receive the same props as React surfaces via properties/attributes.\n */\n tagName: string;\n filter?: (data: Record<string, unknown>) => data is T;\n}>;\n\n/**\n * Definition of when a surface (React or Web Component) should be rendered.\n */\nexport type Definition<T extends Record<string, any> = any> = ReactDefinition<T> | WebComponentDefinition<T>;\n\n/**\n * Creates a React surface definition.\n */\nexport const create = <T extends Record<string, any> = any>(\n definition: Omit<ReactDefinition<T>, 'kind'>,\n): ReactDefinition<T> => ({ ...definition, kind: 'react' });\n\n/**\n * Creates a Web Component surface definition.\n */\nexport const createWeb = <T extends Record<string, any> = any>(\n definition: Omit<WebComponentDefinition<T>, 'kind'>,\n): WebComponentDefinition<T> => ({ ...definition, kind: 'web-component' });\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(wittjosiah): Cleanup to avoid re-naming.\nimport { SurfaceContext } from './context';\nimport { SurfaceComponent, isSurfaceAvailable } from './SurfaceComponent';\nimport { type Definition as SurfaceDefinition, create as createSurface, createWeb as createWebSurface } from './types';\n\nexport namespace Surface {\n export type Definition = SurfaceDefinition;\n export const create = createSurface;\n export const createWeb = createWebSurface;\n\n export type Context = SurfaceContext;\n export const Context = SurfaceContext;\n\n export const Surface = SurfaceComponent;\n export const isAvailable = isSurfaceAvailable;\n}\n"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Capabilities } from '../../../common';\nimport { topologicalSort } from '../../../helpers';\nimport { LoadingState, type UseAppOptions, useCapabilities, useLoading } from '../../hooks';\n\nexport type AppProps = Pick<UseAppOptions, 'placeholder' | 'debounce'> & {\n ready: boolean;\n error: unknown;\n};\n\nexport const App = ({ placeholder: Placeholder, ready, error, debounce }: AppProps) => {\n const reactContexts = useCapabilities(Capabilities.ReactContext);\n const reactRoots = useCapabilities(Capabilities.ReactRoot);\n const stage = useLoading(ready, debounce);\n\n if (error) {\n // This triggers the error boundary to provide UI feedback for the startup error.\n throw error;\n }\n\n // TODO(wittjosiah): Consider using Suspense instead.\n if (stage < LoadingState.Done) {\n if (!Placeholder) {\n return null;\n }\n\n return <Placeholder stage={stage} />;\n }\n\n const ComposedContext = composeContexts(reactContexts);\n return (\n <ComposedContext>\n {reactRoots.map(({ id, root: Component }) => (\n <Component key={id} />\n ))}\n </ComposedContext>\n );\n};\n\nconst composeContexts = (contexts: Capabilities.ReactContext[]) => {\n if (contexts.length === 0) {\n return ({ children }: PropsWithChildren) => <>{children}</>;\n }\n\n return topologicalSort(contexts)\n .map(({ context }) => context)\n .reduce((Acc, Next) => ({ children }) => (\n <Acc>\n <Next>{children}</Next>\n </Acc>\n ));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\ntype DependencyNode = {\n id: string;\n dependsOn?: string[];\n};\n\n/**\n * Topologically sorts a list of nodes based on their dependencies.\n */\n// TODO(wittjosiah): Factor out?\nexport const topologicalSort = <T extends DependencyNode>(nodes: T[]): T[] => {\n const getDependencies = (nodeId: string, seen = new Set<string>(), path = new Set<string>()): string[] => {\n if (path.has(nodeId)) {\n throw new Error(`Circular dependency detected involving ${nodeId}`);\n }\n if (seen.has(nodeId)) {\n return [];\n }\n\n const node = nodes.find((n) => n.id === nodeId);\n if (!node) {\n throw new Error(`Node ${nodeId} not found but is listed as a dependency`);\n }\n\n const newPath = new Set([...path, nodeId]);\n const newSeen = new Set([...seen, nodeId]);\n\n const dependsOn = node.dependsOn ?? [];\n return [...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)), nodeId];\n };\n\n // Get all unique dependencies.\n const allDependencies = nodes\n .map((node) => node.id)\n .flatMap((id) => getDependencies(id))\n .filter((id, index, self) => self.indexOf(id) === index);\n\n // Map back to original nodes\n return allDependencies\n .map((id) => nodes.find((node) => node.id === id))\n .filter((node): node is T => node !== undefined);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as PubSub from 'effect/PubSub';\nimport * as Queue from 'effect/Queue';\nimport React, { type FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { ErrorBoundary, ErrorFallback, type FallbackProps } from '@dxos/react-error-boundary';\nimport { useAsyncEffect, useDefaultValue } from '@dxos/react-hooks';\nimport { ContextProtocolProvider } from '@dxos/web-context-react';\n\nimport { ActivationEvents, Capabilities } from '../../common';\nimport { PluginManagerContext } from '../../context';\nimport { type ActivationEvent, type Plugin, PluginManager } from '../../core';\nimport { App, PluginManagerProvider } from '../components';\n\nconst ENABLED_KEY = 'org.dxos.app-framework.enabled';\n\nexport type UseAppOptions = {\n pluginManager?: PluginManager.PluginManager;\n pluginLoader?: PluginManager.ManagerOptions['pluginLoader'];\n plugins?: Plugin.Plugin[];\n core?: string[];\n defaults?: string[];\n /**\n * Additional activation events to fire before startup.\n * These are fired alongside SetupReactSurface before the Startup event.\n */\n setupEvents?: ActivationEvent.ActivationEvent[];\n cacheEnabled?: boolean;\n safeMode?: boolean;\n debounce?: number;\n timeout?: number;\n fallback?: FC<FallbackProps>;\n placeholder?: FC<{ stage: number }>;\n};\n\n/**\n * Expected usage is for this to be the entrypoint of the application.\n * Initializes plugins and renders the root components.\n *\n * @example\n * const plugins = [LayoutPlugin(), MyPlugin()];\n * const core = [LayoutPluginId];\n * const default = [MyPluginId];\n * const fallback = <div>Initializing Plugins...</div>;\n * const App = useApp({ plugins, core, default, fallback });\n * createRoot(document.getElementById('root')!).render(\n * <StrictMode>\n * <App />\n * </StrictMode>,\n * );\n *\n * @param params.pluginLoader A function which loads new plugins.\n * @param params.plugins All plugins available to the application.\n * @param params.core Core plugins which will always be enabled.\n * @param params.defaults Default plugins are enabled by default but can be disabled by the user.\n * @param params.cacheEnabled Whether to cache enabled plugins in localStorage.\n * @param params.safeMode Whether to enable safe mode, which disables optional plugins.\n * @param params.fallback Fallback component to render if an error occurs during startup.\n * @param params.placeholder Placeholder component to render during startup.\n */\nexport const useApp = ({\n pluginManager,\n pluginLoader: pluginLoaderProp,\n plugins: pluginsProp,\n core: coreProp,\n defaults: defaultsProp,\n setupEvents: setupEventsProp,\n placeholder,\n fallback = ErrorFallback,\n cacheEnabled = false,\n safeMode = false,\n debounce = 0,\n timeout = 30_000,\n}: UseAppOptions) => {\n const plugins = useDefaultValue(pluginsProp, () => []);\n const core = useDefaultValue(coreProp, () => plugins.map(({ meta }) => meta.id));\n const defaults = useDefaultValue(defaultsProp, () => []);\n const setupEvents = useDefaultValue(setupEventsProp, () => []);\n\n // TODO(wittjosiah): Provide a custom plugin loader which supports loading via url.\n const pluginLoader = useMemo(\n () =>\n pluginLoaderProp ??\n ((id: string) =>\n Effect.sync(() => {\n const plugin = plugins.find((plugin) => plugin.meta.id === id);\n invariant(plugin, `Plugin not found: ${id}`);\n return plugin;\n })),\n [pluginLoaderProp, plugins],\n );\n\n const readyRef = useRef(false);\n const [ready, setReady] = useState(false);\n const errorRef = useRef<unknown>(null);\n const [error, setError] = useState<unknown>(null);\n // TODO(wittjosiah): Migrate to Atom.kvs for isomorphic storage.\n const cached: string[] = useMemo(() => JSON.parse(localStorage.getItem(ENABLED_KEY) ?? '[]'), []);\n const enabled = useMemo(\n () => (safeMode ? [] : cacheEnabled && cached.length > 0 ? cached : defaults),\n [safeMode, cacheEnabled, cached, defaults],\n );\n const manager = useMemo(\n () => pluginManager ?? PluginManager.make({ pluginLoader, plugins, core, enabled }),\n [pluginManager, pluginLoader, plugins, core, enabled],\n );\n\n useEffect(() => {\n if (!cacheEnabled) {\n return;\n }\n return manager.registry.subscribe(manager.enabled, (value) => {\n localStorage.setItem(ENABLED_KEY, JSON.stringify(value));\n });\n }, [cacheEnabled, manager]);\n\n useEffect(() => {\n setupDevtools(manager);\n }, [manager]);\n\n useAsyncEffect(async () => {\n manager.capabilities.contribute({\n interface: Capabilities.PluginManager,\n implementation: manager,\n module: 'org.dxos.app-framework.plugin-manager',\n });\n\n manager.capabilities.contribute({\n interface: Capabilities.AtomRegistry,\n implementation: manager.registry,\n module: 'org.dxos.app-framework.atom-registry',\n });\n\n const fiber = Effect.gen(function* () {\n const queue = yield* PubSub.subscribe(manager.activation);\n const listener = yield* Effect.forkDaemon(\n Queue.take(queue).pipe(\n Effect.tap(({ event, state, error: error$ }) =>\n Effect.sync(() => {\n if (event === ActivationEvents.Startup.id && state === 'activated') {\n clearTimeout(timeoutId);\n setReady(true);\n readyRef.current = true;\n }\n if (error$ && !readyRef.current) {\n setError(error$);\n errorRef.current = error$;\n }\n }),\n ),\n Effect.forever,\n ),\n );\n\n yield* Effect.all([\n ...setupEvents.map((event) => manager.activate(event)),\n manager.activate(ActivationEvents.SetupReactSurface),\n manager.activate(ActivationEvents.Startup),\n ]);\n\n return yield* Fiber.join(listener);\n }).pipe(Effect.scoped, Effect.runFork);\n\n // Set up a timeout for startup.\n const timeoutId = setTimeout(() => {\n if (!readyRef.current && !errorRef.current) {\n log.warn('startup timeout diagnostic', {\n eventsFired: manager.getEventsFired(),\n activeModules: manager.getActive(),\n pendingReset: manager.getPendingReset(),\n });\n void runAndForwardErrors(Fiber.interrupt(fiber));\n setError(new Error(`Startup timed out after ${timeout}ms`));\n }\n }, timeout);\n\n return () => {\n clearTimeout(timeoutId);\n void runAndForwardErrors(Fiber.interrupt(fiber));\n manager.capabilities.remove(Capabilities.PluginManager, manager);\n manager.capabilities.remove(Capabilities.AtomRegistry, manager.registry);\n };\n }, [manager]);\n\n return useCallback(\n () => (\n <ErrorBoundary name='app' FallbackComponent={fallback}>\n <PluginManagerProvider value={manager}>\n <ContextProtocolProvider value={manager} context={PluginManagerContext}>\n <RegistryContext.Provider value={manager.registry}>\n <App placeholder={placeholder} ready={ready} error={error} debounce={debounce} />\n </RegistryContext.Provider>\n </ContextProtocolProvider>\n </PluginManagerProvider>\n </ErrorBoundary>\n ),\n [fallback, manager, placeholder, ready, error],\n );\n};\n\nconst setupDevtools = (manager: PluginManager.PluginManager) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.manager = manager;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, useAtomValue } from '@effect-atom/atom-react';\nimport { useCallback } from 'react';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { Capabilities } from '../../common';\nimport { type Capability } from '../../core';\nimport { usePluginManager } from '../components';\n\n/**\n * Hook to request capabilities from the plugin context.\n * @returns An array of capabilities.\n */\nexport const useCapabilities = <T>(interfaceDef: Capability.InterfaceDef<T>) => {\n const manager = usePluginManager();\n return useAtomValue(manager.capabilities.atom(interfaceDef));\n};\n\n/**\n * Hook to request a capability from the plugin context.\n * @returns The capability.\n * @throws If no capability is found.\n */\nexport const useCapability = <T>(interfaceDef: Capability.InterfaceDef<T>) => {\n const capabilities = useCapabilities(interfaceDef);\n invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`);\n return capabilities[0];\n};\n\n/**\n * Hook to get the current value of an atom capability.\n * Automatically subscribes to changes.\n * @example const settings = useAtomCapability(ThreadCapabilities.Settings);\n */\nexport const useAtomCapability = <T>(atomCapability: Capability.InterfaceDef<Atom.Atom<T>>): T => {\n const atom = useCapability(atomCapability);\n return useAtomValue(atom);\n};\n\n/**\n * Hook to get value and updater for an atom capability.\n * Returns [currentValue, updateFn] similar to useState.\n * @example const [settings, updateSettings] = useAtomCapabilityState(ThreadCapabilities.Settings);\n */\nexport const useAtomCapabilityState = <T>(\n atomCapability: Capability.InterfaceDef<Atom.Writable<T>>,\n): [T, (fn: (current: T) => T) => void] => {\n const registry = useCapability(Capabilities.AtomRegistry);\n const atom = useCapability(atomCapability);\n const value = useAtomValue(atom);\n const update = useCallback(\n (fn: (current: T) => T) => {\n registry.set(atom, fn(registry.get(atom)));\n },\n [registry, atom],\n );\n return [value, update];\n};\n\n/**\n * Hook to get the operation invoker capability.\n */\nexport const useOperationInvoker = (): Capabilities.OperationInvoker => useCapability(Capabilities.OperationInvoker);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nexport enum LoadingState {\n Loading = 0,\n FadeIn = 1,\n FadeOut = 2,\n Done = 3,\n}\n\n/**\n * To avoid \"flashing\" the placeholder, we wait a period of time before starting the loading animation.\n * If loading completes during this time the placehoder is not shown, otherwise is it displayed for a minimum period of time.\n *\n * States:\n * 0: Loading - Wait for a period of time before starting the loading animation.\n * 1: Fade-in - Display a loading animation.\n * 2: Fade-out - Fade out the loading animation.\n * 3: Done - Remove the placeholder.\n */\nexport const useLoading = (ready: boolean, debounce = 0) => {\n const [stage, setStage] = useState<LoadingState>(LoadingState.Loading);\n useEffect(() => {\n if (!debounce) {\n return;\n }\n\n const i = setInterval(() => {\n setStage((stage) => {\n switch (stage) {\n case LoadingState.Loading: {\n if (!ready) {\n return LoadingState.FadeIn;\n } else {\n clearInterval(i);\n return LoadingState.Done;\n }\n }\n\n case LoadingState.FadeIn: {\n if (ready) {\n return LoadingState.FadeOut;\n }\n break;\n }\n\n case LoadingState.FadeOut: {\n clearInterval(i);\n return LoadingState.Done;\n }\n }\n\n return stage;\n });\n }, debounce);\n\n return () => clearInterval(i);\n }, [debounce]);\n\n if (!debounce) {\n return ready ? LoadingState.Done : LoadingState.Loading;\n }\n\n return stage;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useMemo } from 'react';\n\nimport { Capabilities } from '../../common';\nimport { usePluginManager } from '../components';\n\n/**\n * Hook to dynamically register an operation resolver (handler) within a React component.\n * The resolver is added when the component mounts and removed when it unmounts.\n *\n * @example\n * ```tsx\n * const scrollHandler = useMemo(() => OperationResolver.make({\n * operation: LayoutOperation.ScrollIntoView,\n * handler: (input) => Effect.sync(() => {\n * // Handle scroll\n * }),\n * }), [deps]);\n *\n * useOperationResolver(meta.id, scrollHandler);\n * ```\n */\nexport const useOperationResolver = (module: string, resolver: Capabilities.OperationResolver) => {\n const manager = usePluginManager();\n // Wrap single resolver in array as the capability expects an array.\n const resolverArray = useMemo(() => [resolver], [resolver]);\n\n useEffect(() => {\n manager.capabilities.contribute({\n module,\n interface: Capabilities.OperationResolver,\n implementation: resolverArray,\n });\n\n return () => manager.capabilities.remove(Capabilities.OperationResolver, resolverArray);\n }, [module, resolverArray]);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, RegistryContext, useAtomValue } from '@effect-atom/atom-react';\nimport { useCallback, useContext } from 'react';\n\n/**\n * Hook to read and update a settings atom.\n * Returns the current value and an update function.\n */\nexport const useSettingsState = <T>(\n atom: Atom.Writable<T>,\n): { settings: T; updateSettings: (fn: (current: T) => T) => void } => {\n const registry = useContext(RegistryContext);\n const settings = useAtomValue(atom);\n\n const updateSettings = useCallback(\n (fn: (current: T) => T) => {\n registry.set(atom, fn(registry.get(atom)));\n },\n [registry, atom],\n );\n\n return { settings, updateSettings };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { Surface } from '../components';\n\nexport const useSurface = (): Surface.Context => {\n return useContext(Surface.Context) ?? raise(new Error('Missing SurfaceContext'));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type PluginManager } from '../../../core';\n\nconst PluginManagerContext = createContext<PluginManager.PluginManager | undefined>(undefined);\n\n/**\n * Get the plugin manager.\n */\nexport const usePluginManager = (): PluginManager.PluginManager =>\n useContext(PluginManagerContext) ?? raise(new Error('Missing PluginManagerContext'));\n\n/**\n * Context provider for a plugin manager.\n */\nexport const PluginManagerProvider = PluginManagerContext.Provider;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Props } from './types';\n\nexport type SurfaceContext = Pick<Props, 'id' | 'role' | 'data'>;\n\n// TODO(burdon): Use @radix-ui/react-context\nexport const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, {\n Fragment,\n type NamedExoticComponent,\n type RefAttributes,\n Suspense,\n forwardRef,\n memo,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { log } from '@dxos/log';\nimport { ErrorBoundary } from '@dxos/react-error-boundary';\nimport { useDefaultValue } from '@dxos/react-hooks';\nimport { byPosition } from '@dxos/util';\n\nimport { Capabilities } from '../../../common';\nimport { type CapabilityManager } from '../../../core';\nimport { useCapabilities } from '../../hooks';\n\nimport { SurfaceContext } from './context';\nimport { SurfaceInfo } from './SurfaceInfo';\nimport { type Definition, type Props, type WebComponentDefinition } from './types';\n\nconst DEFAULT_PLACEHOLDER = <Fragment />;\n\nconst DEBUG = import.meta.env.VITE_DEBUG;\n\n/**\n * Wrapper component for rendering Web Component surfaces.\n * Handles creation, prop setting, and cleanup of Web Components.\n */\nconst WebComponentWrapper = memo(\n forwardRef<HTMLElement, Props & { definition: WebComponentDefinition }>(\n ({ id, role, data, limit, definition, ...rest }, forwardedRef) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const elementRef = useRef<HTMLElement | null>(null);\n const propsRef = useRef({ id, role, data, limit, ...rest });\n\n // Update props ref on every render\n propsRef.current = { id, role, data, limit, ...rest };\n\n // Create element only once\n useEffect(() => {\n if (!containerRef.current || elementRef.current) {\n return;\n }\n\n // Create the Web Component\n const element = document.createElement(definition.tagName);\n elementRef.current = element;\n\n // Set initial properties on the Web Component\n Object.assign(element, propsRef.current);\n\n // Append to container\n containerRef.current.appendChild(element);\n\n // Setup ref forwarding if provided\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n\n // Cleanup on unmount to prevent memory leaks\n return () => {\n if (elementRef.current && containerRef.current?.contains(elementRef.current)) {\n containerRef.current.removeChild(elementRef.current);\n }\n if (typeof forwardedRef === 'function') {\n forwardedRef(null);\n } else if (forwardedRef) {\n forwardedRef.current = null;\n }\n elementRef.current = null;\n };\n }, [definition.tagName, forwardedRef]);\n\n // Update props on existing element without recreating it\n // This runs on every render to ensure all props (including those in `rest`) are kept up to date\n useEffect(() => {\n const element = elementRef.current;\n if (!element) {\n return;\n }\n\n // Update properties on the existing Web Component\n Object.assign(element, propsRef.current);\n });\n\n return <div ref={containerRef} />;\n },\n ),\n);\n\nWebComponentWrapper.displayName = 'WebComponentWrapper';\n\n/**\n * Wrapper component that provides context for a surface.\n */\n// TODO(burdon): Allow DebugPlugin to provide different fallback using react-ui ErrorFallback.\nconst SurfaceContextProvider = memo(\n forwardRef<HTMLElement, Props & { definition: Definition }>(\n ({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {\n const contextValue = useMemo(() => ({ id, role, data }), [id, role, data]);\n\n // Handle Web Component surfaces\n if (definition.kind === 'web-component') {\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <SurfaceContext.Provider value={contextValue}>\n <WebComponentWrapper\n id={id}\n role={role}\n data={data}\n limit={limit}\n definition={definition}\n ref={forwardedRef}\n {...rest}\n />\n </SurfaceContext.Provider>\n </ErrorBoundary>\n );\n }\n\n // Handle React component surfaces\n const Component = definition.component;\n\n // TODO(burdon): Remove from production build?\n const debug = DEBUG || '__DX_DEBUG__' in window;\n if (debug) {\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <div role='none' className='contents' data-id={id} data-role={role}>\n <SurfaceContext.Provider value={contextValue}>\n <SurfaceInfo ref={forwardedRef}>\n <Component id={id} role={role} data={data} limit={limit} {...rest} />\n </SurfaceInfo>\n </SurfaceContext.Provider>\n </div>\n </ErrorBoundary>\n );\n }\n\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <div role='none' className='contents' data-id={id} data-role={role}>\n <SurfaceContext.Provider value={contextValue}>\n <Component id={id} role={role} data={data} limit={limit} {...rest} ref={forwardedRef} />\n </SurfaceContext.Provider>\n </div>\n </ErrorBoundary>\n );\n },\n ),\n);\n\nSurfaceContextProvider.displayName = 'SurfaceContextProvider';\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\n// TODO(burdon): Remove `ref` since relying on this would be error prone.\nexport const SurfaceComponent: NamedExoticComponent<Props & RefAttributes<HTMLElement>> = memo(\n forwardRef(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {\n const data = useDefaultValue(dataProp, () => ({}));\n\n // TODO(wittjosiah): This will make all surfaces depend on a single signal.\n // This isn't ideal because it means that any change to the data will cause all surfaces to re-render.\n // This effectively means that plugin modules which contribute surfaces need to all be activated at startup.\n // This should be fine for now because it's how it worked prior to capabilities api anyway.\n // In the future, it would be nice to be able to bucket the surface contributions by role.\n const surfaces = useSurfaces();\n\n // NOTE: Memoizing the candidates makes the surface not re-render based on reactivity within data.\n const definitions = findCandidates(surfaces, { role, data });\n const candidates = limit ? definitions.slice(0, limit) : definitions;\n if (DEBUG && candidates.length === 0) {\n log.warn('no candidates for surface', { role, data });\n return null;\n }\n\n return (\n <Suspense fallback={placeholder}>\n {candidates.map((definition) => (\n <SurfaceContextProvider\n key={definition.id}\n id={definition.id}\n role={role}\n data={data}\n limit={limit}\n definition={definition}\n ref={forwardedRef}\n {...rest}\n />\n ))}\n </Suspense>\n );\n }),\n);\n\nSurfaceComponent.displayName = 'Surface';\n\n// TODO(burdon): Make user facing, with telemetry.\nconst ErrorFallback = ({ error }: Props) => {\n const { message } = error instanceof Error ? error : { message: String(error) };\n return (\n <div role='alert' data-testid='error-boundary-fallback'>\n <h1 className='flex gap-2 text-sm mt-2 text-info-text'>{message}</h1>\n </div>\n );\n};\n\nconst findCandidates = (surfaces: Definition[], { role, data }: Pick<Props, 'role' | 'data'>) => {\n return Object.values(surfaces)\n .filter((definition) =>\n Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,\n )\n .filter(({ filter }) => (filter ? filter(data ?? {}) : true))\n .toSorted(byPosition);\n};\n\n/**\n * @internal\n */\nexport const useSurfaces = () => {\n const surfaces = useCapabilities(Capabilities.ReactSurface);\n return useMemo(() => surfaces.flat(), [surfaces]);\n};\n\n/**\n * @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.\n */\nexport const isSurfaceAvailable = (\n capabilityManager: CapabilityManager.CapabilityManager,\n { role, data }: Pick<Props, 'role' | 'data'>,\n) => {\n const surfaces = capabilityManager.getAll(Capabilities.ReactSurface);\n const candidates = findCandidates(surfaces.flat(), { role, data });\n return candidates.length > 0;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, {\n type ReactElement,\n type Ref,\n cloneElement,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { addEventListener, combine } from '@dxos/async';\nimport { useMergeRefs } from '@dxos/react-hooks';\n\nimport { useSurface } from '../../hooks';\n\nexport type SurfaceInfoProps = {\n children: ReactElement<{ ref?: Ref<HTMLElement> }>;\n};\n\n/**\n * Debug wrapper for surfaces.\n */\nexport const SurfaceInfo = forwardRef<HTMLElement, SurfaceInfoProps>(({ children }, forwardedRef) => {\n const [rect, setRect] = useState<DOMRect | null>(null);\n const [expand, setExpand] = useState(false);\n const info = useSurface();\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n const measureRef = useCallback((node: HTMLElement | null) => setRoot(node), []);\n const mergedRef = useMergeRefs([measureRef, forwardedRef]);\n const childWithRef = cloneElement(children, { ref: mergedRef });\n\n useLayoutEffect(() => {\n if (!root) {\n setRect(null);\n return;\n }\n\n const measure = () => {\n setRect(root.getBoundingClientRect());\n };\n\n const observer = new ResizeObserver(measure);\n observer.observe(root);\n measure();\n\n return combine(\n addEventListener(window, 'scroll', measure, true),\n addEventListener(window, 'resize', measure),\n () => {\n observer.disconnect();\n },\n );\n }, [root]);\n\n const padding = 0;\n return (\n <>\n {childWithRef}\n {rect &&\n createPortal(\n <div\n role='none'\n className='z-[100] fixed flex flex-col-reverse scrollbar-none overflow-auto pointer-events-none'\n style={{\n top: rect.top + padding,\n left: rect.left + padding,\n width: rect.width - padding * 2,\n height: rect.height - padding * 2,\n }}\n >\n {expand ? (\n <div\n className='absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n setExpand(false);\n }}\n >\n <pre className='p-2 text-xs text-description font-mono'>{JSON.stringify({ info }, null, 2)}</pre>\n </div>\n ) : (\n <span\n className='absolute right-1 bottom-0 flex items-center p-1 text-green-500 opacity-80 hover:opacity-100 text-xl cursor-pointer pointer-events-auto'\n title={info.id}\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n setExpand(true);\n }}\n >\n ⓘ\n </span>\n )}\n </div>,\n // TODO(burdon): Create well-known element to gather all debug portals.\n document.body,\n )}\n </>\n );\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { FC, PropsWithChildren, ReactNode, RefCallback } from 'react';\n\nimport type { MakeOptional, Position } from '@dxos/util';\n\n/**\n * Props that are passed to the Surface component.\n */\nexport type Props<T extends Record<string, any> = Record<string, unknown>> = {\n /**\n * If specified, the Surface will be wrapped in an error boundary.\n * The fallback component will be rendered if an error occurs.\n */\n fallback?: FC<{ error: Error; data?: any }>;\n\n /**\n * If specified, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\n} & MakeOptional<CoreProps<T>, 'id' | 'data'> &\n /**\n * Additional props to pass to the component.\n * These props are not used by Surface itself but may be used by components which resolve the surface.\n * Exclude known prop names to prevent overriding well-defined props.\n */\n {\n [K in keyof Record<string, any>]: K extends keyof CoreProps<T> | 'fallback' | 'placeholder' ? never : any;\n };\n\n/**\n * NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.\n */\nexport type CoreProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{\n /**\n * ID for debugging.\n */\n id: string;\n\n /**\n * Role defines how the data should be rendered.\n */\n role: string;\n\n /**\n * The data to be rendered by the surface.\n * NOTE: This must be a stable value.\n */\n data: T;\n\n /**\n * If more than one component is resolved, the limit determines how many are rendered.\n */\n limit?: number | undefined;\n}>;\n\n// TODO(burdon): Remove ref since relying on this would be error prone.\nexport type ComponentProps<T extends Record<string, any> = Record<string, any>> = CoreProps<T> & {\n ref?: RefCallback<HTMLElement>;\n} & Record<string, any>;\n\n/**\n * React component used to render a surface once is has matched.\n */\nexport type ComponentFunction<T extends Record<string, any> = Record<string, any>> = (\n props: ComponentProps<T>,\n) => ReactNode;\n\n/**\n * Definition of when a React component surface should be rendered.\n */\nexport type ReactDefinition<T extends Record<string, any> = any> = Readonly<{\n kind: 'react';\n id: string;\n role: string | string[];\n position?: Position;\n component: ComponentFunction<T>;\n filter?: (data: Record<string, unknown>) => data is T;\n}>;\n\n/**\n * Definition of when a Web Component surface should be rendered.\n */\nexport type WebComponentDefinition<T extends Record<string, any> = any> = Readonly<{\n kind: 'web-component';\n id: string;\n role: string | string[];\n position?: Position;\n /**\n * The tag name of the Web Component to render.\n * The Web Component will receive the same props as React surfaces via properties/attributes.\n */\n tagName: string;\n filter?: (data: Record<string, unknown>) => data is T;\n}>;\n\n/**\n * Definition of when a surface (React or Web Component) should be rendered.\n */\nexport type Definition<T extends Record<string, any> = any> = ReactDefinition<T> | WebComponentDefinition<T>;\n\n/**\n * Creates a React surface definition.\n */\nexport const create = <T extends Record<string, any> = any>(\n definition: Omit<ReactDefinition<T>, 'kind'>,\n): ReactDefinition<T> => ({ ...definition, kind: 'react' });\n\n/**\n * Creates a Web Component surface definition.\n */\nexport const createWeb = <T extends Record<string, any> = any>(\n definition: Omit<WebComponentDefinition<T>, 'kind'>,\n): WebComponentDefinition<T> => ({ ...definition, kind: 'web-component' });\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(wittjosiah): Cleanup to avoid re-naming.\nimport { SurfaceContext } from './context';\nimport { SurfaceComponent, isSurfaceAvailable } from './SurfaceComponent';\nimport { type Definition as SurfaceDefinition, create as createSurface, createWeb as createWebSurface } from './types';\n\nexport namespace Surface {\n export type Definition = SurfaceDefinition;\n export const create = createSurface;\n export const createWeb = createWebSurface;\n\n export type Context = SurfaceContext;\n export const Context = SurfaceContext;\n\n export const Surface = SurfaceComponent;\n export const isAvailable = isSurfaceAvailable;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAIA,OA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AO,CAAC,EAAEA,OAAM,MAAQA,SAASA,OAAOpE,QAAQ,CAAC,CAAA,IAAK,IAAA,EACtDwE,SAASC,UAAAA;AACd;AAKO,IAAMvB,cAAc,MAAA;AACzB,QAAMD,WAAWyB,gBAAgBC,qBAAaC,YAAY;AAC1D,SAAOjD,SAAQ,MAAMsB,SAAS4B,KAAI,GAAI;IAAC5B;GAAS;AAClD;AAKO,IAAM6B,qBAAqB,CAChCC,mBACA,EAAEhF,MAAMC,KAAI,MAAgC;AAE5C,QAAMiD,WAAW8B,kBAAkBC,OAAOL,qBAAaC,YAAY;AACnE,QAAMvB,aAAaD,eAAeH,SAAS4B,KAAI,GAAI;IAAE9E;IAAMC;EAAK,CAAA;AAChE,SAAOqD,WAAWE,SAAS;AAC7B;;;AE3IO,IAAM0B,SAAS,CACpBC,gBACwB;EAAE,GAAGA;EAAYC,MAAM;AAAQ;AAKlD,IAAMC,YAAY,CACvBF,gBAC+B;EAAE,GAAGA;EAAYC,MAAM;AAAgB;;;UC3GvDE,UAAAA;WAEFC,SAASC;WACTC,YAAYC;WAGZC,UAAUC;WAEVN,UAAUO;WACVC,cAAcC;AAC7B,GAViBT,YAAAA,UAAAA,CAAAA,EAAAA;;",
|
|
6
6
|
"names": ["React", "topologicalSort", "nodes", "getDependencies", "nodeId", "seen", "Set", "path", "has", "Error", "node", "find", "n", "id", "newPath", "newSeen", "dependsOn", "flatMap", "depId", "allDependencies", "map", "filter", "index", "self", "indexOf", "undefined", "RegistryContext", "Effect", "Fiber", "PubSub", "Queue", "React", "useCallback", "useEffect", "useMemo", "useRef", "useState", "runAndForwardErrors", "invariant", "log", "ErrorBoundary", "ErrorFallback", "useAsyncEffect", "useDefaultValue", "ContextProtocolProvider", "ENABLED_KEY", "useApp", "pluginManager", "pluginLoader", "pluginLoaderProp", "plugins", "pluginsProp", "core", "coreProp", "defaults", "defaultsProp", "setupEvents", "setupEventsProp", "placeholder", "fallback", "ErrorFallback", "cacheEnabled", "safeMode", "debounce", "timeout", "useDefaultValue", "map", "meta", "id", "useMemo", "sync", "plugin", "find", "invariant", "readyRef", "useRef", "ready", "setReady", "useState", "errorRef", "error", "setError", "cached", "JSON", "parse", "localStorage", "getItem", "enabled", "length", "manager", "PluginManager", "make", "useEffect", "registry", "subscribe", "value", "setItem", "stringify", "setupDevtools", "useAsyncEffect", "capabilities", "contribute", "interface", "Capabilities", "implementation", "module", "AtomRegistry", "fiber", "gen", "queue", "activation", "listener", "forkDaemon", "take", "pipe", "tap", "event", "state", "error$", "ActivationEvents", "Startup", "clearTimeout", "timeoutId", "current", "forever", "all", "activate", "SetupReactSurface", "join", "scoped", "runFork", "setTimeout", "log", "warn", "eventsFired", "getEventsFired", "activeModules", "getActive", "pendingReset", "getPendingReset", "runAndForwardErrors", "interrupt", "Error", "remove", "useCallback", "ErrorBoundary", "name", "FallbackComponent", "PluginManagerProvider", "ContextProtocolProvider", "context", "PluginManagerContext", "RegistryContext", "Provider", "App", "globalThis", "composer", "useAtomValue", "useCallback", "invariant", "useCapabilities", "interfaceDef", "manager", "usePluginManager", "useAtomValue", "capabilities", "atom", "useCapability", "invariant", "length", "identifier", "useAtomCapability", "atomCapability", "useAtomCapabilityState", "registry", "Capabilities", "AtomRegistry", "value", "update", "useCallback", "fn", "set", "get", "useOperationInvoker", "OperationInvoker", "useEffect", "useState", "LoadingState", "useLoading", "ready", "debounce", "stage", "setStage", "useState", "useEffect", "i", "setInterval", "clearInterval", "useEffect", "useMemo", "useOperationResolver", "module", "resolver", "manager", "usePluginManager", "resolverArray", "useMemo", "useEffect", "capabilities", "contribute", "interface", "Capabilities", "OperationResolver", "implementation", "remove", "RegistryContext", "useAtomValue", "useCallback", "useContext", "useSettingsState", "atom", "registry", "useContext", "RegistryContext", "settings", "useAtomValue", "updateSettings", "useCallback", "fn", "set", "get", "useContext", "raise", "useSurface", "useContext", "Surface", "Context", "raise", "Error", "App", "placeholder", "Placeholder", "ready", "error", "debounce", "reactContexts", "useCapabilities", "Capabilities", "ReactContext", "reactRoots", "ReactRoot", "stage", "useLoading", "LoadingState", "Done", "React", "ComposedContext", "composeContexts", "map", "id", "root", "Component", "key", "contexts", "length", "children", "topologicalSort", "context", "reduce", "Acc", "Next", "createContext", "useContext", "raise", "PluginManagerContext", "createContext", "undefined", "usePluginManager", "useContext", "raise", "Error", "PluginManagerProvider", "Provider", "createContext", "SurfaceContext", "createContext", "undefined", "React", "Fragment", "Suspense", "forwardRef", "memo", "useEffect", "useMemo", "useRef", "log", "ErrorBoundary", "useDefaultValue", "byPosition", "React", "cloneElement", "forwardRef", "useCallback", "useLayoutEffect", "useState", "createPortal", "addEventListener", "combine", "useMergeRefs", "SurfaceInfo", "forwardRef", "children", "forwardedRef", "rect", "setRect", "useState", "expand", "setExpand", "info", "useSurface", "root", "setRoot", "measureRef", "useCallback", "node", "mergedRef", "useMergeRefs", "childWithRef", "cloneElement", "ref", "useLayoutEffect", "measure", "getBoundingClientRect", "observer", "ResizeObserver", "observe", "combine", "addEventListener", "window", "disconnect", "padding", "React", "createPortal", "div", "role", "className", "style", "top", "left", "width", "height", "onPointerDown", "ev", "stopPropagation", "onClick", "pre", "JSON", "stringify", "span", "title", "id", "document", "body", "DEFAULT_PLACEHOLDER", "React", "Fragment", "DEBUG", "env", "VITE_DEBUG", "WebComponentWrapper", "memo", "forwardRef", "id", "role", "data", "limit", "definition", "rest", "forwardedRef", "containerRef", "useRef", "elementRef", "propsRef", "current", "useEffect", "element", "document", "createElement", "tagName", "Object", "assign", "appendChild", "contains", "removeChild", "div", "ref", "displayName", "SurfaceContextProvider", "fallback", "ErrorFallback", "contextValue", "useMemo", "kind", "ErrorBoundary", "name", "resetKeys", "FallbackComponent", "SurfaceContext", "Provider", "value", "Component", "component", "debug", "window", "className", "data-id", "data-role", "SurfaceInfo", "SurfaceComponent", "_id", "dataProp", "placeholder", "useDefaultValue", "surfaces", "useSurfaces", "definitions", "findCandidates", "candidates", "slice", "length", "log", "warn", "Suspense", "map", "key", "error", "message", "Error", "String", "data-testid", "h1", "values", "filter", "Array", "isArray", "includes", "toSorted", "byPosition", "useCapabilities", "Capabilities", "ReactSurface", "flat", "isSurfaceAvailable", "capabilityManager", "getAll", "create", "definition", "kind", "createWeb", "Surface", "create", "createSurface", "createWeb", "createWebSurface", "Context", "SurfaceContext", "SurfaceComponent", "isAvailable", "isSurfaceAvailable"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/context.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@dxos/web-context';\n\nimport { type PluginManager } from './core';\n\nexport const PluginManagerContext = createContext<PluginManager.PluginManager>('dxos.
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@dxos/web-context';\n\nimport { type PluginManager } from './core';\n\nexport const PluginManagerContext = createContext<PluginManager.PluginManager>('org.dxos.app-framework.plugin-manager');\n"],
|
|
5
5
|
"mappings": ";AAIA,SAASA,qBAAqB;AAIvB,IAAMC,uBAAuBC,cAA2C,uCAAA;",
|
|
6
6
|
"names": ["createContext", "PluginManagerContext", "createContext"]
|
|
7
7
|
}
|
|
@@ -13,11 +13,11 @@ var Label = Schema.Union(Schema.String, Schema.mutable(Schema.Tuple(Schema.Strin
|
|
|
13
13
|
// src/common/operations.ts
|
|
14
14
|
import * as Schema2 from "effect/Schema";
|
|
15
15
|
import { Operation } from "@dxos/operation";
|
|
16
|
-
var UNDO_NAMESPACE = "dxos.
|
|
16
|
+
var UNDO_NAMESPACE = "org.dxos.app-framework.undo";
|
|
17
17
|
(function(UndoOperation2) {
|
|
18
18
|
UndoOperation2.ShowUndo = Operation.make({
|
|
19
19
|
meta: {
|
|
20
|
-
key: `${UNDO_NAMESPACE}
|
|
20
|
+
key: `${UNDO_NAMESPACE}.operation.show-undo`,
|
|
21
21
|
name: "Show Undo",
|
|
22
22
|
description: "Show an undo toast notification."
|
|
23
23
|
},
|
|
@@ -41,4 +41,4 @@ export {
|
|
|
41
41
|
Label,
|
|
42
42
|
UndoOperation
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-TIEBZMTF.mjs.map
|