@wix/site-service-interactions 1.0.12 → 1.0.13

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 (76) 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/configEntries.d.ts +13 -0
  5. package/cjs/build/implementations/configEntries.js +80 -0
  6. package/cjs/build/implementations/configEntries.js.map +1 -0
  7. package/cjs/build/implementations/coreInteractions.d.ts +2 -2
  8. package/cjs/build/implementations/coreInteractions.js +50 -23
  9. package/cjs/build/implementations/coreInteractions.js.map +1 -1
  10. package/cjs/build/implementations/interactionsService.d.ts +5 -4
  11. package/cjs/build/implementations/v2/InteractionsScriptElement.d.ts +2 -2
  12. package/cjs/build/implementations/v2/InteractionsScriptElement.js.map +1 -1
  13. package/cjs/build/implementations/v2/authoredStyles.d.ts +2 -0
  14. package/cjs/build/implementations/v2/authoredStyles.js +95 -0
  15. package/cjs/build/implementations/v2/authoredStyles.js.map +1 -0
  16. package/cjs/build/implementations/v2/cdnUrls.d.ts +2 -1
  17. package/cjs/build/implementations/v2/cdnUrls.js +3 -2
  18. package/cjs/build/implementations/v2/cdnUrls.js.map +1 -1
  19. package/cjs/build/implementations/v2/clickTriggerCss.d.ts +1 -1
  20. package/cjs/build/implementations/v2/configCss.d.ts +1 -1
  21. package/cjs/build/implementations/v2/configCss.js +3 -36
  22. package/cjs/build/implementations/v2/configCss.js.map +1 -1
  23. package/cjs/build/implementations/v2/configStyleHeadContent.js +8 -6
  24. package/cjs/build/implementations/v2/configStyleHeadContent.js.map +1 -1
  25. package/cjs/build/implementations/v2/interactionsScriptContent.js +18 -7
  26. package/cjs/build/implementations/v2/interactionsScriptContent.js.map +1 -1
  27. package/cjs/build/implementations/v2/motionPresets.d.ts +14 -0
  28. package/cjs/build/implementations/v2/motionPresets.js +76 -0
  29. package/cjs/build/implementations/v2/motionPresets.js.map +1 -0
  30. package/cjs/build/service.d.ts +1 -1
  31. package/cjs/build/types/index.d.ts +1 -1
  32. package/dist/definition/index.d.ts +19 -3
  33. package/dist/definition/index.js.map +1 -1
  34. package/dist/implementations/InteractionsScriptElement.d.ts +1 -1
  35. package/dist/implementations/configEntries.d.ts +13 -0
  36. package/dist/implementations/configEntries.js +73 -0
  37. package/dist/implementations/configEntries.js.map +1 -0
  38. package/dist/implementations/coreInteractions.d.ts +2 -2
  39. package/dist/implementations/coreInteractions.js +50 -23
  40. package/dist/implementations/coreInteractions.js.map +1 -1
  41. package/dist/implementations/interactionsService.d.ts +5 -4
  42. package/dist/implementations/v2/InteractionsScriptElement.d.ts +2 -2
  43. package/dist/implementations/v2/InteractionsScriptElement.js.map +1 -1
  44. package/dist/implementations/v2/authoredStyles.d.ts +2 -0
  45. package/dist/implementations/v2/authoredStyles.js +91 -0
  46. package/dist/implementations/v2/authoredStyles.js.map +1 -0
  47. package/dist/implementations/v2/cdnUrls.d.ts +2 -1
  48. package/dist/implementations/v2/cdnUrls.js +2 -1
  49. package/dist/implementations/v2/cdnUrls.js.map +1 -1
  50. package/dist/implementations/v2/clickTriggerCss.d.ts +1 -1
  51. package/dist/implementations/v2/configCss.d.ts +1 -1
  52. package/dist/implementations/v2/configCss.js +2 -2
  53. package/dist/implementations/v2/configCss.js.map +1 -1
  54. package/dist/implementations/v2/configStyleHeadContent.js +8 -6
  55. package/dist/implementations/v2/configStyleHeadContent.js.map +1 -1
  56. package/dist/implementations/v2/interactionsScriptContent.js +19 -8
  57. package/dist/implementations/v2/interactionsScriptContent.js.map +1 -1
  58. package/dist/implementations/v2/motionPresets.d.ts +14 -0
  59. package/dist/implementations/v2/motionPresets.js +39 -0
  60. package/dist/implementations/v2/motionPresets.js.map +1 -0
  61. package/dist/service.d.ts +1 -1
  62. package/dist/types/index.d.ts +1 -1
  63. package/package.json +4 -3
  64. package/src/definition/index.ts +19 -2
  65. package/src/implementations/InteractionsScriptElement.tsx +1 -1
  66. package/src/implementations/configEntries.ts +105 -0
  67. package/src/implementations/coreInteractions.ts +64 -30
  68. package/src/implementations/v2/InteractionsScriptElement.tsx +3 -3
  69. package/src/implementations/v2/authoredStyles.ts +108 -0
  70. package/src/implementations/v2/cdnUrls.ts +4 -1
  71. package/src/implementations/v2/clickTriggerCss.ts +1 -1
  72. package/src/implementations/v2/configCss.ts +4 -5
  73. package/src/implementations/v2/configStyleHeadContent.ts +9 -6
  74. package/src/implementations/v2/interactionsScriptContent.ts +20 -8
  75. package/src/implementations/v2/motionPresets.ts +60 -0
  76. package/src/types/index.ts +1 -1
@@ -1,12 +1,28 @@
1
1
  import type { StaticServiceDefinition } from '@wix/static-service';
2
- import type { InteractConfig } from '@wix/interact';
3
- export type IInteractionsServiceConfig = InteractConfig;
2
+ import type { InteractConfig } from '@wix/interact-v2';
3
+ export type { InteractConfig };
4
+ export type InteractStyleRule = {
5
+ key?: string;
6
+ selector?: string;
7
+ '@media'?: string;
8
+ '@container'?: string;
9
+ '@supports'?: string;
10
+ properties: Record<string, string>;
11
+ };
12
+ export type InteractConfigEntry = {
13
+ namespace?: string;
14
+ interact: InteractConfig;
15
+ styles?: InteractStyleRule[];
16
+ };
17
+ export type IInteractionsServiceConfig = InteractConfig | {
18
+ entries: InteractConfigEntry[];
19
+ };
4
20
  export interface IInteractionsService {
5
21
  hasInteractions: (path: string) => boolean;
6
22
  }
7
23
  export type IInteractionsDefinition = StaticServiceDefinition<IInteractionsService, IInteractionsServiceConfig>;
8
24
  export declare const InteractionsDefinition: string & {
9
25
  __api: IInteractionsService;
10
- __config: InteractConfig;
26
+ __config: IInteractionsServiceConfig;
11
27
  isServiceDefinition?: boolean;
12
28
  } & IInteractionsService;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyD;AAY5C,QAAA,sBAAsB,GAAG,IAAA,oCAAmB,EACrD,gCAAgC,CACnC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyD;AA6B5C,QAAA,sBAAsB,GAAG,IAAA,oCAAmB,EACrD,gCAAgC,CACnC,CAAA"}
@@ -1,3 +1,3 @@
1
1
  import type { FunctionComponent } from 'react';
2
- import type { InteractConfig } from '@wix/interact';
2
+ import type { InteractConfig } from '@wix/interact-v2';
3
3
  export declare const createInteractionsScriptElement: (config: InteractConfig, isReducedMotion: boolean, pageId: string) => FunctionComponent;
@@ -0,0 +1,13 @@
1
+ import type { InteractConfigEntry, IInteractionsServiceConfig } from '../definition';
2
+ export declare const REACTIONS_NAMESPACE = "reactions";
3
+ export declare const getInteractConfigEntries: (config: IInteractionsServiceConfig) => InteractConfigEntry[];
4
+ export declare const getResolvedConfigEntries: (config: IInteractionsServiceConfig) => InteractConfigEntry[];
5
+ export declare const getInteractiveKeys: ({ interact }: InteractConfigEntry) => Set<string>;
6
+ /**
7
+ * Interact resolves a custom-element key to the first instance containing that key, so a key shared
8
+ * by two entries would silently drop one of them. Experience entries own the keys they declare:
9
+ * whatever they claim is stripped from the reactions entry by dropping whole interactions whose
10
+ * resolved keys overlap. Top-level effect and sequence libraries are left intact. A collision between two
11
+ * experience entries stays an error, since neither of them is authoritative.
12
+ */
13
+ export declare const resolveInteractKeyConflicts: (entries: InteractConfigEntry[]) => InteractConfigEntry[];
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveInteractKeyConflicts = exports.getInteractiveKeys = exports.getResolvedConfigEntries = exports.getInteractConfigEntries = exports.REACTIONS_NAMESPACE = void 0;
4
+ const motionPresets_1 = require("./v2/motionPresets");
5
+ exports.REACTIONS_NAMESPACE = 'reactions';
6
+ const getInteractConfigEntries = (config) => 'entries' in config ? config.entries : [{ interact: config, namespace: exports.REACTIONS_NAMESPACE }];
7
+ exports.getInteractConfigEntries = getInteractConfigEntries;
8
+ const getResolvedConfigEntries = (config) => (0, exports.getInteractConfigEntries)(config).map(entry => entry.namespace === exports.REACTIONS_NAMESPACE
9
+ ? { ...entry, interact: (0, motionPresets_1.aliasLegacyNamedEffects)(entry.interact) }
10
+ : entry);
11
+ exports.getResolvedConfigEntries = getResolvedConfigEntries;
12
+ /** An `effectId` points at `interact.effects`, which is where a reactions effect keeps its key. */
13
+ const resolveEffectKey = (interact, effect) => effect.key ?? (effect.effectId ? interact.effects?.[effect.effectId]?.key : undefined);
14
+ const addEffectKeys = (keys, interact, effects = []) => {
15
+ for (const effect of effects) {
16
+ const key = resolveEffectKey(interact, effect);
17
+ if (key) {
18
+ keys.add(key);
19
+ }
20
+ }
21
+ };
22
+ /** A `sequenceId` reference has no inline effects; resolve it against `interact.sequences`. */
23
+ const getSequenceEffects = (interact, sequence) => 'effects' in sequence ? sequence.effects : (interact.sequences?.[sequence.sequenceId]?.effects ?? []);
24
+ const getInteractionKeys = (interact, interaction) => {
25
+ const keys = new Set([interaction.key]);
26
+ addEffectKeys(keys, interact, interaction.effects);
27
+ for (const sequence of interaction.sequences ?? []) {
28
+ addEffectKeys(keys, interact, getSequenceEffects(interact, sequence));
29
+ }
30
+ return keys;
31
+ };
32
+ const getInteractiveKeys = ({ interact }) => {
33
+ const keys = new Set();
34
+ for (const interaction of interact.interactions) {
35
+ getInteractionKeys(interact, interaction).forEach(key => keys.add(key));
36
+ }
37
+ return keys;
38
+ };
39
+ exports.getInteractiveKeys = getInteractiveKeys;
40
+ const dropOverriddenKeys = (entry, overriddenKeys) => {
41
+ const { interact } = entry;
42
+ return {
43
+ ...entry,
44
+ interact: {
45
+ ...interact,
46
+ interactions: interact.interactions.filter(interaction => ![...getInteractionKeys(interact, interaction)].some(key => overriddenKeys.has(key))),
47
+ },
48
+ };
49
+ };
50
+ /**
51
+ * Interact resolves a custom-element key to the first instance containing that key, so a key shared
52
+ * by two entries would silently drop one of them. Experience entries own the keys they declare:
53
+ * whatever they claim is stripped from the reactions entry by dropping whole interactions whose
54
+ * resolved keys overlap. Top-level effect and sequence libraries are left intact. A collision between two
55
+ * experience entries stays an error, since neither of them is authoritative.
56
+ */
57
+ const resolveInteractKeyConflicts = (entries) => {
58
+ const owners = new Map();
59
+ entries.forEach((entry, index) => {
60
+ if (entry.namespace === exports.REACTIONS_NAMESPACE) {
61
+ return;
62
+ }
63
+ const owner = entry.namespace ?? `entry-${index}`;
64
+ for (const key of (0, exports.getInteractiveKeys)(entry)) {
65
+ const existingOwner = owners.get(key);
66
+ if (existingOwner !== undefined) {
67
+ throw new Error(`Interactions config key "${key}" is shared by "${existingOwner}" and "${owner}". ` +
68
+ 'Keys must be unique across config entries.');
69
+ }
70
+ owners.set(key, owner);
71
+ }
72
+ });
73
+ if (!owners.size) {
74
+ return entries;
75
+ }
76
+ const overriddenKeys = new Set(owners.keys());
77
+ return entries.map(entry => entry.namespace === exports.REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys) : entry);
78
+ };
79
+ exports.resolveInteractKeyConflicts = resolveInteractKeyConflicts;
80
+ //# sourceMappingURL=configEntries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configEntries.js","sourceRoot":"","sources":["../../../src/implementations/configEntries.ts"],"names":[],"mappings":";;;AACA,sDAA4D;AAE/C,QAAA,mBAAmB,GAAG,WAAW,CAAA;AAMvC,MAAM,wBAAwB,GAAG,CAAC,MAAkC,EAAyB,EAAE,CAClG,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,2BAAmB,EAAE,CAAC,CAAA;AADpF,QAAA,wBAAwB,4BAC4D;AAE1F,MAAM,wBAAwB,GAAG,CAAC,MAAkC,EAAyB,EAAE,CAClG,IAAA,gCAAwB,EAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CACzC,KAAK,CAAC,SAAS,KA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C,KAAK,EAAE,KAAK,EAAE,EAAE;QAC7B,IAAI,KAAK,CAAC,SAAS,KAAK,2BAAmB,EAAE,CAAC;YAC1C,OAAM;QACV,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,IAAI,SAAS,KAAK,EAAE,CAAA;QACjD,KAAK,MAAM,GAAG,IAAI,IAAA,0BAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACrC,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CACX,4BAA4B,GAAG,mBAAmB,aAAa,UAAU,KAAK,KAAK;oBAC/E,4CAA4C,CACnD,CAAA;YACL,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC1B,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,OAAO,CAAA;IAClB,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CACvB,KAAK,CAAC,SAAS,KAAK,2BAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAC9F,CAAA;AACL,CAAC,CAAA;AA5BY,QAAA,2BAA2B,+BA4BvC"}
@@ -1,5 +1,5 @@
1
- import type { InteractConfig } from '@wix/interact';
2
1
  import type { ServicesManager } from '@wix/services-manager/types';
3
- export declare const coreInteractions: (config: InteractConfig, getService: ServicesManager["getService"]) => {
2
+ import type { IInteractionsServiceConfig } from '../definition';
3
+ export declare const coreInteractions: (config: IInteractionsServiceConfig, getService: ServicesManager["getService"]) => {
4
4
  interactiveComps: Set<string>;
5
5
  };
@@ -17,7 +17,11 @@ const InteractionsScriptElement_2 = require("./v2/InteractionsScriptElement");
17
17
  const configCss_1 = require("./v2/configCss");
18
18
  const configStyleHeadContent_1 = require("./v2/configStyleHeadContent");
19
19
  const interactionsScriptContent_1 = require("./v2/interactionsScriptContent");
20
- const initInteract = (config, isReducedMotion) => {
20
+ const authoredStyles_1 = require("./v2/authoredStyles");
21
+ const configEntries_1 = require("./configEntries");
22
+ /** An entry without interactions contributes CSS only; nothing has to load Interact for it. */
23
+ const getRuntimeConfigs = (entries) => entries.map(({ interact }) => interact).filter(({ interactions }) => interactions.length > 0);
24
+ const initInteract = (entries, isReducedMotion) => {
21
25
  // Bundled runtime is v1. v2 on the client is the CDN loader.
22
26
  interact_1.Interact.forceReducedMotion = isReducedMotion;
23
27
  interact_1.Interact.setup({
@@ -27,10 +31,22 @@ const initInteract = (config, isReducedMotion) => {
27
31
  useSafeViewEnter: true,
28
32
  },
29
33
  });
30
- interact_1.Interact.create(config);
34
+ for (const { interact } of entries) {
35
+ interact_1.Interact.create(interact);
36
+ }
37
+ };
38
+ const getV2HeadContent = (entries) => {
39
+ const generatedCss = entries
40
+ .map(({ interact }) => (0, configCss_1.getV2ConfigCss)(interact).trim())
41
+ .filter(Boolean)
42
+ .join('\n');
43
+ const css = [(0, authoredStyles_1.getAuthoredStylesCss)(entries).trim(), generatedCss].filter(Boolean).join('\n');
44
+ return ((getRuntimeConfigs(entries).length ? (0, interactionsScriptContent_1.getV2ModulePreloadHeadContent)() : '') +
45
+ (css ? (0, configStyleHeadContent_1.getV2ConfigStyleHeadContent)(css) : ''));
31
46
  };
32
- const initRuntime = (config, isReducedMotion, getService, useV2) => {
33
- if (!config.interactions?.length) {
47
+ const initRuntime = (entries, isReducedMotion, getService, useV2) => {
48
+ const runtimeConfigs = getRuntimeConfigs(entries);
49
+ if (!runtimeConfigs.length) {
34
50
  return;
35
51
  }
36
52
  const pageId = getService(definition_3.PagesDefinition).currentPageId();
@@ -38,47 +54,58 @@ const initRuntime = (config, isReducedMotion, getService, useV2) => {
38
54
  return;
39
55
  }
40
56
  const { addTopComponent } = getService(provide_component_1.ProvideComponentServiceDefinition);
41
- const interactionsScript = useV2
42
- ? (0, InteractionsScriptElement_2.createV2InteractionsScriptElement)(config, isReducedMotion, pageId)
43
- : (0, InteractionsScriptElement_1.createInteractionsScriptElement)(config, isReducedMotion, pageId);
44
- addTopComponent(interactionsScript);
57
+ if (!useV2) {
58
+ // v1 serializes a single config and has no path for authored-style CSS, so anything beyond
59
+ // that would be silently dropped.
60
+ if (entries.length > 1 || entries.some(({ styles }) => styles?.length)) {
61
+ throw new Error('Multiple interactions config entries and authored styles require Interact v2.');
62
+ }
63
+ addTopComponent((0, InteractionsScriptElement_1.createInteractionsScriptElement)(runtimeConfigs[0], isReducedMotion, pageId));
64
+ return;
65
+ }
66
+ addTopComponent((0, InteractionsScriptElement_2.createV2InteractionsScriptElement)(runtimeConfigs, isReducedMotion, pageId));
67
+ };
68
+ const getInteractiveComps = (entries) => {
69
+ const keys = new Set();
70
+ for (const entry of entries) {
71
+ (0, configEntries_1.getInteractiveKeys)(entry).forEach(key => keys.add(key));
72
+ }
73
+ return keys;
45
74
  };
46
- const getInteractiveComps = (interactions) => interactions.reduce((acc, { key, effects }) => {
47
- // add trigger comp
48
- acc.add(key);
49
- // add reaction comps
50
- // there must be a key
51
- effects?.forEach(({ key }) => acc.add(key));
52
- return acc;
53
- }, new Set());
54
75
  const coreInteractions = (config, getService) => {
55
76
  const { reducedMotion: isReducedMotion } = getService(definition_1.DeviceInfoDefinition);
56
77
  const { isOpen } = getService(definition_2.ExperimentsDefinition);
57
- if (isOpen('specs.thunderbolt.vsm_interactions_v2')) {
78
+ const useV2 = isOpen('specs.thunderbolt.vsm_interactions_v2');
79
+ // The v1 runtime has no preset registration and doesn't understand LEGACY_* names; skip
80
+ // aliasing on those paths so named reaction effects remain resolvable.
81
+ const entries = (0, configEntries_1.resolveInteractKeyConflicts)((useV2 ? configEntries_1.getResolvedConfigEntries : configEntries_1.getInteractConfigEntries)(config));
82
+ if (useV2) {
58
83
  // Both belong in the head: the preload links only help while the document is still parsing,
59
84
  // and the generated CSS hides elements before their entrance effect, so it has to apply
60
85
  // before the body renders.
61
86
  if (!process.env.browser) {
62
- const css = (0, configCss_1.getV2ConfigCss)(config).trim();
87
+ const headContent = getV2HeadContent(entries);
63
88
  // GENERAL rather than setHead's AFTER_SECURITY default: thunderbolt only reads the
64
89
  // after-security bucket on its SEO path, so the default drops this on every normal
65
90
  // request. GENERAL reaches the document as raw markup before `</head>`.
66
- getService(definition_4.HeadAppenderDefinition).setHead((0, interactionsScriptContent_1.getV2ModulePreloadHeadContent)() + (css ? (0, configStyleHeadContent_1.getV2ConfigStyleHeadContent)(css) : ''), types_1.HeadContentType.GENERAL);
91
+ if (headContent) {
92
+ getService(definition_4.HeadAppenderDefinition).setHead(headContent, types_1.HeadContentType.GENERAL);
93
+ }
67
94
  }
68
- initRuntime(config, isReducedMotion, getService, true);
95
+ initRuntime(entries, isReducedMotion, getService, true);
69
96
  }
70
97
  else if (isOpen('specs.thunderbolt.interactionsInSsr')) {
71
98
  // Emits the config and loader scripts. Works in both environments: SSR serves markup the
72
99
  // parser executes, and on the client the loader's ref revives it into a script that runs —
73
100
  // which is what pages rendered only on the client (password-protected / members-only,
74
101
  // client-side navigation) need, since they never get a server-rendered document.
75
- initRuntime(config, isReducedMotion, getService, false);
102
+ initRuntime(entries, isReducedMotion, getService, false);
76
103
  }
77
104
  else {
78
- initInteract(config, isReducedMotion);
105
+ initInteract(entries, isReducedMotion);
79
106
  }
80
107
  return {
81
- interactiveComps: getInteractiveComps(config.interactions),
108
+ interactiveComps: getInteractiveComps(entries),
82
109
  };
83
110
  };
84
111
  exports.coreInteractions = coreInteractions;
@@ -1 +1 @@
1
- {"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../../src/implementations/coreInteractions.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,yEAA+E;AAC/E,yEAAg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IAC7D,wFAAwF;IACxF,uEAAuE;IACvE,MAAM,OAAO,GAAG,IAAA,2CAA2B,EAAC,CAAC,KAAK,CAAC,CAAC,CAAC,wCAAwB,CAAC,CAAC,CAAC,wCAAwB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAElH,IAAI,KAAK,EAAE,CAAC;QACR,4FAA4F;QAC5F,wFAAwF;QACxF,2BAA2B;QAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;YAC7C,mFAAmF;YACnF,mFAAmF;YACnF,wEAAwE;YACxE,IAAI,WAAW,EAAE,CAAC;gBACd,UAAU,CAAC,mCAAsB,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,uBAAe,CAAC,OAAO,CAAC,CAAA;YACpF,CAAC;QACL,CAAC;QAED,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;IAC3D,CAAC;SAAM,IAAI,MAAM,CAAC,qCAAqC,CAAC,EAAE,CAAC;QACvD,yFAAyF;QACzF,2FAA2F;QAC3F,sFAAsF;QACtF,iFAAiF;QACjF,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;IAC5D,CAAC;SAAM,CAAC;QACJ,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IAC1C,CAAC;IAED,OAAO;QACH,gBAAgB,EAAE,mBAAmB,CAAC,OAAO,CAAC;KACjD,CAAA;AACL,CAAC,CAAA;AApCY,QAAA,gBAAgB,oBAoC5B"}
@@ -1,10 +1,11 @@
1
+ import type { IInteractionsServiceConfig } from '../definition';
1
2
  export declare const InteractionsService: import("@wix/services-definitions").ServiceFactory<string & {
2
3
  __api: import("../definition").IInteractionsService;
3
- __config: import("@wix/interact").InteractConfig;
4
+ __config: IInteractionsServiceConfig;
4
5
  isServiceDefinition?: boolean;
5
- } & import("../definition").IInteractionsService, import("@wix/interact").InteractConfig>;
6
+ } & import("../definition").IInteractionsService, IInteractionsServiceConfig>;
6
7
  export declare const InteractionsServiceExternal: import("@wix/services-definitions").ServiceFactory<string & {
7
8
  __api: import("../definition").IInteractionsService;
8
- __config: import("@wix/interact").InteractConfig;
9
+ __config: IInteractionsServiceConfig;
9
10
  isServiceDefinition?: boolean;
10
- } & import("../definition").IInteractionsService, import("@wix/interact").InteractConfig>;
11
+ } & import("../definition").IInteractionsService, IInteractionsServiceConfig>;
@@ -1,3 +1,3 @@
1
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;
2
+ import type { InteractConfig } from '@wix/interact-v2';
3
+ export declare const createV2InteractionsScriptElement: (config: InteractConfig | InteractConfig[], isReducedMotion: boolean, pageId: string) => FunctionComponent;
@@ -1 +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,QAAQ,EAAE,eAAe,CAAC,CAAA;IAC3F,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"}
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,MAAyC,EAAU,EAAE,CAC1F,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AAE5C,MAAM,iCAAiC,GAC1C,CAAC,MAAyC,EAAE,eAAwB,EAAE,MAAc,EAAqB,EAAE,CAC3G,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,QAAQ,EAAE,eAAe,CAAC,CAAA;IAC3F,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
+ import type { InteractConfigEntry } from '../../definition';
2
+ export declare const getAuthoredStylesCss: (entries: InteractConfigEntry[]) => string;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAuthoredStylesCss = void 0;
4
+ const SELECTOR_TOKEN = /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[()[\]]|,/g;
5
+ const escapeCssString = (value) => value
6
+ .replace(/\\/g, '\\\\')
7
+ .replace(/"/g, '\\"')
8
+ .replace(/\n/g, '\\a ')
9
+ .replace(/\r/g, '\\d ')
10
+ .replace(/\f/g, '\\c ');
11
+ const splitSelectorList = (selector) => {
12
+ const parts = [];
13
+ let depth = 0;
14
+ let start = 0;
15
+ SELECTOR_TOKEN.lastIndex = 0;
16
+ for (let match = SELECTOR_TOKEN.exec(selector); match; match = SELECTOR_TOKEN.exec(selector)) {
17
+ const token = match[0];
18
+ if (token === '(' || token === '[') {
19
+ depth++;
20
+ }
21
+ else if (token === ')' || token === ']') {
22
+ depth--;
23
+ }
24
+ else if (token === ',' && depth === 0) {
25
+ parts.push(selector.slice(start, match.index));
26
+ start = match.index + 1;
27
+ }
28
+ }
29
+ parts.push(selector.slice(start));
30
+ return parts.map(part => part.trim()).filter(Boolean);
31
+ };
32
+ const indentCssBlock = (css) => css
33
+ .split('\n')
34
+ .map(line => (line ? ` ${line}` : line))
35
+ .join('\n');
36
+ const renderProperties = (properties) => Object.entries(properties)
37
+ .map(([property, value]) => ` ${property}: ${value};`)
38
+ .join('\n');
39
+ const wrapWithConditions = (block, rule) => {
40
+ let result = block;
41
+ if (rule['@container']) {
42
+ result = `@container ${rule['@container']} {\n${indentCssBlock(result)}\n}`;
43
+ }
44
+ if (rule['@media']) {
45
+ result = `@media ${rule['@media']} {\n${indentCssBlock(result)}\n}`;
46
+ }
47
+ if (rule['@supports']) {
48
+ result = `@supports ${rule['@supports']} {\n${indentCssBlock(result)}\n}`;
49
+ }
50
+ return result;
51
+ };
52
+ const buildRuleSelector = (namespace, rule) => {
53
+ const scopeWrapper = `[data-interact-key="${escapeCssString(namespace)}"]`;
54
+ const scopeRoot = `${scopeWrapper} > :first-child`;
55
+ if (!rule.key) {
56
+ if (!rule.selector) {
57
+ return scopeRoot;
58
+ }
59
+ return splitSelectorList(rule.selector)
60
+ .map(selector => `${scopeRoot} ${selector}`)
61
+ .join(', ');
62
+ }
63
+ const escapedKey = escapeCssString(rule.key);
64
+ const keyWrapper = rule.key === namespace ? scopeWrapper : `${scopeWrapper} [data-interact-key="${escapedKey}"]`;
65
+ const keyRoot = `${keyWrapper} > :first-child`;
66
+ if (!rule.selector) {
67
+ return keyRoot;
68
+ }
69
+ const separator = /^\s/.test(rule.selector) ? ' ' : '';
70
+ return splitSelectorList(rule.selector)
71
+ .map(selector => `${keyRoot}${separator}${selector}`)
72
+ .join(', ');
73
+ };
74
+ const getEntryStylesCss = ({ namespace, styles = [] }) => {
75
+ if (!styles.length) {
76
+ return '';
77
+ }
78
+ if (!namespace) {
79
+ throw new Error('Interactions config entries with authored styles must define a namespace.');
80
+ }
81
+ return styles
82
+ .map(rule => {
83
+ const properties = renderProperties(rule.properties);
84
+ if (!properties) {
85
+ return '';
86
+ }
87
+ const block = `${buildRuleSelector(namespace, rule)} {\n${properties}\n}`;
88
+ return wrapWithConditions(block, rule);
89
+ })
90
+ .filter(Boolean)
91
+ .join('\n\n');
92
+ };
93
+ const getAuthoredStylesCss = (entries) => entries.map(getEntryStylesCss).filter(Boolean).join('\n\n');
94
+ exports.getAuthoredStylesCss = getAuthoredStylesCss;
95
+ //# 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,CAC9C,KAAK;KACA,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;KACtB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;KACpB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;KACtB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;KACtB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAE/B,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAY,EAAE;IACrD,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,cAAc,CAAC,SAAS,GAAG,CAAC,CAAA;IAC5B,KAAK,IAAI,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAA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M,oBAAoB,GAAG,CAAC,OAA8B,EAAU,EAAE,CAC3E,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AADlD,QAAA,oBAAoB,wBAC8B"}
@@ -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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WIX_MOTION_PRESETS_IMPORT_URL = exports.INTERACT_V2_IMPORT_URL = void 0;
3
+ exports.MOTION_PRESETS_IMPORT_URL = exports.LEGACY_WIX_MOTION_PRESETS_IMPORT_URL = exports.INTERACT_V2_IMPORT_URL = void 0;
4
4
  exports.INTERACT_V2_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/interact@2.5.14/dist/es/web.min.js';
5
- exports.WIX_MOTION_PRESETS_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/wix-motion-presets@1.0.0/+esm';
5
+ exports.LEGACY_WIX_MOTION_PRESETS_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/wix-motion-presets@1.2.0/+esm';
6
+ exports.MOTION_PRESETS_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/motion-presets@1.0.7/dist/browser/motion-presets.min.js';
6
7
  //# sourceMappingURL=cdnUrls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,sEAAsE,CAAA;AAE/F,QAAA,6BAA6B,GAAG,iEAAiE,CAAA"}
1
+ {"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,sEAAsE,CAAA;AAE/F,QAAA,oCAAoC,GAAG,iEAAiE,CAAA;AAExG,QAAA,yBAAyB,GAClC,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;
@@ -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,45 +1,12 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.getV2ConfigCss = void 0;
37
4
  const interact_v2_1 = require("@wix/interact-v2");
38
- const motionPresets = __importStar(require("@wix/wix-motion-presets"));
39
5
  const clickTriggerCss_1 = require("./clickTriggerCss");
6
+ const motionPresets_1 = require("./motionPresets");
40
7
  // Interact's registry is process-global. This module is only pulled into the server bundle
41
- // (`process.env.browser` DCE), so the namespace is registered once per Node process.
42
- interact_v2_1.Interact.registerEffects(motionPresets);
8
+ // (`process.env.browser` DCE), so both namespaces are registered once per Node process.
9
+ interact_v2_1.Interact.registerEffects(motionPresets_1.motionPresets);
43
10
  /** Emit animation FOUC CSS and click-trigger cursor rules. */
44
11
  const getV2ConfigCss = (config) => {
45
12
  const animationCss = (0, interact_v2_1.generate)(config, true).trim();
@@ -1 +1 @@
1
- {"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAqD;AAGrD,uEAAwD;AACxD,uDAAsD;AAItD,2FAA2F;AAC3F,qFAAqF;AACrF,sBAAQ,CAAC,eAAe,CAAC,aAA0C,CAAC,CAAA;AAEpE,8DAA8D;AACvD,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC7D,MAAM,YAAY,GAAG,IAAA,sBAAQ,EAAC,MAA0B,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;IACtE,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;AALY,QAAA,cAAc,kBAK1B"}
1
+ {"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":";;;AAAA,kDAAqD;AAErD,uDAAsD;AACtD,mDAA+C;AAI/C,2FAA2F;AAC3F,wFAAwF;AACxF,sBAAQ,CAAC,eAAe,CAAC,6BAA0C,CAAC,CAAA;AAEpE,8DAA8D;AACvD,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC7D,MAAM,YAAY,GAAG,IAAA,sBAAQ,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;AALY,QAAA,cAAc,kBAK1B"}
@@ -2,14 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getV2ConfigStyleHeadContent = void 0;
4
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.
5
+ * Head content is a raw HTML string. CSS values may contain tag-like text, but an actual closing
6
+ * style tag still terminates the raw-text element, and HeadAppender rejects `<script` substrings.
7
+ * Keep other CSS intact: drop content after a closing style tag and break script-like sequences.
9
8
  */
9
+ const STYLE_END_TAG = /<\/style(?=[\t\n\f\r />])/i;
10
+ const SCRIPT_LIKE = /<script/gi;
10
11
  const sanitizeCssForStyleElement = (css) => {
11
- const tagIndex = css.search(/<[a-zA-Z/]/);
12
- return tagIndex === -1 ? css : css.slice(0, tagIndex);
12
+ const styleEndTagIndex = css.search(STYLE_END_TAG);
13
+ const withoutStyleBreakout = styleEndTagIndex === -1 ? css : css.slice(0, styleEndTagIndex);
14
+ return withoutStyleBreakout.replace(SCRIPT_LIKE, '\\3c script');
13
15
  };
14
16
  const getV2ConfigStyleHeadContent = (css) => `<style>${sanitizeCssForStyleElement(css)}</style>`;
15
17
  exports.getV2ConfigStyleHeadContent = getV2ConfigStyleHeadContent;
@@ -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;AAEM,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA;AAA1G,QAAA,2BAA2B,+BAA+E"}
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;IACvD,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;AACnE,CAAC,CAAA;AAEM,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA;AAA1G,QAAA,2BAA2B,+BAA+E"}
@@ -2,23 +2,32 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getV2InteractionsScriptContent = exports.getV2ModulePreloadHeadContent = void 0;
4
4
  const cdnUrls_1 = require("./cdnUrls");
5
+ const motionPresets_1 = require("./motionPresets");
6
+ /** The loader destructures `Promise.all` in this order. */
7
+ const MODULE_IMPORT_URLS = [cdnUrls_1.INTERACT_V2_IMPORT_URL, cdnUrls_1.LEGACY_WIX_MOTION_PRESETS_IMPORT_URL, cdnUrls_1.MOTION_PRESETS_IMPORT_URL];
5
8
  /**
6
9
  * The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
7
10
  * see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
8
11
  * `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
9
12
  * would download each module twice.
10
13
  */
11
- const getV2ModulePreloadHeadContent = () => `<link rel="modulepreload" href="${cdnUrls_1.INTERACT_V2_IMPORT_URL}"><link rel="modulepreload" href="${cdnUrls_1.WIX_MOTION_PRESETS_IMPORT_URL}">`;
14
+ const getV2ModulePreloadHeadContent = () => MODULE_IMPORT_URLS.map(url => `<link rel="modulepreload" href="${url}">`).join('');
12
15
  exports.getV2ModulePreloadHeadContent = getV2ModulePreloadHeadContent;
13
16
  const getV2InteractionsScriptContent = (configId, isReducedMotion) => [
14
17
  `const configElement = document.getElementById(\`${configId}\`)`,
15
18
  'if (configElement) {',
16
- ' const config = JSON.parse(configElement.textContent)',
17
- ' const [{ Interact }, presets] = await Promise.all([',
18
- ` import(\`${cdnUrls_1.INTERACT_V2_IMPORT_URL}\`),`,
19
- ` import(\`${cdnUrls_1.WIX_MOTION_PRESETS_IMPORT_URL}\`),`,
19
+ ' const parsedConfig = JSON.parse(configElement.textContent)',
20
+ ' const configs = Array.isArray(parsedConfig) ? parsedConfig : [parsedConfig]',
21
+ ' const [{ Interact }, legacyPresets, presets] = await Promise.all([',
22
+ ...MODULE_IMPORT_URLS.map(url => ` import(\`${url}\`),`),
20
23
  ' ])',
21
- ' Interact.registerEffects(presets)',
24
+ // Reactions configs carry the prefix on their named effect types, so the two packages can
25
+ // both export a preset under the same name without one shadowing the other.
26
+ ' const aliasedLegacyPresets = {}',
27
+ ' for (const name of Object.keys(legacyPresets)) {',
28
+ ` aliasedLegacyPresets[\`${motionPresets_1.LEGACY_PREFIX}\` + name] = legacyPresets[name]`,
29
+ ' }',
30
+ ' Interact.registerEffects({ ...presets, ...aliasedLegacyPresets })',
22
31
  ` Interact.forceReducedMotion = ${isReducedMotion}`,
23
32
  ' Interact.setup({',
24
33
  ' scrollOptionsGetter: function () {',
@@ -29,7 +38,9 @@ const getV2InteractionsScriptContent = (configId, isReducedMotion) => [
29
38
  ' useSafeViewEnter: true,',
30
39
  ' },',
31
40
  ' })',
32
- ' Interact.create(config)',
41
+ ' for (const config of configs) {',
42
+ ' Interact.create(config)',
43
+ ' }',
33
44
  '}',
34
45
  ].join('\n');
35
46
  exports.getV2InteractionsScriptContent = getV2InteractionsScriptContent;