@nubisco/cms-vue 1.2.0 → 1.4.0
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/cms-vue.css +1 -1
- package/dist/index.d.ts +350 -267
- package/dist/index.js +490 -331
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { BlockInstance } from '@nubisco/cms-core';
|
|
1
3
|
import { Component } from 'vue';
|
|
2
4
|
import { ComponentOptionsMixin } from 'vue';
|
|
3
5
|
import { ComponentProvideOptions } from 'vue';
|
|
6
|
+
import { ComputedRef } from 'vue';
|
|
4
7
|
import { DefineComponent } from 'vue';
|
|
8
|
+
import { FieldValue } from '@nubisco/cms-core';
|
|
5
9
|
import { InjectionKey } from 'vue';
|
|
10
|
+
import { LogicEnv } from '@nubisco/cms-core';
|
|
11
|
+
import { LogicGraph } from '@nubisco/cms-core';
|
|
12
|
+
import { PropType } from 'vue';
|
|
6
13
|
import { PublicProps } from 'vue';
|
|
14
|
+
import { Ref } from 'vue';
|
|
15
|
+
import { ResolvedImage } from '@nubisco/cms-core';
|
|
16
|
+
import { ResolvedLink } from '@nubisco/cms-core';
|
|
17
|
+
import { RichTextSerializers } from '@nubisco/cms-core';
|
|
18
|
+
import { Zone } from '@nubisco/cms-core';
|
|
19
|
+
|
|
20
|
+
declare const __VLS_component: DefineComponent<__VLS_Props_4, {
|
|
21
|
+
link: ComputedRef<ResolvedLink>;
|
|
22
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
7
23
|
|
|
8
24
|
declare type __VLS_Props = {
|
|
9
25
|
block: BlockInstance;
|
|
@@ -18,72 +34,167 @@ declare type __VLS_Props_2 = {
|
|
|
18
34
|
editing?: boolean;
|
|
19
35
|
selectedId?: string | null;
|
|
20
36
|
graphs?: Record<string, LogicGraph>;
|
|
37
|
+
/**
|
|
38
|
+
* Also pass `index`, `blocks` and `context` to every block component, the
|
|
39
|
+
* shape `getBlockComponentProps()` declares. OFF by default and deliberately:
|
|
40
|
+
* a block component that does not declare those props would render them as
|
|
41
|
+
* fallthrough attributes on its root element, changing the markup of every
|
|
42
|
+
* site already rendering with this zone.
|
|
43
|
+
*/
|
|
44
|
+
provideBlockProps?: boolean;
|
|
45
|
+
/** Passed straight through to each block as `context` when the above is on. */
|
|
46
|
+
context?: unknown;
|
|
21
47
|
setText?: (block: BlockInstance, field: string, current: FieldValue | undefined, next: string) => void;
|
|
22
48
|
};
|
|
23
49
|
|
|
24
|
-
|
|
50
|
+
declare type __VLS_Props_3 = {
|
|
51
|
+
block?: BlockInstance;
|
|
52
|
+
field?: string | readonly string[];
|
|
53
|
+
/**
|
|
54
|
+
* Or pass the authored value directly. Typed `unknown` rather than
|
|
55
|
+
* `FieldValue` because `FieldValue` includes `boolean`, and Vue casts an
|
|
56
|
+
* absent prop whose declared type includes Boolean to `false`: every block
|
|
57
|
+
* that read its body from `block`/`field` would have rendered "false".
|
|
58
|
+
*/
|
|
59
|
+
value?: unknown;
|
|
60
|
+
/** Per-node-type rendering overrides, the Prismic serializer equivalent. */
|
|
61
|
+
serializers?: RichTextSerializers;
|
|
62
|
+
/** The element wrapping authored markup. */
|
|
63
|
+
as?: string;
|
|
64
|
+
/** The element wrapping plain authored text. */
|
|
65
|
+
plainAs?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Transform applied after serializers, for the rewrites a serializer cannot
|
|
68
|
+
* express (restructuring a subtree). Kept as an escape hatch so a product
|
|
69
|
+
* with an existing transform can adopt the primitive without losing it.
|
|
70
|
+
*/
|
|
71
|
+
transform?: (html: string) => string;
|
|
72
|
+
};
|
|
25
73
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
74
|
+
declare type __VLS_Props_4 = {
|
|
75
|
+
/** Read the link out of a block's fields. */
|
|
76
|
+
block?: BlockInstance;
|
|
77
|
+
/** The field name, or several accepted spellings, first filled one wins. */
|
|
78
|
+
field?: string | readonly string[];
|
|
79
|
+
/** Or pass the authored value directly (the object shape, or a bare string). */
|
|
80
|
+
value?: unknown;
|
|
81
|
+
/** The host's own coded href, used only when the document carries nothing. */
|
|
82
|
+
fallback?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Label, when it is not supplied as slot content. Typed `unknown` rather than
|
|
85
|
+
* `FieldValue` on purpose: `FieldValue` includes `boolean`, and Vue casts an
|
|
86
|
+
* ABSENT prop whose declared type includes Boolean to `false`, so the label
|
|
87
|
+
* of every link that did not pass one rendered as the word "false".
|
|
88
|
+
*/
|
|
89
|
+
label?: unknown;
|
|
90
|
+
/** Field holding the label, read from `block` like `field` is. */
|
|
91
|
+
labelField?: string | readonly string[];
|
|
92
|
+
};
|
|
44
93
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** Nested blocks for composed blocks with slots. */
|
|
55
|
-
slots?: Record<string, BlockInstance[]>;
|
|
56
|
-
}
|
|
94
|
+
declare type __VLS_Props_5 = {
|
|
95
|
+
block?: BlockInstance;
|
|
96
|
+
field?: string | readonly string[];
|
|
97
|
+
value?: unknown;
|
|
98
|
+
/** The host's own bundled asset, used only when the document carries nothing. */
|
|
99
|
+
fallback?: string | ResolvedImage;
|
|
100
|
+
/** Overrides the authored alt (a product that knows better than the document). */
|
|
101
|
+
alt?: string;
|
|
102
|
+
};
|
|
57
103
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
104
|
+
declare function __VLS_template(): {
|
|
105
|
+
attrs: Partial<{}>;
|
|
106
|
+
slots: {
|
|
107
|
+
default?(_: {
|
|
108
|
+
link: ResolvedLink;
|
|
109
|
+
}): any;
|
|
110
|
+
};
|
|
111
|
+
refs: {};
|
|
112
|
+
rootEl: any;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
70
116
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
y: number;
|
|
75
|
-
width: number;
|
|
76
|
-
height: number;
|
|
77
|
-
paint: {
|
|
78
|
-
title: string;
|
|
79
|
-
color: string;
|
|
80
|
-
category: string;
|
|
81
|
-
ports: NodePort[];
|
|
117
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
118
|
+
new (): {
|
|
119
|
+
$slots: S;
|
|
82
120
|
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export declare interface BlockComponentProps<TFields extends Record<string, FieldValue> = Record<string, FieldValue>, TContext = unknown> {
|
|
124
|
+
block: TypedBlock<TFields>;
|
|
125
|
+
/** Position within the zone, for a block whose look depends on where it sits. */
|
|
126
|
+
index?: number;
|
|
127
|
+
/** Every block in the zone, for a block that must know its neighbours. */
|
|
128
|
+
blocks?: BlockInstance[];
|
|
129
|
+
/** Whatever the host passed to the zone: a locale, a feature-flag bag, a route. */
|
|
130
|
+
context?: TContext;
|
|
83
131
|
}
|
|
84
132
|
|
|
133
|
+
export declare const CMS_CLIENT: InjectionKey<CmsClient>;
|
|
134
|
+
|
|
85
135
|
export declare const CMS_CONTEXT: InjectionKey<CmsContext>;
|
|
86
136
|
|
|
137
|
+
/** Key under which the snapshot travels inside the host's initial state. */
|
|
138
|
+
export declare const CMS_PARTIAL_STATE_KEY = "cmsPartials";
|
|
139
|
+
|
|
140
|
+
export declare interface CmsClient {
|
|
141
|
+
readonly siteId: string;
|
|
142
|
+
readonly environment: string;
|
|
143
|
+
readonly apiBase: string;
|
|
144
|
+
/** The console protocol this canvas answers to. See CmsClientOptions. */
|
|
145
|
+
readonly patchMessageType: string;
|
|
146
|
+
readonly options: CmsClientOptions;
|
|
147
|
+
/** The preview state of this render. */
|
|
148
|
+
preview(): CmsPreview;
|
|
149
|
+
/** The delivery URL for a document path, preview included. */
|
|
150
|
+
documentUrl(path: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* Navigate in-app. Returns false when the host gave no router, which is the
|
|
153
|
+
* caller's signal to leave the click to the browser.
|
|
154
|
+
*/
|
|
155
|
+
navigate(href: string): boolean;
|
|
156
|
+
fetchPage(route: string): Promise<CmsPageResult>;
|
|
157
|
+
fetchPartial(key: string): Promise<CmsPartialResult>;
|
|
158
|
+
/** Vue plugin: `app.use(cms)`. */
|
|
159
|
+
install(app: App): void;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export declare interface CmsClientOptions {
|
|
163
|
+
/** e.g. 'nubisco-corporate'. */
|
|
164
|
+
siteId: string;
|
|
165
|
+
/** Which environment to read: development | staging | production. */
|
|
166
|
+
environment?: string;
|
|
167
|
+
/** Delivery base, e.g. https://cms.nubisco.io. Required: there is no default. */
|
|
168
|
+
apiBase: string;
|
|
169
|
+
/**
|
|
170
|
+
* The postMessage type the editing console posts a live document with.
|
|
171
|
+
* Defaults to the Nubisco console's, so a white-label console can speak its
|
|
172
|
+
* own protocol without forking the library.
|
|
173
|
+
*/
|
|
174
|
+
patchMessageType?: string;
|
|
175
|
+
/** Injected for tests, or for a Worker that must pass its own fetch. */
|
|
176
|
+
fetch?: FetchLike;
|
|
177
|
+
/**
|
|
178
|
+
* How an internal link navigates. A library cannot assume the host's router,
|
|
179
|
+
* so give it one of these, or neither: with neither, every link stays a plain
|
|
180
|
+
* anchor and the browser does a full page load, which is correct, just slower.
|
|
181
|
+
*/
|
|
182
|
+
router?: CmsRouterLike;
|
|
183
|
+
navigate?: (href: string) => unknown;
|
|
184
|
+
/** Where preview comes from. Defaults to reading the browser's query string. */
|
|
185
|
+
preview?: () => CmsPreview;
|
|
186
|
+
/**
|
|
187
|
+
* Whether partials may be fetched at all. A partial has no route to be
|
|
188
|
+
* published at, so there is no row whose presence could turn it on: the host
|
|
189
|
+
* either composes its chrome from the CMS or it does not.
|
|
190
|
+
*/
|
|
191
|
+
partials?: boolean;
|
|
192
|
+
/** Accept live-preview patches from the console while in edit mode. */
|
|
193
|
+
livePreview?: boolean;
|
|
194
|
+
/** Extra origins a live-preview patch may arrive from (the console's URL). */
|
|
195
|
+
consoleOrigins?: string[];
|
|
196
|
+
}
|
|
197
|
+
|
|
87
198
|
/**
|
|
88
199
|
* Render context provided by CmsZone and injected by field primitives. It
|
|
89
200
|
* carries the string table (for { $t } refs), whether edit mode is on, and the
|
|
@@ -96,268 +207,240 @@ export declare interface CmsContext {
|
|
|
96
207
|
setText: (block: BlockInstance, field: string, current: FieldValue | undefined, next: string) => void;
|
|
97
208
|
}
|
|
98
209
|
|
|
99
|
-
export declare const
|
|
100
|
-
|
|
101
|
-
}, any>;
|
|
210
|
+
export declare const CmsImage: DefineComponent<__VLS_Props_5, {
|
|
211
|
+
image: ComputedRef<ResolvedImage>;
|
|
212
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_5> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
102
213
|
|
|
103
|
-
export declare const
|
|
104
|
-
select: (id: string) => any;
|
|
105
|
-
}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
|
|
106
|
-
onSelect?: ((id: string) => any) | undefined;
|
|
107
|
-
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
108
|
-
|
|
109
|
-
export declare type Condition = {
|
|
110
|
-
kind: 'always';
|
|
111
|
-
} | {
|
|
112
|
-
kind: 'simple';
|
|
113
|
-
/** A registered LogicInputDefinition id. */
|
|
114
|
-
input: string;
|
|
115
|
-
/** Input parameters, e.g. { flag: 'stagewright' } for featureFlag. */
|
|
116
|
-
params?: Record<string, unknown>;
|
|
117
|
-
/** Comparison for enum/number/date inputs. Boolean inputs need none. */
|
|
118
|
-
op?: Op;
|
|
119
|
-
value?: unknown;
|
|
120
|
-
} | {
|
|
121
|
-
kind: 'all';
|
|
122
|
-
of: Condition[];
|
|
123
|
-
} | {
|
|
124
|
-
kind: 'any';
|
|
125
|
-
of: Condition[];
|
|
126
|
-
} | {
|
|
127
|
-
kind: 'not';
|
|
128
|
-
of: Condition;
|
|
129
|
-
}
|
|
130
|
-
/** Reference to a serialized Blueprint graph stored alongside the content. */
|
|
131
|
-
| {
|
|
132
|
-
kind: 'graph';
|
|
133
|
-
graphId: string;
|
|
134
|
-
};
|
|
214
|
+
export declare const CmsLink: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
135
215
|
|
|
136
216
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
217
|
+
* How a load ended. Separate from `error` because the two failures are not the
|
|
218
|
+
* same fact and a request-time renderer has to tell them apart: delivery
|
|
219
|
+
* answering 404 means this path genuinely has no page (render the 404), while
|
|
220
|
+
* delivery being unreachable or broken means we do not know (render nothing and
|
|
221
|
+
* answer 503, so a crawler comes back instead of recording the page as gone).
|
|
140
222
|
*/
|
|
141
|
-
export declare
|
|
223
|
+
export declare type CmsOutcome = 'ok' | 'missing' | 'unavailable';
|
|
142
224
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*/
|
|
148
|
-
export declare function evaluate(condition: Condition | undefined, env: LogicEnv, graphs?: Record<string, LogicGraph>): boolean;
|
|
149
|
-
|
|
150
|
-
/** Evaluates the graph to the Visible sink's value, plus each node's output. */
|
|
151
|
-
export declare function evaluateGraph(graph: LogicGraph, env: LogicEnv): GraphResult;
|
|
152
|
-
|
|
153
|
-
/** A field's schema: what a Block declares it accepts. */
|
|
154
|
-
export declare interface FieldSchema {
|
|
155
|
-
type: FieldType;
|
|
156
|
-
/** Editor-facing label. */
|
|
157
|
-
label: string;
|
|
158
|
-
help?: string;
|
|
159
|
-
required?: boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Whether the value is per-locale. Text/richtext default to true and are
|
|
162
|
-
* stored by reference (see TRef) so Verba owns the translations. Media,
|
|
163
|
-
* numbers, and booleans default to false.
|
|
164
|
-
*/
|
|
165
|
-
localized?: boolean;
|
|
166
|
-
/** Allowed values for `select`. */
|
|
167
|
-
options?: string[];
|
|
168
|
-
default?: unknown;
|
|
169
|
-
/** Max length for text, or max value for number. */
|
|
170
|
-
max?: number;
|
|
225
|
+
export declare interface CmsPageDocument {
|
|
226
|
+
route: string;
|
|
227
|
+
meta?: Record<string, unknown>;
|
|
228
|
+
zones: Record<string, Zone>;
|
|
171
229
|
}
|
|
172
230
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
* and any renderer (Vue first, others later) is just a function from these types
|
|
178
|
-
* to a rendered page. Nothing here mentions Vue on purpose.
|
|
179
|
-
*
|
|
180
|
-
* Vocabulary: Fields (primitives) compose into Blocks (placeable units), which
|
|
181
|
-
* are ordered inside Zones on a Page.
|
|
182
|
-
*/
|
|
183
|
-
export declare type FieldType = 'text' | 'richtext' | 'number' | 'boolean' | 'image' | 'link' | 'color' | 'date' | 'select';
|
|
184
|
-
|
|
185
|
-
export declare type FieldValue = TRef | string | number | boolean | ImageValue | LinkValue;
|
|
186
|
-
|
|
187
|
-
export declare interface GraphConnection {
|
|
188
|
-
fromNode: string;
|
|
189
|
-
fromPort: string;
|
|
190
|
-
toNode: string;
|
|
191
|
-
toPort: string;
|
|
231
|
+
export declare interface CmsPageResult {
|
|
232
|
+
doc: CmsPageDocument | null;
|
|
233
|
+
error: string | null;
|
|
234
|
+
outcome: CmsOutcome;
|
|
192
235
|
}
|
|
193
236
|
|
|
194
|
-
export declare interface
|
|
195
|
-
|
|
196
|
-
|
|
237
|
+
export declare interface CmsPartialDocument {
|
|
238
|
+
/** The partial key, e.g. 'footer'. Delivery returns it as `key`. */
|
|
239
|
+
key?: string;
|
|
240
|
+
meta?: Record<string, unknown>;
|
|
241
|
+
zones: Record<string, Zone>;
|
|
197
242
|
}
|
|
198
243
|
|
|
199
|
-
export declare interface
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
w?: number;
|
|
204
|
-
h?: number;
|
|
244
|
+
export declare interface CmsPartialResult {
|
|
245
|
+
doc: CmsPartialDocument | null;
|
|
246
|
+
/** '' on success; a reason otherwise. Any reason means: render the coded fallback. */
|
|
247
|
+
error: string | null;
|
|
205
248
|
}
|
|
206
249
|
|
|
207
|
-
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*/
|
|
213
|
-
export declare type InputResolver = (params: Record<string, unknown> | undefined, op: Op | undefined, value: unknown) => boolean;
|
|
214
|
-
|
|
215
|
-
export declare function isImage(v: unknown): v is ImageValue;
|
|
216
|
-
|
|
217
|
-
export declare function isLink(v: unknown): v is LinkValue;
|
|
250
|
+
/** What the server render hands to the browser, per partial key. */
|
|
251
|
+
export declare interface CmsPartialSnapshot {
|
|
252
|
+
doc: CmsPartialDocument | null;
|
|
253
|
+
error: string | null;
|
|
254
|
+
}
|
|
218
255
|
|
|
219
|
-
|
|
256
|
+
/** Whether this render is the editor canvas, and what it may read. */
|
|
257
|
+
export declare interface CmsPreview {
|
|
258
|
+
/** True in the in-context editor (?cms-edit=1). Bypasses the edge cache. */
|
|
259
|
+
active: boolean;
|
|
260
|
+
/** ?cms-env override, so the canvas shows the environment being edited. */
|
|
261
|
+
environment?: string;
|
|
262
|
+
/**
|
|
263
|
+
* The short-lived token the console mints for the canvas. Reading a draft is
|
|
264
|
+
* a capability, not a flag: delivery serves one only to a caller that proves
|
|
265
|
+
* it edits this site. The canvas runs on the host's own origin and therefore
|
|
266
|
+
* cannot send a CMS session cookie, which is why the token exists.
|
|
267
|
+
*/
|
|
268
|
+
token?: string;
|
|
269
|
+
}
|
|
220
270
|
|
|
221
|
-
export declare
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
271
|
+
export declare const CmsRichText: DefineComponent<__VLS_Props_3, {
|
|
272
|
+
html: ComputedRef<string>;
|
|
273
|
+
plain: ComputedRef<string>;
|
|
274
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {
|
|
275
|
+
as: string;
|
|
276
|
+
plainAs: string;
|
|
277
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
278
|
+
|
|
279
|
+
/** A router this library can hand a route to, without depending on any router. */
|
|
280
|
+
export declare interface CmsRouterLike {
|
|
281
|
+
push: (to: string) => unknown;
|
|
225
282
|
}
|
|
226
283
|
|
|
227
|
-
export declare
|
|
284
|
+
export declare const CmsText: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
285
|
+
el: HTMLSpanElement;
|
|
286
|
+
}, any>;
|
|
228
287
|
|
|
229
|
-
export declare
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
288
|
+
export declare const CmsZone: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
289
|
+
select: (id: string) => any;
|
|
290
|
+
}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
|
|
291
|
+
onSelect?: ((id: string) => any) | undefined;
|
|
292
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
233
293
|
|
|
234
|
-
export declare
|
|
235
|
-
id: string;
|
|
236
|
-
label: string;
|
|
237
|
-
valueType: LogicValueType;
|
|
238
|
-
/** Parameters the author fills in, e.g. featureFlag needs a `flag`. */
|
|
239
|
-
params?: Record<string, FieldSchema>;
|
|
240
|
-
resolveAt: ResolveAt;
|
|
241
|
-
/** Allowed values for enum inputs (environment, region, locale). */
|
|
242
|
-
enumValues?: string[];
|
|
243
|
-
}
|
|
294
|
+
export declare function createCms(options: CmsClientOptions): CmsClient;
|
|
244
295
|
|
|
245
296
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
297
|
+
* Declare a block's fields once and get both the runtime props and the type.
|
|
298
|
+
* `defineBlock<HeroFields>()` is the shorthand a product block uses when it also
|
|
299
|
+
* wants the field type exported for its schema.
|
|
249
300
|
*/
|
|
250
|
-
export declare
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
301
|
+
export declare function defineBlock<TFields extends Record<string, FieldValue>>(): {
|
|
302
|
+
block: {
|
|
303
|
+
type: PropType<TypedBlock<TFields>>;
|
|
304
|
+
required: true;
|
|
305
|
+
};
|
|
306
|
+
index: {
|
|
307
|
+
type: PropType<number>;
|
|
308
|
+
required: false;
|
|
309
|
+
default: number;
|
|
310
|
+
};
|
|
311
|
+
blocks: {
|
|
312
|
+
type: PropType<BlockInstance[]>;
|
|
313
|
+
required: false;
|
|
314
|
+
default: () => BlockInstance[];
|
|
315
|
+
};
|
|
316
|
+
context: {
|
|
317
|
+
type: PropType<unknown>;
|
|
318
|
+
required: false;
|
|
319
|
+
default: unknown;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
262
322
|
|
|
263
|
-
export declare
|
|
323
|
+
export declare type FetchLike = (input: string, init?: {
|
|
324
|
+
cache?: RequestCache;
|
|
325
|
+
headers?: Record<string, string>;
|
|
326
|
+
}) => Promise<{
|
|
327
|
+
ok: boolean;
|
|
328
|
+
status: number;
|
|
329
|
+
json: () => Promise<unknown>;
|
|
330
|
+
}>;
|
|
264
331
|
|
|
265
332
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* Inputs (feature flag, environment, ...) feed gates (AND/OR/NOT) that feed a
|
|
269
|
-
* single Visible sink; graphs are referenced from a condition as
|
|
270
|
-
* { kind: 'graph', graphId }.
|
|
333
|
+
* The runtime props definition matching BlockComponentProps. Returned fresh on
|
|
334
|
+
* every call, because Vue mutates the object it is handed.
|
|
271
335
|
*/
|
|
272
|
-
declare
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
336
|
+
export declare function getBlockComponentProps<TFields extends Record<string, FieldValue> = Record<string, FieldValue>, TContext = unknown>(): {
|
|
337
|
+
block: {
|
|
338
|
+
type: PropType<TypedBlock<TFields>>;
|
|
339
|
+
required: true;
|
|
340
|
+
};
|
|
341
|
+
index: {
|
|
342
|
+
type: PropType<number>;
|
|
343
|
+
required: false;
|
|
344
|
+
default: number;
|
|
345
|
+
};
|
|
346
|
+
blocks: {
|
|
347
|
+
type: PropType<BlockInstance[]>;
|
|
348
|
+
required: false;
|
|
349
|
+
default: () => BlockInstance[];
|
|
350
|
+
};
|
|
351
|
+
context: {
|
|
352
|
+
type: PropType<TContext>;
|
|
353
|
+
required: false;
|
|
354
|
+
default: TContext | undefined;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
286
357
|
|
|
287
358
|
/**
|
|
288
|
-
*
|
|
359
|
+
* Adopt the server's partials before the app mounts, so hydration matches the
|
|
360
|
+
* HTML exactly and no fetch is issued.
|
|
289
361
|
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* the
|
|
293
|
-
|
|
362
|
+
* Skipped in edit mode on purpose: the canvas is meant to show the DRAFT and to
|
|
363
|
+
* take live patches from the console, so it must fetch for itself rather than
|
|
364
|
+
* inherit the published documents the server render resolved.
|
|
365
|
+
*/
|
|
366
|
+
export declare function hydrateCmsPartials(raw: unknown, client?: CmsClient | null): void;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* True when a live-preview patch is carrying THIS partial rather than a page.
|
|
294
370
|
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
371
|
+
* The console posts whichever document it currently has open. A page document
|
|
372
|
+
* is addressed by a route (always '/'-prefixed); a partial is addressed by its
|
|
373
|
+
* key. Every marker delivery or the console might use is accepted, and the
|
|
374
|
+
* '/'-prefix rule is the backstop, so a footer patch is never mistaken for a
|
|
375
|
+
* page (which would replace the page body with the footer) and a page patch is
|
|
376
|
+
* never mistaken for the footer.
|
|
298
377
|
*/
|
|
299
|
-
export declare
|
|
378
|
+
export declare function isPartialDocument(doc: unknown, key?: string): boolean;
|
|
300
379
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
/** Named zones, usually just `main`. */
|
|
310
|
-
zones: Record<string, Zone>;
|
|
311
|
-
/** Whole-page gate, e.g. a product feature flag. */
|
|
312
|
-
when?: Condition;
|
|
313
|
-
/** Logic graphs referenced by block/page conditions via { kind: 'graph', graphId }. */
|
|
314
|
-
graphs?: Record<string, LogicGraph>;
|
|
315
|
-
}
|
|
380
|
+
/** True in any non-browser render (a Worker isolate, Node, a test). */
|
|
381
|
+
export declare function isServerRender(): boolean;
|
|
382
|
+
|
|
383
|
+
/** The default preview source: the canvas's own query string. */
|
|
384
|
+
export declare function readPreviewFromLocation(): CmsPreview;
|
|
385
|
+
|
|
386
|
+
/** Test/dev helper: forget the memoised partials so the next call refetches. */
|
|
387
|
+
export declare function resetCmsPartials(): void;
|
|
316
388
|
|
|
317
389
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* (a Worker) or revealed client-side. It cannot be baked.
|
|
322
|
-
* A block whose condition mixes both is resolved at the most dynamic site.
|
|
390
|
+
* Everything resolved so far, for the server render to serialise. Call it after
|
|
391
|
+
* renderToString, so every partial an awaited prefetch resolved is in. Pass the
|
|
392
|
+
* app instance: on the server that is where the states live.
|
|
323
393
|
*/
|
|
324
|
-
export declare
|
|
394
|
+
export declare function snapshotCmsPartials(app?: unknown): Record<string, CmsPartialSnapshot>;
|
|
325
395
|
|
|
326
|
-
/** A
|
|
327
|
-
export declare interface
|
|
328
|
-
|
|
329
|
-
/** Block types allowed in this slot. Omit to allow any. */
|
|
330
|
-
allow?: string[];
|
|
396
|
+
/** A block instance narrowed to the fields one block type declares. */
|
|
397
|
+
export declare interface TypedBlock<TFields extends Record<string, FieldValue> = Record<string, FieldValue>> extends BlockInstance {
|
|
398
|
+
fields: TFields;
|
|
331
399
|
}
|
|
332
400
|
|
|
333
401
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
402
|
+
* The configured client, or null when the host never installed one. Null is a
|
|
403
|
+
* supported state: the primitives fall back to plain anchors and coded content,
|
|
404
|
+
* which is what lets a product adopt them one component at a time.
|
|
337
405
|
*/
|
|
338
|
-
export declare function
|
|
406
|
+
export declare function useCms(): CmsClient | null;
|
|
407
|
+
|
|
408
|
+
/** The same, but for code that cannot proceed without configuration. */
|
|
409
|
+
export declare function useCmsOrThrow(): CmsClient;
|
|
339
410
|
|
|
340
|
-
|
|
341
|
-
|
|
411
|
+
export declare interface UseCmsPage {
|
|
412
|
+
doc: Ref<CmsPageDocument | null>;
|
|
413
|
+
error: Ref<string | null>;
|
|
414
|
+
outcome: Ref<CmsOutcome>;
|
|
415
|
+
loading: Ref<boolean>;
|
|
416
|
+
load: () => Promise<void>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export declare function useCmsPage(route: string, client?: CmsClient | null): UseCmsPage;
|
|
420
|
+
|
|
421
|
+
export declare interface UseCmsPartial {
|
|
422
|
+
doc: Ref<CmsPartialDocument | null>;
|
|
423
|
+
messages: Ref<Record<string, string>>;
|
|
424
|
+
error: Ref<string | null>;
|
|
425
|
+
loading: Ref<boolean>;
|
|
426
|
+
/** Await the first load, so a server render emits the partial, not the fallback. */
|
|
427
|
+
whenReady: () => Promise<void>;
|
|
428
|
+
}
|
|
342
429
|
|
|
343
430
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
431
|
+
* The 'footer' partial (or any other key), shared across the whole app load.
|
|
432
|
+
* `doc` is null whenever the partial is unavailable for ANY reason: partials are
|
|
433
|
+
* off, the endpoint 404s, the CMS is unreachable, or the document is empty.
|
|
434
|
+
* Callers render their coded fallback in that case.
|
|
348
435
|
*/
|
|
349
|
-
export declare
|
|
350
|
-
$t: string;
|
|
351
|
-
}
|
|
436
|
+
export declare function useCmsPartial(key: string, client?: CmsClient | null): UseCmsPartial;
|
|
352
437
|
|
|
353
438
|
/** Small helper for block components: resolve a field value to display text. */
|
|
354
439
|
export declare function useField(): {
|
|
355
440
|
t: (value: FieldValue | undefined) => string;
|
|
356
441
|
};
|
|
357
442
|
|
|
358
|
-
|
|
359
|
-
export
|
|
360
|
-
blocks: BlockInstance[];
|
|
361
|
-
}
|
|
443
|
+
|
|
444
|
+
export * from "@nubisco/cms-core";
|
|
362
445
|
|
|
363
446
|
export { }
|