@wix/site-service-interactions 1.0.9 → 1.0.10

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 (74) hide show
  1. package/cjs/build/implementations/coreInteractions.js +34 -26
  2. package/cjs/build/implementations/coreInteractions.js.map +1 -1
  3. package/cjs/build/implementations/stylesToAdd.d.ts +1 -1
  4. package/cjs/build/implementations/stylesToAdd.js +1 -1
  5. package/cjs/build/implementations/v2/InteractionsScriptElement.d.ts +3 -0
  6. package/cjs/build/implementations/v2/InteractionsScriptElement.js +33 -0
  7. package/cjs/build/implementations/v2/InteractionsScriptElement.js.map +1 -0
  8. package/cjs/build/implementations/v2/cdnUrls.d.ts +2 -0
  9. package/cjs/build/implementations/v2/cdnUrls.js +6 -0
  10. package/cjs/build/implementations/v2/cdnUrls.js.map +1 -0
  11. package/cjs/build/implementations/v2/clickTriggerCss.d.ts +3 -0
  12. package/cjs/build/implementations/v2/clickTriggerCss.js +35 -0
  13. package/cjs/build/implementations/v2/clickTriggerCss.js.map +1 -0
  14. package/cjs/build/implementations/v2/configCss.d.ts +3 -0
  15. package/cjs/build/implementations/v2/configCss.js +15 -0
  16. package/cjs/build/implementations/v2/configCss.js.map +1 -0
  17. package/cjs/build/implementations/v2/configStyleHeadContent.d.ts +1 -0
  18. package/cjs/build/implementations/v2/configStyleHeadContent.js +16 -0
  19. package/cjs/build/implementations/v2/configStyleHeadContent.js.map +1 -0
  20. package/cjs/build/implementations/v2/interactionsScriptContent.d.ts +9 -0
  21. package/cjs/build/implementations/v2/interactionsScriptContent.js +52 -0
  22. package/cjs/build/implementations/v2/interactionsScriptContent.js.map +1 -0
  23. package/cjs/build/implementations/v2/motionPresets.d.ts +13 -0
  24. package/cjs/build/implementations/v2/motionPresets.js +54 -0
  25. package/cjs/build/implementations/v2/motionPresets.js.map +1 -0
  26. package/cjs/build/implementations/v2/namedEffectTypes.d.ts +2 -0
  27. package/cjs/build/implementations/v2/namedEffectTypes.js +42 -0
  28. package/cjs/build/implementations/v2/namedEffectTypes.js.map +1 -0
  29. package/cjs/build/implementations/v2/registerConfigEffects.d.ts +6 -0
  30. package/cjs/build/implementations/v2/registerConfigEffects.js +27 -0
  31. package/cjs/build/implementations/v2/registerConfigEffects.js.map +1 -0
  32. package/dist/implementations/coreInteractions.js +30 -22
  33. package/dist/implementations/coreInteractions.js.map +1 -1
  34. package/dist/implementations/stylesToAdd.d.ts +1 -1
  35. package/dist/implementations/stylesToAdd.js +1 -1
  36. package/dist/implementations/v2/InteractionsScriptElement.d.ts +3 -0
  37. package/dist/implementations/v2/InteractionsScriptElement.js +26 -0
  38. package/dist/implementations/v2/InteractionsScriptElement.js.map +1 -0
  39. package/dist/implementations/v2/cdnUrls.d.ts +2 -0
  40. package/dist/implementations/v2/cdnUrls.js +3 -0
  41. package/dist/implementations/v2/cdnUrls.js.map +1 -0
  42. package/dist/implementations/v2/clickTriggerCss.d.ts +3 -0
  43. package/dist/implementations/v2/clickTriggerCss.js +31 -0
  44. package/dist/implementations/v2/clickTriggerCss.js.map +1 -0
  45. package/dist/implementations/v2/configCss.d.ts +3 -0
  46. package/dist/implementations/v2/configCss.js +11 -0
  47. package/dist/implementations/v2/configCss.js.map +1 -0
  48. package/dist/implementations/v2/configStyleHeadContent.d.ts +1 -0
  49. package/dist/implementations/v2/configStyleHeadContent.js +12 -0
  50. package/dist/implementations/v2/configStyleHeadContent.js.map +1 -0
  51. package/dist/implementations/v2/interactionsScriptContent.d.ts +9 -0
  52. package/dist/implementations/v2/interactionsScriptContent.js +47 -0
  53. package/dist/implementations/v2/interactionsScriptContent.js.map +1 -0
  54. package/dist/implementations/v2/motionPresets.d.ts +13 -0
  55. package/dist/implementations/v2/motionPresets.js +16 -0
  56. package/dist/implementations/v2/motionPresets.js.map +1 -0
  57. package/dist/implementations/v2/namedEffectTypes.d.ts +2 -0
  58. package/dist/implementations/v2/namedEffectTypes.js +38 -0
  59. package/dist/implementations/v2/namedEffectTypes.js.map +1 -0
  60. package/dist/implementations/v2/registerConfigEffects.d.ts +6 -0
  61. package/dist/implementations/v2/registerConfigEffects.js +23 -0
  62. package/dist/implementations/v2/registerConfigEffects.js.map +1 -0
  63. package/package.json +8 -5
  64. package/src/implementations/coreInteractions.ts +36 -25
  65. package/src/implementations/stylesToAdd.ts +1 -1
  66. package/src/implementations/v2/InteractionsScriptElement.tsx +42 -0
  67. package/src/implementations/v2/cdnUrls.ts +4 -0
  68. package/src/implementations/v2/clickTriggerCss.ts +44 -0
  69. package/src/implementations/v2/configCss.ts +13 -0
  70. package/src/implementations/v2/configStyleHeadContent.ts +12 -0
  71. package/src/implementations/v2/interactionsScriptContent.ts +61 -0
  72. package/src/implementations/v2/motionPresets.ts +26 -0
  73. package/src/implementations/v2/namedEffectTypes.ts +52 -0
  74. package/src/implementations/v2/registerConfigEffects.ts +31 -0
@@ -1,63 +1,71 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.coreInteractions = void 0;
4
- const interact_1 = require("@wix/interact");
4
+ const web_1 = require("@wix/interact/web");
5
5
  const definition_1 = require("@wix/site-service-device-info/definition");
6
6
  const definition_2 = require("@wix/site-service-experiments/definition");
7
- const definition_3 = require("@wix/site-service-rendering-context/definition");
8
- const definition_4 = require("@wix/site-service-pages/definition");
7
+ const definition_3 = require("@wix/site-service-pages/definition");
8
+ const definition_4 = require("@wix/site-service-head-appender/definition");
9
9
  const provide_component_1 = require("@wix/services-manager-react/core-services/provide-component");
10
10
  const InteractionsScriptElement_1 = require("./InteractionsScriptElement");
11
+ const InteractionsScriptElement_2 = require("./v2/InteractionsScriptElement");
12
+ const configCss_1 = require("./v2/configCss");
13
+ const configStyleHeadContent_1 = require("./v2/configStyleHeadContent");
14
+ const interactionsScriptContent_1 = require("./v2/interactionsScriptContent");
15
+ const registerConfigEffects_1 = require("./v2/registerConfigEffects");
11
16
  const initInteract = (config, isReducedMotion) => {
12
- interact_1.Interact.forceReducedMotion = isReducedMotion;
13
- interact_1.Interact.setup({
17
+ // The bundled runtime is v2, where named effects come from a separate package the loader
18
+ // script imports on the SSR path. Here they have to be registered before create().
19
+ (0, registerConfigEffects_1.registerConfigEffects)(config);
20
+ web_1.Interact.forceReducedMotion = isReducedMotion;
21
+ web_1.Interact.setup({
14
22
  scrollOptionsGetter: () => globalThis.document.getElementById('site-root'),
15
23
  allowA11yTriggers: true,
16
24
  viewEnter: {
17
25
  useSafeViewEnter: true,
18
26
  },
19
27
  });
20
- interact_1.Interact.create(config);
28
+ web_1.Interact.create(config);
21
29
  };
22
- const tryInitInteractInSsr = (config, isReducedMotion, getService) => {
23
- const hasInteractions = config.interactions?.length > 0;
24
- if (!hasInteractions) {
25
- return false;
30
+ const initRuntime = (config, isReducedMotion, getService, useV2) => {
31
+ if (!config.interactions?.length) {
32
+ return;
26
33
  }
27
- const { currentPage } = getService(definition_4.PagesDefinition);
28
- const pageId = currentPage?.id;
34
+ const pageId = getService(definition_3.PagesDefinition).currentPage?.id;
29
35
  if (!pageId) {
30
- return false;
36
+ return;
31
37
  }
32
38
  const { addTopComponent } = getService(provide_component_1.ProvideComponentServiceDefinition);
33
- const ssrScriptElement = (0, InteractionsScriptElement_1.createInteractionsScriptElement)(config, isReducedMotion, pageId);
34
- addTopComponent(ssrScriptElement);
35
- return true;
39
+ if (!useV2) {
40
+ addTopComponent((0, InteractionsScriptElement_1.createInteractionsScriptElement)(config, isReducedMotion, pageId));
41
+ return;
42
+ }
43
+ // Both belong in the head: the preload links only help while the document is still parsing,
44
+ // and the generated CSS hides elements before their entrance effect, so it has to apply
45
+ // before the body renders.
46
+ const css = (0, configCss_1.getV2ConfigCss)(config).trim();
47
+ getService(definition_4.HeadAppenderDefinition).setHead((0, interactionsScriptContent_1.getV2ModulePreloadHeadContent)(config) + (css ? (0, configStyleHeadContent_1.getV2ConfigStyleHeadContent)(css) : ''));
48
+ addTopComponent((0, InteractionsScriptElement_2.createV2InteractionsScriptElement)(config, isReducedMotion, pageId));
36
49
  };
37
50
  const getInteractiveComps = (interactions) => interactions.reduce((acc, { key, effects }) => {
38
51
  // add trigger comp
39
52
  acc.add(key);
40
53
  // add reaction comps
41
54
  // there must be a key
42
- effects.forEach(({ key }) => acc.add(key));
55
+ effects?.forEach(({ key }) => acc.add(key));
43
56
  return acc;
44
57
  }, new Set());
45
58
  const coreInteractions = (config, getService) => {
46
59
  const { reducedMotion: isReducedMotion } = getService(definition_1.DeviceInfoDefinition);
47
60
  const { isOpen } = getService(definition_2.ExperimentsDefinition);
48
- const { SSR } = getService(definition_3.RenderingContextDefinition);
49
- const isSSRExperimentOpen = isOpen('specs.thunderbolt.interactionsInSsr');
50
- if (isSSRExperimentOpen) {
61
+ if (isOpen('specs.thunderbolt.interactionsInSsr')) {
51
62
  // Emits the config and loader scripts. Works in both environments: SSR serves markup the
52
63
  // parser executes, and on the client the loader's ref revives it into a script that runs —
53
64
  // which is what pages rendered only on the client (password-protected / members-only,
54
65
  // client-side navigation) need, since they never get a server-rendered document.
55
- const didInitInteractInSsr = tryInitInteractInSsr(config, isReducedMotion, getService);
56
- // Fall back to direct init on the client if the script element could not be set up
57
- // (e.g. no pageId or no interactions).
58
- if (!didInitInteractInSsr && !SSR) {
59
- initInteract(config, isReducedMotion);
60
- }
66
+ // v2 is only reachable from here: it ships as a loader script plus generated CSS, both of
67
+ // which exist only on this path.
68
+ initRuntime(config, isReducedMotion, getService, isOpen('specs.thunderbolt.vsm_interactions_v2'));
61
69
  }
62
70
  else {
63
71
  initInteract(config, isReducedMotion);
@@ -1 +1 @@
1
- {"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../../src/implementations/coreInteractions.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,yEAA+E;AAC/E,yEAAgF;AAChF,+EAA2F;AAC3F,mEAAoE;AACpE,mGAA+G;AAE/G,2EAA6E;AAE7E,MAAM,YAAY,GAAG,CAAC,MAAsB,EAAE,eAAwB,EAAE,EAAE;IACtE,mBAAQ,CAAC,kBAAk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AAE,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAI,CAAC,CAAC,CAAA;IAE3C,OAAO,GAAG,CAAA;AACd,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAA;AAElB,MAAM,gBAAgB,GAAG,CAAC,MAAsB,EAAE,UAAyC,EAAE,EAAE;IAClG,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,UAAU,CAAC,iCAAoB,CAAC,CAAA;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAqB,CAAC,CAAA;IACpD,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,uCAA0B,CAAC,CAAA;IAEtD,MAAM,mBAAmB,GAAG,MAAM,CAAC,qCAAqC,CAAC,CAAA;IACzE,IAAI,mBAAmB,EAAE,CAAC;QACtB,yFAAyF;QACzF,2FAA2F;QAC3F,sFAAsF;QACtF,iFAAiF;QACjF,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,CAAC,CAAA;QAEtF,mFAAmF;QACnF,uCAAuC;QACvC,IAAI,CAAC,oBAAoB,IAAI,CAAC,GAAG,EAAE,CAAC;YAChC,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;QACzC,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACzC,CAAC;IAED,OAAO;QACH,gBAAgB,EAAE,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC;KAC7D,CAAA;AACL,CAAC,CAAA;AAzBY,QAAA,gBAAgB,oBAyB5B"}
1
+ {"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../../src/implementations/coreInteractions.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAE5C,yEAA+E;AAC/E,yEAAgF;AAChF,mEAAoE;AACpE,2EAAmF;AACnF,mGAA+G;AAE/G,2EAA6E;AAC7E,8EAAkF;AAClF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MAAM,CAAC,YAAY,CAAC;KAC7D,CAAA;AACL,CAAC,CAAA;AAnBY,QAAA,gBAAgB,oBAmB5B"}
@@ -1,2 +1,2 @@
1
- export declare const wixInteractElementCss = "\n wix-interact-element {\n display: contents;\n }\n ";
1
+ export declare const wixInteractElementCss = "\n interact-element {\n display: contents;\n }\n ";
2
2
  export declare const hasClickTriggerCss = "\n .has-click-trigger {\n cursor: pointer;\n }\n ";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasClickTriggerCss = exports.wixInteractElementCss = void 0;
4
4
  exports.wixInteractElementCss = `
5
- wix-interact-element {
5
+ interact-element {
6
6
  display: contents;
7
7
  }
8
8
  `;
@@ -0,0 +1,3 @@
1
+ import type { FunctionComponent } from 'react';
2
+ import type { InteractConfig } from '@wix/interact';
3
+ export declare const createV2InteractionsScriptElement: (config: InteractConfig, isReducedMotion: boolean, pageId: string) => FunctionComponent;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createV2InteractionsScriptElement = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const reviveScriptElement_1 = require("../reviveScriptElement");
9
+ const interactionsScriptContent_1 = require("./interactionsScriptContent");
10
+ const DANGEROUSLY_SET_INNER_HTML = ['dangerously', 'Set', 'Inner', 'HTML'];
11
+ /**
12
+ * The config is written as raw markup, so a `</script` inside any string value would close the
13
+ * element early. `\u003c` is valid JSON that `JSON.parse` reads back as `<`.
14
+ */
15
+ const serializeConfigForScriptElement = (config) => JSON.stringify(config).replace(/</g, '\\u003c');
16
+ const createV2InteractionsScriptElement = (config, isReducedMotion, pageId) => () => {
17
+ // This ID is also interpolated into raw module-script text. Percent-encoding removes
18
+ // script delimiters and template-literal syntax while keeping the ID deterministic.
19
+ const safePageId = encodeURIComponent(pageId);
20
+ const configId = `interactions-config-${safePageId}`;
21
+ const interactionsScriptContent = (0, interactionsScriptContent_1.getV2InteractionsScriptContent)(config, configId, isReducedMotion);
22
+ const configProps = {
23
+ [DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: serializeConfigForScriptElement(config) },
24
+ };
25
+ const loaderProps = {
26
+ [DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: interactionsScriptContent },
27
+ };
28
+ return (react_1.default.createElement(react_1.default.Fragment, null,
29
+ react_1.default.createElement("script", { type: "application/json", id: configId, ...configProps }),
30
+ react_1.default.createElement("script", { type: "module", id: `interactions-loader-${safePageId}`, ref: reviveScriptElement_1.reviveScriptElement, ...loaderProps })));
31
+ };
32
+ exports.createV2InteractionsScriptElement = createV2InteractionsScriptElement;
33
+ //# sourceMappingURL=InteractionsScriptElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractionsScriptElement.js","sourceRoot":"","sources":["../../../../src/implementations/v2/InteractionsScriptElement.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAGzB,gEAA4D;AAC5D,2EAA4E;AAE5E,MAAM,0BAA0B,GAAG,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAE1E;;;GAGG;AACH,MAAM,+BAA+B,GAAG,CAAC,MAAsB,EAAU,EAAE,CACvE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AAE5C,MAAM,iCAAiC,GAC1C,CAAC,MAAsB,EAAE,eAAwB,EAAE,MAAc,EAAqB,EAAE,CACxF,GAAG,EAAE;IACD,qFAAqF;IACrF,oFAAoF;IACpF,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAC7C,MAAM,QAAQ,GAAG,uBAAuB,UAAU,EAAE,CAAA;IACpD,MAAM,yBAAyB,GAAG,IAAA,0DAA8B,EAAC,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAA;IACnG,MAAM,WAAW,GAAG;QAChB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE;KAC7F,CAAA;IACD,MAAM,WAAW,GAAG;QAChB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE;KAC/E,CAAA;IAED,OAAO,CACH;QACI,0CAAQ,IAAI,EAAC,kBAAkB,EAAC,EAAE,EAAE,QAAQ,KAAM,WAAW,GAAI;QACjE,0CACI,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,uBAAuB,UAAU,EAAE,EACvC,GAAG,EAAE,yCAAmB,KACpB,WAAW,GACjB,CACH,CACN,CAAA;AACL,CAAC,CAAA;AA1BQ,QAAA,iCAAiC,qCA0BzC"}
@@ -0,0 +1,2 @@
1
+ export declare const INTERACT_V2_IMPORT_URL = "https://cdn.jsdelivr.net/npm/@wix/interact@2/dist/es/web.min.js";
2
+ export declare const WIX_MOTION_PRESETS_IMPORT_URL = "https://static.parastorage.com/services/wix-motion-presets/dist/wix-motion-presets.esm.min.js";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WIX_MOTION_PRESETS_IMPORT_URL = exports.INTERACT_V2_IMPORT_URL = void 0;
4
+ exports.INTERACT_V2_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/interact@2/dist/es/web.min.js';
5
+ exports.WIX_MOTION_PRESETS_IMPORT_URL = 'https://static.parastorage.com/services/wix-motion-presets/dist/wix-motion-presets.esm.min.js';
6
+ //# sourceMappingURL=cdnUrls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,iEAAiE,CAAA;AAE1F,QAAA,6BAA6B,GACtC,+FAA+F,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
3
+ export declare const getClickTriggerCss: (config: InteractConfig) => string;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getClickTriggerCss = void 0;
4
+ const escapeCssAttr = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
5
+ /**
6
+ * Mirrors `@wix/interact` `getSelector(interaction, { asCombinator: true, useFirstChild: true })`
7
+ * plus the `[data-interact-key="…"]` prefix from `CSSRuleToString`.
8
+ */
9
+ const getInteractionSourceSelector = (interaction) => {
10
+ const { key, selector, listContainer, listItemSelector } = interaction;
11
+ const attrSelector = `[data-interact-key="${escapeCssAttr(key)}"]`;
12
+ if (listContainer) {
13
+ const itemFilter = listItemSelector ? ` > ${listItemSelector}` : '';
14
+ const inner = selector ? `${listContainer}${itemFilter} ${selector}` : `${listContainer}${itemFilter || ' > *'}`;
15
+ return `${attrSelector} ${inner}`;
16
+ }
17
+ if (selector) {
18
+ return `${attrSelector} ${selector}`;
19
+ }
20
+ return `${attrSelector} > :first-child`;
21
+ };
22
+ /** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
23
+ const getClickTriggerCss = (config) => {
24
+ const selectors = [
25
+ ...new Set(config.interactions
26
+ .filter(({ trigger }) => trigger === 'activate' || trigger === 'click')
27
+ .map(getInteractionSourceSelector)),
28
+ ];
29
+ if (!selectors.length) {
30
+ return '';
31
+ }
32
+ return selectors.map(selector => `${selector} {\ncursor: pointer;\n}`).join('\n');
33
+ };
34
+ exports.getClickTriggerCss = getClickTriggerCss;
35
+ //# sourceMappingURL=clickTriggerCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clickTriggerCss.js","sourceR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AC,SAAS,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,EAAE,CAAA;IACb,CAAC;IAED,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,yBAAyB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACrF,CAAC,CAAA;AAdY,QAAA,kBAAkB,sBAc9B"}
@@ -0,0 +1,3 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /** Register config-used presets, then emit animation FOUC CSS and click-trigger cursor rules. */
3
+ export declare const getV2ConfigCss: (config: InteractConfig) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getV2ConfigCss = void 0;
4
+ const interact_1 = require("@wix/interact");
5
+ const clickTriggerCss_1 = require("./clickTriggerCss");
6
+ const registerConfigEffects_1 = require("./registerConfigEffects");
7
+ /** Register config-used presets, then emit animation FOUC CSS and click-trigger cursor rules. */
8
+ const getV2ConfigCss = (config) => {
9
+ (0, registerConfigEffects_1.registerConfigEffects)(config);
10
+ const animationCss = (0, interact_1.generate)(config, true).trim();
11
+ const clickCss = (0, clickTriggerCss_1.getClickTriggerCss)(config).trim();
12
+ return [animationCss, clickCss].filter(Boolean).join('\n');
13
+ };
14
+ exports.getV2ConfigCss = getV2ConfigCss;
15
+ //# sourceMappingURL=configCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,uDAAsD;AACtD,mEAA+D;AAE/D,iGAAiG;AAC1F,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC7D,IAAA,6CAAqB,EAAC,MAAM,CAAC,CAAA;IAC7B,MAAM,YAAY,GAAG,IAAA,mBAAQ,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;IAClD,MAAM,QAAQ,GAAG,IAAA,oCAAkB,EAAC,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;AANY,QAAA,cAAc,kBAM1B"}
@@ -0,0 +1 @@
1
+ export declare const getV2ConfigStyleHeadContent: (css: string) => string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getV2ConfigStyleHeadContent = void 0;
4
+ /**
5
+ * Head content is a raw HTML string, so anything tag-like in the generated CSS either closes the
6
+ * style element early or trips the head appender's script-tag guard, which throws. Nothing in CSS
7
+ * opens a tag: `<` appears only in media range queries, followed by a space or a digit. Cutting
8
+ * from the first `<` that could start a tag leaves valid CSS untouched.
9
+ */
10
+ const sanitizeCssForStyleElement = (css) => {
11
+ const tagIndex = css.search(/<[a-zA-Z/]/);
12
+ return tagIndex === -1 ? css : css.slice(0, tagIndex);
13
+ };
14
+ const getV2ConfigStyleHeadContent = (css) => `<style>${sanitizeCssForStyleElement(css)}</style>`;
15
+ exports.getV2ConfigStyleHeadContent = getV2ConfigStyleHeadContent;
16
+ //# sourceMappingURL=configStyleHeadContent.js.map
@@ -0,0 +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;AAEM,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA;AAA1G,QAAA,2BAA2B,+BAA+E"}
@@ -0,0 +1,9 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /**
3
+ * The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
4
+ * see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
5
+ * `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
6
+ * would download each module twice.
7
+ */
8
+ export declare const getV2ModulePreloadHeadContent: (config: InteractConfig) => string;
9
+ export declare const getV2InteractionsScriptContent: (config: InteractConfig, configId: string, isReducedMotion: boolean) => string;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getV2InteractionsScriptContent = exports.getV2ModulePreloadHeadContent = void 0;
4
+ const cdnUrls_1 = require("./cdnUrls");
5
+ const namedEffectTypes_1 = require("./namedEffectTypes");
6
+ const motionPresets_1 = require("./motionPresets");
7
+ const getPresetTypes = (config) => (0, motionPresets_1.filterKnownPresetTypes)((0, namedEffectTypes_1.collectNamedEffectTypes)(config));
8
+ const getModuleUrls = (presetTypes) => presetTypes.length > 0 ? [cdnUrls_1.INTERACT_V2_IMPORT_URL, cdnUrls_1.WIX_MOTION_PRESETS_IMPORT_URL] : [cdnUrls_1.INTERACT_V2_IMPORT_URL];
9
+ /**
10
+ * The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
11
+ * see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
12
+ * `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
13
+ * would download each module twice.
14
+ */
15
+ const getV2ModulePreloadHeadContent = (config) => getModuleUrls(getPresetTypes(config))
16
+ .map(url => `<link rel="modulepreload" href="${url}">`)
17
+ .join('');
18
+ exports.getV2ModulePreloadHeadContent = getV2ModulePreloadHeadContent;
19
+ const getV2InteractionsScriptContent = (config, configId, isReducedMotion) => {
20
+ const presetTypes = getPresetTypes(config);
21
+ const bindings = ['{ Interact }'];
22
+ const imports = getModuleUrls(presetTypes).map(url => `import(\`${url}\`)`);
23
+ if (presetTypes.length > 0) {
24
+ bindings.push(`{ ${presetTypes.join(', ')} }`);
25
+ }
26
+ const registerEffects = presetTypes.length > 0 ? ` Interact.registerEffects({ ${presetTypes.join(', ')} })` : undefined;
27
+ return [
28
+ `const configElement = document.getElementById(\`${configId}\`)`,
29
+ 'if (configElement) {',
30
+ ' const config = JSON.parse(configElement.textContent)',
31
+ ` const [${bindings.join(', ')}] = await Promise.all([`,
32
+ ...imports.map(importCall => ` ${importCall},`),
33
+ ' ])',
34
+ registerEffects,
35
+ ` Interact.forceReducedMotion = ${isReducedMotion}`,
36
+ ' Interact.setup({',
37
+ ' scrollOptionsGetter: function () {',
38
+ ' return document.getElementById(`site-root`)',
39
+ ' },',
40
+ ' allowA11yTriggers: true,',
41
+ ' viewEnter: {',
42
+ ' useSafeViewEnter: true,',
43
+ ' },',
44
+ ' })',
45
+ ' Interact.create(config)',
46
+ '}',
47
+ ]
48
+ .filter((line) => line !== undefined)
49
+ .join('\n');
50
+ };
51
+ exports.getV2InteractionsScriptContent = getV2InteractionsScriptContent;
52
+ //# sourceMappingURL=interactionsScriptContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../../../src/implementations/v2/interactionsScriptContent.ts"],"names":[],"mappings":";;;AACA,uCAAiF;AACjF,yDAA4D;AAC5D,mDAAwD;AAExD,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAY,EAAE,CAAC,IAAA,sCAAsB,EAAC,IAAA,0CAAuB,EAAC,MAAM,CAAC,CAAC,CAAA;AAEpH,MAAM,aAAa,GAAG,CAAC,WAAqB,EAAY,EAAE,CACtD,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gCAAsB,EAAE,uCAA6B,CAAC,CAAC,CAAC,C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,kBAAkB;QAClB,+BAA+B;QAC/B,QAAQ;QACR,MAAM;QACN,2BAA2B;QAC3B,GAAG;KACN;SACI,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC,CAAA;AAvCY,QAAA,8BAA8B,kCAuC1C"}
@@ -0,0 +1,13 @@
1
+ type EffectModule = {
2
+ web: unknown;
3
+ style?: unknown;
4
+ getNames: unknown;
5
+ };
6
+ export declare const motionPresets: Record<string, EffectModule>;
7
+ export declare const isKnownPresetType: (type: string) => boolean;
8
+ /**
9
+ * Preset names become bare JavaScript identifiers in the client loader. Filtering against the
10
+ * installed package prevents unknown names from creating invalid source or a failed import.
11
+ */
12
+ export declare const filterKnownPresetTypes: (types: string[]) => string[];
13
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.filterKnownPresetTypes = exports.isKnownPresetType = exports.motionPresets = void 0;
37
+ const allPresets = __importStar(require("@wix/wix-motion-presets"));
38
+ exports.motionPresets = allPresets;
39
+ const knownPresetTypes = new Set(Object.keys(exports.motionPresets));
40
+ const isKnownPresetType = (type) => knownPresetTypes.has(type);
41
+ exports.isKnownPresetType = isKnownPresetType;
42
+ /**
43
+ * Preset names become bare JavaScript identifiers in the client loader. Filtering against the
44
+ * installed package prevents unknown names from creating invalid source or a failed import.
45
+ */
46
+ const filterKnownPresetTypes = (types) => {
47
+ const unknown = types.filter(type => !(0, exports.isKnownPresetType)(type));
48
+ if (unknown.length > 0) {
49
+ console.warn(`Interactions: skipping unknown Wix motion preset type(s): ${unknown.join(', ')}`);
50
+ }
51
+ return types.filter(exports.isKnownPresetType);
52
+ };
53
+ exports.filterKnownPresetTypes = filterKnownPresetTypes;
54
+ //# sourceMappingURL=motionPresets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motionPresets.js","sourceRoot":"","sources":["../../../../src/implementations/v2/motionPresets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAqD;AAQxC,QAAA,aAAa,GAAiC,UAAqD,CAAA;AAEhH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAa,CAAC,CAAC,CAAA;AAErD,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAAzE,QAAA,iBAAiB,qBAAwD;AAEtF;;;GAGG;AACI,MAAM,sBAAsB,GAAG,CAAC,KAAe,EAAY,EAAE;IAChE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAA,yBAAiB,EAAC,IAAI,CAAC,CAAC,CAAA;IAC9D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,6DAA6D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACnG,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,yBAAiB,CAAC,CAAA;AAC1C,CAAC,CAAA;AAPY,QAAA,sBAAsB,0BAOlC"}
@@ -0,0 +1,2 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ export declare const collectNamedEffectTypes: (config: InteractConfig) => string[];
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectNamedEffectTypes = void 0;
4
+ /** Prefer the effects map; fall back to an inline named effect when an effect id misses. */
5
+ const resolveEffect = (config, effect) => {
6
+ if (!effect.effectId) {
7
+ return effect;
8
+ }
9
+ return config.effects?.[effect.effectId] ?? effect;
10
+ };
11
+ const readNamedEffectType = (effect) => {
12
+ if (!('namedEffect' in effect) || !effect.namedEffect) {
13
+ return undefined;
14
+ }
15
+ const { type } = effect.namedEffect;
16
+ return typeof type === 'string' ? type : undefined;
17
+ };
18
+ const collectNamedEffectTypes = (config) => {
19
+ const types = new Set();
20
+ const collectFromEffects = (effects) => {
21
+ for (const effect of effects) {
22
+ const type = readNamedEffectType(resolveEffect(config, effect));
23
+ if (type) {
24
+ types.add(type);
25
+ }
26
+ }
27
+ };
28
+ for (const interaction of config.interactions) {
29
+ collectFromEffects(interaction.effects ?? []);
30
+ for (const sequence of interaction.sequences ?? []) {
31
+ if ('effects' in sequence) {
32
+ collectFromEffects(sequence.effects);
33
+ continue;
34
+ }
35
+ const referencedSequence = config.sequences?.[sequence.sequenceId];
36
+ collectFromEffects(referencedSequence?.effects ?? []);
37
+ }
38
+ }
39
+ return [...types].sort();
40
+ };
41
+ exports.collectNamedEffectTypes = collectNamedEffectTypes;
42
+ //# sourceMappingURL=namedEffectTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namedEffectTypes.js","sourceRoot":"","sources":["../../../../src/implementations/v2/namedEffectTypes.ts"],"names":[],"mappings":";;;AAMA,4FAA4F;AAC5F,MAAM,aAAa,GAAG,CAAC,MAAsB,EAAE,MAAoB,EAAsB,EAAE;IACvF,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAA;AACtD,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,MAA0B,EAAsB,EAAE;IAC3E,IAAI,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACpD,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,WAAW,CAAA;IACnC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC,CAAA;AAEM,MAAM,uBAAuB,GAAG,CAAC,MAAsB,EAAY,EAAE;IACxE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAE/B,MAAM,kBAAkB,GAAG,CAAC,OAAuB,EAAE,EAAE;QACnD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,mBAAmB,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;YAC/D,IAAI,IAAI,EAAE,CAAC;gBACP,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACnB,CAAC;QACL,CAAC;IACL,CAAC,CAAA;IAED,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC5C,kBAAkB,CAAC,WAAW,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;QAE7C,KAAK,MAAM,QAAQ,IAAI,WAAW,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;YACjD,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;gBACxB,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;gBACpC,SAAQ;YACZ,CAAC;YAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;YAClE,kBAAkB,CAAC,kBAAkB,EAAE,OAAO,IAAI,EAAE,CAAC,CAAA;QACzD,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAA;AAC5B,CAAC,CAAA;AA3BY,QAAA,uBAAuB,2BA2BnC"}
@@ -0,0 +1,6 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /**
3
+ * A named effect only runs once its preset is registered, so every path that reaches
4
+ * `Interact.create` or `generate` has to register the config's presets first.
5
+ */
6
+ export declare const registerConfigEffects: (config: InteractConfig) => void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerConfigEffects = void 0;
4
+ const interact_1 = require("@wix/interact");
5
+ const namedEffectTypes_1 = require("./namedEffectTypes");
6
+ const motionPresets_1 = require("./motionPresets");
7
+ // Interact's effect registry is process-global, so mirror it across repeated SSR renders.
8
+ const registeredTypes = new Set();
9
+ /**
10
+ * A named effect only runs once its preset is registered, so every path that reaches
11
+ * `Interact.create` or `generate` has to register the config's presets first.
12
+ */
13
+ const registerConfigEffects = (config) => {
14
+ const presetsToRegister = {};
15
+ for (const type of (0, motionPresets_1.filterKnownPresetTypes)((0, namedEffectTypes_1.collectNamedEffectTypes)(config))) {
16
+ if (registeredTypes.has(type)) {
17
+ continue;
18
+ }
19
+ presetsToRegister[type] = motionPresets_1.motionPresets[type];
20
+ }
21
+ if (Object.keys(presetsToRegister).length > 0) {
22
+ interact_1.Interact.registerEffects(presetsToRegister);
23
+ Object.keys(presetsToRegister).forEach(type => registeredTypes.add(type));
24
+ }
25
+ };
26
+ exports.registerConfigEffects = registerConfigEffects;
27
+ //# sourceMappingURL=registerConfigEffects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerConfigEffects.js","sourceRoot":"","sources":["../../../../src/implementations/v2/registerConfigEffects.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,yDAA4D;AAC5D,mDAAuE;AAKvE,0FAA0F;AAC1F,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAA;AAEzC;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,MAAsB,EAAE,EAAE;IAC5D,MAAM,iBAAiB,GAAmB,EAAE,CAAA;IAE5C,KAAK,MAAM,IAAI,IAAI,IAAA,sCAAsB,EAAC,IAAA,0CAAuB,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACzE,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,SAAQ;QACZ,CAAC;QAED,iBAAiB,CAAC,IAAI,CAAC,GAAG,6BAAa,CAAC,IAAI,CAAiB,CAAA;IACjE,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,mBAAQ,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;AACL,CAAC,CAAA;AAfY,QAAA,qBAAqB,yBAejC"}
@@ -1,11 +1,19 @@
1
- import { Interact } from '@wix/interact';
1
+ import { Interact } from '@wix/interact/web';
2
2
  import { DeviceInfoDefinition } from '@wix/site-service-device-info/definition';
3
3
  import { ExperimentsDefinition } from '@wix/site-service-experiments/definition';
4
- import { RenderingContextDefinition } from '@wix/site-service-rendering-context/definition';
5
4
  import { PagesDefinition } from '@wix/site-service-pages/definition';
5
+ import { HeadAppenderDefinition } from '@wix/site-service-head-appender/definition';
6
6
  import { ProvideComponentServiceDefinition } from '@wix/services-manager-react/core-services/provide-component';
7
7
  import { createInteractionsScriptElement } from './InteractionsScriptElement';
8
+ import { createV2InteractionsScriptElement } from './v2/InteractionsScriptElement';
9
+ import { getV2ConfigCss } from './v2/configCss';
10
+ import { getV2ConfigStyleHeadContent } from './v2/configStyleHeadContent';
11
+ import { getV2ModulePreloadHeadContent } from './v2/interactionsScriptContent';
12
+ import { registerConfigEffects } from './v2/registerConfigEffects';
8
13
  const initInteract = (config, isReducedMotion) => {
14
+ // The bundled runtime is v2, where named effects come from a separate package the loader
15
+ // script imports on the SSR path. Here they have to be registered before create().
16
+ registerConfigEffects(config);
9
17
  Interact.forceReducedMotion = isReducedMotion;
10
18
  Interact.setup({
11
19
  scrollOptionsGetter: () => globalThis.document.getElementById('site-root'),
@@ -16,45 +24,45 @@ const initInteract = (config, isReducedMotion) => {
16
24
  });
17
25
  Interact.create(config);
18
26
  };
19
- const tryInitInteractInSsr = (config, isReducedMotion, getService) => {
20
- const hasInteractions = config.interactions?.length > 0;
21
- if (!hasInteractions) {
22
- return false;
27
+ const initRuntime = (config, isReducedMotion, getService, useV2) => {
28
+ if (!config.interactions?.length) {
29
+ return;
23
30
  }
24
- const { currentPage } = getService(PagesDefinition);
25
- const pageId = currentPage?.id;
31
+ const pageId = getService(PagesDefinition).currentPage?.id;
26
32
  if (!pageId) {
27
- return false;
33
+ return;
28
34
  }
29
35
  const { addTopComponent } = getService(ProvideComponentServiceDefinition);
30
- const ssrScriptElement = createInteractionsScriptElement(config, isReducedMotion, pageId);
31
- addTopComponent(ssrScriptElement);
32
- return true;
36
+ if (!useV2) {
37
+ addTopComponent(createInteractionsScriptElement(config, isReducedMotion, pageId));
38
+ return;
39
+ }
40
+ // Both belong in the head: the preload links only help while the document is still parsing,
41
+ // and the generated CSS hides elements before their entrance effect, so it has to apply
42
+ // before the body renders.
43
+ const css = getV2ConfigCss(config).trim();
44
+ getService(HeadAppenderDefinition).setHead(getV2ModulePreloadHeadContent(config) + (css ? getV2ConfigStyleHeadContent(css) : ''));
45
+ addTopComponent(createV2InteractionsScriptElement(config, isReducedMotion, pageId));
33
46
  };
34
47
  const getInteractiveComps = (interactions) => interactions.reduce((acc, { key, effects }) => {
35
48
  // add trigger comp
36
49
  acc.add(key);
37
50
  // add reaction comps
38
51
  // there must be a key
39
- effects.forEach(({ key }) => acc.add(key));
52
+ effects?.forEach(({ key }) => acc.add(key));
40
53
  return acc;
41
54
  }, new Set());
42
55
  export const coreInteractions = (config, getService) => {
43
56
  const { reducedMotion: isReducedMotion } = getService(DeviceInfoDefinition);
44
57
  const { isOpen } = getService(ExperimentsDefinition);
45
- const { SSR } = getService(RenderingContextDefinition);
46
- const isSSRExperimentOpen = isOpen('specs.thunderbolt.interactionsInSsr');
47
- if (isSSRExperimentOpen) {
58
+ if (isOpen('specs.thunderbolt.interactionsInSsr')) {
48
59
  // Emits the config and loader scripts. Works in both environments: SSR serves markup the
49
60
  // parser executes, and on the client the loader's ref revives it into a script that runs —
50
61
  // which is what pages rendered only on the client (password-protected / members-only,
51
62
  // client-side navigation) need, since they never get a server-rendered document.
52
- const didInitInteractInSsr = tryInitInteractInSsr(config, isReducedMotion, getService);
53
- // Fall back to direct init on the client if the script element could not be set up
54
- // (e.g. no pageId or no interactions).
55
- if (!didInitInteractInSsr && !SSR) {
56
- initInteract(config, isReducedMotion);
57
- }
63
+ // v2 is only reachable from here: it ships as a loader script plus generated CSS, both of
64
+ // which exist only on this path.
65
+ initRuntime(config, isReducedMotion, getService, isOpen('specs.thunderbolt.vsm_interactions_v2'));
58
66
  }
59
67
  else {
60
68
  initInteract(config, isReducedMotion);