@replohq/canopy-sdk 0.5.0 → 0.7.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.
Files changed (64) hide show
  1. package/_vendor/replo-utils/lib/geometry.d.ts +18 -0
  2. package/_vendor/replo-utils/lib/geometry.mjs +9 -0
  3. package/_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs +1 -1
  4. package/_vendor/schemas/errors.d.ts +1 -1
  5. package/_vendor/schemas/errors.mjs +6 -2
  6. package/_vendor/schemas/generated/consent.d.ts +7 -2
  7. package/_vendor/schemas/generated/selectMode.d.ts +8 -2
  8. package/_vendor/schemas/objectType.mjs +1 -1
  9. package/_vendor/schemas/registry.d.ts +179 -9
  10. package/_vendor/schemas/selectMode.d.ts +41 -2
  11. package/_vendor/schemas/selectMode.mjs +12 -3
  12. package/analytics/analytics-provider.d.ts +4 -1
  13. package/analytics/analytics-provider.js +13 -3
  14. package/analytics/analytics-provider.js.map +2 -2
  15. package/analytics/get-analytics-sinks.d.ts +3 -1
  16. package/analytics/get-analytics-sinks.js +8 -2
  17. package/analytics/get-analytics-sinks.js.map +2 -2
  18. package/analytics/sinks/ga4-sink.js +10 -2
  19. package/analytics/sinks/ga4-sink.js.map +2 -2
  20. package/analytics/sinks/meta-sink.d.ts +1 -1
  21. package/analytics/sinks/meta-sink.js +16 -4
  22. package/analytics/sinks/meta-sink.js.map +2 -2
  23. package/analytics/utils/shopify-funnel-gate.d.ts +8 -0
  24. package/analytics/utils/shopify-funnel-gate.js +22 -0
  25. package/analytics/utils/shopify-funnel-gate.js.map +7 -0
  26. package/{chunk-77XUQJHY.mjs → chunk-ZBNFOPGP.mjs} +83 -1
  27. package/consent/replo-scripts.js +11 -2
  28. package/consent/replo-scripts.js.map +2 -2
  29. package/consent/script-snippets.d.ts +11 -6
  30. package/consent/script-snippets.js +0 -12
  31. package/consent/script-snippets.js.map +2 -2
  32. package/consent/types.d.ts +7 -2
  33. package/editor/ClientErrorBoundary.d.ts +6 -3
  34. package/editor/ClientErrorBoundary.js +18 -5
  35. package/editor/ClientErrorBoundary.js.map +2 -2
  36. package/editor/NextErrorReporter.d.ts +1 -0
  37. package/editor/NextErrorReporter.js +63 -0
  38. package/editor/NextErrorReporter.js.map +7 -0
  39. package/editor/select-mode/hooks/useSelectModeController.js +2 -1
  40. package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
  41. package/editor/select-mode/hooks/useSelectionInteractions.d.ts +3 -3
  42. package/editor/select-mode/hooks/useSelectionInteractions.js +54 -16
  43. package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
  44. package/editor/select-mode/interactions/selectionGeometry.d.ts +37 -12
  45. package/editor/select-mode/interactions/selectionGeometry.js +52 -24
  46. package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
  47. package/editor/select-mode/selectionFrame.d.ts +26 -7
  48. package/editor/select-mode/selectionFrame.js +58 -34
  49. package/editor/select-mode/selectionFrame.js.map +2 -2
  50. package/editor/select-mode/symbolicate.js +32 -1
  51. package/editor/select-mode/symbolicate.js.map +2 -2
  52. package/next/config.d.ts +4 -0
  53. package/next/config.js +86 -0
  54. package/next/config.js.map +7 -0
  55. package/next/image-loader.d.ts +2 -0
  56. package/next/image-loader.js +16 -0
  57. package/next/image-loader.js.map +7 -0
  58. package/next/open-next.d.ts +2 -0
  59. package/next/open-next.js +24 -0
  60. package/next/open-next.js.map +7 -0
  61. package/package.json +1 -1
  62. package/providers/replo-provider.d.ts +1 -1
  63. package/providers/replo-provider.js +20 -9
  64. package/providers/replo-provider.js.map +2 -2
@@ -0,0 +1,18 @@
1
+ export type GeometryRect = {
2
+ left: number;
3
+ right: number;
4
+ top: number;
5
+ bottom: number;
6
+ };
7
+ /**
8
+ * Whether two axis-aligned rects overlap. `tolerance` expands the test
9
+ * rect on every side, so rects that fall a few pixels short of touching
10
+ * (sub-pixel rendering, borders) still count as intersecting.
11
+ */
12
+ export declare function isIntersecting(targetRect: GeometryRect, destinationRect: GeometryRect, { tolerance }?: {
13
+ tolerance?: number;
14
+ }): boolean;
15
+ /**
16
+ * Whether `targetRect` wholly contains `testRect`.
17
+ */
18
+ export declare function isRectEnclosing(targetRect: GeometryRect, testRect: GeometryRect): boolean;
@@ -0,0 +1,9 @@
1
+ // ../replo-utils/lib/geometry.ts
2
+ function isIntersecting(targetRect, destinationRect, { tolerance = 0 } = {}) {
3
+ return targetRect.left <= destinationRect.right + tolerance && targetRect.right >= destinationRect.left - tolerance && targetRect.top <= destinationRect.bottom + tolerance && targetRect.bottom >= destinationRect.top - tolerance;
4
+ }
5
+ function isRectEnclosing(targetRect, testRect) {
6
+ return targetRect.left <= testRect.left && targetRect.right >= testRect.right && targetRect.top <= testRect.top && targetRect.bottom >= testRect.bottom;
7
+ }
8
+
9
+ export { isIntersecting, isRectEnclosing };
@@ -1,4 +1,4 @@
1
- import { priceSchema, metafieldSchema, imageSchema, selectedOptionSchema, mediaSchema, productOptionSchema, productSchema } from '../../../../../chunk-77XUQJHY.mjs';
1
+ import { priceSchema, metafieldSchema, imageSchema, selectedOptionSchema, mediaSchema, productOptionSchema, productSchema } from '../../../../../chunk-ZBNFOPGP.mjs';
2
2
  import { sellingPlanGroupSchema } from '../../../../../chunk-4TZVNC3W.mjs';
3
3
  import { z } from 'zod';
4
4
 
@@ -66,7 +66,7 @@ export declare class ReploHTTPError extends ReploError {
66
66
  userFacingDetails: ErrorUserFacingDetails;
67
67
  statusCode: number;
68
68
  details?: object;
69
- constructor(config: {
69
+ constructor(config: ReploErrorConfig & {
70
70
  statusCode: number;
71
71
  userFacingDetails: ErrorUserFacingDetails;
72
72
  details?: object;
@@ -654,8 +654,12 @@ var ReploHTTPError = class extends ReploError {
654
654
  details;
655
655
  constructor(config) {
656
656
  super({
657
- message: config.userFacingDetails.message,
658
- additionalData: { statusCode: config.statusCode }
657
+ ...config,
658
+ message: config.message ?? config.userFacingDetails.message,
659
+ additionalData: {
660
+ ...config.additionalData,
661
+ statusCode: config.statusCode
662
+ }
659
663
  });
660
664
  this.statusCode = config.statusCode;
661
665
  this.userFacingDetails = config.userFacingDetails;
@@ -1,4 +1,4 @@
1
- export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Triplewhale" | "Segment" | "custom";
1
+ export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "snippet" | "custom";
2
2
  export type ConsentCategory = "necessary" | "analytics" | "marketing" | "preferences" | "sale_of_data";
3
3
  export type ConsentMode = "off" | "simple" | "per-category";
4
4
  export type ScriptTagDescriptor = {
@@ -12,9 +12,14 @@ export type ScriptTagDescriptor = {
12
12
  body: string;
13
13
  };
14
14
  export type ReploScriptEntry = {
15
- type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Triplewhale" | "Segment";
15
+ type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment";
16
16
  identifier: string;
17
17
  requiredConsent?: ConsentCategory[];
18
+ } | {
19
+ type: "snippet";
20
+ id: string;
21
+ body: string;
22
+ requiredConsent: ConsentCategory[];
18
23
  } | {
19
24
  type: "custom";
20
25
  id: string;
@@ -25,6 +25,10 @@ export type SelectModeBoundingRect = {
25
25
  width: number;
26
26
  height: number;
27
27
  };
28
+ export type SelectModeSelectionRect = {
29
+ id: string;
30
+ rect: SelectModeBoundingRect;
31
+ };
28
32
  export type SelectedElement = {
29
33
  kind: "react-element";
30
34
  selector: string;
@@ -61,7 +65,8 @@ export type SelectModeSelection = {
61
65
  items: SelectableData[];
62
66
  } | {
63
67
  type: "drag";
64
- rect: SelectModeBoundingRect;
68
+ dragRect: SelectModeBoundingRect;
69
+ selectionRects: SelectModeSelectionRect[];
65
70
  };
66
71
  export type SelectModeParentMessage = {
67
72
  type: "replo:select:setDisplayMode";
@@ -87,7 +92,8 @@ export type SelectModeIframeMessage = {
87
92
  rect: SelectModeBoundingRect;
88
93
  } | {
89
94
  type: "replo:select:dragRectUpdated";
90
- rect: SelectModeBoundingRect | null;
95
+ dragRect: SelectModeBoundingRect | null;
96
+ selectionRects: SelectModeSelectionRect[];
91
97
  } | {
92
98
  type: "replo:select:areaSelected";
93
99
  rect: SelectModeBoundingRect;
@@ -1,2 +1,2 @@
1
- export { assetSchema, collectionSchema, customerIoBroadcastSchema, customerIoCampaignSchema, customerIoSegmentSchema, externalVideoSchema, getObjectTypeDefinition, imageSchema, integrationSchema, intelligemsExperienceSchema, levantaAffiliateLinkSchema, levantaProductSchema, looxReviewSchema, mediaImageSchema, mediaSchema, metafieldSchema, okendoReviewSchema, optionValueSchema, optionValueSwatchSchema, opusClipSchema, opusCollectionSchema, opusProjectSchema, pageSchema, planSchema, previewImageSchema, priceSchema, productOptionSchema, productSchema, registryItemSchema, segmentSourceSchema, selectedOptionSchema, transformReploProductToCanonical, variantSchema, videoSchema, videoSourceSchema, vwoCampaignSchema } from '../../chunk-77XUQJHY.mjs';
1
+ export { assetSchema, collectionSchema, customerIoBroadcastSchema, customerIoCampaignSchema, customerIoSegmentSchema, externalVideoSchema, getObjectTypeDefinition, imageSchema, integrationSchema, intelligemsExperienceSchema, levantaAffiliateLinkSchema, levantaProductSchema, looxReviewSchema, mediaImageSchema, mediaSchema, metafieldSchema, okendoReviewSchema, optionValueSchema, optionValueSwatchSchema, opusClipSchema, opusCollectionSchema, opusProjectSchema, pageSchema, planSchema, previewImageSchema, priceSchema, productOptionSchema, productSchema, registryItemSchema, segmentSourceSchema, selectedOptionSchema, transformReploProductToCanonical, variantSchema, videoSchema, videoSourceSchema, vwoCampaignSchema } from '../../chunk-ZBNFOPGP.mjs';
2
2
  import '../../chunk-4TZVNC3W.mjs';
@@ -1,12 +1,8 @@
1
1
  import { z } from "zod";
2
2
  /**
3
- * Schemas for the registry Worker — the persistent
4
- * registry of project-authored items (templates, skills, etc.) backed by
5
- * Postgres + R2.
6
- *
7
- * NOTE: Not to be confused with `schemas/registryItem.ts`, which is the
8
- * legacy editor-side catalog shape used by the agent-browser/home tabs and
9
- * is unrelated to the registry Worker.
3
+ * Schemas for the Bedrock registry — the persistent registry of
4
+ * project-authored items (templates, skills, etc.) served by
5
+ * `apps/bedrock-api` and backed by Postgres + R2.
10
6
  *
11
7
  * Per the "PG = searchable + listing display only" rule:
12
8
  * - Top-level row columns hold identity/search/preview fields.
@@ -14,8 +10,8 @@ import { z } from "zod";
14
10
  * aren't covered by standard columns. Types with no metadata store `null`.
15
11
  * - Detailed content (full file trees, npm dependencies) lives in the R2
16
12
  * `.registry.json` doc, not the PG row.
17
- * - Preview imagery is referenced by external URL via `previewUrls` — the
18
- * registry Worker does not host preview blobs anymore.
13
+ * - Preview imagery is referenced by external URL via `previewUrls`; the
14
+ * registry does not host preview blobs.
19
15
  */
20
16
  export declare const registryItemTypeSchema: z.ZodEnum<{
21
17
  product: "product";
@@ -26,6 +22,13 @@ export declare const registryItemTypeSchema: z.ZodEnum<{
26
22
  skill: "skill";
27
23
  branding: "branding";
28
24
  }>;
25
+ export declare const registryItemVisibilitySchema: z.ZodEnum<{
26
+ public: "public";
27
+ unlisted: "unlisted";
28
+ }>;
29
+ export declare const registrySlugSchema: z.ZodString;
30
+ export declare const registryItemIdSchema: z.ZodString;
31
+ export declare const registryContentFilesSchema: z.ZodRecord<z.ZodString, z.ZodString>;
29
32
  export declare const registryItemSourceIdentitySchema: z.ZodObject<{
30
33
  sourceType: z.ZodString;
31
34
  sourceKey: z.ZodString;
@@ -318,6 +321,74 @@ export declare const registryItemDetailSchema: z.ZodObject<{
318
321
  updatedAt: z.ZodString;
319
322
  previewHtml: z.ZodNullable<z.ZodString>;
320
323
  }, z.core.$strip>;
324
+ export declare const registryItemPreviewResultSchema: z.ZodObject<{
325
+ item: z.ZodObject<{
326
+ id: z.ZodString;
327
+ slug: z.ZodString;
328
+ name: z.ZodString;
329
+ type: z.ZodEnum<{
330
+ product: "product";
331
+ plan: "plan";
332
+ site: "site";
333
+ page: "page";
334
+ section: "section";
335
+ skill: "skill";
336
+ branding: "branding";
337
+ }>;
338
+ metadata: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
339
+ brandName: z.ZodOptional<z.ZodString>;
340
+ brandDomain: z.ZodOptional<z.ZodString>;
341
+ logoUrl: z.ZodOptional<z.ZodString>;
342
+ }, z.core.$strict>, z.ZodObject<{
343
+ brandName: z.ZodOptional<z.ZodString>;
344
+ brandDomain: z.ZodOptional<z.ZodString>;
345
+ logoUrl: z.ZodOptional<z.ZodString>;
346
+ }, z.core.$strict>, z.ZodObject<{
347
+ brandName: z.ZodOptional<z.ZodString>;
348
+ brandDomain: z.ZodOptional<z.ZodString>;
349
+ logoUrl: z.ZodOptional<z.ZodString>;
350
+ }, z.core.$strict>, z.ZodObject<{
351
+ command: z.ZodOptional<z.ZodString>;
352
+ tagline: z.ZodOptional<z.ZodString>;
353
+ }, z.core.$strict>, z.ZodObject<{
354
+ palette: z.ZodOptional<z.ZodArray<z.ZodString>>;
355
+ logoUrl: z.ZodOptional<z.ZodString>;
356
+ faviconUrl: z.ZodOptional<z.ZodString>;
357
+ tagline: z.ZodOptional<z.ZodString>;
358
+ }, z.core.$strict>, z.ZodObject<{
359
+ provider: z.ZodString;
360
+ providerDisplayName: z.ZodString;
361
+ providerProductId: z.ZodString;
362
+ productType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
363
+ productTypeName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
364
+ categoryIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
365
+ defaultVariantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
366
+ capabilities: z.ZodObject<{
367
+ mockupGeneration: z.ZodBoolean;
368
+ fileUpload: z.ZodBoolean;
369
+ productCreation: z.ZodBoolean;
370
+ orderFulfillment: z.ZodBoolean;
371
+ variantEditing: z.ZodBoolean;
372
+ }, z.core.$strict>;
373
+ techniques: z.ZodDefault<z.ZodArray<z.ZodString>>;
374
+ colors: z.ZodDefault<z.ZodArray<z.ZodString>>;
375
+ sizes: z.ZodDefault<z.ZodArray<z.ZodString>>;
376
+ }, z.core.$strict>]>>;
377
+ sourceType: z.ZodNullable<z.ZodString>;
378
+ sourceKey: z.ZodNullable<z.ZodString>;
379
+ shortLink: z.ZodNullable<z.ZodString>;
380
+ description: z.ZodNullable<z.ZodString>;
381
+ visibility: z.ZodString;
382
+ tags: z.ZodArray<z.ZodString>;
383
+ category: z.ZodNullable<z.ZodString>;
384
+ previewUrls: z.ZodArray<z.ZodString>;
385
+ createdAt: z.ZodString;
386
+ updatedAt: z.ZodString;
387
+ previewHtml: z.ZodNullable<z.ZodString>;
388
+ projectId: z.ZodNull;
389
+ createdBy: z.ZodNull;
390
+ }, z.core.$strip>;
391
+ }, z.core.$strip>;
321
392
  export declare const registryItemContentSchema: z.ZodObject<{
322
393
  meta: z.ZodObject<{
323
394
  id: z.ZodString;
@@ -337,3 +408,102 @@ export declare const registryItemContentSchema: z.ZodObject<{
337
408
  files: z.ZodRecord<z.ZodString, z.ZodString>;
338
409
  dependencies: z.ZodArray<z.ZodString>;
339
410
  }, z.core.$strip>;
411
+ export declare const registryItemDocumentSchema: z.ZodObject<{
412
+ id: z.ZodString;
413
+ slug: z.ZodString;
414
+ name: z.ZodString;
415
+ type: z.ZodEnum<{
416
+ product: "product";
417
+ plan: "plan";
418
+ site: "site";
419
+ page: "page";
420
+ section: "section";
421
+ skill: "skill";
422
+ branding: "branding";
423
+ }>;
424
+ projectId: z.ZodNullable<z.ZodString>;
425
+ createdBy: z.ZodNullable<z.ZodString>;
426
+ description: z.ZodNullable<z.ZodString>;
427
+ visibility: z.ZodString;
428
+ tags: z.ZodArray<z.ZodString>;
429
+ category: z.ZodNullable<z.ZodString>;
430
+ sourceType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
431
+ sourceKey: z.ZodDefault<z.ZodNullable<z.ZodString>>;
432
+ shortLink: z.ZodDefault<z.ZodNullable<z.ZodString>>;
433
+ previewUrls: z.ZodArray<z.ZodString>;
434
+ previewHtml: z.ZodNullable<z.ZodString>;
435
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
436
+ files: z.ZodRecord<z.ZodString, z.ZodString>;
437
+ dependencies: z.ZodArray<z.ZodString>;
438
+ embeddingText: z.ZodString;
439
+ embedding: z.ZodArray<z.ZodNumber>;
440
+ createdAt: z.ZodString;
441
+ updatedAt: z.ZodString;
442
+ }, z.core.$strip>;
443
+ export declare const registryCreateItemInputSchema: z.ZodObject<{
444
+ item: z.ZodObject<{
445
+ id: z.ZodString;
446
+ slug: z.ZodString;
447
+ name: z.ZodString;
448
+ type: z.ZodEnum<{
449
+ product: "product";
450
+ plan: "plan";
451
+ site: "site";
452
+ page: "page";
453
+ section: "section";
454
+ skill: "skill";
455
+ branding: "branding";
456
+ }>;
457
+ projectId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
458
+ createdBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
459
+ sourceType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
460
+ sourceKey: z.ZodDefault<z.ZodNullable<z.ZodString>>;
461
+ description: z.ZodDefault<z.ZodNullable<z.ZodString>>;
462
+ metadata: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
463
+ visibility: z.ZodDefault<z.ZodEnum<{
464
+ public: "public";
465
+ unlisted: "unlisted";
466
+ }>>;
467
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
468
+ category: z.ZodDefault<z.ZodNullable<z.ZodString>>;
469
+ previewUrls: z.ZodDefault<z.ZodArray<z.ZodString>>;
470
+ previewHtml: z.ZodDefault<z.ZodNullable<z.ZodString>>;
471
+ files: z.ZodRecord<z.ZodString, z.ZodString>;
472
+ dependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
473
+ }, z.core.$strip>;
474
+ }, z.core.$strip>;
475
+ export declare const registryCreateItemOutputSchema: z.ZodObject<{
476
+ created: z.ZodObject<{
477
+ id: z.ZodString;
478
+ type: z.ZodEnum<{
479
+ product: "product";
480
+ plan: "plan";
481
+ site: "site";
482
+ page: "page";
483
+ section: "section";
484
+ skill: "skill";
485
+ branding: "branding";
486
+ }>;
487
+ slug: z.ZodString;
488
+ sourceType: z.ZodNullable<z.ZodString>;
489
+ sourceKey: z.ZodNullable<z.ZodString>;
490
+ url: z.ZodString;
491
+ shareUrl: z.ZodNullable<z.ZodString>;
492
+ }, z.core.$strip>;
493
+ }, z.core.$strip>;
494
+ export declare const registryCatalogUpsertInputSchema: z.ZodObject<{
495
+ name: z.ZodString;
496
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
497
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
498
+ visibility: z.ZodOptional<z.ZodEnum<{
499
+ public: "public";
500
+ unlisted: "unlisted";
501
+ }>>;
502
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
503
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
504
+ previewUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
505
+ previewHtml: z.ZodOptional<z.ZodNullable<z.ZodString>>;
506
+ files: z.ZodRecord<z.ZodString, z.ZodString>;
507
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
508
+ }, z.core.$strip>;
509
+ export type RegistryCatalogUpsertInput = z.infer<typeof registryCatalogUpsertInputSchema>;
@@ -30,6 +30,19 @@ export declare const selectModeBoundingRectSchema: z.ZodObject<{
30
30
  width: z.ZodNumber;
31
31
  height: z.ZodNumber;
32
32
  }, z.core.$strip>;
33
+ export declare const selectModeSelectionRectSchema: z.ZodObject<{
34
+ id: z.ZodString;
35
+ rect: z.ZodObject<{
36
+ x: z.ZodNumber;
37
+ y: z.ZodNumber;
38
+ left: z.ZodNumber;
39
+ top: z.ZodNumber;
40
+ right: z.ZodNumber;
41
+ bottom: z.ZodNumber;
42
+ width: z.ZodNumber;
43
+ height: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ }, z.core.$strip>;
33
46
  export type RectOffset = {
34
47
  left: number;
35
48
  top: number;
@@ -316,7 +329,7 @@ export declare const selectModeSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodOb
316
329
  }, z.core.$strip>], "kind">>;
317
330
  }, z.core.$strip>, z.ZodObject<{
318
331
  type: z.ZodLiteral<"drag">;
319
- rect: z.ZodObject<{
332
+ dragRect: z.ZodObject<{
320
333
  x: z.ZodNumber;
321
334
  y: z.ZodNumber;
322
335
  left: z.ZodNumber;
@@ -326,6 +339,19 @@ export declare const selectModeSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodOb
326
339
  width: z.ZodNumber;
327
340
  height: z.ZodNumber;
328
341
  }, z.core.$strip>;
342
+ selectionRects: z.ZodArray<z.ZodObject<{
343
+ id: z.ZodString;
344
+ rect: z.ZodObject<{
345
+ x: z.ZodNumber;
346
+ y: z.ZodNumber;
347
+ left: z.ZodNumber;
348
+ top: z.ZodNumber;
349
+ right: z.ZodNumber;
350
+ bottom: z.ZodNumber;
351
+ width: z.ZodNumber;
352
+ height: z.ZodNumber;
353
+ }, z.core.$strip>;
354
+ }, z.core.$strip>>;
329
355
  }, z.core.$strip>], "type">;
330
356
  export declare const selectModeParentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
331
357
  type: z.ZodLiteral<"replo:select:setDisplayMode">;
@@ -435,7 +461,7 @@ export declare const selectModeIframeMessageSchema: z.ZodDiscriminatedUnion<[z.Z
435
461
  }, z.core.$strip>;
436
462
  }, z.core.$strip>, z.ZodObject<{
437
463
  type: z.ZodLiteral<"replo:select:dragRectUpdated">;
438
- rect: z.ZodNullable<z.ZodObject<{
464
+ dragRect: z.ZodNullable<z.ZodObject<{
439
465
  x: z.ZodNumber;
440
466
  y: z.ZodNumber;
441
467
  left: z.ZodNumber;
@@ -445,6 +471,19 @@ export declare const selectModeIframeMessageSchema: z.ZodDiscriminatedUnion<[z.Z
445
471
  width: z.ZodNumber;
446
472
  height: z.ZodNumber;
447
473
  }, z.core.$strip>>;
474
+ selectionRects: z.ZodArray<z.ZodObject<{
475
+ id: z.ZodString;
476
+ rect: z.ZodObject<{
477
+ x: z.ZodNumber;
478
+ y: z.ZodNumber;
479
+ left: z.ZodNumber;
480
+ top: z.ZodNumber;
481
+ right: z.ZodNumber;
482
+ bottom: z.ZodNumber;
483
+ width: z.ZodNumber;
484
+ height: z.ZodNumber;
485
+ }, z.core.$strip>;
486
+ }, z.core.$strip>>;
448
487
  }, z.core.$strip>, z.ZodObject<{
449
488
  type: z.ZodLiteral<"replo:select:areaSelected">;
450
489
  rect: z.ZodObject<{
@@ -36,6 +36,10 @@ var selectModeBoundingRectSchema = z.object({
36
36
  width: z.number(),
37
37
  height: z.number()
38
38
  }).describe("SelectModeBoundingRect");
39
+ var selectModeSelectionRectSchema = z.object({
40
+ id: z.string(),
41
+ rect: selectModeBoundingRectSchema
42
+ }).describe("SelectModeSelectionRect");
39
43
  function transformRect({
40
44
  rect,
41
45
  offset
@@ -134,7 +138,11 @@ var selectModeSelectionSchema = z.discriminatedUnion("type", [
134
138
  }),
135
139
  z.object({
136
140
  type: z.literal("drag"),
137
- rect: selectModeBoundingRectSchema
141
+ dragRect: selectModeBoundingRectSchema,
142
+ // Bounding boxes of the selectables the drag currently intersects,
143
+ // rendered as lighter highlights so the user can see what the drag
144
+ // will capture before they release.
145
+ selectionRects: z.array(selectModeSelectionRectSchema)
138
146
  })
139
147
  ]).describe("SelectModeSelection");
140
148
  var selectModeParentMessageSchema = z.discriminatedUnion("type", [
@@ -175,7 +183,8 @@ var selectModeIframeMessageSchema = z.discriminatedUnion("type", [
175
183
  }),
176
184
  z.object({
177
185
  type: z.literal("replo:select:dragRectUpdated"),
178
- rect: selectModeBoundingRectSchema.nullable()
186
+ dragRect: selectModeBoundingRectSchema.nullable(),
187
+ selectionRects: z.array(selectModeSelectionRectSchema)
179
188
  }),
180
189
  z.object({
181
190
  type: z.literal("replo:select:areaSelected"),
@@ -184,4 +193,4 @@ var selectModeIframeMessageSchema = z.discriminatedUnion("type", [
184
193
  })
185
194
  ]).describe("SelectModeIframeMessage");
186
195
 
187
- export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeIframeMessageSchema, selectModeParentMessageSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeTextMetricsSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData };
196
+ export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeIframeMessageSchema, selectModeParentMessageSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeTextMetricsSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData };
@@ -1,6 +1,9 @@
1
1
  import type React from "react";
2
+ import type { CheckoutProvider } from "../lib/integration-utils";
2
3
  import type { AnalyticsSink } from "./analytics-sink";
3
- export declare function AnalyticsProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
4
+ export declare function AnalyticsProvider({ children, checkoutProvider, }: React.PropsWithChildren<{
5
+ checkoutProvider?: CheckoutProvider;
6
+ }>): import("react/jsx-runtime").JSX.Element;
4
7
  /**
5
8
  * Returns the AnalyticsSink from the nearest AnalyticsProvider.
6
9
  * Throws if used outside of an AnalyticsProvider.
@@ -43,7 +43,10 @@ function combineSinks(sinks) {
43
43
  };
44
44
  }
45
45
  const AnalyticsContext = createContext(null);
46
- function AnalyticsProvider({ children }) {
46
+ function AnalyticsProvider({
47
+ children,
48
+ checkoutProvider
49
+ }) {
47
50
  const consent = useConsent();
48
51
  const registeredScripts = useRegisteredScripts();
49
52
  const analytics = useMemo(() => {
@@ -54,10 +57,17 @@ function AnalyticsProvider({ children }) {
54
57
  categories: consent.categories,
55
58
  decidedAt: consent.decidedAt
56
59
  },
57
- registeredScripts
60
+ registeredScripts,
61
+ checkoutProvider
58
62
  })
59
63
  );
60
- }, [consent.mode, consent.categories, consent.decidedAt, registeredScripts]);
64
+ }, [
65
+ consent.mode,
66
+ consent.categories,
67
+ consent.decidedAt,
68
+ registeredScripts,
69
+ checkoutProvider
70
+ ]);
61
71
  const analyticsRef = useRef(analytics);
62
72
  analyticsRef.current = analytics;
63
73
  const navigationTracker = useRef(null);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../analytics/analytics-provider.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport type React from \"react\";\nimport type { AnalyticsSink } from \"./analytics-sink\";\nimport type { PageMetadata } from \"./utils/navigation-tracker\";\n\nimport { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\n\nimport { useConsent } from \"../consent/consent-store\";\nimport { useRegisteredScripts } from \"../consent/script-registration-store\";\nimport { getAnalyticsSinks } from \"./get-analytics-sinks\";\nimport { NavigationTracker } from \"./utils/navigation-tracker\";\n\nfunction combineSinks(sinks: AnalyticsSink[]): AnalyticsSink {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n const broadcast = async (method: keyof AnalyticsSink, ...args: any[]) => {\n if (typeof window !== \"undefined\") {\n console.debug(\n \"[analytics] broadcast\",\n method,\n \"to\",\n sinks.length,\n \"sinks\",\n { args },\n );\n }\n\n await Promise.all(\n sinks.map(async (sink) => {\n try {\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n const sinkMethod = sink[method] as (...args: any[]) => Promise<void>;\n await sinkMethod.apply(sink, args);\n } catch {\n if (typeof window !== \"undefined\") {\n console.warn(\"[analytics] sink error\", { method, sink });\n }\n }\n }),\n );\n };\n\n return {\n pageView: (...args) => broadcast(\"pageView\", ...args),\n purchase: (...args) => broadcast(\"purchase\", ...args),\n click: (...args) => broadcast(\"click\", ...args),\n productViewed: (...args) => broadcast(\"productViewed\", ...args),\n addToCart: (...args) => broadcast(\"addToCart\", ...args),\n removeFromCart: (...args) => broadcast(\"removeFromCart\", ...args),\n viewCart: (...args) => broadcast(\"viewCart\", ...args),\n startCheckout: (...args) => broadcast(\"startCheckout\", ...args),\n viewCollection: (...args) => broadcast(\"viewCollection\", ...args),\n };\n}\n\ninterface AnalyticsContextType {\n analytics: AnalyticsSink | null;\n}\n\nconst AnalyticsContext = createContext<AnalyticsContextType | null>(null);\n\nexport function AnalyticsProvider({ children }: React.PropsWithChildren) {\n const consent = useConsent();\n const registeredScripts = useRegisteredScripts();\n\n // Sinks are derived from consent + which managed scripts are on the page, so\n // the set rebuilds whenever the visitor changes consent or a script mounts.\n const analytics = useMemo(() => {\n return combineSinks(\n getAnalyticsSinks({\n consent: {\n mode: consent.mode,\n categories: consent.categories,\n decidedAt: consent.decidedAt,\n },\n registeredScripts,\n }),\n );\n }, [consent.mode, consent.categories, consent.decidedAt, registeredScripts]);\n\n // The navigation tracker is set up once, but always dispatches to the latest\n // combined sink via a ref so consent/registration changes take effect.\n const analyticsRef = useRef(analytics);\n analyticsRef.current = analytics;\n const navigationTracker = useRef<NavigationTracker | null>(null);\n\n // eslint-disable-next-line replo/no-use-effect -- one-time SPA navigation tracking setup; dispatches through analyticsRef to stay current\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n navigationTracker.current = new NavigationTracker(\n (metadata: PageMetadata) => {\n void analyticsRef.current.pageView(metadata);\n },\n );\n navigationTracker.current.init();\n\n return () => {\n navigationTracker.current?.cleanup();\n };\n }, []);\n\n return (\n <AnalyticsContext.Provider value={{ analytics }}>\n {children}\n </AnalyticsContext.Provider>\n );\n}\n\nclass AnalyticsContextError extends Error {\n constructor({ message }: { message: string }) {\n super(message);\n }\n}\n\n/**\n * Returns the AnalyticsSink from the nearest AnalyticsProvider.\n * Throws if used outside of an AnalyticsProvider.\n */\nexport function useAnalytics(): AnalyticsSink | null {\n const context = useContext(AnalyticsContext);\n if (!context) {\n throw new AnalyticsContextError({\n message: \"useAnalytics must be used within <AnalyticsProvider>\",\n });\n }\n return context.analytics;\n}\n\n/**\n * Returns the AnalyticsSink if an AnalyticsProvider is present, or null otherwise.\n * Does not throw -- safe to use in components that may render with or without analytics.\n */\nexport function useAnalyticsOptional(): AnalyticsSink | null {\n const context = useContext(AnalyticsContext);\n return context?.analytics ?? null;\n}\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["\"use client\";\n\nimport type React from \"react\";\nimport type { CheckoutProvider } from \"../lib/integration-utils\";\nimport type { AnalyticsSink } from \"./analytics-sink\";\nimport type { PageMetadata } from \"./utils/navigation-tracker\";\n\nimport { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\n\nimport { useConsent } from \"../consent/consent-store\";\nimport { useRegisteredScripts } from \"../consent/script-registration-store\";\nimport { getAnalyticsSinks } from \"./get-analytics-sinks\";\nimport { NavigationTracker } from \"./utils/navigation-tracker\";\n\nfunction combineSinks(sinks: AnalyticsSink[]): AnalyticsSink {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n const broadcast = async (method: keyof AnalyticsSink, ...args: any[]) => {\n if (typeof window !== \"undefined\") {\n console.debug(\n \"[analytics] broadcast\",\n method,\n \"to\",\n sinks.length,\n \"sinks\",\n { args },\n );\n }\n\n await Promise.all(\n sinks.map(async (sink) => {\n try {\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n const sinkMethod = sink[method] as (...args: any[]) => Promise<void>;\n await sinkMethod.apply(sink, args);\n } catch {\n if (typeof window !== \"undefined\") {\n console.warn(\"[analytics] sink error\", { method, sink });\n }\n }\n }),\n );\n };\n\n return {\n pageView: (...args) => broadcast(\"pageView\", ...args),\n purchase: (...args) => broadcast(\"purchase\", ...args),\n click: (...args) => broadcast(\"click\", ...args),\n productViewed: (...args) => broadcast(\"productViewed\", ...args),\n addToCart: (...args) => broadcast(\"addToCart\", ...args),\n removeFromCart: (...args) => broadcast(\"removeFromCart\", ...args),\n viewCart: (...args) => broadcast(\"viewCart\", ...args),\n startCheckout: (...args) => broadcast(\"startCheckout\", ...args),\n viewCollection: (...args) => broadcast(\"viewCollection\", ...args),\n };\n}\n\ninterface AnalyticsContextType {\n analytics: AnalyticsSink | null;\n}\n\nconst AnalyticsContext = createContext<AnalyticsContextType | null>(null);\n\nexport function AnalyticsProvider({\n children,\n checkoutProvider,\n}: React.PropsWithChildren<{ checkoutProvider?: CheckoutProvider }>) {\n const consent = useConsent();\n const registeredScripts = useRegisteredScripts();\n\n // Sinks are derived from consent + which managed scripts are on the page, so\n // the set rebuilds whenever the visitor changes consent or a script mounts.\n const analytics = useMemo(() => {\n return combineSinks(\n getAnalyticsSinks({\n consent: {\n mode: consent.mode,\n categories: consent.categories,\n decidedAt: consent.decidedAt,\n },\n registeredScripts,\n checkoutProvider,\n }),\n );\n }, [\n consent.mode,\n consent.categories,\n consent.decidedAt,\n registeredScripts,\n checkoutProvider,\n ]);\n\n // The navigation tracker is set up once, but always dispatches to the latest\n // combined sink via a ref so consent/registration changes take effect.\n const analyticsRef = useRef(analytics);\n analyticsRef.current = analytics;\n const navigationTracker = useRef<NavigationTracker | null>(null);\n\n // eslint-disable-next-line replo/no-use-effect -- one-time SPA navigation tracking setup; dispatches through analyticsRef to stay current\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n navigationTracker.current = new NavigationTracker(\n (metadata: PageMetadata) => {\n void analyticsRef.current.pageView(metadata);\n },\n );\n navigationTracker.current.init();\n\n return () => {\n navigationTracker.current?.cleanup();\n };\n }, []);\n\n return (\n <AnalyticsContext.Provider value={{ analytics }}>\n {children}\n </AnalyticsContext.Provider>\n );\n}\n\nclass AnalyticsContextError extends Error {\n constructor({ message }: { message: string }) {\n super(message);\n }\n}\n\n/**\n * Returns the AnalyticsSink from the nearest AnalyticsProvider.\n * Throws if used outside of an AnalyticsProvider.\n */\nexport function useAnalytics(): AnalyticsSink | null {\n const context = useContext(AnalyticsContext);\n if (!context) {\n throw new AnalyticsContextError({\n message: \"useAnalytics must be used within <AnalyticsProvider>\",\n });\n }\n return context.analytics;\n}\n\n/**\n * Returns the AnalyticsSink if an AnalyticsProvider is present, or null otherwise.\n * Does not throw -- safe to use in components that may render with or without analytics.\n */\nexport function useAnalyticsOptional(): AnalyticsSink | null {\n const context = useContext(AnalyticsContext);\n return context?.analytics ?? null;\n}\n"],
5
+ "mappings": "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",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,6 @@
1
1
  import type { ConsentState } from "../consent/consent-store";
2
2
  import type { RegisteredScript } from "../consent/script-registration-store";
3
+ import type { CheckoutProvider } from "../lib/integration-utils";
3
4
  import type { AnalyticsSink } from "./analytics-sink";
4
5
  /**
5
6
  * Builds the set of analytics sinks that may fire given the current consent
@@ -19,7 +20,8 @@ import type { AnalyticsSink } from "./analytics-sink";
19
20
  * Third-party provider sinks are created only when a matching `<ReploScripts>`
20
21
  * entry is registered AND its required consent is granted.
21
22
  */
22
- export declare function getAnalyticsSinks({ consent, registeredScripts, }: {
23
+ export declare function getAnalyticsSinks({ consent, registeredScripts, checkoutProvider, }: {
23
24
  consent: ConsentState;
24
25
  registeredScripts: RegisteredScript[];
26
+ checkoutProvider?: CheckoutProvider;
25
27
  }): AnalyticsSink[];
@@ -7,6 +7,7 @@ import { ReploSink } from "./sinks/replo-sink";
7
7
  import { SnapchatSink } from "./sinks/snapchat-sink";
8
8
  import { TikTokSink } from "./sinks/tiktok-sink";
9
9
  import { WindowSink } from "./sinks/window-sink";
10
+ import { gateShopifyOwnedFunnelEvents } from "./utils/shopify-funnel-gate";
10
11
  const PROVIDER_SINK_FACTORIES = {
11
12
  GA4: () => new GA4Sink(),
12
13
  Meta: () => new MetaSink(),
@@ -17,13 +18,15 @@ const PROVIDER_SINK_FACTORIES = {
17
18
  };
18
19
  function getAnalyticsSinks({
19
20
  consent,
20
- registeredScripts
21
+ registeredScripts,
22
+ checkoutProvider
21
23
  }) {
22
24
  const sinks = [new WindowSink()];
23
25
  const firstPartyAllowed = consent.mode === "off" || consent.categories.analytics;
24
26
  if (firstPartyAllowed) {
25
27
  sinks.push(new ReploSink());
26
28
  }
29
+ const shopifyOwnsCheckout = checkoutProvider === "shopify";
27
30
  const addedTypes = /* @__PURE__ */ new Set();
28
31
  for (const script of registeredScripts) {
29
32
  const factory = PROVIDER_SINK_FACTORIES[script.type];
@@ -34,7 +37,10 @@ function getAnalyticsSinks({
34
37
  state: consent,
35
38
  requiredConsent: script.requiredConsent
36
39
  })) {
37
- sinks.push(factory());
40
+ const sink = factory();
41
+ sinks.push(
42
+ shopifyOwnsCheckout ? gateShopifyOwnedFunnelEvents(sink) : sink
43
+ );
38
44
  addedTypes.add(script.type);
39
45
  }
40
46
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../analytics/get-analytics-sinks.ts"],
4
- "sourcesContent": ["import type { ReploScriptType } from \"schemas/generated/consent\";\nimport type { ConsentState } from \"../consent/consent-store\";\nimport type { RegisteredScript } from \"../consent/script-registration-store\";\nimport type { AnalyticsSink } from \"./analytics-sink\";\n\nimport { isConsentAllowed } from \"../consent/consent-store\";\nimport { GA4Sink } from \"./sinks/ga4-sink\";\nimport { MetaSink } from \"./sinks/meta-sink\";\nimport { PinterestSink } from \"./sinks/pinterest-sink\";\nimport { RedditSink } from \"./sinks/reddit-sink\";\nimport { ReploSink } from \"./sinks/replo-sink\";\nimport { SnapchatSink } from \"./sinks/snapchat-sink\";\nimport { TikTokSink } from \"./sinks/tiktok-sink\";\nimport { WindowSink } from \"./sinks/window-sink\";\n\n/**\n * Named providers that have a corresponding ecommerce-event sink. The other\n * managed providers (GoogleTagManager, Hotjar, MicrosoftClarity, Triplewhale,\n * Segment) load scripts but do not map to `AnalyticsSink` events today, so they\n * never produce a sink here.\n */\nconst PROVIDER_SINK_FACTORIES: Partial<\n Record<ReploScriptType, () => AnalyticsSink>\n> = {\n GA4: () => new GA4Sink(),\n Meta: () => new MetaSink(),\n TikTok: () => new TikTokSink(),\n Snapchat: () => new SnapchatSink(),\n Pinterest: () => new PinterestSink(),\n Reddit: () => new RedditSink(),\n};\n\n/**\n * Builds the set of analytics sinks that may fire given the current consent\n * state and which managed scripts are registered on the page.\n *\n * Consent gates data egress, not in-page plumbing:\n * - `WindowSink` is a local `CustomEvent` bus (no data leaves the device), so it\n * always ships regardless of consent. Its consumers self-gate: managed pixels\n * are already gated at the injection layer (they never mount without consent,\n * so they never subscribe), and unmanaged custom scripts are the author's\n * responsibility.\n * - `ReploSink` forwards into Replo's first-party analytics pipeline (real\n * egress / processing), so it counts as `analytics`-category tracking and is\n * gated by that consent. It is an implicit sink this scaffold always ships\n * (not tied to a registered entry) and is never editable in the miniapp.\n *\n * Third-party provider sinks are created only when a matching `<ReploScripts>`\n * entry is registered AND its required consent is granted.\n */\nexport function getAnalyticsSinks({\n consent,\n registeredScripts,\n}: {\n consent: ConsentState;\n registeredScripts: RegisteredScript[];\n}): AnalyticsSink[] {\n const sinks: AnalyticsSink[] = [new WindowSink()];\n\n const firstPartyAllowed =\n consent.mode === \"off\" || consent.categories.analytics;\n if (firstPartyAllowed) {\n sinks.push(new ReploSink());\n }\n\n const addedTypes = new Set<ReploScriptType>();\n for (const script of registeredScripts) {\n const factory = PROVIDER_SINK_FACTORIES[script.type];\n if (!factory || addedTypes.has(script.type)) {\n continue;\n }\n if (\n isConsentAllowed({\n state: consent,\n requiredConsent: script.requiredConsent,\n })\n ) {\n sinks.push(factory());\n addedTypes.add(script.type);\n }\n }\n\n return sinks;\n}\n"],
5
- "mappings": "AAKA,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAQ3B,MAAM,0BAEF;AAAA,EACF,KAAK,MAAM,IAAI,QAAQ;AAAA,EACvB,MAAM,MAAM,IAAI,SAAS;AAAA,EACzB,QAAQ,MAAM,IAAI,WAAW;AAAA,EAC7B,UAAU,MAAM,IAAI,aAAa;AAAA,EACjC,WAAW,MAAM,IAAI,cAAc;AAAA,EACnC,QAAQ,MAAM,IAAI,WAAW;AAC/B;AAoBO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAGoB;AAClB,QAAM,QAAyB,CAAC,IAAI,WAAW,CAAC;AAEhD,QAAM,oBACJ,QAAQ,SAAS,SAAS,QAAQ,WAAW;AAC/C,MAAI,mBAAmB;AACrB,UAAM,KAAK,IAAI,UAAU,CAAC;AAAA,EAC5B;AAEA,QAAM,aAAa,oBAAI,IAAqB;AAC5C,aAAW,UAAU,mBAAmB;AACtC,UAAM,UAAU,wBAAwB,OAAO,IAAI;AACnD,QAAI,CAAC,WAAW,WAAW,IAAI,OAAO,IAAI,GAAG;AAC3C;AAAA,IACF;AACA,QACE,iBAAiB;AAAA,MACf,OAAO;AAAA,MACP,iBAAiB,OAAO;AAAA,IAC1B,CAAC,GACD;AACA,YAAM,KAAK,QAAQ,CAAC;AACpB,iBAAW,IAAI,OAAO,IAAI;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { ReploScriptType } from \"schemas/generated/consent\";\nimport type { ConsentState } from \"../consent/consent-store\";\nimport type { RegisteredScript } from \"../consent/script-registration-store\";\nimport type { CheckoutProvider } from \"../lib/integration-utils\";\nimport type { AnalyticsSink } from \"./analytics-sink\";\n\nimport { isConsentAllowed } from \"../consent/consent-store\";\nimport { GA4Sink } from \"./sinks/ga4-sink\";\nimport { MetaSink } from \"./sinks/meta-sink\";\nimport { PinterestSink } from \"./sinks/pinterest-sink\";\nimport { RedditSink } from \"./sinks/reddit-sink\";\nimport { ReploSink } from \"./sinks/replo-sink\";\nimport { SnapchatSink } from \"./sinks/snapchat-sink\";\nimport { TikTokSink } from \"./sinks/tiktok-sink\";\nimport { WindowSink } from \"./sinks/window-sink\";\nimport { gateShopifyOwnedFunnelEvents } from \"./utils/shopify-funnel-gate\";\n\n/**\n * Named providers that have a corresponding ecommerce-event sink. The other\n * managed providers (GoogleTagManager, Hotjar, MicrosoftClarity, Segment) and\n * generic `snippet`/`custom` entries load scripts but do not map to\n * `AnalyticsSink` events today, so they never produce a sink here.\n */\nconst PROVIDER_SINK_FACTORIES: Partial<\n Record<ReploScriptType, () => AnalyticsSink>\n> = {\n GA4: () => new GA4Sink(),\n Meta: () => new MetaSink(),\n TikTok: () => new TikTokSink(),\n Snapchat: () => new SnapchatSink(),\n Pinterest: () => new PinterestSink(),\n Reddit: () => new RedditSink(),\n};\n\n/**\n * Builds the set of analytics sinks that may fire given the current consent\n * state and which managed scripts are registered on the page.\n *\n * Consent gates data egress, not in-page plumbing:\n * - `WindowSink` is a local `CustomEvent` bus (no data leaves the device), so it\n * always ships regardless of consent. Its consumers self-gate: managed pixels\n * are already gated at the injection layer (they never mount without consent,\n * so they never subscribe), and unmanaged custom scripts are the author's\n * responsibility.\n * - `ReploSink` forwards into Replo's first-party analytics pipeline (real\n * egress / processing), so it counts as `analytics`-category tracking and is\n * gated by that consent. It is an implicit sink this scaffold always ships\n * (not tied to a registered entry) and is never editable in the miniapp.\n *\n * Third-party provider sinks are created only when a matching `<ReploScripts>`\n * entry is registered AND its required consent is granted.\n */\nexport function getAnalyticsSinks({\n consent,\n registeredScripts,\n checkoutProvider,\n}: {\n consent: ConsentState;\n registeredScripts: RegisteredScript[];\n checkoutProvider?: CheckoutProvider;\n}): AnalyticsSink[] {\n const sinks: AnalyticsSink[] = [new WindowSink()];\n\n const firstPartyAllowed =\n consent.mode === \"off\" || consent.categories.analytics;\n if (firstPartyAllowed) {\n sinks.push(new ReploSink());\n }\n\n // When Shopify hosts checkout, its native channels report the checkout-funnel\n // events to ad platforms server-side. Suppress those events on third-party\n // storefront pixels so they don't double-count Shopify's copy.\n const shopifyOwnsCheckout = checkoutProvider === \"shopify\";\n\n const addedTypes = new Set<ReploScriptType>();\n for (const script of registeredScripts) {\n const factory = PROVIDER_SINK_FACTORIES[script.type];\n if (!factory || addedTypes.has(script.type)) {\n continue;\n }\n if (\n isConsentAllowed({\n state: consent,\n requiredConsent: script.requiredConsent,\n })\n ) {\n const sink = factory();\n sinks.push(\n shopifyOwnsCheckout ? gateShopifyOwnedFunnelEvents(sink) : sink,\n );\n addedTypes.add(script.type);\n }\n }\n\n return sinks;\n}\n"],
5
+ "mappings": "AAMA,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,oCAAoC;AAQ7C,MAAM,0BAEF;AAAA,EACF,KAAK,MAAM,IAAI,QAAQ;AAAA,EACvB,MAAM,MAAM,IAAI,SAAS;AAAA,EACzB,QAAQ,MAAM,IAAI,WAAW;AAAA,EAC7B,UAAU,MAAM,IAAI,aAAa;AAAA,EACjC,WAAW,MAAM,IAAI,cAAc;AAAA,EACnC,QAAQ,MAAM,IAAI,WAAW;AAC/B;AAoBO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAIoB;AAClB,QAAM,QAAyB,CAAC,IAAI,WAAW,CAAC;AAEhD,QAAM,oBACJ,QAAQ,SAAS,SAAS,QAAQ,WAAW;AAC/C,MAAI,mBAAmB;AACrB,UAAM,KAAK,IAAI,UAAU,CAAC;AAAA,EAC5B;AAKA,QAAM,sBAAsB,qBAAqB;AAEjD,QAAM,aAAa,oBAAI,IAAqB;AAC5C,aAAW,UAAU,mBAAmB;AACtC,UAAM,UAAU,wBAAwB,OAAO,IAAI;AACnD,QAAI,CAAC,WAAW,WAAW,IAAI,OAAO,IAAI,GAAG;AAC3C;AAAA,IACF;AACA,QACE,iBAAiB;AAAA,MACf,OAAO;AAAA,MACP,iBAAiB,OAAO;AAAA,IAC1B,CAAC,GACD;AACA,YAAM,OAAO,QAAQ;AACrB,YAAM;AAAA,QACJ,sBAAsB,6BAA6B,IAAI,IAAI;AAAA,MAC7D;AACA,iBAAW,IAAI,OAAO,IAAI;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }