@distinctagency/cms-client 1.26.0 → 1.27.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 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.26.0";
10
+ declare const CMS_CLIENT_VERSION = "1.27.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" | "group";
@@ -1004,4 +1004,81 @@ declare function isTrustedOrigin(origin: string, allowlist: readonly string[]):
1004
1004
  /** Narrow an unknown postMessage payload to a visual message, or null. */
1005
1005
  declare function parseVisualMessage(data: unknown): VisualMessage | null;
1006
1006
 
1007
- 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 };
1007
+ declare const CMS_MARKUP_SOURCE: "cms-markup";
1008
+ interface MarkupReady {
1009
+ source: typeof CMS_MARKUP_SOURCE;
1010
+ type: "markup-ready";
1011
+ docW: number;
1012
+ docH: number;
1013
+ }
1014
+ interface MarkupPin {
1015
+ source: typeof CMS_MARKUP_SOURCE;
1016
+ type: "markup-pin";
1017
+ xPct: number;
1018
+ yPct: number;
1019
+ relX: number;
1020
+ relY: number;
1021
+ selector: string | null;
1022
+ viewportW: number;
1023
+ docW: number;
1024
+ docH: number;
1025
+ }
1026
+ interface MarkupViewport {
1027
+ source: typeof CMS_MARKUP_SOURCE;
1028
+ type: "markup-viewport";
1029
+ scrollX: number;
1030
+ scrollY: number;
1031
+ docW: number;
1032
+ docH: number;
1033
+ viewportW: number;
1034
+ }
1035
+ interface MarkupLocated {
1036
+ source: typeof CMS_MARKUP_SOURCE;
1037
+ type: "markup-located";
1038
+ id: string;
1039
+ rect: {
1040
+ x: number;
1041
+ y: number;
1042
+ w: number;
1043
+ h: number;
1044
+ } | null;
1045
+ }
1046
+ interface MarkupInit {
1047
+ source: typeof CMS_MARKUP_SOURCE;
1048
+ type: "markup-init";
1049
+ }
1050
+ interface MarkupLocate {
1051
+ source: typeof CMS_MARKUP_SOURCE;
1052
+ type: "markup-locate";
1053
+ id: string;
1054
+ selector: string;
1055
+ }
1056
+ type MarkupOutbound = MarkupReady | MarkupPin | MarkupViewport | MarkupLocated;
1057
+ type MarkupInbound = MarkupInit | MarkupLocate;
1058
+ type MarkupMessage = MarkupOutbound | MarkupInbound;
1059
+ declare function parseMarkupMessage(data: unknown): MarkupMessage | null;
1060
+
1061
+ interface PinAnchor {
1062
+ xPct: number;
1063
+ yPct: number;
1064
+ relX: number;
1065
+ relY: number;
1066
+ }
1067
+ interface Rect {
1068
+ x: number;
1069
+ y: number;
1070
+ w: number;
1071
+ h: number;
1072
+ }
1073
+ /** Turn a click into a hybrid anchor. clickX/clickY are VIEWPORT coords. */
1074
+ declare function computeAnchor(clickX: number, clickY: number, el: Element, scrollX: number, scrollY: number, docW: number, docH: number): PinAnchor;
1075
+ /** Resolve a pin to absolute {left, top} in document coords. */
1076
+ declare function positionPin(pin: PinAnchor, located: Rect | null, layout: {
1077
+ docW: number;
1078
+ docH: number;
1079
+ }): {
1080
+ left: number;
1081
+ top: number;
1082
+ };
1083
+
1084
+ export { type BookingStatus, type BridgeInbound, type BridgeOutbound, CMS_CLIENT_VERSION, CMS_MARKUP_SOURCE, 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 MarkupInbound, type MarkupInit, type MarkupLocate, type MarkupLocated, type MarkupMessage, type MarkupOutbound, type MarkupPin, type MarkupReady, type MarkupViewport, type MediaFolder, type MediaItem, type Member, type MembershipTier, type OrderAddress, type OrderLineItem, type OrderStatus, type ParsedPartialDate, type PaymentStatus, type PickImageMessage, type PinAnchor, type Product, type ProductCategory, type ProductOption, type ProductQueryOptions, type ProductStatus, type ProductVariant, type Profile, type ReadyMessage, type Rect, 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, computeAnchor, createCmsClient, createEventsClient, createMapsClient, createShopClient, formatPartialDate, getEmbedHtml, getSrcSet, getTransformUrl, isTrustedOrigin, parseMarkupMessage, parsePartialDate, parseVisualMessage, positionPin, 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.26.0";
10
+ declare const CMS_CLIENT_VERSION = "1.27.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" | "group";
@@ -1004,4 +1004,81 @@ declare function isTrustedOrigin(origin: string, allowlist: readonly string[]):
1004
1004
  /** Narrow an unknown postMessage payload to a visual message, or null. */
1005
1005
  declare function parseVisualMessage(data: unknown): VisualMessage | null;
1006
1006
 
1007
- 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 };
1007
+ declare const CMS_MARKUP_SOURCE: "cms-markup";
1008
+ interface MarkupReady {
1009
+ source: typeof CMS_MARKUP_SOURCE;
1010
+ type: "markup-ready";
1011
+ docW: number;
1012
+ docH: number;
1013
+ }
1014
+ interface MarkupPin {
1015
+ source: typeof CMS_MARKUP_SOURCE;
1016
+ type: "markup-pin";
1017
+ xPct: number;
1018
+ yPct: number;
1019
+ relX: number;
1020
+ relY: number;
1021
+ selector: string | null;
1022
+ viewportW: number;
1023
+ docW: number;
1024
+ docH: number;
1025
+ }
1026
+ interface MarkupViewport {
1027
+ source: typeof CMS_MARKUP_SOURCE;
1028
+ type: "markup-viewport";
1029
+ scrollX: number;
1030
+ scrollY: number;
1031
+ docW: number;
1032
+ docH: number;
1033
+ viewportW: number;
1034
+ }
1035
+ interface MarkupLocated {
1036
+ source: typeof CMS_MARKUP_SOURCE;
1037
+ type: "markup-located";
1038
+ id: string;
1039
+ rect: {
1040
+ x: number;
1041
+ y: number;
1042
+ w: number;
1043
+ h: number;
1044
+ } | null;
1045
+ }
1046
+ interface MarkupInit {
1047
+ source: typeof CMS_MARKUP_SOURCE;
1048
+ type: "markup-init";
1049
+ }
1050
+ interface MarkupLocate {
1051
+ source: typeof CMS_MARKUP_SOURCE;
1052
+ type: "markup-locate";
1053
+ id: string;
1054
+ selector: string;
1055
+ }
1056
+ type MarkupOutbound = MarkupReady | MarkupPin | MarkupViewport | MarkupLocated;
1057
+ type MarkupInbound = MarkupInit | MarkupLocate;
1058
+ type MarkupMessage = MarkupOutbound | MarkupInbound;
1059
+ declare function parseMarkupMessage(data: unknown): MarkupMessage | null;
1060
+
1061
+ interface PinAnchor {
1062
+ xPct: number;
1063
+ yPct: number;
1064
+ relX: number;
1065
+ relY: number;
1066
+ }
1067
+ interface Rect {
1068
+ x: number;
1069
+ y: number;
1070
+ w: number;
1071
+ h: number;
1072
+ }
1073
+ /** Turn a click into a hybrid anchor. clickX/clickY are VIEWPORT coords. */
1074
+ declare function computeAnchor(clickX: number, clickY: number, el: Element, scrollX: number, scrollY: number, docW: number, docH: number): PinAnchor;
1075
+ /** Resolve a pin to absolute {left, top} in document coords. */
1076
+ declare function positionPin(pin: PinAnchor, located: Rect | null, layout: {
1077
+ docW: number;
1078
+ docH: number;
1079
+ }): {
1080
+ left: number;
1081
+ top: number;
1082
+ };
1083
+
1084
+ export { type BookingStatus, type BridgeInbound, type BridgeOutbound, CMS_CLIENT_VERSION, CMS_MARKUP_SOURCE, 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 MarkupInbound, type MarkupInit, type MarkupLocate, type MarkupLocated, type MarkupMessage, type MarkupOutbound, type MarkupPin, type MarkupReady, type MarkupViewport, type MediaFolder, type MediaItem, type Member, type MembershipTier, type OrderAddress, type OrderLineItem, type OrderStatus, type ParsedPartialDate, type PaymentStatus, type PickImageMessage, type PinAnchor, type Product, type ProductCategory, type ProductOption, type ProductQueryOptions, type ProductStatus, type ProductVariant, type Profile, type ReadyMessage, type Rect, 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, computeAnchor, createCmsClient, createEventsClient, createMapsClient, createShopClient, formatPartialDate, getEmbedHtml, getSrcSet, getTransformUrl, isTrustedOrigin, parseMarkupMessage, parsePartialDate, parseVisualMessage, positionPin, revalidateAllTags, singletonTag, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -21,12 +21,14 @@ 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_MARKUP_SOURCE: () => CMS_MARKUP_SOURCE,
24
25
  CMS_VISUAL_SOURCE: () => CMS_VISUAL_SOURCE,
25
26
  DEFAULT_TRUSTED_ORIGINS: () => DEFAULT_TRUSTED_ORIGINS,
26
27
  IMAGE_PRESETS: () => IMAGE_PRESETS,
27
28
  MAPBOX_CONFIG_TAG: () => MAPBOX_CONFIG_TAG,
28
29
  TRACKING_CONFIG_TAG: () => TRACKING_CONFIG_TAG,
29
30
  WEBHOOK_EVENTS: () => WEBHOOK_EVENTS,
31
+ computeAnchor: () => computeAnchor,
30
32
  createCmsClient: () => createCmsClient,
31
33
  createEventsClient: () => createEventsClient,
32
34
  createMapsClient: () => createMapsClient,
@@ -36,8 +38,10 @@ __export(src_exports, {
36
38
  getSrcSet: () => getSrcSet,
37
39
  getTransformUrl: () => getTransformUrl,
38
40
  isTrustedOrigin: () => isTrustedOrigin,
41
+ parseMarkupMessage: () => parseMarkupMessage,
39
42
  parsePartialDate: () => parsePartialDate,
40
43
  parseVisualMessage: () => parseVisualMessage,
44
+ positionPin: () => positionPin,
41
45
  revalidateAllTags: () => revalidateAllTags,
42
46
  singletonTag: () => singletonTag,
43
47
  verifyWebhookSignature: () => verifyWebhookSignature
@@ -45,7 +49,7 @@ __export(src_exports, {
45
49
  module.exports = __toCommonJS(src_exports);
46
50
 
47
51
  // src/version.ts
48
- var CMS_CLIENT_VERSION = "1.26.0";
52
+ var CMS_CLIENT_VERSION = "1.27.0";
49
53
 
50
54
  // src/queries.ts
51
55
  var import_supabase_js = require("@supabase/supabase-js");
@@ -819,15 +823,59 @@ function parseVisualMessage(data) {
819
823
  }
820
824
  return null;
821
825
  }
826
+
827
+ // src/markup/protocol.ts
828
+ var CMS_MARKUP_SOURCE = "cms-markup";
829
+ var VALID = /* @__PURE__ */ new Set([
830
+ "markup-ready",
831
+ "markup-pin",
832
+ "markup-viewport",
833
+ "markup-located",
834
+ "markup-init",
835
+ "markup-locate"
836
+ ]);
837
+ function parseMarkupMessage(data) {
838
+ if (typeof data === "object" && data !== null && data.source === CMS_MARKUP_SOURCE && typeof data.type === "string" && VALID.has(data.type)) {
839
+ return data;
840
+ }
841
+ return null;
842
+ }
843
+
844
+ // src/markup/anchor.ts
845
+ function docRect(el, scrollX, scrollY) {
846
+ const r = el.getBoundingClientRect();
847
+ return { x: r.left + scrollX, y: r.top + scrollY, w: r.width, h: r.height };
848
+ }
849
+ function computeAnchor(clickX, clickY, el, scrollX, scrollY, docW, docH) {
850
+ const docX = clickX + scrollX;
851
+ const docY = clickY + scrollY;
852
+ const rect = docRect(el, scrollX, scrollY);
853
+ const relX = rect.w > 0 ? (docX - rect.x) / rect.w : 0;
854
+ const relY = rect.h > 0 ? (docY - rect.y) / rect.h : 0;
855
+ return {
856
+ xPct: docW > 0 ? docX / docW : 0,
857
+ yPct: docH > 0 ? docY / docH : 0,
858
+ relX: Math.min(1, Math.max(0, relX)),
859
+ relY: Math.min(1, Math.max(0, relY))
860
+ };
861
+ }
862
+ function positionPin(pin, located, layout) {
863
+ if (located) {
864
+ return { left: located.x + pin.relX * located.w, top: located.y + pin.relY * located.h };
865
+ }
866
+ return { left: pin.xPct * layout.docW, top: pin.yPct * layout.docH };
867
+ }
822
868
  // Annotate the CommonJS export names for ESM import in node:
823
869
  0 && (module.exports = {
824
870
  CMS_CLIENT_VERSION,
871
+ CMS_MARKUP_SOURCE,
825
872
  CMS_VISUAL_SOURCE,
826
873
  DEFAULT_TRUSTED_ORIGINS,
827
874
  IMAGE_PRESETS,
828
875
  MAPBOX_CONFIG_TAG,
829
876
  TRACKING_CONFIG_TAG,
830
877
  WEBHOOK_EVENTS,
878
+ computeAnchor,
831
879
  createCmsClient,
832
880
  createEventsClient,
833
881
  createMapsClient,
@@ -837,8 +885,10 @@ function parseVisualMessage(data) {
837
885
  getSrcSet,
838
886
  getTransformUrl,
839
887
  isTrustedOrigin,
888
+ parseMarkupMessage,
840
889
  parsePartialDate,
841
890
  parseVisualMessage,
891
+ positionPin,
842
892
  revalidateAllTags,
843
893
  singletonTag,
844
894
  verifyWebhookSignature