@sanity/workbench 0.1.0-alpha.2 → 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.
Files changed (48) 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/studio.js +864 -0
  5. package/dist/_chunks-es/studio.js.map +1 -0
  6. package/dist/_internal.d.ts +16 -4
  7. package/dist/_internal.js +34 -26
  8. package/dist/_internal.js.map +1 -1
  9. package/dist/core.d.ts +2138 -0
  10. package/dist/core.js +75 -0
  11. package/dist/core.js.map +1 -0
  12. package/dist/system.d.ts +2120 -0
  13. package/dist/system.js +888 -0
  14. package/dist/system.js.map +1 -0
  15. package/package.json +33 -6
  16. package/src/_exports/core.ts +1 -0
  17. package/src/_exports/system.ts +1 -0
  18. package/src/_internal/index.ts +2 -1
  19. package/src/_internal/render.ts +72 -42
  20. package/src/core/applications/application-list.ts +104 -0
  21. package/src/core/applications/application.ts +174 -0
  22. package/src/core/canvases.ts +92 -0
  23. package/src/core/config.ts +34 -0
  24. package/src/core/env.ts +43 -0
  25. package/src/core/index.ts +13 -0
  26. package/src/core/log/index.ts +125 -0
  27. package/src/core/media-libraries.ts +93 -0
  28. package/src/core/organizations.ts +115 -0
  29. package/src/core/projects.ts +114 -0
  30. package/src/core/shared/urls.ts +129 -0
  31. package/src/core/user-applications/core-app.ts +148 -0
  32. package/src/core/user-applications/studios/index.ts +3 -0
  33. package/src/core/user-applications/studios/schemas.ts +128 -0
  34. package/src/core/user-applications/studios/studio.ts +533 -0
  35. package/src/core/user-applications/studios/workspace.ts +152 -0
  36. package/src/core/user-applications/user-application.ts +222 -0
  37. package/src/system/auth.machine.ts +223 -0
  38. package/src/system/index.ts +22 -0
  39. package/src/system/inspect.ts +40 -0
  40. package/src/system/load-federated-module.ts +54 -0
  41. package/src/system/remote.machine.ts +219 -0
  42. package/src/system/remotes.machine.ts +92 -0
  43. package/src/system/root.machine.ts +224 -0
  44. package/src/system/service.machine.ts +207 -0
  45. package/src/system/services.machine.ts +120 -0
  46. package/src/system/system-preferences.machine.ts +215 -0
  47. package/src/system/telemetry.machine.ts +179 -0
  48. package/src/_internal/render.test.ts +0 -18
@@ -0,0 +1,2120 @@
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 { FederationInstance } from "@sanity/federation/runtime";
11
+ import { InspectionEvent } from "xstate";
12
+ import { MetaObject } from "xstate";
13
+ import { NonReducibleUnknown } from "xstate";
14
+ import { ObservableActorLogic } from "xstate";
15
+ import { PromiseActorLogic } from "xstate";
16
+ import { SanityInstance } from "@sanity/sdk";
17
+ import { StateMachine } from "xstate";
18
+ import { TelemetryStore } from "@sanity/telemetry";
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ export declare interface AuthInput extends OSBaseInput {}
24
+
25
+ declare type ColorScheme = "light" | "dark";
26
+
27
+ declare type ColorSchemePreference = "system" | ColorScheme;
28
+
29
+ /**
30
+ * Creates a set of default options for the OS machine. Forwards the workbench
31
+ * user properties to the machine's input and wires the structured-logging
32
+ * `inspect` callback. Browser-specific concerns (color-scheme seeding,
33
+ * persistence) live in the {@link SystemPreferencesAdapter} the host passes
34
+ * via `systemPreferencesAdapter`.
35
+ * @public
36
+ */
37
+ export declare function createOSOptions(input: OSInput): {
38
+ id: string;
39
+ input: OSInput;
40
+ inspect: (event: InspectionEvent) => void;
41
+ };
42
+
43
+ /**
44
+ * A module exposed by an application's federation remote.
45
+ *
46
+ * @public
47
+ */
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;
67
+ }
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
+
81
+ /**
82
+ * @internal
83
+ */
84
+ export declare interface LogoutInput extends OSBaseInput {}
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
+
97
+ /**
98
+ * The sanity OS machine, responsible for managing the global state of the OS.
99
+ * @public
100
+ * @example
101
+ * ```ts
102
+ * import { os, createOSOptions } from "@sanity/workbench/system";
103
+ * import { useActor } from "@xstate/react";
104
+ *
105
+ * const [state, send] = useActor(os, createOSOptions({
106
+ * version: "1.0.0",
107
+ * organizationId: "...",
108
+ * environment: "production",
109
+ * userAgent: navigator.userAgent,
110
+ * }));
111
+ * ```
112
+ */
113
+ export declare const os: StateMachine<
114
+ OSContext,
115
+ | {
116
+ type: "boot.auth.ready";
117
+ }
118
+ | {
119
+ type: "boot.auth.failed";
120
+ }
121
+ | {
122
+ type: "boot.telemetry.ready";
123
+ },
124
+ {
125
+ remotes?:
126
+ | ActorRefFromLogic<
127
+ StateMachine<
128
+ {
129
+ instance: FederationInstance;
130
+ children: Map<string, ActorRefFrom<remoteLogic>>;
131
+ },
132
+ | {
133
+ type: "remote.load.request";
134
+ moduleId: string;
135
+ entry: string;
136
+ }
137
+ | {
138
+ type: "remote.settled";
139
+ moduleId: string;
140
+ status: "loaded" | "error";
141
+ },
142
+ {
143
+ [x: string]:
144
+ | ActorRefFromLogic<
145
+ StateMachine<
146
+ RemoteInput & {
147
+ module: unknown;
148
+ error: RemoteError | null;
149
+ },
150
+ AnyEventObject,
151
+ {
152
+ [x: string]:
153
+ | ActorRefFromLogic<
154
+ PromiseActorLogic<
155
+ unknown,
156
+ RemoteInput,
157
+ EventObject
158
+ >
159
+ >
160
+ | undefined;
161
+ },
162
+ {
163
+ src: "load";
164
+ logic: PromiseActorLogic<
165
+ unknown,
166
+ RemoteInput,
167
+ EventObject
168
+ >;
169
+ id: string | undefined;
170
+ },
171
+ | {
172
+ type: "setModule";
173
+ params: {
174
+ module: unknown;
175
+ };
176
+ }
177
+ | {
178
+ type: "setError";
179
+ params: {
180
+ error: unknown;
181
+ };
182
+ },
183
+ never,
184
+ never,
185
+ "error" | "loading" | "loaded",
186
+ "loading" | "ready" | "failed",
187
+ RemoteInput,
188
+ NonReducibleUnknown,
189
+ EventObject,
190
+ MetaObject,
191
+ {
192
+ id: "remote";
193
+ states: {
194
+ readonly loading: {};
195
+ readonly loaded: {};
196
+ readonly error: {};
197
+ };
198
+ }
199
+ >
200
+ >
201
+ | undefined;
202
+ },
203
+ {
204
+ src: "remote";
205
+ logic: StateMachine<
206
+ RemoteInput & {
207
+ module: unknown;
208
+ error: RemoteError | null;
209
+ },
210
+ AnyEventObject,
211
+ {
212
+ [x: string]:
213
+ | ActorRefFromLogic<
214
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
215
+ >
216
+ | undefined;
217
+ },
218
+ {
219
+ src: "load";
220
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
221
+ id: string | undefined;
222
+ },
223
+ | {
224
+ type: "setModule";
225
+ params: {
226
+ module: unknown;
227
+ };
228
+ }
229
+ | {
230
+ type: "setError";
231
+ params: {
232
+ error: unknown;
233
+ };
234
+ },
235
+ never,
236
+ never,
237
+ "error" | "loading" | "loaded",
238
+ "loading" | "ready" | "failed",
239
+ RemoteInput,
240
+ NonReducibleUnknown,
241
+ EventObject,
242
+ MetaObject,
243
+ {
244
+ id: "remote";
245
+ states: {
246
+ readonly loading: {};
247
+ readonly loaded: {};
248
+ readonly error: {};
249
+ };
250
+ }
251
+ >;
252
+ id: string | undefined;
253
+ },
254
+ {
255
+ type: "spawnRemote";
256
+ params: {
257
+ moduleId: string;
258
+ entry: string;
259
+ };
260
+ },
261
+ {
262
+ type: "remoteNotKnown";
263
+ params: {
264
+ moduleId: string;
265
+ };
266
+ },
267
+ never,
268
+ {},
269
+ string,
270
+ {
271
+ instance: FederationInstance;
272
+ },
273
+ NonReducibleUnknown,
274
+ EventObject,
275
+ MetaObject,
276
+ {
277
+ id: "remotes";
278
+ }
279
+ >
280
+ >
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;
669
+ telemetry?:
670
+ | ActorRefFromLogic<
671
+ StateMachine<
672
+ {
673
+ instance: SanityInstance;
674
+ store: TelemetryStore<WorkbenchUserProperties> | null;
675
+ userProperties: WorkbenchUserProperties;
676
+ },
677
+ | {
678
+ type: "telemetry.start";
679
+ }
680
+ | {
681
+ type: "telemetry.stop";
682
+ },
683
+ {
684
+ [x: string]:
685
+ | ActorRefFromLogic<
686
+ PromiseActorLogic<
687
+ {
688
+ status: ConsentStatus;
689
+ },
690
+ {
691
+ instance: SanityInstance;
692
+ },
693
+ EventObject
694
+ >
695
+ >
696
+ | undefined;
697
+ },
698
+ {
699
+ src: "checkConsent";
700
+ logic: PromiseActorLogic<
701
+ {
702
+ status: ConsentStatus;
703
+ },
704
+ {
705
+ instance: SanityInstance;
706
+ },
707
+ EventObject
708
+ >;
709
+ id: string | undefined;
710
+ },
711
+ | {
712
+ type: "createStore";
713
+ params: NonReducibleUnknown;
714
+ }
715
+ | {
716
+ type: "teardownStore";
717
+ params: unknown;
718
+ },
719
+ {
720
+ type: "isConsentGranted";
721
+ params: {
722
+ status: ConsentStatus;
723
+ };
724
+ },
725
+ never,
726
+ "active" | "stopped" | "denied" | "idle" | "checkingConsent",
727
+ string,
728
+ TelemetryInput,
729
+ NonReducibleUnknown,
730
+ EventObject,
731
+ MetaObject,
732
+ {
733
+ id: "telemetry";
734
+ states: {
735
+ readonly idle: {};
736
+ readonly checkingConsent: {};
737
+ readonly active: {};
738
+ readonly stopped: {};
739
+ readonly denied: {};
740
+ };
741
+ }
742
+ >
743
+ >
744
+ | undefined;
745
+ auth?:
746
+ | ActorRefFromLogic<
747
+ StateMachine<
748
+ {
749
+ instance: SanityInstance;
750
+ token: string | null;
751
+ currentUser: CurrentUser | null;
752
+ error: unknown;
753
+ },
754
+ {
755
+ type: "auth.logout";
756
+ },
757
+ {
758
+ [x: string]:
759
+ | ActorRefFromLogic<
760
+ ObservableActorLogic<AuthState, AuthInput, EventObject>
761
+ >
762
+ | ActorRefFromLogic<
763
+ PromiseActorLogic<void, LogoutInput, EventObject>
764
+ >
765
+ | undefined;
766
+ },
767
+ | {
768
+ src: "authState";
769
+ logic: ObservableActorLogic<AuthState, AuthInput, EventObject>;
770
+ id: string | undefined;
771
+ }
772
+ | {
773
+ src: "logoutActor";
774
+ logic: PromiseActorLogic<void, LogoutInput, EventObject>;
775
+ id: string | undefined;
776
+ },
777
+ | {
778
+ type: "setError";
779
+ params: {
780
+ error: unknown;
781
+ };
782
+ }
783
+ | {
784
+ type: "setLoggedIn";
785
+ params: {
786
+ token: string;
787
+ currentUser: CurrentUser;
788
+ };
789
+ }
790
+ | {
791
+ type: "clearAuth";
792
+ params: NonReducibleUnknown;
793
+ },
794
+ | {
795
+ type: "isLoggedInComplete";
796
+ params: {
797
+ state: AuthState | undefined;
798
+ };
799
+ }
800
+ | {
801
+ type: "isAuthState";
802
+ params: {
803
+ state: AuthState | undefined;
804
+ type: AuthStateType;
805
+ };
806
+ },
807
+ "authTimeout",
808
+ "init" | AuthStateType | "logging-out",
809
+ "error" | "authenticating" | "authenticated",
810
+ AuthInput,
811
+ NonReducibleUnknown,
812
+ EventObject,
813
+ MetaObject,
814
+ {
815
+ id: "auth";
816
+ states: {
817
+ readonly init: {};
818
+ readonly "logging-in": {};
819
+ readonly "logged-in": {};
820
+ readonly "logging-out": {};
821
+ readonly "logged-out": {};
822
+ readonly error: {};
823
+ };
824
+ }
825
+ >
826
+ >
827
+ | undefined;
828
+ "system-preferences"?:
829
+ | ActorRefFromLogic<
830
+ StateMachine<
831
+ SystemPreferencesContext & {
832
+ adapter: SystemPreferencesAdapter | undefined;
833
+ },
834
+ | {
835
+ type: "preferredColorScheme.set";
836
+ preferredColorScheme: ("light" | "dark") | "system";
837
+ }
838
+ | {
839
+ type: "osColorScheme.set";
840
+ osColorScheme: "light" | "dark";
841
+ },
842
+ {
843
+ [x: string]:
844
+ | ActorRefFromLogic<
845
+ CallbackActorLogic<
846
+ {
847
+ type: "preferredColorScheme.set";
848
+ preferredColorScheme: ("light" | "dark") | "system";
849
+ },
850
+ SystemPreferencesAdapter | undefined,
851
+ SystemPreferencesEvent
852
+ >
853
+ >
854
+ | undefined;
855
+ },
856
+ {
857
+ src: "adapterBridge";
858
+ logic: CallbackActorLogic<
859
+ {
860
+ type: "preferredColorScheme.set";
861
+ preferredColorScheme: ("light" | "dark") | "system";
862
+ },
863
+ SystemPreferencesAdapter | undefined,
864
+ SystemPreferencesEvent
865
+ >;
866
+ id: string | undefined;
867
+ },
868
+ | {
869
+ type: "setPreferredColorScheme";
870
+ params: {
871
+ preferredColorScheme: ("light" | "dark") | "system";
872
+ };
873
+ }
874
+ | {
875
+ type: "setOsColorScheme";
876
+ params: {
877
+ osColorScheme: "light" | "dark";
878
+ };
879
+ },
880
+ never,
881
+ never,
882
+ "ready",
883
+ string,
884
+ {
885
+ adapter?: SystemPreferencesAdapter;
886
+ },
887
+ NonReducibleUnknown,
888
+ EventObject,
889
+ MetaObject,
890
+ {
891
+ id: "system-preferences";
892
+ states: {
893
+ readonly ready: {};
894
+ };
895
+ }
896
+ >
897
+ >
898
+ | undefined;
899
+ },
900
+ | {
901
+ src: "remotes";
902
+ logic: StateMachine<
903
+ {
904
+ instance: FederationInstance;
905
+ children: Map<string, ActorRefFrom<remoteLogic>>;
906
+ },
907
+ | {
908
+ type: "remote.load.request";
909
+ moduleId: string;
910
+ entry: string;
911
+ }
912
+ | {
913
+ type: "remote.settled";
914
+ moduleId: string;
915
+ status: "loaded" | "error";
916
+ },
917
+ {
918
+ [x: string]:
919
+ | ActorRefFromLogic<
920
+ StateMachine<
921
+ RemoteInput & {
922
+ module: unknown;
923
+ error: RemoteError | null;
924
+ },
925
+ AnyEventObject,
926
+ {
927
+ [x: string]:
928
+ | ActorRefFromLogic<
929
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
930
+ >
931
+ | undefined;
932
+ },
933
+ {
934
+ src: "load";
935
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
936
+ id: string | undefined;
937
+ },
938
+ | {
939
+ type: "setModule";
940
+ params: {
941
+ module: unknown;
942
+ };
943
+ }
944
+ | {
945
+ type: "setError";
946
+ params: {
947
+ error: unknown;
948
+ };
949
+ },
950
+ never,
951
+ never,
952
+ "error" | "loading" | "loaded",
953
+ "loading" | "ready" | "failed",
954
+ RemoteInput,
955
+ NonReducibleUnknown,
956
+ EventObject,
957
+ MetaObject,
958
+ {
959
+ id: "remote";
960
+ states: {
961
+ readonly loading: {};
962
+ readonly loaded: {};
963
+ readonly error: {};
964
+ };
965
+ }
966
+ >
967
+ >
968
+ | undefined;
969
+ },
970
+ {
971
+ src: "remote";
972
+ logic: StateMachine<
973
+ RemoteInput & {
974
+ module: unknown;
975
+ error: RemoteError | null;
976
+ },
977
+ AnyEventObject,
978
+ {
979
+ [x: string]:
980
+ | ActorRefFromLogic<
981
+ PromiseActorLogic<unknown, RemoteInput, EventObject>
982
+ >
983
+ | undefined;
984
+ },
985
+ {
986
+ src: "load";
987
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
988
+ id: string | undefined;
989
+ },
990
+ | {
991
+ type: "setModule";
992
+ params: {
993
+ module: unknown;
994
+ };
995
+ }
996
+ | {
997
+ type: "setError";
998
+ params: {
999
+ error: unknown;
1000
+ };
1001
+ },
1002
+ never,
1003
+ never,
1004
+ "error" | "loading" | "loaded",
1005
+ "loading" | "ready" | "failed",
1006
+ RemoteInput,
1007
+ NonReducibleUnknown,
1008
+ EventObject,
1009
+ MetaObject,
1010
+ {
1011
+ id: "remote";
1012
+ states: {
1013
+ readonly loading: {};
1014
+ readonly loaded: {};
1015
+ readonly error: {};
1016
+ };
1017
+ }
1018
+ >;
1019
+ id: string | undefined;
1020
+ },
1021
+ {
1022
+ type: "spawnRemote";
1023
+ params: {
1024
+ moduleId: string;
1025
+ entry: string;
1026
+ };
1027
+ },
1028
+ {
1029
+ type: "remoteNotKnown";
1030
+ params: {
1031
+ moduleId: string;
1032
+ };
1033
+ },
1034
+ never,
1035
+ {},
1036
+ string,
1037
+ {
1038
+ instance: FederationInstance;
1039
+ },
1040
+ NonReducibleUnknown,
1041
+ EventObject,
1042
+ MetaObject,
1043
+ {
1044
+ id: "remotes";
1045
+ }
1046
+ >;
1047
+ id: "remotes";
1048
+ }
1049
+ | {
1050
+ src: "services";
1051
+ logic: StateMachine<
1052
+ {
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
+ }>;
1063
+ },
1064
+ {
1065
+ [x: string]:
1066
+ | ActorRefFromLogic<
1067
+ StateMachine<
1068
+ ServiceInput & {
1069
+ workerUrl: string | null;
1070
+ },
1071
+ AnyEventObject,
1072
+ {
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;
1145
+ },
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
+ | {
1471
+ type: "createStore";
1472
+ params: NonReducibleUnknown;
1473
+ }
1474
+ | {
1475
+ type: "teardownStore";
1476
+ params: unknown;
1477
+ },
1478
+ {
1479
+ type: "isConsentGranted";
1480
+ params: {
1481
+ status: ConsentStatus;
1482
+ };
1483
+ },
1484
+ never,
1485
+ "active" | "stopped" | "denied" | "idle" | "checkingConsent",
1486
+ string,
1487
+ TelemetryInput,
1488
+ NonReducibleUnknown,
1489
+ EventObject,
1490
+ MetaObject,
1491
+ {
1492
+ id: "telemetry";
1493
+ states: {
1494
+ readonly idle: {};
1495
+ readonly checkingConsent: {};
1496
+ readonly active: {};
1497
+ readonly stopped: {};
1498
+ readonly denied: {};
1499
+ };
1500
+ }
1501
+ >;
1502
+ id: "telemetry";
1503
+ }
1504
+ | {
1505
+ src: "auth";
1506
+ logic: StateMachine<
1507
+ {
1508
+ instance: SanityInstance;
1509
+ token: string | null;
1510
+ currentUser: CurrentUser | null;
1511
+ error: unknown;
1512
+ },
1513
+ {
1514
+ type: "auth.logout";
1515
+ },
1516
+ {
1517
+ [x: string]:
1518
+ | ActorRefFromLogic<
1519
+ ObservableActorLogic<AuthState, AuthInput, EventObject>
1520
+ >
1521
+ | ActorRefFromLogic<
1522
+ PromiseActorLogic<void, LogoutInput, EventObject>
1523
+ >
1524
+ | undefined;
1525
+ },
1526
+ | {
1527
+ src: "authState";
1528
+ logic: ObservableActorLogic<AuthState, AuthInput, EventObject>;
1529
+ id: string | undefined;
1530
+ }
1531
+ | {
1532
+ src: "logoutActor";
1533
+ logic: PromiseActorLogic<void, LogoutInput, EventObject>;
1534
+ id: string | undefined;
1535
+ },
1536
+ | {
1537
+ type: "setError";
1538
+ params: {
1539
+ error: unknown;
1540
+ };
1541
+ }
1542
+ | {
1543
+ type: "setLoggedIn";
1544
+ params: {
1545
+ token: string;
1546
+ currentUser: CurrentUser;
1547
+ };
1548
+ }
1549
+ | {
1550
+ type: "clearAuth";
1551
+ params: NonReducibleUnknown;
1552
+ },
1553
+ | {
1554
+ type: "isLoggedInComplete";
1555
+ params: {
1556
+ state: AuthState | undefined;
1557
+ };
1558
+ }
1559
+ | {
1560
+ type: "isAuthState";
1561
+ params: {
1562
+ state: AuthState | undefined;
1563
+ type: AuthStateType;
1564
+ };
1565
+ },
1566
+ "authTimeout",
1567
+ "init" | AuthStateType | "logging-out",
1568
+ "error" | "authenticating" | "authenticated",
1569
+ AuthInput,
1570
+ NonReducibleUnknown,
1571
+ EventObject,
1572
+ MetaObject,
1573
+ {
1574
+ id: "auth";
1575
+ states: {
1576
+ readonly init: {};
1577
+ readonly "logging-in": {};
1578
+ readonly "logged-in": {};
1579
+ readonly "logging-out": {};
1580
+ readonly "logged-out": {};
1581
+ readonly error: {};
1582
+ };
1583
+ }
1584
+ >;
1585
+ id: "auth";
1586
+ }
1587
+ | {
1588
+ src: "systemPreferences";
1589
+ logic: StateMachine<
1590
+ SystemPreferencesContext & {
1591
+ adapter: SystemPreferencesAdapter | undefined;
1592
+ },
1593
+ | {
1594
+ type: "preferredColorScheme.set";
1595
+ preferredColorScheme: ("light" | "dark") | "system";
1596
+ }
1597
+ | {
1598
+ type: "osColorScheme.set";
1599
+ osColorScheme: "light" | "dark";
1600
+ },
1601
+ {
1602
+ [x: string]:
1603
+ | ActorRefFromLogic<
1604
+ CallbackActorLogic<
1605
+ {
1606
+ type: "preferredColorScheme.set";
1607
+ preferredColorScheme: ("light" | "dark") | "system";
1608
+ },
1609
+ SystemPreferencesAdapter | undefined,
1610
+ SystemPreferencesEvent
1611
+ >
1612
+ >
1613
+ | undefined;
1614
+ },
1615
+ {
1616
+ src: "adapterBridge";
1617
+ logic: CallbackActorLogic<
1618
+ {
1619
+ type: "preferredColorScheme.set";
1620
+ preferredColorScheme: ("light" | "dark") | "system";
1621
+ },
1622
+ SystemPreferencesAdapter | undefined,
1623
+ SystemPreferencesEvent
1624
+ >;
1625
+ id: string | undefined;
1626
+ },
1627
+ | {
1628
+ type: "setPreferredColorScheme";
1629
+ params: {
1630
+ preferredColorScheme: ("light" | "dark") | "system";
1631
+ };
1632
+ }
1633
+ | {
1634
+ type: "setOsColorScheme";
1635
+ params: {
1636
+ osColorScheme: "light" | "dark";
1637
+ };
1638
+ },
1639
+ never,
1640
+ never,
1641
+ "ready",
1642
+ string,
1643
+ {
1644
+ adapter?: SystemPreferencesAdapter;
1645
+ },
1646
+ NonReducibleUnknown,
1647
+ EventObject,
1648
+ MetaObject,
1649
+ {
1650
+ id: "system-preferences";
1651
+ states: {
1652
+ readonly ready: {};
1653
+ };
1654
+ }
1655
+ >;
1656
+ id: "system-preferences";
1657
+ },
1658
+ | {
1659
+ type: "raiseAuthReady";
1660
+ params: NonReducibleUnknown;
1661
+ }
1662
+ | {
1663
+ type: "raiseAuthFailed";
1664
+ params: NonReducibleUnknown;
1665
+ }
1666
+ | {
1667
+ type: "raiseTelemetryReady";
1668
+ params: NonReducibleUnknown;
1669
+ }
1670
+ | {
1671
+ type: "startTelemetry";
1672
+ params: NonReducibleUnknown;
1673
+ },
1674
+ {
1675
+ type: "hasTag";
1676
+ params: {
1677
+ hasTag: boolean;
1678
+ };
1679
+ },
1680
+ never,
1681
+ | "running"
1682
+ | {
1683
+ booting: "error" | "done" | "telemetry" | "auth";
1684
+ },
1685
+ string,
1686
+ OSInput,
1687
+ NonReducibleUnknown,
1688
+ EventObject,
1689
+ MetaObject,
1690
+ {
1691
+ id: "os";
1692
+ states: {
1693
+ readonly booting: {
1694
+ states: {
1695
+ readonly auth: {};
1696
+ readonly telemetry: {};
1697
+ readonly error: {};
1698
+ readonly done: {};
1699
+ };
1700
+ };
1701
+ readonly running: {};
1702
+ };
1703
+ }
1704
+ >;
1705
+
1706
+ /**
1707
+ * The base inputs for the OS machine.
1708
+ * @internal
1709
+ */
1710
+ declare interface OSBaseInput extends Pick<OSContext, "instance"> {}
1711
+
1712
+ declare type OSContext = {
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;
1720
+ userProperties: WorkbenchUserProperties;
1721
+ systemPreferencesAdapter: SystemPreferencesAdapter | undefined;
1722
+ };
1723
+
1724
+ declare type OSInput = WorkbenchUserProperties & {
1725
+ systemPreferencesAdapter?: SystemPreferencesAdapter;
1726
+ };
1727
+
1728
+ declare type RemoteContext = RemoteInput & {
1729
+ /** The loaded module, shape-agnostic — each consumer narrows it. @see {@link RemoteModuleByInterfaceType} */
1730
+ module: unknown;
1731
+ error: RemoteError | null;
1732
+ };
1733
+
1734
+ /**
1735
+ * @public
1736
+ */
1737
+ export declare interface RemoteError {
1738
+ message: string;
1739
+ cause: unknown;
1740
+ }
1741
+
1742
+ /**
1743
+ * @internal
1744
+ */
1745
+ export declare interface RemoteInput {
1746
+ /** Fully-qualified module id — `${appId}/${expose}`. One child per moduleId. */
1747
+ moduleId: string;
1748
+ entry: string;
1749
+ instance: FederationInstance;
1750
+ }
1751
+
1752
+ /**
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.
1757
+ *
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.
1762
+ *
1763
+ * The machine sends a `remote.settled` event to its parent on entry to
1764
+ * either terminal state, reserved for future supervision/retry.
1765
+ *
1766
+ * @internal
1767
+ */
1768
+ declare const remoteLogic: StateMachine<
1769
+ RemoteContext,
1770
+ AnyEventObject,
1771
+ {
1772
+ [x: string]:
1773
+ | ActorRefFromLogic<PromiseActorLogic<unknown, RemoteInput, EventObject>>
1774
+ | undefined;
1775
+ },
1776
+ {
1777
+ src: "load";
1778
+ logic: PromiseActorLogic<unknown, RemoteInput, EventObject>;
1779
+ id: string | undefined;
1780
+ },
1781
+ | {
1782
+ type: "setModule";
1783
+ params: {
1784
+ module: unknown;
1785
+ };
1786
+ }
1787
+ | {
1788
+ type: "setError";
1789
+ params: {
1790
+ error: unknown;
1791
+ };
1792
+ },
1793
+ never,
1794
+ never,
1795
+ "error" | "loading" | "loaded",
1796
+ "loading" | "ready" | "failed",
1797
+ RemoteInput,
1798
+ NonReducibleUnknown,
1799
+ EventObject,
1800
+ MetaObject,
1801
+ {
1802
+ id: "remote";
1803
+ states: {
1804
+ readonly loading: {};
1805
+ readonly loaded: {};
1806
+ readonly error: {};
1807
+ };
1808
+ }
1809
+ >;
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
+
1826
+ /**
1827
+ * @public
1828
+ */
1829
+ export declare interface RemoteRenderOptions {
1830
+ basePath?: string;
1831
+ scheme?: "light" | "dark";
1832
+ /**
1833
+ * This is a temporary measure designed to authenticate federated
1834
+ * studios & SDK apps before we write a working protocol.
1835
+ */
1836
+ unstable_temporaryToken?: string | null;
1837
+ }
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
+
2037
+ /**
2038
+ * Adapter interface the host implements to give the system-preferences
2039
+ * machine access to the user's environment (OS color scheme, persistent
2040
+ * storage, cross-context change notifications).
2041
+ *
2042
+ * The package owns all orchestration — synchronous seeding, idempotent
2043
+ * persistence, mapping cleared storage to `"system"`. The host's
2044
+ * implementation is pure DOM/storage glue: read, write, subscribe.
2045
+ * @public
2046
+ */
2047
+ export declare type SystemPreferencesAdapter = {
2048
+ /** Read the user's stored preference. `null` means "no preference set"
2049
+ * (the machine treats this as `"system"`). */
2050
+ getPreferredColorScheme: () => ColorSchemePreference | null;
2051
+ /** Write the user's preference to persistent storage. */
2052
+ persistPreferredColorScheme: (value: ColorSchemePreference) => void;
2053
+ /** Subscribe to cross-context preference changes (e.g. another tab
2054
+ * writing to the shared storage). The callback receives the new stored
2055
+ * value (or `null` if it was cleared). Returns an unsubscribe function. */
2056
+ subscribePreferredColorScheme: (
2057
+ callback: (next: ColorSchemePreference | null) => void,
2058
+ ) => () => void;
2059
+ /** Read the current OS-detected color scheme. */
2060
+ getOsColorScheme: () => ColorScheme;
2061
+ /** Subscribe to OS color-scheme changes (e.g. user flipping dark mode).
2062
+ * Returns an unsubscribe function. */
2063
+ subscribeOsColorScheme: (callback: (next: ColorScheme) => void) => () => void;
2064
+ };
2065
+
2066
+ /**
2067
+ * The system-preferences machine's context. Consumers read fields directly
2068
+ * (e.g. via `useSelector`) rather than going through a resolver utility —
2069
+ * the action handlers keep `colorScheme` in sync with `preferredColorScheme`
2070
+ * and `osColorScheme`.
2071
+ *
2072
+ * Note: `colorScheme` is intentionally stored as derived state in context so
2073
+ * consumers can read the resolved value directly without a utility. The
2074
+ * action handlers below are the single source of truth for the resolution.
2075
+ * @public
2076
+ */
2077
+ export declare type SystemPreferencesContext = {
2078
+ /** User's color scheme choice; `system` defers to the OS preference. */
2079
+ preferredColorScheme: ColorSchemePreference;
2080
+ /** Last reported OS color scheme. Used to resolve `colorScheme` when the
2081
+ * preference is `system`. */
2082
+ osColorScheme: ColorScheme;
2083
+ /** Resolved color scheme — what the UI should render. Recomputed by the
2084
+ * action handlers whenever an input changes. */
2085
+ colorScheme: ColorScheme;
2086
+ };
2087
+
2088
+ /**
2089
+ * Events the system-preferences machine accepts. Both originate from the
2090
+ * host's adapter — `preferredColorScheme.set` is also forwarded back to it
2091
+ * so it can persist the user's choice.
2092
+ * @public
2093
+ */
2094
+ export declare type SystemPreferencesEvent =
2095
+ | {
2096
+ type: "preferredColorScheme.set";
2097
+ preferredColorScheme: ColorSchemePreference;
2098
+ }
2099
+ | {
2100
+ type: "osColorScheme.set";
2101
+ osColorScheme: ColorScheme;
2102
+ };
2103
+
2104
+ /**
2105
+ * @internal
2106
+ */
2107
+ export declare interface TelemetryInput
2108
+ extends OSBaseInput, WorkbenchUserProperties {}
2109
+
2110
+ /**
2111
+ * @public
2112
+ */
2113
+ export declare type WorkbenchUserProperties = {
2114
+ version: string;
2115
+ organizationId: string;
2116
+ environment: string;
2117
+ userAgent: string;
2118
+ };
2119
+
2120
+ export {};