@bettercms-ai/sdk 1.46.0 → 1.47.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/editable.cjs +229 -0
- package/dist/editable.cjs.map +1 -0
- package/dist/editable.d.cts +5 -0
- package/dist/editable.d.ts +5 -0
- package/dist/editable.js +202 -0
- package/dist/editable.js.map +1 -0
- package/dist/index.cjs +164 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -13
- package/dist/index.d.ts +84 -13
- package/dist/index.js +162 -23
- package/dist/index.js.map +1 -1
- package/dist/{read-B2lJr72F.d.ts → read-CpX17LTf.d.ts} +1 -1
- package/dist/{read-BZq0vVvs.d.cts → read-DlLBgPVS.d.cts} +1 -1
- package/dist/{read-client-DQhWuKf4.d.cts → read-client-D5jzCGEc.d.cts} +8 -1
- package/dist/{read-client-DQhWuKf4.d.ts → read-client-D5jzCGEc.d.ts} +8 -1
- package/dist/read.cjs +8 -5
- package/dist/read.cjs.map +1 -1
- package/dist/read.d.cts +2 -2
- package/dist/read.d.ts +2 -2
- package/dist/read.js +8 -5
- package/dist/read.js.map +1 -1
- package/dist/sections.cjs +8 -5
- package/dist/sections.cjs.map +1 -1
- package/dist/sections.d.cts +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/sections.js +8 -5
- package/dist/sections.js.map +1 -1
- package/dist/seo.cjs +26 -1
- package/dist/seo.cjs.map +1 -1
- package/dist/seo.d.cts +1 -1
- package/dist/seo.d.ts +1 -1
- package/dist/seo.js +24 -1
- package/dist/seo.js.map +1 -1
- package/package.json +6 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
2
|
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
3
|
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, DeliveryEntry, DeliveryList, DeliveryPage, EmbedCard, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, ResolvedAuthor, ResolvedPost, RichTextEmbeds, RichTextResolved, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, fileFieldLimits, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
|
-
import { D as DeliveryFormField } from './read-client-
|
|
5
|
-
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-
|
|
4
|
+
import { D as DeliveryFormField } from './read-client-D5jzCGEc.cjs';
|
|
5
|
+
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-D5jzCGEc.cjs';
|
|
6
6
|
export { C as CONTENT_APPLIED, a as ContentAppliedMessage, E as EDITOR_FRAME_NAME, c as contentApplied, i as inEditor, o as onContentApplied } from './in-editor-D1vXPgJh.cjs';
|
|
7
|
-
export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-
|
|
7
|
+
export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-DlLBgPVS.cjs';
|
|
8
8
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
|
|
9
9
|
export { verifyWebhookSignature } from './webhook.cjs';
|
|
10
10
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
@@ -947,36 +947,61 @@ declare const BetterCMS: {
|
|
|
947
947
|
signUp(options: SignUpInput): Promise<AuthResult>;
|
|
948
948
|
};
|
|
949
949
|
|
|
950
|
-
/**
|
|
950
|
+
/**
|
|
951
|
+
* Provenance describing where a string came from, for editor deep-linking. A `stega=2` payload
|
|
952
|
+
* (`{t, id, f}`) is read into this same shape: `type` from `t`, `field` from `f`, and `ws`/`slug`
|
|
953
|
+
* empty, because v2 does not carry them.
|
|
954
|
+
*/
|
|
951
955
|
interface StegaPayload {
|
|
952
|
-
/** Workspace slug. */
|
|
956
|
+
/** Workspace slug (v1 only; "" from a v2 payload). */
|
|
953
957
|
ws: string;
|
|
954
|
-
type: "entry" | "page";
|
|
958
|
+
type: "entry" | "page" | "layout" | "component";
|
|
955
959
|
/** Entry/page id. */
|
|
956
960
|
id: string;
|
|
961
|
+
/** v1 only; "" from a v2 payload. */
|
|
957
962
|
slug: string;
|
|
958
963
|
/** Field key (or block id) the value belongs to. */
|
|
959
964
|
field: string;
|
|
960
965
|
/** The binding kind (`text`), where the encoder knows it. */
|
|
961
966
|
kind?: string;
|
|
962
967
|
}
|
|
963
|
-
/** Append an invisible provenance payload to a string. */
|
|
968
|
+
/** Append an invisible provenance payload to a string (the v1 frame). */
|
|
964
969
|
declare function encodeStega(clean: string, payload: StegaPayload): string;
|
|
965
|
-
/**
|
|
970
|
+
/**
|
|
971
|
+
* Extract `{ clean, payload }` from a stega-encoded string (v1 or v2), or null if absent. `ref` is
|
|
972
|
+
* the field ref, present when the payload names a document.
|
|
973
|
+
*/
|
|
966
974
|
declare function decodeStega(value: string): {
|
|
967
975
|
clean: string;
|
|
968
976
|
payload: StegaPayload;
|
|
977
|
+
ref?: string;
|
|
969
978
|
} | null;
|
|
970
|
-
/**
|
|
971
|
-
|
|
979
|
+
/**
|
|
980
|
+
* A value's clean text and the field ref it carries (`entry:e_1:title`, `page:pg_1:hero.title`,
|
|
981
|
+
* `layout:nav:brand`), or `ref: null` when it carries none. What a template uses when it needs both
|
|
982
|
+
* the string to compare and the address to bind.
|
|
983
|
+
*/
|
|
984
|
+
declare function stegaSplit(value: string): {
|
|
985
|
+
clean: string;
|
|
986
|
+
ref: string | null;
|
|
987
|
+
};
|
|
972
988
|
/**
|
|
973
989
|
* Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
|
|
974
990
|
* string with it and the payload frame, so a text node can be told inside a value from text
|
|
975
991
|
* that merely precedes one. @see resolveStega
|
|
976
992
|
*/
|
|
977
993
|
declare const STEGA_OPEN = "\u2060\u2061";
|
|
978
|
-
/**
|
|
979
|
-
|
|
994
|
+
/**
|
|
995
|
+
* A value with EVERY stega frame taken out, markers included, from every string in it at any depth
|
|
996
|
+
* (arrays and plain objects). The SAME value back when it holds none. What a value passes through
|
|
997
|
+
* before it is compared, used as a key or attribute, saved or published.
|
|
998
|
+
*/
|
|
999
|
+
declare function stegaClean<T>(value: T): T;
|
|
1000
|
+
/**
|
|
1001
|
+
* Remove every stega frame. An alias of {@link stegaClean}: it used to remove only the FIRST frame,
|
|
1002
|
+
* which left the payload behind on a `stega=2` value (an open marker, then the payload).
|
|
1003
|
+
*/
|
|
1004
|
+
declare const stripStega: typeof stegaClean;
|
|
980
1005
|
/** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
|
|
981
1006
|
interface StegaNode {
|
|
982
1007
|
textContent: string | null;
|
|
@@ -999,6 +1024,52 @@ declare function resolveStega(node: StegaNode): {
|
|
|
999
1024
|
element: StegaNode;
|
|
1000
1025
|
} | null;
|
|
1001
1026
|
|
|
1027
|
+
/** A frame found where no rendered text belongs, which a template should have cleaned. */
|
|
1028
|
+
interface StegaLeak {
|
|
1029
|
+
kind: "head" | "attribute" | "script" | "style" | "form" | "comment";
|
|
1030
|
+
/** The field ref the leaked frame carries, when it carries one. */
|
|
1031
|
+
ref: string | null;
|
|
1032
|
+
/** `tag` for text, `tag[attribute]` for an attribute. */
|
|
1033
|
+
where: string;
|
|
1034
|
+
}
|
|
1035
|
+
interface MarkEditableResult {
|
|
1036
|
+
/** Elements stamped from a frame. */
|
|
1037
|
+
stamped: number;
|
|
1038
|
+
leaks: StegaLeak[];
|
|
1039
|
+
/** Values found and left unstamped: sharing their element, or a ref this page cannot stamp. */
|
|
1040
|
+
unresolved: number;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* The least of the DOM this needs, so the SDK's types never pull the DOM library into a consumer
|
|
1044
|
+
* that runs on a server: a real `Element` satisfies it, and so does a JSDOM one.
|
|
1045
|
+
*/
|
|
1046
|
+
interface MarkNode {
|
|
1047
|
+
nodeType: number;
|
|
1048
|
+
parentNode: MarkNode | null;
|
|
1049
|
+
}
|
|
1050
|
+
interface MarkElement extends MarkNode {
|
|
1051
|
+
tagName: string;
|
|
1052
|
+
namespaceURI: string | null;
|
|
1053
|
+
textContent: string | null;
|
|
1054
|
+
childElementCount: number;
|
|
1055
|
+
attributes: ArrayLike<{
|
|
1056
|
+
name: string;
|
|
1057
|
+
value: string;
|
|
1058
|
+
}>;
|
|
1059
|
+
childNodes: ArrayLike<MarkNode>;
|
|
1060
|
+
/** A `<template>`'s parsed children live here, not in `childNodes`. */
|
|
1061
|
+
content?: {
|
|
1062
|
+
childNodes: ArrayLike<MarkNode>;
|
|
1063
|
+
};
|
|
1064
|
+
hasAttribute(name: string): boolean;
|
|
1065
|
+
setAttribute(name: string, value: string): void;
|
|
1066
|
+
querySelectorAll(selector: string): ArrayLike<MarkElement>;
|
|
1067
|
+
}
|
|
1068
|
+
declare function markEditable(root: MarkElement, opts: {
|
|
1069
|
+
pageId?: string;
|
|
1070
|
+
strip: boolean;
|
|
1071
|
+
}): MarkEditableResult;
|
|
1072
|
+
|
|
1002
1073
|
/**
|
|
1003
1074
|
* Admin pages methods.
|
|
1004
1075
|
* @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
|
|
@@ -1274,4 +1345,4 @@ interface WebhookListResponse {
|
|
|
1274
1345
|
};
|
|
1275
1346
|
}
|
|
1276
1347
|
|
|
1277
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1348
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MarkEditableResult, type MarkElement, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaLeak, type StegaNode, type StegaPayload, type SubmissionListOptions, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, markEditable, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stegaSplit, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
2
|
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
3
|
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, DeliveryEntry, DeliveryList, DeliveryPage, EmbedCard, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, ResolvedAuthor, ResolvedPost, RichTextEmbeds, RichTextResolved, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, fileFieldLimits, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
|
-
import { D as DeliveryFormField } from './read-client-
|
|
5
|
-
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-
|
|
4
|
+
import { D as DeliveryFormField } from './read-client-D5jzCGEc.js';
|
|
5
|
+
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, U as UploadFormFileOptions, h as UploadedFormFile, i as asStringArray, j as createClient, k as fileFieldRefusal, l as formInitialValues, m as isMultiValueField, s as shouldShowField, n as submitForm, t as toggleOption, u as uploadFormFile } from './read-client-D5jzCGEc.js';
|
|
6
6
|
export { C as CONTENT_APPLIED, a as ContentAppliedMessage, E as EDITOR_FRAME_NAME, c as contentApplied, i as inEditor, o as onContentApplied } from './in-editor-D1vXPgJh.js';
|
|
7
|
-
export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-
|
|
7
|
+
export { P as PORTABLE_TEXT_FORMAT, a as PublishedContent, R as ResolvedHolder, b as RichTextValue, S as SearchHit, c as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, d as portableText, f as publishedContentFile, g as publishedEntry, r as readPublishedContent, h as resetPublishedContentCache, j as resolved, k as rich, s as search } from './read-CpX17LTf.js';
|
|
8
8
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.js';
|
|
9
9
|
export { verifyWebhookSignature } from './webhook.js';
|
|
10
10
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
@@ -947,36 +947,61 @@ declare const BetterCMS: {
|
|
|
947
947
|
signUp(options: SignUpInput): Promise<AuthResult>;
|
|
948
948
|
};
|
|
949
949
|
|
|
950
|
-
/**
|
|
950
|
+
/**
|
|
951
|
+
* Provenance describing where a string came from, for editor deep-linking. A `stega=2` payload
|
|
952
|
+
* (`{t, id, f}`) is read into this same shape: `type` from `t`, `field` from `f`, and `ws`/`slug`
|
|
953
|
+
* empty, because v2 does not carry them.
|
|
954
|
+
*/
|
|
951
955
|
interface StegaPayload {
|
|
952
|
-
/** Workspace slug. */
|
|
956
|
+
/** Workspace slug (v1 only; "" from a v2 payload). */
|
|
953
957
|
ws: string;
|
|
954
|
-
type: "entry" | "page";
|
|
958
|
+
type: "entry" | "page" | "layout" | "component";
|
|
955
959
|
/** Entry/page id. */
|
|
956
960
|
id: string;
|
|
961
|
+
/** v1 only; "" from a v2 payload. */
|
|
957
962
|
slug: string;
|
|
958
963
|
/** Field key (or block id) the value belongs to. */
|
|
959
964
|
field: string;
|
|
960
965
|
/** The binding kind (`text`), where the encoder knows it. */
|
|
961
966
|
kind?: string;
|
|
962
967
|
}
|
|
963
|
-
/** Append an invisible provenance payload to a string. */
|
|
968
|
+
/** Append an invisible provenance payload to a string (the v1 frame). */
|
|
964
969
|
declare function encodeStega(clean: string, payload: StegaPayload): string;
|
|
965
|
-
/**
|
|
970
|
+
/**
|
|
971
|
+
* Extract `{ clean, payload }` from a stega-encoded string (v1 or v2), or null if absent. `ref` is
|
|
972
|
+
* the field ref, present when the payload names a document.
|
|
973
|
+
*/
|
|
966
974
|
declare function decodeStega(value: string): {
|
|
967
975
|
clean: string;
|
|
968
976
|
payload: StegaPayload;
|
|
977
|
+
ref?: string;
|
|
969
978
|
} | null;
|
|
970
|
-
/**
|
|
971
|
-
|
|
979
|
+
/**
|
|
980
|
+
* A value's clean text and the field ref it carries (`entry:e_1:title`, `page:pg_1:hero.title`,
|
|
981
|
+
* `layout:nav:brand`), or `ref: null` when it carries none. What a template uses when it needs both
|
|
982
|
+
* the string to compare and the address to bind.
|
|
983
|
+
*/
|
|
984
|
+
declare function stegaSplit(value: string): {
|
|
985
|
+
clean: string;
|
|
986
|
+
ref: string | null;
|
|
987
|
+
};
|
|
972
988
|
/**
|
|
973
989
|
* Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
|
|
974
990
|
* string with it and the payload frame, so a text node can be told inside a value from text
|
|
975
991
|
* that merely precedes one. @see resolveStega
|
|
976
992
|
*/
|
|
977
993
|
declare const STEGA_OPEN = "\u2060\u2061";
|
|
978
|
-
/**
|
|
979
|
-
|
|
994
|
+
/**
|
|
995
|
+
* A value with EVERY stega frame taken out, markers included, from every string in it at any depth
|
|
996
|
+
* (arrays and plain objects). The SAME value back when it holds none. What a value passes through
|
|
997
|
+
* before it is compared, used as a key or attribute, saved or published.
|
|
998
|
+
*/
|
|
999
|
+
declare function stegaClean<T>(value: T): T;
|
|
1000
|
+
/**
|
|
1001
|
+
* Remove every stega frame. An alias of {@link stegaClean}: it used to remove only the FIRST frame,
|
|
1002
|
+
* which left the payload behind on a `stega=2` value (an open marker, then the payload).
|
|
1003
|
+
*/
|
|
1004
|
+
declare const stripStega: typeof stegaClean;
|
|
980
1005
|
/** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
|
|
981
1006
|
interface StegaNode {
|
|
982
1007
|
textContent: string | null;
|
|
@@ -999,6 +1024,52 @@ declare function resolveStega(node: StegaNode): {
|
|
|
999
1024
|
element: StegaNode;
|
|
1000
1025
|
} | null;
|
|
1001
1026
|
|
|
1027
|
+
/** A frame found where no rendered text belongs, which a template should have cleaned. */
|
|
1028
|
+
interface StegaLeak {
|
|
1029
|
+
kind: "head" | "attribute" | "script" | "style" | "form" | "comment";
|
|
1030
|
+
/** The field ref the leaked frame carries, when it carries one. */
|
|
1031
|
+
ref: string | null;
|
|
1032
|
+
/** `tag` for text, `tag[attribute]` for an attribute. */
|
|
1033
|
+
where: string;
|
|
1034
|
+
}
|
|
1035
|
+
interface MarkEditableResult {
|
|
1036
|
+
/** Elements stamped from a frame. */
|
|
1037
|
+
stamped: number;
|
|
1038
|
+
leaks: StegaLeak[];
|
|
1039
|
+
/** Values found and left unstamped: sharing their element, or a ref this page cannot stamp. */
|
|
1040
|
+
unresolved: number;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* The least of the DOM this needs, so the SDK's types never pull the DOM library into a consumer
|
|
1044
|
+
* that runs on a server: a real `Element` satisfies it, and so does a JSDOM one.
|
|
1045
|
+
*/
|
|
1046
|
+
interface MarkNode {
|
|
1047
|
+
nodeType: number;
|
|
1048
|
+
parentNode: MarkNode | null;
|
|
1049
|
+
}
|
|
1050
|
+
interface MarkElement extends MarkNode {
|
|
1051
|
+
tagName: string;
|
|
1052
|
+
namespaceURI: string | null;
|
|
1053
|
+
textContent: string | null;
|
|
1054
|
+
childElementCount: number;
|
|
1055
|
+
attributes: ArrayLike<{
|
|
1056
|
+
name: string;
|
|
1057
|
+
value: string;
|
|
1058
|
+
}>;
|
|
1059
|
+
childNodes: ArrayLike<MarkNode>;
|
|
1060
|
+
/** A `<template>`'s parsed children live here, not in `childNodes`. */
|
|
1061
|
+
content?: {
|
|
1062
|
+
childNodes: ArrayLike<MarkNode>;
|
|
1063
|
+
};
|
|
1064
|
+
hasAttribute(name: string): boolean;
|
|
1065
|
+
setAttribute(name: string, value: string): void;
|
|
1066
|
+
querySelectorAll(selector: string): ArrayLike<MarkElement>;
|
|
1067
|
+
}
|
|
1068
|
+
declare function markEditable(root: MarkElement, opts: {
|
|
1069
|
+
pageId?: string;
|
|
1070
|
+
strip: boolean;
|
|
1071
|
+
}): MarkEditableResult;
|
|
1072
|
+
|
|
1002
1073
|
/**
|
|
1003
1074
|
* Admin pages methods.
|
|
1004
1075
|
* @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
|
|
@@ -1274,4 +1345,4 @@ interface WebhookListResponse {
|
|
|
1274
1345
|
};
|
|
1275
1346
|
}
|
|
1276
1347
|
|
|
1277
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1348
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MarkEditableResult, type MarkElement, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaLeak, type StegaNode, type StegaPayload, type SubmissionListOptions, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, markEditable, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stegaSplit, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.js
CHANGED
|
@@ -1287,6 +1287,7 @@ function createClient(options) {
|
|
|
1287
1287
|
}
|
|
1288
1288
|
const draft = perspective === "drafts";
|
|
1289
1289
|
const stega = options.stega ?? draft;
|
|
1290
|
+
const stegaParam = stega === 2 ? "2" : stega ? "1" : void 0;
|
|
1290
1291
|
return {
|
|
1291
1292
|
perspective,
|
|
1292
1293
|
async getEntry(slug, opts) {
|
|
@@ -1294,12 +1295,12 @@ function createClient(options) {
|
|
|
1294
1295
|
token: previewToken,
|
|
1295
1296
|
depth: opts?.depth,
|
|
1296
1297
|
select: opts?.select?.join(","),
|
|
1297
|
-
stega:
|
|
1298
|
+
stega: stegaParam
|
|
1298
1299
|
})}` : `${base}/content-entries/${encodeURIComponent(slug)}${qs({
|
|
1299
1300
|
depth: opts?.depth,
|
|
1300
1301
|
select: opts?.select?.join(","),
|
|
1301
1302
|
perspective: draft ? "draft" : void 0,
|
|
1302
|
-
stega: draft
|
|
1303
|
+
stega: draft ? stegaParam : void 0,
|
|
1303
1304
|
projectId: defaultProjectId,
|
|
1304
1305
|
branch
|
|
1305
1306
|
})}`;
|
|
@@ -1314,7 +1315,7 @@ function createClient(options) {
|
|
|
1314
1315
|
select: opts?.select?.join(","),
|
|
1315
1316
|
...listQueryParams(opts?.filter, opts?.sort),
|
|
1316
1317
|
perspective: draft ? "draft" : void 0,
|
|
1317
|
-
stega: draft
|
|
1318
|
+
stega: draft ? stegaParam : void 0,
|
|
1318
1319
|
projectId: defaultProjectId,
|
|
1319
1320
|
branch
|
|
1320
1321
|
})}`;
|
|
@@ -1324,7 +1325,7 @@ function createClient(options) {
|
|
|
1324
1325
|
if (draft && previewToken && tokenSlug(previewToken) === slug) {
|
|
1325
1326
|
const url = `${apiUrl}/api/v1/preview/${encodeURIComponent(slug)}${qs({
|
|
1326
1327
|
token: previewToken,
|
|
1327
|
-
stega:
|
|
1328
|
+
stega: stegaParam
|
|
1328
1329
|
})}`;
|
|
1329
1330
|
const d = unwrap(await fetchJSON(url));
|
|
1330
1331
|
return {
|
|
@@ -1354,6 +1355,8 @@ function createClient(options) {
|
|
|
1354
1355
|
page: opts?.page,
|
|
1355
1356
|
perPage: opts?.perPage,
|
|
1356
1357
|
slug: opts?.slug,
|
|
1358
|
+
// Framed only on a branch, the draft lane of this list; never v1, which frames no blocks.
|
|
1359
|
+
stega: draft && stega === 2 ? "2" : void 0,
|
|
1357
1360
|
projectId: defaultProjectId,
|
|
1358
1361
|
branch
|
|
1359
1362
|
})}`;
|
|
@@ -1369,7 +1372,7 @@ function createClient(options) {
|
|
|
1369
1372
|
return unwrap(await fetchJSON(url));
|
|
1370
1373
|
},
|
|
1371
1374
|
async getLayout() {
|
|
1372
|
-
const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId, branch })}`;
|
|
1375
|
+
const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, stega: draft && stega === 2 ? "2" : void 0, projectId: defaultProjectId, branch })}`;
|
|
1373
1376
|
try {
|
|
1374
1377
|
return unwrap(await fetchJSON(url));
|
|
1375
1378
|
} catch (error) {
|
|
@@ -1397,7 +1400,7 @@ var ZERO = "\u200B";
|
|
|
1397
1400
|
var ONE = "\u200C";
|
|
1398
1401
|
var START = "\u2060";
|
|
1399
1402
|
var END = "\u2061";
|
|
1400
|
-
var
|
|
1403
|
+
var FRAMES = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`, "g");
|
|
1401
1404
|
function toBits(s) {
|
|
1402
1405
|
const bytes = new TextEncoder().encode(s);
|
|
1403
1406
|
let out = "";
|
|
@@ -1418,23 +1421,50 @@ function fromBits(bits) {
|
|
|
1418
1421
|
function encodeStega(clean, payload) {
|
|
1419
1422
|
return `${clean}${START}${toBits(JSON.stringify(payload))}${END}`;
|
|
1420
1423
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
if (!m || m[1] == null) return null;
|
|
1424
|
+
var V2_TYPES = { e: "entry", p: "page", l: "layout", c: "component" };
|
|
1425
|
+
function payloadOf(bits) {
|
|
1424
1426
|
try {
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
+
const raw = JSON.parse(fromBits(bits));
|
|
1428
|
+
if (typeof raw.t === "string" && raw.t in V2_TYPES && typeof raw.id === "string" && typeof raw.f === "string") {
|
|
1429
|
+
return { ws: "", type: V2_TYPES[raw.t], id: raw.id, slug: "", field: raw.f };
|
|
1430
|
+
}
|
|
1431
|
+
return raw;
|
|
1427
1432
|
} catch {
|
|
1428
1433
|
return null;
|
|
1429
1434
|
}
|
|
1430
1435
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1436
|
+
var TARGETS = { entry: 1, page: 1, layout: 1, component: 1 };
|
|
1437
|
+
var stegaRef = (payload) => typeof payload.type === "string" && payload.type in TARGETS && typeof payload.id === "string" && typeof payload.field === "string" ? `${payload.type}:${payload.id}:${payload.field}` : null;
|
|
1438
|
+
function decodeStega(value) {
|
|
1439
|
+
for (const frame of value.matchAll(FRAMES)) {
|
|
1440
|
+
if (!frame[1]) continue;
|
|
1441
|
+
const payload = payloadOf(frame[1]);
|
|
1442
|
+
if (!payload) return null;
|
|
1443
|
+
const ref = stegaRef(payload);
|
|
1444
|
+
return { clean: stegaClean(value), payload, ...ref ? { ref } : {} };
|
|
1445
|
+
}
|
|
1446
|
+
return null;
|
|
1447
|
+
}
|
|
1448
|
+
function stegaSplit(value) {
|
|
1449
|
+
const decoded = decodeStega(value);
|
|
1450
|
+
return { clean: decoded?.clean ?? stegaClean(value), ref: decoded?.ref ?? null };
|
|
1433
1451
|
}
|
|
1434
1452
|
var STEGA_OPEN = `${START}${END}`;
|
|
1435
|
-
var FRAMES = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`, "g");
|
|
1436
1453
|
function stegaClean(value) {
|
|
1437
|
-
return value.replace(FRAMES, "");
|
|
1454
|
+
if (typeof value === "string") return value.includes(START) ? value.replace(FRAMES, "") : value;
|
|
1455
|
+
if (Array.isArray(value)) {
|
|
1456
|
+
const out = value.map((v) => stegaClean(v));
|
|
1457
|
+
return out.some((v, i) => v !== value[i]) ? out : value;
|
|
1458
|
+
}
|
|
1459
|
+
if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
1460
|
+
const entries = Object.entries(value).map(([k, v]) => [k, stegaClean(v)]);
|
|
1461
|
+
return entries.some(([k, v]) => v !== value[k]) ? Object.fromEntries(entries) : value;
|
|
1462
|
+
}
|
|
1463
|
+
return value;
|
|
1464
|
+
}
|
|
1465
|
+
var stripStega = stegaClean;
|
|
1466
|
+
function stegaFrames(text) {
|
|
1467
|
+
return [...text.matchAll(FRAMES)].map((m) => ({ index: m.index, end: m.index + m[0].length, payload: m[1] ? payloadOf(m[1]) : null, open: !m[1] }));
|
|
1438
1468
|
}
|
|
1439
1469
|
function resolveStega(node) {
|
|
1440
1470
|
let offset = 0;
|
|
@@ -1446,22 +1476,126 @@ function resolveStega(node) {
|
|
|
1446
1476
|
}
|
|
1447
1477
|
const text = up.textContent ?? "";
|
|
1448
1478
|
const opens = [];
|
|
1449
|
-
for (const frame of text
|
|
1450
|
-
if (
|
|
1479
|
+
for (const frame of stegaFrames(text)) {
|
|
1480
|
+
if (frame.open) {
|
|
1451
1481
|
opens.push(frame.index);
|
|
1452
1482
|
continue;
|
|
1453
1483
|
}
|
|
1454
1484
|
const open = opens.pop();
|
|
1455
|
-
if (frame.
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1485
|
+
if (frame.end <= offset || open === void 0 || open >= offset + length) continue;
|
|
1486
|
+
if (!frame.payload) break;
|
|
1487
|
+
return { payload: frame.payload, element: up };
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
return null;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
// src/mark-editable.ts
|
|
1494
|
+
var BOUND = ["data-bcms-field", "data-bcms-layout-field", "data-bcms-entry-field"];
|
|
1495
|
+
var NOT_PROSE = { SCRIPT: "script", STYLE: "style", NOSCRIPT: "script", TEMPLATE: "script", TITLE: "head", TEXTAREA: "form" };
|
|
1496
|
+
var INLINE_BREAKS = /* @__PURE__ */ new Set(["BR", "WBR"]);
|
|
1497
|
+
var SVG = "http://www.w3.org/2000/svg";
|
|
1498
|
+
var START2 = "\u2060";
|
|
1499
|
+
var isBound = (el) => BOUND.some((name) => el.hasAttribute(name));
|
|
1500
|
+
function refIn(text) {
|
|
1501
|
+
const payload = stegaFrames(text).find((frame) => frame.payload)?.payload;
|
|
1502
|
+
return payload ? stegaRef(payload) : null;
|
|
1503
|
+
}
|
|
1504
|
+
function stampOf(ref, pageId) {
|
|
1505
|
+
const [target, id] = ref.split(":", 2);
|
|
1506
|
+
const path = ref.slice(`${target}:${id}:`.length);
|
|
1507
|
+
if (!path) return null;
|
|
1508
|
+
if (target === "entry") return ["data-bcms-entry-field", ref];
|
|
1509
|
+
if (target === "layout") return ["data-bcms-layout-field", ref];
|
|
1510
|
+
if (target === "page" && pageId && id === pageId) return ["data-bcms-field", path];
|
|
1511
|
+
return null;
|
|
1512
|
+
}
|
|
1513
|
+
function markEditable(root, opts) {
|
|
1514
|
+
const leaks = [];
|
|
1515
|
+
const texts = [];
|
|
1516
|
+
const all = [];
|
|
1517
|
+
const leak = (kind, where, text) => leaks.push({ kind, ref: refIn(text), where });
|
|
1518
|
+
const visit = (el, skip) => {
|
|
1519
|
+
for (const attr of Array.from(el.attributes)) {
|
|
1520
|
+
if (!attr.value.includes(START2)) continue;
|
|
1521
|
+
leak("attribute", `${el.tagName.toLowerCase()}[${attr.name}]`, attr.value);
|
|
1522
|
+
el.setAttribute(attr.name, stegaClean(attr.value));
|
|
1523
|
+
}
|
|
1524
|
+
const own = el.tagName === "HEAD" ? "head" : NOT_PROSE[el.tagName];
|
|
1525
|
+
const next = skip ?? own ?? (el.namespaceURI === SVG ? "bound" : null) ?? (el !== root && isBound(el) ? "bound" : null);
|
|
1526
|
+
for (const node of [...Array.from(el.childNodes), ...Array.from(el.content?.childNodes ?? [])]) {
|
|
1527
|
+
if (node.nodeType === 1) visit(node, next);
|
|
1528
|
+
else if (node.nodeType === 8 && node.data.includes(START2)) {
|
|
1529
|
+
const comment = node;
|
|
1530
|
+
leak("comment", el.tagName.toLowerCase(), comment.data);
|
|
1531
|
+
comment.data = stegaClean(comment.data);
|
|
1532
|
+
} else if (node.nodeType === 3) {
|
|
1533
|
+
const text = node;
|
|
1534
|
+
all.push(text);
|
|
1535
|
+
if (next === null) texts.push(text);
|
|
1536
|
+
else if (next !== "bound" && text.data.includes(START2)) {
|
|
1537
|
+
leak(next, el.tagName.toLowerCase(), text.data);
|
|
1538
|
+
text.data = stegaClean(text.data);
|
|
1539
|
+
}
|
|
1460
1540
|
}
|
|
1461
1541
|
}
|
|
1542
|
+
};
|
|
1543
|
+
visit(root, null);
|
|
1544
|
+
const starts = [];
|
|
1545
|
+
let full = "";
|
|
1546
|
+
for (const text of texts) {
|
|
1547
|
+
starts.push(full.length);
|
|
1548
|
+
full += text.data;
|
|
1549
|
+
}
|
|
1550
|
+
const nodeAt = (offset) => {
|
|
1551
|
+
let lo = 0;
|
|
1552
|
+
let hi = starts.length - 1;
|
|
1553
|
+
while (lo < hi) {
|
|
1554
|
+
const mid = lo + hi + 1 >> 1;
|
|
1555
|
+
if (starts[mid] <= offset) lo = mid;
|
|
1556
|
+
else hi = mid - 1;
|
|
1557
|
+
}
|
|
1558
|
+
return lo;
|
|
1559
|
+
};
|
|
1560
|
+
let stamped = 0;
|
|
1561
|
+
let unresolved = 0;
|
|
1562
|
+
const opens = [];
|
|
1563
|
+
for (const frame of stegaFrames(full)) {
|
|
1564
|
+
if (frame.open) {
|
|
1565
|
+
opens.push(frame.index);
|
|
1566
|
+
continue;
|
|
1567
|
+
}
|
|
1568
|
+
const start = opens.pop() ?? starts[nodeAt(frame.index)];
|
|
1569
|
+
if (!frame.payload) continue;
|
|
1570
|
+
const first = texts[nodeAt(start)];
|
|
1571
|
+
const last = texts[nodeAt(frame.end - 1)];
|
|
1572
|
+
const holder = commonElement(first, last);
|
|
1573
|
+
const ref = stegaRef(frame.payload);
|
|
1574
|
+
const stamp = ref ? stampOf(ref, opts.pageId) : null;
|
|
1575
|
+
if (!holder || holder === root || !stamp || !holdsOnly(holder, stegaClean(full.slice(start, frame.end)))) {
|
|
1576
|
+
unresolved += 1;
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
holder.setAttribute(stamp[0], stamp[1]);
|
|
1580
|
+
holder.setAttribute("data-bcms-kind", "text");
|
|
1581
|
+
holder.setAttribute("data-bcms-match", "stega");
|
|
1582
|
+
stamped += 1;
|
|
1462
1583
|
}
|
|
1584
|
+
if (opts.strip) {
|
|
1585
|
+
for (const text of all) if (text.data.includes(START2)) text.data = stegaClean(text.data);
|
|
1586
|
+
}
|
|
1587
|
+
return { stamped, leaks, unresolved };
|
|
1588
|
+
}
|
|
1589
|
+
function commonElement(a, b) {
|
|
1590
|
+
const above = /* @__PURE__ */ new Set();
|
|
1591
|
+
for (let n = a.parentNode; n; n = n.parentNode) above.add(n);
|
|
1592
|
+
for (let n = b.parentNode; n; n = n.parentNode) if (above.has(n) && n.nodeType === 1) return n;
|
|
1463
1593
|
return null;
|
|
1464
1594
|
}
|
|
1595
|
+
function holdsOnly(el, value) {
|
|
1596
|
+
if (stegaClean(el.textContent ?? "").trim() !== value.trim()) return false;
|
|
1597
|
+
return el.childElementCount === 0 || Array.from(el.querySelectorAll("*")).every((child) => INLINE_BREAKS.has(child.tagName) || stegaClean(child.textContent ?? "").trim() !== "");
|
|
1598
|
+
}
|
|
1465
1599
|
|
|
1466
1600
|
// src/content-applied.ts
|
|
1467
1601
|
var CONTENT_APPLIED = "bcms:content-applied";
|
|
@@ -1620,7 +1754,10 @@ function entrySeoInput(entry) {
|
|
|
1620
1754
|
noindex: noindex === true
|
|
1621
1755
|
};
|
|
1622
1756
|
}
|
|
1623
|
-
function resolveSeo(
|
|
1757
|
+
function resolveSeo(framedPage, framedDefaults = {}, location = {}) {
|
|
1758
|
+
const { title: pageTitle, metaTitle, metaDescription, metaJson, slug, noindex } = framedPage;
|
|
1759
|
+
const page = stegaClean({ title: pageTitle, metaTitle, metaDescription, metaJson, slug, noindex });
|
|
1760
|
+
const defaults = stegaClean(framedDefaults);
|
|
1624
1761
|
const meta = page.metaJson ?? {};
|
|
1625
1762
|
const title = page.metaTitle || page.title || "";
|
|
1626
1763
|
const description = page.metaDescription || defaults.metaDescription || "";
|
|
@@ -2141,6 +2278,7 @@ export {
|
|
|
2141
2278
|
listPages,
|
|
2142
2279
|
listSubmissions,
|
|
2143
2280
|
listWorkspaces,
|
|
2281
|
+
markEditable,
|
|
2144
2282
|
onContentApplied,
|
|
2145
2283
|
plain,
|
|
2146
2284
|
portableText,
|
|
@@ -2165,6 +2303,7 @@ export {
|
|
|
2165
2303
|
signInWithGoogle,
|
|
2166
2304
|
signUp,
|
|
2167
2305
|
stegaClean,
|
|
2306
|
+
stegaSplit,
|
|
2168
2307
|
stripStega,
|
|
2169
2308
|
submitForm,
|
|
2170
2309
|
toggleOption,
|