@sanity/workbench 0.1.0-alpha.15 → 0.1.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/system.d.ts CHANGED
@@ -1,10 +1,13 @@
1
+ import { ActorRefFrom } from "xstate";
1
2
  import { ActorRefFromLogic } from "xstate";
3
+ import { AnyEventObject } from "xstate";
2
4
  import { AuthState } from "@sanity/sdk";
3
5
  import { AuthStateType } from "@sanity/sdk";
4
6
  import { CallbackActorLogic } from "xstate";
5
7
  import { ConsentStatus } from "@sanity/telemetry";
6
8
  import { CurrentUser } from "@sanity/sdk";
7
9
  import { EventObject } from "xstate";
10
+ import { FederationInstance } from "@sanity/federation/runtime";
8
11
  import { InspectionEvent } from "xstate";
9
12
  import { MetaObject } from "xstate";
10
13
  import { NonReducibleUnknown } from "xstate";
@@ -37,6 +40,16 @@ export declare function createOSOptions(input: OSInput): {
37
40
  inspect: (event: InspectionEvent) => void;
38
41
  };
39
42
 
43
+ /**
44
+ * @public
45
+ */
46
+ export declare interface LoadedRemoteModule {
47
+ render: (
48
+ rootElement: HTMLElement,
49
+ options?: RemoteRenderOptions,
50
+ ) => () => void;
51
+ }
52
+
40
53
  /**
41
54
  * @internal
42
55
  */
@@ -70,6 +83,169 @@ export declare const os: StateMachine<
70
83
  type: "boot.telemetry.ready";
71
84
  },
72
85
  {
86
+ remotes?:
87
+ | ActorRefFromLogic<
88
+ StateMachine<
89
+ {
90
+ instance: FederationInstance;
91
+ children: Map<string, ActorRefFrom<remoteLogic>>;
92
+ },
93
+ | {
94
+ type: "remote.load.request";
95
+ id: string;
96
+ entry: string;
97
+ }
98
+ | {
99
+ type: "remote.settled";
100
+ id: string;
101
+ status: "loaded" | "error";
102
+ },
103
+ {
104
+ [x: string]:
105
+ | ActorRefFromLogic<
106
+ StateMachine<
107
+ RemoteInput & {
108
+ module: LoadedRemoteModule | null;
109
+ error: RemoteError | null;
110
+ },
111
+ AnyEventObject,
112
+ {
113
+ [x: string]:
114
+ | ActorRefFromLogic<
115
+ PromiseActorLogic<
116
+ LoadedRemoteModule,
117
+ RemoteInput,
118
+ EventObject
119
+ >
120
+ >
121
+ | undefined;
122
+ },
123
+ {
124
+ src: "load";
125
+ logic: PromiseActorLogic<
126
+ LoadedRemoteModule,
127
+ RemoteInput,
128
+ EventObject
129
+ >;
130
+ id: string | undefined;
131
+ },
132
+ | {
133
+ type: "setModule";
134
+ params: {
135
+ module: LoadedRemoteModule;
136
+ };
137
+ }
138
+ | {
139
+ type: "setError";
140
+ params: {
141
+ error: unknown;
142
+ };
143
+ },
144
+ never,
145
+ never,
146
+ "error" | "loading" | "loaded",
147
+ "loading" | "ready" | "failed",
148
+ RemoteInput,
149
+ NonReducibleUnknown,
150
+ EventObject,
151
+ MetaObject,
152
+ {
153
+ id: "remote";
154
+ states: {
155
+ readonly loading: {};
156
+ readonly loaded: {};
157
+ readonly error: {};
158
+ };
159
+ }
160
+ >
161
+ >
162
+ | undefined;
163
+ },
164
+ {
165
+ src: "remote";
166
+ logic: StateMachine<
167
+ RemoteInput & {
168
+ module: LoadedRemoteModule | null;
169
+ error: RemoteError | null;
170
+ },
171
+ AnyEventObject,
172
+ {
173
+ [x: string]:
174
+ | ActorRefFromLogic<
175
+ PromiseActorLogic<
176
+ LoadedRemoteModule,
177
+ RemoteInput,
178
+ EventObject
179
+ >
180
+ >
181
+ | undefined;
182
+ },
183
+ {
184
+ src: "load";
185
+ logic: PromiseActorLogic<
186
+ LoadedRemoteModule,
187
+ RemoteInput,
188
+ EventObject
189
+ >;
190
+ id: string | undefined;
191
+ },
192
+ | {
193
+ type: "setModule";
194
+ params: {
195
+ module: LoadedRemoteModule;
196
+ };
197
+ }
198
+ | {
199
+ type: "setError";
200
+ params: {
201
+ error: unknown;
202
+ };
203
+ },
204
+ never,
205
+ never,
206
+ "error" | "loading" | "loaded",
207
+ "loading" | "ready" | "failed",
208
+ RemoteInput,
209
+ NonReducibleUnknown,
210
+ EventObject,
211
+ MetaObject,
212
+ {
213
+ id: "remote";
214
+ states: {
215
+ readonly loading: {};
216
+ readonly loaded: {};
217
+ readonly error: {};
218
+ };
219
+ }
220
+ >;
221
+ id: string | undefined;
222
+ },
223
+ {
224
+ type: "spawnRemote";
225
+ params: {
226
+ id: string;
227
+ entry: string;
228
+ };
229
+ },
230
+ {
231
+ type: "remoteNotKnown";
232
+ params: {
233
+ id: string;
234
+ };
235
+ },
236
+ never,
237
+ {},
238
+ string,
239
+ NonReducibleUnknown,
240
+ NonReducibleUnknown,
241
+ EventObject,
242
+ MetaObject,
243
+ {
244
+ id: "remotes";
245
+ }
246
+ >
247
+ >
248
+ | undefined;
73
249
  telemetry?:
74
250
  | ActorRefFromLogic<
75
251
  StateMachine<
@@ -178,6 +354,12 @@ export declare const os: StateMachine<
178
354
  logic: PromiseActorLogic<void, LogoutInput, EventObject>;
179
355
  id: string | undefined;
180
356
  },
357
+ | {
358
+ type: "setError";
359
+ params: {
360
+ error: unknown;
361
+ };
362
+ }
181
363
  | {
182
364
  type: "setLoggedIn";
183
365
  params: {
@@ -188,12 +370,6 @@ export declare const os: StateMachine<
188
370
  | {
189
371
  type: "clearAuth";
190
372
  params: NonReducibleUnknown;
191
- }
192
- | {
193
- type: "setError";
194
- params: {
195
- error: unknown;
196
- };
197
373
  },
198
374
  | {
199
375
  type: "isLoggedInComplete";
@@ -301,6 +477,169 @@ export declare const os: StateMachine<
301
477
  >
302
478
  | undefined;
303
479
  },
480
+ | {
481
+ src: "remotes";
482
+ logic: StateMachine<
483
+ {
484
+ instance: FederationInstance;
485
+ children: Map<string, ActorRefFrom<remoteLogic>>;
486
+ },
487
+ | {
488
+ type: "remote.load.request";
489
+ id: string;
490
+ entry: string;
491
+ }
492
+ | {
493
+ type: "remote.settled";
494
+ id: string;
495
+ status: "loaded" | "error";
496
+ },
497
+ {
498
+ [x: string]:
499
+ | ActorRefFromLogic<
500
+ StateMachine<
501
+ RemoteInput & {
502
+ module: LoadedRemoteModule | null;
503
+ error: RemoteError | null;
504
+ },
505
+ AnyEventObject,
506
+ {
507
+ [x: string]:
508
+ | ActorRefFromLogic<
509
+ PromiseActorLogic<
510
+ LoadedRemoteModule,
511
+ RemoteInput,
512
+ EventObject
513
+ >
514
+ >
515
+ | undefined;
516
+ },
517
+ {
518
+ src: "load";
519
+ logic: PromiseActorLogic<
520
+ LoadedRemoteModule,
521
+ RemoteInput,
522
+ EventObject
523
+ >;
524
+ id: string | undefined;
525
+ },
526
+ | {
527
+ type: "setModule";
528
+ params: {
529
+ module: LoadedRemoteModule;
530
+ };
531
+ }
532
+ | {
533
+ type: "setError";
534
+ params: {
535
+ error: unknown;
536
+ };
537
+ },
538
+ never,
539
+ never,
540
+ "error" | "loading" | "loaded",
541
+ "loading" | "ready" | "failed",
542
+ RemoteInput,
543
+ NonReducibleUnknown,
544
+ EventObject,
545
+ MetaObject,
546
+ {
547
+ id: "remote";
548
+ states: {
549
+ readonly loading: {};
550
+ readonly loaded: {};
551
+ readonly error: {};
552
+ };
553
+ }
554
+ >
555
+ >
556
+ | undefined;
557
+ },
558
+ {
559
+ src: "remote";
560
+ logic: StateMachine<
561
+ RemoteInput & {
562
+ module: LoadedRemoteModule | null;
563
+ error: RemoteError | null;
564
+ },
565
+ AnyEventObject,
566
+ {
567
+ [x: string]:
568
+ | ActorRefFromLogic<
569
+ PromiseActorLogic<
570
+ LoadedRemoteModule,
571
+ RemoteInput,
572
+ EventObject
573
+ >
574
+ >
575
+ | undefined;
576
+ },
577
+ {
578
+ src: "load";
579
+ logic: PromiseActorLogic<
580
+ LoadedRemoteModule,
581
+ RemoteInput,
582
+ EventObject
583
+ >;
584
+ id: string | undefined;
585
+ },
586
+ | {
587
+ type: "setModule";
588
+ params: {
589
+ module: LoadedRemoteModule;
590
+ };
591
+ }
592
+ | {
593
+ type: "setError";
594
+ params: {
595
+ error: unknown;
596
+ };
597
+ },
598
+ never,
599
+ never,
600
+ "error" | "loading" | "loaded",
601
+ "loading" | "ready" | "failed",
602
+ RemoteInput,
603
+ NonReducibleUnknown,
604
+ EventObject,
605
+ MetaObject,
606
+ {
607
+ id: "remote";
608
+ states: {
609
+ readonly loading: {};
610
+ readonly loaded: {};
611
+ readonly error: {};
612
+ };
613
+ }
614
+ >;
615
+ id: string | undefined;
616
+ },
617
+ {
618
+ type: "spawnRemote";
619
+ params: {
620
+ id: string;
621
+ entry: string;
622
+ };
623
+ },
624
+ {
625
+ type: "remoteNotKnown";
626
+ params: {
627
+ id: string;
628
+ };
629
+ },
630
+ never,
631
+ {},
632
+ string,
633
+ NonReducibleUnknown,
634
+ NonReducibleUnknown,
635
+ EventObject,
636
+ MetaObject,
637
+ {
638
+ id: "remotes";
639
+ }
640
+ >;
641
+ id: "remotes";
642
+ }
304
643
  | {
305
644
  src: "telemetry";
306
645
  logic: StateMachine<
@@ -409,6 +748,12 @@ export declare const os: StateMachine<
409
748
  logic: PromiseActorLogic<void, LogoutInput, EventObject>;
410
749
  id: string | undefined;
411
750
  },
751
+ | {
752
+ type: "setError";
753
+ params: {
754
+ error: unknown;
755
+ };
756
+ }
412
757
  | {
413
758
  type: "setLoggedIn";
414
759
  params: {
@@ -419,12 +764,6 @@ export declare const os: StateMachine<
419
764
  | {
420
765
  type: "clearAuth";
421
766
  params: NonReducibleUnknown;
422
- }
423
- | {
424
- type: "setError";
425
- params: {
426
- error: unknown;
427
- };
428
767
  },
429
768
  | {
430
769
  type: "isLoggedInComplete";
@@ -595,6 +934,99 @@ declare type OSInput = WorkbenchUserProperties & {
595
934
  systemPreferencesAdapter?: SystemPreferencesAdapter;
596
935
  };
597
936
 
937
+ declare type RemoteContext = RemoteInput & {
938
+ module: LoadedRemoteModule | null;
939
+ error: RemoteError | null;
940
+ };
941
+
942
+ /**
943
+ * @public
944
+ */
945
+ export declare interface RemoteError {
946
+ message: string;
947
+ cause: unknown;
948
+ }
949
+
950
+ /**
951
+ * @internal
952
+ */
953
+ export declare interface RemoteInput {
954
+ id: string;
955
+ entry: string;
956
+ instance: FederationInstance;
957
+ }
958
+
959
+ /**
960
+ * Lifecycle machine for a single federated application remote.
961
+ *
962
+ * Spawned by the {@link remotesLogic} supervisor on demand. Each instance
963
+ * owns one remote's load lifecycle: `loading` → `loaded | error`. Tags
964
+ * (`loading` / `ready` / `failed`) drive the UI contract — state names
965
+ * are internal.
966
+ *
967
+ * The machine sends a `remote.settled` event to its parent on entry to
968
+ * either terminal state, reserved for future supervision/retry.
969
+ *
970
+ * @internal
971
+ */
972
+ declare const remoteLogic: StateMachine<
973
+ RemoteContext,
974
+ AnyEventObject,
975
+ {
976
+ [x: string]:
977
+ | ActorRefFromLogic<
978
+ PromiseActorLogic<LoadedRemoteModule, RemoteInput, EventObject>
979
+ >
980
+ | undefined;
981
+ },
982
+ {
983
+ src: "load";
984
+ logic: PromiseActorLogic<LoadedRemoteModule, RemoteInput, EventObject>;
985
+ id: string | undefined;
986
+ },
987
+ | {
988
+ type: "setModule";
989
+ params: {
990
+ module: LoadedRemoteModule;
991
+ };
992
+ }
993
+ | {
994
+ type: "setError";
995
+ params: {
996
+ error: unknown;
997
+ };
998
+ },
999
+ never,
1000
+ never,
1001
+ "error" | "loading" | "loaded",
1002
+ "loading" | "ready" | "failed",
1003
+ RemoteInput,
1004
+ NonReducibleUnknown,
1005
+ EventObject,
1006
+ MetaObject,
1007
+ {
1008
+ id: "remote";
1009
+ states: {
1010
+ readonly loading: {};
1011
+ readonly loaded: {};
1012
+ readonly error: {};
1013
+ };
1014
+ }
1015
+ >;
1016
+
1017
+ /**
1018
+ * @public
1019
+ */
1020
+ export declare interface RemoteRenderOptions {
1021
+ basePath?: string;
1022
+ scheme?: "light" | "dark";
1023
+ /**
1024
+ * This is a temporary measure designed to authenticate federated
1025
+ * studios & SDK apps before we write a working protocol.
1026
+ */
1027
+ unstable_temporaryToken?: string | null;
1028
+ }
1029
+
598
1030
  /**
599
1031
  * Adapter interface the host implements to give the system-preferences
600
1032
  * machine access to the user's environment (OS color scheme, persistent