@wix/site-service-interactions 1.0.12 → 1.0.14

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 (102) hide show
  1. package/cjs/build/definition/index.d.ts +19 -3
  2. package/cjs/build/definition/index.js.map +1 -1
  3. package/cjs/build/implementations/InteractionsScriptElement.d.ts +1 -1
  4. package/cjs/build/implementations/InteractionsScriptElement.js.map +1 -1
  5. package/cjs/build/implementations/configEntries.d.ts +13 -0
  6. package/cjs/build/implementations/configEntries.js +78 -0
  7. package/cjs/build/implementations/configEntries.js.map +1 -0
  8. package/cjs/build/implementations/coreInteractions.d.ts +2 -2
  9. package/cjs/build/implementations/coreInteractions.js +50 -23
  10. package/cjs/build/implementations/coreInteractions.js.map +1 -1
  11. package/cjs/build/implementations/interactions.js +1 -1
  12. package/cjs/build/implementations/interactions.js.map +1 -1
  13. package/cjs/build/implementations/interactionsExternal.js +1 -1
  14. package/cjs/build/implementations/interactionsExternal.js.map +1 -1
  15. package/cjs/build/implementations/interactionsService.d.ts +5 -4
  16. package/cjs/build/implementations/interactionsService.js.map +1 -1
  17. package/cjs/build/implementations/reviveScriptElement.js.map +1 -1
  18. package/cjs/build/implementations/v2/InteractionsScriptElement.d.ts +2 -2
  19. package/cjs/build/implementations/v2/InteractionsScriptElement.js.map +1 -1
  20. package/cjs/build/implementations/v2/authoredStyles.d.ts +2 -0
  21. package/cjs/build/implementations/v2/authoredStyles.js +90 -0
  22. package/cjs/build/implementations/v2/authoredStyles.js.map +1 -0
  23. package/cjs/build/implementations/v2/cdnUrls.d.ts +2 -1
  24. package/cjs/build/implementations/v2/cdnUrls.js +3 -2
  25. package/cjs/build/implementations/v2/cdnUrls.js.map +1 -1
  26. package/cjs/build/implementations/v2/clickTriggerCss.d.ts +1 -1
  27. package/cjs/build/implementations/v2/clickTriggerCss.js +1 -1
  28. package/cjs/build/implementations/v2/clickTriggerCss.js.map +1 -1
  29. package/cjs/build/implementations/v2/configCss.d.ts +1 -1
  30. package/cjs/build/implementations/v2/configCss.js +3 -36
  31. package/cjs/build/implementations/v2/configCss.js.map +1 -1
  32. package/cjs/build/implementations/v2/configStyleHeadContent.js +8 -6
  33. package/cjs/build/implementations/v2/configStyleHeadContent.js.map +1 -1
  34. package/cjs/build/implementations/v2/interactionsScriptContent.js +18 -7
  35. package/cjs/build/implementations/v2/interactionsScriptContent.js.map +1 -1
  36. package/cjs/build/implementations/v2/motionPresets.d.ts +14 -0
  37. package/cjs/build/implementations/v2/motionPresets.js +76 -0
  38. package/cjs/build/implementations/v2/motionPresets.js.map +1 -0
  39. package/cjs/build/service.d.ts +1 -1
  40. package/cjs/build/types/index.d.ts +1 -1
  41. package/cjs/package.json +1 -1
  42. package/definition/package.json +1 -1
  43. package/dist/definition/index.d.ts +19 -3
  44. package/dist/definition/index.js.map +1 -1
  45. package/dist/implementations/InteractionsScriptElement.d.ts +1 -1
  46. package/dist/implementations/InteractionsScriptElement.js.map +1 -1
  47. package/dist/implementations/configEntries.d.ts +13 -0
  48. package/dist/implementations/configEntries.js +71 -0
  49. package/dist/implementations/configEntries.js.map +1 -0
  50. package/dist/implementations/coreInteractions.d.ts +2 -2
  51. package/dist/implementations/coreInteractions.js +50 -23
  52. package/dist/implementations/coreInteractions.js.map +1 -1
  53. package/dist/implementations/interactions.js +1 -1
  54. package/dist/implementations/interactions.js.map +1 -1
  55. package/dist/implementations/interactionsExternal.js +1 -1
  56. package/dist/implementations/interactionsExternal.js.map +1 -1
  57. package/dist/implementations/interactionsService.d.ts +5 -4
  58. package/dist/implementations/interactionsService.js.map +1 -1
  59. package/dist/implementations/reviveScriptElement.js.map +1 -1
  60. package/dist/implementations/v2/InteractionsScriptElement.d.ts +2 -2
  61. package/dist/implementations/v2/InteractionsScriptElement.js.map +1 -1
  62. package/dist/implementations/v2/authoredStyles.d.ts +2 -0
  63. package/dist/implementations/v2/authoredStyles.js +86 -0
  64. package/dist/implementations/v2/authoredStyles.js.map +1 -0
  65. package/dist/implementations/v2/cdnUrls.d.ts +2 -1
  66. package/dist/implementations/v2/cdnUrls.js +2 -1
  67. package/dist/implementations/v2/cdnUrls.js.map +1 -1
  68. package/dist/implementations/v2/clickTriggerCss.d.ts +1 -1
  69. package/dist/implementations/v2/clickTriggerCss.js +1 -1
  70. package/dist/implementations/v2/clickTriggerCss.js.map +1 -1
  71. package/dist/implementations/v2/configCss.d.ts +1 -1
  72. package/dist/implementations/v2/configCss.js +2 -2
  73. package/dist/implementations/v2/configCss.js.map +1 -1
  74. package/dist/implementations/v2/configStyleHeadContent.js +8 -6
  75. package/dist/implementations/v2/configStyleHeadContent.js.map +1 -1
  76. package/dist/implementations/v2/interactionsScriptContent.js +19 -8
  77. package/dist/implementations/v2/interactionsScriptContent.js.map +1 -1
  78. package/dist/implementations/v2/motionPresets.d.ts +14 -0
  79. package/dist/implementations/v2/motionPresets.js +39 -0
  80. package/dist/implementations/v2/motionPresets.js.map +1 -0
  81. package/dist/service.d.ts +1 -1
  82. package/dist/types/index.d.ts +1 -1
  83. package/implementations/package.json +1 -1
  84. package/package.json +24 -23
  85. package/src/definition/index.ts +21 -4
  86. package/src/implementations/InteractionsScriptElement.tsx +17 -17
  87. package/src/implementations/configEntries.ts +103 -0
  88. package/src/implementations/coreInteractions.ts +102 -68
  89. package/src/implementations/interactions.ts +8 -8
  90. package/src/implementations/interactionsExternal.ts +11 -11
  91. package/src/implementations/interactionsService.ts +8 -8
  92. package/src/implementations/reviveScriptElement.ts +8 -8
  93. package/src/implementations/v2/InteractionsScriptElement.tsx +23 -28
  94. package/src/implementations/v2/authoredStyles.ts +103 -0
  95. package/src/implementations/v2/cdnUrls.ts +4 -1
  96. package/src/implementations/v2/clickTriggerCss.ts +26 -26
  97. package/src/implementations/v2/configCss.ts +6 -7
  98. package/src/implementations/v2/configStyleHeadContent.ts +9 -6
  99. package/src/implementations/v2/interactionsScriptContent.ts +36 -24
  100. package/src/implementations/v2/motionPresets.ts +60 -0
  101. package/src/types/index.ts +1 -1
  102. package/types/package.json +1 -1
@@ -0,0 +1,86 @@
1
+ const SELECTOR_TOKEN = /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[()[\]]|,/g;
2
+ const escapeCssString = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\a ').replace(/\r/g, '\\d ').replace(/\f/g, '\\c ');
3
+ const splitSelectorList = (selector) => {
4
+ const parts = [];
5
+ let depth = 0;
6
+ let start = 0;
7
+ SELECTOR_TOKEN.lastIndex = 0;
8
+ for (let match = SELECTOR_TOKEN.exec(selector); match; match = SELECTOR_TOKEN.exec(selector)) {
9
+ const token = match[0];
10
+ if (token === '(' || token === '[') {
11
+ depth++;
12
+ }
13
+ else if (token === ')' || token === ']') {
14
+ depth--;
15
+ }
16
+ else if (token === ',' && depth === 0) {
17
+ parts.push(selector.slice(start, match.index));
18
+ start = match.index + 1;
19
+ }
20
+ }
21
+ parts.push(selector.slice(start));
22
+ return parts.map((part) => part.trim()).filter(Boolean);
23
+ };
24
+ const indentCssBlock = (css) => css
25
+ .split('\n')
26
+ .map((line) => (line ? ` ${line}` : line))
27
+ .join('\n');
28
+ const renderProperties = (properties) => Object.entries(properties)
29
+ .map(([property, value]) => ` ${property}: ${value};`)
30
+ .join('\n');
31
+ const wrapWithConditions = (block, rule) => {
32
+ let result = block;
33
+ if (rule['@container']) {
34
+ result = `@container ${rule['@container']} {\n${indentCssBlock(result)}\n}`;
35
+ }
36
+ if (rule['@media']) {
37
+ result = `@media ${rule['@media']} {\n${indentCssBlock(result)}\n}`;
38
+ }
39
+ if (rule['@supports']) {
40
+ result = `@supports ${rule['@supports']} {\n${indentCssBlock(result)}\n}`;
41
+ }
42
+ return result;
43
+ };
44
+ const buildRuleSelector = (namespace, rule) => {
45
+ const scopeWrapper = `[data-interact-key="${escapeCssString(namespace)}"]`;
46
+ const scopeRoot = `${scopeWrapper} > :first-child`;
47
+ if (!rule.key) {
48
+ if (!rule.selector) {
49
+ return scopeRoot;
50
+ }
51
+ return splitSelectorList(rule.selector)
52
+ .map((selector) => `${scopeRoot} ${selector}`)
53
+ .join(', ');
54
+ }
55
+ const escapedKey = escapeCssString(rule.key);
56
+ const keyWrapper = rule.key === namespace ? scopeWrapper : `${scopeWrapper} [data-interact-key="${escapedKey}"]`;
57
+ const keyRoot = `${keyWrapper} > :first-child`;
58
+ if (!rule.selector) {
59
+ return keyRoot;
60
+ }
61
+ const separator = /^\s/.test(rule.selector) ? ' ' : '';
62
+ return splitSelectorList(rule.selector)
63
+ .map((selector) => `${keyRoot}${separator}${selector}`)
64
+ .join(', ');
65
+ };
66
+ const getEntryStylesCss = ({ namespace, styles = [] }) => {
67
+ if (!styles.length) {
68
+ return '';
69
+ }
70
+ if (!namespace) {
71
+ throw new Error('Interactions config entries with authored styles must define a namespace.');
72
+ }
73
+ return styles
74
+ .map((rule) => {
75
+ const properties = renderProperties(rule.properties);
76
+ if (!properties) {
77
+ return '';
78
+ }
79
+ const block = `${buildRuleSelector(namespace, rule)} {\n${properties}\n}`;
80
+ return wrapWithConditions(block, rule);
81
+ })
82
+ .filter(Boolean)
83
+ .join('\n\n');
84
+ };
85
+ export const getAuthoredStylesCss = (entries) => entries.map(getEntryStylesCss).filter(Boolean).join('\n\n');
86
+ //# sourceMappingURL=authoredStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoredStyles.js","sourceRoot":"","sources":["../../../src/implementations/v2/authoredStyles.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,gDAAgD,CAAA;AAEvE,MAAM,eAAe,GAAG,CAAC,KAAa,EAAU,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAEvH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B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACpD,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,OAAO,EAAE,CAAA;QACV,CAAC;QACD,MAAM,KAAK,GAAG,GAAG,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,UAAU,KAAK,CAAA;QACzE,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACvC,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,MAAM,CAAC,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAA8B,EAAU,EAAE,CAC9E,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA"}
@@ -1,2 +1,3 @@
1
1
  export declare const INTERACT_V2_IMPORT_URL = "https://cdn.jsdelivr.net/npm/@wix/interact@2.5.14/dist/es/web.min.js";
2
- export declare const WIX_MOTION_PRESETS_IMPORT_URL = "https://cdn.jsdelivr.net/npm/@wix/wix-motion-presets@1.0.0/+esm";
2
+ export declare const LEGACY_WIX_MOTION_PRESETS_IMPORT_URL = "https://cdn.jsdelivr.net/npm/@wix/wix-motion-presets@1.2.0/+esm";
3
+ export declare const MOTION_PRESETS_IMPORT_URL = "https://cdn.jsdelivr.net/npm/@wix/motion-presets@1.0.7/dist/browser/motion-presets.min.js";
@@ -1,3 +1,4 @@
1
1
  export const INTERACT_V2_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/interact@2.5.14/dist/es/web.min.js';
2
- export const WIX_MOTION_PRESETS_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/wix-motion-presets@1.0.0/+esm';
2
+ export const LEGACY_WIX_MOTION_PRESETS_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/wix-motion-presets@1.2.0/+esm';
3
+ export const MOTION_PRESETS_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/motion-presets@1.0.7/dist/browser/motion-presets.min.js';
3
4
  //# sourceMappingURL=cdnUrls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,sEAAsE,CAAA;AAE5G,MAAM,CAAC,MAAM,6BAA6B,GAAG,iEAAiE,CAAA"}
1
+ {"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,sEAAsE,CAAA;AAE5G,MAAM,CAAC,MAAM,oCAAoC,GAAG,iEAAiE,CAAA;AAErH,MAAM,CAAC,MAAM,yBAAyB,GACrC,2FAA2F,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { InteractConfig } from '@wix/interact';
1
+ import type { InteractConfig } from '@wix/interact-v2';
2
2
  /** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
3
3
  export declare const getClickTriggerCss: (config: InteractConfig) => string;
@@ -26,6 +26,6 @@ export const getClickTriggerCss = (config) => {
26
26
  if (!selectors.length) {
27
27
  return '';
28
28
  }
29
- return selectors.map(selector => `${selector} {\ncursor: pointer;\n}`).join('\n');
29
+ return selectors.map((selector) => `${selector} {\ncursor: pointer;\n}`).join('\n');
30
30
  };
31
31
  //# sourceMappingURL=clickTriggerCss.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clickTriggerCss.js","sourceRoot":"","sources":["../../../src/implementations/v2/clickTriggerCss.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAElG;;;GAGG;AACH,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BAA4B,CAAC,CACnC;KACD,CAAA;IAED,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,EAAE,CAAA;IACV,CAAC;IAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,QAAQ,yBAAyB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACpF,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { InteractConfig } from '@wix/interact';
1
+ import type { InteractConfig } from '@wix/interact-v2';
2
2
  /** Emit animation FOUC CSS and click-trigger cursor rules. */
3
3
  export declare const getV2ConfigCss: (config: InteractConfig) => string;
@@ -1,8 +1,8 @@
1
1
  import { generate, Interact } from '@wix/interact-v2';
2
- import * as motionPresets from '@wix/wix-motion-presets';
3
2
  import { getClickTriggerCss } from './clickTriggerCss';
3
+ import { motionPresets } from './motionPresets';
4
4
  // Interact's registry is process-global. This module is only pulled into the server bundle
5
- // (`process.env.browser` DCE), so the namespace is registered once per Node process.
5
+ // (`process.env.browser` DCE), so both namespaces are registered once per Node process.
6
6
  Interact.registerEffects(motionPresets);
7
7
  /** Emit animation FOUC CSS and click-trigger cursor rules. */
8
8
  export const getV2ConfigCss = (config) => {
@@ -1 +1 @@
1
- {"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGrD,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAItD,2FAA2F;AAC3F,qFAAqF;AACrF,QAAQ,CAAC,eAAe,CAAC,aAA0C,CAAC,CAAA;AAEpE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC7D,MAAM,YAAY,GAAG,QAAQ,CAAC,MAA0B,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;IACtE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAElD,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC9D,CAAC,CAAA"}
1
+ {"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,2FAA2F;AAC3F,wFAAwF;AACxF,QAAQ,CAAC,eAAe,CAAC,aAA0C,CAAC,CAAA;AAEpE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAChE,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;IAClD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAElD,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC3D,CAAC,CAAA"}
@@ -1,12 +1,14 @@
1
1
  /**
2
- * Head content is a raw HTML string, so anything tag-like in the generated CSS either closes the
3
- * style element early or trips the head appender's script-tag guard, which throws. Nothing in CSS
4
- * opens a tag: `<` appears only in media range queries, followed by a space or a digit. Cutting
5
- * from the first `<` that could start a tag leaves valid CSS untouched.
2
+ * Head content is a raw HTML string. CSS values may contain tag-like text, but an actual closing
3
+ * style tag still terminates the raw-text element, and HeadAppender rejects `<script` substrings.
4
+ * Keep other CSS intact: drop content after a closing style tag and break script-like sequences.
6
5
  */
6
+ const STYLE_END_TAG = /<\/style(?=[\t\n\f\r />])/i;
7
+ const SCRIPT_LIKE = /<script/gi;
7
8
  const sanitizeCssForStyleElement = (css) => {
8
- const tagIndex = css.search(/<[a-zA-Z/]/);
9
- return tagIndex === -1 ? css : css.slice(0, tagIndex);
9
+ const styleEndTagIndex = css.search(STYLE_END_TAG);
10
+ const withoutStyleBreakout = styleEndTagIndex === -1 ? css : css.slice(0, styleEndTagIndex);
11
+ return withoutStyleBreakout.replace(SCRIPT_LIKE, '\\3c script');
10
12
  };
11
13
  export const getV2ConfigStyleHeadContent = (css) => `<style>${sanitizeCssForStyleElement(css)}</style>`;
12
14
  //# sourceMappingURL=configStyleHeadContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configStyleHeadContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/configStyleHeadContent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CAAC,GAAW,EAAU,EAAE;IACvD,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IACzC,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;AACzD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA"}
1
+ {"version":3,"file":"configStyleHeadContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/configStyleHeadContent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,aAAa,GAAG,4BAA4B,CAAA;AAClD,MAAM,WAAW,GAAG,WAAW,CAAA;AAE/B,MAAM,0BAA0B,GAAG,CAAC,GAAW,EAAU,EAAE;IAC1D,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IAClD,MAAM,oBAAoB,GAAG,gBAAgB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAA;IAC3F,OAAO,oBAAoB,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;AAChE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA"}
@@ -1,20 +1,29 @@
1
- import { INTERACT_V2_IMPORT_URL, WIX_MOTION_PRESETS_IMPORT_URL } from './cdnUrls';
1
+ import { INTERACT_V2_IMPORT_URL, LEGACY_WIX_MOTION_PRESETS_IMPORT_URL, MOTION_PRESETS_IMPORT_URL } from './cdnUrls';
2
+ import { LEGACY_PREFIX } from './motionPresets';
3
+ /** The loader destructures `Promise.all` in this order. */
4
+ const MODULE_IMPORT_URLS = [INTERACT_V2_IMPORT_URL, LEGACY_WIX_MOTION_PRESETS_IMPORT_URL, MOTION_PRESETS_IMPORT_URL];
2
5
  /**
3
6
  * The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
4
7
  * see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
5
8
  * `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
6
9
  * would download each module twice.
7
10
  */
8
- export const getV2ModulePreloadHeadContent = () => `<link rel="modulepreload" href="${INTERACT_V2_IMPORT_URL}"><link rel="modulepreload" href="${WIX_MOTION_PRESETS_IMPORT_URL}">`;
11
+ export const getV2ModulePreloadHeadContent = () => MODULE_IMPORT_URLS.map((url) => `<link rel="modulepreload" href="${url}">`).join('');
9
12
  export const getV2InteractionsScriptContent = (configId, isReducedMotion) => [
10
13
  `const configElement = document.getElementById(\`${configId}\`)`,
11
14
  'if (configElement) {',
12
- ' const config = JSON.parse(configElement.textContent)',
13
- ' const [{ Interact }, presets] = await Promise.all([',
14
- ` import(\`${INTERACT_V2_IMPORT_URL}\`),`,
15
- ` import(\`${WIX_MOTION_PRESETS_IMPORT_URL}\`),`,
15
+ ' const parsedConfig = JSON.parse(configElement.textContent)',
16
+ ' const configs = Array.isArray(parsedConfig) ? parsedConfig : [parsedConfig]',
17
+ ' const [{ Interact }, legacyPresets, presets] = await Promise.all([',
18
+ ...MODULE_IMPORT_URLS.map((url) => ` import(\`${url}\`),`),
16
19
  ' ])',
17
- ' Interact.registerEffects(presets)',
20
+ // Reactions configs carry the prefix on their named effect types, so the two packages can
21
+ // both export a preset under the same name without one shadowing the other.
22
+ ' const aliasedLegacyPresets = {}',
23
+ ' for (const name of Object.keys(legacyPresets)) {',
24
+ ` aliasedLegacyPresets[\`${LEGACY_PREFIX}\` + name] = legacyPresets[name]`,
25
+ ' }',
26
+ ' Interact.registerEffects({ ...presets, ...aliasedLegacyPresets })',
18
27
  ` Interact.forceReducedMotion = ${isReducedMotion}`,
19
28
  ' Interact.setup({',
20
29
  ' scrollOptionsGetter: function () {',
@@ -25,7 +34,9 @@ export const getV2InteractionsScriptContent = (configId, isReducedMotion) => [
25
34
  ' useSafeViewEnter: true,',
26
35
  ' },',
27
36
  ' })',
28
- ' Interact.create(config)',
37
+ ' for (const config of configs) {',
38
+ ' Interact.create(config)',
39
+ ' }',
29
40
  '}',
30
41
  ].join('\n');
31
42
  //# sourceMappingURL=interactionsScriptContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/interactionsScriptContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAA;AAEjF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAW,EAAE,CACtD,mCAAmC,sBAAsB,qCAAqC,6BAA6B,IAAI,CAAA;AAEnI,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,QAAgB,EAAE,eAAwB,EAAU,EAAE,CACjG;IACI,mDAAmD,QAAQ,KAAK;IAChE,sBAAsB;IACtB,wDAAwD;IACxD,uDAAuD;IACvD,gBAAgB,sBAAsB,MAAM;IAC5C,gBAAgB,6BAA6B,MAAM;IACnD,MAAM;IACN,qCAAqC;IACrC,mCAAmC,eAAe,EAAE;IACpD,oBAAoB;IACpB,wCAAwC;IACxC,mDAAmD;IACnD,QAAQ;IACR,8BAA8B;IAC9B,kBAAkB;IAClB,+BAA+B;IAC/B,QAAQ;IACR,MAAM;IACN,2BAA2B;IAC3B,GAAG;CACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
1
+ {"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/interactionsScriptContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,oCAAoC,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AACnH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG,CAAC,sBAAsB,EAAE,oCAAoC,EAAE,yBAAyB,CAAC,CAAA;AAEpH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAW,EAAE,CACzD,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAErF,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,QAAgB,EAAE,eAAwB,EAAU,EAAE,CACpG;IACC,mDAAmD,QAAQ,KAAK;IAChE,sBAAsB;IACtB,8DAA8D;IAC9D,+EAA+E;IAC/E,sEAAsE;IACtE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,GAAG,MAAM,CAAC;IAC7D,MAAM;IACN,0FAA0F;IAC1F,4EAA4E;IAC5E,mCAAmC;IACnC,oDAAoD;IACpD,8BAA8B,aAAa,kCAAkC;IAC7E,KAAK;IACL,qEAAqE;IACrE,mCAAmC,eAAe,EAAE;IACpD,oBAAoB;IACpB,wCAAwC;IACxC,mDAAmD;IACnD,QAAQ;IACR,8BAA8B;IAC9B,kBAAkB;IAClB,+BAA+B;IAC/B,QAAQ;IACR,MAAM;IACN,mCAAmC;IACnC,6BAA6B;IAC7B,KAAK;IACL,GAAG;CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { InteractConfig } from '@wix/interact-v2';
2
+ type EffectModule = {
3
+ web: unknown;
4
+ style?: unknown;
5
+ getNames: unknown;
6
+ };
7
+ export declare const LEGACY_PREFIX = "LEGACY_";
8
+ /**
9
+ * Both preset packages under one registry, mirroring what the client loader registers. The legacy
10
+ * names carry the prefix so a preset published by both packages doesn't shadow its counterpart.
11
+ */
12
+ export declare const motionPresets: Record<string, EffectModule>;
13
+ export declare const aliasLegacyNamedEffects: (interact: InteractConfig) => InteractConfig;
14
+ export {};
@@ -0,0 +1,39 @@
1
+ import * as allLegacyPresets from '@wix/wix-motion-presets';
2
+ import * as allPresets from '@wix/motion-presets';
3
+ export const LEGACY_PREFIX = 'LEGACY_';
4
+ const isEffectModule = (value) => typeof value === 'object' && value !== null && 'web' in value && 'getNames' in value;
5
+ const getPresetModules = (namespace, prefix = '') => Object.fromEntries(Object.entries(namespace)
6
+ .filter(([, value]) => isEffectModule(value))
7
+ .map(([name, value]) => [`${prefix}${name}`, value]));
8
+ /**
9
+ * Both preset packages under one registry, mirroring what the client loader registers. The legacy
10
+ * names carry the prefix so a preset published by both packages doesn't shadow its counterpart.
11
+ */
12
+ export const motionPresets = {
13
+ ...getPresetModules(allPresets),
14
+ ...getPresetModules(allLegacyPresets, LEGACY_PREFIX),
15
+ };
16
+ const aliasEffect = (effect) => {
17
+ const { namedEffect } = effect;
18
+ if (!namedEffect?.type) {
19
+ return effect;
20
+ }
21
+ return { ...effect, namedEffect: { ...namedEffect, type: `${LEGACY_PREFIX}${namedEffect.type}` } };
22
+ };
23
+ const aliasSequence = (sequence) => {
24
+ const { effects } = sequence;
25
+ return effects ? { ...sequence, effects: effects.map(aliasEffect) } : sequence;
26
+ };
27
+ const mapRecord = (record, map) => Object.fromEntries(Object.entries(record).map(([key, value]) => [key, map(value)]));
28
+ // TODO(ameerf): make this implementation simpler without so many copies of the config object. The current implementation is a direct translation of the v1 code, which was written to avoid mutating the config object.
29
+ export const aliasLegacyNamedEffects = (interact) => ({
30
+ ...interact,
31
+ ...(interact.effects && { effects: mapRecord(interact.effects, aliasEffect) }),
32
+ ...(interact.sequences && { sequences: mapRecord(interact.sequences, aliasSequence) }),
33
+ interactions: interact.interactions.map((interaction) => ({
34
+ ...interaction,
35
+ ...(interaction.effects && { effects: interaction.effects.map(aliasEffect) }),
36
+ ...(interaction.sequences && { sequences: interaction.sequences.map(aliasSequence) }),
37
+ })),
38
+ });
39
+ //# sourceMappingURL=motionPresets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motionPresets.js","sourceRoot":"","sources":["../../../src/implementations/v2/motionPresets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AAWjD,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CAChE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,CAAA;AAErF,MAAM,gBAAgB,GAAG,CAAC,SAAiB,EAAE,SAAiB,EAAE,EAAgC,EAAE,CACjG,MAAM,CAAC,WAAW,CACjB,MAAM,CAAC,OAAO,CAAC,SAAS,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,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAEpF,wNAAwN;AACxN,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAwB,EAAkB,EAAE,CAAC,CAAC;IACrF,GAAG,QAAQ;IACX,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;IAC9E,GAAG,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,CAAC;IACtF,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzD,GAAG,WAAW;QACd,GAAG,CAAC,WAAW,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7E,GAAG,CAAC,WAAW,CAAC,SAAS,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;KACrF,CAAC,CAAC;CACH,CAAC,CAAA"}
package/dist/service.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { InteractionsService } from './implementations/interactionsService';
2
2
  export declare const definition: string & {
3
3
  __api: import("./definition").IInteractionsService;
4
- __config: import("@wix/interact").InteractConfig;
4
+ __config: import("./definition").IInteractionsServiceConfig;
5
5
  isServiceDefinition?: boolean;
6
6
  } & import("./definition").IInteractionsService;
7
7
  export default InteractionsService;
@@ -1,2 +1,2 @@
1
1
  export type { IInteractionsService, IInteractionsServiceConfig, IInteractionsDefinition } from '../definition';
2
- export type { InteractConfig } from '@wix/interact';
2
+ export type { InteractConfig } from '@wix/interact-v2';
@@ -1,3 +1,3 @@
1
1
  {
2
- "main": "../cjs/build/implementations/index.js"
2
+ "main": "../cjs/build/implementations/index.js"
3
3
  }
package/package.json CHANGED
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-service-interactions",
3
- "version": "1.0.12",
4
- "main": "cjs/build/index.js",
5
- "module": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "1.0.14",
7
4
  "license": "UNLICENSED",
8
5
  "files": [
9
6
  "dist",
@@ -15,6 +12,10 @@
15
12
  "!doc.md",
16
13
  "!**/*.tsbuildinfo"
17
14
  ],
15
+ "sideEffects": false,
16
+ "main": "cjs/build/index.js",
17
+ "module": "dist/index.js",
18
+ "types": "dist/index.d.ts",
18
19
  "exports": {
19
20
  ".": {
20
21
  "types": "./dist/index.d.ts",
@@ -42,19 +43,30 @@
42
43
  "require": "./cjs/build/service.js"
43
44
  }
44
45
  },
46
+ "publishConfig": {
47
+ "registry": "https://registry.npmjs.org/",
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
52
+ "lint": "yarn run -T lint:package $npm_package_name",
53
+ "test": "vitest --run && yarn test-type-check",
54
+ "test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
55
+ },
45
56
  "dependencies": {
46
57
  "@wix/interact": "^1.103.0",
47
58
  "@wix/interact-v2": "npm:@wix/interact@2.5.14",
48
59
  "@wix/motion": "2.1.14",
60
+ "@wix/motion-presets": "1.0.7",
49
61
  "@wix/services-manager": "^0.2.20",
50
62
  "@wix/services-manager-react": "^0.1.26",
51
- "@wix/site-service-device-info": "1.0.2",
52
- "@wix/site-service-experiments": "1.0.3",
53
- "@wix/site-service-head-appender": "1.0.1",
54
- "@wix/site-service-provide-css": "1.0.1",
55
- "@wix/static-service": "1.0.19",
56
- "@wix/viewer-service-pages": "1.0.11",
57
- "@wix/wix-motion-presets": "1.0.0"
63
+ "@wix/site-service-device-info": "1.0.3",
64
+ "@wix/site-service-experiments": "1.0.4",
65
+ "@wix/site-service-head-appender": "1.0.2",
66
+ "@wix/site-service-provide-css": "1.0.2",
67
+ "@wix/static-service": "1.0.20",
68
+ "@wix/viewer-service-pages": "1.0.12",
69
+ "@wix/wix-motion-presets": "1.2.0"
58
70
  },
59
71
  "devDependencies": {
60
72
  "@types/react": "^18.3.1",
@@ -67,18 +79,7 @@
67
79
  "peerDependencies": {
68
80
  "react": "^18.3.1"
69
81
  },
70
- "scripts": {
71
- "build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
72
- "lint": "yarn run -T lint:package $npm_package_name",
73
- "test": "vitest --run && yarn test-type-check",
74
- "test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
75
- },
76
82
  "publishUnscoped": false,
77
- "publishConfig": {
78
- "registry": "https://registry.npmjs.org/",
79
- "access": "public"
80
- },
81
- "sideEffects": false,
82
83
  "wix": {
83
84
  "artifact": {
84
85
  "groupId": "com.wixpress.npm",
@@ -95,5 +96,5 @@
95
96
  ]
96
97
  }
97
98
  },
98
- "falconPackageHash": "5d2ddb6f5c28f87858a9ccd9f053a9c022831e4a5d61c58eb1269947"
99
+ "falconPackageHash": "a8d648625df67e046c3aa93cd0880a79ca1c94237614a1b4bf703080"
99
100
  }
@@ -1,15 +1,32 @@
1
1
  import { defineStaticService } from '@wix/static-service'
2
2
  import type { StaticServiceDefinition } from '@wix/static-service'
3
- import type { InteractConfig } from '@wix/interact'
3
+ import type { InteractConfig } from '@wix/interact-v2'
4
4
 
5
- export type IInteractionsServiceConfig = InteractConfig
5
+ export type { InteractConfig }
6
+
7
+ export type InteractStyleRule = {
8
+ key?: string
9
+ selector?: string
10
+ '@media'?: string
11
+ '@container'?: string
12
+ '@supports'?: string
13
+ properties: Record<string, string>
14
+ }
15
+
16
+ export type InteractConfigEntry = {
17
+ namespace?: string
18
+ interact: InteractConfig
19
+ styles?: InteractStyleRule[]
20
+ }
21
+
22
+ export type IInteractionsServiceConfig = InteractConfig | { entries: InteractConfigEntry[] }
6
23
 
7
24
  export interface IInteractionsService {
8
- hasInteractions: (path: string) => boolean
25
+ hasInteractions: (path: string) => boolean
9
26
  }
10
27
 
11
28
  export type IInteractionsDefinition = StaticServiceDefinition<IInteractionsService, IInteractionsServiceConfig>
12
29
 
13
30
  export const InteractionsDefinition = defineStaticService<IInteractionsService, IInteractionsServiceConfig>(
14
- '@wix/site-service-interactions'
31
+ '@wix/site-service-interactions'
15
32
  )
@@ -1,25 +1,25 @@
1
1
  import React from 'react'
2
2
  import type { FunctionComponent } from 'react'
3
- import type { InteractConfig } from '@wix/interact'
3
+ import type { InteractConfig } from '@wix/interact-v2'
4
4
  import { getInteractionsScriptContent } from './interactionsScriptContent'
5
5
  import { reviveScriptElement } from './reviveScriptElement'
6
6
 
7
7
  export const createInteractionsScriptElement =
8
- (config: InteractConfig, isReducedMotion: boolean, pageId: string): FunctionComponent =>
9
- () => {
10
- const configId = `interactions-config-${pageId}`
11
- const interactionsScriptContent = getInteractionsScriptContent(configId, isReducedMotion)
8
+ (config: InteractConfig, isReducedMotion: boolean, pageId: string): FunctionComponent =>
9
+ () => {
10
+ const configId = `interactions-config-${pageId}`
11
+ const interactionsScriptContent = getInteractionsScriptContent(configId, isReducedMotion)
12
12
 
13
- return (
14
- <>
15
- <script type="application/json" id={configId}>
16
- {encodeURIComponent(JSON.stringify(config))}
17
- </script>
18
- {/* In SSR the parser creates this and runs it. On the client React creates a script
13
+ return (
14
+ <>
15
+ <script type="application/json" id={configId}>
16
+ {encodeURIComponent(JSON.stringify(config))}
17
+ </script>
18
+ {/* In SSR the parser creates this and runs it. On the client React creates a script
19
19
  that can never execute, so the ref swaps in one that can. */}
20
- <script type="module" id={`interactions-loader-${pageId}`} ref={reviveScriptElement}>
21
- {interactionsScriptContent}
22
- </script>
23
- </>
24
- )
25
- }
20
+ <script type="module" id={`interactions-loader-${pageId}`} ref={reviveScriptElement}>
21
+ {interactionsScriptContent}
22
+ </script>
23
+ </>
24
+ )
25
+ }
@@ -0,0 +1,103 @@
1
+ import type { InteractConfig, InteractConfigEntry, IInteractionsServiceConfig } from '../definition'
2
+ import { aliasLegacyNamedEffects } from './v2/motionPresets'
3
+
4
+ export const REACTIONS_NAMESPACE = 'reactions'
5
+
6
+ type Interaction = InteractConfig['interactions'][number]
7
+ type Sequence = NonNullable<Interaction['sequences']>[number]
8
+ type KeyedEffect = { key?: string; effectId?: string }
9
+
10
+ export const getInteractConfigEntries = (config: IInteractionsServiceConfig): InteractConfigEntry[] =>
11
+ 'entries' in config ? config.entries : [{ interact: config, namespace: REACTIONS_NAMESPACE }]
12
+
13
+ export const getResolvedConfigEntries = (config: IInteractionsServiceConfig): InteractConfigEntry[] =>
14
+ getInteractConfigEntries(config).map((entry) =>
15
+ entry.namespace === REACTIONS_NAMESPACE ? { ...entry, interact: aliasLegacyNamedEffects(entry.interact) } : entry
16
+ )
17
+
18
+ /** An `effectId` points at `interact.effects`, which is where a reactions effect keeps its key. */
19
+ const resolveEffectKey = (interact: InteractConfig, effect: KeyedEffect): string | undefined =>
20
+ effect.key ?? (effect.effectId ? interact.effects?.[effect.effectId]?.key : undefined)
21
+
22
+ const addEffectKeys = (keys: Set<string>, interact: InteractConfig, effects: readonly KeyedEffect[] = []) => {
23
+ for (const effect of effects) {
24
+ const key = resolveEffectKey(interact, effect)
25
+ if (key) {
26
+ keys.add(key)
27
+ }
28
+ }
29
+ }
30
+
31
+ /** A `sequenceId` reference has no inline effects; resolve it against `interact.sequences`. */
32
+ const getSequenceEffects = (interact: InteractConfig, sequence: Sequence): readonly KeyedEffect[] =>
33
+ 'effects' in sequence ? sequence.effects : (interact.sequences?.[sequence.sequenceId]?.effects ?? [])
34
+
35
+ const getInteractionKeys = (interact: InteractConfig, interaction: Interaction): Set<string> => {
36
+ const keys = new Set<string>([interaction.key])
37
+ addEffectKeys(keys, interact, interaction.effects)
38
+ for (const sequence of interaction.sequences ?? []) {
39
+ addEffectKeys(keys, interact, getSequenceEffects(interact, sequence))
40
+ }
41
+ return keys
42
+ }
43
+
44
+ export const getInteractiveKeys = ({ interact }: InteractConfigEntry): Set<string> => {
45
+ const keys = new Set<string>()
46
+
47
+ for (const interaction of interact.interactions) {
48
+ getInteractionKeys(interact, interaction).forEach((key) => keys.add(key))
49
+ }
50
+
51
+ return keys
52
+ }
53
+
54
+ const dropOverriddenKeys = (entry: InteractConfigEntry, overriddenKeys: Set<string>): InteractConfigEntry => {
55
+ const { interact } = entry
56
+
57
+ return {
58
+ ...entry,
59
+ interact: {
60
+ ...interact,
61
+ interactions: interact.interactions.filter(
62
+ (interaction) => ![...getInteractionKeys(interact, interaction)].some((key) => overriddenKeys.has(key))
63
+ ),
64
+ },
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Interact resolves a custom-element key to the first instance containing that key, so a key shared
70
+ * by two entries would silently drop one of them. Experience entries own the keys they declare:
71
+ * whatever they claim is stripped from the reactions entry by dropping whole interactions whose
72
+ * resolved keys overlap. Top-level effect and sequence libraries are left intact. A collision between two
73
+ * experience entries stays an error, since neither of them is authoritative.
74
+ */
75
+ export const resolveInteractKeyConflicts = (entries: InteractConfigEntry[]): InteractConfigEntry[] => {
76
+ const owners = new Map<string, string>()
77
+
78
+ entries.forEach((entry, index) => {
79
+ if (entry.namespace === REACTIONS_NAMESPACE) {
80
+ return
81
+ }
82
+ const owner = entry.namespace ?? `entry-${index}`
83
+ for (const key of getInteractiveKeys(entry)) {
84
+ const existingOwner = owners.get(key)
85
+ if (existingOwner !== undefined) {
86
+ throw new Error(
87
+ `Interactions config key "${key}" is shared by "${existingOwner}" and "${owner}". ` +
88
+ 'Keys must be unique across config entries.'
89
+ )
90
+ }
91
+ owners.set(key, owner)
92
+ }
93
+ })
94
+
95
+ if (!owners.size) {
96
+ return entries
97
+ }
98
+
99
+ const overriddenKeys = new Set(owners.keys())
100
+ return entries.map((entry) =>
101
+ entry.namespace === REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys) : entry
102
+ )
103
+ }