@bettercms-ai/types 1.62.0 → 1.64.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/index.d.ts CHANGED
@@ -2745,6 +2745,8 @@ interface ComponentPropDef {
2745
2745
  * when the stored value is not what an author should read (a component id, for instance).
2746
2746
  */
2747
2747
  options?: Array<string | ChoiceOption>;
2748
+ /** `select` keyed `variant` — the component's reserved variant enum (embed.ts `variantPropOf`). */
2749
+ role?: "variant";
2748
2750
  /** `group` / `table` / `object` — the sub-shape; 10 levels at most, counting the prop (MAX_FIELD_DEPTH). */
2749
2751
  fields?: ComponentSubField[];
2750
2752
  /**
@@ -4327,7 +4329,7 @@ declare function fieldGroupOf(topKey: string, flat?: boolean): {
4327
4329
  * section added from the library carries neither, which is how it is told apart: the site's code
4328
4330
  * has nothing to draw it with.
4329
4331
  */
4330
- declare function placementBindOf(block: unknown): string | null;
4332
+ declare function placementBindOf(block: unknown, groupOf?: (topKey: string) => string | undefined): string | null;
4331
4333
  /**
4332
4334
  * A slot the CMS was not known to hold when the page was wrapped is spelled `code:<bind>`.
4333
4335
  * It matches a block bound to `<bind>` like the bare spelling does; it differs only when no block
@@ -4603,6 +4605,182 @@ interface RichTextEmbeds {
4603
4605
  cards: Record<string, EmbedCard>;
4604
4606
  }
4605
4607
 
4608
+ /**
4609
+ * Components inside a rich-text body (components v1): the one contract the server, the site
4610
+ * renderers (`BcmsBody`) and the dashboard all code against. Every refusal is a closed code here;
4611
+ * the dashboard maps a code to its copy and never re-spells it.
4612
+ */
4613
+
4614
+ /** Why an embed cannot be inserted or drawn, or why a section cannot be added. First applicable wins. */
4615
+ declare const EMBED_REASONS: readonly ["EMBED_BODY_NOT_DECLARED", "EMBED_COMPONENT_NOT_DECLARED", "EMBED_VARIANT_NOT_ALLOWED", "EMBED_BOUND_TO_PAGE", "EMBED_SOURCE_NOT_RECORDED", "EMBED_COMPONENT_MISSING", "EMBED_RENDER_FAILED", "EMBED_FRAMEWORK_UNSUPPORTED", "SLOT_NOT_IN_PAGE_CODE", "COMPONENT_PAGE_OWN"];
4616
+ type EmbedReason = (typeof EMBED_REASONS)[number];
4617
+ /** Setup-plan exclusions: the six hard gates in order, then the AI pass. */
4618
+ declare const COMPONENT_GATE_CODES: readonly ["COMPONENT_NOT_REUSABLE", "COMPONENT_SOURCE_NOT_MOUNTABLE", "PROP_NOT_REPRESENTABLE", "EMBED_WIDTH_FIT_FAILED", "COMPONENT_IS_CHROME", "COMPONENT_HAS_BODY", "AI_EXCLUDED"];
4619
+ type ComponentGateCode = (typeof COMPONENT_GATE_CODES)[number];
4620
+ /** `EMBED_WIDTH_FIT_FAILED` detail: no runtime to measure in counts as a fail. */
4621
+ declare const WIDTH_FIT_FAIL_KINDS: readonly ["overflow", "full-bleed", "unmeasured"];
4622
+ type WidthFitFailKind = (typeof WIDTH_FIT_FAIL_KINDS)[number];
4623
+ /** Per-embed ledger outcome. `HIDDEN` is info, never a publish warning. */
4624
+ declare const EMBED_LEDGER_OUTCOMES: readonly ["NOT_RENDERED", "HIDDEN"];
4625
+ type EmbedLedgerOutcome = (typeof EMBED_LEDGER_OUTCOMES)[number];
4626
+ declare function isEmbedReason(code: unknown): code is EmbedReason;
4627
+ declare function isComponentGateCode(code: unknown): code is ComponentGateCode;
4628
+ /** The embed node in a Portable Text body. A code component's variant is `overrides.variant`. */
4629
+ interface ComponentEmbedNode {
4630
+ _type: "bcmsBlock";
4631
+ _key: string;
4632
+ schemaKey: "component";
4633
+ schemaLabel?: string;
4634
+ fields: {
4635
+ componentId: string;
4636
+ overrides?: Record<string, unknown> & {
4637
+ variant?: string;
4638
+ };
4639
+ /** Written on every new insert. Absent reads as `true` (legacy nodes). */
4640
+ visible?: boolean;
4641
+ };
4642
+ }
4643
+ /** `visible: false` keeps the value and position; the published html draws nothing. */
4644
+ declare function embedVisible(node: {
4645
+ fields?: {
4646
+ visible?: unknown;
4647
+ } | null;
4648
+ } | null | undefined): boolean;
4649
+ interface EmbedMarker {
4650
+ ptKey: string;
4651
+ componentId: string;
4652
+ hidden?: boolean;
4653
+ reason?: EmbedReason;
4654
+ }
4655
+ /** The stored/delivered marker for one embed. A site renderer swaps it for the mounted component. */
4656
+ declare function embedMarkerHtml(m: EmbedMarker): string;
4657
+ interface EmbedMarkerMatch extends EmbedMarker {
4658
+ /** Offsets of the whole marker in the html it was found in, for splitting. */
4659
+ start: number;
4660
+ end: number;
4661
+ }
4662
+ /** Every marker in `html`, in order. Attribute order does not matter; a marker without an id is skipped. */
4663
+ declare function parseEmbedMarkers(html: string): EmbedMarkerMatch[];
4664
+ /** One body the setup plan declares as accepting components (`setup_state.bodies.items[]`). */
4665
+ interface BodyDeclaration {
4666
+ /** Exactly one of page / model names the owner of `field`. */
4667
+ page?: string;
4668
+ model?: string;
4669
+ field: string;
4670
+ /** The site file that renders the body (`BcmsBody` lives there). */
4671
+ sink: string;
4672
+ widthPx: number;
4673
+ hostClasses?: string;
4674
+ allow: Array<{
4675
+ componentId: string;
4676
+ path: string;
4677
+ export: string;
4678
+ variants: string[];
4679
+ why: string;
4680
+ }>;
4681
+ exclude: Array<{
4682
+ componentId: string;
4683
+ code: ComponentGateCode;
4684
+ detail?: string | {
4685
+ kind: WidthFitFailKind;
4686
+ };
4687
+ why?: string;
4688
+ }>;
4689
+ }
4690
+ interface BodiesState {
4691
+ at: string;
4692
+ commit?: string;
4693
+ items: BodyDeclaration[];
4694
+ }
4695
+ /** `GET …/embed-capability`: what this body's "+" may offer. Never "everything" on a code-drawn page. */
4696
+ interface EmbedCapability {
4697
+ field: string;
4698
+ declared: boolean;
4699
+ widthPx: number | null;
4700
+ allow: Array<{
4701
+ componentId: string;
4702
+ name: string;
4703
+ variants: string[];
4704
+ thumb: string | null;
4705
+ }>;
4706
+ denied: Array<{
4707
+ componentId: string;
4708
+ name: string;
4709
+ code: EmbedReason | ComponentGateCode;
4710
+ detail?: string;
4711
+ }>;
4712
+ bodyReason: EmbedReason | null;
4713
+ }
4714
+ /** `GET …/pages/:pageId/declared-slots`. */
4715
+ interface DeclaredSlot {
4716
+ slot: string;
4717
+ bind: string | null;
4718
+ placed: boolean;
4719
+ componentId: string | null;
4720
+ }
4721
+ /** `POST …/components/:id/fit`. */
4722
+ interface WidthFitResult {
4723
+ ok: boolean;
4724
+ code?: "EMBED_WIDTH_FIT_FAILED";
4725
+ kind?: WidthFitFailKind;
4726
+ measured: {
4727
+ hostWidth: number | null;
4728
+ rootWidth: number | null;
4729
+ scrollWidth: number | null;
4730
+ at: number[];
4731
+ };
4732
+ }
4733
+ /** A publish verdict warning for an embed the site cannot draw. Never a refusal. */
4734
+ interface EmbedNotRenderedWarning {
4735
+ code: "NOT_RENDERED";
4736
+ reason: EmbedReason;
4737
+ page: string;
4738
+ field: string;
4739
+ ptKey: string;
4740
+ }
4741
+ /** Ledger address of one embed: `<field>#<ptKey>`. */
4742
+ declare const embedAddress: (field: string, ptKey: string) => string;
4743
+ declare const VARIANT_PROP_KEY = "variant";
4744
+ declare const DEFAULT_VARIANT = "default";
4745
+ type PropLike = {
4746
+ key: string;
4747
+ type: string;
4748
+ showIf?: ShowIf;
4749
+ config?: {
4750
+ role?: string;
4751
+ options?: Array<string | {
4752
+ value: string;
4753
+ }>;
4754
+ } | null;
4755
+ };
4756
+ /** The reserved variant prop, or undefined. A plain `select` keyed `variant` without the role is not it. */
4757
+ declare function variantPropOf<P extends PropLike>(def: {
4758
+ props?: readonly P[] | null;
4759
+ }): P | undefined;
4760
+ /** The variant values, `["default"]` when the component declares none. */
4761
+ declare function variantOptionsOf(def: {
4762
+ props?: readonly PropLike[] | null;
4763
+ }): string[];
4764
+ /**
4765
+ * Variant values from a file's `variant?:` TS type text (`"dark" | "split"`). Anything that is not
4766
+ * a union of string literals gives `["default"]`, and so does no prop at all.
4767
+ */
4768
+ declare function variantOptionsFromUnion(typeText: string | null | undefined): string[];
4769
+ /**
4770
+ * The shared `showIf` evaluator (the dashboard's showIf.ts semantics). With `sourceTypes`, a rule
4771
+ * naming an unknown key passes (fail-open: content never vanishes from the editor) and booleans
4772
+ * compare as "true"/"false". Values compare as strings.
4773
+ */
4774
+ declare function evaluateShowIf(showIf: {
4775
+ match?: "all" | "any";
4776
+ rules?: readonly Pick<ShowIfRule, "field" | "op" | "value">[];
4777
+ } | null | undefined, values: Record<string, unknown>, sourceTypes?: ReadonlyMap<string, string>): boolean;
4778
+ /**
4779
+ * Is this prop's control shown for these values (variant-only fields hide on other variants)?
4780
+ * Hidden is never deleted: callers keep and send the value.
4781
+ */
4782
+ declare function isVariantVisible(prop: PropLike, values: Record<string, unknown>, props?: readonly PropLike[]): boolean;
4783
+
4606
4784
  /**
4607
4785
  * The id a heading's words make, V2's `slugify` byte for byte, so V2's stored links keep working.
4608
4786
  * The one spelling: @bettercms-ai/richtext stamps it on every rendered h2/h3 and re-exports it,
@@ -4610,4 +4788,4 @@ interface RichTextEmbeds {
4610
4788
  */
4611
4789
  declare const slugify: (s: string) => string;
4612
4790
 
4613
- export { type AlignToken, type AllowRule, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ApproveDockUiInput, type ApproveDockUiOutput, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BLOCK_FIELD_TYPES, BLOCK_FIELD_TYPES_RENDERABLE_NOW, BODY_SCHEMA_ORIGINS, BREAKPOINTS, BUTTON_ACTIONS, BUTTON_FULL_WIDTH_INVALID, BUTTON_ICONS, BUTTON_ICON_NAMES, BUTTON_LOOK_KEYS, BUTTON_PLACEMENT_KEYS, BUTTON_SIZES, BUTTON_VARIANTS, type BetterCMSErrorCode, type BgToken, type BindingKind, type BlockBinding, type BlockHoverStyle, type BlockStyle, type BlockType, type BodySchema, type BodySchemaOrigin, type ButtonAction, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSiteLook, type ButtonSizeName, type ButtonValue, type ButtonVariant, CANVAS_GESTURE_NAMES, CATEGORY_ID_MAX, CATEGORY_ORDER, CODE_SLOT_PREFIX, COMPONENT_PROP_TYPES, CONTROL_HELP, type CanonicalInputDefinition, type CanvasGesture, type ChoiceOption, type CollectionBlock, type CollectionFilter, type CollectionProps, type ColorToken, type ColumnsBlock, type ColumnsProps, type Component, type ComponentBlock, type ComponentCategory, type ComponentCategoryId, type ComponentFormPropRef, type ComponentPreview, type ComponentPropDef, type ComponentPropType, type ComponentPropUi, type ComponentProps, type ComponentSubField, type ComponentTab, type ComponentV2, type ComponentVariantGroup, type Content, type ContentBlock, type ContentEntry, type ContentModel, type ContentModelField, type ContentModelFieldType, type ContentModelFieldUi, type ContentModelV2, type ContentPageResult, type ContentResponse, type ContentWidthToken, type ControlKind, type CornerToken, DEPTH_MAX, DERIVE_MINTED_RESERVED, DIALOG_SELECTOR, DOCK_BUDGET, DOCK_ICON_NAMES, DOCK_ICON_NAME_SET, DOCK_UI_IMPORTS, DOCK_UI_LIMITS, DOCK_UI_NAME, type DeepReadonly, type DefSources, type DeliveredLayout, type DeliveryComponent, type DeliveryEntry, type DeliveryEntrySeo, type DeliveryList, type DeliveryPage, type DerivedLocator, type DockBudget, type DockFieldLike, type DockFieldsetLike, type DockIconName, type DockInputRef, type DockLane, type DockNode, type DockPropGroupLike, type DockScreen, type DockUiBuildReceipt, type DockUiKind, type DockUiOrigin, type DockUiScope, type DockUiSource, type DockUiStatus, type DockUiVersion, type ElementLike, type EmbedCard, type ExpandedBinding, FIELD_SIZE_ZOOM, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, FRAME_REFUSALS, type FieldConfig, type FieldSize, type FieldStyle, type FieldStyleKey, type FieldStyles, type Fieldset, type FieldsetKind, type FieldsetUiBefore, type FontSizeToken, type FooterBlock, type FooterColumn, type FooterProps, type Form, type FormBlock, type FormField, type FormProps, type FormSubmission, HELP_CAPS, HELP_LINE_MAX, HELP_MAX, HELP_WRITE_MAX, type HeadingBlock, type HeadingProps, IMAGE_ASPECTS, IMAGE_FRAME_RADIUS, type ImageAspect, type ImageBlock, type ImageProps, KEY_FORBIDDEN, KEY_FORMAT, KEY_RESERVED, KEY_RESERVED_PREFIX, KIT_CATEGORIES, type KitCategory, LANDMARK_SELECTOR, LAYOUT_SECTION_ICONS, LAYOUT_SECTION_ICON_SET, LINK_RELS, LINK_VALUE_TYPES, LIST_ITEMS_CAP, LIST_PREVIEW_SLOTS, LOCATOR_PATH, type LandmarkChainElement, type LandmarkElement, type LayoutComponentItem, type LayoutDataDocument, type LayoutFieldDefinition, type LayoutFieldItem, type LayoutFieldType, type LayoutScalarFieldType, type LayoutSection, type LayoutSectionDesign, type LayoutSectionIcon, type LayoutSectionItem, type LayoutStructureDocument, type LayoutZone, type LinkPairSibling, type LinkRel, type LinkValue, type LinkValueType, type ListDockUiInput, type ListDockUiOutput, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, type NumberFieldFormat, type NumberScale, OPEN_MODES, OPEN_MODE_TYPES, OPTION_DESCRIPTION_MAX, type OpenMode, PAGE_CONTENT_ANCHOR_ID, PRIMITIVE_ARRAY_RULE, type Page, type PageLayoutOverrideDataDocument, type PageLayoutOverrideDocument, type PageLayoutOverrideState, type PageLayoutOverrideStructureDocument, type PageLayoutSectionOverride, type PageLayoutSectionStructureOverride, type PageMetaJson, type PageOnlyLayoutSection, type PageSectionPlacement, type PaginatedResult, type Perspective, type PortableTextDocument, type PortableTextNode, type PropGroup, type PropTab, type PublishDockUiInput, type PublishDockUiOutput, REFERENCE_CREATE_REFUSAL_CODES, RESPONSIVE_CSS, RICHTEXT_ADVANCED_ELEMENTS, RICHTEXT_BLOCK_ELEMENTS, RICHTEXT_BLOCK_FEATURES, RICHTEXT_CORE_ELEMENTS, RICHTEXT_ELEMENTS, RICHTEXT_FEATURES, RICHTEXT_FEATURE_ALIASES, RICHTEXT_HEADING_FEATURES, RICHTEXT_MARK_FEATURES, RICHTEXT_TOGGLE_FEATURES, ROLE_KEYS, type RadiusToken, type ReadButtonValue, type Redirect, type ReferenceCreateCapability, type ReferenceCreateRefusal, type ReferenceCreateRefusalCode, type ReferenceCreateResult, type ReferenceCreatedOption, type ReservedLayoutSection, type ResolvedAuthor, type ResolvedLayoutNode, type ResolvedPost, type RichTextBlock, type RichTextElementName, type RichTextEmbeds, type RichTextFeature, type RichTextProps, type RichTextRefusalCode, type RichTextResolved, SCHEMA_HASH_INPUTS, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SEGMENTED_MAX, SEGMENTED_MIN, SHOW_IF_SCOPES, SIDE_SPACE_MIN_PX, SIDE_SPACE_TOKENS, SLOT_CHILD_KEYS, SLOT_ITEMS_CAP, SLOT_MAX_ITEMS, SLOT_SETTINGS_MAX, SLOT_SETTINGS_TYPES, SOURCE_RANK, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type ScaleUnit, type SchemaHashTable, type SchemaSource, type SectionBlock, type SectionPlanItem, type SectionProps, type SectionSpaceToken, type ShadowToken, type ShowIf, type ShowIfRule, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SlotChild, type SlotItem, type SlotShapeOptions, type SlotShapeProblem, type SlotValue, type SourcedFacet, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, TABLE_COLUMN_TYPES, TABLE_JSONLD_TYPES, TABLE_LIMITS, TABLE_RESPONSIVE, TAB_MAX, TAB_MAX_RENDERABLE_NOW, TAG_HEADS, type TabItem, type TableCell, type TableCellObject, type TableCellValue, type TableCheckOptions, type TableColumn, type TableColumnType, type TableFieldOptions, type TableFootnote, type TableGroup, type TableLink, type TableProblem, type TableRef, type TableRefResolved, type TableRow, type TableValue, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, UI_PROTOCOLS, UI_REFUSAL_CODES, UI_REFUSAL_IDS, type UiBefore, type UiManifestEntry, type UiManifestV2, type UiOrigin, type UiProtocol, type UiRefusal, type UiRefusalFamily, type UiRefusalId, type V2Placement, type V2Shape, type V2VariantMeta, V2_KEYS, V2_PLACEMENTS, V2_SHAPES, VIDEO_TRANSCRIPT_MAX, VIDEO_VALUE_KEYS, type ValidateDockUiInput, type ValidateDockUiOutput, type VariantGroupV2, type VariantInputMapping, type VideoBlock, type VideoProps, type VideoValue, type VisibilityWindow, type WeightToken, type WindowState, type Workspace, type WriteDockUiInput, type WriteDockUiOutput, type ZoneField, allowRuleOf, anchorTargetRel, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, bodySchemaOf, buttonBlockProps, buttonFullWidthProblem, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonLookValue, buttonSiteLookOf, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, canonicalJson, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, dockUiMerkleKey, exampleFor, expandBlockBindings, fieldGroupOf, fieldStyleCssText, fieldStyleToCss, formatNumber, formatPropsAttribute, getBlockType, headingPaintCss, hiddenEverywhere, hideOnAttr, imageFrameCss, inWindow, isBlock, isButtonLookValue, isChromeLandmark, isCodeButton, isDeriveReservedKey, isDockUiImportAllowed, isLinkObject, isReservedKey, isRoleKey, isRulePaired, isScriptHref, isSlotChild, isTableValue, isUiRefusal, keyWords, landmarkRegions, linkAnchorOf, linkHref, linkRefOf, linkValueProblem, locatorFor, locatorPath, mayOverwrite, normaliseRichTextFeatures, normalizeLinkValue, normalizeTableValue, normalizeWindow, parseNumberText, parsePropsAttribute, pickFieldStyle, placementBindOf, planSections, readButtonValue, readNumberFormat, readPath, referenceCreateRefusal, regionOf, renderTableHtml, richTextRefusal, rulePartnerOf, safeCssUrl, schemaHashInput, sideFloorApplies, sideSpaceCss, slotBindOf, slotChildValues, slotItems, slotPathString, slotShapeProblems, slugify, spaceTokenCss, splitButtonStyle, tableCellText, tablePathString, tableRefCells, tableSearchText, tableToMarkdown, tableValueProblems, topFieldKeyOf, uiRefusalId, usesHideOn, videoUrlOf, videoValueProblem, visibleBlocks, visibleDeliveredLayout, visibleLayoutStructure, windowState, withButtonLookProps, withExample };
4791
+ export { type AlignToken, type AllowRule, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ApproveDockUiInput, type ApproveDockUiOutput, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BLOCK_FIELD_TYPES, BLOCK_FIELD_TYPES_RENDERABLE_NOW, BODY_SCHEMA_ORIGINS, BREAKPOINTS, BUTTON_ACTIONS, BUTTON_FULL_WIDTH_INVALID, BUTTON_ICONS, BUTTON_ICON_NAMES, BUTTON_LOOK_KEYS, BUTTON_PLACEMENT_KEYS, BUTTON_SIZES, BUTTON_VARIANTS, type BetterCMSErrorCode, type BgToken, type BindingKind, type BlockBinding, type BlockHoverStyle, type BlockStyle, type BlockType, type BodiesState, type BodyDeclaration, type BodySchema, type BodySchemaOrigin, type ButtonAction, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSiteLook, type ButtonSizeName, type ButtonValue, type ButtonVariant, CANVAS_GESTURE_NAMES, CATEGORY_ID_MAX, CATEGORY_ORDER, CODE_SLOT_PREFIX, COMPONENT_GATE_CODES, COMPONENT_PROP_TYPES, CONTROL_HELP, type CanonicalInputDefinition, type CanvasGesture, type ChoiceOption, type CollectionBlock, type CollectionFilter, type CollectionProps, type ColorToken, type ColumnsBlock, type ColumnsProps, type Component, type ComponentBlock, type ComponentCategory, type ComponentCategoryId, type ComponentEmbedNode, type ComponentFormPropRef, type ComponentGateCode, type ComponentPreview, type ComponentPropDef, type ComponentPropType, type ComponentPropUi, type ComponentProps, type ComponentSubField, type ComponentTab, type ComponentV2, type ComponentVariantGroup, type Content, type ContentBlock, type ContentEntry, type ContentModel, type ContentModelField, type ContentModelFieldType, type ContentModelFieldUi, type ContentModelV2, type ContentPageResult, type ContentResponse, type ContentWidthToken, type ControlKind, type CornerToken, DEFAULT_VARIANT, DEPTH_MAX, DERIVE_MINTED_RESERVED, DIALOG_SELECTOR, DOCK_BUDGET, DOCK_ICON_NAMES, DOCK_ICON_NAME_SET, DOCK_UI_IMPORTS, DOCK_UI_LIMITS, DOCK_UI_NAME, type DeclaredSlot, type DeepReadonly, type DefSources, type DeliveredLayout, type DeliveryComponent, type DeliveryEntry, type DeliveryEntrySeo, type DeliveryList, type DeliveryPage, type DerivedLocator, type DockBudget, type DockFieldLike, type DockFieldsetLike, type DockIconName, type DockInputRef, type DockLane, type DockNode, type DockPropGroupLike, type DockScreen, type DockUiBuildReceipt, type DockUiKind, type DockUiOrigin, type DockUiScope, type DockUiSource, type DockUiStatus, type DockUiVersion, EMBED_LEDGER_OUTCOMES, EMBED_REASONS, type ElementLike, type EmbedCapability, type EmbedCard, type EmbedLedgerOutcome, type EmbedMarker, type EmbedMarkerMatch, type EmbedNotRenderedWarning, type EmbedReason, type ExpandedBinding, FIELD_SIZE_ZOOM, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, FRAME_REFUSALS, type FieldConfig, type FieldSize, type FieldStyle, type FieldStyleKey, type FieldStyles, type Fieldset, type FieldsetKind, type FieldsetUiBefore, type FontSizeToken, type FooterBlock, type FooterColumn, type FooterProps, type Form, type FormBlock, type FormField, type FormProps, type FormSubmission, HELP_CAPS, HELP_LINE_MAX, HELP_MAX, HELP_WRITE_MAX, type HeadingBlock, type HeadingProps, IMAGE_ASPECTS, IMAGE_FRAME_RADIUS, type ImageAspect, type ImageBlock, type ImageProps, KEY_FORBIDDEN, KEY_FORMAT, KEY_RESERVED, KEY_RESERVED_PREFIX, KIT_CATEGORIES, type KitCategory, LANDMARK_SELECTOR, LAYOUT_SECTION_ICONS, LAYOUT_SECTION_ICON_SET, LINK_RELS, LINK_VALUE_TYPES, LIST_ITEMS_CAP, LIST_PREVIEW_SLOTS, LOCATOR_PATH, type LandmarkChainElement, type LandmarkElement, type LayoutComponentItem, type LayoutDataDocument, type LayoutFieldDefinition, type LayoutFieldItem, type LayoutFieldType, type LayoutScalarFieldType, type LayoutSection, type LayoutSectionDesign, type LayoutSectionIcon, type LayoutSectionItem, type LayoutStructureDocument, type LayoutZone, type LinkPairSibling, type LinkRel, type LinkValue, type LinkValueType, type ListDockUiInput, type ListDockUiOutput, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, type NumberFieldFormat, type NumberScale, OPEN_MODES, OPEN_MODE_TYPES, OPTION_DESCRIPTION_MAX, type OpenMode, PAGE_CONTENT_ANCHOR_ID, PRIMITIVE_ARRAY_RULE, type Page, type PageLayoutOverrideDataDocument, type PageLayoutOverrideDocument, type PageLayoutOverrideState, type PageLayoutOverrideStructureDocument, type PageLayoutSectionOverride, type PageLayoutSectionStructureOverride, type PageMetaJson, type PageOnlyLayoutSection, type PageSectionPlacement, type PaginatedResult, type Perspective, type PortableTextDocument, type PortableTextNode, type PropGroup, type PropTab, type PublishDockUiInput, type PublishDockUiOutput, REFERENCE_CREATE_REFUSAL_CODES, RESPONSIVE_CSS, RICHTEXT_ADVANCED_ELEMENTS, RICHTEXT_BLOCK_ELEMENTS, RICHTEXT_BLOCK_FEATURES, RICHTEXT_CORE_ELEMENTS, RICHTEXT_ELEMENTS, RICHTEXT_FEATURES, RICHTEXT_FEATURE_ALIASES, RICHTEXT_HEADING_FEATURES, RICHTEXT_MARK_FEATURES, RICHTEXT_TOGGLE_FEATURES, ROLE_KEYS, type RadiusToken, type ReadButtonValue, type Redirect, type ReferenceCreateCapability, type ReferenceCreateRefusal, type ReferenceCreateRefusalCode, type ReferenceCreateResult, type ReferenceCreatedOption, type ReservedLayoutSection, type ResolvedAuthor, type ResolvedLayoutNode, type ResolvedPost, type RichTextBlock, type RichTextElementName, type RichTextEmbeds, type RichTextFeature, type RichTextProps, type RichTextRefusalCode, type RichTextResolved, SCHEMA_HASH_INPUTS, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SEGMENTED_MAX, SEGMENTED_MIN, SHOW_IF_SCOPES, SIDE_SPACE_MIN_PX, SIDE_SPACE_TOKENS, SLOT_CHILD_KEYS, SLOT_ITEMS_CAP, SLOT_MAX_ITEMS, SLOT_SETTINGS_MAX, SLOT_SETTINGS_TYPES, SOURCE_RANK, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type ScaleUnit, type SchemaHashTable, type SchemaSource, type SectionBlock, type SectionPlanItem, type SectionProps, type SectionSpaceToken, type ShadowToken, type ShowIf, type ShowIfRule, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SlotChild, type SlotItem, type SlotShapeOptions, type SlotShapeProblem, type SlotValue, type SourcedFacet, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, TABLE_COLUMN_TYPES, TABLE_JSONLD_TYPES, TABLE_LIMITS, TABLE_RESPONSIVE, TAB_MAX, TAB_MAX_RENDERABLE_NOW, TAG_HEADS, type TabItem, type TableCell, type TableCellObject, type TableCellValue, type TableCheckOptions, type TableColumn, type TableColumnType, type TableFieldOptions, type TableFootnote, type TableGroup, type TableLink, type TableProblem, type TableRef, type TableRefResolved, type TableRow, type TableValue, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, UI_PROTOCOLS, UI_REFUSAL_CODES, UI_REFUSAL_IDS, type UiBefore, type UiManifestEntry, type UiManifestV2, type UiOrigin, type UiProtocol, type UiRefusal, type UiRefusalFamily, type UiRefusalId, type V2Placement, type V2Shape, type V2VariantMeta, V2_KEYS, V2_PLACEMENTS, V2_SHAPES, VARIANT_PROP_KEY, VIDEO_TRANSCRIPT_MAX, VIDEO_VALUE_KEYS, type ValidateDockUiInput, type ValidateDockUiOutput, type VariantGroupV2, type VariantInputMapping, type VideoBlock, type VideoProps, type VideoValue, type VisibilityWindow, WIDTH_FIT_FAIL_KINDS, type WeightToken, type WidthFitFailKind, type WidthFitResult, type WindowState, type Workspace, type WriteDockUiInput, type WriteDockUiOutput, type ZoneField, allowRuleOf, anchorTargetRel, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, bodySchemaOf, buttonBlockProps, buttonFullWidthProblem, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonLookValue, buttonSiteLookOf, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, canonicalJson, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, dockUiMerkleKey, embedAddress, embedMarkerHtml, embedVisible, evaluateShowIf, exampleFor, expandBlockBindings, fieldGroupOf, fieldStyleCssText, fieldStyleToCss, formatNumber, formatPropsAttribute, getBlockType, headingPaintCss, hiddenEverywhere, hideOnAttr, imageFrameCss, inWindow, isBlock, isButtonLookValue, isChromeLandmark, isCodeButton, isComponentGateCode, isDeriveReservedKey, isDockUiImportAllowed, isEmbedReason, isLinkObject, isReservedKey, isRoleKey, isRulePaired, isScriptHref, isSlotChild, isTableValue, isUiRefusal, isVariantVisible, keyWords, landmarkRegions, linkAnchorOf, linkHref, linkRefOf, linkValueProblem, locatorFor, locatorPath, mayOverwrite, normaliseRichTextFeatures, normalizeLinkValue, normalizeTableValue, normalizeWindow, parseEmbedMarkers, parseNumberText, parsePropsAttribute, pickFieldStyle, placementBindOf, planSections, readButtonValue, readNumberFormat, readPath, referenceCreateRefusal, regionOf, renderTableHtml, richTextRefusal, rulePartnerOf, safeCssUrl, schemaHashInput, sideFloorApplies, sideSpaceCss, slotBindOf, slotChildValues, slotItems, slotPathString, slotShapeProblems, slugify, spaceTokenCss, splitButtonStyle, tableCellText, tablePathString, tableRefCells, tableSearchText, tableToMarkdown, tableValueProblems, topFieldKeyOf, uiRefusalId, usesHideOn, variantOptionsFromUnion, variantOptionsOf, variantPropOf, videoUrlOf, videoValueProblem, visibleBlocks, visibleDeliveredLayout, visibleLayoutStructure, windowState, withButtonLookProps, withExample };
package/dist/index.js CHANGED
@@ -264,7 +264,7 @@ function formatPropsAttribute(entries) {
264
264
  }
265
265
  function parsePropsAttribute(value) {
266
266
  if (!value) return [];
267
- return value.split(";").map((entry) => entry.split("|")).filter((parts) => parts.length === 3 && parts.every(Boolean)).map(([address, kind, attr]) => ({ address, kind, attr }));
267
+ return value.split(";").map((entry) => entry.split("|")).filter((parts) => parts.length === 3 && parts.every(Boolean)).map(([address, kind, attr2]) => ({ address, kind, attr: attr2 }));
268
268
  }
269
269
  function componentPropTargetKey(prop) {
270
270
  if (!prop?.key || !prop.target?.blockId) return null;
@@ -4421,14 +4421,14 @@ function fieldGroupOf(topKey, flat = false) {
4421
4421
  if (TAG_HEADS.has(head)) return { groupKey: topKey, rooted: false };
4422
4422
  return { groupKey: head, rooted: true };
4423
4423
  }
4424
- function placementBindOf(block) {
4424
+ function placementBindOf(block, groupOf) {
4425
4425
  if (!block || typeof block !== "object" || block.type !== "component") return null;
4426
4426
  const props = block.props;
4427
4427
  const bind = props?.bind;
4428
4428
  if (typeof bind === "string" && bind) return bind;
4429
4429
  const source = props?.source;
4430
4430
  if (!source || typeof source !== "object") return null;
4431
- const groups = Object.values(source).filter((path) => typeof path === "string" && path.length > 0).map((path) => ({ top: topFieldKeyOf(path), group: fieldGroupOf(topFieldKeyOf(path), path === topFieldKeyOf(path)).groupKey }));
4431
+ const groups = Object.values(source).filter((path) => typeof path === "string" && path.length > 0).map((path) => ({ top: topFieldKeyOf(path), group: groupOf?.(topFieldKeyOf(path)) ?? fieldGroupOf(topFieldKeyOf(path), path === topFieldKeyOf(path)).groupKey }));
4432
4432
  return (groups.find((g) => g.group !== g.top) ?? groups[0])?.group ?? null;
4433
4433
  }
4434
4434
  var CODE_SLOT_PREFIX = "code:";
@@ -4787,6 +4787,112 @@ var referenceCreateRefusal = (code, detail) => ({
4787
4787
  reason: `reference_create.${code}:${detail}`
4788
4788
  });
4789
4789
 
4790
+ // src/embed.ts
4791
+ var EMBED_REASONS = [
4792
+ "EMBED_BODY_NOT_DECLARED",
4793
+ "EMBED_COMPONENT_NOT_DECLARED",
4794
+ "EMBED_VARIANT_NOT_ALLOWED",
4795
+ "EMBED_BOUND_TO_PAGE",
4796
+ "EMBED_SOURCE_NOT_RECORDED",
4797
+ "EMBED_COMPONENT_MISSING",
4798
+ "EMBED_RENDER_FAILED",
4799
+ "EMBED_FRAMEWORK_UNSUPPORTED",
4800
+ "SLOT_NOT_IN_PAGE_CODE",
4801
+ "COMPONENT_PAGE_OWN"
4802
+ ];
4803
+ var COMPONENT_GATE_CODES = [
4804
+ "COMPONENT_NOT_REUSABLE",
4805
+ "COMPONENT_SOURCE_NOT_MOUNTABLE",
4806
+ "PROP_NOT_REPRESENTABLE",
4807
+ "EMBED_WIDTH_FIT_FAILED",
4808
+ "COMPONENT_IS_CHROME",
4809
+ "COMPONENT_HAS_BODY",
4810
+ "AI_EXCLUDED"
4811
+ ];
4812
+ var WIDTH_FIT_FAIL_KINDS = ["overflow", "full-bleed", "unmeasured"];
4813
+ var EMBED_LEDGER_OUTCOMES = ["NOT_RENDERED", "HIDDEN"];
4814
+ function isEmbedReason(code) {
4815
+ return EMBED_REASONS.includes(code);
4816
+ }
4817
+ function isComponentGateCode(code) {
4818
+ return COMPONENT_GATE_CODES.includes(code);
4819
+ }
4820
+ function embedVisible(node) {
4821
+ return node?.fields?.visible !== false;
4822
+ }
4823
+ var esc2 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
4824
+ var unesc = (s) => s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
4825
+ function embedMarkerHtml(m) {
4826
+ return `<div class="bcms-block" data-bcms-schema-key="component" data-bcms-embed="${esc2(m.ptKey)}" data-bcms-component="${esc2(m.componentId)}"` + (m.hidden ? " data-bcms-embed-hidden" : "") + (m.reason ? ` data-bcms-embed-reason="${m.reason}"` : "") + "></div>";
4827
+ }
4828
+ var MARKER_RE = /<div\b([^>]*\bdata-bcms-embed="[^"]*"[^>]*)>\s*<\/div>/g;
4829
+ var attr = (attrs, name) => attrs.match(new RegExp(`\\b${name}="([^"]*)"`))?.[1];
4830
+ function parseEmbedMarkers(html) {
4831
+ const out = [];
4832
+ for (const m of html.matchAll(MARKER_RE)) {
4833
+ const attrs = m[1] ?? "";
4834
+ if (!/\bclass="[^"]*\bbcms-block\b/.test(attrs)) continue;
4835
+ const ptKey = attr(attrs, "data-bcms-embed");
4836
+ const componentId = attr(attrs, "data-bcms-component");
4837
+ if (!ptKey || !componentId) continue;
4838
+ const reason = attr(attrs, "data-bcms-embed-reason");
4839
+ out.push({
4840
+ ptKey: unesc(ptKey),
4841
+ componentId: unesc(componentId),
4842
+ .../\bdata-bcms-embed-hidden\b/.test(attrs) ? { hidden: true } : {},
4843
+ ...isEmbedReason(reason) ? { reason } : {},
4844
+ start: m.index,
4845
+ end: m.index + m[0].length
4846
+ });
4847
+ }
4848
+ return out;
4849
+ }
4850
+ var embedAddress = (field, ptKey) => `${field}#${ptKey}`;
4851
+ var VARIANT_PROP_KEY = "variant";
4852
+ var DEFAULT_VARIANT = "default";
4853
+ function variantPropOf(def) {
4854
+ return def.props?.find((p) => p.key === VARIANT_PROP_KEY && p.type === "select" && p.config?.role === "variant");
4855
+ }
4856
+ function variantOptionsOf(def) {
4857
+ const opts = (variantPropOf(def)?.config?.options ?? []).map((o) => typeof o === "string" ? o : o.value).filter(Boolean);
4858
+ return opts.length ? opts : [DEFAULT_VARIANT];
4859
+ }
4860
+ function variantOptionsFromUnion(typeText) {
4861
+ const parts = (typeText ?? "").split("|").map((s) => s.trim()).filter(Boolean);
4862
+ const lits = parts.map((s) => s.match(/^(["'])([^"']+)\1$/)?.[2]);
4863
+ return parts.length && lits.every(Boolean) ? [...new Set(lits)] : [DEFAULT_VARIANT];
4864
+ }
4865
+ function evaluateShowIf(showIf, values, sourceTypes) {
4866
+ const rules = Array.isArray(showIf?.rules) ? showIf.rules : [];
4867
+ if (!rules.length) return true;
4868
+ const str = (v) => String(v ?? "");
4869
+ const test = (r) => {
4870
+ const type = sourceTypes?.get(r.field);
4871
+ if (sourceTypes && type === void 0) return true;
4872
+ const raw = values[r.field];
4873
+ const set = raw !== void 0 && raw !== null && raw !== "" && !(Array.isArray(raw) && raw.length === 0);
4874
+ if (r.op === "isSet" || r.op === "notEmpty") return set;
4875
+ if (r.op === "empty") return !set;
4876
+ if (r.op === "gt" || r.op === "lt") {
4877
+ if (!set || typeof raw === "boolean") return false;
4878
+ const n = Number(raw), bound = Number(r.value);
4879
+ if (!Number.isFinite(n) || !Number.isFinite(bound)) return false;
4880
+ return r.op === "gt" ? n > bound : n < bound;
4881
+ }
4882
+ const s = type === "boolean" || type === "toggle" ? String(raw === true || raw === "true") : str(raw);
4883
+ if (r.op === "in" || r.op === "notIn") {
4884
+ const hit = (Array.isArray(r.value) ? r.value : [r.value]).map(str).includes(s);
4885
+ return r.op === "in" ? hit : !hit;
4886
+ }
4887
+ if (r.op === "neq") return s !== str(r.value);
4888
+ return s === str(r.value);
4889
+ };
4890
+ return showIf.match === "any" ? rules.some(test) : rules.every(test);
4891
+ }
4892
+ function isVariantVisible(prop, values, props) {
4893
+ return evaluateShowIf(prop.showIf, values, props ? new Map(props.map((p) => [p.key, p.type])) : void 0);
4894
+ }
4895
+
4790
4896
  // src/heading-id.ts
4791
4897
  var slugify = (s) => s.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "section";
4792
4898
  export {
@@ -4807,8 +4913,10 @@ export {
4807
4913
  CATEGORY_ID_MAX,
4808
4914
  CATEGORY_ORDER,
4809
4915
  CODE_SLOT_PREFIX,
4916
+ COMPONENT_GATE_CODES,
4810
4917
  COMPONENT_PROP_TYPES,
4811
4918
  CONTROL_HELP,
4919
+ DEFAULT_VARIANT,
4812
4920
  DEPTH_MAX,
4813
4921
  DERIVE_MINTED_RESERVED,
4814
4922
  DIALOG_SELECTOR,
@@ -4818,6 +4926,8 @@ export {
4818
4926
  DOCK_UI_IMPORTS,
4819
4927
  DOCK_UI_LIMITS,
4820
4928
  DOCK_UI_NAME,
4929
+ EMBED_LEDGER_OUTCOMES,
4930
+ EMBED_REASONS,
4821
4931
  FIELD_SIZE_ZOOM,
4822
4932
  FIELD_STYLE_KEYS,
4823
4933
  FOOTER_SECTION_ID,
@@ -4890,8 +5000,10 @@ export {
4890
5000
  V2_KEYS,
4891
5001
  V2_PLACEMENTS,
4892
5002
  V2_SHAPES,
5003
+ VARIANT_PROP_KEY,
4893
5004
  VIDEO_TRANSCRIPT_MAX,
4894
5005
  VIDEO_VALUE_KEYS,
5006
+ WIDTH_FIT_FAIL_KINDS,
4895
5007
  allowRuleOf,
4896
5008
  anchorTargetRel,
4897
5009
  blockStyleToColumnCss,
@@ -4916,6 +5028,10 @@ export {
4916
5028
  dockBudget,
4917
5029
  dockScreens,
4918
5030
  dockUiMerkleKey,
5031
+ embedAddress,
5032
+ embedMarkerHtml,
5033
+ embedVisible,
5034
+ evaluateShowIf,
4919
5035
  exampleFor,
4920
5036
  expandBlockBindings,
4921
5037
  fieldGroupOf,
@@ -4933,8 +5049,10 @@ export {
4933
5049
  isButtonLookValue,
4934
5050
  isChromeLandmark,
4935
5051
  isCodeButton,
5052
+ isComponentGateCode,
4936
5053
  isDeriveReservedKey,
4937
5054
  isDockUiImportAllowed,
5055
+ isEmbedReason,
4938
5056
  isLinkObject,
4939
5057
  isReservedKey,
4940
5058
  isRoleKey,
@@ -4943,6 +5061,7 @@ export {
4943
5061
  isSlotChild,
4944
5062
  isTableValue,
4945
5063
  isUiRefusal,
5064
+ isVariantVisible,
4946
5065
  keyWords,
4947
5066
  landmarkRegions,
4948
5067
  linkAnchorOf,
@@ -4956,6 +5075,7 @@ export {
4956
5075
  normalizeLinkValue,
4957
5076
  normalizeTableValue,
4958
5077
  normalizeWindow,
5078
+ parseEmbedMarkers,
4959
5079
  parseNumberText,
4960
5080
  parsePropsAttribute,
4961
5081
  pickFieldStyle,
@@ -4990,6 +5110,9 @@ export {
4990
5110
  topFieldKeyOf,
4991
5111
  uiRefusalId,
4992
5112
  usesHideOn,
5113
+ variantOptionsFromUnion,
5114
+ variantOptionsOf,
5115
+ variantPropOf,
4993
5116
  videoUrlOf,
4994
5117
  videoValueProblem,
4995
5118
  visibleBlocks,