@distinctagency/cms-client 1.23.0 → 1.25.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.mts +82 -2
- package/dist/index.d.ts +82 -2
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -1
- package/dist/index.mjs.map +1 -1
- package/dist/visual-editing.d.mts +14 -0
- package/dist/visual-editing.d.ts +14 -0
- package/dist/visual-editing.js +226 -0
- package/dist/visual-editing.js.map +1 -0
- package/dist/visual-editing.mjs +202 -0
- package/dist/visual-editing.mjs.map +1 -0
- package/package.json +6 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
7
7
|
* report installed-version telemetry and to send `x-cms-client-version` on
|
|
8
8
|
* outgoing requests.
|
|
9
9
|
*/
|
|
10
|
-
declare const CMS_CLIENT_VERSION = "1.
|
|
10
|
+
declare const CMS_CLIENT_VERSION = "1.25.0";
|
|
11
11
|
|
|
12
12
|
/** Field types supported by the CMS schema */
|
|
13
13
|
type FieldType = "text" | "textarea" | "richtext" | "date" | "datetime" | "select" | "number" | "boolean" | "image" | "gallery" | "url" | "file" | "reference" | "multi-reference" | "computed" | "color" | "tags" | "json" | "embed" | "flipbook";
|
|
@@ -58,6 +58,10 @@ interface FieldDefinition {
|
|
|
58
58
|
decimal_places?: number;
|
|
59
59
|
/** For date fields: which parts of the date the editor collects. Defaults to `full`. Stored in partial-ISO form — see {@link DateGranularity}. */
|
|
60
60
|
date_granularity?: DateGranularity;
|
|
61
|
+
/** For text/textarea/richtext fields: hard maximum character count. Enforced in the editor and on save. Undefined = no cap. */
|
|
62
|
+
max_length?: number;
|
|
63
|
+
/** For text/textarea/richtext fields: soft target character count. Exceeding it shows a warning but does not block saving. */
|
|
64
|
+
recommended_length?: number;
|
|
61
65
|
}
|
|
62
66
|
interface Tenant {
|
|
63
67
|
id: string;
|
|
@@ -111,6 +115,10 @@ interface ContentType {
|
|
|
111
115
|
schema: FieldDefinition[];
|
|
112
116
|
seo_config?: ContentTypeSeoConfig | null;
|
|
113
117
|
required_membership_tier_id?: string | null;
|
|
118
|
+
/** When true, this content type is a "page": it holds exactly one item, edited as a singleton document rather than a collection. */
|
|
119
|
+
is_singleton?: boolean;
|
|
120
|
+
/** For singleton pages: the site path the visual editor previews (e.g. "/", "/about"). Defaults to "/". */
|
|
121
|
+
preview_path?: string;
|
|
114
122
|
created_at: string;
|
|
115
123
|
}
|
|
116
124
|
interface ContentItem {
|
|
@@ -419,6 +427,18 @@ declare function createCmsClient(supabase: SupabaseClient, options: CmsClientOpt
|
|
|
419
427
|
* Returns null if not found.
|
|
420
428
|
*/
|
|
421
429
|
getContentItemBySlug(contentTypeSlug: string, itemSlug: string): Promise<ContentItem | null>;
|
|
430
|
+
/**
|
|
431
|
+
* Get the single published item for a singleton content type ("page").
|
|
432
|
+
*
|
|
433
|
+
* A singleton content type owns exactly one item. Use this for editable
|
|
434
|
+
* page copy (hero text, section headings, etc.) stored in the CMS.
|
|
435
|
+
* Returns null when the singleton has no published item yet — callers
|
|
436
|
+
* should fall back to their hardcoded defaults in that case.
|
|
437
|
+
*
|
|
438
|
+
* Wrap this in `unstable_cache` with a `cms:singleton:<slug>` tag on the
|
|
439
|
+
* consuming site to cache it and revalidate via the CMS webhook.
|
|
440
|
+
*/
|
|
441
|
+
getSingleton(contentTypeSlug: string): Promise<ContentItem | null>;
|
|
422
442
|
/**
|
|
423
443
|
* Get a content type definition (including its field schema).
|
|
424
444
|
*/
|
|
@@ -527,6 +547,13 @@ interface TrackingConfigOptions {
|
|
|
527
547
|
* handler so public-token changes take effect immediately.
|
|
528
548
|
*/
|
|
529
549
|
declare const MAPBOX_CONFIG_TAG = "cms:mapbox-config";
|
|
550
|
+
/**
|
|
551
|
+
* Cache tag for a singleton "page" content type. Wrap `getSingleton(slug)` in
|
|
552
|
+
* `unstable_cache` tagged with `singletonTag(slug)`, then call
|
|
553
|
+
* `revalidateTag(singletonTag(slug))` from the CMS `content.updated` webhook
|
|
554
|
+
* (the webhook payload's `cache_tags` already include this value).
|
|
555
|
+
*/
|
|
556
|
+
declare function singletonTag(slug: string): string;
|
|
530
557
|
interface MapboxConfigOptions {
|
|
531
558
|
/** Cache lifetime in seconds on Next.js. Defaults to 3600. `0` disables caching, `false` caches until tag revalidation. Ignored outside Next.js. */
|
|
532
559
|
revalidate?: number | false;
|
|
@@ -908,4 +935,57 @@ declare function revalidateAllTags(payload: Pick<WebhookEventPayload, "cache_tag
|
|
|
908
935
|
expire?: number;
|
|
909
936
|
}) => unknown): string[];
|
|
910
937
|
|
|
911
|
-
|
|
938
|
+
/** Discriminator stamped on every visual-editing postMessage. */
|
|
939
|
+
declare const CMS_VISUAL_SOURCE: "cms-visual";
|
|
940
|
+
/** CMS origins the bridge will trust by default. */
|
|
941
|
+
declare const DEFAULT_TRUSTED_ORIGINS: readonly string[];
|
|
942
|
+
type VisualFieldType = "text" | "image";
|
|
943
|
+
/** Compact wire type announced in `ready`; the schema adds length constraints. */
|
|
944
|
+
interface VisualFieldMeta {
|
|
945
|
+
name: string;
|
|
946
|
+
type: VisualFieldType;
|
|
947
|
+
}
|
|
948
|
+
interface VisualFieldSchema {
|
|
949
|
+
name: string;
|
|
950
|
+
type: VisualFieldType;
|
|
951
|
+
max_length?: number;
|
|
952
|
+
recommended_length?: number;
|
|
953
|
+
}
|
|
954
|
+
interface ReadyMessage {
|
|
955
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
956
|
+
type: "ready";
|
|
957
|
+
fields: VisualFieldMeta[];
|
|
958
|
+
}
|
|
959
|
+
interface EditMessage {
|
|
960
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
961
|
+
type: "edit";
|
|
962
|
+
name: string;
|
|
963
|
+
value: string;
|
|
964
|
+
length: number;
|
|
965
|
+
}
|
|
966
|
+
interface PickImageMessage {
|
|
967
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
968
|
+
type: "pick-image";
|
|
969
|
+
name: string;
|
|
970
|
+
}
|
|
971
|
+
interface InitMessage {
|
|
972
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
973
|
+
type: "init";
|
|
974
|
+
values: Record<string, string>;
|
|
975
|
+
schema: Record<string, VisualFieldSchema>;
|
|
976
|
+
}
|
|
977
|
+
interface SetMessage {
|
|
978
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
979
|
+
type: "set";
|
|
980
|
+
name: string;
|
|
981
|
+
value: string;
|
|
982
|
+
}
|
|
983
|
+
type BridgeOutbound = ReadyMessage | EditMessage | PickImageMessage;
|
|
984
|
+
type BridgeInbound = InitMessage | SetMessage;
|
|
985
|
+
type VisualMessage = BridgeOutbound | BridgeInbound;
|
|
986
|
+
/** Exact-match origin allowlist, plus any localhost port for local dev. */
|
|
987
|
+
declare function isTrustedOrigin(origin: string, allowlist: readonly string[]): boolean;
|
|
988
|
+
/** Narrow an unknown postMessage payload to a visual message, or null. */
|
|
989
|
+
declare function parseVisualMessage(data: unknown): VisualMessage | null;
|
|
990
|
+
|
|
991
|
+
export { type BookingStatus, type BridgeInbound, type BridgeOutbound, CMS_CLIENT_VERSION, CMS_VISUAL_SOURCE, type CmsClientOptions, type CmsEvent, type CmsTicketTier, type ContentItem, type ContentQueryOptions, type ContentType, type ContentTypeSeoConfig, type CreateBookingParams, type CreateBookingResult, type CreateOrderParams, type CreateOrderResult, DEFAULT_TRUSTED_ORIGINS, type DateGranularity, type DiscountType, type EditMessage, type EmbedValue, type EventQueryOptions, type EventStatus, type EventWithTiers, type FieldDefinition, type FieldType, type FlipbookPagePublic, type FlipbookPublic, type FlipbookTocEntryPublic, type FormatPartialDateOptions, type GeocodeOptions, type GeocodeResult, type GoogleReview, IMAGE_PRESETS, type ImageConfig, type ImageTransformOptions, type InitMessage, MAPBOX_CONFIG_TAG, type MapboxConfig, type MapboxConfigOptions, type MapsClientOptions, type MediaFolder, type MediaItem, type Member, type MembershipTier, type OrderAddress, type OrderLineItem, type OrderStatus, type ParsedPartialDate, type PaymentStatus, type PickImageMessage, type Product, type ProductCategory, type ProductOption, type ProductQueryOptions, type ProductStatus, type ProductVariant, type Profile, type ReadyMessage, type ReviewQueryOptions, type SetMessage, TRACKING_CONFIG_TAG, type Tenant, type TenantMembership, type TrackingConfig, type TrackingConfigOptions, type VisualFieldMeta, type VisualFieldSchema, type VisualFieldType, type VisualMessage, WEBHOOK_EVENTS, type WebhookEvent, type WebhookEventPayload, createCmsClient, createEventsClient, createMapsClient, createShopClient, formatPartialDate, getEmbedHtml, getSrcSet, getTransformUrl, isTrustedOrigin, parsePartialDate, parseVisualMessage, revalidateAllTags, singletonTag, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
7
7
|
* report installed-version telemetry and to send `x-cms-client-version` on
|
|
8
8
|
* outgoing requests.
|
|
9
9
|
*/
|
|
10
|
-
declare const CMS_CLIENT_VERSION = "1.
|
|
10
|
+
declare const CMS_CLIENT_VERSION = "1.25.0";
|
|
11
11
|
|
|
12
12
|
/** Field types supported by the CMS schema */
|
|
13
13
|
type FieldType = "text" | "textarea" | "richtext" | "date" | "datetime" | "select" | "number" | "boolean" | "image" | "gallery" | "url" | "file" | "reference" | "multi-reference" | "computed" | "color" | "tags" | "json" | "embed" | "flipbook";
|
|
@@ -58,6 +58,10 @@ interface FieldDefinition {
|
|
|
58
58
|
decimal_places?: number;
|
|
59
59
|
/** For date fields: which parts of the date the editor collects. Defaults to `full`. Stored in partial-ISO form — see {@link DateGranularity}. */
|
|
60
60
|
date_granularity?: DateGranularity;
|
|
61
|
+
/** For text/textarea/richtext fields: hard maximum character count. Enforced in the editor and on save. Undefined = no cap. */
|
|
62
|
+
max_length?: number;
|
|
63
|
+
/** For text/textarea/richtext fields: soft target character count. Exceeding it shows a warning but does not block saving. */
|
|
64
|
+
recommended_length?: number;
|
|
61
65
|
}
|
|
62
66
|
interface Tenant {
|
|
63
67
|
id: string;
|
|
@@ -111,6 +115,10 @@ interface ContentType {
|
|
|
111
115
|
schema: FieldDefinition[];
|
|
112
116
|
seo_config?: ContentTypeSeoConfig | null;
|
|
113
117
|
required_membership_tier_id?: string | null;
|
|
118
|
+
/** When true, this content type is a "page": it holds exactly one item, edited as a singleton document rather than a collection. */
|
|
119
|
+
is_singleton?: boolean;
|
|
120
|
+
/** For singleton pages: the site path the visual editor previews (e.g. "/", "/about"). Defaults to "/". */
|
|
121
|
+
preview_path?: string;
|
|
114
122
|
created_at: string;
|
|
115
123
|
}
|
|
116
124
|
interface ContentItem {
|
|
@@ -419,6 +427,18 @@ declare function createCmsClient(supabase: SupabaseClient, options: CmsClientOpt
|
|
|
419
427
|
* Returns null if not found.
|
|
420
428
|
*/
|
|
421
429
|
getContentItemBySlug(contentTypeSlug: string, itemSlug: string): Promise<ContentItem | null>;
|
|
430
|
+
/**
|
|
431
|
+
* Get the single published item for a singleton content type ("page").
|
|
432
|
+
*
|
|
433
|
+
* A singleton content type owns exactly one item. Use this for editable
|
|
434
|
+
* page copy (hero text, section headings, etc.) stored in the CMS.
|
|
435
|
+
* Returns null when the singleton has no published item yet — callers
|
|
436
|
+
* should fall back to their hardcoded defaults in that case.
|
|
437
|
+
*
|
|
438
|
+
* Wrap this in `unstable_cache` with a `cms:singleton:<slug>` tag on the
|
|
439
|
+
* consuming site to cache it and revalidate via the CMS webhook.
|
|
440
|
+
*/
|
|
441
|
+
getSingleton(contentTypeSlug: string): Promise<ContentItem | null>;
|
|
422
442
|
/**
|
|
423
443
|
* Get a content type definition (including its field schema).
|
|
424
444
|
*/
|
|
@@ -527,6 +547,13 @@ interface TrackingConfigOptions {
|
|
|
527
547
|
* handler so public-token changes take effect immediately.
|
|
528
548
|
*/
|
|
529
549
|
declare const MAPBOX_CONFIG_TAG = "cms:mapbox-config";
|
|
550
|
+
/**
|
|
551
|
+
* Cache tag for a singleton "page" content type. Wrap `getSingleton(slug)` in
|
|
552
|
+
* `unstable_cache` tagged with `singletonTag(slug)`, then call
|
|
553
|
+
* `revalidateTag(singletonTag(slug))` from the CMS `content.updated` webhook
|
|
554
|
+
* (the webhook payload's `cache_tags` already include this value).
|
|
555
|
+
*/
|
|
556
|
+
declare function singletonTag(slug: string): string;
|
|
530
557
|
interface MapboxConfigOptions {
|
|
531
558
|
/** Cache lifetime in seconds on Next.js. Defaults to 3600. `0` disables caching, `false` caches until tag revalidation. Ignored outside Next.js. */
|
|
532
559
|
revalidate?: number | false;
|
|
@@ -908,4 +935,57 @@ declare function revalidateAllTags(payload: Pick<WebhookEventPayload, "cache_tag
|
|
|
908
935
|
expire?: number;
|
|
909
936
|
}) => unknown): string[];
|
|
910
937
|
|
|
911
|
-
|
|
938
|
+
/** Discriminator stamped on every visual-editing postMessage. */
|
|
939
|
+
declare const CMS_VISUAL_SOURCE: "cms-visual";
|
|
940
|
+
/** CMS origins the bridge will trust by default. */
|
|
941
|
+
declare const DEFAULT_TRUSTED_ORIGINS: readonly string[];
|
|
942
|
+
type VisualFieldType = "text" | "image";
|
|
943
|
+
/** Compact wire type announced in `ready`; the schema adds length constraints. */
|
|
944
|
+
interface VisualFieldMeta {
|
|
945
|
+
name: string;
|
|
946
|
+
type: VisualFieldType;
|
|
947
|
+
}
|
|
948
|
+
interface VisualFieldSchema {
|
|
949
|
+
name: string;
|
|
950
|
+
type: VisualFieldType;
|
|
951
|
+
max_length?: number;
|
|
952
|
+
recommended_length?: number;
|
|
953
|
+
}
|
|
954
|
+
interface ReadyMessage {
|
|
955
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
956
|
+
type: "ready";
|
|
957
|
+
fields: VisualFieldMeta[];
|
|
958
|
+
}
|
|
959
|
+
interface EditMessage {
|
|
960
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
961
|
+
type: "edit";
|
|
962
|
+
name: string;
|
|
963
|
+
value: string;
|
|
964
|
+
length: number;
|
|
965
|
+
}
|
|
966
|
+
interface PickImageMessage {
|
|
967
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
968
|
+
type: "pick-image";
|
|
969
|
+
name: string;
|
|
970
|
+
}
|
|
971
|
+
interface InitMessage {
|
|
972
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
973
|
+
type: "init";
|
|
974
|
+
values: Record<string, string>;
|
|
975
|
+
schema: Record<string, VisualFieldSchema>;
|
|
976
|
+
}
|
|
977
|
+
interface SetMessage {
|
|
978
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
979
|
+
type: "set";
|
|
980
|
+
name: string;
|
|
981
|
+
value: string;
|
|
982
|
+
}
|
|
983
|
+
type BridgeOutbound = ReadyMessage | EditMessage | PickImageMessage;
|
|
984
|
+
type BridgeInbound = InitMessage | SetMessage;
|
|
985
|
+
type VisualMessage = BridgeOutbound | BridgeInbound;
|
|
986
|
+
/** Exact-match origin allowlist, plus any localhost port for local dev. */
|
|
987
|
+
declare function isTrustedOrigin(origin: string, allowlist: readonly string[]): boolean;
|
|
988
|
+
/** Narrow an unknown postMessage payload to a visual message, or null. */
|
|
989
|
+
declare function parseVisualMessage(data: unknown): VisualMessage | null;
|
|
990
|
+
|
|
991
|
+
export { type BookingStatus, type BridgeInbound, type BridgeOutbound, CMS_CLIENT_VERSION, CMS_VISUAL_SOURCE, type CmsClientOptions, type CmsEvent, type CmsTicketTier, type ContentItem, type ContentQueryOptions, type ContentType, type ContentTypeSeoConfig, type CreateBookingParams, type CreateBookingResult, type CreateOrderParams, type CreateOrderResult, DEFAULT_TRUSTED_ORIGINS, type DateGranularity, type DiscountType, type EditMessage, type EmbedValue, type EventQueryOptions, type EventStatus, type EventWithTiers, type FieldDefinition, type FieldType, type FlipbookPagePublic, type FlipbookPublic, type FlipbookTocEntryPublic, type FormatPartialDateOptions, type GeocodeOptions, type GeocodeResult, type GoogleReview, IMAGE_PRESETS, type ImageConfig, type ImageTransformOptions, type InitMessage, MAPBOX_CONFIG_TAG, type MapboxConfig, type MapboxConfigOptions, type MapsClientOptions, type MediaFolder, type MediaItem, type Member, type MembershipTier, type OrderAddress, type OrderLineItem, type OrderStatus, type ParsedPartialDate, type PaymentStatus, type PickImageMessage, type Product, type ProductCategory, type ProductOption, type ProductQueryOptions, type ProductStatus, type ProductVariant, type Profile, type ReadyMessage, type ReviewQueryOptions, type SetMessage, TRACKING_CONFIG_TAG, type Tenant, type TenantMembership, type TrackingConfig, type TrackingConfigOptions, type VisualFieldMeta, type VisualFieldSchema, type VisualFieldType, type VisualMessage, WEBHOOK_EVENTS, type WebhookEvent, type WebhookEventPayload, createCmsClient, createEventsClient, createMapsClient, createShopClient, formatPartialDate, getEmbedHtml, getSrcSet, getTransformUrl, isTrustedOrigin, parsePartialDate, parseVisualMessage, revalidateAllTags, singletonTag, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
CMS_CLIENT_VERSION: () => CMS_CLIENT_VERSION,
|
|
24
|
+
CMS_VISUAL_SOURCE: () => CMS_VISUAL_SOURCE,
|
|
25
|
+
DEFAULT_TRUSTED_ORIGINS: () => DEFAULT_TRUSTED_ORIGINS,
|
|
24
26
|
IMAGE_PRESETS: () => IMAGE_PRESETS,
|
|
25
27
|
MAPBOX_CONFIG_TAG: () => MAPBOX_CONFIG_TAG,
|
|
26
28
|
TRACKING_CONFIG_TAG: () => TRACKING_CONFIG_TAG,
|
|
@@ -33,14 +35,17 @@ __export(src_exports, {
|
|
|
33
35
|
getEmbedHtml: () => getEmbedHtml,
|
|
34
36
|
getSrcSet: () => getSrcSet,
|
|
35
37
|
getTransformUrl: () => getTransformUrl,
|
|
38
|
+
isTrustedOrigin: () => isTrustedOrigin,
|
|
36
39
|
parsePartialDate: () => parsePartialDate,
|
|
40
|
+
parseVisualMessage: () => parseVisualMessage,
|
|
37
41
|
revalidateAllTags: () => revalidateAllTags,
|
|
42
|
+
singletonTag: () => singletonTag,
|
|
38
43
|
verifyWebhookSignature: () => verifyWebhookSignature
|
|
39
44
|
});
|
|
40
45
|
module.exports = __toCommonJS(src_exports);
|
|
41
46
|
|
|
42
47
|
// src/version.ts
|
|
43
|
-
var CMS_CLIENT_VERSION = "1.
|
|
48
|
+
var CMS_CLIENT_VERSION = "1.25.0";
|
|
44
49
|
|
|
45
50
|
// src/queries.ts
|
|
46
51
|
var import_supabase_js = require("@supabase/supabase-js");
|
|
@@ -216,6 +221,27 @@ function createCmsClient(supabase, options) {
|
|
|
216
221
|
}
|
|
217
222
|
return data;
|
|
218
223
|
},
|
|
224
|
+
/**
|
|
225
|
+
* Get the single published item for a singleton content type ("page").
|
|
226
|
+
*
|
|
227
|
+
* A singleton content type owns exactly one item. Use this for editable
|
|
228
|
+
* page copy (hero text, section headings, etc.) stored in the CMS.
|
|
229
|
+
* Returns null when the singleton has no published item yet — callers
|
|
230
|
+
* should fall back to their hardcoded defaults in that case.
|
|
231
|
+
*
|
|
232
|
+
* Wrap this in `unstable_cache` with a `cms:singleton:<slug>` tag on the
|
|
233
|
+
* consuming site to cache it and revalidate via the CMS webhook.
|
|
234
|
+
*/
|
|
235
|
+
async getSingleton(contentTypeSlug) {
|
|
236
|
+
const contentTypeId = await getContentTypeId(contentTypeSlug);
|
|
237
|
+
const { data, error } = await client.from("content_items").select("*").eq("content_type_id", contentTypeId).eq("status", "published").order("updated_at", { ascending: false }).limit(1).maybeSingle();
|
|
238
|
+
if (error) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Failed to fetch singleton ${contentTypeSlug}: ${error.message}`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return data ?? null;
|
|
244
|
+
},
|
|
219
245
|
/**
|
|
220
246
|
* Get a content type definition (including its field schema).
|
|
221
247
|
*/
|
|
@@ -418,6 +444,9 @@ function createCmsClient(supabase, options) {
|
|
|
418
444
|
}
|
|
419
445
|
var TRACKING_CONFIG_TAG = "cms:tracking-config";
|
|
420
446
|
var MAPBOX_CONFIG_TAG = "cms:mapbox-config";
|
|
447
|
+
function singletonTag(slug) {
|
|
448
|
+
return `cms:singleton:${slug}`;
|
|
449
|
+
}
|
|
421
450
|
function nullify(v) {
|
|
422
451
|
if (!v) return null;
|
|
423
452
|
const trimmed = v.trim();
|
|
@@ -772,9 +801,29 @@ function timingSafeEqualHex(a, b) {
|
|
|
772
801
|
}
|
|
773
802
|
return mismatch === 0;
|
|
774
803
|
}
|
|
804
|
+
|
|
805
|
+
// src/visual-editing/protocol.ts
|
|
806
|
+
var CMS_VISUAL_SOURCE = "cms-visual";
|
|
807
|
+
var DEFAULT_TRUSTED_ORIGINS = [
|
|
808
|
+
"https://cms.distinctstudio.co.nz",
|
|
809
|
+
"https://distinctcms.com"
|
|
810
|
+
];
|
|
811
|
+
function isTrustedOrigin(origin, allowlist) {
|
|
812
|
+
if (allowlist.includes(origin)) return true;
|
|
813
|
+
return /^https?:\/\/localhost(:\d+)?$/.test(origin);
|
|
814
|
+
}
|
|
815
|
+
var VALID_VISUAL_TYPES = /* @__PURE__ */ new Set(["ready", "edit", "pick-image", "init", "set"]);
|
|
816
|
+
function parseVisualMessage(data) {
|
|
817
|
+
if (typeof data === "object" && data !== null && data.source === CMS_VISUAL_SOURCE && typeof data.type === "string" && VALID_VISUAL_TYPES.has(data.type)) {
|
|
818
|
+
return data;
|
|
819
|
+
}
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
775
822
|
// Annotate the CommonJS export names for ESM import in node:
|
|
776
823
|
0 && (module.exports = {
|
|
777
824
|
CMS_CLIENT_VERSION,
|
|
825
|
+
CMS_VISUAL_SOURCE,
|
|
826
|
+
DEFAULT_TRUSTED_ORIGINS,
|
|
778
827
|
IMAGE_PRESETS,
|
|
779
828
|
MAPBOX_CONFIG_TAG,
|
|
780
829
|
TRACKING_CONFIG_TAG,
|
|
@@ -787,8 +836,11 @@ function timingSafeEqualHex(a, b) {
|
|
|
787
836
|
getEmbedHtml,
|
|
788
837
|
getSrcSet,
|
|
789
838
|
getTransformUrl,
|
|
839
|
+
isTrustedOrigin,
|
|
790
840
|
parsePartialDate,
|
|
841
|
+
parseVisualMessage,
|
|
791
842
|
revalidateAllTags,
|
|
843
|
+
singletonTag,
|
|
792
844
|
verifyWebhookSignature
|
|
793
845
|
});
|
|
794
846
|
//# sourceMappingURL=index.js.map
|