@wix/site-service-interactions 1.0.8 → 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.
- package/cjs/build/implementations/coreInteractions.js +34 -26
- package/cjs/build/implementations/coreInteractions.js.map +1 -1
- package/cjs/build/implementations/interactionsScriptContent.js +30 -16
- package/cjs/build/implementations/interactionsScriptContent.js.map +1 -1
- package/cjs/build/implementations/stylesToAdd.d.ts +1 -1
- package/cjs/build/implementations/stylesToAdd.js +1 -1
- package/cjs/build/implementations/v2/InteractionsScriptElement.d.ts +3 -0
- package/cjs/build/implementations/v2/InteractionsScriptElement.js +33 -0
- package/cjs/build/implementations/v2/InteractionsScriptElement.js.map +1 -0
- package/cjs/build/implementations/v2/cdnUrls.d.ts +2 -0
- package/cjs/build/implementations/v2/cdnUrls.js +6 -0
- package/cjs/build/implementations/v2/cdnUrls.js.map +1 -0
- package/cjs/build/implementations/v2/clickTriggerCss.d.ts +3 -0
- package/cjs/build/implementations/v2/clickTriggerCss.js +35 -0
- package/cjs/build/implementations/v2/clickTriggerCss.js.map +1 -0
- package/cjs/build/implementations/v2/configCss.d.ts +3 -0
- package/cjs/build/implementations/v2/configCss.js +15 -0
- package/cjs/build/implementations/v2/configCss.js.map +1 -0
- package/cjs/build/implementations/v2/configStyleHeadContent.d.ts +1 -0
- package/cjs/build/implementations/v2/configStyleHeadContent.js +16 -0
- package/cjs/build/implementations/v2/configStyleHeadContent.js.map +1 -0
- package/cjs/build/implementations/v2/interactionsScriptContent.d.ts +9 -0
- package/cjs/build/implementations/v2/interactionsScriptContent.js +52 -0
- package/cjs/build/implementations/v2/interactionsScriptContent.js.map +1 -0
- package/cjs/build/implementations/v2/motionPresets.d.ts +13 -0
- package/cjs/build/implementations/v2/motionPresets.js +54 -0
- package/cjs/build/implementations/v2/motionPresets.js.map +1 -0
- package/cjs/build/implementations/v2/namedEffectTypes.d.ts +2 -0
- package/cjs/build/implementations/v2/namedEffectTypes.js +42 -0
- package/cjs/build/implementations/v2/namedEffectTypes.js.map +1 -0
- package/cjs/build/implementations/v2/registerConfigEffects.d.ts +6 -0
- package/cjs/build/implementations/v2/registerConfigEffects.js +27 -0
- package/cjs/build/implementations/v2/registerConfigEffects.js.map +1 -0
- package/dist/implementations/coreInteractions.js +30 -22
- package/dist/implementations/coreInteractions.js.map +1 -1
- package/dist/implementations/interactionsScriptContent.js +30 -16
- package/dist/implementations/interactionsScriptContent.js.map +1 -1
- package/dist/implementations/stylesToAdd.d.ts +1 -1
- package/dist/implementations/stylesToAdd.js +1 -1
- package/dist/implementations/v2/InteractionsScriptElement.d.ts +3 -0
- package/dist/implementations/v2/InteractionsScriptElement.js +26 -0
- package/dist/implementations/v2/InteractionsScriptElement.js.map +1 -0
- package/dist/implementations/v2/cdnUrls.d.ts +2 -0
- package/dist/implementations/v2/cdnUrls.js +3 -0
- package/dist/implementations/v2/cdnUrls.js.map +1 -0
- package/dist/implementations/v2/clickTriggerCss.d.ts +3 -0
- package/dist/implementations/v2/clickTriggerCss.js +31 -0
- package/dist/implementations/v2/clickTriggerCss.js.map +1 -0
- package/dist/implementations/v2/configCss.d.ts +3 -0
- package/dist/implementations/v2/configCss.js +11 -0
- package/dist/implementations/v2/configCss.js.map +1 -0
- package/dist/implementations/v2/configStyleHeadContent.d.ts +1 -0
- package/dist/implementations/v2/configStyleHeadContent.js +12 -0
- package/dist/implementations/v2/configStyleHeadContent.js.map +1 -0
- package/dist/implementations/v2/interactionsScriptContent.d.ts +9 -0
- package/dist/implementations/v2/interactionsScriptContent.js +47 -0
- package/dist/implementations/v2/interactionsScriptContent.js.map +1 -0
- package/dist/implementations/v2/motionPresets.d.ts +13 -0
- package/dist/implementations/v2/motionPresets.js +16 -0
- package/dist/implementations/v2/motionPresets.js.map +1 -0
- package/dist/implementations/v2/namedEffectTypes.d.ts +2 -0
- package/dist/implementations/v2/namedEffectTypes.js +38 -0
- package/dist/implementations/v2/namedEffectTypes.js.map +1 -0
- package/dist/implementations/v2/registerConfigEffects.d.ts +6 -0
- package/dist/implementations/v2/registerConfigEffects.js +23 -0
- package/dist/implementations/v2/registerConfigEffects.js.map +1 -0
- package/package.json +8 -5
- package/src/implementations/coreInteractions.ts +36 -25
- package/src/implementations/interactionsScriptContent.ts +30 -16
- package/src/implementations/stylesToAdd.ts +1 -1
- package/src/implementations/v2/InteractionsScriptElement.tsx +42 -0
- package/src/implementations/v2/cdnUrls.ts +4 -0
- package/src/implementations/v2/clickTriggerCss.ts +44 -0
- package/src/implementations/v2/configCss.ts +13 -0
- package/src/implementations/v2/configStyleHeadContent.ts +12 -0
- package/src/implementations/v2/interactionsScriptContent.ts +61 -0
- package/src/implementations/v2/motionPresets.ts +26 -0
- package/src/implementations/v2/namedEffectTypes.ts +52 -0
- package/src/implementations/v2/registerConfigEffects.ts +31 -0
|
@@ -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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return false;
|
|
27
|
+
const initRuntime = (config, isReducedMotion, getService, useV2) => {
|
|
28
|
+
if (!config.interactions?.length) {
|
|
29
|
+
return;
|
|
23
30
|
}
|
|
24
|
-
const
|
|
25
|
-
const pageId = currentPage?.id;
|
|
31
|
+
const pageId = getService(PagesDefinition).currentPage?.id;
|
|
26
32
|
if (!pageId) {
|
|
27
|
-
return
|
|
33
|
+
return;
|
|
28
34
|
}
|
|
29
35
|
const { addTopComponent } = getService(ProvideComponentServiceDefinition);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../src/implementations/coreInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../src/implementations/coreInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0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CAAC,oBAAoB,CAAC,CAAA;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAA;IAEpD,IAAI,MAAM,CAAC,qCAAqC,CAAC,EAAE,CAAC;QAChD,yFAAyF;QACzF,2FAA2F;QAC3F,sFAAsF;QACtF,iFAAiF;QACjF,0FAA0F;QAC1F,iCAAiC;QACjC,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAA;IACrG,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"}
|
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
export const getInteractionsScriptContent = (configId, isReducedMotion) => `
|
|
2
2
|
await import(\`https://static.parastorage.com/services/interact/dist/interact.umd.min.js\`);
|
|
3
3
|
|
|
4
|
+
// Wix pages run an AMD loader (RequireJS) whose define wins the interact UMD wrapper, so the
|
|
5
|
+
// bundle registers itself as a named AMD module instead of assigning window.interact. Read the
|
|
6
|
+
// global first, and when it is absent pull the module back out of the AMD loader.
|
|
7
|
+
let interactModule = window.interact;
|
|
8
|
+
if (!interactModule?.Interact) {
|
|
9
|
+
if (typeof window.require === \`function\`) {
|
|
10
|
+
try {
|
|
11
|
+
interactModule = await new Promise(function (resolve, reject) {
|
|
12
|
+
window.require([\`interact\`], resolve, reject);
|
|
13
|
+
});
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error(\`Failed loading Interact via the AMD loader\`, error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const Interact = interactModule?.Interact;
|
|
4
21
|
const configElement = document.getElementById(\`${configId}\`);
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} else {
|
|
10
|
-
const config = JSON.parse(decodeURIComponent(configElement.textContent));
|
|
22
|
+
if (!Interact) {
|
|
23
|
+
console.error(\`Interact library is not loaded\`);
|
|
24
|
+
} else if (configElement) {
|
|
25
|
+
const config = JSON.parse(decodeURIComponent(configElement.textContent));
|
|
11
26
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
Interact.forceReducedMotion = ${isReducedMotion};
|
|
28
|
+
Interact.setup({
|
|
29
|
+
scrollOptionsGetter: function(){ return document.getElementById(\`site-root\`) },
|
|
30
|
+
allowA11yTriggers: true,
|
|
31
|
+
viewEnter: {
|
|
32
|
+
useSafeViewEnter: true,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
}
|
|
36
|
+
Interact.create(config);
|
|
23
37
|
}
|
|
24
38
|
`;
|
|
25
39
|
//# sourceMappingURL=interactionsScriptContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../src/implementations/interactionsScriptContent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,QAAgB,EAAE,eAAwB,EAAE,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../src/implementations/interactionsScriptContent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,QAAgB,EAAE,eAAwB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;sDAoBtC,QAAQ;;;;;;wCAMtB,eAAe;;;;;;;;;;;CAWtD,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const wixInteractElementCss = "\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 ";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { reviveScriptElement } from '../reviveScriptElement';
|
|
3
|
+
import { getV2InteractionsScriptContent } from './interactionsScriptContent';
|
|
4
|
+
const DANGEROUSLY_SET_INNER_HTML = ['dangerously', 'Set', 'Inner', 'HTML'];
|
|
5
|
+
/**
|
|
6
|
+
* The config is written as raw markup, so a `</script` inside any string value would close the
|
|
7
|
+
* element early. `\u003c` is valid JSON that `JSON.parse` reads back as `<`.
|
|
8
|
+
*/
|
|
9
|
+
const serializeConfigForScriptElement = (config) => JSON.stringify(config).replace(/</g, '\\u003c');
|
|
10
|
+
export const createV2InteractionsScriptElement = (config, isReducedMotion, pageId) => () => {
|
|
11
|
+
// This ID is also interpolated into raw module-script text. Percent-encoding removes
|
|
12
|
+
// script delimiters and template-literal syntax while keeping the ID deterministic.
|
|
13
|
+
const safePageId = encodeURIComponent(pageId);
|
|
14
|
+
const configId = `interactions-config-${safePageId}`;
|
|
15
|
+
const interactionsScriptContent = getV2InteractionsScriptContent(config, configId, isReducedMotion);
|
|
16
|
+
const configProps = {
|
|
17
|
+
[DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: serializeConfigForScriptElement(config) },
|
|
18
|
+
};
|
|
19
|
+
const loaderProps = {
|
|
20
|
+
[DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: interactionsScriptContent },
|
|
21
|
+
};
|
|
22
|
+
return (React.createElement(React.Fragment, null,
|
|
23
|
+
React.createElement("script", { type: "application/json", id: configId, ...configProps }),
|
|
24
|
+
React.createElement("script", { type: "module", id: `interactions-loader-${safePageId}`, ref: reviveScriptElement, ...loaderProps })));
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=InteractionsScriptElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionsScriptElement.js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,GAAG,EAAE,mBAAmB,KACpB,WAAW,GACjB,CACH,CACN,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const INTERACT_V2_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/interact@2/dist/es/web.min.js';
|
|
2
|
+
export const WIX_MOTION_PRESETS_IMPORT_URL = 'https://static.parastorage.com/services/wix-motion-presets/dist/wix-motion-presets.esm.min.js';
|
|
3
|
+
//# sourceMappingURL=cdnUrls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,iEAAiE,CAAA;AAEvG,MAAM,CAAC,MAAM,6BAA6B,GACtC,+FAA+F,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const escapeCssAttr = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
2
|
+
/**
|
|
3
|
+
* Mirrors `@wix/interact` `getSelector(interaction, { asCombinator: true, useFirstChild: true })`
|
|
4
|
+
* plus the `[data-interact-key="…"]` prefix from `CSSRuleToString`.
|
|
5
|
+
*/
|
|
6
|
+
const getInteractionSourceSelector = (interaction) => {
|
|
7
|
+
const { key, selector, listContainer, listItemSelector } = interaction;
|
|
8
|
+
const attrSelector = `[data-interact-key="${escapeCssAttr(key)}"]`;
|
|
9
|
+
if (listContainer) {
|
|
10
|
+
const itemFilter = listItemSelector ? ` > ${listItemSelector}` : '';
|
|
11
|
+
const inner = selector ? `${listContainer}${itemFilter} ${selector}` : `${listContainer}${itemFilter || ' > *'}`;
|
|
12
|
+
return `${attrSelector} ${inner}`;
|
|
13
|
+
}
|
|
14
|
+
if (selector) {
|
|
15
|
+
return `${attrSelector} ${selector}`;
|
|
16
|
+
}
|
|
17
|
+
return `${attrSelector} > :first-child`;
|
|
18
|
+
};
|
|
19
|
+
/** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
|
|
20
|
+
export const getClickTriggerCss = (config) => {
|
|
21
|
+
const selectors = [
|
|
22
|
+
...new Set(config.interactions
|
|
23
|
+
.filter(({ trigger }) => trigger === 'activate' || trigger === 'click')
|
|
24
|
+
.map(getInteractionSourceSelector)),
|
|
25
|
+
];
|
|
26
|
+
if (!selectors.length) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
return selectors.map(selector => `${selector} {\ncursor: pointer;\n}`).join('\n');
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=clickTriggerCss.js.map
|
|
@@ -0,0 +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,MAAM,4BAA4B,GAAG,CACjC,WAAyF,EACnF,EAAE;IACR,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAAA;IACtE,MAAM,YAAY,GAAG,uBAAuB,aAAa,CAAC,GAAG,CAAC,IAAI,CAAA;IAElE,IAAI,aAAa,EAAE,CAAC;QAChB,MAAM,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,MAAM,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QACnE,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,UAAU,IAAI,MAAM,EAAE,CAAA;QAEhH,OAAO,GAAG,YAAY,IAAI,KAAK,EAAE,CAAA;IACrC,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACX,OAAO,GAAG,YAAY,IAAI,QAAQ,EAAE,CAAA;IACxC,CAAC;IAED,OAAO,GAAG,YAAY,iBAAiB,CAAA;AAC3C,CAAC,CAAA;AAED,6HAA6H;AAC7H,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAsB,EAAU,EAAE;IACjE,MAAM,SAAS,GAAG;QACd,GAAG,IAAI,GAAG,CACN,MAAM,CAAC,YAAY;aACd,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,OAAO,CAAC;aACtE,GAAG,CAAC,4BAA4B,CAAC,CACzC;KACJ,CAAA;IAED,IAAI,CAAC,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { generate } from '@wix/interact';
|
|
2
|
+
import { getClickTriggerCss } from './clickTriggerCss';
|
|
3
|
+
import { registerConfigEffects } from './registerConfigEffects';
|
|
4
|
+
/** Register config-used presets, then emit animation FOUC CSS and click-trigger cursor rules. */
|
|
5
|
+
export const getV2ConfigCss = (config) => {
|
|
6
|
+
registerConfigEffects(config);
|
|
7
|
+
const animationCss = generate(config, true).trim();
|
|
8
|
+
const clickCss = getClickTriggerCss(config).trim();
|
|
9
|
+
return [animationCss, clickCss].filter(Boolean).join('\n');
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=configCss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,iGAAiG;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC7D,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC7B,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;AAC9D,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getV2ConfigStyleHeadContent: (css: string) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.
|
|
6
|
+
*/
|
|
7
|
+
const sanitizeCssForStyleElement = (css) => {
|
|
8
|
+
const tagIndex = css.search(/<[a-zA-Z/]/);
|
|
9
|
+
return tagIndex === -1 ? css : css.slice(0, tagIndex);
|
|
10
|
+
};
|
|
11
|
+
export const getV2ConfigStyleHeadContent = (css) => `<style>${sanitizeCssForStyleElement(css)}</style>`;
|
|
12
|
+
//# 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;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA"}
|
|
@@ -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,47 @@
|
|
|
1
|
+
import { INTERACT_V2_IMPORT_URL, WIX_MOTION_PRESETS_IMPORT_URL } from './cdnUrls';
|
|
2
|
+
import { collectNamedEffectTypes } from './namedEffectTypes';
|
|
3
|
+
import { filterKnownPresetTypes } from './motionPresets';
|
|
4
|
+
const getPresetTypes = (config) => filterKnownPresetTypes(collectNamedEffectTypes(config));
|
|
5
|
+
const getModuleUrls = (presetTypes) => presetTypes.length > 0 ? [INTERACT_V2_IMPORT_URL, WIX_MOTION_PRESETS_IMPORT_URL] : [INTERACT_V2_IMPORT_URL];
|
|
6
|
+
/**
|
|
7
|
+
* The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
|
|
8
|
+
* see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
|
|
9
|
+
* `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
|
|
10
|
+
* would download each module twice.
|
|
11
|
+
*/
|
|
12
|
+
export const getV2ModulePreloadHeadContent = (config) => getModuleUrls(getPresetTypes(config))
|
|
13
|
+
.map(url => `<link rel="modulepreload" href="${url}">`)
|
|
14
|
+
.join('');
|
|
15
|
+
export const getV2InteractionsScriptContent = (config, configId, isReducedMotion) => {
|
|
16
|
+
const presetTypes = getPresetTypes(config);
|
|
17
|
+
const bindings = ['{ Interact }'];
|
|
18
|
+
const imports = getModuleUrls(presetTypes).map(url => `import(\`${url}\`)`);
|
|
19
|
+
if (presetTypes.length > 0) {
|
|
20
|
+
bindings.push(`{ ${presetTypes.join(', ')} }`);
|
|
21
|
+
}
|
|
22
|
+
const registerEffects = presetTypes.length > 0 ? ` Interact.registerEffects({ ${presetTypes.join(', ')} })` : undefined;
|
|
23
|
+
return [
|
|
24
|
+
`const configElement = document.getElementById(\`${configId}\`)`,
|
|
25
|
+
'if (configElement) {',
|
|
26
|
+
' const config = JSON.parse(configElement.textContent)',
|
|
27
|
+
` const [${bindings.join(', ')}] = await Promise.all([`,
|
|
28
|
+
...imports.map(importCall => ` ${importCall},`),
|
|
29
|
+
' ])',
|
|
30
|
+
registerEffects,
|
|
31
|
+
` Interact.forceReducedMotion = ${isReducedMotion}`,
|
|
32
|
+
' Interact.setup({',
|
|
33
|
+
' scrollOptionsGetter: function () {',
|
|
34
|
+
' return document.getElementById(`site-root`)',
|
|
35
|
+
' },',
|
|
36
|
+
' allowA11yTriggers: true,',
|
|
37
|
+
' viewEnter: {',
|
|
38
|
+
' useSafeViewEnter: true,',
|
|
39
|
+
' },',
|
|
40
|
+
' })',
|
|
41
|
+
' Interact.create(config)',
|
|
42
|
+
'}',
|
|
43
|
+
]
|
|
44
|
+
.filter((line) => line !== undefined)
|
|
45
|
+
.join('\n');
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=interactionsScriptContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/interactionsScriptContent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAY,EAAE,CAAC,sBAAsB,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEpH,MAAM,aAAa,GAAG,CAAC,WAAqB,EAAY,EAAE,CACtD,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,EAAE,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAA;AAE/G;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAAsB,EAAU,EAAE,CAC5E,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;KAChC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAmC,GAAG,IAAI,CAAC;KACtD,IAAI,CAAC,EAAE,CAAC,CAAA;AAEjB,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC1C,MAAsB,EACtB,QAAgB,EAChB,eAAwB,EAClB,EAAE;IACR,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,CAAA;IACjC,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,GAAG,KAAK,CAAC,CAAA;IAE3E,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,eAAe,GACjB,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IAEpG,OAAO;QACH,mDAAmD,QAAQ,KAAK;QAChE,sBAAsB;QACtB,wDAAwD;QACxD,YAAY,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB;QACxD,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,UAAU,GAAG,CAAC;QAClD,MAAM;QACN,eAAe;QACf,mCAAmC,eAAe,EAAE;QACpD,oBAAoB;QACpB,wCAAwC;QACxC,mDAAmD;QACnD,QAAQ;QACR,8BAA8B;QAC9B,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"}
|
|
@@ -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,16 @@
|
|
|
1
|
+
import * as allPresets from '@wix/wix-motion-presets';
|
|
2
|
+
export const motionPresets = allPresets;
|
|
3
|
+
const knownPresetTypes = new Set(Object.keys(motionPresets));
|
|
4
|
+
export const isKnownPresetType = (type) => knownPresetTypes.has(type);
|
|
5
|
+
/**
|
|
6
|
+
* Preset names become bare JavaScript identifiers in the client loader. Filtering against the
|
|
7
|
+
* installed package prevents unknown names from creating invalid source or a failed import.
|
|
8
|
+
*/
|
|
9
|
+
export const filterKnownPresetTypes = (types) => {
|
|
10
|
+
const unknown = types.filter(type => !isKnownPresetType(type));
|
|
11
|
+
if (unknown.length > 0) {
|
|
12
|
+
console.warn(`Interactions: skipping unknown Wix motion preset type(s): ${unknown.join(', ')}`);
|
|
13
|
+
}
|
|
14
|
+
return types.filter(isKnownPresetType);
|
|
15
|
+
};
|
|
16
|
+
//# 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,UAAU,MAAM,yBAAyB,CAAA;AAQrD,MAAM,CAAC,MAAM,aAAa,GAAiC,UAAqD,CAAA;AAEhH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAEtF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAe,EAAY,EAAE;IAChE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,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,iBAAiB,CAAC,CAAA;AAC1C,CAAC,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Prefer the effects map; fall back to an inline named effect when an effect id misses. */
|
|
2
|
+
const resolveEffect = (config, effect) => {
|
|
3
|
+
if (!effect.effectId) {
|
|
4
|
+
return effect;
|
|
5
|
+
}
|
|
6
|
+
return config.effects?.[effect.effectId] ?? effect;
|
|
7
|
+
};
|
|
8
|
+
const readNamedEffectType = (effect) => {
|
|
9
|
+
if (!('namedEffect' in effect) || !effect.namedEffect) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const { type } = effect.namedEffect;
|
|
13
|
+
return typeof type === 'string' ? type : undefined;
|
|
14
|
+
};
|
|
15
|
+
export const collectNamedEffectTypes = (config) => {
|
|
16
|
+
const types = new Set();
|
|
17
|
+
const collectFromEffects = (effects) => {
|
|
18
|
+
for (const effect of effects) {
|
|
19
|
+
const type = readNamedEffectType(resolveEffect(config, effect));
|
|
20
|
+
if (type) {
|
|
21
|
+
types.add(type);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
for (const interaction of config.interactions) {
|
|
26
|
+
collectFromEffects(interaction.effects ?? []);
|
|
27
|
+
for (const sequence of interaction.sequences ?? []) {
|
|
28
|
+
if ('effects' in sequence) {
|
|
29
|
+
collectFromEffects(sequence.effects);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const referencedSequence = config.sequences?.[sequence.sequenceId];
|
|
33
|
+
collectFromEffects(referencedSequence?.effects ?? []);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [...types].sort();
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=namedEffectTypes.js.map
|
|
@@ -0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AC,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"}
|
|
@@ -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,23 @@
|
|
|
1
|
+
import { Interact } from '@wix/interact';
|
|
2
|
+
import { collectNamedEffectTypes } from './namedEffectTypes';
|
|
3
|
+
import { filterKnownPresetTypes, motionPresets } from './motionPresets';
|
|
4
|
+
// Interact's effect registry is process-global, so mirror it across repeated SSR renders.
|
|
5
|
+
const registeredTypes = new Set();
|
|
6
|
+
/**
|
|
7
|
+
* A named effect only runs once its preset is registered, so every path that reaches
|
|
8
|
+
* `Interact.create` or `generate` has to register the config's presets first.
|
|
9
|
+
*/
|
|
10
|
+
export const registerConfigEffects = (config) => {
|
|
11
|
+
const presetsToRegister = {};
|
|
12
|
+
for (const type of filterKnownPresetTypes(collectNamedEffectTypes(config))) {
|
|
13
|
+
if (registeredTypes.has(type)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
presetsToRegister[type] = motionPresets[type];
|
|
17
|
+
}
|
|
18
|
+
if (Object.keys(presetsToRegister).length > 0) {
|
|
19
|
+
Interact.registerEffects(presetsToRegister);
|
|
20
|
+
Object.keys(presetsToRegister).forEach(type => registeredTypes.add(type));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=registerConfigEffects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerConfigEffects.js","sourceRoot":"","sources":["../../../src/implementations/v2/registerConfigEffects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAKvE,0FAA0F;AAC1F,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAsB,EAAE,EAAE;IAC5D,MAAM,iBAAiB,GAAmB,EAAE,CAAA;IAE5C,KAAK,MAAM,IAAI,IAAI,sBAAsB,CAAC,uBAAuB,CAAC,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,aAAa,CAAC,IAAI,CAAiB,CAAA;IACjE,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,QAAQ,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/site-service-interactions",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "cjs/build/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -43,19 +43,22 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@wix/interact": "^
|
|
46
|
+
"@wix/interact": "^2.5.8",
|
|
47
47
|
"@wix/services-manager": "^0.2.20",
|
|
48
48
|
"@wix/services-manager-react": "^0.1.26",
|
|
49
49
|
"@wix/site-service-device-info": "1.0.2",
|
|
50
50
|
"@wix/site-service-experiments": "1.0.3",
|
|
51
|
+
"@wix/site-service-head-appender": "1.0.1",
|
|
51
52
|
"@wix/site-service-pages": "1.1.0",
|
|
52
53
|
"@wix/site-service-provide-css": "1.0.1",
|
|
53
|
-
"@wix/
|
|
54
|
-
"@wix/
|
|
54
|
+
"@wix/static-service": "1.0.19",
|
|
55
|
+
"@wix/wix-motion-presets": "^1.0.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@types/react": "^18.3.1",
|
|
59
|
+
"@types/react-dom": "^18.3.1",
|
|
58
60
|
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
59
62
|
"typescript": "^5.3.3",
|
|
60
63
|
"vitest": "4.1.0"
|
|
61
64
|
},
|
|
@@ -90,5 +93,5 @@
|
|
|
90
93
|
]
|
|
91
94
|
}
|
|
92
95
|
},
|
|
93
|
-
"falconPackageHash": "
|
|
96
|
+
"falconPackageHash": "6a5a4c22b50ccbb6b82b1bbe1aa5a588d4987df274e1b605bc05d9b6"
|
|
94
97
|
}
|