@anvilkit/contracts 0.1.18

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.
@@ -0,0 +1,240 @@
1
+ /**
2
+ * @file Export format contract — the shape every exporter plugin
3
+ * (HTML, React, JSON, …) registers with the Studio runtime.
4
+ *
5
+ * ### Why `run(ir, options)` and not `run(data, options)`?
6
+ *
7
+ * All exports normalize through {@link PageIR} first. This invariant
8
+ * is enforced at the **type** level here — {@link
9
+ * ExportFormatDefinition.run} accepts a `PageIR`, not a Puck `Data`.
10
+ * Authors of new exporters cannot accidentally skip IR normalization;
11
+ * they physically cannot type-check a function that takes `Data`.
12
+ *
13
+ * The normalization step (Puck `Data` → `PageIR`) lives in
14
+ * `@anvilkit/ir` (Phase 3) and is called once by the export pipeline
15
+ * before any registered format runs.
16
+ *
17
+ * ### Design rules
18
+ *
19
+ * 1. **Types only.** This file has zero runtime code.
20
+ * 2. **Generic options.** {@link ExportOptions} is an identity type
21
+ * with a `Record<string, unknown>` constraint, so format authors
22
+ * can declare a strongly-typed option bag while the runtime
23
+ * treats all formats uniformly.
24
+ * 3. **Unicode or bytes.** {@link ExportResult.content} is
25
+ * `string | Uint8Array` so text formats (HTML, JSON, Markdown)
26
+ * stay strings and binary formats (PDF, ZIP) stay bytes — no
27
+ * base64 round-tripping.
28
+ *
29
+ * @see {@link https://github.com/anvilkit/studio/blob/main/docs/tasks/core-006-types-domain.md | core-006}
30
+ */
31
+ import type { IRAssetResolver } from "./assets.js";
32
+ import type { PageIR } from "./ir.js";
33
+ /**
34
+ * Severity of a warning produced during an export run.
35
+ *
36
+ * - `"info"` — advisory; nothing wrong, just worth noting.
37
+ * - `"warn"` — non-fatal concern (e.g. missing alt text, unused
38
+ * prop).
39
+ * - `"error"` — the export succeeded but emitted output the user
40
+ * should almost certainly fix (e.g. unresolved asset url). An
41
+ * exporter that cannot produce output at all should `throw` with
42
+ * a `StudioExportError`, not return an `"error"` warning.
43
+ */
44
+ export type ExportWarningLevel = "info" | "warn" | "error";
45
+ /**
46
+ * A single diagnostic emitted by an exporter.
47
+ *
48
+ * Warnings are advisory — they do not abort the export. Host apps
49
+ * typically surface them in a toast or a dev console. Hard failures
50
+ * should throw `StudioExportError` (see `core-008`), not return a
51
+ * warning with `level: "error"`.
52
+ */
53
+ export interface ExportWarning {
54
+ /**
55
+ * Severity of this warning. See {@link ExportWarningLevel}.
56
+ */
57
+ readonly level: ExportWarningLevel;
58
+ /**
59
+ * Machine-readable warning code (e.g. `"missing-alt-text"`).
60
+ *
61
+ * Stable across releases so host apps can filter or localize.
62
+ * Codes are plugin-defined; Core does not maintain a registry.
63
+ */
64
+ readonly code: string;
65
+ /**
66
+ * Human-readable warning message suitable for developer-facing
67
+ * surfaces (dev console, toast, logs).
68
+ */
69
+ readonly message: string;
70
+ /**
71
+ * Optional {@link PageIRNode.id} the warning is attached to.
72
+ *
73
+ * When present, host UIs may highlight the offending node in the
74
+ * editor.
75
+ */
76
+ readonly nodeId?: string;
77
+ }
78
+ /**
79
+ * Generic bag of format-specific options passed to
80
+ * {@link ExportFormatDefinition.run}.
81
+ *
82
+ * Declared as a constrained identity type rather than a bare
83
+ * `Record<string, unknown>` so format authors can parameterize their
84
+ * own `run()` signature with a strongly-typed option shape while the
85
+ * runtime's dispatch layer treats every format's options uniformly.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * interface HtmlExportOptions extends Record<string, unknown> {
90
+ * readonly inlineStyles: boolean;
91
+ * readonly minify?: boolean;
92
+ * }
93
+ *
94
+ * const htmlFormat: ExportFormatDefinition<HtmlExportOptions> = {
95
+ * id: "html",
96
+ * label: "HTML",
97
+ * extension: "html",
98
+ * mimeType: "text/html",
99
+ * async run(ir, options) {
100
+ * // ^? options: ExportOptions<HtmlExportOptions>
101
+ * // ^? options.inlineStyles is typed as boolean
102
+ * return { content: "<!doctype html>…", filename: "page.html" };
103
+ * },
104
+ * };
105
+ * ```
106
+ *
107
+ * @typeParam T - Format-specific option shape. Defaults to an
108
+ * unconstrained `Record<string, unknown>` so formats that don't care
109
+ * about options can omit the type parameter entirely.
110
+ */
111
+ export type ExportOptions<T extends Record<string, unknown> = Record<string, unknown>> = T;
112
+ /**
113
+ * Per-run context handed to {@link ExportFormatDefinition.run} for
114
+ * formats that opt into asset-URL rewriting (review finding TS-c).
115
+ *
116
+ * `assetResolvers` is the runtime's registration-ordered resolver list
117
+ * (sourced from `StudioRuntime.assetResolvers`): a format consults each
118
+ * resolver in order and stops at the first that returns a non-null
119
+ * rewrite. Absent or empty ⇒ no rewriting is applied; how a format then
120
+ * treats a reference no resolver handles is its own policy — the bundled
121
+ * HTML / React exporters omit unresolved `asset://` / `design://` refs and
122
+ * emit an `ASSET_UNRESOLVED` warning rather than passing them through.
123
+ */
124
+ export interface ExportFormatRunContext {
125
+ readonly assetResolvers?: readonly IRAssetResolver[];
126
+ }
127
+ /**
128
+ * The return value of a successful {@link ExportFormatDefinition.run}
129
+ * call.
130
+ *
131
+ * Text formats (HTML, JSON, Markdown, React source) should set
132
+ * {@link content} to a `string`. Binary formats (PDF, ZIP, images)
133
+ * should set it to a `Uint8Array`. Host apps dispatch on the type at
134
+ * download time — a `string` becomes a `Blob` with the format's
135
+ * `mimeType`, a `Uint8Array` becomes a `Blob` wrapping the raw bytes.
136
+ */
137
+ export interface ExportResult {
138
+ /**
139
+ * The serialized output.
140
+ *
141
+ * Use `string` for text formats and `Uint8Array` for binary
142
+ * formats. Do not base64-encode binary content into a string;
143
+ * host apps handle the two cases differently.
144
+ */
145
+ readonly content: string | Uint8Array;
146
+ /**
147
+ * The suggested filename for the download, including the
148
+ * extension (e.g. `"page.html"`, `"page.pdf"`).
149
+ *
150
+ * Host apps may override this at the download step, but the
151
+ * exporter is expected to provide a sensible default.
152
+ */
153
+ readonly filename: string;
154
+ /**
155
+ * Optional non-fatal diagnostics emitted during the export run.
156
+ *
157
+ * See {@link ExportWarning}. Host apps may surface these in a
158
+ * dev console or toast; the export itself is still considered
159
+ * successful.
160
+ */
161
+ readonly warnings?: readonly ExportWarning[];
162
+ }
163
+ /**
164
+ * The descriptor every exporter plugin contributes to Studio.
165
+ *
166
+ * Registered via `StudioPluginRegistration.exportFormats` (part of
167
+ * the plugin surface that stays in `@anvilkit/core`).
168
+ * The runtime collects every registered definition into the export
169
+ * registry (`core-009`) and dispatches to the matching `id` when the
170
+ * host calls `exportAs(formatId, options)`.
171
+ *
172
+ * ### `run(ir, options, ctx?)` contract
173
+ *
174
+ * The `run` callback receives a fully-normalized {@link PageIR}, not
175
+ * a Puck `Data`. The IR normalization step (Puck `Data` → `PageIR`)
176
+ * is performed exactly once by the export pipeline before any format
177
+ * runs, ensuring every exporter sees the same input regardless of
178
+ * how the page was authored.
179
+ *
180
+ * Format authors should treat the `ir` argument as deeply read-only.
181
+ * Mutating it has no effect on the runtime and may break other
182
+ * exporters in the same pipeline.
183
+ *
184
+ * @typeParam Opts - Optional format-specific option shape. See
185
+ * {@link ExportOptions} for an example of how to parameterize a
186
+ * concrete format. Defaults to an unconstrained
187
+ * `Record<string, unknown>`.
188
+ */
189
+ export interface ExportFormatDefinition<Opts extends Record<string, unknown> = Record<string, unknown>> {
190
+ /**
191
+ * Stable, globally-unique format identifier (e.g. `"html"`,
192
+ * `"react"`, `"json"`).
193
+ *
194
+ * The runtime rejects duplicate ids at `createExportRegistry()`
195
+ * time. Convention: lowercase, hyphen-separated, no namespace
196
+ * prefix — host apps refer to formats by id in their UI.
197
+ */
198
+ readonly id: string;
199
+ /**
200
+ * Human-readable label surfaced in export menus and dialogs
201
+ * (e.g. `"HTML"`, `"React source"`, `"JSON snapshot"`).
202
+ */
203
+ readonly label: string;
204
+ /**
205
+ * Optional i18n message key for the label, resolved by the chrome via
206
+ * `useMsg(labelKey, label)` at render — so the export menu localizes
207
+ * with the active locale. When present it wins; `label` is the
208
+ * missing-key fallback. Plugins contribute the key via
209
+ * `ctx.registerMessages` under their own namespace.
210
+ */
211
+ readonly labelKey?: string;
212
+ /**
213
+ * File extension (without the leading dot) for downloads in this
214
+ * format (e.g. `"html"`, `"jsx"`, `"json"`, `"pdf"`).
215
+ */
216
+ readonly extension: string;
217
+ /**
218
+ * MIME type for the exported content (e.g. `"text/html"`,
219
+ * `"application/json"`, `"application/pdf"`).
220
+ *
221
+ * Used by host apps to set the correct `Blob` type at download
222
+ * time and to populate the `Content-Type` header when sending
223
+ * exports over the network.
224
+ */
225
+ readonly mimeType: string;
226
+ /**
227
+ * Produce the serialized output for a page.
228
+ *
229
+ * Receives a normalized {@link PageIR} and a format-specific
230
+ * {@link ExportOptions} bag. Returns a `Promise<ExportResult>`
231
+ * — always async so the contract is uniform regardless of
232
+ * whether a given format happens to run synchronously.
233
+ *
234
+ * @param ir - The normalized page IR. Deeply read-only.
235
+ * @param options - Format-specific option bag.
236
+ * @param ctx - Optional runtime context for additive export hooks.
237
+ */
238
+ readonly run: (ir: PageIR, options: ExportOptions<Opts>, ctx?: ExportFormatRunContext) => Promise<ExportResult>;
239
+ }
240
+ //# sourceMappingURL=export.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.cts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAA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AY,CAAC,CAAC;CAC3B"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * @file Export format contract — the shape every exporter plugin
3
+ * (HTML, React, JSON, …) registers with the Studio runtime.
4
+ *
5
+ * ### Why `run(ir, options)` and not `run(data, options)`?
6
+ *
7
+ * All exports normalize through {@link PageIR} first. This invariant
8
+ * is enforced at the **type** level here — {@link
9
+ * ExportFormatDefinition.run} accepts a `PageIR`, not a Puck `Data`.
10
+ * Authors of new exporters cannot accidentally skip IR normalization;
11
+ * they physically cannot type-check a function that takes `Data`.
12
+ *
13
+ * The normalization step (Puck `Data` → `PageIR`) lives in
14
+ * `@anvilkit/ir` (Phase 3) and is called once by the export pipeline
15
+ * before any registered format runs.
16
+ *
17
+ * ### Design rules
18
+ *
19
+ * 1. **Types only.** This file has zero runtime code.
20
+ * 2. **Generic options.** {@link ExportOptions} is an identity type
21
+ * with a `Record<string, unknown>` constraint, so format authors
22
+ * can declare a strongly-typed option bag while the runtime
23
+ * treats all formats uniformly.
24
+ * 3. **Unicode or bytes.** {@link ExportResult.content} is
25
+ * `string | Uint8Array` so text formats (HTML, JSON, Markdown)
26
+ * stay strings and binary formats (PDF, ZIP) stay bytes — no
27
+ * base64 round-tripping.
28
+ *
29
+ * @see {@link https://github.com/anvilkit/studio/blob/main/docs/tasks/core-006-types-domain.md | core-006}
30
+ */
31
+ import type { IRAssetResolver } from "./assets.js";
32
+ import type { PageIR } from "./ir.js";
33
+ /**
34
+ * Severity of a warning produced during an export run.
35
+ *
36
+ * - `"info"` — advisory; nothing wrong, just worth noting.
37
+ * - `"warn"` — non-fatal concern (e.g. missing alt text, unused
38
+ * prop).
39
+ * - `"error"` — the export succeeded but emitted output the user
40
+ * should almost certainly fix (e.g. unresolved asset url). An
41
+ * exporter that cannot produce output at all should `throw` with
42
+ * a `StudioExportError`, not return an `"error"` warning.
43
+ */
44
+ export type ExportWarningLevel = "info" | "warn" | "error";
45
+ /**
46
+ * A single diagnostic emitted by an exporter.
47
+ *
48
+ * Warnings are advisory — they do not abort the export. Host apps
49
+ * typically surface them in a toast or a dev console. Hard failures
50
+ * should throw `StudioExportError` (see `core-008`), not return a
51
+ * warning with `level: "error"`.
52
+ */
53
+ export interface ExportWarning {
54
+ /**
55
+ * Severity of this warning. See {@link ExportWarningLevel}.
56
+ */
57
+ readonly level: ExportWarningLevel;
58
+ /**
59
+ * Machine-readable warning code (e.g. `"missing-alt-text"`).
60
+ *
61
+ * Stable across releases so host apps can filter or localize.
62
+ * Codes are plugin-defined; Core does not maintain a registry.
63
+ */
64
+ readonly code: string;
65
+ /**
66
+ * Human-readable warning message suitable for developer-facing
67
+ * surfaces (dev console, toast, logs).
68
+ */
69
+ readonly message: string;
70
+ /**
71
+ * Optional {@link PageIRNode.id} the warning is attached to.
72
+ *
73
+ * When present, host UIs may highlight the offending node in the
74
+ * editor.
75
+ */
76
+ readonly nodeId?: string;
77
+ }
78
+ /**
79
+ * Generic bag of format-specific options passed to
80
+ * {@link ExportFormatDefinition.run}.
81
+ *
82
+ * Declared as a constrained identity type rather than a bare
83
+ * `Record<string, unknown>` so format authors can parameterize their
84
+ * own `run()` signature with a strongly-typed option shape while the
85
+ * runtime's dispatch layer treats every format's options uniformly.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * interface HtmlExportOptions extends Record<string, unknown> {
90
+ * readonly inlineStyles: boolean;
91
+ * readonly minify?: boolean;
92
+ * }
93
+ *
94
+ * const htmlFormat: ExportFormatDefinition<HtmlExportOptions> = {
95
+ * id: "html",
96
+ * label: "HTML",
97
+ * extension: "html",
98
+ * mimeType: "text/html",
99
+ * async run(ir, options) {
100
+ * // ^? options: ExportOptions<HtmlExportOptions>
101
+ * // ^? options.inlineStyles is typed as boolean
102
+ * return { content: "<!doctype html>…", filename: "page.html" };
103
+ * },
104
+ * };
105
+ * ```
106
+ *
107
+ * @typeParam T - Format-specific option shape. Defaults to an
108
+ * unconstrained `Record<string, unknown>` so formats that don't care
109
+ * about options can omit the type parameter entirely.
110
+ */
111
+ export type ExportOptions<T extends Record<string, unknown> = Record<string, unknown>> = T;
112
+ /**
113
+ * Per-run context handed to {@link ExportFormatDefinition.run} for
114
+ * formats that opt into asset-URL rewriting (review finding TS-c).
115
+ *
116
+ * `assetResolvers` is the runtime's registration-ordered resolver list
117
+ * (sourced from `StudioRuntime.assetResolvers`): a format consults each
118
+ * resolver in order and stops at the first that returns a non-null
119
+ * rewrite. Absent or empty ⇒ no rewriting is applied; how a format then
120
+ * treats a reference no resolver handles is its own policy — the bundled
121
+ * HTML / React exporters omit unresolved `asset://` / `design://` refs and
122
+ * emit an `ASSET_UNRESOLVED` warning rather than passing them through.
123
+ */
124
+ export interface ExportFormatRunContext {
125
+ readonly assetResolvers?: readonly IRAssetResolver[];
126
+ }
127
+ /**
128
+ * The return value of a successful {@link ExportFormatDefinition.run}
129
+ * call.
130
+ *
131
+ * Text formats (HTML, JSON, Markdown, React source) should set
132
+ * {@link content} to a `string`. Binary formats (PDF, ZIP, images)
133
+ * should set it to a `Uint8Array`. Host apps dispatch on the type at
134
+ * download time — a `string` becomes a `Blob` with the format's
135
+ * `mimeType`, a `Uint8Array` becomes a `Blob` wrapping the raw bytes.
136
+ */
137
+ export interface ExportResult {
138
+ /**
139
+ * The serialized output.
140
+ *
141
+ * Use `string` for text formats and `Uint8Array` for binary
142
+ * formats. Do not base64-encode binary content into a string;
143
+ * host apps handle the two cases differently.
144
+ */
145
+ readonly content: string | Uint8Array;
146
+ /**
147
+ * The suggested filename for the download, including the
148
+ * extension (e.g. `"page.html"`, `"page.pdf"`).
149
+ *
150
+ * Host apps may override this at the download step, but the
151
+ * exporter is expected to provide a sensible default.
152
+ */
153
+ readonly filename: string;
154
+ /**
155
+ * Optional non-fatal diagnostics emitted during the export run.
156
+ *
157
+ * See {@link ExportWarning}. Host apps may surface these in a
158
+ * dev console or toast; the export itself is still considered
159
+ * successful.
160
+ */
161
+ readonly warnings?: readonly ExportWarning[];
162
+ }
163
+ /**
164
+ * The descriptor every exporter plugin contributes to Studio.
165
+ *
166
+ * Registered via `StudioPluginRegistration.exportFormats` (part of
167
+ * the plugin surface that stays in `@anvilkit/core`).
168
+ * The runtime collects every registered definition into the export
169
+ * registry (`core-009`) and dispatches to the matching `id` when the
170
+ * host calls `exportAs(formatId, options)`.
171
+ *
172
+ * ### `run(ir, options, ctx?)` contract
173
+ *
174
+ * The `run` callback receives a fully-normalized {@link PageIR}, not
175
+ * a Puck `Data`. The IR normalization step (Puck `Data` → `PageIR`)
176
+ * is performed exactly once by the export pipeline before any format
177
+ * runs, ensuring every exporter sees the same input regardless of
178
+ * how the page was authored.
179
+ *
180
+ * Format authors should treat the `ir` argument as deeply read-only.
181
+ * Mutating it has no effect on the runtime and may break other
182
+ * exporters in the same pipeline.
183
+ *
184
+ * @typeParam Opts - Optional format-specific option shape. See
185
+ * {@link ExportOptions} for an example of how to parameterize a
186
+ * concrete format. Defaults to an unconstrained
187
+ * `Record<string, unknown>`.
188
+ */
189
+ export interface ExportFormatDefinition<Opts extends Record<string, unknown> = Record<string, unknown>> {
190
+ /**
191
+ * Stable, globally-unique format identifier (e.g. `"html"`,
192
+ * `"react"`, `"json"`).
193
+ *
194
+ * The runtime rejects duplicate ids at `createExportRegistry()`
195
+ * time. Convention: lowercase, hyphen-separated, no namespace
196
+ * prefix — host apps refer to formats by id in their UI.
197
+ */
198
+ readonly id: string;
199
+ /**
200
+ * Human-readable label surfaced in export menus and dialogs
201
+ * (e.g. `"HTML"`, `"React source"`, `"JSON snapshot"`).
202
+ */
203
+ readonly label: string;
204
+ /**
205
+ * Optional i18n message key for the label, resolved by the chrome via
206
+ * `useMsg(labelKey, label)` at render — so the export menu localizes
207
+ * with the active locale. When present it wins; `label` is the
208
+ * missing-key fallback. Plugins contribute the key via
209
+ * `ctx.registerMessages` under their own namespace.
210
+ */
211
+ readonly labelKey?: string;
212
+ /**
213
+ * File extension (without the leading dot) for downloads in this
214
+ * format (e.g. `"html"`, `"jsx"`, `"json"`, `"pdf"`).
215
+ */
216
+ readonly extension: string;
217
+ /**
218
+ * MIME type for the exported content (e.g. `"text/html"`,
219
+ * `"application/json"`, `"application/pdf"`).
220
+ *
221
+ * Used by host apps to set the correct `Blob` type at download
222
+ * time and to populate the `Content-Type` header when sending
223
+ * exports over the network.
224
+ */
225
+ readonly mimeType: string;
226
+ /**
227
+ * Produce the serialized output for a page.
228
+ *
229
+ * Receives a normalized {@link PageIR} and a format-specific
230
+ * {@link ExportOptions} bag. Returns a `Promise<ExportResult>`
231
+ * — always async so the contract is uniform regardless of
232
+ * whether a given format happens to run synchronously.
233
+ *
234
+ * @param ir - The normalized page IR. Deeply read-only.
235
+ * @param options - Format-specific option bag.
236
+ * @param ctx - Optional runtime context for additive export hooks.
237
+ */
238
+ readonly run: (ir: PageIR, options: ExportOptions<Opts>, ctx?: ExportFormatRunContext) => Promise<ExportResult>;
239
+ }
240
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAA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s ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file Barrel for `@anvilkit/contracts` — the shared, type-only
3
+ * contract layer of the AnvilKit workspace.
4
+ *
5
+ * ### What lives here
6
+ *
7
+ * The serializable data contracts passed **between** packages: the
8
+ * Page IR (`ir.ts`), the AI generation + validation DTOs (`ai.ts`,
9
+ * `ai-section.ts`), the export format contract (`export.ts`), the
10
+ * pages-source host contract (`page.ts`), and asset resolution
11
+ * (`assets.ts`).
12
+ *
13
+ * ### What deliberately does NOT live here
14
+ *
15
+ * Runtime logic of any kind. Transforms (`puckDataToIR`,
16
+ * `configToAiContext`, …), Zod validators, migrations, React hooks,
17
+ * Puck overrides, and the Studio plugin registration surface stay in
18
+ * their owning packages. This package must remain runtime-free: it
19
+ * has no `dependencies`, its only peer is a **type-only** import from
20
+ * `@puckeditor/core`, and every module compiles to an empty runtime
21
+ * output under `verbatimModuleSyntax`.
22
+ *
23
+ * ### Dependency direction
24
+ *
25
+ * ```
26
+ * @anvilkit/contracts
27
+ * ↓
28
+ * @anvilkit/ir · @anvilkit/schema · @anvilkit/validator
29
+ * ↓
30
+ * @anvilkit/core
31
+ * ↓
32
+ * plugins / apps
33
+ * ```
34
+ *
35
+ * `@anvilkit/core/types` re-exports everything below as a
36
+ * compatibility shim, so existing consumers keep working; new code
37
+ * should import from `@anvilkit/contracts` directly.
38
+ */
39
+ export type { AiComponentSchema, AiFieldSchema, AiFieldType, AiGenerationContext, AiThemeHint, AiValidationIssue, AiValidationResult, } from "./ai.js";
40
+ export type { AiSectionContext, AiSectionPatch, AiSectionSelection, ConfigToAiSectionContextOptions, } from "./ai-section.js";
41
+ export type { AssetResolution, IRAssetResolver } from "./assets.js";
42
+ export type { ExportFormatDefinition, ExportFormatRunContext, ExportOptions, ExportResult, ExportWarning, ExportWarningLevel, } from "./export.js";
43
+ export type { PageIR, PageIRAsset, PageIRMetadata, PageIRNode, PageIRNodeMeta, } from "./ir.js";
44
+ export type { StudioPage, StudioPageCreateInput, StudioPageRenameInput, StudioPageReorderInput, StudioPageSeo, StudioPageSettingsInput, StudioPagesSource, } from "./page.js";
45
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,SAAS,CAAC;AACjB,YAAY,EACX,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EACX,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,MAAM,EACN,WAAW,EACX,cAAc,EACd,UAAU,EACV,cAAc,GACd,MAAM,SAAS,CAAC;AACjB,YAAY,EACX,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,iBAAiB,GACjB,MAAM,WAAW,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file Barrel for `@anvilkit/contracts` — the shared, type-only
3
+ * contract layer of the AnvilKit workspace.
4
+ *
5
+ * ### What lives here
6
+ *
7
+ * The serializable data contracts passed **between** packages: the
8
+ * Page IR (`ir.ts`), the AI generation + validation DTOs (`ai.ts`,
9
+ * `ai-section.ts`), the export format contract (`export.ts`), the
10
+ * pages-source host contract (`page.ts`), and asset resolution
11
+ * (`assets.ts`).
12
+ *
13
+ * ### What deliberately does NOT live here
14
+ *
15
+ * Runtime logic of any kind. Transforms (`puckDataToIR`,
16
+ * `configToAiContext`, …), Zod validators, migrations, React hooks,
17
+ * Puck overrides, and the Studio plugin registration surface stay in
18
+ * their owning packages. This package must remain runtime-free: it
19
+ * has no `dependencies`, its only peer is a **type-only** import from
20
+ * `@puckeditor/core`, and every module compiles to an empty runtime
21
+ * output under `verbatimModuleSyntax`.
22
+ *
23
+ * ### Dependency direction
24
+ *
25
+ * ```
26
+ * @anvilkit/contracts
27
+ * ↓
28
+ * @anvilkit/ir · @anvilkit/schema · @anvilkit/validator
29
+ * ↓
30
+ * @anvilkit/core
31
+ * ↓
32
+ * plugins / apps
33
+ * ```
34
+ *
35
+ * `@anvilkit/core/types` re-exports everything below as a
36
+ * compatibility shim, so existing consumers keep working; new code
37
+ * should import from `@anvilkit/contracts` directly.
38
+ */
39
+ export type { AiComponentSchema, AiFieldSchema, AiFieldType, AiGenerationContext, AiThemeHint, AiValidationIssue, AiValidationResult, } from "./ai.js";
40
+ export type { AiSectionContext, AiSectionPatch, AiSectionSelection, ConfigToAiSectionContextOptions, } from "./ai-section.js";
41
+ export type { AssetResolution, IRAssetResolver } from "./assets.js";
42
+ export type { ExportFormatDefinition, ExportFormatRunContext, ExportOptions, ExportResult, ExportWarning, ExportWarningLevel, } from "./export.js";
43
+ export type { PageIR, PageIRAsset, PageIRMetadata, PageIRNode, PageIRNodeMeta, } from "./ir.js";
44
+ export type { StudioPage, StudioPageCreateInput, StudioPageRenameInput, StudioPageReorderInput, StudioPageSeo, StudioPageSettingsInput, StudioPagesSource, } from "./page.js";
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,SAAS,CAAC;AACjB,YAAY,EACX,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EACX,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,MAAM,EACN,WAAW,EACX,cAAc,EACd,UAAU,EACV,cAAc,GACd,MAAM,SAAS,CAAC;AACjB,YAAY,EACX,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,iBAAiB,GACjB,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/ir.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });