@bettercms-ai/sdk 1.28.0 → 1.30.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.cjs +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -1
- package/dist/index.d.ts +70 -1
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -797,6 +797,7 @@ interface ManagedComponentInput {
|
|
|
797
797
|
/** Update only: prop chrome by prop path (`cta.label`). Any of these, or `override`, needs `ifMatch`. */
|
|
798
798
|
propUi?: Record<string, Record<string, unknown> | null>;
|
|
799
799
|
propGroup?: Record<string, Record<string, unknown> | null>;
|
|
800
|
+
propTab?: Record<string, Record<string, unknown> | null>;
|
|
800
801
|
propLabel?: Record<string, string>;
|
|
801
802
|
/** Replace chrome a person shaped; without it that is a 409 `ui_human_owned`. */
|
|
802
803
|
override?: boolean;
|
|
@@ -1244,6 +1245,8 @@ interface StegaPayload {
|
|
|
1244
1245
|
slug: string;
|
|
1245
1246
|
/** Field key (or block id) the value belongs to. */
|
|
1246
1247
|
field: string;
|
|
1248
|
+
/** The binding kind (`text`), where the encoder knows it. */
|
|
1249
|
+
kind?: string;
|
|
1247
1250
|
}
|
|
1248
1251
|
/** Append an invisible provenance payload to a string. */
|
|
1249
1252
|
declare function encodeStega(clean: string, payload: StegaPayload): string;
|
|
@@ -1254,6 +1257,72 @@ declare function decodeStega(value: string): {
|
|
|
1254
1257
|
} | null;
|
|
1255
1258
|
/** Remove any stega payload, returning the clean string. */
|
|
1256
1259
|
declare function stripStega(value: string): string;
|
|
1260
|
+
/**
|
|
1261
|
+
* Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
|
|
1262
|
+
* string with it and the payload frame, so a text node can be told inside a value from text
|
|
1263
|
+
* that merely precedes one. @see resolveStega
|
|
1264
|
+
*/
|
|
1265
|
+
declare const STEGA_OPEN = "\u2060\u2061";
|
|
1266
|
+
/** Remove EVERY stega frame, markers included. What a value passes through before it is saved or published. */
|
|
1267
|
+
declare function stegaClean(value: string): string;
|
|
1268
|
+
/** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
|
|
1269
|
+
interface StegaNode {
|
|
1270
|
+
textContent: string | null;
|
|
1271
|
+
parentNode: StegaNode | null;
|
|
1272
|
+
childNodes?: ArrayLike<StegaNode>;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Which value does this node render? Its payload and the nearest ancestor that holds the whole
|
|
1276
|
+
* value, or null when the node's text belongs to none.
|
|
1277
|
+
*
|
|
1278
|
+
* By CONTENT, not by attribute: a splitting library cuts a heading into one element per
|
|
1279
|
+
* character, a marquee clones its track, a component redraws its children, and the element a
|
|
1280
|
+
* build stamped is gone or copied. The string survives all of that, in order, across however
|
|
1281
|
+
* many text nodes: climbing from the clicked node, the first ancestor whose text holds a value
|
|
1282
|
+
* (its open marker to its payload frame) that overlaps the node is the value's extent.
|
|
1283
|
+
* Every copy of a value resolves to the same payload.
|
|
1284
|
+
*/
|
|
1285
|
+
declare function resolveStega(node: StegaNode): {
|
|
1286
|
+
payload: StegaPayload;
|
|
1287
|
+
element: StegaNode;
|
|
1288
|
+
} | null;
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
|
|
1292
|
+
* the page's DOM.
|
|
1293
|
+
*
|
|
1294
|
+
* An edit changes how tall a heading is. Everything on the page that measured the layout once
|
|
1295
|
+
* (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
|
|
1296
|
+
* text splitter's lines) is now wrong, and only the page's own code can measure again. So the
|
|
1297
|
+
* editor posts one message to the frame's window after each applied edit, and the site listens:
|
|
1298
|
+
*
|
|
1299
|
+
* onContentApplied(() => ScrollTrigger.refresh());
|
|
1300
|
+
*
|
|
1301
|
+
* A published page receives no such message: nothing there posts it, and the listener is inert.
|
|
1302
|
+
*/
|
|
1303
|
+
/** The `type` of the message. */
|
|
1304
|
+
declare const CONTENT_APPLIED = "bcms:content-applied";
|
|
1305
|
+
interface ContentAppliedMessage {
|
|
1306
|
+
type: typeof CONTENT_APPLIED;
|
|
1307
|
+
/** The field addresses whose rendering changed; empty when the editor does not say. */
|
|
1308
|
+
fields: string[];
|
|
1309
|
+
}
|
|
1310
|
+
/** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
|
|
1311
|
+
declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
|
|
1312
|
+
/** The least of `window` this needs. */
|
|
1313
|
+
interface MessageTarget {
|
|
1314
|
+
addEventListener(type: "message", listener: (event: {
|
|
1315
|
+
data: unknown;
|
|
1316
|
+
}) => void): void;
|
|
1317
|
+
removeEventListener(type: "message", listener: (event: {
|
|
1318
|
+
data: unknown;
|
|
1319
|
+
}) => void): void;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Run `handler` after every edit the editor applies to this page. Returns the function that
|
|
1323
|
+
* stops listening. Safe to call where there is no window (a server render): it does nothing.
|
|
1324
|
+
*/
|
|
1325
|
+
declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
|
|
1257
1326
|
|
|
1258
1327
|
/**
|
|
1259
1328
|
* Reading a rich-text field, for any site.
|
|
@@ -1827,4 +1896,4 @@ interface WebhookListResponse {
|
|
|
1827
1896
|
};
|
|
1828
1897
|
}
|
|
1829
1898
|
|
|
1830
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1899
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, 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, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.d.ts
CHANGED
|
@@ -797,6 +797,7 @@ interface ManagedComponentInput {
|
|
|
797
797
|
/** Update only: prop chrome by prop path (`cta.label`). Any of these, or `override`, needs `ifMatch`. */
|
|
798
798
|
propUi?: Record<string, Record<string, unknown> | null>;
|
|
799
799
|
propGroup?: Record<string, Record<string, unknown> | null>;
|
|
800
|
+
propTab?: Record<string, Record<string, unknown> | null>;
|
|
800
801
|
propLabel?: Record<string, string>;
|
|
801
802
|
/** Replace chrome a person shaped; without it that is a 409 `ui_human_owned`. */
|
|
802
803
|
override?: boolean;
|
|
@@ -1244,6 +1245,8 @@ interface StegaPayload {
|
|
|
1244
1245
|
slug: string;
|
|
1245
1246
|
/** Field key (or block id) the value belongs to. */
|
|
1246
1247
|
field: string;
|
|
1248
|
+
/** The binding kind (`text`), where the encoder knows it. */
|
|
1249
|
+
kind?: string;
|
|
1247
1250
|
}
|
|
1248
1251
|
/** Append an invisible provenance payload to a string. */
|
|
1249
1252
|
declare function encodeStega(clean: string, payload: StegaPayload): string;
|
|
@@ -1254,6 +1257,72 @@ declare function decodeStega(value: string): {
|
|
|
1254
1257
|
} | null;
|
|
1255
1258
|
/** Remove any stega payload, returning the clean string. */
|
|
1256
1259
|
declare function stripStega(value: string): string;
|
|
1260
|
+
/**
|
|
1261
|
+
* Where a value BEGINS in a rendered page: an empty frame. The canvas brackets every bound
|
|
1262
|
+
* string with it and the payload frame, so a text node can be told inside a value from text
|
|
1263
|
+
* that merely precedes one. @see resolveStega
|
|
1264
|
+
*/
|
|
1265
|
+
declare const STEGA_OPEN = "\u2060\u2061";
|
|
1266
|
+
/** Remove EVERY stega frame, markers included. What a value passes through before it is saved or published. */
|
|
1267
|
+
declare function stegaClean(value: string): string;
|
|
1268
|
+
/** The least of a DOM node this needs: a real `Node` satisfies it, and so does a test's plain object. */
|
|
1269
|
+
interface StegaNode {
|
|
1270
|
+
textContent: string | null;
|
|
1271
|
+
parentNode: StegaNode | null;
|
|
1272
|
+
childNodes?: ArrayLike<StegaNode>;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Which value does this node render? Its payload and the nearest ancestor that holds the whole
|
|
1276
|
+
* value, or null when the node's text belongs to none.
|
|
1277
|
+
*
|
|
1278
|
+
* By CONTENT, not by attribute: a splitting library cuts a heading into one element per
|
|
1279
|
+
* character, a marquee clones its track, a component redraws its children, and the element a
|
|
1280
|
+
* build stamped is gone or copied. The string survives all of that, in order, across however
|
|
1281
|
+
* many text nodes: climbing from the clicked node, the first ancestor whose text holds a value
|
|
1282
|
+
* (its open marker to its payload frame) that overlaps the node is the value's extent.
|
|
1283
|
+
* Every copy of a value resolves to the same payload.
|
|
1284
|
+
*/
|
|
1285
|
+
declare function resolveStega(node: StegaNode): {
|
|
1286
|
+
payload: StegaPayload;
|
|
1287
|
+
element: StegaNode;
|
|
1288
|
+
} | null;
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
|
|
1292
|
+
* the page's DOM.
|
|
1293
|
+
*
|
|
1294
|
+
* An edit changes how tall a heading is. Everything on the page that measured the layout once
|
|
1295
|
+
* (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
|
|
1296
|
+
* text splitter's lines) is now wrong, and only the page's own code can measure again. So the
|
|
1297
|
+
* editor posts one message to the frame's window after each applied edit, and the site listens:
|
|
1298
|
+
*
|
|
1299
|
+
* onContentApplied(() => ScrollTrigger.refresh());
|
|
1300
|
+
*
|
|
1301
|
+
* A published page receives no such message: nothing there posts it, and the listener is inert.
|
|
1302
|
+
*/
|
|
1303
|
+
/** The `type` of the message. */
|
|
1304
|
+
declare const CONTENT_APPLIED = "bcms:content-applied";
|
|
1305
|
+
interface ContentAppliedMessage {
|
|
1306
|
+
type: typeof CONTENT_APPLIED;
|
|
1307
|
+
/** The field addresses whose rendering changed; empty when the editor does not say. */
|
|
1308
|
+
fields: string[];
|
|
1309
|
+
}
|
|
1310
|
+
/** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
|
|
1311
|
+
declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
|
|
1312
|
+
/** The least of `window` this needs. */
|
|
1313
|
+
interface MessageTarget {
|
|
1314
|
+
addEventListener(type: "message", listener: (event: {
|
|
1315
|
+
data: unknown;
|
|
1316
|
+
}) => void): void;
|
|
1317
|
+
removeEventListener(type: "message", listener: (event: {
|
|
1318
|
+
data: unknown;
|
|
1319
|
+
}) => void): void;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Run `handler` after every edit the editor applies to this page. Returns the function that
|
|
1323
|
+
* stops listening. Safe to call where there is no window (a server render): it does nothing.
|
|
1324
|
+
*/
|
|
1325
|
+
declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
|
|
1257
1326
|
|
|
1258
1327
|
/**
|
|
1259
1328
|
* Reading a rich-text field, for any site.
|
|
@@ -1827,4 +1896,4 @@ interface WebhookListResponse {
|
|
|
1827
1896
|
};
|
|
1828
1897
|
}
|
|
1829
1898
|
|
|
1830
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1899
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedSeo, type RichTextValue, STEGA_OPEN, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, type TextOrRich, 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, asStringArray, commandManagedLayout, contentApplied, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, resolveStega, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.js
CHANGED
|
@@ -1395,6 +1395,52 @@ function decodeStega(value) {
|
|
|
1395
1395
|
function stripStega(value) {
|
|
1396
1396
|
return value.replace(FRAME, "");
|
|
1397
1397
|
}
|
|
1398
|
+
var STEGA_OPEN = `${START}${END}`;
|
|
1399
|
+
var FRAMES = new RegExp(`${START}([${ZERO}${ONE}]*)${END}`, "g");
|
|
1400
|
+
function stegaClean(value) {
|
|
1401
|
+
return value.replace(FRAMES, "");
|
|
1402
|
+
}
|
|
1403
|
+
function resolveStega(node) {
|
|
1404
|
+
let offset = 0;
|
|
1405
|
+
const length = node.textContent?.length ?? 0;
|
|
1406
|
+
for (let cur = node, up = node.parentNode; up; cur = up, up = up.parentNode) {
|
|
1407
|
+
for (const sibling of Array.from(up.childNodes ?? [])) {
|
|
1408
|
+
if (sibling === cur) break;
|
|
1409
|
+
offset += sibling.textContent?.length ?? 0;
|
|
1410
|
+
}
|
|
1411
|
+
const text = up.textContent ?? "";
|
|
1412
|
+
const opens = [];
|
|
1413
|
+
for (const frame of text.matchAll(FRAMES)) {
|
|
1414
|
+
if (!frame[1]) {
|
|
1415
|
+
opens.push(frame.index);
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
const open = opens.pop();
|
|
1419
|
+
if (frame.index + frame[0].length <= offset || open === void 0 || open >= offset + length) continue;
|
|
1420
|
+
try {
|
|
1421
|
+
return { payload: JSON.parse(fromBits(frame[1])), element: up };
|
|
1422
|
+
} catch {
|
|
1423
|
+
break;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
return null;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
// src/content-applied.ts
|
|
1431
|
+
var CONTENT_APPLIED = "bcms:content-applied";
|
|
1432
|
+
var contentApplied = (fields = []) => ({ type: CONTENT_APPLIED, fields: [...fields] });
|
|
1433
|
+
function onContentApplied(handler, target = globalThis.window) {
|
|
1434
|
+
if (!target) return () => {
|
|
1435
|
+
};
|
|
1436
|
+
const listener = (event) => {
|
|
1437
|
+
const data = event.data;
|
|
1438
|
+
if (!data || typeof data !== "object" || data.type !== CONTENT_APPLIED) return;
|
|
1439
|
+
handler({ type: CONTENT_APPLIED, fields: Array.isArray(data.fields) ? data.fields.filter((f) => typeof f === "string") : [] });
|
|
1440
|
+
};
|
|
1441
|
+
target.addEventListener("message", listener);
|
|
1442
|
+
return () => target.removeEventListener("message", listener);
|
|
1443
|
+
}
|
|
1398
1444
|
|
|
1399
1445
|
// src/richtext.ts
|
|
1400
1446
|
var PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
@@ -1913,12 +1959,15 @@ export {
|
|
|
1913
1959
|
BetterCMSDeliveryClient,
|
|
1914
1960
|
BetterCMSError,
|
|
1915
1961
|
BetterCMSManagementClient,
|
|
1962
|
+
CONTENT_APPLIED,
|
|
1916
1963
|
ErrorCodes,
|
|
1917
1964
|
PORTABLE_TEXT_FORMAT,
|
|
1965
|
+
STEGA_OPEN,
|
|
1918
1966
|
addModelFields,
|
|
1919
1967
|
addPageFields,
|
|
1920
1968
|
asStringArray,
|
|
1921
1969
|
commandManagedLayout,
|
|
1970
|
+
contentApplied,
|
|
1922
1971
|
createApiKey,
|
|
1923
1972
|
createClient,
|
|
1924
1973
|
createEntry,
|
|
@@ -1966,6 +2015,7 @@ export {
|
|
|
1966
2015
|
listPages,
|
|
1967
2016
|
listSubmissions,
|
|
1968
2017
|
listWorkspaces,
|
|
2018
|
+
onContentApplied,
|
|
1969
2019
|
plain,
|
|
1970
2020
|
portableText,
|
|
1971
2021
|
publishManagedLayout,
|
|
@@ -1977,6 +2027,7 @@ export {
|
|
|
1977
2027
|
removeMember,
|
|
1978
2028
|
resetPublishedContentCache,
|
|
1979
2029
|
resolveSeo,
|
|
2030
|
+
resolveStega,
|
|
1980
2031
|
revokeApiKey,
|
|
1981
2032
|
rich,
|
|
1982
2033
|
search,
|
|
@@ -1986,6 +2037,7 @@ export {
|
|
|
1986
2037
|
signInWithGithub,
|
|
1987
2038
|
signInWithGoogle,
|
|
1988
2039
|
signUp,
|
|
2040
|
+
stegaClean,
|
|
1989
2041
|
stripStega,
|
|
1990
2042
|
submitForm,
|
|
1991
2043
|
toggleOption,
|