@sanity/workbench 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (52) hide show
  1. package/README.md +24 -0
  2. package/dist/_chunks-es/index.js +39 -0
  3. package/dist/_chunks-es/index.js.map +1 -0
  4. package/dist/_chunks-es/module-federation.js +59 -0
  5. package/dist/_chunks-es/module-federation.js.map +1 -0
  6. package/dist/_chunks-es/studio.js +892 -0
  7. package/dist/_chunks-es/studio.js.map +1 -0
  8. package/dist/_internal.d.ts +16 -4
  9. package/dist/_internal.js +34 -27
  10. package/dist/_internal.js.map +1 -1
  11. package/dist/core.d.ts +2250 -0
  12. package/dist/core.js +74 -0
  13. package/dist/core.js.map +1 -0
  14. package/dist/system.d.ts +2135 -0
  15. package/dist/system.js +887 -0
  16. package/dist/system.js.map +1 -0
  17. package/package.json +34 -6
  18. package/src/_exports/core.ts +1 -0
  19. package/src/_exports/system.ts +1 -0
  20. package/src/_internal/index.ts +2 -1
  21. package/src/_internal/render.ts +72 -43
  22. package/src/core/applications/application-list.ts +104 -0
  23. package/src/core/applications/application.ts +177 -0
  24. package/src/core/applications/interface.ts +126 -0
  25. package/src/core/canvases.ts +92 -0
  26. package/src/core/config.ts +34 -0
  27. package/src/core/env.ts +43 -0
  28. package/src/core/index.ts +13 -0
  29. package/src/core/log/index.ts +125 -0
  30. package/src/core/media-libraries.ts +93 -0
  31. package/src/core/organizations.ts +115 -0
  32. package/src/core/projects.ts +114 -0
  33. package/src/core/shared/urls.ts +129 -0
  34. package/src/core/user-applications/core-app.ts +148 -0
  35. package/src/core/user-applications/studios/index.ts +3 -0
  36. package/src/core/user-applications/studios/schemas.ts +128 -0
  37. package/src/core/user-applications/studios/studio.ts +533 -0
  38. package/src/core/user-applications/studios/workspace.ts +156 -0
  39. package/src/core/user-applications/user-application.ts +222 -0
  40. package/src/system/auth.machine.ts +223 -0
  41. package/src/system/index.ts +22 -0
  42. package/src/system/inspect.ts +40 -0
  43. package/src/system/load-federated-module.ts +53 -0
  44. package/src/system/module-federation.ts +116 -0
  45. package/src/system/remote.machine.ts +219 -0
  46. package/src/system/remotes.machine.ts +92 -0
  47. package/src/system/root.machine.ts +224 -0
  48. package/src/system/service.machine.ts +207 -0
  49. package/src/system/services.machine.ts +120 -0
  50. package/src/system/system-preferences.machine.ts +215 -0
  51. package/src/system/telemetry.machine.ts +179 -0
  52. package/src/_internal/render.test.ts +0 -18
@@ -0,0 +1,2135 @@
1
+ import { ActorRefFrom } from "xstate";
2
+ import { ActorRefFromLogic } from "xstate";
3
+ import { AnyEventObject } from "xstate";
4
+ import { AuthState } from "@sanity/sdk";
5
+ import { AuthStateType } from "@sanity/sdk";
6
+ import { CallbackActorLogic } from "xstate";
7
+ import { ConsentStatus } from "@sanity/telemetry";
8
+ import { CurrentUser } from "@sanity/sdk";
9
+ import { EventObject } from "xstate";
10
+ import { InspectionEvent } from "xstate";
11
+ import { MetaObject } from "xstate";
12
+ import { NonReducibleUnknown } from "xstate";
13
+ import { ObservableActorLogic } from "xstate";
14
+ import { PromiseActorLogic } from "xstate";
15
+ import { SanityInstance } from "@sanity/sdk";
16
+ import { StateMachine } from "xstate";
17
+ import { TelemetryStore } from "@sanity/telemetry";
18
+
19
+ /**
20
+ * @internal
21
+ */
22
+ export declare interface AuthInput extends OSBaseInput {}
23
+
24
+ declare type ColorScheme = "light" | "dark";
25
+
26
+ declare type ColorSchemePreference = "system" | ColorScheme;
27
+
28
+ /**
29
+ * Creates a set of default options for the OS machine. Forwards the workbench
30
+ * user properties to the machine's input and wires the structured-logging
31
+ * `inspect` callback. Browser-specific concerns (color-scheme seeding,
32
+ * persistence) live in the {@link SystemPreferencesAdapter} the host passes
33
+ * via `systemPreferencesAdapter`.
34
+ * @public
35
+ */
36
+ export declare function createOSOptions(input: OSInput): {
37
+ id: string;
38
+ input: OSInput;
39
+ inspect: (event: InspectionEvent) => void;
40
+ };
41
+
42
+ /**
43
+ * A module exposed by an application's federation remote.
44
+ *
45
+ * @public
46
+ */
47
+ export declare interface FederatedModuleRef {
48
+ /**
49
+ * Fully-qualified module id — `${appId}/${expose}`, e.g.
50
+ * `studio-1/views/feed/panel` (a view component) or `studio-1/App` (the
51
+ * full-page view). The remote's name is its first segment.
52
+ */
53
+ moduleId: string;
54
+ /** The remote's `mf-manifest.json` URL (served from the app's origin). */
55
+ entry: string;
56
+ }
57
+
58
+ /**
59
+ * @public
60
+ */
61
+ declare interface FederationInstance {
62
+ registerRemotes(remotes: FederationRemote[]): void;
63
+ loadRemote<T>(id: string): Promise<T | null>;
64
+ }
65
+
66
+ /**
67
+ * @public
68
+ */
69
+ declare type FederationRemote = {
70
+ name: string;
71
+ entry: string;
72
+ };
73
+
74
+ /**
75
+ * A loaded render-contract module. `TProps` is what its `render` accepts —
76
+ * `RemoteRenderOptions` for an application's full-page view, the view's props
77
+ * for a dock-panel component.
78
+ * @public
79
+ */
80
+ export declare interface LoadedRemoteModule<TProps = RemoteRenderOptions> {
81
+ render: (rootElement: HTMLElement, props?: TProps) => () => void;
82
+ }
83
+
84
+ /**
85
+ * {@link loadRemoteModule} with the render-empty-on-failure policy: any failure
86
+ * resolves to `null` (and logs), so every caller handles a missing interface
87
+ * the same way — a panel renders empty, a worker doesn't spawn.
88
+ *
89
+ * @public
90
+ */
91
+ export declare function loadFederatedModule<T>(
92
+ instance: FederationInstance,
93
+ ref: FederatedModuleRef,
94
+ ): Promise<T | null>;
95
+
96
+ /**
97
+ * @internal
98
+ */
99
+ export declare interface LogoutInput extends OSBaseInput {}
100
+
101
+ /**
102
+ * Thrown by a render consumer (e.g. the island) when a loaded module doesn't
103
+ * expose a `render` function. Render-specific — `remoteLogic` itself is
104
+ * shape-agnostic, so this lives with the consumer that needs the contract, not
105
+ * the loader. Surfaced via `RemoteError.cause` for consumers that discriminate.
106
+ * @public
107
+ */
108
+ export declare class ModuleShapeError extends Error {
109
+ constructor(remoteId: string);
110
+ }
111
+
112
+ /**
113
+ * The sanity OS machine, responsible for managing the global state of the OS.
114
+ * @public
115
+ * @example
116
+ * ```ts
117
+ * import { os, createOSOptions } from "@sanity/workbench/system";
118
+ * import { useActor } from "@xstate/react";
119
+ *
120
+ * const [state, send] = useActor(os, createOSOptions({
121
+ * version: "1.0.0",
122
+ * organizationId: "...",
123
+ * environment: "production",
124
+ * userAgent: navigator.userAgent,
125
+ * }));
126
+ * ```
127
+ */
128
+ export declare const os: StateMachine<
129
+ OSContext,
130
+ | {
131
+ type: "boot.auth.ready";
132
+ }
133
+ | {
134
+ type: "boot.auth.failed";
135
+ }
136
+ | {
137
+ type: "boot.telemetry.ready";
138
+ },
139
+ {
140
+ remotes?:
141
+ | ActorRefFromLogic<
142
+ StateMachine<
143
+ {
144
+ instance: FederationInstance;
145
+ children: Map<string, ActorRefFrom<remoteLogic>>;
146
+ },
147
+ | {
148
+ type: "remote.load.request";
149
+ moduleId: string;
150
+ entry: string;
151
+ }
152
+ | {
153
+ type: "remote.settled";
154
+ moduleId: string;
155
+ status: "loaded" | "error";
156
+ },
157
+ {
158
+ [x: string]:
159
+ | ActorRefFromLogic<
160
+ StateMachine<
161
+ RemoteInput & {
162
+ module: unknown;
163
+ error: RemoteError | null;
164
+ },
165
+ AnyEventObject,
166
+ {
167
+ [x: string]:
168
+ | ActorRefFromLogic<
169
+ PromiseActorLogic<
170
+ unknown,
171
+ RemoteInput,
172
+ EventObject
173
+ >
174
+ >
175
+ | undefined;
176
+ },
177
+ {
178
+ src: "load";
179
+ logic: PromiseActorLogic<
180
+ unknown,
181
+ RemoteInput,
182
+ EventObject
183
+ >;
184
+ id: string | undefined;
185
+ },
186
+ | {
187
+ type: "setModule";
188
+ params: {
189
+ module: unknown;
190
+ };
191
+ }
192
+ | {
193
+ type: "setError";
194
+ params: {
195
+ error: unknown;
196
+ };
197
+ },
198
+ never,
199
+ never,
200
+ "error" | "loading" | "loaded",
201
+ "loading" | "ready" | "failed",
202
+ RemoteInput,
203
+ NonReducibleUnknown,
204
+ EventObject,
205
+ MetaObject,
206
+ {
207
+ id: "remote";
208
+ states: {
209
+ readonly loading: {};
210
+ readonly loaded: {};
211
+ readonly error: {};
212
+ };
213
+ }
214
+ >
215
+ >
216
+ | undefined;
217
+ },
218
+ {
219
+ src: "remote";
220
+ logic: StateMachine<
221
+ RemoteInput & {
222
+ module: unknown;
223
+ error: RemoteError | null;
224
+ },
225
+ AnyEventObject,
226
+ {
227
+ [x: string]:
228
+ | ActorRefFromLogic<
229
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
230
+ >
231
+ | undefined;
232
+ },
233
+ {
234
+ src: "load";
235
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
236
+ id: string | undefined;
237
+ },
238
+ | {
239
+ type: "setModule";
240
+ params: {
241
+ module: unknown;
242
+ };
243
+ }
244
+ | {
245
+ type: "setError";
246
+ params: {
247
+ error: unknown;
248
+ };
249
+ },
250
+ never,
251
+ never,
252
+ "error" | "loading" | "loaded",
253
+ "loading" | "ready" | "failed",
254
+ RemoteInput,
255
+ NonReducibleUnknown,
256
+ EventObject,
257
+ MetaObject,
258
+ {
259
+ id: "remote";
260
+ states: {
261
+ readonly loading: {};
262
+ readonly loaded: {};
263
+ readonly error: {};
264
+ };
265
+ }
266
+ >;
267
+ id: string | undefined;
268
+ },
269
+ {
270
+ type: "spawnRemote";
271
+ params: {
272
+ moduleId: string;
273
+ entry: string;
274
+ };
275
+ },
276
+ {
277
+ type: "remoteNotKnown";
278
+ params: {
279
+ moduleId: string;
280
+ };
281
+ },
282
+ never,
283
+ {},
284
+ string,
285
+ {
286
+ instance: FederationInstance;
287
+ },
288
+ NonReducibleUnknown,
289
+ EventObject,
290
+ MetaObject,
291
+ {
292
+ id: "remotes";
293
+ }
294
+ >
295
+ >
296
+ | undefined;
297
+ services?:
298
+ | ActorRefFromLogic<
299
+ StateMachine<
300
+ {
301
+ instance: FederationInstance;
302
+ children: Map<string, ActorRefFrom<serviceLogic>>;
303
+ },
304
+ {
305
+ type: "services.sync";
306
+ services: ReadonlyArray<{
307
+ appId: string;
308
+ serviceName: string;
309
+ entry: string;
310
+ }>;
311
+ },
312
+ {
313
+ [x: string]:
314
+ | ActorRefFromLogic<
315
+ StateMachine<
316
+ ServiceInput & {
317
+ workerUrl: string | null;
318
+ },
319
+ AnyEventObject,
320
+ {
321
+ [x: string]:
322
+ | ActorRefFromLogic<
323
+ StateMachine<
324
+ RemoteInput & {
325
+ module: unknown;
326
+ error: RemoteError | null;
327
+ },
328
+ AnyEventObject,
329
+ {
330
+ [x: string]:
331
+ | ActorRefFromLogic<
332
+ PromiseActorLogic<
333
+ unknown,
334
+ RemoteInput,
335
+ EventObject
336
+ >
337
+ >
338
+ | undefined;
339
+ },
340
+ {
341
+ src: "load";
342
+ logic: PromiseActorLogic<
343
+ unknown,
344
+ RemoteInput,
345
+ EventObject
346
+ >;
347
+ id: string | undefined;
348
+ },
349
+ | {
350
+ type: "setModule";
351
+ params: {
352
+ module: unknown;
353
+ };
354
+ }
355
+ | {
356
+ type: "setError";
357
+ params: {
358
+ error: unknown;
359
+ };
360
+ },
361
+ never,
362
+ never,
363
+ "error" | "loading" | "loaded",
364
+ "loading" | "ready" | "failed",
365
+ RemoteInput,
366
+ NonReducibleUnknown,
367
+ EventObject,
368
+ MetaObject,
369
+ {
370
+ id: "remote";
371
+ states: {
372
+ readonly loading: {};
373
+ readonly loaded: {};
374
+ readonly error: {};
375
+ };
376
+ }
377
+ >
378
+ >
379
+ | ActorRefFromLogic<
380
+ CallbackActorLogic<
381
+ {
382
+ type: string;
383
+ },
384
+ {
385
+ key: string;
386
+ serviceName: string;
387
+ workerUrl: string;
388
+ },
389
+ EventObject
390
+ >
391
+ >
392
+ | undefined;
393
+ },
394
+ | {
395
+ src: "loadInterface";
396
+ logic: StateMachine<
397
+ RemoteInput & {
398
+ module: unknown;
399
+ error: RemoteError | null;
400
+ },
401
+ AnyEventObject,
402
+ {
403
+ [x: string]:
404
+ | ActorRefFromLogic<
405
+ PromiseActorLogic<
406
+ unknown,
407
+ RemoteInput,
408
+ EventObject
409
+ >
410
+ >
411
+ | undefined;
412
+ },
413
+ {
414
+ src: "load";
415
+ logic: PromiseActorLogic<
416
+ unknown,
417
+ RemoteInput,
418
+ EventObject
419
+ >;
420
+ id: string | undefined;
421
+ },
422
+ | {
423
+ type: "setModule";
424
+ params: {
425
+ module: unknown;
426
+ };
427
+ }
428
+ | {
429
+ type: "setError";
430
+ params: {
431
+ error: unknown;
432
+ };
433
+ },
434
+ never,
435
+ never,
436
+ "error" | "loading" | "loaded",
437
+ "loading" | "ready" | "failed",
438
+ RemoteInput,
439
+ NonReducibleUnknown,
440
+ EventObject,
441
+ MetaObject,
442
+ {
443
+ id: "remote";
444
+ states: {
445
+ readonly loading: {};
446
+ readonly loaded: {};
447
+ readonly error: {};
448
+ };
449
+ }
450
+ >;
451
+ id: string | undefined;
452
+ }
453
+ | {
454
+ src: "runWorker";
455
+ logic: CallbackActorLogic<
456
+ {
457
+ type: string;
458
+ },
459
+ {
460
+ key: string;
461
+ serviceName: string;
462
+ workerUrl: string;
463
+ },
464
+ EventObject
465
+ >;
466
+ id: string | undefined;
467
+ },
468
+ never,
469
+ never,
470
+ never,
471
+ "error" | "loading" | "running",
472
+ "loading" | "failed" | "running",
473
+ ServiceInput,
474
+ NonReducibleUnknown,
475
+ EventObject,
476
+ MetaObject,
477
+ {
478
+ id: "service";
479
+ states: {
480
+ readonly loading: {};
481
+ readonly running: {};
482
+ readonly error: {};
483
+ };
484
+ }
485
+ >
486
+ >
487
+ | undefined;
488
+ },
489
+ {
490
+ src: "service";
491
+ logic: StateMachine<
492
+ ServiceInput & {
493
+ workerUrl: string | null;
494
+ },
495
+ AnyEventObject,
496
+ {
497
+ [x: string]:
498
+ | ActorRefFromLogic<
499
+ StateMachine<
500
+ RemoteInput & {
501
+ module: unknown;
502
+ error: RemoteError | null;
503
+ },
504
+ AnyEventObject,
505
+ {
506
+ [x: string]:
507
+ | ActorRefFromLogic<
508
+ PromiseActorLogic<
509
+ unknown,
510
+ RemoteInput,
511
+ EventObject
512
+ >
513
+ >
514
+ | undefined;
515
+ },
516
+ {
517
+ src: "load";
518
+ logic: PromiseActorLogic<
519
+ unknown,
520
+ RemoteInput,
521
+ EventObject
522
+ >;
523
+ id: string | undefined;
524
+ },
525
+ | {
526
+ type: "setModule";
527
+ params: {
528
+ module: unknown;
529
+ };
530
+ }
531
+ | {
532
+ type: "setError";
533
+ params: {
534
+ error: unknown;
535
+ };
536
+ },
537
+ never,
538
+ never,
539
+ "error" | "loading" | "loaded",
540
+ "loading" | "ready" | "failed",
541
+ RemoteInput,
542
+ NonReducibleUnknown,
543
+ EventObject,
544
+ MetaObject,
545
+ {
546
+ id: "remote";
547
+ states: {
548
+ readonly loading: {};
549
+ readonly loaded: {};
550
+ readonly error: {};
551
+ };
552
+ }
553
+ >
554
+ >
555
+ | ActorRefFromLogic<
556
+ CallbackActorLogic<
557
+ {
558
+ type: string;
559
+ },
560
+ {
561
+ key: string;
562
+ serviceName: string;
563
+ workerUrl: string;
564
+ },
565
+ EventObject
566
+ >
567
+ >
568
+ | undefined;
569
+ },
570
+ | {
571
+ src: "loadInterface";
572
+ logic: StateMachine<
573
+ RemoteInput & {
574
+ module: unknown;
575
+ error: RemoteError | null;
576
+ },
577
+ AnyEventObject,
578
+ {
579
+ [x: string]:
580
+ | ActorRefFromLogic<
581
+ PromiseActorLogic<
582
+ unknown,
583
+ RemoteInput,
584
+ EventObject
585
+ >
586
+ >
587
+ | undefined;
588
+ },
589
+ {
590
+ src: "load";
591
+ logic: PromiseActorLogic<
592
+ unknown,
593
+ RemoteInput,
594
+ EventObject
595
+ >;
596
+ id: string | undefined;
597
+ },
598
+ | {
599
+ type: "setModule";
600
+ params: {
601
+ module: unknown;
602
+ };
603
+ }
604
+ | {
605
+ type: "setError";
606
+ params: {
607
+ error: unknown;
608
+ };
609
+ },
610
+ never,
611
+ never,
612
+ "error" | "loading" | "loaded",
613
+ "loading" | "ready" | "failed",
614
+ RemoteInput,
615
+ NonReducibleUnknown,
616
+ EventObject,
617
+ MetaObject,
618
+ {
619
+ id: "remote";
620
+ states: {
621
+ readonly loading: {};
622
+ readonly loaded: {};
623
+ readonly error: {};
624
+ };
625
+ }
626
+ >;
627
+ id: string | undefined;
628
+ }
629
+ | {
630
+ src: "runWorker";
631
+ logic: CallbackActorLogic<
632
+ {
633
+ type: string;
634
+ },
635
+ {
636
+ key: string;
637
+ serviceName: string;
638
+ workerUrl: string;
639
+ },
640
+ EventObject
641
+ >;
642
+ id: string | undefined;
643
+ },
644
+ never,
645
+ never,
646
+ never,
647
+ "error" | "loading" | "running",
648
+ "loading" | "failed" | "running",
649
+ ServiceInput,
650
+ NonReducibleUnknown,
651
+ EventObject,
652
+ MetaObject,
653
+ {
654
+ id: "service";
655
+ states: {
656
+ readonly loading: {};
657
+ readonly running: {};
658
+ readonly error: {};
659
+ };
660
+ }
661
+ >;
662
+ id: string | undefined;
663
+ },
664
+ {
665
+ type: "syncServices";
666
+ params: NonReducibleUnknown;
667
+ },
668
+ never,
669
+ never,
670
+ {},
671
+ string,
672
+ {
673
+ instance: FederationInstance;
674
+ },
675
+ NonReducibleUnknown,
676
+ EventObject,
677
+ MetaObject,
678
+ {
679
+ id: "services";
680
+ }
681
+ >
682
+ >
683
+ | undefined;
684
+ telemetry?:
685
+ | ActorRefFromLogic<
686
+ StateMachine<
687
+ {
688
+ instance: SanityInstance;
689
+ store: TelemetryStore<WorkbenchUserProperties> | null;
690
+ userProperties: WorkbenchUserProperties;
691
+ },
692
+ | {
693
+ type: "telemetry.start";
694
+ }
695
+ | {
696
+ type: "telemetry.stop";
697
+ },
698
+ {
699
+ [x: string]:
700
+ | ActorRefFromLogic<
701
+ PromiseActorLogic<
702
+ {
703
+ status: ConsentStatus;
704
+ },
705
+ {
706
+ instance: SanityInstance;
707
+ },
708
+ EventObject
709
+ >
710
+ >
711
+ | undefined;
712
+ },
713
+ {
714
+ src: "checkConsent";
715
+ logic: PromiseActorLogic<
716
+ {
717
+ status: ConsentStatus;
718
+ },
719
+ {
720
+ instance: SanityInstance;
721
+ },
722
+ EventObject
723
+ >;
724
+ id: string | undefined;
725
+ },
726
+ | {
727
+ type: "createStore";
728
+ params: NonReducibleUnknown;
729
+ }
730
+ | {
731
+ type: "teardownStore";
732
+ params: unknown;
733
+ },
734
+ {
735
+ type: "isConsentGranted";
736
+ params: {
737
+ status: ConsentStatus;
738
+ };
739
+ },
740
+ never,
741
+ "active" | "stopped" | "denied" | "idle" | "checkingConsent",
742
+ string,
743
+ TelemetryInput,
744
+ NonReducibleUnknown,
745
+ EventObject,
746
+ MetaObject,
747
+ {
748
+ id: "telemetry";
749
+ states: {
750
+ readonly idle: {};
751
+ readonly checkingConsent: {};
752
+ readonly active: {};
753
+ readonly stopped: {};
754
+ readonly denied: {};
755
+ };
756
+ }
757
+ >
758
+ >
759
+ | undefined;
760
+ auth?:
761
+ | ActorRefFromLogic<
762
+ StateMachine<
763
+ {
764
+ instance: SanityInstance;
765
+ token: string | null;
766
+ currentUser: CurrentUser | null;
767
+ error: unknown;
768
+ },
769
+ {
770
+ type: "auth.logout";
771
+ },
772
+ {
773
+ [x: string]:
774
+ | ActorRefFromLogic<
775
+ ObservableActorLogic<AuthState, AuthInput, EventObject>
776
+ >
777
+ | ActorRefFromLogic<
778
+ PromiseActorLogic<void, LogoutInput, EventObject>
779
+ >
780
+ | undefined;
781
+ },
782
+ | {
783
+ src: "authState";
784
+ logic: ObservableActorLogic<AuthState, AuthInput, EventObject>;
785
+ id: string | undefined;
786
+ }
787
+ | {
788
+ src: "logoutActor";
789
+ logic: PromiseActorLogic<void, LogoutInput, EventObject>;
790
+ id: string | undefined;
791
+ },
792
+ | {
793
+ type: "setError";
794
+ params: {
795
+ error: unknown;
796
+ };
797
+ }
798
+ | {
799
+ type: "setLoggedIn";
800
+ params: {
801
+ token: string;
802
+ currentUser: CurrentUser;
803
+ };
804
+ }
805
+ | {
806
+ type: "clearAuth";
807
+ params: NonReducibleUnknown;
808
+ },
809
+ | {
810
+ type: "isLoggedInComplete";
811
+ params: {
812
+ state: AuthState | undefined;
813
+ };
814
+ }
815
+ | {
816
+ type: "isAuthState";
817
+ params: {
818
+ state: AuthState | undefined;
819
+ type: AuthStateType;
820
+ };
821
+ },
822
+ "authTimeout",
823
+ "init" | AuthStateType | "logging-out",
824
+ "error" | "authenticating" | "authenticated",
825
+ AuthInput,
826
+ NonReducibleUnknown,
827
+ EventObject,
828
+ MetaObject,
829
+ {
830
+ id: "auth";
831
+ states: {
832
+ readonly init: {};
833
+ readonly "logging-in": {};
834
+ readonly "logged-in": {};
835
+ readonly "logging-out": {};
836
+ readonly "logged-out": {};
837
+ readonly error: {};
838
+ };
839
+ }
840
+ >
841
+ >
842
+ | undefined;
843
+ "system-preferences"?:
844
+ | ActorRefFromLogic<
845
+ StateMachine<
846
+ SystemPreferencesContext & {
847
+ adapter: SystemPreferencesAdapter | undefined;
848
+ },
849
+ | {
850
+ type: "preferredColorScheme.set";
851
+ preferredColorScheme: ("light" | "dark") | "system";
852
+ }
853
+ | {
854
+ type: "osColorScheme.set";
855
+ osColorScheme: "light" | "dark";
856
+ },
857
+ {
858
+ [x: string]:
859
+ | ActorRefFromLogic<
860
+ CallbackActorLogic<
861
+ {
862
+ type: "preferredColorScheme.set";
863
+ preferredColorScheme: ("light" | "dark") | "system";
864
+ },
865
+ SystemPreferencesAdapter | undefined,
866
+ SystemPreferencesEvent
867
+ >
868
+ >
869
+ | undefined;
870
+ },
871
+ {
872
+ src: "adapterBridge";
873
+ logic: CallbackActorLogic<
874
+ {
875
+ type: "preferredColorScheme.set";
876
+ preferredColorScheme: ("light" | "dark") | "system";
877
+ },
878
+ SystemPreferencesAdapter | undefined,
879
+ SystemPreferencesEvent
880
+ >;
881
+ id: string | undefined;
882
+ },
883
+ | {
884
+ type: "setPreferredColorScheme";
885
+ params: {
886
+ preferredColorScheme: ("light" | "dark") | "system";
887
+ };
888
+ }
889
+ | {
890
+ type: "setOsColorScheme";
891
+ params: {
892
+ osColorScheme: "light" | "dark";
893
+ };
894
+ },
895
+ never,
896
+ never,
897
+ "ready",
898
+ string,
899
+ {
900
+ adapter?: SystemPreferencesAdapter;
901
+ },
902
+ NonReducibleUnknown,
903
+ EventObject,
904
+ MetaObject,
905
+ {
906
+ id: "system-preferences";
907
+ states: {
908
+ readonly ready: {};
909
+ };
910
+ }
911
+ >
912
+ >
913
+ | undefined;
914
+ },
915
+ | {
916
+ src: "remotes";
917
+ logic: StateMachine<
918
+ {
919
+ instance: FederationInstance;
920
+ children: Map<string, ActorRefFrom<remoteLogic>>;
921
+ },
922
+ | {
923
+ type: "remote.load.request";
924
+ moduleId: string;
925
+ entry: string;
926
+ }
927
+ | {
928
+ type: "remote.settled";
929
+ moduleId: string;
930
+ status: "loaded" | "error";
931
+ },
932
+ {
933
+ [x: string]:
934
+ | ActorRefFromLogic<
935
+ StateMachine<
936
+ RemoteInput & {
937
+ module: unknown;
938
+ error: RemoteError | null;
939
+ },
940
+ AnyEventObject,
941
+ {
942
+ [x: string]:
943
+ | ActorRefFromLogic<
944
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
945
+ >
946
+ | undefined;
947
+ },
948
+ {
949
+ src: "load";
950
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
951
+ id: string | undefined;
952
+ },
953
+ | {
954
+ type: "setModule";
955
+ params: {
956
+ module: unknown;
957
+ };
958
+ }
959
+ | {
960
+ type: "setError";
961
+ params: {
962
+ error: unknown;
963
+ };
964
+ },
965
+ never,
966
+ never,
967
+ "error" | "loading" | "loaded",
968
+ "loading" | "ready" | "failed",
969
+ RemoteInput,
970
+ NonReducibleUnknown,
971
+ EventObject,
972
+ MetaObject,
973
+ {
974
+ id: "remote";
975
+ states: {
976
+ readonly loading: {};
977
+ readonly loaded: {};
978
+ readonly error: {};
979
+ };
980
+ }
981
+ >
982
+ >
983
+ | undefined;
984
+ },
985
+ {
986
+ src: "remote";
987
+ logic: StateMachine<
988
+ RemoteInput & {
989
+ module: unknown;
990
+ error: RemoteError | null;
991
+ },
992
+ AnyEventObject,
993
+ {
994
+ [x: string]:
995
+ | ActorRefFromLogic<
996
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
997
+ >
998
+ | undefined;
999
+ },
1000
+ {
1001
+ src: "load";
1002
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1003
+ id: string | undefined;
1004
+ },
1005
+ | {
1006
+ type: "setModule";
1007
+ params: {
1008
+ module: unknown;
1009
+ };
1010
+ }
1011
+ | {
1012
+ type: "setError";
1013
+ params: {
1014
+ error: unknown;
1015
+ };
1016
+ },
1017
+ never,
1018
+ never,
1019
+ "error" | "loading" | "loaded",
1020
+ "loading" | "ready" | "failed",
1021
+ RemoteInput,
1022
+ NonReducibleUnknown,
1023
+ EventObject,
1024
+ MetaObject,
1025
+ {
1026
+ id: "remote";
1027
+ states: {
1028
+ readonly loading: {};
1029
+ readonly loaded: {};
1030
+ readonly error: {};
1031
+ };
1032
+ }
1033
+ >;
1034
+ id: string | undefined;
1035
+ },
1036
+ {
1037
+ type: "spawnRemote";
1038
+ params: {
1039
+ moduleId: string;
1040
+ entry: string;
1041
+ };
1042
+ },
1043
+ {
1044
+ type: "remoteNotKnown";
1045
+ params: {
1046
+ moduleId: string;
1047
+ };
1048
+ },
1049
+ never,
1050
+ {},
1051
+ string,
1052
+ {
1053
+ instance: FederationInstance;
1054
+ },
1055
+ NonReducibleUnknown,
1056
+ EventObject,
1057
+ MetaObject,
1058
+ {
1059
+ id: "remotes";
1060
+ }
1061
+ >;
1062
+ id: "remotes";
1063
+ }
1064
+ | {
1065
+ src: "services";
1066
+ logic: StateMachine<
1067
+ {
1068
+ instance: FederationInstance;
1069
+ children: Map<string, ActorRefFrom<serviceLogic>>;
1070
+ },
1071
+ {
1072
+ type: "services.sync";
1073
+ services: ReadonlyArray<{
1074
+ appId: string;
1075
+ serviceName: string;
1076
+ entry: string;
1077
+ }>;
1078
+ },
1079
+ {
1080
+ [x: string]:
1081
+ | ActorRefFromLogic<
1082
+ StateMachine<
1083
+ ServiceInput & {
1084
+ workerUrl: string | null;
1085
+ },
1086
+ AnyEventObject,
1087
+ {
1088
+ [x: string]:
1089
+ | ActorRefFromLogic<
1090
+ StateMachine<
1091
+ RemoteInput & {
1092
+ module: unknown;
1093
+ error: RemoteError | null;
1094
+ },
1095
+ AnyEventObject,
1096
+ {
1097
+ [x: string]:
1098
+ | ActorRefFromLogic<
1099
+ PromiseActorLogic<
1100
+ unknown,
1101
+ RemoteInput,
1102
+ EventObject
1103
+ >
1104
+ >
1105
+ | undefined;
1106
+ },
1107
+ {
1108
+ src: "load";
1109
+ logic: PromiseActorLogic<
1110
+ unknown,
1111
+ RemoteInput,
1112
+ EventObject
1113
+ >;
1114
+ id: string | undefined;
1115
+ },
1116
+ | {
1117
+ type: "setModule";
1118
+ params: {
1119
+ module: unknown;
1120
+ };
1121
+ }
1122
+ | {
1123
+ type: "setError";
1124
+ params: {
1125
+ error: unknown;
1126
+ };
1127
+ },
1128
+ never,
1129
+ never,
1130
+ "error" | "loading" | "loaded",
1131
+ "loading" | "ready" | "failed",
1132
+ RemoteInput,
1133
+ NonReducibleUnknown,
1134
+ EventObject,
1135
+ MetaObject,
1136
+ {
1137
+ id: "remote";
1138
+ states: {
1139
+ readonly loading: {};
1140
+ readonly loaded: {};
1141
+ readonly error: {};
1142
+ };
1143
+ }
1144
+ >
1145
+ >
1146
+ | ActorRefFromLogic<
1147
+ CallbackActorLogic<
1148
+ {
1149
+ type: string;
1150
+ },
1151
+ {
1152
+ key: string;
1153
+ serviceName: string;
1154
+ workerUrl: string;
1155
+ },
1156
+ EventObject
1157
+ >
1158
+ >
1159
+ | undefined;
1160
+ },
1161
+ | {
1162
+ src: "loadInterface";
1163
+ logic: StateMachine<
1164
+ RemoteInput & {
1165
+ module: unknown;
1166
+ error: RemoteError | null;
1167
+ },
1168
+ AnyEventObject,
1169
+ {
1170
+ [x: string]:
1171
+ | ActorRefFromLogic<
1172
+ PromiseActorLogic<
1173
+ unknown,
1174
+ RemoteInput,
1175
+ EventObject
1176
+ >
1177
+ >
1178
+ | undefined;
1179
+ },
1180
+ {
1181
+ src: "load";
1182
+ logic: PromiseActorLogic<
1183
+ unknown,
1184
+ RemoteInput,
1185
+ EventObject
1186
+ >;
1187
+ id: string | undefined;
1188
+ },
1189
+ | {
1190
+ type: "setModule";
1191
+ params: {
1192
+ module: unknown;
1193
+ };
1194
+ }
1195
+ | {
1196
+ type: "setError";
1197
+ params: {
1198
+ error: unknown;
1199
+ };
1200
+ },
1201
+ never,
1202
+ never,
1203
+ "error" | "loading" | "loaded",
1204
+ "loading" | "ready" | "failed",
1205
+ RemoteInput,
1206
+ NonReducibleUnknown,
1207
+ EventObject,
1208
+ MetaObject,
1209
+ {
1210
+ id: "remote";
1211
+ states: {
1212
+ readonly loading: {};
1213
+ readonly loaded: {};
1214
+ readonly error: {};
1215
+ };
1216
+ }
1217
+ >;
1218
+ id: string | undefined;
1219
+ }
1220
+ | {
1221
+ src: "runWorker";
1222
+ logic: CallbackActorLogic<
1223
+ {
1224
+ type: string;
1225
+ },
1226
+ {
1227
+ key: string;
1228
+ serviceName: string;
1229
+ workerUrl: string;
1230
+ },
1231
+ EventObject
1232
+ >;
1233
+ id: string | undefined;
1234
+ },
1235
+ never,
1236
+ never,
1237
+ never,
1238
+ "error" | "loading" | "running",
1239
+ "loading" | "failed" | "running",
1240
+ ServiceInput,
1241
+ NonReducibleUnknown,
1242
+ EventObject,
1243
+ MetaObject,
1244
+ {
1245
+ id: "service";
1246
+ states: {
1247
+ readonly loading: {};
1248
+ readonly running: {};
1249
+ readonly error: {};
1250
+ };
1251
+ }
1252
+ >
1253
+ >
1254
+ | undefined;
1255
+ },
1256
+ {
1257
+ src: "service";
1258
+ logic: StateMachine<
1259
+ ServiceInput & {
1260
+ workerUrl: string | null;
1261
+ },
1262
+ AnyEventObject,
1263
+ {
1264
+ [x: string]:
1265
+ | ActorRefFromLogic<
1266
+ StateMachine<
1267
+ RemoteInput & {
1268
+ module: unknown;
1269
+ error: RemoteError | null;
1270
+ },
1271
+ AnyEventObject,
1272
+ {
1273
+ [x: string]:
1274
+ | ActorRefFromLogic<
1275
+ PromiseActorLogic<
1276
+ unknown,
1277
+ RemoteInput,
1278
+ EventObject
1279
+ >
1280
+ >
1281
+ | undefined;
1282
+ },
1283
+ {
1284
+ src: "load";
1285
+ logic: PromiseActorLogic<
1286
+ unknown,
1287
+ RemoteInput,
1288
+ EventObject
1289
+ >;
1290
+ id: string | undefined;
1291
+ },
1292
+ | {
1293
+ type: "setModule";
1294
+ params: {
1295
+ module: unknown;
1296
+ };
1297
+ }
1298
+ | {
1299
+ type: "setError";
1300
+ params: {
1301
+ error: unknown;
1302
+ };
1303
+ },
1304
+ never,
1305
+ never,
1306
+ "error" | "loading" | "loaded",
1307
+ "loading" | "ready" | "failed",
1308
+ RemoteInput,
1309
+ NonReducibleUnknown,
1310
+ EventObject,
1311
+ MetaObject,
1312
+ {
1313
+ id: "remote";
1314
+ states: {
1315
+ readonly loading: {};
1316
+ readonly loaded: {};
1317
+ readonly error: {};
1318
+ };
1319
+ }
1320
+ >
1321
+ >
1322
+ | ActorRefFromLogic<
1323
+ CallbackActorLogic<
1324
+ {
1325
+ type: string;
1326
+ },
1327
+ {
1328
+ key: string;
1329
+ serviceName: string;
1330
+ workerUrl: string;
1331
+ },
1332
+ EventObject
1333
+ >
1334
+ >
1335
+ | undefined;
1336
+ },
1337
+ | {
1338
+ src: "loadInterface";
1339
+ logic: StateMachine<
1340
+ RemoteInput & {
1341
+ module: unknown;
1342
+ error: RemoteError | null;
1343
+ },
1344
+ AnyEventObject,
1345
+ {
1346
+ [x: string]:
1347
+ | ActorRefFromLogic<
1348
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
1349
+ >
1350
+ | undefined;
1351
+ },
1352
+ {
1353
+ src: "load";
1354
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1355
+ id: string | undefined;
1356
+ },
1357
+ | {
1358
+ type: "setModule";
1359
+ params: {
1360
+ module: unknown;
1361
+ };
1362
+ }
1363
+ | {
1364
+ type: "setError";
1365
+ params: {
1366
+ error: unknown;
1367
+ };
1368
+ },
1369
+ never,
1370
+ never,
1371
+ "error" | "loading" | "loaded",
1372
+ "loading" | "ready" | "failed",
1373
+ RemoteInput,
1374
+ NonReducibleUnknown,
1375
+ EventObject,
1376
+ MetaObject,
1377
+ {
1378
+ id: "remote";
1379
+ states: {
1380
+ readonly loading: {};
1381
+ readonly loaded: {};
1382
+ readonly error: {};
1383
+ };
1384
+ }
1385
+ >;
1386
+ id: string | undefined;
1387
+ }
1388
+ | {
1389
+ src: "runWorker";
1390
+ logic: CallbackActorLogic<
1391
+ {
1392
+ type: string;
1393
+ },
1394
+ {
1395
+ key: string;
1396
+ serviceName: string;
1397
+ workerUrl: string;
1398
+ },
1399
+ EventObject
1400
+ >;
1401
+ id: string | undefined;
1402
+ },
1403
+ never,
1404
+ never,
1405
+ never,
1406
+ "error" | "loading" | "running",
1407
+ "loading" | "failed" | "running",
1408
+ ServiceInput,
1409
+ NonReducibleUnknown,
1410
+ EventObject,
1411
+ MetaObject,
1412
+ {
1413
+ id: "service";
1414
+ states: {
1415
+ readonly loading: {};
1416
+ readonly running: {};
1417
+ readonly error: {};
1418
+ };
1419
+ }
1420
+ >;
1421
+ id: string | undefined;
1422
+ },
1423
+ {
1424
+ type: "syncServices";
1425
+ params: NonReducibleUnknown;
1426
+ },
1427
+ never,
1428
+ never,
1429
+ {},
1430
+ string,
1431
+ {
1432
+ instance: FederationInstance;
1433
+ },
1434
+ NonReducibleUnknown,
1435
+ EventObject,
1436
+ MetaObject,
1437
+ {
1438
+ id: "services";
1439
+ }
1440
+ >;
1441
+ id: "services";
1442
+ }
1443
+ | {
1444
+ src: "telemetry";
1445
+ logic: StateMachine<
1446
+ {
1447
+ instance: SanityInstance;
1448
+ store: TelemetryStore<WorkbenchUserProperties> | null;
1449
+ userProperties: WorkbenchUserProperties;
1450
+ },
1451
+ | {
1452
+ type: "telemetry.start";
1453
+ }
1454
+ | {
1455
+ type: "telemetry.stop";
1456
+ },
1457
+ {
1458
+ [x: string]:
1459
+ | ActorRefFromLogic<
1460
+ PromiseActorLogic<
1461
+ {
1462
+ status: ConsentStatus;
1463
+ },
1464
+ {
1465
+ instance: SanityInstance;
1466
+ },
1467
+ EventObject
1468
+ >
1469
+ >
1470
+ | undefined;
1471
+ },
1472
+ {
1473
+ src: "checkConsent";
1474
+ logic: PromiseActorLogic<
1475
+ {
1476
+ status: ConsentStatus;
1477
+ },
1478
+ {
1479
+ instance: SanityInstance;
1480
+ },
1481
+ EventObject
1482
+ >;
1483
+ id: string | undefined;
1484
+ },
1485
+ | {
1486
+ type: "createStore";
1487
+ params: NonReducibleUnknown;
1488
+ }
1489
+ | {
1490
+ type: "teardownStore";
1491
+ params: unknown;
1492
+ },
1493
+ {
1494
+ type: "isConsentGranted";
1495
+ params: {
1496
+ status: ConsentStatus;
1497
+ };
1498
+ },
1499
+ never,
1500
+ "active" | "stopped" | "denied" | "idle" | "checkingConsent",
1501
+ string,
1502
+ TelemetryInput,
1503
+ NonReducibleUnknown,
1504
+ EventObject,
1505
+ MetaObject,
1506
+ {
1507
+ id: "telemetry";
1508
+ states: {
1509
+ readonly idle: {};
1510
+ readonly checkingConsent: {};
1511
+ readonly active: {};
1512
+ readonly stopped: {};
1513
+ readonly denied: {};
1514
+ };
1515
+ }
1516
+ >;
1517
+ id: "telemetry";
1518
+ }
1519
+ | {
1520
+ src: "auth";
1521
+ logic: StateMachine<
1522
+ {
1523
+ instance: SanityInstance;
1524
+ token: string | null;
1525
+ currentUser: CurrentUser | null;
1526
+ error: unknown;
1527
+ },
1528
+ {
1529
+ type: "auth.logout";
1530
+ },
1531
+ {
1532
+ [x: string]:
1533
+ | ActorRefFromLogic<
1534
+ ObservableActorLogic<AuthState, AuthInput, EventObject>
1535
+ >
1536
+ | ActorRefFromLogic<
1537
+ PromiseActorLogic<void, LogoutInput, EventObject>
1538
+ >
1539
+ | undefined;
1540
+ },
1541
+ | {
1542
+ src: "authState";
1543
+ logic: ObservableActorLogic<AuthState, AuthInput, EventObject>;
1544
+ id: string | undefined;
1545
+ }
1546
+ | {
1547
+ src: "logoutActor";
1548
+ logic: PromiseActorLogic<void, LogoutInput, EventObject>;
1549
+ id: string | undefined;
1550
+ },
1551
+ | {
1552
+ type: "setError";
1553
+ params: {
1554
+ error: unknown;
1555
+ };
1556
+ }
1557
+ | {
1558
+ type: "setLoggedIn";
1559
+ params: {
1560
+ token: string;
1561
+ currentUser: CurrentUser;
1562
+ };
1563
+ }
1564
+ | {
1565
+ type: "clearAuth";
1566
+ params: NonReducibleUnknown;
1567
+ },
1568
+ | {
1569
+ type: "isLoggedInComplete";
1570
+ params: {
1571
+ state: AuthState | undefined;
1572
+ };
1573
+ }
1574
+ | {
1575
+ type: "isAuthState";
1576
+ params: {
1577
+ state: AuthState | undefined;
1578
+ type: AuthStateType;
1579
+ };
1580
+ },
1581
+ "authTimeout",
1582
+ "init" | AuthStateType | "logging-out",
1583
+ "error" | "authenticating" | "authenticated",
1584
+ AuthInput,
1585
+ NonReducibleUnknown,
1586
+ EventObject,
1587
+ MetaObject,
1588
+ {
1589
+ id: "auth";
1590
+ states: {
1591
+ readonly init: {};
1592
+ readonly "logging-in": {};
1593
+ readonly "logged-in": {};
1594
+ readonly "logging-out": {};
1595
+ readonly "logged-out": {};
1596
+ readonly error: {};
1597
+ };
1598
+ }
1599
+ >;
1600
+ id: "auth";
1601
+ }
1602
+ | {
1603
+ src: "systemPreferences";
1604
+ logic: StateMachine<
1605
+ SystemPreferencesContext & {
1606
+ adapter: SystemPreferencesAdapter | undefined;
1607
+ },
1608
+ | {
1609
+ type: "preferredColorScheme.set";
1610
+ preferredColorScheme: ("light" | "dark") | "system";
1611
+ }
1612
+ | {
1613
+ type: "osColorScheme.set";
1614
+ osColorScheme: "light" | "dark";
1615
+ },
1616
+ {
1617
+ [x: string]:
1618
+ | ActorRefFromLogic<
1619
+ CallbackActorLogic<
1620
+ {
1621
+ type: "preferredColorScheme.set";
1622
+ preferredColorScheme: ("light" | "dark") | "system";
1623
+ },
1624
+ SystemPreferencesAdapter | undefined,
1625
+ SystemPreferencesEvent
1626
+ >
1627
+ >
1628
+ | undefined;
1629
+ },
1630
+ {
1631
+ src: "adapterBridge";
1632
+ logic: CallbackActorLogic<
1633
+ {
1634
+ type: "preferredColorScheme.set";
1635
+ preferredColorScheme: ("light" | "dark") | "system";
1636
+ },
1637
+ SystemPreferencesAdapter | undefined,
1638
+ SystemPreferencesEvent
1639
+ >;
1640
+ id: string | undefined;
1641
+ },
1642
+ | {
1643
+ type: "setPreferredColorScheme";
1644
+ params: {
1645
+ preferredColorScheme: ("light" | "dark") | "system";
1646
+ };
1647
+ }
1648
+ | {
1649
+ type: "setOsColorScheme";
1650
+ params: {
1651
+ osColorScheme: "light" | "dark";
1652
+ };
1653
+ },
1654
+ never,
1655
+ never,
1656
+ "ready",
1657
+ string,
1658
+ {
1659
+ adapter?: SystemPreferencesAdapter;
1660
+ },
1661
+ NonReducibleUnknown,
1662
+ EventObject,
1663
+ MetaObject,
1664
+ {
1665
+ id: "system-preferences";
1666
+ states: {
1667
+ readonly ready: {};
1668
+ };
1669
+ }
1670
+ >;
1671
+ id: "system-preferences";
1672
+ },
1673
+ | {
1674
+ type: "raiseAuthReady";
1675
+ params: NonReducibleUnknown;
1676
+ }
1677
+ | {
1678
+ type: "raiseAuthFailed";
1679
+ params: NonReducibleUnknown;
1680
+ }
1681
+ | {
1682
+ type: "raiseTelemetryReady";
1683
+ params: NonReducibleUnknown;
1684
+ }
1685
+ | {
1686
+ type: "startTelemetry";
1687
+ params: NonReducibleUnknown;
1688
+ },
1689
+ {
1690
+ type: "hasTag";
1691
+ params: {
1692
+ hasTag: boolean;
1693
+ };
1694
+ },
1695
+ never,
1696
+ | "running"
1697
+ | {
1698
+ booting: "error" | "done" | "telemetry" | "auth";
1699
+ },
1700
+ string,
1701
+ OSInput,
1702
+ NonReducibleUnknown,
1703
+ EventObject,
1704
+ MetaObject,
1705
+ {
1706
+ id: "os";
1707
+ states: {
1708
+ readonly booting: {
1709
+ states: {
1710
+ readonly auth: {};
1711
+ readonly telemetry: {};
1712
+ readonly error: {};
1713
+ readonly done: {};
1714
+ };
1715
+ };
1716
+ readonly running: {};
1717
+ };
1718
+ }
1719
+ >;
1720
+
1721
+ /**
1722
+ * The base inputs for the OS machine.
1723
+ * @internal
1724
+ */
1725
+ declare interface OSBaseInput extends Pick<OSContext, "instance"> {}
1726
+
1727
+ declare type OSContext = {
1728
+ instance: SanityInstance;
1729
+ /**
1730
+ * The single module-federation instance every interface loads through —
1731
+ * shared by the `remotes` (views) and `services` (workers) supervisors so an
1732
+ * app's remote is registered once for all its interfaces.
1733
+ */
1734
+ federationInstance: FederationInstance;
1735
+ userProperties: WorkbenchUserProperties;
1736
+ systemPreferencesAdapter: SystemPreferencesAdapter | undefined;
1737
+ };
1738
+
1739
+ declare type OSInput = WorkbenchUserProperties & {
1740
+ systemPreferencesAdapter?: SystemPreferencesAdapter;
1741
+ };
1742
+
1743
+ declare type RemoteContext = RemoteInput & {
1744
+ /** The loaded module, shape-agnostic — each consumer narrows it. @see {@link RemoteModuleByInterfaceType} */
1745
+ module: unknown;
1746
+ error: RemoteError | null;
1747
+ };
1748
+
1749
+ /**
1750
+ * @public
1751
+ */
1752
+ export declare interface RemoteError {
1753
+ message: string;
1754
+ cause: unknown;
1755
+ }
1756
+
1757
+ /**
1758
+ * @internal
1759
+ */
1760
+ export declare interface RemoteInput {
1761
+ /** Fully-qualified module id — `${appId}/${expose}`. One child per moduleId. */
1762
+ moduleId: string;
1763
+ entry: string;
1764
+ instance: FederationInstance;
1765
+ }
1766
+
1767
+ /**
1768
+ * Lifecycle machine for a single federated interface module — an application's
1769
+ * `App` entry, one view component, or a worker service's loader. Interface-
1770
+ * agnostic: it loads and tracks any module, leaving the shape contract
1771
+ * (render vs. worker URL) to the consumer.
1772
+ *
1773
+ * Spawned by the {@link remotesLogic} supervisor on demand, one per remote id
1774
+ * (`${appId}/${moduleId}`). Each instance owns one module's load lifecycle:
1775
+ * `loading` → `loaded | error`. Tags (`loading` / `ready` / `failed`) drive the
1776
+ * UI contract — state names are internal.
1777
+ *
1778
+ * The machine sends a `remote.settled` event to its parent on entry to
1779
+ * either terminal state, reserved for future supervision/retry.
1780
+ *
1781
+ * @internal
1782
+ */
1783
+ declare const remoteLogic: StateMachine<
1784
+ RemoteContext,
1785
+ AnyEventObject,
1786
+ {
1787
+ [x: string]:
1788
+ | ActorRefFromLogic<PromiseActorLogic<unknown, RemoteInput, EventObject>>
1789
+ | undefined;
1790
+ },
1791
+ {
1792
+ src: "load";
1793
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1794
+ id: string | undefined;
1795
+ },
1796
+ | {
1797
+ type: "setModule";
1798
+ params: {
1799
+ module: unknown;
1800
+ };
1801
+ }
1802
+ | {
1803
+ type: "setError";
1804
+ params: {
1805
+ error: unknown;
1806
+ };
1807
+ },
1808
+ never,
1809
+ never,
1810
+ "error" | "loading" | "loaded",
1811
+ "loading" | "ready" | "failed",
1812
+ RemoteInput,
1813
+ NonReducibleUnknown,
1814
+ EventObject,
1815
+ MetaObject,
1816
+ {
1817
+ id: "remote";
1818
+ states: {
1819
+ readonly loading: {};
1820
+ readonly loaded: {};
1821
+ readonly error: {};
1822
+ };
1823
+ }
1824
+ >;
1825
+
1826
+ /**
1827
+ * The federated-module shape each interface type exposes, keyed by
1828
+ * `interface_type`. Every interface — `panel`, `app`, `worker` — loads through
1829
+ * the same {@link remoteLogic} lifecycle; this maps what its loaded module looks
1830
+ * like so each consumer narrows the machine's shape-agnostic `module` to the
1831
+ * right type: a render contract for `panel`/`app` (rendered by an island), a
1832
+ * worker loader for `worker` (run as a Web Worker, never rendered).
1833
+ * @public
1834
+ */
1835
+ export declare interface RemoteModuleByInterfaceType {
1836
+ panel: LoadedRemoteModule;
1837
+ app: LoadedRemoteModule;
1838
+ worker: ServiceLoaderModule;
1839
+ }
1840
+
1841
+ /**
1842
+ * @public
1843
+ */
1844
+ export declare interface RemoteRenderOptions {
1845
+ basePath?: string;
1846
+ scheme?: "light" | "dark";
1847
+ /**
1848
+ * This is a temporary measure designed to authenticate federated
1849
+ * studios & SDK apps before we write a working protocol.
1850
+ */
1851
+ unstable_temporaryToken?: string | null;
1852
+ }
1853
+
1854
+ declare type ServiceContext = ServiceInput & {
1855
+ /** Resolved worker-bundle URL, absolute on the app origin. */
1856
+ workerUrl: string | null;
1857
+ };
1858
+
1859
+ /**
1860
+ * @internal
1861
+ */
1862
+ declare interface ServiceInput {
1863
+ /** Stable child key, `${appId}:${serviceName}`. */
1864
+ key: string;
1865
+ appId: string;
1866
+ serviceName: string;
1867
+ /** The app's `mf-manifest.json` URL — the federation remote entry. */
1868
+ entry: string;
1869
+ instance: FederationInstance;
1870
+ }
1871
+
1872
+ /**
1873
+ * A worker service's loader module — the `worker` interface's expose. Carries
1874
+ * the worker bundle URL (root-relative to the app origin) for the host to
1875
+ * bootstrap, not a render function; the services counterpart of
1876
+ * {@link LoadedRemoteModule}.
1877
+ * @public
1878
+ */
1879
+ export declare interface ServiceLoaderModule {
1880
+ url: string;
1881
+ type: string;
1882
+ name: string;
1883
+ version: number;
1884
+ }
1885
+
1886
+ /**
1887
+ * Lifecycle machine for a single background service worker.
1888
+ *
1889
+ * Spawned by the {@link servicesLogic} supervisor, one per `(app, service)`.
1890
+ * `loading` loads the worker's loader module through the shared
1891
+ * {@link remoteLogic} lifecycle — the same machine every interface (panel, app,
1892
+ * worker) loads through — and reads the bundle URL off it. A worker isn't a
1893
+ * render module, so it's never handed to an island; `running` bootstraps it as
1894
+ * a Web Worker from that URL.
1895
+ *
1896
+ * @internal
1897
+ */
1898
+ declare const serviceLogic: StateMachine<
1899
+ ServiceContext,
1900
+ AnyEventObject,
1901
+ {
1902
+ [x: string]:
1903
+ | ActorRefFromLogic<
1904
+ StateMachine<
1905
+ RemoteInput & {
1906
+ module: unknown;
1907
+ error: RemoteError | null;
1908
+ },
1909
+ AnyEventObject,
1910
+ {
1911
+ [x: string]:
1912
+ | ActorRefFromLogic<
1913
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
1914
+ >
1915
+ | undefined;
1916
+ },
1917
+ {
1918
+ src: "load";
1919
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1920
+ id: string | undefined;
1921
+ },
1922
+ | {
1923
+ type: "setModule";
1924
+ params: {
1925
+ module: unknown;
1926
+ };
1927
+ }
1928
+ | {
1929
+ type: "setError";
1930
+ params: {
1931
+ error: unknown;
1932
+ };
1933
+ },
1934
+ never,
1935
+ never,
1936
+ "error" | "loading" | "loaded",
1937
+ "loading" | "ready" | "failed",
1938
+ RemoteInput,
1939
+ NonReducibleUnknown,
1940
+ EventObject,
1941
+ MetaObject,
1942
+ {
1943
+ id: "remote";
1944
+ states: {
1945
+ readonly loading: {};
1946
+ readonly loaded: {};
1947
+ readonly error: {};
1948
+ };
1949
+ }
1950
+ >
1951
+ >
1952
+ | ActorRefFromLogic<
1953
+ CallbackActorLogic<
1954
+ {
1955
+ type: string;
1956
+ },
1957
+ {
1958
+ key: string;
1959
+ serviceName: string;
1960
+ workerUrl: string;
1961
+ },
1962
+ EventObject
1963
+ >
1964
+ >
1965
+ | undefined;
1966
+ },
1967
+ | {
1968
+ src: "loadInterface";
1969
+ logic: StateMachine<
1970
+ RemoteInput & {
1971
+ module: unknown;
1972
+ error: RemoteError | null;
1973
+ },
1974
+ AnyEventObject,
1975
+ {
1976
+ [x: string]:
1977
+ | ActorRefFromLogic<
1978
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
1979
+ >
1980
+ | undefined;
1981
+ },
1982
+ {
1983
+ src: "load";
1984
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1985
+ id: string | undefined;
1986
+ },
1987
+ | {
1988
+ type: "setModule";
1989
+ params: {
1990
+ module: unknown;
1991
+ };
1992
+ }
1993
+ | {
1994
+ type: "setError";
1995
+ params: {
1996
+ error: unknown;
1997
+ };
1998
+ },
1999
+ never,
2000
+ never,
2001
+ "error" | "loading" | "loaded",
2002
+ "loading" | "ready" | "failed",
2003
+ RemoteInput,
2004
+ NonReducibleUnknown,
2005
+ EventObject,
2006
+ MetaObject,
2007
+ {
2008
+ id: "remote";
2009
+ states: {
2010
+ readonly loading: {};
2011
+ readonly loaded: {};
2012
+ readonly error: {};
2013
+ };
2014
+ }
2015
+ >;
2016
+ id: string | undefined;
2017
+ }
2018
+ | {
2019
+ src: "runWorker";
2020
+ logic: CallbackActorLogic<
2021
+ {
2022
+ type: string;
2023
+ },
2024
+ {
2025
+ key: string;
2026
+ serviceName: string;
2027
+ workerUrl: string;
2028
+ },
2029
+ EventObject
2030
+ >;
2031
+ id: string | undefined;
2032
+ },
2033
+ never,
2034
+ never,
2035
+ never,
2036
+ "error" | "loading" | "running",
2037
+ "loading" | "failed" | "running",
2038
+ ServiceInput,
2039
+ NonReducibleUnknown,
2040
+ EventObject,
2041
+ MetaObject,
2042
+ {
2043
+ id: "service";
2044
+ states: {
2045
+ readonly loading: {};
2046
+ readonly running: {};
2047
+ readonly error: {};
2048
+ };
2049
+ }
2050
+ >;
2051
+
2052
+ /**
2053
+ * Adapter interface the host implements to give the system-preferences
2054
+ * machine access to the user's environment (OS color scheme, persistent
2055
+ * storage, cross-context change notifications).
2056
+ *
2057
+ * The package owns all orchestration — synchronous seeding, idempotent
2058
+ * persistence, mapping cleared storage to `"system"`. The host's
2059
+ * implementation is pure DOM/storage glue: read, write, subscribe.
2060
+ * @public
2061
+ */
2062
+ export declare type SystemPreferencesAdapter = {
2063
+ /** Read the user's stored preference. `null` means "no preference set"
2064
+ * (the machine treats this as `"system"`). */
2065
+ getPreferredColorScheme: () => ColorSchemePreference | null;
2066
+ /** Write the user's preference to persistent storage. */
2067
+ persistPreferredColorScheme: (value: ColorSchemePreference) => void;
2068
+ /** Subscribe to cross-context preference changes (e.g. another tab
2069
+ * writing to the shared storage). The callback receives the new stored
2070
+ * value (or `null` if it was cleared). Returns an unsubscribe function. */
2071
+ subscribePreferredColorScheme: (
2072
+ callback: (next: ColorSchemePreference | null) => void,
2073
+ ) => () => void;
2074
+ /** Read the current OS-detected color scheme. */
2075
+ getOsColorScheme: () => ColorScheme;
2076
+ /** Subscribe to OS color-scheme changes (e.g. user flipping dark mode).
2077
+ * Returns an unsubscribe function. */
2078
+ subscribeOsColorScheme: (callback: (next: ColorScheme) => void) => () => void;
2079
+ };
2080
+
2081
+ /**
2082
+ * The system-preferences machine's context. Consumers read fields directly
2083
+ * (e.g. via `useSelector`) rather than going through a resolver utility —
2084
+ * the action handlers keep `colorScheme` in sync with `preferredColorScheme`
2085
+ * and `osColorScheme`.
2086
+ *
2087
+ * Note: `colorScheme` is intentionally stored as derived state in context so
2088
+ * consumers can read the resolved value directly without a utility. The
2089
+ * action handlers below are the single source of truth for the resolution.
2090
+ * @public
2091
+ */
2092
+ export declare type SystemPreferencesContext = {
2093
+ /** User's color scheme choice; `system` defers to the OS preference. */
2094
+ preferredColorScheme: ColorSchemePreference;
2095
+ /** Last reported OS color scheme. Used to resolve `colorScheme` when the
2096
+ * preference is `system`. */
2097
+ osColorScheme: ColorScheme;
2098
+ /** Resolved color scheme — what the UI should render. Recomputed by the
2099
+ * action handlers whenever an input changes. */
2100
+ colorScheme: ColorScheme;
2101
+ };
2102
+
2103
+ /**
2104
+ * Events the system-preferences machine accepts. Both originate from the
2105
+ * host's adapter — `preferredColorScheme.set` is also forwarded back to it
2106
+ * so it can persist the user's choice.
2107
+ * @public
2108
+ */
2109
+ export declare type SystemPreferencesEvent =
2110
+ | {
2111
+ type: "preferredColorScheme.set";
2112
+ preferredColorScheme: ColorSchemePreference;
2113
+ }
2114
+ | {
2115
+ type: "osColorScheme.set";
2116
+ osColorScheme: ColorScheme;
2117
+ };
2118
+
2119
+ /**
2120
+ * @internal
2121
+ */
2122
+ export declare interface TelemetryInput
2123
+ extends OSBaseInput, WorkbenchUserProperties {}
2124
+
2125
+ /**
2126
+ * @public
2127
+ */
2128
+ export declare type WorkbenchUserProperties = {
2129
+ version: string;
2130
+ organizationId: string;
2131
+ environment: string;
2132
+ userAgent: string;
2133
+ };
2134
+
2135
+ export {};