@nubisco/cms-vue 1.3.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 +10 -510
- package/dist/index.js +192 -743
- package/package.json +4 -1
package/dist/cms-vue.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.cms-text--editing[data-v-
|
|
1
|
+
.cms-text--editing[data-v-67fffd3d]{outline:1px dashed color-mix(in srgb, var(--nb-c-primary,#5856a9) 55%, transparent);outline-offset:3px;cursor:text;border-radius:4px}.cms-text--editing[data-v-67fffd3d]:hover{background:color-mix(in srgb, var(--nb-c-primary,#5856a9) 6%, transparent)}.cms-text--editing[data-v-67fffd3d]:focus{outline:2px solid var(--nb-c-primary,#5856a9);background:color-mix(in srgb, var(--nb-c-primary,#5856a9) 9%, transparent)}.bf[data-v-22d52899]{border:1px solid var(--nb-c-border,#e7e7f1);background:var(--nb-c-surface,#fff);border-radius:10px;margin:10px;transition:box-shadow .15s,border-color .15s;position:relative}.bf[data-v-22d52899]:hover{box-shadow:0 4px 16px #1a1a2614}.bf--selected[data-v-22d52899]{border-color:var(--nb-c-primary,#5856a9);box-shadow:0 0 0 1px var(--nb-c-primary,#5856a9)}.bf--dim .bf__body[data-v-22d52899]{opacity:.42}.bf__bar[data-v-22d52899]{border-bottom:1px solid var(--nb-c-border,#e7e7f1);cursor:pointer;align-items:center;gap:10px;padding:7px 10px;font-size:12px;display:flex}.bf__grip[data-v-22d52899]{color:var(--nb-c-text-muted,#9797a6);cursor:grab}.bf__type[data-v-22d52899]{color:var(--nb-c-text-muted,#6a6a7b);font-family:ui-monospace,monospace;font-weight:600}.bf--selected .bf__type[data-v-22d52899]{color:var(--nb-c-primary,#5856a9)}.bf__badge[data-v-22d52899]{color:#b9781e;background:#b9781e29;border-radius:5px;padding:2px 7px;font-size:10px;font-weight:700}.bf__spacer[data-v-22d52899]{flex:1}.bf__btn[data-v-22d52899]{border:1px solid var(--nb-c-border,#d7d7e6);background:var(--nb-c-surface,#fff);width:26px;height:26px;color:var(--nb-c-text,#1a1a26);border-radius:6px;line-height:1}.bf__btn[data-v-22d52899]:hover:not(:disabled){background:var(--nb-c-surface-2,#f4f4fa)}.bf__btn[data-v-22d52899]:disabled{opacity:.35;cursor:not-allowed}.bf__body[data-v-22d52899]{border-radius:0 0 10px 10px;overflow:hidden}.cms-zone__missing[data-v-6a544d0b]{border:1px dashed var(--nb-c-border,#d7d7e6);color:var(--nb-c-text-muted,#6a6a7b);border-radius:8px;padding:12px 16px;font-size:13px}.cms-link--inert[data-v-87a57473]{cursor:default}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
|
+
import { BlockInstance } from '@nubisco/cms-core';
|
|
2
3
|
import { Component } from 'vue';
|
|
3
4
|
import { ComponentOptionsMixin } from 'vue';
|
|
4
5
|
import { ComponentProvideOptions } from 'vue';
|
|
5
6
|
import { ComputedRef } from 'vue';
|
|
6
7
|
import { DefineComponent } from 'vue';
|
|
8
|
+
import { FieldValue } from '@nubisco/cms-core';
|
|
7
9
|
import { InjectionKey } from 'vue';
|
|
10
|
+
import { LogicEnv } from '@nubisco/cms-core';
|
|
11
|
+
import { LogicGraph } from '@nubisco/cms-core';
|
|
8
12
|
import { PropType } from 'vue';
|
|
9
13
|
import { PublicProps } from 'vue';
|
|
10
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';
|
|
11
19
|
|
|
12
20
|
declare const __VLS_component: DefineComponent<__VLS_Props_4, {
|
|
13
21
|
link: ComputedRef<ResolvedLink>;
|
|
@@ -112,17 +120,6 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
112
120
|
};
|
|
113
121
|
};
|
|
114
122
|
|
|
115
|
-
/**
|
|
116
|
-
* Apply serializers to authored HTML.
|
|
117
|
-
*
|
|
118
|
-
* A single pass over the tags, keeping a stack of open elements, so a renamed
|
|
119
|
-
* tag's close tag is renamed with it and nesting is never guessed at. Text
|
|
120
|
-
* between tags is passed through byte for byte: nothing here rewrites content.
|
|
121
|
-
*/
|
|
122
|
-
export declare function applySerializers(html: string, serializers?: RichTextSerializers): string;
|
|
123
|
-
|
|
124
|
-
export declare type BlockCategory = 'content' | 'media' | 'form' | 'layout';
|
|
125
|
-
|
|
126
123
|
export declare interface BlockComponentProps<TFields extends Record<string, FieldValue> = Record<string, FieldValue>, TContext = unknown> {
|
|
127
124
|
block: TypedBlock<TFields>;
|
|
128
125
|
/** Position within the zone, for a block whose look depends on where it sits. */
|
|
@@ -133,65 +130,6 @@ export declare interface BlockComponentProps<TFields extends Record<string, Fiel
|
|
|
133
130
|
context?: TContext;
|
|
134
131
|
}
|
|
135
132
|
|
|
136
|
-
/**
|
|
137
|
-
* A block type definition, registered once. The editor catalog, the inspector
|
|
138
|
-
* fields, validation, and serialization all derive from this, mirroring how the
|
|
139
|
-
* NubiscoUI Blueprint system derives everything from a NodeDefinition.
|
|
140
|
-
*
|
|
141
|
-
* Coded blocks map `type` to a real component through a per-framework registry
|
|
142
|
-
* that lives in the renderer package, not in this contract.
|
|
143
|
-
*/
|
|
144
|
-
export declare interface BlockDefinition {
|
|
145
|
-
type: string;
|
|
146
|
-
label: string;
|
|
147
|
-
kind: BlockKind;
|
|
148
|
-
category?: BlockCategory;
|
|
149
|
-
icon?: string;
|
|
150
|
-
fields: Record<string, FieldSchema>;
|
|
151
|
-
variations?: BlockVariation[];
|
|
152
|
-
slots?: Record<string, SlotSchema>;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** A block as it appears in a content document. */
|
|
156
|
-
export declare interface BlockInstance {
|
|
157
|
-
/** Stable id: survives reorder, used for deep links and in-place edit targeting. */
|
|
158
|
-
id: string;
|
|
159
|
-
type: string;
|
|
160
|
-
variation?: string;
|
|
161
|
-
fields: Record<string, FieldValue>;
|
|
162
|
-
/** Visibility logic. Absent means always visible. */
|
|
163
|
-
when?: Condition;
|
|
164
|
-
/** Nested blocks for composed blocks with slots. */
|
|
165
|
-
slots?: Record<string, BlockInstance[]>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export declare type BlockKind =
|
|
169
|
-
/** Fields only, assembled in the CMS. No app code required. */
|
|
170
|
-
'composed'
|
|
171
|
-
/** Backed by an app component (anything with behavior, e.g. a form). */
|
|
172
|
-
| 'coded';
|
|
173
|
-
|
|
174
|
-
export declare interface BlockVariation {
|
|
175
|
-
id: string;
|
|
176
|
-
label: string;
|
|
177
|
-
/** Field values this variation presets (a footer subscribe vs a hero one). */
|
|
178
|
-
presets?: Record<string, FieldValue>;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export declare interface BlueprintCard {
|
|
182
|
-
id: string;
|
|
183
|
-
x: number;
|
|
184
|
-
y: number;
|
|
185
|
-
width: number;
|
|
186
|
-
height: number;
|
|
187
|
-
paint: {
|
|
188
|
-
title: string;
|
|
189
|
-
color: string;
|
|
190
|
-
category: string;
|
|
191
|
-
ports: NodePort[];
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
133
|
export declare const CMS_CLIENT: InjectionKey<CmsClient>;
|
|
196
134
|
|
|
197
135
|
export declare const CMS_CONTEXT: InjectionKey<CmsContext>;
|
|
@@ -353,49 +291,6 @@ select: (id: string) => any;
|
|
|
353
291
|
onSelect?: ((id: string) => any) | undefined;
|
|
354
292
|
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
355
293
|
|
|
356
|
-
/**
|
|
357
|
-
* Turn authored `<router-link>` into a real anchor (or an inert span).
|
|
358
|
-
*
|
|
359
|
-
* The close tag is matched to what the OPEN tag became, so a destination-less
|
|
360
|
-
* link closes `</span>` and not `</a>`: emitting the wrong closer leaves the
|
|
361
|
-
* span open and the browser swallows the rest of the paragraph into it.
|
|
362
|
-
*/
|
|
363
|
-
export declare function compileLinks(html: string): string;
|
|
364
|
-
|
|
365
|
-
export declare type Condition = {
|
|
366
|
-
kind: 'always';
|
|
367
|
-
} | {
|
|
368
|
-
kind: 'simple';
|
|
369
|
-
/** A registered LogicInputDefinition id. */
|
|
370
|
-
input: string;
|
|
371
|
-
/** Input parameters, e.g. { flag: 'stagewright' } for featureFlag. */
|
|
372
|
-
params?: Record<string, unknown>;
|
|
373
|
-
/** Comparison for enum/number/date inputs. Boolean inputs need none. */
|
|
374
|
-
op?: Op;
|
|
375
|
-
value?: unknown;
|
|
376
|
-
} | {
|
|
377
|
-
kind: 'all';
|
|
378
|
-
of: Condition[];
|
|
379
|
-
} | {
|
|
380
|
-
kind: 'any';
|
|
381
|
-
of: Condition[];
|
|
382
|
-
} | {
|
|
383
|
-
kind: 'not';
|
|
384
|
-
of: Condition;
|
|
385
|
-
}
|
|
386
|
-
/** Reference to a serialized Blueprint graph stored alongside the content. */
|
|
387
|
-
| {
|
|
388
|
-
kind: 'graph';
|
|
389
|
-
graphId: string;
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* The initial catalog. Extend by appending a definition (and, for the visual
|
|
394
|
-
* editor, a matching Blueprint NodeDefinition). `campaignSource` is the worked
|
|
395
|
-
* example of a future input: append one entry with resolveAt: 'request'.
|
|
396
|
-
*/
|
|
397
|
-
export declare const CORE_LOGIC_INPUTS: LogicInputDefinition[];
|
|
398
|
-
|
|
399
294
|
export declare function createCms(options: CmsClientOptions): CmsClient;
|
|
400
295
|
|
|
401
296
|
/**
|
|
@@ -425,16 +320,6 @@ export declare function defineBlock<TFields extends Record<string, FieldValue>>(
|
|
|
425
320
|
};
|
|
426
321
|
};
|
|
427
322
|
|
|
428
|
-
/**
|
|
429
|
-
* Evaluates a Condition tree to a visibility boolean. `graphs` supplies the
|
|
430
|
-
* logic graphs referenced by { kind: 'graph' } conditions (stored on the page
|
|
431
|
-
* document); a graph condition with no matching graph defaults to visible.
|
|
432
|
-
*/
|
|
433
|
-
export declare function evaluate(condition: Condition | undefined, env: LogicEnv, graphs?: Record<string, LogicGraph>): boolean;
|
|
434
|
-
|
|
435
|
-
/** Evaluates the graph to the Visible sink's value, plus each node's output. */
|
|
436
|
-
export declare function evaluateGraph(graph: LogicGraph, env: LogicEnv): GraphResult;
|
|
437
|
-
|
|
438
323
|
export declare type FetchLike = (input: string, init?: {
|
|
439
324
|
cache?: RequestCache;
|
|
440
325
|
headers?: Record<string, string>;
|
|
@@ -444,40 +329,6 @@ export declare type FetchLike = (input: string, init?: {
|
|
|
444
329
|
json: () => Promise<unknown>;
|
|
445
330
|
}>;
|
|
446
331
|
|
|
447
|
-
/** A field's schema: what a Block declares it accepts. */
|
|
448
|
-
export declare interface FieldSchema {
|
|
449
|
-
type: FieldType;
|
|
450
|
-
/** Editor-facing label. */
|
|
451
|
-
label: string;
|
|
452
|
-
help?: string;
|
|
453
|
-
required?: boolean;
|
|
454
|
-
/**
|
|
455
|
-
* Whether the value is per-locale. Text/richtext default to true and are
|
|
456
|
-
* stored by reference (see TRef) so Verba owns the translations. Media,
|
|
457
|
-
* numbers, and booleans default to false.
|
|
458
|
-
*/
|
|
459
|
-
localized?: boolean;
|
|
460
|
-
/** Allowed values for `select`. */
|
|
461
|
-
options?: string[];
|
|
462
|
-
default?: unknown;
|
|
463
|
-
/** Max length for text, or max value for number. */
|
|
464
|
-
max?: number;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Content contract: the framework-agnostic shape of Nubisco CMS content.
|
|
469
|
-
*
|
|
470
|
-
* This is the crown jewel of the system. The CMS edits documents of this shape,
|
|
471
|
-
* and any renderer (Vue first, others later) is just a function from these types
|
|
472
|
-
* to a rendered page. Nothing here mentions Vue on purpose.
|
|
473
|
-
*
|
|
474
|
-
* Vocabulary: Fields (primitives) compose into Blocks (placeable units), which
|
|
475
|
-
* are ordered inside Zones on a Page.
|
|
476
|
-
*/
|
|
477
|
-
export declare type FieldType = 'text' | 'richtext' | 'number' | 'boolean' | 'image' | 'link' | 'color' | 'date' | 'select';
|
|
478
|
-
|
|
479
|
-
export declare type FieldValue = TRef | string | number | boolean | ImageValue | LinkValue;
|
|
480
|
-
|
|
481
332
|
/**
|
|
482
333
|
* The runtime props definition matching BlockComponentProps. Returned fresh on
|
|
483
334
|
* every call, because Vue mutates the object it is handed.
|
|
@@ -504,21 +355,6 @@ export declare function getBlockComponentProps<TFields extends Record<string, Fi
|
|
|
504
355
|
};
|
|
505
356
|
};
|
|
506
357
|
|
|
507
|
-
export declare interface GraphConnection {
|
|
508
|
-
fromNode: string;
|
|
509
|
-
fromPort: string;
|
|
510
|
-
toNode: string;
|
|
511
|
-
toPort: string;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
export declare interface GraphResult {
|
|
515
|
-
visible: boolean;
|
|
516
|
-
nodeOut: Record<string, boolean>;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/** Whether a field value is an image the renderer can draw. */
|
|
520
|
-
export declare function hasImage(value: FieldValue | unknown): boolean;
|
|
521
|
-
|
|
522
358
|
/**
|
|
523
359
|
* Adopt the server's partials before the app mounts, so hydration matches the
|
|
524
360
|
* HTML exactly and no fetch is issued.
|
|
@@ -529,32 +365,6 @@ export declare function hasImage(value: FieldValue | unknown): boolean;
|
|
|
529
365
|
*/
|
|
530
366
|
export declare function hydrateCmsPartials(raw: unknown, client?: CmsClient | null): void;
|
|
531
367
|
|
|
532
|
-
export declare interface ImageValue {
|
|
533
|
-
src: string;
|
|
534
|
-
alt?: TRef;
|
|
535
|
-
/** Intrinsic size, when known, to avoid layout shift. */
|
|
536
|
-
w?: number;
|
|
537
|
-
h?: number;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Resolves one logic input to a boolean, given the author's params/op/value.
|
|
542
|
-
* The host provides one resolver per registered input id (featureFlag,
|
|
543
|
-
* environment, auth, region, ...). This is where build-time vs request-time
|
|
544
|
-
* resolution actually happens; the contract only declares which is which.
|
|
545
|
-
*/
|
|
546
|
-
export declare type InputResolver = (params: Record<string, unknown> | undefined, op: Op | undefined, value: unknown) => boolean;
|
|
547
|
-
|
|
548
|
-
/** Whether an authored value carries markup, or is one plain paragraph of text. */
|
|
549
|
-
export declare function isHtml(value: string): boolean;
|
|
550
|
-
|
|
551
|
-
export declare function isImage(v: unknown): v is ImageValue;
|
|
552
|
-
|
|
553
|
-
/** A route the host app can navigate to in place: site-absolute, not protocol-relative. */
|
|
554
|
-
export declare function isInternalHref(href: string): boolean;
|
|
555
|
-
|
|
556
|
-
export declare function isLink(v: unknown): v is LinkValue;
|
|
557
|
-
|
|
558
368
|
/**
|
|
559
369
|
* True when a live-preview patch is carrying THIS partial rather than a page.
|
|
560
370
|
*
|
|
@@ -570,300 +380,12 @@ export declare function isPartialDocument(doc: unknown, key?: string): boolean;
|
|
|
570
380
|
/** True in any non-browser render (a Worker isolate, Node, a test). */
|
|
571
381
|
export declare function isServerRender(): boolean;
|
|
572
382
|
|
|
573
|
-
export declare function isTRef(v: unknown): v is TRef;
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* The attributes an anchor needs, or NOTHING when the link is inert.
|
|
577
|
-
*
|
|
578
|
-
* Binding this with `v-bind` on a `<component :is="linkTag(link)">` is the whole
|
|
579
|
-
* of rule 2: an inert link gets no `href`, no `target` and no `rel`, so it
|
|
580
|
-
* renders as the label in plain text.
|
|
581
|
-
*/
|
|
582
|
-
export declare function linkAttrs(link: ResolvedLink): Record<string, string>;
|
|
583
|
-
|
|
584
|
-
/** The class that paints an inert link as body copy rather than as a link. */
|
|
585
|
-
export declare function linkClass(link: ResolvedLink): string;
|
|
586
|
-
|
|
587
|
-
export declare type LinkKind = 'doc' | 'url' | 'media' | 'none';
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* The `link` field, generalised out of the site that first shipped it.
|
|
591
|
-
*
|
|
592
|
-
* A link used to be a raw href typed as a free string, so a typo was a silent
|
|
593
|
-
* 404, renaming a route broke every href pointing at it, and nothing stopped an
|
|
594
|
-
* editor linking to a page that is deliberately held back. The CMS models a
|
|
595
|
-
* link as an object and DELIVERY RESOLVES IT server side, so a renderer needs no
|
|
596
|
-
* resolver of its own:
|
|
597
|
-
*
|
|
598
|
-
* { "kind": "doc", "route": "/docs", "href": "/docs", "status": "ok" }
|
|
599
|
-
* { "kind": "url", "url": "https://…", "newTab": true }
|
|
600
|
-
* { "kind": "media", "id": "<media id>", "href": "https://…/asset.pdf", "newTab": true }
|
|
601
|
-
*
|
|
602
|
-
* `newTab` is authored on ANY of the three kinds. It is orthogonal to `status`:
|
|
603
|
-
* a link that is not 'ok' renders inert whatever the editor asked for, because
|
|
604
|
-
* there is no destination to open in either tab.
|
|
605
|
-
*
|
|
606
|
-
* `status` is delivery's verdict on a `doc` reference against the SAME site and
|
|
607
|
-
* environment: 'ok', 'missing' (no document for that route) or 'unpublished'
|
|
608
|
-
* (the document exists but is not visible to this caller).
|
|
609
|
-
*
|
|
610
|
-
* Two rules this module exists to enforce, in ONE place rather than in each of
|
|
611
|
-
* the fields a product renders as a link:
|
|
612
|
-
*
|
|
613
|
-
* 1. BACKWARD COMPATIBILITY. Documents in the wild still hold plain strings,
|
|
614
|
-
* and a document is migrated when it is migrated. A bare string is
|
|
615
|
-
* therefore a first-class input: a leading '/' reads as an internal route,
|
|
616
|
-
* anything else as an external URL. Nothing may 404 or render blank because
|
|
617
|
-
* a document has not been migrated yet.
|
|
618
|
-
*
|
|
619
|
-
* 2. A LINK THAT IS NOT 'ok' RENDERS INERT. The label still shows, as plain
|
|
620
|
-
* text, never as a dead anchor. This is what stops a held-back page (an
|
|
621
|
-
* unreleased product, say) leaking through a link on a page that IS live:
|
|
622
|
-
* the URL never reaches the markup at all, so it cannot be read out of the
|
|
623
|
-
* rendered HTML either.
|
|
624
|
-
*/
|
|
625
|
-
/** Delivery's verdict, plus the two verdicts a renderer reaches on its own. */
|
|
626
|
-
export declare type LinkStatus = 'ok'
|
|
627
|
-
/** No document for that route. */
|
|
628
|
-
| 'missing'
|
|
629
|
-
/** The document exists but is not published (or not visible to this caller). */
|
|
630
|
-
| 'unpublished'
|
|
631
|
-
/** Nothing authored at all. */
|
|
632
|
-
| 'empty'
|
|
633
|
-
/** A reference delivery did not resolve (a media id with no asset URL). */
|
|
634
|
-
| 'unresolved';
|
|
635
|
-
|
|
636
|
-
/** The tag an anchor slot should render: a real link, or plain text. */
|
|
637
|
-
export declare function linkTag(link: ResolvedLink): 'a' | 'span';
|
|
638
|
-
|
|
639
|
-
export declare interface LinkValue {
|
|
640
|
-
href: string;
|
|
641
|
-
label?: TRef;
|
|
642
|
-
external?: boolean;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
export declare type LogicEnv = Record<string, InputResolver>;
|
|
646
|
-
|
|
647
|
-
export declare interface LogicGraph {
|
|
648
|
-
nodes: LogicNode[];
|
|
649
|
-
connections: GraphConnection[];
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
export declare interface LogicInputDefinition {
|
|
653
|
-
id: string;
|
|
654
|
-
label: string;
|
|
655
|
-
valueType: LogicValueType;
|
|
656
|
-
/** Parameters the author fills in, e.g. featureFlag needs a `flag`. */
|
|
657
|
-
params?: Record<string, FieldSchema>;
|
|
658
|
-
resolveAt: ResolveAt;
|
|
659
|
-
/** Allowed values for enum inputs (environment, region, locale). */
|
|
660
|
-
enumValues?: string[];
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* A logic input type, registered once. The value is resolved by a host-provided
|
|
665
|
-
* resolver keyed by `id`; this definition only declares the shape and where it
|
|
666
|
-
* can run, so the visual editor and the evaluator are fully data-driven.
|
|
667
|
-
*/
|
|
668
|
-
export declare type LogicKind = 'featureFlag' | 'environment' | 'auth' | 'region' | 'and' | 'or' | 'not' | 'visible';
|
|
669
|
-
|
|
670
|
-
export declare interface LogicNode {
|
|
671
|
-
id: string;
|
|
672
|
-
kind: LogicKind;
|
|
673
|
-
x: number;
|
|
674
|
-
y: number;
|
|
675
|
-
/** Flag key / environment value / region code, for the input nodes. */
|
|
676
|
-
param?: string;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
export declare type LogicValueType = 'boolean' | 'enum' | 'number' | 'date';
|
|
680
|
-
|
|
681
|
-
export declare const NODE_SPECS: Record<LogicKind, NodeSpec>;
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* App-side logic for the graph form of a Condition (the data shapes live in the
|
|
685
|
-
* contract). The node catalog, Blueprint card mapping, and evaluator are here.
|
|
686
|
-
* Inputs (feature flag, environment, ...) feed gates (AND/OR/NOT) that feed a
|
|
687
|
-
* single Visible sink; graphs are referenced from a condition as
|
|
688
|
-
* { kind: 'graph', graphId }.
|
|
689
|
-
*/
|
|
690
|
-
declare interface NodePort {
|
|
691
|
-
id: string;
|
|
692
|
-
label: string;
|
|
693
|
-
type: 'input' | 'output';
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
declare interface NodeSpec {
|
|
697
|
-
label: string;
|
|
698
|
-
color: string;
|
|
699
|
-
category: string;
|
|
700
|
-
ports: NodePort[];
|
|
701
|
-
/** Which parameter this node carries, if any. */
|
|
702
|
-
param?: 'flag' | 'environment' | 'region';
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/** The node type a tag maps to, so serializers are named by meaning, not by tag. */
|
|
706
|
-
export declare function nodeTypeOf(tag: string): RichTextNodeType;
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Normalise ANY authored image value. `messages` resolves a `{ $t }` alt;
|
|
710
|
-
* `fallback` is the host's own bundled asset, used only when nothing is
|
|
711
|
-
* authored, so a half-authored document still renders a complete page.
|
|
712
|
-
*/
|
|
713
|
-
export declare function normalizeImage(value: unknown, messages?: Record<string, string>, fallback?: string | ResolvedImage): ResolvedImage;
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Normalise ANY authored link value: the object shape, a legacy bare string, or
|
|
717
|
-
* nothing at all. `fallback` is the host's own bundled href, used only when the
|
|
718
|
-
* document carries nothing (blocks often keep a coded default so a
|
|
719
|
-
* half-authored document still renders a complete page).
|
|
720
|
-
*/
|
|
721
|
-
export declare function normalizeLink(value: unknown, fallback?: string): ResolvedLink;
|
|
722
|
-
|
|
723
|
-
/**
|
|
724
|
-
* Logic contract: visibility and variation conditions.
|
|
725
|
-
*
|
|
726
|
-
* A Condition gates whether a Block or Page renders. It is either a simple
|
|
727
|
-
* predicate, a boolean tree, or a reference to a NubiscoUI Blueprint graph for
|
|
728
|
-
* the genuinely compound cases. Most content uses a simple predicate; the graph
|
|
729
|
-
* is the escape hatch, not the default.
|
|
730
|
-
*
|
|
731
|
-
* Logic inputs are a registry. Adding a new input type (e.g. campaign source)
|
|
732
|
-
* later is one LogicInputDefinition plus one Blueprint NodeDefinition. Nothing
|
|
733
|
-
* in the engine or the content schema changes.
|
|
734
|
-
*/
|
|
735
|
-
export declare type Op = 'is' | 'not' | 'in' | 'gte' | 'lte' | 'between';
|
|
736
|
-
|
|
737
|
-
export declare interface PageDocument {
|
|
738
|
-
route: string;
|
|
739
|
-
meta?: {
|
|
740
|
-
title?: TRef;
|
|
741
|
-
description?: TRef;
|
|
742
|
-
/** Page renders its own newsletter, so the footer one is suppressed. */
|
|
743
|
-
ownNewsletter?: boolean;
|
|
744
|
-
};
|
|
745
|
-
/** Named zones, usually just `main`. */
|
|
746
|
-
zones: Record<string, Zone>;
|
|
747
|
-
/** Whole-page gate, e.g. a product feature flag. */
|
|
748
|
-
when?: Condition;
|
|
749
|
-
/** Logic graphs referenced by block/page conditions via { kind: 'graph', graphId }. */
|
|
750
|
-
graphs?: Record<string, LogicGraph>;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
/** The first alias that is filled, for documents that spell a field several ways. */
|
|
754
|
-
export declare function pickField(source: Record<string, unknown> | undefined, aliases: readonly string[]): unknown;
|
|
755
|
-
|
|
756
|
-
/** The link under the first accepted spelling that is filled. */
|
|
757
|
-
export declare function pickLink(source: Record<string, unknown> | undefined, aliases: readonly string[], fallback?: string): ResolvedLink;
|
|
758
|
-
|
|
759
383
|
/** The default preview source: the canvas's own query string. */
|
|
760
384
|
export declare function readPreviewFromLocation(): CmsPreview;
|
|
761
385
|
|
|
762
386
|
/** Test/dev helper: forget the memoised partials so the next call refetches. */
|
|
763
387
|
export declare function resetCmsPartials(): void;
|
|
764
388
|
|
|
765
|
-
/**
|
|
766
|
-
* Where a logic input can be evaluated. This is load-bearing for delivery:
|
|
767
|
-
* - `build` inputs (flag, environment, locale) let a gated block prerender.
|
|
768
|
-
* - `request` inputs (auth, region) force the block to be resolved at the edge
|
|
769
|
-
* (a Worker) or revealed client-side. It cannot be baked.
|
|
770
|
-
* A block whose condition mixes both is resolved at the most dynamic site.
|
|
771
|
-
*/
|
|
772
|
-
export declare type ResolveAt = 'build' | 'request';
|
|
773
|
-
|
|
774
|
-
export declare interface ResolvedImage {
|
|
775
|
-
/** '' when nothing is authored, which is the caller's signal to render nothing. */
|
|
776
|
-
src: string;
|
|
777
|
-
/** Always a string. '' means decorative, and must still reach the markup as alt="". */
|
|
778
|
-
alt: string;
|
|
779
|
-
width?: number;
|
|
780
|
-
height?: number;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
/**
|
|
784
|
-
* An authored link, normalised. Named `ResolvedLink` rather than `CmsLink`
|
|
785
|
-
* because `CmsLink` is the component that renders one.
|
|
786
|
-
*/
|
|
787
|
-
export declare interface ResolvedLink {
|
|
788
|
-
/** True when this may render as a real anchor. False means render it inert. */
|
|
789
|
-
ok: boolean;
|
|
790
|
-
/** Where it points. Always '' when `ok` is false, so it cannot leak. */
|
|
791
|
-
href: string;
|
|
792
|
-
/** True when `href` is a route the host app owns, so its router should take it. */
|
|
793
|
-
internal: boolean;
|
|
794
|
-
/**
|
|
795
|
-
* Whether it should open in a new tab. Authored per link, for ALL THREE
|
|
796
|
-
* kinds: an editor can send an internal page to a new tab just as easily as
|
|
797
|
-
* an external URL, and a linked PDF in the media library is the case that
|
|
798
|
-
* made this matter. Never true for a destination that must open in place
|
|
799
|
-
* (#anchor, mailto:, tel:), where a new tab would leave an empty one behind.
|
|
800
|
-
*/
|
|
801
|
-
newTab: boolean;
|
|
802
|
-
status: LinkStatus;
|
|
803
|
-
kind: LinkKind;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/** The node a serializer is handed. `attrs` are the authored attributes, as written. */
|
|
807
|
-
export declare interface RichTextNode {
|
|
808
|
-
type: RichTextNodeType;
|
|
809
|
-
/** The authored tag name, lowercased. */
|
|
810
|
-
tag: string;
|
|
811
|
-
attrs: Record<string, string>;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Richtext: authored HTML, and the one hook a product needs to style it.
|
|
816
|
-
*
|
|
817
|
-
* The CMS stores a richtext field as HTML written by an editor. A renderer
|
|
818
|
-
* inserts it (Vue: `v-html`), which is why two things live here rather than in
|
|
819
|
-
* each product's blocks:
|
|
820
|
-
*
|
|
821
|
-
* 1. `compileLinks`, because inserted markup is NOT compiled. A document that
|
|
822
|
-
* authored `<router-link to="/x">` would otherwise render the literal
|
|
823
|
-
* element and vanish; it becomes a real `<a href>`, and CmsRichText's
|
|
824
|
-
* delegated click handler gives it SPA navigation. A `router-link` with no
|
|
825
|
-
* destination becomes a `<span>`: the label renders, never a dead anchor,
|
|
826
|
-
* the same rule the link field enforces everywhere else.
|
|
827
|
-
*
|
|
828
|
-
* 2. `applySerializers`, the equivalent of Prismic's rich text serializers. A
|
|
829
|
-
* product styles its own headings, paragraphs and quotes by naming a class
|
|
830
|
-
* (or rewriting the tag) per node type, instead of forking the component.
|
|
831
|
-
*
|
|
832
|
-
* WHAT A SERIALIZER CAN DO, precisely: it rewrites an element's OPEN TAG (its
|
|
833
|
-
* tag name, its classes, its attributes). The children are passed through
|
|
834
|
-
* untouched, and a renamed tag has its matching close tag renamed with it. It
|
|
835
|
-
* cannot restructure a subtree (wrapping a blockquote's text in an extra
|
|
836
|
-
* paragraph, say) because the input is HTML rather than a node tree. A product
|
|
837
|
-
* that needs that keeps its own transform and passes the result in as `html`.
|
|
838
|
-
*/
|
|
839
|
-
export declare type RichTextNodeType = 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'list' | 'oList' | 'listItem' | 'quote' | 'preformatted' | 'code' | 'hyperlink' | 'image' | 'strong' | 'em' | 'span' | 'break' | 'table' | 'row' | 'cell' | 'other';
|
|
840
|
-
|
|
841
|
-
/** What a serializer may return. Returning nothing leaves the element alone. */
|
|
842
|
-
export declare interface RichTextRewrite {
|
|
843
|
-
/** Render as a different element. The matching close tag is renamed too. */
|
|
844
|
-
tag?: string;
|
|
845
|
-
/** Classes to ADD to whatever the element already carries. */
|
|
846
|
-
class?: string;
|
|
847
|
-
/** Attributes to set (or, with an empty string, to leave as-is). */
|
|
848
|
-
attrs?: Record<string, string>;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* A serializer for one node type. The string form is the common case: classes
|
|
853
|
-
* to add. The function form returns a rewrite, or a raw open tag if a product
|
|
854
|
-
* wants full control (its close tag then keeps the authored tag name).
|
|
855
|
-
*/
|
|
856
|
-
export declare type RichTextSerializer = string | ((node: RichTextNode) => RichTextRewrite | string | void);
|
|
857
|
-
|
|
858
|
-
export declare type RichTextSerializers = Partial<Record<RichTextNodeType, RichTextSerializer>>;
|
|
859
|
-
|
|
860
|
-
/** A named region inside a composed block that nests other blocks. */
|
|
861
|
-
export declare interface SlotSchema {
|
|
862
|
-
label: string;
|
|
863
|
-
/** Block types allowed in this slot. Omit to allow any. */
|
|
864
|
-
allow?: string[];
|
|
865
|
-
}
|
|
866
|
-
|
|
867
389
|
/**
|
|
868
390
|
* Everything resolved so far, for the server render to serialise. Call it after
|
|
869
391
|
* renderToString, so every partial an awaited prefetch resolved is in. Pass the
|
|
@@ -871,26 +393,6 @@ export declare interface SlotSchema {
|
|
|
871
393
|
*/
|
|
872
394
|
export declare function snapshotCmsPartials(app?: unknown): Record<string, CmsPartialSnapshot>;
|
|
873
395
|
|
|
874
|
-
/**
|
|
875
|
-
* Resolves a field value to display text. String refs ({ $t }) resolve from the
|
|
876
|
-
* provided message table (Verba / locale JSON), falling back to the key so a
|
|
877
|
-
* missing translation is visible rather than blank.
|
|
878
|
-
*/
|
|
879
|
-
export declare function text(value: FieldValue | undefined, messages: Record<string, string>): string;
|
|
880
|
-
|
|
881
|
-
/** Maps the logic graph to Blueprint card geometry + paint. */
|
|
882
|
-
export declare function toCards(graph: LogicGraph): BlueprintCard[];
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* A reference to an i18n key. Localized strings are never inlined into content;
|
|
886
|
-
* they resolve from Verba / the site's locale JSON at render time. This keeps
|
|
887
|
-
* Verba authoritative and the content documents small, and it matches how the
|
|
888
|
-
* existing sites already use vue-i18n keys.
|
|
889
|
-
*/
|
|
890
|
-
export declare interface TRef {
|
|
891
|
-
$t: string;
|
|
892
|
-
}
|
|
893
|
-
|
|
894
396
|
/** A block instance narrowed to the fields one block type declares. */
|
|
895
397
|
export declare interface TypedBlock<TFields extends Record<string, FieldValue> = Record<string, FieldValue>> extends BlockInstance {
|
|
896
398
|
fields: TFields;
|
|
@@ -938,9 +440,7 @@ export declare function useField(): {
|
|
|
938
440
|
t: (value: FieldValue | undefined) => string;
|
|
939
441
|
};
|
|
940
442
|
|
|
941
|
-
|
|
942
|
-
export
|
|
943
|
-
blocks: BlockInstance[];
|
|
944
|
-
}
|
|
443
|
+
|
|
444
|
+
export * from "@nubisco/cms-core";
|
|
945
445
|
|
|
946
446
|
export { }
|