@sanity/cli-build 0.0.0-20260612071721 → 0.0.0-20260612074408
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/_exports/_internal/federation.d.ts +300 -0
- package/dist/_exports/_internal/federation.js +15 -0
- package/dist/_exports/_internal/federation.js.map +1 -0
- package/dist/workbench/contract.js +55 -0
- package/dist/workbench/contract.js.map +1 -0
- package/dist/workbench/defineApp.js +83 -0
- package/dist/workbench/defineApp.js.map +1 -0
- package/dist/workbench/defineService.js +19 -0
- package/dist/workbench/defineService.js.map +1 -0
- package/dist/workbench/defineView.js +19 -0
- package/dist/workbench/defineView.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { z } from "zod/mini";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* User-facing input for `unstable_defineApp`. Excludes the internal
|
|
5
|
+
* `applicationType` — that field is validated by the schema but is not part of
|
|
6
|
+
* the public surface (Sanity-owned apps set it via `@ts-expect-error`).
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare type DefineAppInput = Omit<
|
|
10
|
+
z.output<typeof DefineAppInputSchema>,
|
|
11
|
+
"applicationType"
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Runtime-validation schema for `unstable_defineApp`. Validates the full shape
|
|
16
|
+
* including the internal `applicationType`; the user-facing `DefineAppInput`
|
|
17
|
+
* type below omits that field.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare const DefineAppInputSchema: z.ZodMiniObject<
|
|
21
|
+
{
|
|
22
|
+
applicationType: z.ZodMiniOptional<
|
|
23
|
+
z.ZodMiniEnum<{
|
|
24
|
+
coreApp: "coreApp";
|
|
25
|
+
studio: "studio";
|
|
26
|
+
canvas: "canvas";
|
|
27
|
+
dashboard: "dashboard";
|
|
28
|
+
"media-library": "media-library";
|
|
29
|
+
system: "system";
|
|
30
|
+
}>
|
|
31
|
+
>;
|
|
32
|
+
entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
33
|
+
group: z.ZodMiniOptional<
|
|
34
|
+
z.ZodMiniEnum<{
|
|
35
|
+
"dock.system": "dock.system";
|
|
36
|
+
"dock.applications": "dock.applications";
|
|
37
|
+
"dock.user": "dock.user";
|
|
38
|
+
}>
|
|
39
|
+
>;
|
|
40
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
41
|
+
name: z.ZodMiniString<string>;
|
|
42
|
+
organizationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
44
|
+
services: z.ZodMiniOptional<
|
|
45
|
+
z.ZodMiniArray<
|
|
46
|
+
z.ZodMiniDiscriminatedUnion<
|
|
47
|
+
[
|
|
48
|
+
z.ZodMiniObject<
|
|
49
|
+
{
|
|
50
|
+
name: z.ZodMiniString<string>;
|
|
51
|
+
src: z.ZodMiniString<string>;
|
|
52
|
+
type: z.ZodMiniLiteral<"worker">;
|
|
53
|
+
},
|
|
54
|
+
z.core.$strip
|
|
55
|
+
>,
|
|
56
|
+
],
|
|
57
|
+
"type"
|
|
58
|
+
>
|
|
59
|
+
>
|
|
60
|
+
>;
|
|
61
|
+
title: z.ZodMiniString<string>;
|
|
62
|
+
views: z.ZodMiniOptional<
|
|
63
|
+
z.ZodMiniArray<
|
|
64
|
+
z.ZodMiniDiscriminatedUnion<
|
|
65
|
+
[
|
|
66
|
+
z.ZodMiniObject<
|
|
67
|
+
{
|
|
68
|
+
name: z.ZodMiniString<string>;
|
|
69
|
+
src: z.ZodMiniString<string>;
|
|
70
|
+
type: z.ZodMiniLiteral<"panel">;
|
|
71
|
+
},
|
|
72
|
+
z.core.$strip
|
|
73
|
+
>,
|
|
74
|
+
],
|
|
75
|
+
"type"
|
|
76
|
+
>
|
|
77
|
+
>
|
|
78
|
+
>;
|
|
79
|
+
},
|
|
80
|
+
z.core.$strip
|
|
81
|
+
>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The branded result of `unstable_defineApp`. Carries the same fields as the
|
|
85
|
+
* input plus the internal brand — users only ever see `DefineAppInput`.
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export declare interface DefineAppResult extends DefineAppInput {
|
|
89
|
+
readonly [WORKBENCH_APP]: true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The result of `unstable_defineService`: the author's callback, the service
|
|
94
|
+
* type, and the internal contract version the worker artifact targets.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare interface DefinedService<
|
|
98
|
+
TType extends ServiceType = ServiceType,
|
|
99
|
+
> {
|
|
100
|
+
readonly run: ServiceCallbacksByType[TType];
|
|
101
|
+
readonly type: TType;
|
|
102
|
+
/** @internal */
|
|
103
|
+
readonly version: typeof SERVICE_CONTRACT_VERSION;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The result of `unstable_defineView`: the author's component(s), the view type,
|
|
108
|
+
* and the internal contract version the build artifact targets.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare interface DefinedView<
|
|
112
|
+
TType extends InterfaceType = InterfaceType,
|
|
113
|
+
> {
|
|
114
|
+
readonly components: ViewComponentsByType[TType];
|
|
115
|
+
readonly type: TType;
|
|
116
|
+
/** @internal */
|
|
117
|
+
readonly version: typeof VIEW_CONTRACT_VERSION;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Dock group identifier. The API does not block a user app from declaring a
|
|
122
|
+
* reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned
|
|
123
|
+
* apps ahead.
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export declare type DockGroup = z.output<typeof DockGroupSchema>;
|
|
127
|
+
|
|
128
|
+
/** Dock groups an app can place itself into. */
|
|
129
|
+
declare const DockGroupSchema: z.ZodMiniEnum<{
|
|
130
|
+
"dock.system": "dock.system";
|
|
131
|
+
"dock.applications": "dock.applications";
|
|
132
|
+
"dock.user": "dock.user";
|
|
133
|
+
}>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Every supported interface type — the first argument to `unstable_defineView`.
|
|
137
|
+
* The build's component registry (`VIEW_COMPONENTS`, which expands a view into
|
|
138
|
+
* one render artifact per component) ships with the vite plugin.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare type InterfaceType = "panel";
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A panel's view-component slot — the module-federation expose for one island.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare type PanelComponent = keyof PanelViewComponents;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The component slots a `panel` view exposes — each its own module-federation
|
|
151
|
+
* island, typed with the panel props.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export declare interface PanelViewComponents {
|
|
155
|
+
panel: ViewComponent<PanelViewProps>;
|
|
156
|
+
title: ViewComponent<PanelViewProps>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Props a panel component receives: its interface record, minus the
|
|
161
|
+
* service-assigned `id`/`deployment_id` a local dev server can't provide. Mirrors
|
|
162
|
+
* the `panel` record the workbench host renders from (the wire format owned by
|
|
163
|
+
* `@sanity/workbench`); drift is guarded by the stamped contract version.
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export declare type PanelViewProps = ViewComponentBaseProps<{
|
|
167
|
+
entry_point: string;
|
|
168
|
+
interface_type: "panel";
|
|
169
|
+
name: string;
|
|
170
|
+
}>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Contract version stamped on every defined service. Lets the workbench host
|
|
174
|
+
* and the generated worker artifact evolve the service contract without
|
|
175
|
+
* breaking already-deployed services; bumped only on a breaking change.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
declare const SERVICE_CONTRACT_VERSION = 1;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A service callback. Runs once inside the worker on start; returns an optional
|
|
182
|
+
* disposer the host calls before terminating the worker.
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
export declare type ServiceCallback = (
|
|
186
|
+
context: ServiceContext,
|
|
187
|
+
) => (() => void) | void;
|
|
188
|
+
|
|
189
|
+
/** The callback shape each service type defines, keyed by type. */
|
|
190
|
+
declare interface ServiceCallbacksByType {
|
|
191
|
+
worker: ServiceCallback;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Context every service callback receives when its worker starts. Mirrors how a
|
|
196
|
+
* view component receives its `view` — the service receives its own `service`.
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
export declare interface ServiceContext {
|
|
200
|
+
readonly service: ServiceInfo;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The service's own declaration, surfaced to the callback.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export declare interface ServiceInfo {
|
|
208
|
+
readonly name: string;
|
|
209
|
+
readonly type: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Every supported service type — the first argument to `unstable_defineService`.
|
|
214
|
+
* Add a service type by adding its declaration schema below and registering it
|
|
215
|
+
* here.
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
export declare type ServiceType = "worker";
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Declare a Sanity Workbench application. Identity at runtime — returns the same
|
|
222
|
+
* object reference, tagged with the workbench brand. Field validation (the
|
|
223
|
+
* `name` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;
|
|
224
|
+
* this helper stays a thin, pure identity wrapper.
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
export declare function unstable_defineApp(
|
|
228
|
+
input: DefineAppInput,
|
|
229
|
+
): DefineAppResult;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Define a Sanity Workbench background service. The first argument narrows the
|
|
233
|
+
* callback shape — `"worker"` runs the callback inside a Web Worker, where it
|
|
234
|
+
* can emit dock-badge updates and return a disposer.
|
|
235
|
+
*
|
|
236
|
+
* Identity at runtime: returns the callback tagged with its type and the contract
|
|
237
|
+
* version, for the CLI build to generate a worker artifact from. Used as the
|
|
238
|
+
* default export of a service's `src` file.
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
export declare function unstable_defineService<TType extends ServiceType>(
|
|
242
|
+
type: TType,
|
|
243
|
+
run: ServiceCallbacksByType[TType],
|
|
244
|
+
): DefinedService<TType>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Define a Sanity Workbench view. The first argument narrows the component shape
|
|
248
|
+
* and the props each component receives — `"panel"` yields a `{title, panel}`
|
|
249
|
+
* record whose components are typed with the panel props.
|
|
250
|
+
*
|
|
251
|
+
* Returns the component(s) tagged with their type and the contract version, for
|
|
252
|
+
* the CLI build to generate render artifacts from. Used as the default export of
|
|
253
|
+
* a view's `src` file.
|
|
254
|
+
* @public
|
|
255
|
+
*/
|
|
256
|
+
export declare function unstable_defineView<TType extends InterfaceType>(
|
|
257
|
+
type: TType,
|
|
258
|
+
components: ViewComponentsByType[TType],
|
|
259
|
+
): DefinedView<TType>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Contract version stamped on every defined view — lets the host and the
|
|
263
|
+
* generated artifact evolve the contract without breaking deployed views.
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
declare const VIEW_CONTRACT_VERSION = 1;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* A view component. The return is opaque so the runtime helpers carry no React
|
|
270
|
+
* dependency — the generated artifact renders it with the app's own React.
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
declare type ViewComponent<TProps> = (props: TProps) => unknown;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Props every view component receives, whatever its type. Per-type props
|
|
277
|
+
* compose from this, so a prop added here reaches every view.
|
|
278
|
+
* @public
|
|
279
|
+
*/
|
|
280
|
+
declare interface ViewComponentBaseProps<TView> {
|
|
281
|
+
view: TView;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* The components each interface type exposes, keyed by type.
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
export declare interface ViewComponentsByType {
|
|
289
|
+
panel: PanelViewComponents;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Nominal brand the CLI discriminates on to enable the workbench build/deploy
|
|
294
|
+
* codepath. Registered via `Symbol.for` so the marker survives module-realm
|
|
295
|
+
* boundaries — `@sanity/cli-core` re-derives the same global symbol with
|
|
296
|
+
* `Symbol.for` rather than importing it, so it stays internal to this module.
|
|
297
|
+
*/
|
|
298
|
+
declare const WORKBENCH_APP: unique symbol;
|
|
299
|
+
|
|
300
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Browser-safe module-federation extension API — the canonical source for the
|
|
2
|
+
// `unstable_define*` authoring helpers and their contract. Lives in
|
|
3
|
+
// `@sanity/cli-build` (alongside the vite plugin that consumes the same
|
|
4
|
+
// contract) so there is a single source of truth; `@sanity/cli` re-exports it on
|
|
5
|
+
// its public `.` and `/runtime` entries (→ `sanity/cli` and `sanity`).
|
|
6
|
+
//
|
|
7
|
+
// This entry's module graph is zod-only — no `node:*`, no `@sanity/cli-core`, no
|
|
8
|
+
// vite — so `@sanity/cli/runtime` re-exporting it stays browser-safe under
|
|
9
|
+
// per-entry resolution, exactly as the Node-only `./vite` and `./_internal/*`
|
|
10
|
+
// entries don't leak into it.
|
|
11
|
+
export { unstable_defineApp } from '../../workbench/defineApp.js';
|
|
12
|
+
export { unstable_defineService } from '../../workbench/defineService.js';
|
|
13
|
+
export { unstable_defineView } from '../../workbench/defineView.js';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/_exports/_internal/federation.ts"],"sourcesContent":["// Browser-safe module-federation extension API — the canonical source for the\n// `unstable_define*` authoring helpers and their contract. Lives in\n// `@sanity/cli-build` (alongside the vite plugin that consumes the same\n// contract) so there is a single source of truth; `@sanity/cli` re-exports it on\n// its public `.` and `/runtime` entries (→ `sanity/cli` and `sanity`).\n//\n// This entry's module graph is zod-only — no `node:*`, no `@sanity/cli-core`, no\n// vite — so `@sanity/cli/runtime` re-exporting it stays browser-safe under\n// per-entry resolution, exactly as the Node-only `./vite` and `./_internal/*`\n// entries don't leak into it.\nexport type {InterfaceType, ServiceType} from '../../workbench/contract.js'\nexport {unstable_defineApp} from '../../workbench/defineApp.js'\nexport type {DefineAppInput, DefineAppResult, DockGroup} from '../../workbench/defineApp.js'\nexport {unstable_defineService} from '../../workbench/defineService.js'\nexport type {\n DefinedService,\n ServiceCallback,\n ServiceContext,\n ServiceInfo,\n} from '../../workbench/defineService.js'\nexport {unstable_defineView} from '../../workbench/defineView.js'\nexport type {\n DefinedView,\n PanelComponent,\n PanelViewComponents,\n PanelViewProps,\n ViewComponentsByType,\n} from '../../workbench/defineView.js'\n"],"names":["unstable_defineApp","unstable_defineService","unstable_defineView"],"mappings":"AAAA,8EAA8E;AAC9E,oEAAoE;AACpE,wEAAwE;AACxE,iFAAiF;AACjF,uEAAuE;AACvE,EAAE;AACF,iFAAiF;AACjF,2EAA2E;AAC3E,8EAA8E;AAC9E,8BAA8B;AAE9B,SAAQA,kBAAkB,QAAO,+BAA8B;AAE/D,SAAQC,sBAAsB,QAAO,mCAAkC;AAOvE,SAAQC,mBAAmB,QAAO,gCAA+B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
// The shared kernel of the module-federation extension contract: the supported
|
|
3
|
+
// view/service types, the contract versions the helpers stamp, and the
|
|
4
|
+
// declaration schemas an app author writes in `unstable_defineApp({views, services})`.
|
|
5
|
+
//
|
|
6
|
+
// Lives in `@sanity/cli-build` (alongside the vite plugin that consumes the same
|
|
7
|
+
// contract) so there is a single source of truth. `zod/mini` is used throughout
|
|
8
|
+
// cli-build to keep bundles small.
|
|
9
|
+
/**
|
|
10
|
+
* Contract version stamped on every defined view — lets the host and the
|
|
11
|
+
* generated artifact evolve the contract without breaking deployed views.
|
|
12
|
+
* @internal
|
|
13
|
+
*/ export const VIEW_CONTRACT_VERSION = 1;
|
|
14
|
+
/**
|
|
15
|
+
* Contract version stamped on every defined service. Lets the workbench host
|
|
16
|
+
* and the generated worker artifact evolve the service contract without
|
|
17
|
+
* breaking already-deployed services; bumped only on a breaking change.
|
|
18
|
+
* @internal
|
|
19
|
+
*/ export const SERVICE_CONTRACT_VERSION = 1;
|
|
20
|
+
/**
|
|
21
|
+
* Fields every extension declaration shares — a view or a service. The shape is
|
|
22
|
+
* identical (`name` + `src`); `kind` only tailors the validation message. Each
|
|
23
|
+
* declaration adds its `type` discriminator on top.
|
|
24
|
+
*/ function extensionDeclarationFields(kind) {
|
|
25
|
+
const pattern = /^[a-zA-Z0-9_-]+$/;
|
|
26
|
+
return {
|
|
27
|
+
name: z.string().check(z.regex(pattern, `${kind} \`name\` must match ${pattern}`)),
|
|
28
|
+
src: z.string()
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** What an author writes for a `panel` in `unstable_defineApp({views})`. */ const PanelViewSchema = z.object({
|
|
32
|
+
type: z.literal('panel'),
|
|
33
|
+
...extensionDeclarationFields('View')
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* The `{type, name, src}` an app declares for a view, discriminated by `type`.
|
|
37
|
+
* Persisted to the application service on deploy; never part of the app manifest.
|
|
38
|
+
* @internal
|
|
39
|
+
*/ export const InterfaceDeclarationSchema = z.discriminatedUnion('type', [
|
|
40
|
+
PanelViewSchema
|
|
41
|
+
]);
|
|
42
|
+
/** Declaration schema for a `worker` service — what a developer writes in `unstable_defineApp({services})`. */ const WorkerServiceSchema = z.object({
|
|
43
|
+
type: z.literal('worker'),
|
|
44
|
+
...extensionDeclarationFields('Service')
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* A service declared on an app, discriminated by `type`. Metadata only; built
|
|
48
|
+
* into a worker artifact and persisted to the application service on deploy,
|
|
49
|
+
* never part of the app manifest.
|
|
50
|
+
* @internal
|
|
51
|
+
*/ export const ServiceDeclarationSchema = z.discriminatedUnion('type', [
|
|
52
|
+
WorkerServiceSchema
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/workbench/contract.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n// The shared kernel of the module-federation extension contract: the supported\n// view/service types, the contract versions the helpers stamp, and the\n// declaration schemas an app author writes in `unstable_defineApp({views, services})`.\n//\n// Lives in `@sanity/cli-build` (alongside the vite plugin that consumes the same\n// contract) so there is a single source of truth. `zod/mini` is used throughout\n// cli-build to keep bundles small.\n\n/**\n * Contract version stamped on every defined view — lets the host and the\n * generated artifact evolve the contract without breaking deployed views.\n * @internal\n */\nexport const VIEW_CONTRACT_VERSION = 1\n\n/**\n * Contract version stamped on every defined service. Lets the workbench host\n * and the generated worker artifact evolve the service contract without\n * breaking already-deployed services; bumped only on a breaking change.\n * @internal\n */\nexport const SERVICE_CONTRACT_VERSION = 1\n\n/**\n * A view component. The return is opaque so the runtime helpers carry no React\n * dependency — the generated artifact renders it with the app's own React.\n * @public\n */\nexport type ViewComponent<TProps> = (props: TProps) => unknown\n\n/**\n * Props every view component receives, whatever its type. Per-type props\n * compose from this, so a prop added here reaches every view.\n * @public\n */\nexport interface ViewComponentBaseProps<TView> {\n view: TView\n}\n\n/**\n * Every supported interface type — the first argument to `unstable_defineView`.\n * The build's component registry (`VIEW_COMPONENTS`, which expands a view into\n * one render artifact per component) ships with the vite plugin.\n * @public\n */\nexport type InterfaceType = 'panel'\n\n/**\n * Every supported service type — the first argument to `unstable_defineService`.\n * Add a service type by adding its declaration schema below and registering it\n * here.\n * @public\n */\nexport type ServiceType = 'worker'\n\n/**\n * Fields every extension declaration shares — a view or a service. The shape is\n * identical (`name` + `src`); `kind` only tailors the validation message. Each\n * declaration adds its `type` discriminator on top.\n */\nfunction extensionDeclarationFields(kind: 'Service' | 'View') {\n const pattern = /^[a-zA-Z0-9_-]+$/\n return {\n name: z.string().check(z.regex(pattern, `${kind} \\`name\\` must match ${pattern}`)),\n src: z.string(),\n }\n}\n\n/** What an author writes for a `panel` in `unstable_defineApp({views})`. */\nconst PanelViewSchema = z.object({\n type: z.literal('panel'),\n ...extensionDeclarationFields('View'),\n})\n\n/**\n * The `{type, name, src}` an app declares for a view, discriminated by `type`.\n * Persisted to the application service on deploy; never part of the app manifest.\n * @internal\n */\nexport const InterfaceDeclarationSchema = z.discriminatedUnion('type', [PanelViewSchema])\n\n/** Declaration schema for a `worker` service — what a developer writes in `unstable_defineApp({services})`. */\nconst WorkerServiceSchema = z.object({\n type: z.literal('worker'),\n ...extensionDeclarationFields('Service'),\n})\n\n/**\n * A service declared on an app, discriminated by `type`. Metadata only; built\n * into a worker artifact and persisted to the application service on deploy,\n * never part of the app manifest.\n * @internal\n */\nexport const ServiceDeclarationSchema = z.discriminatedUnion('type', [WorkerServiceSchema])\n"],"names":["z","VIEW_CONTRACT_VERSION","SERVICE_CONTRACT_VERSION","extensionDeclarationFields","kind","pattern","name","string","check","regex","src","PanelViewSchema","object","type","literal","InterfaceDeclarationSchema","discriminatedUnion","WorkerServiceSchema","ServiceDeclarationSchema"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B,+EAA+E;AAC/E,uEAAuE;AACvE,uFAAuF;AACvF,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,mCAAmC;AAEnC;;;;CAIC,GACD,OAAO,MAAMC,wBAAwB,EAAC;AAEtC;;;;;CAKC,GACD,OAAO,MAAMC,2BAA2B,EAAC;AAkCzC;;;;CAIC,GACD,SAASC,2BAA2BC,IAAwB;IAC1D,MAAMC,UAAU;IAChB,OAAO;QACLC,MAAMN,EAAEO,MAAM,GAAGC,KAAK,CAACR,EAAES,KAAK,CAACJ,SAAS,GAAGD,KAAK,qBAAqB,EAAEC,SAAS;QAChFK,KAAKV,EAAEO,MAAM;IACf;AACF;AAEA,0EAA0E,GAC1E,MAAMI,kBAAkBX,EAAEY,MAAM,CAAC;IAC/BC,MAAMb,EAAEc,OAAO,CAAC;IAChB,GAAGX,2BAA2B,OAAO;AACvC;AAEA;;;;CAIC,GACD,OAAO,MAAMY,6BAA6Bf,EAAEgB,kBAAkB,CAAC,QAAQ;IAACL;CAAgB,EAAC;AAEzF,6GAA6G,GAC7G,MAAMM,sBAAsBjB,EAAEY,MAAM,CAAC;IACnCC,MAAMb,EAAEc,OAAO,CAAC;IAChB,GAAGX,2BAA2B,UAAU;AAC1C;AAEA;;;;;CAKC,GACD,OAAO,MAAMe,2BAA2BlB,EAAEgB,kBAAkB,CAAC,QAAQ;IAACC;CAAoB,EAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
import { InterfaceDeclarationSchema, ServiceDeclarationSchema } from './contract.js';
|
|
3
|
+
/** Allowed characters for an app `name`. */ const APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
4
|
+
/**
|
|
5
|
+
* Internal application discriminator. Sanity-owned singleton apps only;
|
|
6
|
+
* validated by the schema but excluded from the public `DefineAppInput` type.
|
|
7
|
+
*/ const ApplicationType = z.enum([
|
|
8
|
+
'coreApp',
|
|
9
|
+
'studio',
|
|
10
|
+
'canvas',
|
|
11
|
+
'dashboard',
|
|
12
|
+
'media-library',
|
|
13
|
+
'system'
|
|
14
|
+
]);
|
|
15
|
+
/** Dock groups an app can place itself into. */ const DockGroupSchema = z.enum([
|
|
16
|
+
'dock.system',
|
|
17
|
+
'dock.applications',
|
|
18
|
+
'dock.user'
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* Runtime-validation schema for `unstable_defineApp`. Validates the full shape
|
|
22
|
+
* including the internal `applicationType`; the user-facing `DefineAppInput`
|
|
23
|
+
* type below omits that field.
|
|
24
|
+
* @internal
|
|
25
|
+
*/ export const DefineAppInputSchema = z.object({
|
|
26
|
+
/**
|
|
27
|
+
* Internal — Sanity-owned singleton apps only. Validated here but excluded
|
|
28
|
+
* from the public `DefineAppInput` type.
|
|
29
|
+
* @internal
|
|
30
|
+
*/ applicationType: z.optional(ApplicationType),
|
|
31
|
+
/**
|
|
32
|
+
* App entrypoint module. Defaults to `./src/App.tsx` when omitted. The build
|
|
33
|
+
* derives the app's navigable `app` view from it. SDK apps only — setting it
|
|
34
|
+
* on a studio is rejected (studio app views are not yet implemented).
|
|
35
|
+
*/ entry: z.optional(z.string()),
|
|
36
|
+
/** Dock group to render in. Defaults to `dock.applications` when omitted. */ group: z.optional(DockGroupSchema),
|
|
37
|
+
/** Optional icon override (path to an SVG). Wins over manifest/studio icon. */ icon: z.optional(z.string()),
|
|
38
|
+
/** Unique app identifier — matches `/^[a-zA-Z0-9_-]+$/`. */ name: z.string().check(z.regex(APP_NAME_PATTERN, 'App `name` must match /^[a-zA-Z0-9_-]+$/')),
|
|
39
|
+
/** Organization that owns the app — required to run and deploy an SDK app. */ organizationId: z.optional(z.string()),
|
|
40
|
+
/** Sort position within the group, ascending. Defaults to `100` when omitted. */ priority: z.optional(z.number()),
|
|
41
|
+
/**
|
|
42
|
+
* Background services the app runs (e.g. a `worker` emitting dock badges).
|
|
43
|
+
* Metadata only — built into worker artifacts and persisted to the
|
|
44
|
+
* application service on deploy, not into the app manifest. Service `name`s
|
|
45
|
+
* must be unique within the app.
|
|
46
|
+
*/ services: z.optional(z.array(ServiceDeclarationSchema).check(z.refine((services)=>new Set(services.map((service)=>service.name)).size === services.length, 'Service `name` must be unique within an app'))),
|
|
47
|
+
/** User-facing app title. Wins over studio.config.ts title on merge. */ title: z.string(),
|
|
48
|
+
/**
|
|
49
|
+
* Views the app exposes (e.g. dock panels). Metadata only — built into
|
|
50
|
+
* render artifacts and persisted to the application service on deploy, not
|
|
51
|
+
* into the app manifest. View `name`s must be unique within the app.
|
|
52
|
+
*/ views: z.optional(z.array(InterfaceDeclarationSchema).check(z.refine((views)=>new Set(views.map((view)=>view.name)).size === views.length, 'View `name` must be unique within an app')))
|
|
53
|
+
}).check(// Studio app views are not implemented yet. A studio that declares `entry`
|
|
54
|
+
// (the SDK app-view entrypoint) is rejected here rather than silently
|
|
55
|
+
// generating one; studios keep navigating via their existing render path.
|
|
56
|
+
z.refine((input)=>!(input.applicationType === 'studio' && input.entry !== undefined), {
|
|
57
|
+
error: 'App views for studios are not implemented yet',
|
|
58
|
+
path: [
|
|
59
|
+
'entry'
|
|
60
|
+
]
|
|
61
|
+
}));
|
|
62
|
+
/**
|
|
63
|
+
* Nominal brand the CLI discriminates on to enable the workbench build/deploy
|
|
64
|
+
* codepath. Registered via `Symbol.for` so the marker survives module-realm
|
|
65
|
+
* boundaries — `@sanity/cli-core` re-derives the same global symbol with
|
|
66
|
+
* `Symbol.for` rather than importing it, so it stays internal to this module.
|
|
67
|
+
*/ const WORKBENCH_APP = Symbol.for('sanity.workbench.defineApp');
|
|
68
|
+
/**
|
|
69
|
+
* Declare a Sanity Workbench application. Identity at runtime — returns the same
|
|
70
|
+
* object reference, tagged with the workbench brand. Field validation (the
|
|
71
|
+
* `name` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;
|
|
72
|
+
* this helper stays a thin, pure identity wrapper.
|
|
73
|
+
* @public
|
|
74
|
+
*/ export function unstable_defineApp(input) {
|
|
75
|
+
return Object.defineProperty(input, WORKBENCH_APP, {
|
|
76
|
+
configurable: false,
|
|
77
|
+
enumerable: false,
|
|
78
|
+
value: true,
|
|
79
|
+
writable: false
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=defineApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/workbench/defineApp.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\nimport {InterfaceDeclarationSchema, ServiceDeclarationSchema} from './contract.js'\n\n/** Allowed characters for an app `name`. */\nconst APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/\n\n/**\n * Internal application discriminator. Sanity-owned singleton apps only;\n * validated by the schema but excluded from the public `DefineAppInput` type.\n */\nconst ApplicationType = z.enum([\n 'coreApp',\n 'studio',\n 'canvas',\n 'dashboard',\n 'media-library',\n 'system',\n])\n\n/** Dock groups an app can place itself into. */\nconst DockGroupSchema = z.enum(['dock.system', 'dock.applications', 'dock.user'])\n\n/**\n * Dock group identifier. The API does not block a user app from declaring a\n * reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned\n * apps ahead.\n * @public\n */\nexport type DockGroup = z.output<typeof DockGroupSchema>\n\n/**\n * Runtime-validation schema for `unstable_defineApp`. Validates the full shape\n * including the internal `applicationType`; the user-facing `DefineAppInput`\n * type below omits that field.\n * @internal\n */\nexport const DefineAppInputSchema = z\n .object({\n /**\n * Internal — Sanity-owned singleton apps only. Validated here but excluded\n * from the public `DefineAppInput` type.\n * @internal\n */\n applicationType: z.optional(ApplicationType),\n /**\n * App entrypoint module. Defaults to `./src/App.tsx` when omitted. The build\n * derives the app's navigable `app` view from it. SDK apps only — setting it\n * on a studio is rejected (studio app views are not yet implemented).\n */\n entry: z.optional(z.string()),\n /** Dock group to render in. Defaults to `dock.applications` when omitted. */\n group: z.optional(DockGroupSchema),\n /** Optional icon override (path to an SVG). Wins over manifest/studio icon. */\n icon: z.optional(z.string()),\n /** Unique app identifier — matches `/^[a-zA-Z0-9_-]+$/`. */\n name: z.string().check(z.regex(APP_NAME_PATTERN, 'App `name` must match /^[a-zA-Z0-9_-]+$/')),\n /** Organization that owns the app — required to run and deploy an SDK app. */\n organizationId: z.optional(z.string()),\n /** Sort position within the group, ascending. Defaults to `100` when omitted. */\n priority: z.optional(z.number()),\n /**\n * Background services the app runs (e.g. a `worker` emitting dock badges).\n * Metadata only — built into worker artifacts and persisted to the\n * application service on deploy, not into the app manifest. Service `name`s\n * must be unique within the app.\n */\n services: z.optional(\n z\n .array(ServiceDeclarationSchema)\n .check(\n z.refine(\n (services) => new Set(services.map((service) => service.name)).size === services.length,\n 'Service `name` must be unique within an app',\n ),\n ),\n ),\n /** User-facing app title. Wins over studio.config.ts title on merge. */\n title: z.string(),\n /**\n * Views the app exposes (e.g. dock panels). Metadata only — built into\n * render artifacts and persisted to the application service on deploy, not\n * into the app manifest. View `name`s must be unique within the app.\n */\n views: z.optional(\n z\n .array(InterfaceDeclarationSchema)\n .check(\n z.refine(\n (views) => new Set(views.map((view) => view.name)).size === views.length,\n 'View `name` must be unique within an app',\n ),\n ),\n ),\n })\n .check(\n // Studio app views are not implemented yet. A studio that declares `entry`\n // (the SDK app-view entrypoint) is rejected here rather than silently\n // generating one; studios keep navigating via their existing render path.\n z.refine((input) => !(input.applicationType === 'studio' && input.entry !== undefined), {\n error: 'App views for studios are not implemented yet',\n path: ['entry'],\n }),\n )\n\n/**\n * User-facing input for `unstable_defineApp`. Excludes the internal\n * `applicationType` — that field is validated by the schema but is not part of\n * the public surface (Sanity-owned apps set it via `@ts-expect-error`).\n * @public\n */\nexport type DefineAppInput = Omit<z.output<typeof DefineAppInputSchema>, 'applicationType'>\n\n/**\n * Nominal brand the CLI discriminates on to enable the workbench build/deploy\n * codepath. Registered via `Symbol.for` so the marker survives module-realm\n * boundaries — `@sanity/cli-core` re-derives the same global symbol with\n * `Symbol.for` rather than importing it, so it stays internal to this module.\n */\nconst WORKBENCH_APP: unique symbol = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * The branded result of `unstable_defineApp`. Carries the same fields as the\n * input plus the internal brand — users only ever see `DefineAppInput`.\n * @public\n */\nexport interface DefineAppResult extends DefineAppInput {\n readonly [WORKBENCH_APP]: true\n}\n\n/**\n * Declare a Sanity Workbench application. Identity at runtime — returns the same\n * object reference, tagged with the workbench brand. Field validation (the\n * `name` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;\n * this helper stays a thin, pure identity wrapper.\n * @public\n */\nexport function unstable_defineApp(input: DefineAppInput): DefineAppResult {\n return Object.defineProperty(input, WORKBENCH_APP, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n }) as DefineAppResult\n}\n"],"names":["z","InterfaceDeclarationSchema","ServiceDeclarationSchema","APP_NAME_PATTERN","ApplicationType","enum","DockGroupSchema","DefineAppInputSchema","object","applicationType","optional","entry","string","group","icon","name","check","regex","organizationId","priority","number","services","array","refine","Set","map","service","size","length","title","views","view","input","undefined","error","path","WORKBENCH_APP","Symbol","for","unstable_defineApp","Object","defineProperty","configurable","enumerable","value","writable"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B,SAAQC,0BAA0B,EAAEC,wBAAwB,QAAO,gBAAe;AAElF,0CAA0C,GAC1C,MAAMC,mBAAmB;AAEzB;;;CAGC,GACD,MAAMC,kBAAkBJ,EAAEK,IAAI,CAAC;IAC7B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,8CAA8C,GAC9C,MAAMC,kBAAkBN,EAAEK,IAAI,CAAC;IAAC;IAAe;IAAqB;CAAY;AAUhF;;;;;CAKC,GACD,OAAO,MAAME,uBAAuBP,EACjCQ,MAAM,CAAC;IACN;;;;KAIC,GACDC,iBAAiBT,EAAEU,QAAQ,CAACN;IAC5B;;;;KAIC,GACDO,OAAOX,EAAEU,QAAQ,CAACV,EAAEY,MAAM;IAC1B,2EAA2E,GAC3EC,OAAOb,EAAEU,QAAQ,CAACJ;IAClB,6EAA6E,GAC7EQ,MAAMd,EAAEU,QAAQ,CAACV,EAAEY,MAAM;IACzB,0DAA0D,GAC1DG,MAAMf,EAAEY,MAAM,GAAGI,KAAK,CAAChB,EAAEiB,KAAK,CAACd,kBAAkB;IACjD,4EAA4E,GAC5Ee,gBAAgBlB,EAAEU,QAAQ,CAACV,EAAEY,MAAM;IACnC,+EAA+E,GAC/EO,UAAUnB,EAAEU,QAAQ,CAACV,EAAEoB,MAAM;IAC7B;;;;;KAKC,GACDC,UAAUrB,EAAEU,QAAQ,CAClBV,EACGsB,KAAK,CAACpB,0BACNc,KAAK,CACJhB,EAAEuB,MAAM,CACN,CAACF,WAAa,IAAIG,IAAIH,SAASI,GAAG,CAAC,CAACC,UAAYA,QAAQX,IAAI,GAAGY,IAAI,KAAKN,SAASO,MAAM,EACvF;IAIR,sEAAsE,GACtEC,OAAO7B,EAAEY,MAAM;IACf;;;;KAIC,GACDkB,OAAO9B,EAAEU,QAAQ,CACfV,EACGsB,KAAK,CAACrB,4BACNe,KAAK,CACJhB,EAAEuB,MAAM,CACN,CAACO,QAAU,IAAIN,IAAIM,MAAML,GAAG,CAAC,CAACM,OAASA,KAAKhB,IAAI,GAAGY,IAAI,KAAKG,MAAMF,MAAM,EACxE;AAIV,GACCZ,KAAK,CACJ,2EAA2E;AAC3E,sEAAsE;AACtE,0EAA0E;AAC1EhB,EAAEuB,MAAM,CAAC,CAACS,QAAU,CAAEA,CAAAA,MAAMvB,eAAe,KAAK,YAAYuB,MAAMrB,KAAK,KAAKsB,SAAQ,GAAI;IACtFC,OAAO;IACPC,MAAM;QAAC;KAAQ;AACjB,IACD;AAUH;;;;;CAKC,GACD,MAAMC,gBAA+BC,OAAOC,GAAG,CAAC;AAWhD;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmBP,KAAqB;IACtD,OAAOQ,OAAOC,cAAc,CAACT,OAAOI,eAAe;QACjDM,cAAc;QACdC,YAAY;QACZC,OAAO;QACPC,UAAU;IACZ;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SERVICE_CONTRACT_VERSION } from './contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Define a Sanity Workbench background service. The first argument narrows the
|
|
4
|
+
* callback shape — `"worker"` runs the callback inside a Web Worker, where it
|
|
5
|
+
* can emit dock-badge updates and return a disposer.
|
|
6
|
+
*
|
|
7
|
+
* Identity at runtime: returns the callback tagged with its type and the contract
|
|
8
|
+
* version, for the CLI build to generate a worker artifact from. Used as the
|
|
9
|
+
* default export of a service's `src` file.
|
|
10
|
+
* @public
|
|
11
|
+
*/ export function unstable_defineService(type, run) {
|
|
12
|
+
return {
|
|
13
|
+
run,
|
|
14
|
+
type,
|
|
15
|
+
version: SERVICE_CONTRACT_VERSION
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=defineService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/workbench/defineService.ts"],"sourcesContent":["import {SERVICE_CONTRACT_VERSION, type ServiceType} from './contract.js'\n\n/**\n * The service's own declaration, surfaced to the callback.\n * @public\n */\nexport interface ServiceInfo {\n readonly name: string\n readonly type: string\n}\n\n/**\n * Context every service callback receives when its worker starts. Mirrors how a\n * view component receives its `view` — the service receives its own `service`.\n * @public\n */\nexport interface ServiceContext {\n readonly service: ServiceInfo\n}\n\n/**\n * A service callback. Runs once inside the worker on start; returns an optional\n * disposer the host calls before terminating the worker.\n * @public\n */\nexport type ServiceCallback = (context: ServiceContext) => (() => void) | void\n\n/** The callback shape each service type defines, keyed by type. */\ninterface ServiceCallbacksByType {\n worker: ServiceCallback\n}\n\n/**\n * The result of `unstable_defineService`: the author's callback, the service\n * type, and the internal contract version the worker artifact targets.\n * @public\n */\nexport interface DefinedService<TType extends ServiceType = ServiceType> {\n readonly run: ServiceCallbacksByType[TType]\n readonly type: TType\n /** @internal */\n readonly version: typeof SERVICE_CONTRACT_VERSION\n}\n\n/**\n * Define a Sanity Workbench background service. The first argument narrows the\n * callback shape — `\"worker\"` runs the callback inside a Web Worker, where it\n * can emit dock-badge updates and return a disposer.\n *\n * Identity at runtime: returns the callback tagged with its type and the contract\n * version, for the CLI build to generate a worker artifact from. Used as the\n * default export of a service's `src` file.\n * @public\n */\nexport function unstable_defineService<TType extends ServiceType>(\n type: TType,\n run: ServiceCallbacksByType[TType],\n): DefinedService<TType> {\n return {run, type, version: SERVICE_CONTRACT_VERSION}\n}\n"],"names":["SERVICE_CONTRACT_VERSION","unstable_defineService","type","run","version"],"mappings":"AAAA,SAAQA,wBAAwB,QAAyB,gBAAe;AA4CxE;;;;;;;;;CASC,GACD,OAAO,SAASC,uBACdC,IAAW,EACXC,GAAkC;IAElC,OAAO;QAACA;QAAKD;QAAME,SAASJ;IAAwB;AACtD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VIEW_CONTRACT_VERSION } from './contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Define a Sanity Workbench view. The first argument narrows the component shape
|
|
4
|
+
* and the props each component receives — `"panel"` yields a `{title, panel}`
|
|
5
|
+
* record whose components are typed with the panel props.
|
|
6
|
+
*
|
|
7
|
+
* Returns the component(s) tagged with their type and the contract version, for
|
|
8
|
+
* the CLI build to generate render artifacts from. Used as the default export of
|
|
9
|
+
* a view's `src` file.
|
|
10
|
+
* @public
|
|
11
|
+
*/ export function unstable_defineView(type, components) {
|
|
12
|
+
return {
|
|
13
|
+
components,
|
|
14
|
+
type,
|
|
15
|
+
version: VIEW_CONTRACT_VERSION
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=defineView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/workbench/defineView.ts"],"sourcesContent":["import {\n type InterfaceType,\n VIEW_CONTRACT_VERSION,\n type ViewComponent,\n type ViewComponentBaseProps,\n} from './contract.js'\n\n/**\n * Props a panel component receives: its interface record, minus the\n * service-assigned `id`/`deployment_id` a local dev server can't provide. Mirrors\n * the `panel` record the workbench host renders from (the wire format owned by\n * `@sanity/workbench`); drift is guarded by the stamped contract version.\n * @public\n */\nexport type PanelViewProps = ViewComponentBaseProps<{\n entry_point: string\n interface_type: 'panel'\n name: string\n}>\n\n/**\n * The component slots a `panel` view exposes — each its own module-federation\n * island, typed with the panel props.\n * @public\n */\nexport interface PanelViewComponents {\n panel: ViewComponent<PanelViewProps>\n title: ViewComponent<PanelViewProps>\n}\n\n/**\n * A panel's view-component slot — the module-federation expose for one island.\n * @public\n */\nexport type PanelComponent = keyof PanelViewComponents\n\n/**\n * The components each interface type exposes, keyed by type.\n * @public\n */\nexport interface ViewComponentsByType {\n panel: PanelViewComponents\n}\n\n/**\n * The result of `unstable_defineView`: the author's component(s), the view type,\n * and the internal contract version the build artifact targets.\n * @public\n */\nexport interface DefinedView<TType extends InterfaceType = InterfaceType> {\n readonly components: ViewComponentsByType[TType]\n readonly type: TType\n /** @internal */\n readonly version: typeof VIEW_CONTRACT_VERSION\n}\n\n/**\n * Define a Sanity Workbench view. The first argument narrows the component shape\n * and the props each component receives — `\"panel\"` yields a `{title, panel}`\n * record whose components are typed with the panel props.\n *\n * Returns the component(s) tagged with their type and the contract version, for\n * the CLI build to generate render artifacts from. Used as the default export of\n * a view's `src` file.\n * @public\n */\nexport function unstable_defineView<TType extends InterfaceType>(\n type: TType,\n components: ViewComponentsByType[TType],\n): DefinedView<TType> {\n return {components, type, version: VIEW_CONTRACT_VERSION}\n}\n"],"names":["VIEW_CONTRACT_VERSION","unstable_defineView","type","components","version"],"mappings":"AAAA,SAEEA,qBAAqB,QAGhB,gBAAe;AAmDtB;;;;;;;;;CASC,GACD,OAAO,SAASC,oBACdC,IAAW,EACXC,UAAuC;IAEvC,OAAO;QAACA;QAAYD;QAAME,SAASJ;IAAqB;AAC1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-build",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20260612074408",
|
|
4
4
|
"description": "Internal Sanity package for building studios and apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"source": "./src/_exports/_internal/extract.ts",
|
|
37
37
|
"default": "./dist/_exports/_internal/extract.js"
|
|
38
38
|
},
|
|
39
|
+
"./_internal/federation": {
|
|
40
|
+
"source": "./src/_exports/_internal/federation.ts",
|
|
41
|
+
"default": "./dist/_exports/_internal/federation.js"
|
|
42
|
+
},
|
|
39
43
|
"./package.json": "./package.json"
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
@@ -62,7 +66,7 @@
|
|
|
62
66
|
"semver": "^7.8.1",
|
|
63
67
|
"vite": "^8.0.16",
|
|
64
68
|
"zod": "^4.4.3",
|
|
65
|
-
"@sanity/cli-core": "^0.0.0-
|
|
69
|
+
"@sanity/cli-core": "^0.0.0-20260612074408"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@eslint/compat": "^2.1.0",
|
|
@@ -89,7 +93,7 @@
|
|
|
89
93
|
"vitest": "^4.1.8",
|
|
90
94
|
"@repo/package.config": "0.0.1",
|
|
91
95
|
"@repo/tsconfig": "3.70.0",
|
|
92
|
-
"@sanity/cli-test": "0.0.0-
|
|
96
|
+
"@sanity/cli-test": "0.0.0-20260612074408",
|
|
93
97
|
"@sanity/eslint-config-cli": "^1.1.2"
|
|
94
98
|
},
|
|
95
99
|
"peerDependencies": {
|