@dxos/app-framework 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/.storybook/main.mts +11 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/dist/lib/browser/{app-graph-builder-AFFC6VB2.mjs → app-graph-builder-OIEZZC45.mjs} +31 -30
  4. package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-ORWHM7CO.mjs → chunk-SCPE4ZO2.mjs} +11 -8
  6. package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-T6M7JB7M.mjs → chunk-VFUKEZIN.mjs} +121 -109
  8. package/dist/lib/browser/chunk-VFUKEZIN.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-OZY7HV2A.mjs → chunk-WPW5VVAX.mjs} +281 -273
  10. package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +14 -56
  12. package/dist/lib/browser/index.mjs.map +3 -3
  13. package/dist/lib/browser/{intent-dispatcher-QG7UPGQX.mjs → intent-dispatcher-LZ4AE66E.mjs} +2 -2
  14. package/dist/lib/browser/{intent-resolver-4S4PSTM5.mjs → intent-resolver-QVCKRX6G.mjs} +7 -7
  15. package/dist/lib/browser/intent-resolver-QVCKRX6G.mjs.map +7 -0
  16. package/dist/lib/browser/meta.json +1 -1
  17. package/dist/lib/browser/react/index.mjs +34 -0
  18. package/dist/lib/browser/{store-6E33KLGK.mjs → store-CNPHOYTJ.mjs} +5 -5
  19. package/dist/lib/browser/store-CNPHOYTJ.mjs.map +7 -0
  20. package/dist/lib/browser/testing/index.mjs +14 -16
  21. package/dist/lib/browser/testing/index.mjs.map +3 -3
  22. package/dist/lib/node-esm/{app-graph-builder-S4OAULX5.mjs → app-graph-builder-EBU4NVWD.mjs} +31 -30
  23. package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-HJFU7QOR.mjs → chunk-IJOHO66N.mjs} +121 -109
  25. package/dist/lib/node-esm/chunk-IJOHO66N.mjs.map +7 -0
  26. package/dist/lib/node-esm/{chunk-F63ZRXMK.mjs → chunk-XJZGUJ3H.mjs} +281 -273
  27. package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs.map +7 -0
  28. package/dist/lib/node-esm/{chunk-UMZQERLE.mjs → chunk-ZX63QUGE.mjs} +11 -8
  29. package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +7 -0
  30. package/dist/lib/node-esm/index.mjs +14 -56
  31. package/dist/lib/node-esm/index.mjs.map +3 -3
  32. package/dist/lib/node-esm/{intent-dispatcher-NXBGPJOX.mjs → intent-dispatcher-MGOJ3CHD.mjs} +2 -2
  33. package/dist/lib/node-esm/{intent-resolver-2ZKXI5ET.mjs → intent-resolver-URF3HN3G.mjs} +7 -7
  34. package/dist/lib/node-esm/intent-resolver-URF3HN3G.mjs.map +7 -0
  35. package/dist/lib/node-esm/meta.json +1 -1
  36. package/dist/lib/node-esm/react/index.mjs +35 -0
  37. package/dist/lib/node-esm/{store-QQUTQHHT.mjs → store-RK5B4XEL.mjs} +5 -5
  38. package/dist/lib/node-esm/store-RK5B4XEL.mjs.map +7 -0
  39. package/dist/lib/node-esm/testing/index.mjs +14 -16
  40. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  41. package/dist/types/src/common/capabilities.d.ts +41 -37
  42. package/dist/types/src/common/capabilities.d.ts.map +1 -1
  43. package/dist/types/src/common/collaboration.d.ts +1 -1
  44. package/dist/types/src/common/collaboration.d.ts.map +1 -1
  45. package/dist/types/src/common/file.d.ts +1 -1
  46. package/dist/types/src/common/file.d.ts.map +1 -1
  47. package/dist/types/src/common/layout.d.ts +1 -3
  48. package/dist/types/src/common/layout.d.ts.map +1 -1
  49. package/dist/types/src/common/surface.d.ts +19 -16
  50. package/dist/types/src/common/surface.d.ts.map +1 -1
  51. package/dist/types/src/common/translations.d.ts +1 -1
  52. package/dist/types/src/common/translations.d.ts.map +1 -1
  53. package/dist/types/src/core/capabilities.d.ts +15 -15
  54. package/dist/types/src/core/capabilities.d.ts.map +1 -1
  55. package/dist/types/src/core/manager.d.ts +1 -1
  56. package/dist/types/src/core/manager.d.ts.map +1 -1
  57. package/dist/types/src/core/plugin.d.ts +8 -1
  58. package/dist/types/src/core/plugin.d.ts.map +1 -1
  59. package/dist/types/src/index.d.ts +0 -2
  60. package/dist/types/src/index.d.ts.map +1 -1
  61. package/dist/types/src/playground/debug/plugin.d.ts +1 -1
  62. package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
  63. package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
  64. package/dist/types/src/playground/generator/generator.d.ts +1 -1
  65. package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
  66. package/dist/types/src/playground/generator/plugin.d.ts +1 -1
  67. package/dist/types/src/playground/generator/plugin.d.ts.map +1 -1
  68. package/dist/types/src/playground/layout/plugin.d.ts +1 -1
  69. package/dist/types/src/playground/layout/plugin.d.ts.map +1 -1
  70. package/dist/types/src/playground/logger/plugin.d.ts +1 -1
  71. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -1
  72. package/dist/types/src/playground/logger/schema.d.ts +1 -1
  73. package/dist/types/src/playground/logger/schema.d.ts.map +1 -1
  74. package/dist/types/src/playground/playground.stories.d.ts +0 -1
  75. package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
  76. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +1 -1
  77. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
  78. package/dist/types/src/plugin-intent/actions.d.ts +5 -7
  79. package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
  80. package/dist/types/src/plugin-intent/errors.d.ts.map +1 -1
  81. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +4 -4
  82. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
  83. package/dist/types/src/plugin-intent/intent.d.ts +1 -1
  84. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
  85. package/dist/types/src/plugin-intent/meta.d.ts +3 -0
  86. package/dist/types/src/plugin-intent/meta.d.ts.map +1 -0
  87. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +1 -1
  88. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -1
  89. package/dist/types/src/plugin-settings/actions.d.ts +5 -7
  90. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
  91. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
  92. package/dist/types/src/plugin-settings/meta.d.ts +3 -0
  93. package/dist/types/src/plugin-settings/meta.d.ts.map +1 -0
  94. package/dist/types/src/plugin-settings/translations.d.ts +2 -1
  95. package/dist/types/src/plugin-settings/translations.d.ts.map +1 -1
  96. package/dist/types/src/react/App.d.ts.map +1 -0
  97. package/dist/types/src/{components → react}/App.stories.d.ts +0 -1
  98. package/dist/types/src/react/App.stories.d.ts.map +1 -0
  99. package/dist/types/src/react/DefaultFallback.d.ts.map +1 -0
  100. package/dist/types/src/react/ErrorBoundary.d.ts +2 -2
  101. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -1
  102. package/dist/types/src/react/Surface.d.ts +5 -5
  103. package/dist/types/src/react/Surface.d.ts.map +1 -1
  104. package/dist/types/src/react/Surface.stories.d.ts +3 -7
  105. package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
  106. package/dist/types/src/react/index.d.ts +2 -0
  107. package/dist/types/src/react/index.d.ts.map +1 -1
  108. package/dist/types/src/react/types.d.ts +14 -0
  109. package/dist/types/src/react/types.d.ts.map +1 -0
  110. package/dist/types/src/{components → react}/useApp.d.ts +2 -2
  111. package/dist/types/src/react/useApp.d.ts.map +1 -0
  112. package/dist/types/src/react/useLoading.d.ts.map +1 -0
  113. package/dist/types/src/testing/withPluginManager.d.ts +6 -7
  114. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  115. package/dist/types/tsconfig.tsbuildinfo +1 -1
  116. package/moon.yml +5 -1
  117. package/package.json +44 -40
  118. package/src/common/capabilities.ts +34 -19
  119. package/src/common/collaboration.ts +3 -3
  120. package/src/common/file.ts +1 -1
  121. package/src/common/layout.ts +3 -4
  122. package/src/common/surface.ts +23 -21
  123. package/src/common/translations.ts +1 -1
  124. package/src/core/capabilities.test.ts +2 -2
  125. package/src/core/capabilities.ts +26 -22
  126. package/src/core/manager.test.ts +19 -19
  127. package/src/core/manager.ts +14 -7
  128. package/src/core/plugin.ts +13 -2
  129. package/src/index.ts +0 -2
  130. package/src/playground/debug/plugin.ts +7 -8
  131. package/src/playground/generator/Main.tsx +0 -1
  132. package/src/playground/generator/generator.ts +2 -2
  133. package/src/playground/generator/plugin.ts +12 -13
  134. package/src/playground/layout/plugin.ts +9 -8
  135. package/src/playground/logger/plugin.ts +27 -23
  136. package/src/playground/logger/schema.ts +1 -1
  137. package/src/playground/playground.stories.tsx +6 -7
  138. package/src/plugin-intent/IntentPlugin.ts +12 -13
  139. package/src/plugin-intent/actions.ts +4 -6
  140. package/src/plugin-intent/errors.ts +2 -1
  141. package/src/plugin-intent/intent-dispatcher.test.ts +10 -3
  142. package/src/plugin-intent/intent-dispatcher.ts +13 -6
  143. package/src/plugin-intent/intent.ts +1 -1
  144. package/src/plugin-intent/meta.ts +10 -0
  145. package/src/plugin-settings/SettingsPlugin.ts +25 -27
  146. package/src/plugin-settings/actions.ts +9 -13
  147. package/src/plugin-settings/app-graph-builder.ts +22 -20
  148. package/src/plugin-settings/intent-resolver.ts +2 -2
  149. package/src/plugin-settings/meta.ts +10 -0
  150. package/src/plugin-settings/store.ts +2 -2
  151. package/src/plugin-settings/translations.ts +4 -4
  152. package/src/{components → react}/App.stories.tsx +1 -3
  153. package/src/{components → react}/App.tsx +1 -1
  154. package/src/{components → react}/DefaultFallback.tsx +1 -1
  155. package/src/react/ErrorBoundary.tsx +10 -8
  156. package/src/react/Surface.stories.tsx +70 -49
  157. package/src/react/Surface.tsx +67 -36
  158. package/src/react/index.ts +4 -0
  159. package/src/react/types.ts +37 -0
  160. package/src/{components → react}/useApp.tsx +23 -24
  161. package/src/react/useCapabilities.ts +2 -2
  162. package/src/testing/withPluginManager.stories.tsx +1 -1
  163. package/src/testing/withPluginManager.tsx +22 -21
  164. package/tsconfig.json +10 -1
  165. package/vitest.config.ts +8 -6
  166. package/dist/lib/browser/app-graph-builder-AFFC6VB2.mjs.map +0 -7
  167. package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
  168. package/dist/lib/browser/chunk-OZY7HV2A.mjs.map +0 -7
  169. package/dist/lib/browser/chunk-T6M7JB7M.mjs.map +0 -7
  170. package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs.map +0 -7
  171. package/dist/lib/browser/store-6E33KLGK.mjs.map +0 -7
  172. package/dist/lib/browser/worker.mjs +0 -85
  173. package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs.map +0 -7
  174. package/dist/lib/node-esm/chunk-F63ZRXMK.mjs.map +0 -7
  175. package/dist/lib/node-esm/chunk-HJFU7QOR.mjs.map +0 -7
  176. package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
  177. package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs.map +0 -7
  178. package/dist/lib/node-esm/store-QQUTQHHT.mjs.map +0 -7
  179. package/dist/lib/node-esm/worker.mjs +0 -86
  180. package/dist/types/src/components/App.d.ts.map +0 -1
  181. package/dist/types/src/components/App.stories.d.ts.map +0 -1
  182. package/dist/types/src/components/DefaultFallback.d.ts.map +0 -1
  183. package/dist/types/src/components/index.d.ts +0 -2
  184. package/dist/types/src/components/index.d.ts.map +0 -1
  185. package/dist/types/src/components/useApp.d.ts.map +0 -1
  186. package/dist/types/src/components/useLoading.d.ts.map +0 -1
  187. package/dist/types/src/worker.d.ts +0 -4
  188. package/dist/types/src/worker.d.ts.map +0 -1
  189. package/src/components/index.ts +0 -5
  190. package/src/worker.ts +0 -11
  191. /package/dist/lib/browser/{intent-dispatcher-QG7UPGQX.mjs.map → intent-dispatcher-LZ4AE66E.mjs.map} +0 -0
  192. /package/dist/lib/browser/{worker.mjs.map → react/index.mjs.map} +0 -0
  193. /package/dist/lib/node-esm/{intent-dispatcher-NXBGPJOX.mjs.map → intent-dispatcher-MGOJ3CHD.mjs.map} +0 -0
  194. /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
  195. /package/dist/types/src/{components → react}/App.d.ts +0 -0
  196. /package/dist/types/src/{components → react}/DefaultFallback.d.ts +0 -0
  197. /package/dist/types/src/{components → react}/useLoading.d.ts +0 -0
  198. /package/src/{components → react}/useLoading.tsx +0 -0
@@ -1,30 +1,20 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // src/plugin-intent/intent-dispatcher.ts
4
- import { Effect as Effect3, Option, Ref as Ref2, pipe as pipe2 } from "effect";
4
+ import * as Effect3 from "effect/Effect";
5
+ import * as Function2 from "effect/Function";
6
+ import * as Option from "effect/Option";
7
+ import * as Ref2 from "effect/Ref";
5
8
  import { live as live2 } from "@dxos/live-object";
6
9
  import { log as log3 } from "@dxos/log";
7
10
  import { byPosition } from "@dxos/util";
8
11
 
9
12
  // src/core/capabilities.ts
10
- import { Rx } from "@effect-rx/rx-react";
11
- import { Effect } from "effect";
13
+ import { Atom } from "@effect-atom/atom-react";
14
+ import * as Effect from "effect/Effect";
12
15
  import { Trigger } from "@dxos/async";
13
16
  import { invariant } from "@dxos/invariant";
14
17
  import { log } from "@dxos/log";
15
- function _define_property(obj, key, value) {
16
- if (key in obj) {
17
- Object.defineProperty(obj, key, {
18
- value,
19
- enumerable: true,
20
- configurable: true,
21
- writable: true
22
- });
23
- } else {
24
- obj[key] = value;
25
- }
26
- return obj;
27
- }
28
18
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
29
19
  var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
30
20
  var defineCapability = (identifier) => {
@@ -33,9 +23,9 @@ var defineCapability = (identifier) => {
33
23
  };
34
24
  };
35
25
  var CapabilityImpl = class {
26
+ moduleId;
27
+ implementation;
36
28
  constructor(moduleId, implementation) {
37
- _define_property(this, "moduleId", void 0);
38
- _define_property(this, "implementation", void 0);
39
29
  this.moduleId = moduleId;
40
30
  this.implementation = implementation;
41
31
  }
@@ -52,6 +42,48 @@ var lazy = (c) => async (props) => {
52
42
  return async () => getCapability(props);
53
43
  };
54
44
  var PluginContext = class {
45
+ _registry;
46
+ _capabilityImpls = Atom.family(() => {
47
+ return Atom.make([]).pipe(Atom.keepAlive);
48
+ });
49
+ _capabilities = Atom.family((id) => {
50
+ return Atom.make((get) => {
51
+ const current = get(this._capabilityImpls(id));
52
+ return current.map((c) => c.implementation);
53
+ });
54
+ });
55
+ _capability = Atom.family((id) => {
56
+ return Atom.make((get) => {
57
+ const current = get(this._capabilities(id));
58
+ invariant(current.length > 0, `No capability found for ${id}`, {
59
+ F: __dxlog_file,
60
+ L: 126,
61
+ S: this,
62
+ A: [
63
+ "current.length > 0",
64
+ "`No capability found for ${id}`"
65
+ ]
66
+ });
67
+ return current[0];
68
+ });
69
+ });
70
+ /**
71
+ * Activates plugins based on the activation event.
72
+ * @param event The activation event.
73
+ * @returns Whether the activation was successful.
74
+ */
75
+ activate;
76
+ /**
77
+ * Re-activates the modules that were activated by the event.
78
+ * @param event The activation event.
79
+ * @returns Whether the reset was successful.
80
+ */
81
+ reset;
82
+ constructor({ registry, activate, reset }) {
83
+ this._registry = registry;
84
+ this.activate = activate;
85
+ this.reset = reset;
86
+ }
55
87
  /**
56
88
  * @internal
57
89
  */
@@ -71,7 +103,7 @@ var PluginContext = class {
71
103
  count: current.length
72
104
  }, {
73
105
  F: __dxlog_file,
74
- L: 166,
106
+ L: 170,
75
107
  S: this,
76
108
  C: (f, a) => f(...a)
77
109
  });
@@ -92,7 +124,7 @@ var PluginContext = class {
92
124
  count: current.length
93
125
  }, {
94
126
  F: __dxlog_file,
95
- L: 185,
127
+ L: 189,
96
128
  S: this,
97
129
  C: (f, a) => f(...a)
98
130
  });
@@ -101,26 +133,26 @@ var PluginContext = class {
101
133
  id: interfaceDef.identifier
102
134
  }, {
103
135
  F: __dxlog_file,
104
- L: 187,
136
+ L: 191,
105
137
  S: this,
106
138
  C: (f, a) => f(...a)
107
139
  });
108
140
  }
109
141
  }
110
142
  /**
111
- * Get the Rx reference to the available capabilities for a given interface.
112
- * Primarily useful for deriving other Rx values based on the capabilities or
143
+ * Get the Atom reference to the available capabilities for a given interface.
144
+ * Primarily useful for deriving other Atom values based on the capabilities or
113
145
  * for subscribing to changes in the capabilities.
114
- * @returns An Rx reference to the available capabilities.
146
+ * @returns An atom reference to the available capabilities.
115
147
  */
116
148
  capabilities(interfaceDef) {
117
149
  return this._capabilities(interfaceDef.identifier);
118
150
  }
119
151
  /**
120
- * Get the Rx reference to the available capabilities for a given interface.
121
- * Primarily useful for deriving other Rx values based on the capability or
152
+ * Get the Atom reference to the available capabilities for a given interface.
153
+ * Primarily useful for deriving other Atom values based on the capability or
122
154
  * for subscribing to changes in the capability.
123
- * @returns An Rx reference to the available capability.
155
+ * @returns An atom reference to the available capability.
124
156
  * @throws If no capability is found.
125
157
  */
126
158
  capability(interfaceDef) {
@@ -166,38 +198,6 @@ var PluginContext = class {
166
198
  async resetPromise(event) {
167
199
  return this.reset(event).pipe(Effect.runPromise);
168
200
  }
169
- constructor({ registry, activate, reset }) {
170
- _define_property(this, "_registry", void 0);
171
- _define_property(this, "_capabilityImpls", Rx.family(() => {
172
- return Rx.make([]).pipe(Rx.keepAlive);
173
- }));
174
- _define_property(this, "_capabilities", Rx.family((id) => {
175
- return Rx.make((get) => {
176
- const current = get(this._capabilityImpls(id));
177
- return current.map((c) => c.implementation);
178
- });
179
- }));
180
- _define_property(this, "_capability", Rx.family((id) => {
181
- return Rx.make((get) => {
182
- const current = get(this._capabilities(id));
183
- invariant(current.length > 0, `No capability found for ${id}`, {
184
- F: __dxlog_file,
185
- L: 122,
186
- S: this,
187
- A: [
188
- "current.length > 0",
189
- "`No capability found for ${id}`"
190
- ]
191
- });
192
- return current[0];
193
- });
194
- }));
195
- _define_property(this, "activate", void 0);
196
- _define_property(this, "reset", void 0);
197
- this._registry = registry;
198
- this.activate = activate;
199
- this.reset = reset;
200
- }
201
201
  };
202
202
 
203
203
  // src/core/events.ts
@@ -223,30 +223,55 @@ var getEvents = (events) => "type" in events ? events.events : [
223
223
  ];
224
224
 
225
225
  // src/core/manager.ts
226
- import { Registry } from "@effect-rx/rx-react";
226
+ import { Registry } from "@effect-atom/atom-react";
227
227
  import { untracked } from "@preact/signals-core";
228
- import { Array, Duration, Effect as Effect2, Fiber, HashSet, Match, Ref, pipe } from "effect";
228
+ import * as Array from "effect/Array";
229
+ import * as Duration from "effect/Duration";
230
+ import * as Effect2 from "effect/Effect";
231
+ import * as Fiber from "effect/Fiber";
232
+ import * as Function from "effect/Function";
233
+ import * as HashSet from "effect/HashSet";
234
+ import * as Match from "effect/Match";
235
+ import * as Ref from "effect/Ref";
229
236
  import { Event } from "@dxos/async";
230
237
  import { live } from "@dxos/live-object";
231
238
  import { log as log2 } from "@dxos/log";
232
- function _define_property2(obj, key, value) {
233
- if (key in obj) {
234
- Object.defineProperty(obj, key, {
235
- value,
236
- enumerable: true,
237
- configurable: true,
238
- writable: true
239
- });
240
- } else {
241
- obj[key] = value;
242
- }
243
- return obj;
244
- }
245
239
  var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
246
- var isPromise = (value) => {
247
- return value !== null && typeof value === "object" && "then" in value;
240
+ var isPromise = (value2) => {
241
+ return value2 !== null && typeof value2 === "object" && "then" in value2;
248
242
  };
249
243
  var PluginManager = class {
244
+ activation = new Event();
245
+ context;
246
+ registry;
247
+ // TODO(wittjosiah): Replace with Atom.
248
+ _state;
249
+ _pluginLoader;
250
+ _capabilities = /* @__PURE__ */ new Map();
251
+ _moduleMemoMap = /* @__PURE__ */ new Map();
252
+ _activatingEvents = Effect2.runSync(Ref.make([]));
253
+ _activatingModules = Effect2.runSync(Ref.make([]));
254
+ constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
255
+ this.registry = registry ?? Registry.make();
256
+ this.context = new PluginContext({
257
+ registry: this.registry,
258
+ activate: (event) => this._activate(event),
259
+ reset: (id) => this._reset(id)
260
+ });
261
+ this._pluginLoader = pluginLoader;
262
+ this._state = live({
263
+ plugins,
264
+ core,
265
+ enabled,
266
+ modules: [],
267
+ active: [],
268
+ eventsFired: [],
269
+ pendingReset: []
270
+ });
271
+ plugins.forEach((plugin) => this._addPlugin(plugin));
272
+ core.forEach((id) => this.enable(id));
273
+ enabled.forEach((id) => this.enable(id));
274
+ }
250
275
  /**
251
276
  * Plugins that are currently registered.
252
277
  *
@@ -313,7 +338,7 @@ var PluginManager = class {
313
338
  id
314
339
  }, {
315
340
  F: __dxlog_file2,
316
- L: 157,
341
+ L: 164,
317
342
  S: this,
318
343
  C: (f, a) => f(...a)
319
344
  });
@@ -332,7 +357,7 @@ var PluginManager = class {
332
357
  id
333
358
  }, {
334
359
  F: __dxlog_file2,
335
- L: 170,
360
+ L: 177,
336
361
  S: this,
337
362
  C: (f, a) => f(...a)
338
363
  });
@@ -353,7 +378,7 @@ var PluginManager = class {
353
378
  ]
354
379
  }, {
355
380
  F: __dxlog_file2,
356
- L: 185,
381
+ L: 192,
357
382
  S: this,
358
383
  C: (f, a) => f(...a)
359
384
  });
@@ -373,7 +398,7 @@ var PluginManager = class {
373
398
  id
374
399
  }, {
375
400
  F: __dxlog_file2,
376
- L: 203,
401
+ L: 210,
377
402
  S: this,
378
403
  C: (f, a) => f(...a)
379
404
  });
@@ -395,7 +420,7 @@ var PluginManager = class {
395
420
  id
396
421
  }, {
397
422
  F: __dxlog_file2,
398
- L: 220,
423
+ L: 227,
399
424
  S: this,
400
425
  C: (f, a) => f(...a)
401
426
  });
@@ -447,7 +472,7 @@ var PluginManager = class {
447
472
  id: plugin.meta.id
448
473
  }, {
449
474
  F: __dxlog_file2,
450
- L: 273,
475
+ L: 280,
451
476
  S: this,
452
477
  C: (f, a) => f(...a)
453
478
  });
@@ -462,7 +487,7 @@ var PluginManager = class {
462
487
  id
463
488
  }, {
464
489
  F: __dxlog_file2,
465
- L: 283,
490
+ L: 290,
466
491
  S: this,
467
492
  C: (f, a) => f(...a)
468
493
  });
@@ -478,7 +503,7 @@ var PluginManager = class {
478
503
  id: module.id
479
504
  }, {
480
505
  F: __dxlog_file2,
481
- L: 293,
506
+ L: 300,
482
507
  S: this,
483
508
  C: (f, a) => f(...a)
484
509
  });
@@ -493,7 +518,7 @@ var PluginManager = class {
493
518
  id
494
519
  }, {
495
520
  F: __dxlog_file2,
496
- L: 303,
521
+ L: 310,
497
522
  S: this,
498
523
  C: (f, a) => f(...a)
499
524
  });
@@ -527,7 +552,7 @@ var PluginManager = class {
527
552
  events: pendingReset
528
553
  }, {
529
554
  F: __dxlog_file2,
530
- L: 341,
555
+ L: 348,
531
556
  S: this,
532
557
  C: (f, a) => f(...a)
533
558
  });
@@ -547,7 +572,7 @@ var PluginManager = class {
547
572
  ...params
548
573
  }, {
549
574
  F: __dxlog_file2,
550
- L: 357,
575
+ L: 364,
551
576
  S: this,
552
577
  C: (f, a) => f(...a)
553
578
  });
@@ -572,7 +597,7 @@ var PluginManager = class {
572
597
  key
573
598
  }, {
574
599
  F: __dxlog_file2,
575
- L: 388,
600
+ L: 395,
576
601
  S: this,
577
602
  C: (f, a) => f(...a)
578
603
  });
@@ -586,7 +611,7 @@ var PluginManager = class {
586
611
  modules: modules.map((module) => module.id)
587
612
  }, {
588
613
  F: __dxlog_file2,
589
- L: 395,
614
+ L: 402,
590
615
  S: this,
591
616
  C: (f, a) => f(...a)
592
617
  });
@@ -594,12 +619,12 @@ var PluginManager = class {
594
619
  event: key,
595
620
  state: "activating"
596
621
  });
597
- yield* pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
622
+ yield* Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
598
623
  before: key
599
624
  })), Effect2.allWith({
600
625
  concurrency: "unbounded"
601
626
  }));
602
- const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
627
+ const getCapabilities = yield* Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
603
628
  concurrency: "unbounded"
604
629
  }), Effect2.catchAll((error) => {
605
630
  this.activation.emit({
@@ -609,15 +634,13 @@ var PluginManager = class {
609
634
  });
610
635
  return Effect2.fail(error);
611
636
  }));
612
- yield* pipe(
637
+ yield* Function.pipe(
613
638
  modules,
614
639
  Array.zip(getCapabilities),
615
640
  Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
616
- // TODO(wittjosiah): This currently can't be run in parallel.
617
- // Running this with concurrency causes races with `allOf` activation events.
618
641
  Effect2.all
619
642
  );
620
- yield* pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
643
+ yield* Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
621
644
  after: key
622
645
  })), Effect2.allWith({
623
646
  concurrency: "unbounded"
@@ -635,13 +658,74 @@ var PluginManager = class {
635
658
  key
636
659
  }, {
637
660
  F: __dxlog_file2,
638
- L: 451,
661
+ L: 458,
639
662
  S: this,
640
663
  C: (f, a) => f(...a)
641
664
  });
642
665
  return true;
643
666
  });
644
667
  }
668
+ // Memoized with _moduleMemoMap
669
+ _loadModule = (mod) => Effect2.tryPromise({
670
+ try: async () => {
671
+ const entry = this._moduleMemoMap.get(mod.id);
672
+ if (entry) {
673
+ return entry;
674
+ }
675
+ const promise2 = (async () => {
676
+ const start = performance.now();
677
+ let failed = false;
678
+ try {
679
+ log2("loading module", {
680
+ module: mod.id
681
+ }, {
682
+ F: __dxlog_file2,
683
+ L: 477,
684
+ S: this,
685
+ C: (f, a) => f(...a)
686
+ });
687
+ let activationResult = await mod.activate(this.context);
688
+ if (typeof activationResult === "function") {
689
+ activationResult = await activationResult();
690
+ }
691
+ return Array.isArray(activationResult) ? activationResult : [
692
+ activationResult
693
+ ];
694
+ } catch (error) {
695
+ failed = true;
696
+ throw error;
697
+ } finally {
698
+ performance.measure("activate-module", {
699
+ start,
700
+ end: performance.now(),
701
+ detail: {
702
+ module: mod.id
703
+ }
704
+ });
705
+ log2("loaded module", {
706
+ module: mod.id,
707
+ elapsed: performance.now() - start,
708
+ failed
709
+ }, {
710
+ F: __dxlog_file2,
711
+ L: 495,
712
+ S: this,
713
+ C: (f, a) => f(...a)
714
+ });
715
+ }
716
+ })();
717
+ this._moduleMemoMap.set(mod.id, promise2);
718
+ return promise2;
719
+ },
720
+ catch: (error) => error
721
+ }).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
722
+ module: mod.id
723
+ }, {
724
+ F: __dxlog_file2,
725
+ L: 506,
726
+ S: this,
727
+ C: (f, a) => f(...a)
728
+ }))))));
645
729
  _contributeCapabilities(module, capabilities) {
646
730
  return Effect2.gen(this, function* () {
647
731
  capabilities.forEach((capability) => {
@@ -674,7 +758,7 @@ var PluginManager = class {
674
758
  id
675
759
  }, {
676
760
  F: __dxlog_file2,
677
- L: 533,
761
+ L: 540,
678
762
  S: this,
679
763
  C: (f, a) => f(...a)
680
764
  });
@@ -684,8 +768,8 @@ var PluginManager = class {
684
768
  for (const capability of capabilities) {
685
769
  this.context.removeCapability(capability.interface, capability.implementation);
686
770
  const program = capability.deactivate?.();
687
- yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise) => Effect2.tryPromise({
688
- try: () => promise,
771
+ yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise2) => Effect2.tryPromise({
772
+ try: () => promise2,
689
773
  catch: (error) => error
690
774
  })), Match.orElse((program2) => Effect2.succeed(program2)));
691
775
  }
@@ -699,7 +783,7 @@ var PluginManager = class {
699
783
  id
700
784
  }, {
701
785
  F: __dxlog_file2,
702
- L: 560,
786
+ L: 567,
703
787
  S: this,
704
788
  C: (f, a) => f(...a)
705
789
  });
@@ -713,7 +797,7 @@ var PluginManager = class {
713
797
  key
714
798
  }, {
715
799
  F: __dxlog_file2,
716
- L: 568,
800
+ L: 575,
717
801
  S: this,
718
802
  C: (f, a) => f(...a)
719
803
  });
@@ -728,96 +812,6 @@ var PluginManager = class {
728
812
  }
729
813
  });
730
814
  }
731
- constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
732
- _define_property2(this, "activation", new Event());
733
- _define_property2(this, "context", void 0);
734
- _define_property2(this, "registry", void 0);
735
- _define_property2(this, "_state", void 0);
736
- _define_property2(this, "_pluginLoader", void 0);
737
- _define_property2(this, "_capabilities", /* @__PURE__ */ new Map());
738
- _define_property2(this, "_moduleMemoMap", /* @__PURE__ */ new Map());
739
- _define_property2(this, "_activatingEvents", Effect2.runSync(Ref.make([])));
740
- _define_property2(this, "_activatingModules", Effect2.runSync(Ref.make([])));
741
- _define_property2(this, "_loadModule", (mod) => Effect2.tryPromise({
742
- try: async () => {
743
- const entry = this._moduleMemoMap.get(mod.id);
744
- if (entry) {
745
- return entry;
746
- }
747
- const promise = (async () => {
748
- const start = performance.now();
749
- let failed = false;
750
- try {
751
- log2("loading module", {
752
- module: mod.id
753
- }, {
754
- F: __dxlog_file2,
755
- L: 470,
756
- S: this,
757
- C: (f, a) => f(...a)
758
- });
759
- let activationResult = await mod.activate(this.context);
760
- if (typeof activationResult === "function") {
761
- activationResult = await activationResult();
762
- }
763
- return Array.isArray(activationResult) ? activationResult : [
764
- activationResult
765
- ];
766
- } catch (error) {
767
- failed = true;
768
- throw error;
769
- } finally {
770
- performance.measure("activate-module", {
771
- start,
772
- end: performance.now(),
773
- detail: {
774
- module: mod.id
775
- }
776
- });
777
- log2("loaded module", {
778
- module: mod.id,
779
- elapsed: performance.now() - start,
780
- failed
781
- }, {
782
- F: __dxlog_file2,
783
- L: 488,
784
- S: this,
785
- C: (f, a) => f(...a)
786
- });
787
- }
788
- })();
789
- this._moduleMemoMap.set(mod.id, promise);
790
- return promise;
791
- },
792
- catch: (error) => error
793
- }).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
794
- module: mod.id
795
- }, {
796
- F: __dxlog_file2,
797
- L: 499,
798
- S: this,
799
- C: (f, a) => f(...a)
800
- })))))));
801
- this.registry = registry ?? Registry.make();
802
- this.context = new PluginContext({
803
- registry: this.registry,
804
- activate: (event) => this._activate(event),
805
- reset: (id) => this._reset(id)
806
- });
807
- this._pluginLoader = pluginLoader;
808
- this._state = live({
809
- plugins,
810
- core,
811
- enabled,
812
- modules: [],
813
- active: [],
814
- eventsFired: [],
815
- pendingReset: []
816
- });
817
- plugins.forEach((plugin) => this._addPlugin(plugin));
818
- core.forEach((id) => this.enable(id));
819
- enabled.forEach((id) => this.enable(id));
820
- }
821
815
  };
822
816
  var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
823
817
  const togetherFiber = yield* Effect2.fork(togetherEffect);
@@ -827,26 +821,13 @@ var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
827
821
  });
828
822
 
829
823
  // src/core/plugin.ts
830
- function _define_property3(obj, key, value) {
831
- if (key in obj) {
832
- Object.defineProperty(obj, key, {
833
- value,
834
- enumerable: true,
835
- configurable: true,
836
- writable: true
837
- });
838
- } else {
839
- obj[key] = value;
840
- }
841
- return obj;
842
- }
843
824
  var PluginModule = class {
825
+ id;
826
+ activatesOn;
827
+ activatesBefore;
828
+ activatesAfter;
829
+ activate;
844
830
  constructor(options) {
845
- _define_property3(this, "id", void 0);
846
- _define_property3(this, "activatesOn", void 0);
847
- _define_property3(this, "activatesBefore", void 0);
848
- _define_property3(this, "activatesAfter", void 0);
849
- _define_property3(this, "activate", void 0);
850
831
  this.id = options.id;
851
832
  this.activatesOn = options.activatesOn;
852
833
  this.activatesBefore = options.activatesBefore;
@@ -856,22 +837,27 @@ var PluginModule = class {
856
837
  };
857
838
  var defineModule = (options) => new PluginModule(options);
858
839
  var Plugin = class {
859
- constructor(meta, modules) {
860
- _define_property3(this, "meta", void 0);
861
- _define_property3(this, "modules", void 0);
862
- this.meta = meta;
840
+ meta;
841
+ modules;
842
+ constructor(meta2, modules) {
843
+ this.meta = meta2;
863
844
  this.modules = modules;
864
845
  }
865
846
  };
866
- var definePlugin = (meta, modules) => {
867
- return new Plugin(meta, modules);
847
+ var definePlugin = (meta2, provider) => {
848
+ const factory = (args) => {
849
+ return new Plugin(meta2, provider(args));
850
+ };
851
+ return Object.assign(factory, {
852
+ meta: meta2
853
+ });
868
854
  };
869
855
 
870
856
  // src/common/capabilities.ts
871
857
  (function(Capabilities2) {
872
858
  Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
873
859
  Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
874
- Capabilities2.RxRegistry = defineCapability("dxos.org/app-framework/capability/rx-registry");
860
+ Capabilities2.AtomRegistry = defineCapability("dxos.org/app-framework/capability/atom-registry");
875
861
  Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
876
862
  Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
877
863
  Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
@@ -886,8 +872,9 @@ var definePlugin = (meta, modules) => {
886
872
  Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
887
873
  Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
888
874
  Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
889
- Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
890
875
  Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
876
+ Capabilities2.AiServiceLayer = defineCapability("dxos.org/app-framework/capability/ai-service-factory");
877
+ Capabilities2.AiModelResolver = defineCapability("dxos.org/app-framework/capability/ai-model-resolver");
891
878
  Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
892
879
  Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
893
880
  Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
@@ -895,14 +882,14 @@ var definePlugin = (meta, modules) => {
895
882
  var Capabilities;
896
883
 
897
884
  // src/common/collaboration.ts
898
- import { Schema } from "effect";
899
- import { DataType } from "@dxos/schema";
885
+ import * as Schema from "effect/Schema";
886
+ import { ContentBlock } from "@dxos/types";
900
887
  (function(CollaborationActions2) {
901
888
  class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
902
889
  input: Schema.Struct({
903
890
  subject: Schema.Any,
904
891
  anchor: Schema.String,
905
- proposal: DataType.MessageBlock.Proposal
892
+ proposal: ContentBlock.Proposal
906
893
  }),
907
894
  output: Schema.Void
908
895
  }) {
@@ -930,7 +917,7 @@ var CollaborationActions;
930
917
  var Events;
931
918
 
932
919
  // src/common/file.ts
933
- import { Schema as Schema2 } from "effect";
920
+ import * as Schema2 from "effect/Schema";
934
921
  var defaultFileTypes = {
935
922
  images: [
936
923
  "png",
@@ -958,13 +945,13 @@ var FileInfoSchema = Schema2.Struct({
958
945
  });
959
946
 
960
947
  // src/common/layout.ts
961
- import { Schema as Schema5 } from "effect";
948
+ import * as Schema5 from "effect/Schema";
962
949
 
963
950
  // src/plugin-intent/actions.ts
964
- import { Schema as Schema4 } from "effect";
951
+ import * as Schema4 from "effect/Schema";
965
952
 
966
953
  // src/plugin-intent/intent.ts
967
- import { Schema as Schema3 } from "effect";
954
+ import * as Schema3 from "effect/Schema";
968
955
  var createIntent = (schema, data = {}, params = {}) => {
969
956
  const _ = Schema3.validateSync(schema.fields.input)(data);
970
957
  const intent = {
@@ -1007,11 +994,15 @@ var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.
1007
994
  defaultValue: Schema3.optional(Schema3.String)
1008
995
  })))));
1009
996
 
997
+ // src/plugin-intent/meta.ts
998
+ var meta = {
999
+ id: "dxos.org/plugin/intent",
1000
+ name: "Intent"
1001
+ };
1002
+
1010
1003
  // src/plugin-intent/actions.ts
1011
- var INTENT_PLUGIN = "dxos.org/plugin/intent";
1012
- var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
1013
1004
  (function(IntentAction2) {
1014
- class Track extends Schema4.TaggedClass()(`${INTENT_ACTION}/track`, {
1005
+ class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
1015
1006
  input: Schema4.Struct({
1016
1007
  intents: Schema4.Array(Schema4.String),
1017
1008
  error: Schema4.optional(Schema4.String)
@@ -1020,7 +1011,7 @@ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
1020
1011
  }) {
1021
1012
  }
1022
1013
  IntentAction2.Track = Track;
1023
- class ShowUndo extends Schema4.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
1014
+ class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
1024
1015
  input: Schema4.Struct({
1025
1016
  message: Label
1026
1017
  }),
@@ -1032,31 +1023,20 @@ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
1032
1023
  var IntentAction;
1033
1024
 
1034
1025
  // src/plugin-intent/errors.ts
1035
- function _define_property4(obj, key, value) {
1036
- if (key in obj) {
1037
- Object.defineProperty(obj, key, {
1038
- value,
1039
- enumerable: true,
1040
- configurable: true,
1041
- writable: true
1042
- });
1043
- } else {
1044
- obj[key] = value;
1045
- }
1046
- return obj;
1047
- }
1048
1026
  var BaseError = class extends Error {
1027
+ code;
1028
+ context;
1049
1029
  constructor(code, message, context) {
1050
1030
  super(message ?? code, {
1051
1031
  cause: context
1052
- }), _define_property4(this, "code", void 0), _define_property4(this, "context", void 0), this.code = code, this.context = context;
1032
+ }), this.code = code, this.context = context;
1053
1033
  this.name = code;
1054
1034
  Object.setPrototypeOf(this, new.target.prototype);
1055
1035
  }
1056
1036
  };
1057
1037
  var NoResolversError = class extends BaseError {
1058
1038
  constructor(action) {
1059
- super("NO_RESOLVERS", "No resolvers were found for the action", {
1039
+ super("NO_RESOLVERS", `No resolvers were found for the action: ${action}`, {
1060
1040
  action
1061
1041
  });
1062
1042
  }
@@ -1068,12 +1048,9 @@ var CycleDetectedError = class extends BaseError {
1068
1048
  };
1069
1049
 
1070
1050
  // src/plugin-intent/IntentPlugin.ts
1071
- var IntentPlugin = () => definePlugin({
1072
- id: INTENT_PLUGIN,
1073
- name: "Intent"
1074
- }, [
1051
+ var IntentPlugin = definePlugin(meta, () => [
1075
1052
  defineModule({
1076
- id: `${INTENT_PLUGIN}/module/dispatcher`,
1053
+ id: `${meta.id}/module/dispatcher`,
1077
1054
  // TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
1078
1055
  // This is fine for now because it's how it worked prior to capabilities api anyways.
1079
1056
  // In the future, the intent dispatcher should be able to be reset without resetting the entire app.
@@ -1081,15 +1058,14 @@ var IntentPlugin = () => definePlugin({
1081
1058
  activatesAfter: [
1082
1059
  Events.DispatcherReady
1083
1060
  ],
1084
- activate: lazy(() => import("./intent-dispatcher-NXBGPJOX.mjs"))
1061
+ activate: lazy(() => import("./intent-dispatcher-MGOJ3CHD.mjs"))
1085
1062
  })
1086
1063
  ]);
1087
1064
 
1088
1065
  // src/common/layout.ts
1089
1066
  var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
1090
- var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
1091
1067
  (function(LayoutAction2) {
1092
- LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_ACTION}/update-layout`;
1068
+ LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
1093
1069
  class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1094
1070
  input: Schema5.Struct({
1095
1071
  part: Schema5.String.annotations({
@@ -1426,7 +1402,7 @@ var LayoutAction;
1426
1402
  var createSurface = (definition) => definition;
1427
1403
 
1428
1404
  // src/common/translations.ts
1429
- import { Schema as Schema6 } from "effect";
1405
+ import * as Schema6 from "effect/Schema";
1430
1406
  var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
1431
1407
  key: Schema6.String,
1432
1408
  value: Schema6.Any
@@ -1451,14 +1427,6 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1451
1427
  const handleIntent = (intent) => Effect3.gen(function* () {
1452
1428
  const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
1453
1429
  if (candidates.length === 0) {
1454
- log3.info("no resolvers found", {
1455
- intent: intent.id
1456
- }, {
1457
- F: __dxlog_file3,
1458
- L: 200,
1459
- S: this,
1460
- C: (f, a) => f(...a)
1461
- });
1462
1430
  return yield* Effect3.fail(new NoResolversError(intent.id));
1463
1431
  }
1464
1432
  const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
@@ -1469,12 +1437,29 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1469
1437
  };
1470
1438
  });
1471
1439
  const dispatch = (intentChain, depth = 0) => {
1440
+ log3("dispatch", {
1441
+ intentChain: intentChain.all.map((i) => i.id),
1442
+ depth
1443
+ }, {
1444
+ F: __dxlog_file3,
1445
+ L: 212,
1446
+ S: void 0,
1447
+ C: (f, a) => f(...a)
1448
+ });
1472
1449
  return Effect3.gen(function* () {
1473
1450
  if (depth > executionLimit) {
1474
1451
  return yield* Effect3.fail(new CycleDetectedError());
1475
1452
  }
1476
1453
  const resultsRef = yield* Ref2.make([]);
1477
1454
  for (const intent of intentChain.all) {
1455
+ log3("processing", {
1456
+ intent
1457
+ }, {
1458
+ F: __dxlog_file3,
1459
+ L: 220,
1460
+ S: this,
1461
+ C: (f, a) => f(...a)
1462
+ });
1478
1463
  const { data: prev } = (yield* resultsRef.get)[0] ?? {};
1479
1464
  const result2 = yield* handleIntent({
1480
1465
  ...intent,
@@ -1483,6 +1468,15 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1483
1468
  ...prev
1484
1469
  }
1485
1470
  });
1471
+ log3("ok", {
1472
+ intent: intent.id,
1473
+ result: result2
1474
+ }, {
1475
+ F: __dxlog_file3,
1476
+ L: 223,
1477
+ S: this,
1478
+ C: (f, a) => f(...a)
1479
+ });
1486
1480
  yield* Ref2.update(resultsRef, (results2) => [
1487
1481
  result2,
1488
1482
  ...results2
@@ -1493,6 +1487,15 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1493
1487
  }
1494
1488
  }
1495
1489
  if (result2.error) {
1490
+ log3.error("failed", {
1491
+ intent: intent.id,
1492
+ error: result2.error
1493
+ }, {
1494
+ F: __dxlog_file3,
1495
+ L: 240,
1496
+ S: this,
1497
+ C: (f, a) => f(...a)
1498
+ });
1496
1499
  return yield* Effect3.fail(result2.error);
1497
1500
  }
1498
1501
  }
@@ -1509,10 +1512,19 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1509
1512
  return next;
1510
1513
  });
1511
1514
  if (result.undoable && isUndoable(results)) {
1512
- yield* pipe2(dispatch(createIntent(IntentAction.ShowUndo, {
1515
+ yield* Function2.pipe(dispatch(createIntent(IntentAction.ShowUndo, {
1513
1516
  message: result.undoable.message
1514
1517
  })), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
1515
1518
  }
1519
+ log3("done", {
1520
+ intent: intentChain.all.map((i) => i.id),
1521
+ result: result.data
1522
+ }, {
1523
+ F: __dxlog_file3,
1524
+ L: 270,
1525
+ S: this,
1526
+ C: (f, a) => f(...a)
1527
+ });
1516
1528
  return result.data;
1517
1529
  });
1518
1530
  };
@@ -1522,7 +1534,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1522
1534
  })).catch((error) => {
1523
1535
  log3.catch(error, void 0, {
1524
1536
  F: __dxlog_file3,
1525
- L: 272,
1537
+ L: 279,
1526
1538
  S: void 0,
1527
1539
  C: (f, a) => f(...a)
1528
1540
  });
@@ -1537,7 +1549,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1537
1549
  const last = history.findLastIndex(isUndoable);
1538
1550
  const result = last !== -1 ? history[last] : void 0;
1539
1551
  if (result) {
1540
- const all = result.map(({ _intent, undoable }) => {
1552
+ const all2 = result.map(({ _intent, undoable }) => {
1541
1553
  const data = _intent.data;
1542
1554
  const undoData = undoable?.data ?? {};
1543
1555
  return {
@@ -1550,9 +1562,9 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1550
1562
  };
1551
1563
  });
1552
1564
  const intent = {
1553
- first: all[0],
1554
- last: all.at(-1),
1555
- all
1565
+ first: all2[0],
1566
+ last: all2.at(-1),
1567
+ all: all2
1556
1568
  };
1557
1569
  yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
1558
1570
  return yield* dispatch(intent);
@@ -1575,7 +1587,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1575
1587
  };
1576
1588
  var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
1577
1589
  var defaultPromise = () => Effect3.runPromise(defaultEffect());
1578
- var intent_dispatcher_default = (context) => {
1590
+ var intent_dispatcher_default = ((context) => {
1579
1591
  const state = live2({
1580
1592
  dispatch: defaultEffect,
1581
1593
  dispatchPromise: defaultPromise,
@@ -1597,7 +1609,7 @@ var intent_dispatcher_default = (context) => {
1597
1609
  state.undo = undo;
1598
1610
  state.undoPromise = undoPromise;
1599
1611
  return contributes(Capabilities.IntentDispatcher, state);
1600
- };
1612
+ });
1601
1613
 
1602
1614
  export {
1603
1615
  defineCapability,
@@ -1624,8 +1636,6 @@ export {
1624
1636
  createIntent,
1625
1637
  chain,
1626
1638
  Label,
1627
- INTENT_PLUGIN,
1628
- INTENT_ACTION,
1629
1639
  IntentAction,
1630
1640
  BaseError,
1631
1641
  NoResolversError,
@@ -1634,12 +1644,10 @@ export {
1634
1644
  createDispatcher,
1635
1645
  intent_dispatcher_default,
1636
1646
  IntentPlugin,
1637
- LAYOUT_PLUGIN,
1638
- LAYOUT_ACTION,
1639
1647
  LayoutAction,
1640
1648
  createSurface,
1641
1649
  ResourceKey,
1642
1650
  ResourceLanguage,
1643
1651
  Resource
1644
1652
  };
1645
- //# sourceMappingURL=chunk-F63ZRXMK.mjs.map
1653
+ //# sourceMappingURL=chunk-XJZGUJ3H.mjs.map