@sanity/workbench 0.1.0-alpha.19 → 0.1.0-alpha.20

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/system.d.ts CHANGED
@@ -41,20 +41,59 @@ export declare function createOSOptions(input: OSInput): {
41
41
  };
42
42
 
43
43
  /**
44
+ * A module exposed by an application's federation remote.
45
+ *
44
46
  * @public
45
47
  */
46
- export declare interface LoadedRemoteModule {
47
- render: (
48
- rootElement: HTMLElement,
49
- options?: RemoteRenderOptions,
50
- ) => () => void;
48
+ export declare interface FederatedModuleRef {
49
+ /**
50
+ * Fully-qualified module id — `${appId}/${expose}`, e.g.
51
+ * `studio-1/views/feed/panel` (a view component) or `studio-1/App` (the
52
+ * full-page view). The remote's name is its first segment.
53
+ */
54
+ moduleId: string;
55
+ /** The remote's `mf-manifest.json` URL (served from the app's origin). */
56
+ entry: string;
57
+ }
58
+
59
+ /**
60
+ * A loaded render-contract module. `TProps` is what its `render` accepts —
61
+ * `RemoteRenderOptions` for an application's full-page view, the view's props
62
+ * for a dock-panel component.
63
+ * @public
64
+ */
65
+ export declare interface LoadedRemoteModule<TProps = RemoteRenderOptions> {
66
+ render: (rootElement: HTMLElement, props?: TProps) => () => void;
51
67
  }
52
68
 
69
+ /**
70
+ * {@link loadRemoteModule} with the render-empty-on-failure policy: any failure
71
+ * resolves to `null` (and logs), so every caller handles a missing interface
72
+ * the same way — a panel renders empty, a worker doesn't spawn.
73
+ *
74
+ * @public
75
+ */
76
+ export declare function loadFederatedModule<T>(
77
+ instance: FederationInstance,
78
+ ref: FederatedModuleRef,
79
+ ): Promise<T | null>;
80
+
53
81
  /**
54
82
  * @internal
55
83
  */
56
84
  export declare interface LogoutInput extends OSBaseInput {}
57
85
 
86
+ /**
87
+ * Thrown by a render consumer (e.g. the island) when a loaded module doesn't
88
+ * expose a `render` function. Render-specific — `remoteLogic` itself is
89
+ * shape-agnostic, so this lives with the consumer that needs the contract, not
90
+ * the loader. Surfaced via `RemoteError.cause` for consumers that discriminate.
91
+ * @public
92
+ */
93
+ export declare class ModuleShapeError extends Error {
94
+ constructor(remoteId: string);
95
+ }
96
+
58
97
  /**
59
98
  * The sanity OS machine, responsible for managing the global state of the OS.
60
99
  * @public
@@ -92,12 +131,12 @@ export declare const os: StateMachine<
92
131
  },
93
132
  | {
94
133
  type: "remote.load.request";
95
- id: string;
134
+ moduleId: string;
96
135
  entry: string;
97
136
  }
98
137
  | {
99
138
  type: "remote.settled";
100
- id: string;
139
+ moduleId: string;
101
140
  status: "loaded" | "error";
102
141
  },
103
142
  {
@@ -105,7 +144,7 @@ export declare const os: StateMachine<
105
144
  | ActorRefFromLogic<
106
145
  StateMachine<
107
146
  RemoteInput & {
108
- module: LoadedRemoteModule | null;
147
+ module: unknown;
109
148
  error: RemoteError | null;
110
149
  },
111
150
  AnyEventObject,
@@ -113,7 +152,7 @@ export declare const os: StateMachine<
113
152
  [x: string]:
114
153
  | ActorRefFromLogic<
115
154
  PromiseActorLogic<
116
- LoadedRemoteModule,
155
+ unknown,
117
156
  RemoteInput,
118
157
  EventObject
119
158
  >
@@ -123,7 +162,7 @@ export declare const os: StateMachine<
123
162
  {
124
163
  src: "load";
125
164
  logic: PromiseActorLogic<
126
- LoadedRemoteModule,
165
+ unknown,
127
166
  RemoteInput,
128
167
  EventObject
129
168
  >;
@@ -132,7 +171,7 @@ export declare const os: StateMachine<
132
171
  | {
133
172
  type: "setModule";
134
173
  params: {
135
- module: LoadedRemoteModule;
174
+ module: unknown;
136
175
  };
137
176
  }
138
177
  | {
@@ -165,34 +204,26 @@ export declare const os: StateMachine<
165
204
  src: "remote";
166
205
  logic: StateMachine<
167
206
  RemoteInput & {
168
- module: LoadedRemoteModule | null;
207
+ module: unknown;
169
208
  error: RemoteError | null;
170
209
  },
171
210
  AnyEventObject,
172
211
  {
173
212
  [x: string]:
174
213
  | ActorRefFromLogic<
175
- PromiseActorLogic<
176
- LoadedRemoteModule,
177
- RemoteInput,
178
- EventObject
179
- >
214
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
180
215
  >
181
216
  | undefined;
182
217
  },
183
218
  {
184
219
  src: "load";
185
- logic: PromiseActorLogic<
186
- LoadedRemoteModule,
187
- RemoteInput,
188
- EventObject
189
- >;
220
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
190
221
  id: string | undefined;
191
222
  },
192
223
  | {
193
224
  type: "setModule";
194
225
  params: {
195
- module: LoadedRemoteModule;
226
+ module: unknown;
196
227
  };
197
228
  }
198
229
  | {
@@ -223,20 +254,22 @@ export declare const os: StateMachine<
223
254
  {
224
255
  type: "spawnRemote";
225
256
  params: {
226
- id: string;
257
+ moduleId: string;
227
258
  entry: string;
228
259
  };
229
260
  },
230
261
  {
231
262
  type: "remoteNotKnown";
232
263
  params: {
233
- id: string;
264
+ moduleId: string;
234
265
  };
235
266
  },
236
267
  never,
237
268
  {},
238
269
  string,
239
- NonReducibleUnknown,
270
+ {
271
+ instance: FederationInstance;
272
+ },
240
273
  NonReducibleUnknown,
241
274
  EventObject,
242
275
  MetaObject,
@@ -246,6 +279,393 @@ export declare const os: StateMachine<
246
279
  >
247
280
  >
248
281
  | undefined;
282
+ services?:
283
+ | ActorRefFromLogic<
284
+ StateMachine<
285
+ {
286
+ instance: FederationInstance;
287
+ children: Map<string, ActorRefFrom<serviceLogic>>;
288
+ },
289
+ {
290
+ type: "services.sync";
291
+ services: ReadonlyArray<{
292
+ appId: string;
293
+ serviceName: string;
294
+ entry: string;
295
+ }>;
296
+ },
297
+ {
298
+ [x: string]:
299
+ | ActorRefFromLogic<
300
+ StateMachine<
301
+ ServiceInput & {
302
+ workerUrl: string | null;
303
+ },
304
+ AnyEventObject,
305
+ {
306
+ [x: string]:
307
+ | ActorRefFromLogic<
308
+ StateMachine<
309
+ RemoteInput & {
310
+ module: unknown;
311
+ error: RemoteError | null;
312
+ },
313
+ AnyEventObject,
314
+ {
315
+ [x: string]:
316
+ | ActorRefFromLogic<
317
+ PromiseActorLogic<
318
+ unknown,
319
+ RemoteInput,
320
+ EventObject
321
+ >
322
+ >
323
+ | undefined;
324
+ },
325
+ {
326
+ src: "load";
327
+ logic: PromiseActorLogic<
328
+ unknown,
329
+ RemoteInput,
330
+ EventObject
331
+ >;
332
+ id: string | undefined;
333
+ },
334
+ | {
335
+ type: "setModule";
336
+ params: {
337
+ module: unknown;
338
+ };
339
+ }
340
+ | {
341
+ type: "setError";
342
+ params: {
343
+ error: unknown;
344
+ };
345
+ },
346
+ never,
347
+ never,
348
+ "error" | "loading" | "loaded",
349
+ "loading" | "ready" | "failed",
350
+ RemoteInput,
351
+ NonReducibleUnknown,
352
+ EventObject,
353
+ MetaObject,
354
+ {
355
+ id: "remote";
356
+ states: {
357
+ readonly loading: {};
358
+ readonly loaded: {};
359
+ readonly error: {};
360
+ };
361
+ }
362
+ >
363
+ >
364
+ | ActorRefFromLogic<
365
+ CallbackActorLogic<
366
+ {
367
+ type: string;
368
+ },
369
+ {
370
+ key: string;
371
+ serviceName: string;
372
+ workerUrl: string;
373
+ },
374
+ EventObject
375
+ >
376
+ >
377
+ | undefined;
378
+ },
379
+ | {
380
+ src: "loadInterface";
381
+ logic: StateMachine<
382
+ RemoteInput & {
383
+ module: unknown;
384
+ error: RemoteError | null;
385
+ },
386
+ AnyEventObject,
387
+ {
388
+ [x: string]:
389
+ | ActorRefFromLogic<
390
+ PromiseActorLogic<
391
+ unknown,
392
+ RemoteInput,
393
+ EventObject
394
+ >
395
+ >
396
+ | undefined;
397
+ },
398
+ {
399
+ src: "load";
400
+ logic: PromiseActorLogic<
401
+ unknown,
402
+ RemoteInput,
403
+ EventObject
404
+ >;
405
+ id: string | undefined;
406
+ },
407
+ | {
408
+ type: "setModule";
409
+ params: {
410
+ module: unknown;
411
+ };
412
+ }
413
+ | {
414
+ type: "setError";
415
+ params: {
416
+ error: unknown;
417
+ };
418
+ },
419
+ never,
420
+ never,
421
+ "error" | "loading" | "loaded",
422
+ "loading" | "ready" | "failed",
423
+ RemoteInput,
424
+ NonReducibleUnknown,
425
+ EventObject,
426
+ MetaObject,
427
+ {
428
+ id: "remote";
429
+ states: {
430
+ readonly loading: {};
431
+ readonly loaded: {};
432
+ readonly error: {};
433
+ };
434
+ }
435
+ >;
436
+ id: string | undefined;
437
+ }
438
+ | {
439
+ src: "runWorker";
440
+ logic: CallbackActorLogic<
441
+ {
442
+ type: string;
443
+ },
444
+ {
445
+ key: string;
446
+ serviceName: string;
447
+ workerUrl: string;
448
+ },
449
+ EventObject
450
+ >;
451
+ id: string | undefined;
452
+ },
453
+ never,
454
+ never,
455
+ never,
456
+ "error" | "loading" | "running",
457
+ "loading" | "failed" | "running",
458
+ ServiceInput,
459
+ NonReducibleUnknown,
460
+ EventObject,
461
+ MetaObject,
462
+ {
463
+ id: "service";
464
+ states: {
465
+ readonly loading: {};
466
+ readonly running: {};
467
+ readonly error: {};
468
+ };
469
+ }
470
+ >
471
+ >
472
+ | undefined;
473
+ },
474
+ {
475
+ src: "service";
476
+ logic: StateMachine<
477
+ ServiceInput & {
478
+ workerUrl: string | null;
479
+ },
480
+ AnyEventObject,
481
+ {
482
+ [x: string]:
483
+ | ActorRefFromLogic<
484
+ StateMachine<
485
+ RemoteInput & {
486
+ module: unknown;
487
+ error: RemoteError | null;
488
+ },
489
+ AnyEventObject,
490
+ {
491
+ [x: string]:
492
+ | ActorRefFromLogic<
493
+ PromiseActorLogic<
494
+ unknown,
495
+ RemoteInput,
496
+ EventObject
497
+ >
498
+ >
499
+ | undefined;
500
+ },
501
+ {
502
+ src: "load";
503
+ logic: PromiseActorLogic<
504
+ unknown,
505
+ RemoteInput,
506
+ EventObject
507
+ >;
508
+ id: string | undefined;
509
+ },
510
+ | {
511
+ type: "setModule";
512
+ params: {
513
+ module: unknown;
514
+ };
515
+ }
516
+ | {
517
+ type: "setError";
518
+ params: {
519
+ error: unknown;
520
+ };
521
+ },
522
+ never,
523
+ never,
524
+ "error" | "loading" | "loaded",
525
+ "loading" | "ready" | "failed",
526
+ RemoteInput,
527
+ NonReducibleUnknown,
528
+ EventObject,
529
+ MetaObject,
530
+ {
531
+ id: "remote";
532
+ states: {
533
+ readonly loading: {};
534
+ readonly loaded: {};
535
+ readonly error: {};
536
+ };
537
+ }
538
+ >
539
+ >
540
+ | ActorRefFromLogic<
541
+ CallbackActorLogic<
542
+ {
543
+ type: string;
544
+ },
545
+ {
546
+ key: string;
547
+ serviceName: string;
548
+ workerUrl: string;
549
+ },
550
+ EventObject
551
+ >
552
+ >
553
+ | undefined;
554
+ },
555
+ | {
556
+ src: "loadInterface";
557
+ logic: StateMachine<
558
+ RemoteInput & {
559
+ module: unknown;
560
+ error: RemoteError | null;
561
+ },
562
+ AnyEventObject,
563
+ {
564
+ [x: string]:
565
+ | ActorRefFromLogic<
566
+ PromiseActorLogic<
567
+ unknown,
568
+ RemoteInput,
569
+ EventObject
570
+ >
571
+ >
572
+ | undefined;
573
+ },
574
+ {
575
+ src: "load";
576
+ logic: PromiseActorLogic<
577
+ unknown,
578
+ RemoteInput,
579
+ EventObject
580
+ >;
581
+ id: string | undefined;
582
+ },
583
+ | {
584
+ type: "setModule";
585
+ params: {
586
+ module: unknown;
587
+ };
588
+ }
589
+ | {
590
+ type: "setError";
591
+ params: {
592
+ error: unknown;
593
+ };
594
+ },
595
+ never,
596
+ never,
597
+ "error" | "loading" | "loaded",
598
+ "loading" | "ready" | "failed",
599
+ RemoteInput,
600
+ NonReducibleUnknown,
601
+ EventObject,
602
+ MetaObject,
603
+ {
604
+ id: "remote";
605
+ states: {
606
+ readonly loading: {};
607
+ readonly loaded: {};
608
+ readonly error: {};
609
+ };
610
+ }
611
+ >;
612
+ id: string | undefined;
613
+ }
614
+ | {
615
+ src: "runWorker";
616
+ logic: CallbackActorLogic<
617
+ {
618
+ type: string;
619
+ },
620
+ {
621
+ key: string;
622
+ serviceName: string;
623
+ workerUrl: string;
624
+ },
625
+ EventObject
626
+ >;
627
+ id: string | undefined;
628
+ },
629
+ never,
630
+ never,
631
+ never,
632
+ "error" | "loading" | "running",
633
+ "loading" | "failed" | "running",
634
+ ServiceInput,
635
+ NonReducibleUnknown,
636
+ EventObject,
637
+ MetaObject,
638
+ {
639
+ id: "service";
640
+ states: {
641
+ readonly loading: {};
642
+ readonly running: {};
643
+ readonly error: {};
644
+ };
645
+ }
646
+ >;
647
+ id: string | undefined;
648
+ },
649
+ {
650
+ type: "syncServices";
651
+ params: NonReducibleUnknown;
652
+ },
653
+ never,
654
+ never,
655
+ {},
656
+ string,
657
+ {
658
+ instance: FederationInstance;
659
+ },
660
+ NonReducibleUnknown,
661
+ EventObject,
662
+ MetaObject,
663
+ {
664
+ id: "services";
665
+ }
666
+ >
667
+ >
668
+ | undefined;
249
669
  telemetry?:
250
670
  | ActorRefFromLogic<
251
671
  StateMachine<
@@ -486,12 +906,12 @@ export declare const os: StateMachine<
486
906
  },
487
907
  | {
488
908
  type: "remote.load.request";
489
- id: string;
909
+ moduleId: string;
490
910
  entry: string;
491
911
  }
492
912
  | {
493
913
  type: "remote.settled";
494
- id: string;
914
+ moduleId: string;
495
915
  status: "loaded" | "error";
496
916
  },
497
917
  {
@@ -499,34 +919,26 @@ export declare const os: StateMachine<
499
919
  | ActorRefFromLogic<
500
920
  StateMachine<
501
921
  RemoteInput & {
502
- module: LoadedRemoteModule | null;
922
+ module: unknown;
503
923
  error: RemoteError | null;
504
924
  },
505
925
  AnyEventObject,
506
926
  {
507
927
  [x: string]:
508
928
  | ActorRefFromLogic<
509
- PromiseActorLogic<
510
- LoadedRemoteModule,
511
- RemoteInput,
512
- EventObject
513
- >
929
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
514
930
  >
515
931
  | undefined;
516
932
  },
517
933
  {
518
934
  src: "load";
519
- logic: PromiseActorLogic<
520
- LoadedRemoteModule,
521
- RemoteInput,
522
- EventObject
523
- >;
935
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
524
936
  id: string | undefined;
525
937
  },
526
938
  | {
527
939
  type: "setModule";
528
940
  params: {
529
- module: LoadedRemoteModule;
941
+ module: unknown;
530
942
  };
531
943
  }
532
944
  | {
@@ -559,34 +971,26 @@ export declare const os: StateMachine<
559
971
  src: "remote";
560
972
  logic: StateMachine<
561
973
  RemoteInput & {
562
- module: LoadedRemoteModule | null;
974
+ module: unknown;
563
975
  error: RemoteError | null;
564
976
  },
565
977
  AnyEventObject,
566
978
  {
567
979
  [x: string]:
568
980
  | ActorRefFromLogic<
569
- PromiseActorLogic<
570
- LoadedRemoteModule,
571
- RemoteInput,
572
- EventObject
573
- >
981
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
574
982
  >
575
983
  | undefined;
576
984
  },
577
985
  {
578
986
  src: "load";
579
- logic: PromiseActorLogic<
580
- LoadedRemoteModule,
581
- RemoteInput,
582
- EventObject
583
- >;
987
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
584
988
  id: string | undefined;
585
989
  },
586
990
  | {
587
991
  type: "setModule";
588
992
  params: {
589
- module: LoadedRemoteModule;
993
+ module: unknown;
590
994
  };
591
995
  }
592
996
  | {
@@ -617,20 +1021,22 @@ export declare const os: StateMachine<
617
1021
  {
618
1022
  type: "spawnRemote";
619
1023
  params: {
620
- id: string;
1024
+ moduleId: string;
621
1025
  entry: string;
622
1026
  };
623
1027
  },
624
1028
  {
625
1029
  type: "remoteNotKnown";
626
1030
  params: {
627
- id: string;
1031
+ moduleId: string;
628
1032
  };
629
1033
  },
630
1034
  never,
631
1035
  {},
632
1036
  string,
633
- NonReducibleUnknown,
1037
+ {
1038
+ instance: FederationInstance;
1039
+ },
634
1040
  NonReducibleUnknown,
635
1041
  EventObject,
636
1042
  MetaObject,
@@ -641,48 +1047,427 @@ export declare const os: StateMachine<
641
1047
  id: "remotes";
642
1048
  }
643
1049
  | {
644
- src: "telemetry";
1050
+ src: "services";
645
1051
  logic: StateMachine<
646
1052
  {
647
- instance: SanityInstance;
648
- store: TelemetryStore<WorkbenchUserProperties> | null;
649
- userProperties: WorkbenchUserProperties;
1053
+ instance: FederationInstance;
1054
+ children: Map<string, ActorRefFrom<serviceLogic>>;
1055
+ },
1056
+ {
1057
+ type: "services.sync";
1058
+ services: ReadonlyArray<{
1059
+ appId: string;
1060
+ serviceName: string;
1061
+ entry: string;
1062
+ }>;
650
1063
  },
651
- | {
652
- type: "telemetry.start";
653
- }
654
- | {
655
- type: "telemetry.stop";
656
- },
657
1064
  {
658
1065
  [x: string]:
659
1066
  | ActorRefFromLogic<
660
- PromiseActorLogic<
661
- {
662
- status: ConsentStatus;
1067
+ StateMachine<
1068
+ ServiceInput & {
1069
+ workerUrl: string | null;
663
1070
  },
1071
+ AnyEventObject,
664
1072
  {
665
- instance: SanityInstance;
1073
+ [x: string]:
1074
+ | ActorRefFromLogic<
1075
+ StateMachine<
1076
+ RemoteInput & {
1077
+ module: unknown;
1078
+ error: RemoteError | null;
1079
+ },
1080
+ AnyEventObject,
1081
+ {
1082
+ [x: string]:
1083
+ | ActorRefFromLogic<
1084
+ PromiseActorLogic<
1085
+ unknown,
1086
+ RemoteInput,
1087
+ EventObject
1088
+ >
1089
+ >
1090
+ | undefined;
1091
+ },
1092
+ {
1093
+ src: "load";
1094
+ logic: PromiseActorLogic<
1095
+ unknown,
1096
+ RemoteInput,
1097
+ EventObject
1098
+ >;
1099
+ id: string | undefined;
1100
+ },
1101
+ | {
1102
+ type: "setModule";
1103
+ params: {
1104
+ module: unknown;
1105
+ };
1106
+ }
1107
+ | {
1108
+ type: "setError";
1109
+ params: {
1110
+ error: unknown;
1111
+ };
1112
+ },
1113
+ never,
1114
+ never,
1115
+ "error" | "loading" | "loaded",
1116
+ "loading" | "ready" | "failed",
1117
+ RemoteInput,
1118
+ NonReducibleUnknown,
1119
+ EventObject,
1120
+ MetaObject,
1121
+ {
1122
+ id: "remote";
1123
+ states: {
1124
+ readonly loading: {};
1125
+ readonly loaded: {};
1126
+ readonly error: {};
1127
+ };
1128
+ }
1129
+ >
1130
+ >
1131
+ | ActorRefFromLogic<
1132
+ CallbackActorLogic<
1133
+ {
1134
+ type: string;
1135
+ },
1136
+ {
1137
+ key: string;
1138
+ serviceName: string;
1139
+ workerUrl: string;
1140
+ },
1141
+ EventObject
1142
+ >
1143
+ >
1144
+ | undefined;
666
1145
  },
667
- EventObject
668
- >
669
- >
670
- | undefined;
671
- },
672
- {
673
- src: "checkConsent";
674
- logic: PromiseActorLogic<
675
- {
676
- status: ConsentStatus;
677
- },
678
- {
679
- instance: SanityInstance;
680
- },
681
- EventObject
682
- >;
683
- id: string | undefined;
684
- },
685
- | {
1146
+ | {
1147
+ src: "loadInterface";
1148
+ logic: StateMachine<
1149
+ RemoteInput & {
1150
+ module: unknown;
1151
+ error: RemoteError | null;
1152
+ },
1153
+ AnyEventObject,
1154
+ {
1155
+ [x: string]:
1156
+ | ActorRefFromLogic<
1157
+ PromiseActorLogic<
1158
+ unknown,
1159
+ RemoteInput,
1160
+ EventObject
1161
+ >
1162
+ >
1163
+ | undefined;
1164
+ },
1165
+ {
1166
+ src: "load";
1167
+ logic: PromiseActorLogic<
1168
+ unknown,
1169
+ RemoteInput,
1170
+ EventObject
1171
+ >;
1172
+ id: string | undefined;
1173
+ },
1174
+ | {
1175
+ type: "setModule";
1176
+ params: {
1177
+ module: unknown;
1178
+ };
1179
+ }
1180
+ | {
1181
+ type: "setError";
1182
+ params: {
1183
+ error: unknown;
1184
+ };
1185
+ },
1186
+ never,
1187
+ never,
1188
+ "error" | "loading" | "loaded",
1189
+ "loading" | "ready" | "failed",
1190
+ RemoteInput,
1191
+ NonReducibleUnknown,
1192
+ EventObject,
1193
+ MetaObject,
1194
+ {
1195
+ id: "remote";
1196
+ states: {
1197
+ readonly loading: {};
1198
+ readonly loaded: {};
1199
+ readonly error: {};
1200
+ };
1201
+ }
1202
+ >;
1203
+ id: string | undefined;
1204
+ }
1205
+ | {
1206
+ src: "runWorker";
1207
+ logic: CallbackActorLogic<
1208
+ {
1209
+ type: string;
1210
+ },
1211
+ {
1212
+ key: string;
1213
+ serviceName: string;
1214
+ workerUrl: string;
1215
+ },
1216
+ EventObject
1217
+ >;
1218
+ id: string | undefined;
1219
+ },
1220
+ never,
1221
+ never,
1222
+ never,
1223
+ "error" | "loading" | "running",
1224
+ "loading" | "failed" | "running",
1225
+ ServiceInput,
1226
+ NonReducibleUnknown,
1227
+ EventObject,
1228
+ MetaObject,
1229
+ {
1230
+ id: "service";
1231
+ states: {
1232
+ readonly loading: {};
1233
+ readonly running: {};
1234
+ readonly error: {};
1235
+ };
1236
+ }
1237
+ >
1238
+ >
1239
+ | undefined;
1240
+ },
1241
+ {
1242
+ src: "service";
1243
+ logic: StateMachine<
1244
+ ServiceInput & {
1245
+ workerUrl: string | null;
1246
+ },
1247
+ AnyEventObject,
1248
+ {
1249
+ [x: string]:
1250
+ | ActorRefFromLogic<
1251
+ StateMachine<
1252
+ RemoteInput & {
1253
+ module: unknown;
1254
+ error: RemoteError | null;
1255
+ },
1256
+ AnyEventObject,
1257
+ {
1258
+ [x: string]:
1259
+ | ActorRefFromLogic<
1260
+ PromiseActorLogic<
1261
+ unknown,
1262
+ RemoteInput,
1263
+ EventObject
1264
+ >
1265
+ >
1266
+ | undefined;
1267
+ },
1268
+ {
1269
+ src: "load";
1270
+ logic: PromiseActorLogic<
1271
+ unknown,
1272
+ RemoteInput,
1273
+ EventObject
1274
+ >;
1275
+ id: string | undefined;
1276
+ },
1277
+ | {
1278
+ type: "setModule";
1279
+ params: {
1280
+ module: unknown;
1281
+ };
1282
+ }
1283
+ | {
1284
+ type: "setError";
1285
+ params: {
1286
+ error: unknown;
1287
+ };
1288
+ },
1289
+ never,
1290
+ never,
1291
+ "error" | "loading" | "loaded",
1292
+ "loading" | "ready" | "failed",
1293
+ RemoteInput,
1294
+ NonReducibleUnknown,
1295
+ EventObject,
1296
+ MetaObject,
1297
+ {
1298
+ id: "remote";
1299
+ states: {
1300
+ readonly loading: {};
1301
+ readonly loaded: {};
1302
+ readonly error: {};
1303
+ };
1304
+ }
1305
+ >
1306
+ >
1307
+ | ActorRefFromLogic<
1308
+ CallbackActorLogic<
1309
+ {
1310
+ type: string;
1311
+ },
1312
+ {
1313
+ key: string;
1314
+ serviceName: string;
1315
+ workerUrl: string;
1316
+ },
1317
+ EventObject
1318
+ >
1319
+ >
1320
+ | undefined;
1321
+ },
1322
+ | {
1323
+ src: "loadInterface";
1324
+ logic: StateMachine<
1325
+ RemoteInput & {
1326
+ module: unknown;
1327
+ error: RemoteError | null;
1328
+ },
1329
+ AnyEventObject,
1330
+ {
1331
+ [x: string]:
1332
+ | ActorRefFromLogic<
1333
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
1334
+ >
1335
+ | undefined;
1336
+ },
1337
+ {
1338
+ src: "load";
1339
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1340
+ id: string | undefined;
1341
+ },
1342
+ | {
1343
+ type: "setModule";
1344
+ params: {
1345
+ module: unknown;
1346
+ };
1347
+ }
1348
+ | {
1349
+ type: "setError";
1350
+ params: {
1351
+ error: unknown;
1352
+ };
1353
+ },
1354
+ never,
1355
+ never,
1356
+ "error" | "loading" | "loaded",
1357
+ "loading" | "ready" | "failed",
1358
+ RemoteInput,
1359
+ NonReducibleUnknown,
1360
+ EventObject,
1361
+ MetaObject,
1362
+ {
1363
+ id: "remote";
1364
+ states: {
1365
+ readonly loading: {};
1366
+ readonly loaded: {};
1367
+ readonly error: {};
1368
+ };
1369
+ }
1370
+ >;
1371
+ id: string | undefined;
1372
+ }
1373
+ | {
1374
+ src: "runWorker";
1375
+ logic: CallbackActorLogic<
1376
+ {
1377
+ type: string;
1378
+ },
1379
+ {
1380
+ key: string;
1381
+ serviceName: string;
1382
+ workerUrl: string;
1383
+ },
1384
+ EventObject
1385
+ >;
1386
+ id: string | undefined;
1387
+ },
1388
+ never,
1389
+ never,
1390
+ never,
1391
+ "error" | "loading" | "running",
1392
+ "loading" | "failed" | "running",
1393
+ ServiceInput,
1394
+ NonReducibleUnknown,
1395
+ EventObject,
1396
+ MetaObject,
1397
+ {
1398
+ id: "service";
1399
+ states: {
1400
+ readonly loading: {};
1401
+ readonly running: {};
1402
+ readonly error: {};
1403
+ };
1404
+ }
1405
+ >;
1406
+ id: string | undefined;
1407
+ },
1408
+ {
1409
+ type: "syncServices";
1410
+ params: NonReducibleUnknown;
1411
+ },
1412
+ never,
1413
+ never,
1414
+ {},
1415
+ string,
1416
+ {
1417
+ instance: FederationInstance;
1418
+ },
1419
+ NonReducibleUnknown,
1420
+ EventObject,
1421
+ MetaObject,
1422
+ {
1423
+ id: "services";
1424
+ }
1425
+ >;
1426
+ id: "services";
1427
+ }
1428
+ | {
1429
+ src: "telemetry";
1430
+ logic: StateMachine<
1431
+ {
1432
+ instance: SanityInstance;
1433
+ store: TelemetryStore<WorkbenchUserProperties> | null;
1434
+ userProperties: WorkbenchUserProperties;
1435
+ },
1436
+ | {
1437
+ type: "telemetry.start";
1438
+ }
1439
+ | {
1440
+ type: "telemetry.stop";
1441
+ },
1442
+ {
1443
+ [x: string]:
1444
+ | ActorRefFromLogic<
1445
+ PromiseActorLogic<
1446
+ {
1447
+ status: ConsentStatus;
1448
+ },
1449
+ {
1450
+ instance: SanityInstance;
1451
+ },
1452
+ EventObject
1453
+ >
1454
+ >
1455
+ | undefined;
1456
+ },
1457
+ {
1458
+ src: "checkConsent";
1459
+ logic: PromiseActorLogic<
1460
+ {
1461
+ status: ConsentStatus;
1462
+ },
1463
+ {
1464
+ instance: SanityInstance;
1465
+ },
1466
+ EventObject
1467
+ >;
1468
+ id: string | undefined;
1469
+ },
1470
+ | {
686
1471
  type: "createStore";
687
1472
  params: NonReducibleUnknown;
688
1473
  }
@@ -926,6 +1711,12 @@ declare interface OSBaseInput extends Pick<OSContext, "instance"> {}
926
1711
 
927
1712
  declare type OSContext = {
928
1713
  instance: SanityInstance;
1714
+ /**
1715
+ * The single module-federation instance every interface loads through —
1716
+ * shared by the `remotes` (views) and `services` (workers) supervisors so an
1717
+ * app's remote is registered once for all its interfaces.
1718
+ */
1719
+ federationInstance: FederationInstance;
929
1720
  userProperties: WorkbenchUserProperties;
930
1721
  systemPreferencesAdapter: SystemPreferencesAdapter | undefined;
931
1722
  };
@@ -935,7 +1726,8 @@ declare type OSInput = WorkbenchUserProperties & {
935
1726
  };
936
1727
 
937
1728
  declare type RemoteContext = RemoteInput & {
938
- module: LoadedRemoteModule | null;
1729
+ /** The loaded module, shape-agnostic each consumer narrows it. @see {@link RemoteModuleByInterfaceType} */
1730
+ module: unknown;
939
1731
  error: RemoteError | null;
940
1732
  };
941
1733
 
@@ -951,18 +1743,22 @@ export declare interface RemoteError {
951
1743
  * @internal
952
1744
  */
953
1745
  export declare interface RemoteInput {
954
- id: string;
1746
+ /** Fully-qualified module id — `${appId}/${expose}`. One child per moduleId. */
1747
+ moduleId: string;
955
1748
  entry: string;
956
1749
  instance: FederationInstance;
957
1750
  }
958
1751
 
959
1752
  /**
960
- * Lifecycle machine for a single federated application remote.
1753
+ * Lifecycle machine for a single federated interface module — an application's
1754
+ * `App` entry, one view component, or a worker service's loader. Interface-
1755
+ * agnostic: it loads and tracks any module, leaving the shape contract
1756
+ * (render vs. worker URL) to the consumer.
961
1757
  *
962
- * Spawned by the {@link remotesLogic} supervisor on demand. Each instance
963
- * owns one remote's load lifecycle: `loading` → `loaded | error`. Tags
964
- * (`loading` / `ready` / `failed`) drive the UI contract — state names
965
- * are internal.
1758
+ * Spawned by the {@link remotesLogic} supervisor on demand, one per remote id
1759
+ * (`${appId}/${moduleId}`). Each instance owns one module's load lifecycle:
1760
+ * `loading` → `loaded | error`. Tags (`loading` / `ready` / `failed`) drive the
1761
+ * UI contract — state names are internal.
966
1762
  *
967
1763
  * The machine sends a `remote.settled` event to its parent on entry to
968
1764
  * either terminal state, reserved for future supervision/retry.
@@ -974,20 +1770,18 @@ declare const remoteLogic: StateMachine<
974
1770
  AnyEventObject,
975
1771
  {
976
1772
  [x: string]:
977
- | ActorRefFromLogic<
978
- PromiseActorLogic<LoadedRemoteModule, RemoteInput, EventObject>
979
- >
1773
+ | ActorRefFromLogic<PromiseActorLogic<unknown, RemoteInput, EventObject>>
980
1774
  | undefined;
981
1775
  },
982
1776
  {
983
1777
  src: "load";
984
- logic: PromiseActorLogic<LoadedRemoteModule, RemoteInput, EventObject>;
1778
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
985
1779
  id: string | undefined;
986
1780
  },
987
1781
  | {
988
1782
  type: "setModule";
989
1783
  params: {
990
- module: LoadedRemoteModule;
1784
+ module: unknown;
991
1785
  };
992
1786
  }
993
1787
  | {
@@ -1014,6 +1808,21 @@ declare const remoteLogic: StateMachine<
1014
1808
  }
1015
1809
  >;
1016
1810
 
1811
+ /**
1812
+ * The federated-module shape each interface type exposes, keyed by
1813
+ * `interface_type`. Every interface — `panel`, `app`, `worker` — loads through
1814
+ * the same {@link remoteLogic} lifecycle; this maps what its loaded module looks
1815
+ * like so each consumer narrows the machine's shape-agnostic `module` to the
1816
+ * right type: a render contract for `panel`/`app` (rendered by an island), a
1817
+ * worker loader for `worker` (run as a Web Worker, never rendered).
1818
+ * @public
1819
+ */
1820
+ export declare interface RemoteModuleByInterfaceType {
1821
+ panel: LoadedRemoteModule;
1822
+ app: LoadedRemoteModule;
1823
+ worker: ServiceLoaderModule;
1824
+ }
1825
+
1017
1826
  /**
1018
1827
  * @public
1019
1828
  */
@@ -1027,6 +1836,204 @@ export declare interface RemoteRenderOptions {
1027
1836
  unstable_temporaryToken?: string | null;
1028
1837
  }
1029
1838
 
1839
+ declare type ServiceContext = ServiceInput & {
1840
+ /** Resolved worker-bundle URL, absolute on the app origin. */
1841
+ workerUrl: string | null;
1842
+ };
1843
+
1844
+ /**
1845
+ * @internal
1846
+ */
1847
+ declare interface ServiceInput {
1848
+ /** Stable child key, `${appId}:${serviceName}`. */
1849
+ key: string;
1850
+ appId: string;
1851
+ serviceName: string;
1852
+ /** The app's `mf-manifest.json` URL — the federation remote entry. */
1853
+ entry: string;
1854
+ instance: FederationInstance;
1855
+ }
1856
+
1857
+ /**
1858
+ * A worker service's loader module — the `worker` interface's expose. Carries
1859
+ * the worker bundle URL (root-relative to the app origin) for the host to
1860
+ * bootstrap, not a render function; the services counterpart of
1861
+ * {@link LoadedRemoteModule}.
1862
+ * @public
1863
+ */
1864
+ export declare interface ServiceLoaderModule {
1865
+ url: string;
1866
+ type: string;
1867
+ name: string;
1868
+ version: number;
1869
+ }
1870
+
1871
+ /**
1872
+ * Lifecycle machine for a single background service worker.
1873
+ *
1874
+ * Spawned by the {@link servicesLogic} supervisor, one per `(app, service)`.
1875
+ * `loading` loads the worker's loader module through the shared
1876
+ * {@link remoteLogic} lifecycle — the same machine every interface (panel, app,
1877
+ * worker) loads through — and reads the bundle URL off it. A worker isn't a
1878
+ * render module, so it's never handed to an island; `running` bootstraps it as
1879
+ * a Web Worker from that URL.
1880
+ *
1881
+ * @internal
1882
+ */
1883
+ declare const serviceLogic: StateMachine<
1884
+ ServiceContext,
1885
+ AnyEventObject,
1886
+ {
1887
+ [x: string]:
1888
+ | ActorRefFromLogic<
1889
+ StateMachine<
1890
+ RemoteInput & {
1891
+ module: unknown;
1892
+ error: RemoteError | null;
1893
+ },
1894
+ AnyEventObject,
1895
+ {
1896
+ [x: string]:
1897
+ | ActorRefFromLogic<
1898
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
1899
+ >
1900
+ | undefined;
1901
+ },
1902
+ {
1903
+ src: "load";
1904
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1905
+ id: string | undefined;
1906
+ },
1907
+ | {
1908
+ type: "setModule";
1909
+ params: {
1910
+ module: unknown;
1911
+ };
1912
+ }
1913
+ | {
1914
+ type: "setError";
1915
+ params: {
1916
+ error: unknown;
1917
+ };
1918
+ },
1919
+ never,
1920
+ never,
1921
+ "error" | "loading" | "loaded",
1922
+ "loading" | "ready" | "failed",
1923
+ RemoteInput,
1924
+ NonReducibleUnknown,
1925
+ EventObject,
1926
+ MetaObject,
1927
+ {
1928
+ id: "remote";
1929
+ states: {
1930
+ readonly loading: {};
1931
+ readonly loaded: {};
1932
+ readonly error: {};
1933
+ };
1934
+ }
1935
+ >
1936
+ >
1937
+ | ActorRefFromLogic<
1938
+ CallbackActorLogic<
1939
+ {
1940
+ type: string;
1941
+ },
1942
+ {
1943
+ key: string;
1944
+ serviceName: string;
1945
+ workerUrl: string;
1946
+ },
1947
+ EventObject
1948
+ >
1949
+ >
1950
+ | undefined;
1951
+ },
1952
+ | {
1953
+ src: "loadInterface";
1954
+ logic: StateMachine<
1955
+ RemoteInput & {
1956
+ module: unknown;
1957
+ error: RemoteError | null;
1958
+ },
1959
+ AnyEventObject,
1960
+ {
1961
+ [x: string]:
1962
+ | ActorRefFromLogic<
1963
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
1964
+ >
1965
+ | undefined;
1966
+ },
1967
+ {
1968
+ src: "load";
1969
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1970
+ id: string | undefined;
1971
+ },
1972
+ | {
1973
+ type: "setModule";
1974
+ params: {
1975
+ module: unknown;
1976
+ };
1977
+ }
1978
+ | {
1979
+ type: "setError";
1980
+ params: {
1981
+ error: unknown;
1982
+ };
1983
+ },
1984
+ never,
1985
+ never,
1986
+ "error" | "loading" | "loaded",
1987
+ "loading" | "ready" | "failed",
1988
+ RemoteInput,
1989
+ NonReducibleUnknown,
1990
+ EventObject,
1991
+ MetaObject,
1992
+ {
1993
+ id: "remote";
1994
+ states: {
1995
+ readonly loading: {};
1996
+ readonly loaded: {};
1997
+ readonly error: {};
1998
+ };
1999
+ }
2000
+ >;
2001
+ id: string | undefined;
2002
+ }
2003
+ | {
2004
+ src: "runWorker";
2005
+ logic: CallbackActorLogic<
2006
+ {
2007
+ type: string;
2008
+ },
2009
+ {
2010
+ key: string;
2011
+ serviceName: string;
2012
+ workerUrl: string;
2013
+ },
2014
+ EventObject
2015
+ >;
2016
+ id: string | undefined;
2017
+ },
2018
+ never,
2019
+ never,
2020
+ never,
2021
+ "error" | "loading" | "running",
2022
+ "loading" | "failed" | "running",
2023
+ ServiceInput,
2024
+ NonReducibleUnknown,
2025
+ EventObject,
2026
+ MetaObject,
2027
+ {
2028
+ id: "service";
2029
+ states: {
2030
+ readonly loading: {};
2031
+ readonly running: {};
2032
+ readonly error: {};
2033
+ };
2034
+ }
2035
+ >;
2036
+
1030
2037
  /**
1031
2038
  * Adapter interface the host implements to give the system-preferences
1032
2039
  * machine access to the user's environment (OS color scheme, persistent