@wix/site-service-interactions 1.0.34 → 1.0.36
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 +38 -10
- package/cjs/build/implementations/coreInteractions.js.map +1 -1
- package/cjs/build/implementations/v2/BundledInteractions.d.ts +8 -0
- package/cjs/build/implementations/v2/BundledInteractions.js +69 -0
- package/cjs/build/implementations/v2/BundledInteractions.js.map +1 -0
- package/cjs/build/implementations/v2/ConfigStyleSheet.d.ts +17 -0
- package/cjs/build/implementations/v2/{ClickTriggerStyleSheet.js → ConfigStyleSheet.js} +8 -7
- package/cjs/build/implementations/v2/ConfigStyleSheet.js.map +1 -0
- package/cjs/build/implementations/v2/InteractionsScriptElement.d.ts +1 -1
- package/cjs/build/implementations/v2/InteractionsScriptElement.js +3 -3
- package/cjs/build/implementations/v2/InteractionsScriptElement.js.map +1 -1
- package/cjs/build/implementations/v2/backgroundScrollCss.d.ts +2 -0
- package/cjs/build/implementations/v2/backgroundScrollCss.js +169 -0
- package/cjs/build/implementations/v2/backgroundScrollCss.js.map +1 -0
- package/cjs/build/implementations/v2/configCss.d.ts +2 -0
- package/cjs/build/implementations/v2/configCss.js +11 -6
- package/cjs/build/implementations/v2/configCss.js.map +1 -1
- package/dist/implementations/coreInteractions.js +39 -11
- package/dist/implementations/coreInteractions.js.map +1 -1
- package/dist/implementations/v2/BundledInteractions.d.ts +8 -0
- package/dist/implementations/v2/BundledInteractions.js +32 -0
- package/dist/implementations/v2/BundledInteractions.js.map +1 -0
- package/dist/implementations/v2/ConfigStyleSheet.d.ts +17 -0
- package/dist/implementations/v2/{ClickTriggerStyleSheet.js → ConfigStyleSheet.js} +6 -5
- package/dist/implementations/v2/ConfigStyleSheet.js.map +1 -0
- package/dist/implementations/v2/InteractionsScriptElement.d.ts +1 -1
- package/dist/implementations/v2/InteractionsScriptElement.js +3 -3
- package/dist/implementations/v2/InteractionsScriptElement.js.map +1 -1
- package/dist/implementations/v2/backgroundScrollCss.d.ts +2 -0
- package/dist/implementations/v2/backgroundScrollCss.js +165 -0
- package/dist/implementations/v2/backgroundScrollCss.js.map +1 -0
- package/dist/implementations/v2/configCss.d.ts +2 -0
- package/dist/implementations/v2/configCss.js +8 -3
- package/dist/implementations/v2/configCss.js.map +1 -1
- package/package.json +2 -2
- package/src/implementations/coreInteractions.ts +48 -11
- package/src/implementations/v2/BundledInteractions.tsx +36 -0
- package/src/implementations/v2/{ClickTriggerStyleSheet.tsx → ConfigStyleSheet.tsx} +5 -4
- package/src/implementations/v2/InteractionsScriptElement.tsx +3 -3
- package/src/implementations/v2/backgroundScrollCss.ts +208 -0
- package/src/implementations/v2/configCss.ts +9 -3
- package/cjs/build/implementations/v2/ClickTriggerStyleSheet.d.ts +0 -16
- package/cjs/build/implementations/v2/ClickTriggerStyleSheet.js.map +0 -1
- package/dist/implementations/v2/ClickTriggerStyleSheet.d.ts +0 -16
- package/dist/implementations/v2/ClickTriggerStyleSheet.js.map +0 -1
|
@@ -14,14 +14,18 @@ const types_1 = require("@wix/site-service-head-appender/types");
|
|
|
14
14
|
const provide_component_1 = require("@wix/services-manager-react/core-services/provide-component");
|
|
15
15
|
const InteractionsScriptElement_1 = require("./InteractionsScriptElement");
|
|
16
16
|
const InteractionsScriptElement_2 = require("./v2/InteractionsScriptElement");
|
|
17
|
+
const BundledInteractions_1 = require("./v2/BundledInteractions");
|
|
17
18
|
const configCss_1 = require("./v2/configCss");
|
|
18
19
|
const configStyleHeadContent_1 = require("./v2/configStyleHeadContent");
|
|
19
20
|
const clickTriggerCss_1 = require("./v2/clickTriggerCss");
|
|
21
|
+
const backgroundScrollCss_1 = require("./v2/backgroundScrollCss");
|
|
20
22
|
const interactionsScriptContent_1 = require("./v2/interactionsScriptContent");
|
|
21
23
|
const authoredStyles_1 = require("./v2/authoredStyles");
|
|
22
24
|
const configEntries_1 = require("./configEntries");
|
|
23
25
|
/** An entry without interactions contributes CSS only; nothing has to load Interact for it. */
|
|
24
26
|
const getRuntimeConfigs = (entries) => entries.map(({ interact }) => interact).filter(({ interactions }) => interactions.length > 0);
|
|
27
|
+
/** Only the reactions entry plays background scroll presets; experiences don't support them yet. */
|
|
28
|
+
const getBackgroundCss = ({ namespace, interact }) => namespace === configEntries_1.REACTIONS_NAMESPACE ? (0, backgroundScrollCss_1.getBackgroundScrollCss)(interact) : '';
|
|
25
29
|
const initInteract = (entries, isReducedMotion) => {
|
|
26
30
|
const runtimeConfigs = getRuntimeConfigs(entries);
|
|
27
31
|
// v1 registers its interact-element on create, and a tag can only be defined once: starting it for
|
|
@@ -42,12 +46,16 @@ const initInteract = (entries, isReducedMotion) => {
|
|
|
42
46
|
interact_v1_1.Interact.create(config);
|
|
43
47
|
}
|
|
44
48
|
};
|
|
45
|
-
const
|
|
49
|
+
const getV2Css = (entries) => {
|
|
46
50
|
const generatedCss = entries
|
|
47
|
-
.
|
|
51
|
+
.flatMap((entry) => [(0, configCss_1.getV2ConfigCss)(entry.interact), getBackgroundCss(entry)])
|
|
52
|
+
.map((css) => css.trim())
|
|
48
53
|
.filter(Boolean)
|
|
49
54
|
.join('\n');
|
|
50
|
-
|
|
55
|
+
return [(0, authoredStyles_1.getAuthoredStylesCss)(entries).trim(), generatedCss].filter(Boolean).join('\n');
|
|
56
|
+
};
|
|
57
|
+
const getV2HeadContent = (entries) => {
|
|
58
|
+
const css = getV2Css(entries);
|
|
51
59
|
return ((getRuntimeConfigs(entries).length ? (0, interactionsScriptContent_1.getV2ModulePreloadHeadContent)() : '') +
|
|
52
60
|
(css ? (0, configStyleHeadContent_1.getV2ConfigStyleHeadContent)(css) : ''));
|
|
53
61
|
};
|
|
@@ -70,8 +78,20 @@ const initRuntime = (entries, isReducedMotion, getService, useV2) => {
|
|
|
70
78
|
addTopComponent((0, InteractionsScriptElement_1.createInteractionsScriptElement)(runtimeConfigs[0], isReducedMotion, pageId));
|
|
71
79
|
return;
|
|
72
80
|
}
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
// The server sends these with the generated CSS; the client adopts whatever it did not send.
|
|
82
|
+
const configCss = entries
|
|
83
|
+
.flatMap((entry) => [(0, clickTriggerCss_1.getClickTriggerCss)(entry.interact), getBackgroundCss(entry)])
|
|
84
|
+
.map((css) => css.trim())
|
|
85
|
+
.filter(Boolean);
|
|
86
|
+
addTopComponent((0, InteractionsScriptElement_2.createV2InteractionsScriptElement)(runtimeConfigs, isReducedMotion, pageId, configCss));
|
|
87
|
+
};
|
|
88
|
+
/** In place of `initRuntime`'s loader, on the same pages: the bundled runtime, with the server's head CSS rendered with the page. */
|
|
89
|
+
const initBundledRuntime = (entries, isReducedMotion, getService) => {
|
|
90
|
+
const runtimeConfigs = getRuntimeConfigs(entries);
|
|
91
|
+
if (!runtimeConfigs.length || !getService(definition_3.PagesDefinition).currentPageId()) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
getService(provide_component_1.ProvideComponentServiceDefinition).addTopComponent((0, BundledInteractions_1.createBundledV2Interactions)(runtimeConfigs, isReducedMotion, getV2Css(entries)));
|
|
75
95
|
};
|
|
76
96
|
const getInteractiveComps = (entries) => {
|
|
77
97
|
const keys = new Set();
|
|
@@ -88,10 +108,15 @@ const coreInteractions = ({ version, ...config }, getService) => {
|
|
|
88
108
|
// aliasing on those paths so named reaction effects remain resolvable.
|
|
89
109
|
const entries = (0, configEntries_1.resolveInteractKeyConflicts)((useV2 ? configEntries_1.getResolvedConfigEntries : configEntries_1.getInteractConfigEntries)(config));
|
|
90
110
|
if (useV2) {
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
// The editor renders pages only in the browser, so it gets no server head: it renders that CSS with the page and
|
|
112
|
+
// runs the runtime it bundles, rather than a loader that imports it from the CDN after the page has painted
|
|
113
|
+
if (process.env.PACKAGE_NAME === 'thunderbolt-ds') {
|
|
114
|
+
initBundledRuntime(entries, isReducedMotion, getService);
|
|
115
|
+
}
|
|
116
|
+
else if (!process.env.browser) {
|
|
117
|
+
// Both belong in the head: the preload links only help while the document is still parsing,
|
|
118
|
+
// and the generated CSS hides elements before their entrance effect, so it has to apply
|
|
119
|
+
// before the body renders.
|
|
95
120
|
const headContent = getV2HeadContent(entries);
|
|
96
121
|
// GENERAL rather than setHead's AFTER_SECURITY default: thunderbolt only reads the
|
|
97
122
|
// after-security bucket on its SEO path, so the default drops this on every normal
|
|
@@ -99,8 +124,11 @@ const coreInteractions = ({ version, ...config }, getService) => {
|
|
|
99
124
|
if (headContent) {
|
|
100
125
|
getService(definition_4.HeadAppenderDefinition).setHead(headContent, types_1.HeadContentType.GENERAL);
|
|
101
126
|
}
|
|
127
|
+
initRuntime(entries, isReducedMotion, getService, true);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
initRuntime(entries, isReducedMotion, getService, true);
|
|
102
131
|
}
|
|
103
|
-
initRuntime(entries, isReducedMotion, getService, true);
|
|
104
132
|
}
|
|
105
133
|
else if (isOpen('specs.thunderbolt.interactionsInSsr')) {
|
|
106
134
|
// Emits the config and loader scripts. Works in both environments: SSR serves markup the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../../src/implementations/coreInteractions.ts"],"names":[],"mappings":";;;AAAA,kDAA2C;AAE3C,yEAA+E;AAC/E,yEAAgF;AAChF,+FAA+F;AAC/F,+FAA+F;AAC/F,+FAA+F;AAC/F,kFAAkF;AAClF,qEAAsE;AACtE,2EAAmF;AACnF,iEAAuE;AACvE,mGAA+G;AAG/G,2EAA6E;AAC7E,8EAAkF;AAClF,8CAA+C;AAC/C,wEAAyE;AACzE,0DAAyD;AACzD,8EAA8E;AAC9E,wDAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../../src/implementations/coreInteractions.ts"],"names":[],"mappings":";;;AAAA,kDAA2C;AAE3C,yEAA+E;AAC/E,yEAAgF;AAChF,+FAA+F;AAC/F,+F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,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjC,4FAA4F;YAC5F,wFAAwF;YACxF,2BAA2B;YAC3B,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;YAC7C,mFAAmF;YACnF,mFAAmF;YACnF,wEAAwE;YACxE,IAAI,WAAW,EAAE,CAAC;gBACjB,UAAU,CAAC,mCAAsB,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,uBAAe,CAAC,OAAO,CAAC,CAAA;YACjF,CAAC;YACD,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACP,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QACxD,CAAC;IACF,CAAC;SAAM,IAAI,MAAM,CAAC,qCAAqC,CAAC,EAAE,CAAC;QAC1D,yFAAyF;QACzF,2FAA2F;QAC3F,sFAAsF;QACtF,iFAAiF;QACjF,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;IACzD,CAAC;SAAM,CAAC;QACP,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IACvC,CAAC;IAED,OAAO;QACN,gBAAgB,EAAE,mBAAmB,CAAC,OAAO,CAAC;KAC9C,CAAA;AACF,CAAC,CAAA;AA5CY,QAAA,gBAAgB,GAAhB,gBAAgB,CA4C5B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { InteractConfig } from '../../definition';
|
|
3
|
+
/**
|
|
4
|
+
* The page's interactions with the bundled runtime, for the editor, which renders pages only in the browser: the CSS
|
|
5
|
+
* the server would send in the head renders with the page, so its first paint already animates, and the instances are
|
|
6
|
+
* the page's own.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createBundledV2Interactions: (configs: InteractConfig[], isReducedMotion: boolean, css: string) => FunctionComponent;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.createBundledV2Interactions = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const configCss_1 = require("./configCss");
|
|
39
|
+
/**
|
|
40
|
+
* The page's interactions with the bundled runtime, for the editor, which renders pages only in the browser: the CSS
|
|
41
|
+
* the server would send in the head renders with the page, so its first paint already animates, and the instances are
|
|
42
|
+
* the page's own.
|
|
43
|
+
*/
|
|
44
|
+
const createBundledV2Interactions = (configs, isReducedMotion, css) => () => {
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
configCss_1.Interact.forceReducedMotion = isReducedMotion;
|
|
47
|
+
configCss_1.Interact.setup({
|
|
48
|
+
scrollOptionsGetter: () => document.getElementById('site-root'),
|
|
49
|
+
allowA11yTriggers: true,
|
|
50
|
+
viewEnter: {
|
|
51
|
+
useSafeViewEnter: true,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
// The editor's config can be mid-edit: a config that fails is skipped rather than taking the page down with it
|
|
55
|
+
const instances = configs.flatMap((config) => {
|
|
56
|
+
try {
|
|
57
|
+
return [configCss_1.Interact.create(config)];
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error('Failed running an interactions config', error);
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return () => instances.forEach((instance) => instance.destroy());
|
|
65
|
+
}, []);
|
|
66
|
+
return react_1.default.createElement("style", null, css);
|
|
67
|
+
};
|
|
68
|
+
exports.createBundledV2Interactions = createBundledV2Interactions;
|
|
69
|
+
//# sourceMappingURL=BundledInteractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundledInteractions.js","sourceRoot":"","sources":["../../../../src/implementations/v2/BundledInteractions.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AAGxC,2CAAsC;AAEtC;;;;GAIG;AACI,MAAM,2BAA2B,GACvC,CAAC,OAAyB,EAAE,eAAwB,EAAE,GAAW,EAAqB,EAAE,CACxF,GAAG,EAAE;IACJ,IAAA,iBAAS,EAAC,GAAG,EAAE;QACd,oBAAQ,CAAC,kBAAkB,GAAG,eAAe,CAAA;QAC7C,oBAAQ,CAAC,KAAK,CAAC;YACd,mBAAmB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC;YAC/D,iBAAiB,EAAE,IAAI;YACvB,SAAS,EAAE;gBACV,gBAAgB,EAAE,IAAI;aACtB;SACD,CAAC,CAAA;QACF,+GAA+G;QAC/G,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5C,IAAI,CAAC;gBACJ,OAAO,CAAC,oBAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;YACjC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;gBAC7D,OAAO,EAAE,CAAA;YACV,CAAC;QACF,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACjE,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,6CAAQ,GAAG,CAAS,CAAA;AAC5B,CAAC,CAAA;AAzBW,QAAA,2BAA2B,GAA3B,2BAA2B,CAyBtC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
type StyleSheetDocument = Pick<Document, 'adoptedStyleSheets' | 'querySelectorAll'>;
|
|
3
|
+
/**
|
|
4
|
+
* Adopts the rules the server did not already send as a constructable stylesheet, and returns a
|
|
5
|
+
* function that removes that sheet again.
|
|
6
|
+
*/
|
|
7
|
+
export declare const adoptMissingStyleSheet: (rules: Array<string>, document?: StyleSheetDocument | undefined) => () => void;
|
|
8
|
+
/**
|
|
9
|
+
* The server sends the rules it derives from the config (click-trigger cursors, background scroll
|
|
10
|
+
* sizing) in the head only for what it rendered, so content rendered on the client (client-side
|
|
11
|
+
* navigation, password-protected / members-only pages, a host that renders only on the client) never
|
|
12
|
+
* gets them. Adopt the missing ones while the page is mounted and remove them when navigating away.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ConfigStyleSheet: FunctionComponent<{
|
|
15
|
+
rules: Array<string>;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ConfigStyleSheet = exports.adoptMissingStyleSheet = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const configStyleHeadContent_1 = require("./configStyleHeadContent");
|
|
6
6
|
const getServerRenderedCss = (document) => Array.from(document.querySelectorAll(`style[${configStyleHeadContent_1.SSR_STYLE_ATTRIBUTE}]`))
|
|
@@ -28,13 +28,14 @@ const adoptMissingStyleSheet = (rules, document = globalThis.document) => {
|
|
|
28
28
|
};
|
|
29
29
|
exports.adoptMissingStyleSheet = adoptMissingStyleSheet;
|
|
30
30
|
/**
|
|
31
|
-
* The server sends the
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* The server sends the rules it derives from the config (click-trigger cursors, background scroll
|
|
32
|
+
* sizing) in the head only for what it rendered, so content rendered on the client (client-side
|
|
33
|
+
* navigation, password-protected / members-only pages, a host that renders only on the client) never
|
|
34
|
+
* gets them. Adopt the missing ones while the page is mounted and remove them when navigating away.
|
|
34
35
|
*/
|
|
35
|
-
const
|
|
36
|
+
const ConfigStyleSheet = ({ rules }) => {
|
|
36
37
|
(0, react_1.useEffect)(() => (0, exports.adoptMissingStyleSheet)(rules), [rules]);
|
|
37
38
|
return null;
|
|
38
39
|
};
|
|
39
|
-
exports.
|
|
40
|
-
//# sourceMappingURL=
|
|
40
|
+
exports.ConfigStyleSheet = ConfigStyleSheet;
|
|
41
|
+
//# sourceMappingURL=ConfigStyleSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigStyleSheet.js","sourceRoot":"","sources":["../../../../src/implementations/v2/ConfigStyleSheet.tsx"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,qEAA8D;AAI9D,MAAM,oBAAoB,GAAG,CAAC,QAA4B,EAAU,EAAE,CACrE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,4CAAmB,GAAG,CAAC,CAAC;KACpE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;KACvC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEb;;;GAGG;AACI,MAAM,sBAAsB,GAAG,CACrC,KAAoB,EACpB,QAAQ,GAAmC,UAAU,CAAC,QAAQ,EAC7D,EAAE;IACH,IAAI,CAAC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;QACnC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IAChB,CAAC;IAED,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IACxD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChF,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IAChB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,aAAa,EAAE,CAAA;IACjC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACtB,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;IAErE,OAAO,GAAG,EAAE;QACX,QAAQ,CAAC,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,CAAC,CAAA;IACjG,CAAC,CAAA;AACF,CAAC,CAAA;AArBY,QAAA,sBAAsB,GAAtB,sBAAsB,CAqBlC;AAED;;;;;GAKG;AACI,MAAM,gBAAgB,GAAgD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1F,IAAA,iBAAS,EAAC,GAAG,EAAE,CAAC,IAAA,QAAA,sBAAsB,EAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEvD,OAAO,IAAI,CAAA;AACZ,CAAC,CAAA;AAJY,QAAA,gBAAgB,GAAhB,gBAAgB,CAI5B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { FunctionComponent } from 'react';
|
|
2
2
|
import type { InteractConfig } from '@wix/interact';
|
|
3
|
-
export declare const createV2InteractionsScriptElement: (config: InteractConfig | InteractConfig[], isReducedMotion: boolean, pageId: string,
|
|
3
|
+
export declare const createV2InteractionsScriptElement: (config: InteractConfig | InteractConfig[], isReducedMotion: boolean, pageId: string, configCss?: Array<string>) => FunctionComponent;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createV2InteractionsScriptElement = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const reviveScriptElement_1 = require("../reviveScriptElement");
|
|
9
|
-
const
|
|
9
|
+
const ConfigStyleSheet_1 = require("./ConfigStyleSheet");
|
|
10
10
|
const interactionsScriptContent_1 = require("./interactionsScriptContent");
|
|
11
11
|
const DANGEROUSLY_SET_INNER_HTML = ['dangerously', 'Set', 'Inner', 'HTML'];
|
|
12
12
|
/**
|
|
@@ -14,7 +14,7 @@ const DANGEROUSLY_SET_INNER_HTML = ['dangerously', 'Set', 'Inner', 'HTML'];
|
|
|
14
14
|
* element early. `\u003c` is valid JSON that `JSON.parse` reads back as `<`.
|
|
15
15
|
*/
|
|
16
16
|
const serializeConfigForScriptElement = (config) => JSON.stringify(config).replace(/</g, '\\u003c');
|
|
17
|
-
const createV2InteractionsScriptElement = (config, isReducedMotion, pageId,
|
|
17
|
+
const createV2InteractionsScriptElement = (config, isReducedMotion, pageId, configCss = []) => () => {
|
|
18
18
|
// This ID is also interpolated into raw module-script text. Percent-encoding removes
|
|
19
19
|
// script delimiters and template-literal syntax while keeping the ID deterministic.
|
|
20
20
|
const safePageId = encodeURIComponent(pageId);
|
|
@@ -29,7 +29,7 @@ const createV2InteractionsScriptElement = (config, isReducedMotion, pageId, clic
|
|
|
29
29
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
30
30
|
react_1.default.createElement("script", { type: "application/json", id: configId, ...configProps }),
|
|
31
31
|
react_1.default.createElement("script", { type: "module", id: `interactions-loader-${safePageId}`, ref: reviveScriptElement_1.reviveScriptElement, ...loaderProps }),
|
|
32
|
-
|
|
32
|
+
configCss.length > 0 && react_1.default.createElement(ConfigStyleSheet_1.ConfigStyleSheet, { rules: configCss })));
|
|
33
33
|
};
|
|
34
34
|
exports.createV2InteractionsScriptElement = createV2InteractionsScriptElement;
|
|
35
35
|
//# sourceMappingURL=InteractionsScriptElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionsScriptElement.js","sourceRoot":"","sources":["../../../../src/implementations/v2/InteractionsScriptElement.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAGzB,gEAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"InteractionsScriptElement.js","sourceRoot":"","sources":["../../../../src/implementations/v2/InteractionsScriptElement.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAGzB,gEAA4D;AAC5D,yDAAqD;AACrD,2EAA4E;AAE5E,MAAM,0BAA0B,GAAG,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAE1E;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: true });
|
|
3
|
+
exports.getBackgroundScrollCss = void 0;
|
|
4
|
+
const motionPresets_1 = require("./motionPresets");
|
|
5
|
+
const BG_SKEW_ANGLE = 20;
|
|
6
|
+
const BG_ROTATE_ANGLE = 22;
|
|
7
|
+
const BG_PAN_SPEED = 0.2;
|
|
8
|
+
const IMAGE_PARALLAX_SPEED = 1.5;
|
|
9
|
+
// Mimics `position: fixed` with sticky positioning, which keeps working inside a transform or an overflow.
|
|
10
|
+
const FIXED_MEDIA_STYLE = {
|
|
11
|
+
'will-change': 'var(--motion-bgreveal-will-change)',
|
|
12
|
+
height: 'calc(100% + 200lvh)',
|
|
13
|
+
'margin-top': '-100lvh',
|
|
14
|
+
overflow: 'clip',
|
|
15
|
+
// a media rendered as a background image needs its own stacking context in some browsers
|
|
16
|
+
isolation: 'isolate',
|
|
17
|
+
};
|
|
18
|
+
const FIXED_IMG_STYLE = {
|
|
19
|
+
position: 'sticky',
|
|
20
|
+
height: 'max(100lvh, calc(100% - 200lvh))',
|
|
21
|
+
width: '100%',
|
|
22
|
+
top: '0px',
|
|
23
|
+
'margin-bottom': 'calc(100lvh - max(100lvh, var(--motion-comp-height, 100%)))',
|
|
24
|
+
display: 'block',
|
|
25
|
+
padding: '0px',
|
|
26
|
+
};
|
|
27
|
+
const FILL_STYLE = { height: '100%', width: '100%', position: 'absolute' };
|
|
28
|
+
// Firefox breaks the sticky imitation without it, https://bugzilla.mozilla.org/show_bug.cgi?id=1791232. It only
|
|
29
|
+
// defines the variable the fixed media style reads, so it is always rendered.
|
|
30
|
+
const FIREFOX_CSS = '@supports (-moz-appearance: none) {\nbody {\n--motion-bgreveal-will-change: transform;\n}\n}';
|
|
31
|
+
const toRadians = (degrees) => (degrees * Math.PI) / 180;
|
|
32
|
+
const numberParam = (namedEffect, name, fallback) => typeof namedEffect[name] === 'number' && namedEffect[name] ? namedEffect[name] : fallback;
|
|
33
|
+
const isFixedStyle = (namedEffect) => (namedEffect.type === 'BgZoom' && namedEffect.direction === 'in') ||
|
|
34
|
+
['BgReveal', 'BgParallax', 'BgFake3D'].includes(namedEffect.type);
|
|
35
|
+
const MEDIA_STYLES = {
|
|
36
|
+
BgParallax: () => FIXED_MEDIA_STYLE,
|
|
37
|
+
BgReveal: () => FIXED_MEDIA_STYLE,
|
|
38
|
+
BgFake3D: () => FIXED_MEDIA_STYLE,
|
|
39
|
+
BgSkew: (namedEffect) => {
|
|
40
|
+
const tan = Math.tan(toRadians(numberParam(namedEffect, 'angle', BG_SKEW_ANGLE)));
|
|
41
|
+
return { 'padding-bottom': `${(100 * tan).toFixed(3)}%`, 'margin-top': `${(-50 * tan).toFixed(3)}%` };
|
|
42
|
+
},
|
|
43
|
+
BgRotate: (namedEffect) => {
|
|
44
|
+
const angle = toRadians(numberParam(namedEffect, 'angle', BG_ROTATE_ANGLE));
|
|
45
|
+
const cos = (100 * Math.cos(angle)).toFixed(3);
|
|
46
|
+
const sin = (100 * Math.sin(angle)).toFixed(3);
|
|
47
|
+
return {
|
|
48
|
+
width: `max(100%, calc(${cos}cqw + ${sin}cqh))`,
|
|
49
|
+
height: `max(100%, calc(${sin}cqw + ${cos}cqh))`,
|
|
50
|
+
translate: 'calc(50cqw - 50%) calc(50cqh - 50%)',
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
BgPan: (namedEffect) => {
|
|
54
|
+
const speed = numberParam(namedEffect, 'speed', BG_PAN_SPEED);
|
|
55
|
+
return { position: 'relative', width: `${100 * (1 + speed)}%`, left: `-${50 * speed}%` };
|
|
56
|
+
},
|
|
57
|
+
BgZoom: (namedEffect) => isFixedStyle(namedEffect)
|
|
58
|
+
? FIXED_MEDIA_STYLE
|
|
59
|
+
: { position: 'relative', width: '115%', height: '115%', left: '-7.5%', top: '-7.5%' },
|
|
60
|
+
ImageParallax: (namedEffect) => ({
|
|
61
|
+
height: `${100 * numberParam(namedEffect, 'speed', IMAGE_PARALLAX_SPEED)}%`,
|
|
62
|
+
position: 'relative',
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
const IMG_STYLES = {
|
|
66
|
+
BgParallax: () => FIXED_IMG_STYLE,
|
|
67
|
+
BgReveal: () => FIXED_IMG_STYLE,
|
|
68
|
+
BgFake3D: () => FIXED_IMG_STYLE,
|
|
69
|
+
BgZoom: (namedEffect) => (isFixedStyle(namedEffect) ? FIXED_IMG_STYLE : {}),
|
|
70
|
+
BgSkew: () => FILL_STYLE,
|
|
71
|
+
ImageParallax: () => FILL_STYLE,
|
|
72
|
+
};
|
|
73
|
+
const BACKGROUND_SCROLL_EFFECTS = new Set([
|
|
74
|
+
'BgCloseUp',
|
|
75
|
+
'BgFade',
|
|
76
|
+
'BgFadeBack',
|
|
77
|
+
'BgPullBack',
|
|
78
|
+
...Object.keys(MEDIA_STYLES),
|
|
79
|
+
...Object.keys(IMG_STYLES),
|
|
80
|
+
]);
|
|
81
|
+
const escapeCssAttr = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
82
|
+
const rule = (selector, style) => `${selector} {\n${Object.entries(style)
|
|
83
|
+
.map(([property, value]) => `${property}: ${value};`)
|
|
84
|
+
.join('\n')}\n}`;
|
|
85
|
+
/**
|
|
86
|
+
* Keys are comp paths, so the last segment is the comp id. A part carries `<PART> <comp id>`, and a repeated
|
|
87
|
+
* comp's id carries its item, `<comp id>__<item>`, on the root and on its parts alike.
|
|
88
|
+
*/
|
|
89
|
+
const getSelectors = (key, selectorConditions) => {
|
|
90
|
+
const compId = escapeCssAttr(key.slice(key.lastIndexOf('/') + 1));
|
|
91
|
+
const root = `:is([id="${compId}"], [id^="${compId}__"])${selectorConditions}`;
|
|
92
|
+
const part = (name) => `:is([data-motion-part="${name} ${compId}"], [data-motion-part^="${name} ${compId}__"])`;
|
|
93
|
+
// Every part is matched under the root, as Thunderbolt does, so a root that is itself the layer is not matched.
|
|
94
|
+
return {
|
|
95
|
+
layer: `${root} ${part('BG_LAYER')}`,
|
|
96
|
+
media: `${root} ${part('BG_MEDIA')}`,
|
|
97
|
+
image: `${root}:not([data-show-canvas]) ${part('BG_IMG')}, ${root}[data-has-alpha="true"] canvas`,
|
|
98
|
+
imageXMedia: `${root}[data-testid="imageX"] ${part('BG_MEDIA')}`,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const getEffectRules = (namedEffect, key, selectorConditions) => {
|
|
102
|
+
const selectors = getSelectors(key, selectorConditions);
|
|
103
|
+
const mediaStyle = MEDIA_STYLES[namedEffect.type]?.(namedEffect);
|
|
104
|
+
const imgStyle = IMG_STYLES[namedEffect.type]?.(namedEffect);
|
|
105
|
+
const isRotate = namedEffect.type === 'BgRotate';
|
|
106
|
+
const rules = [
|
|
107
|
+
...(mediaStyle ? [rule(selectors.media, mediaStyle)] : []),
|
|
108
|
+
...(imgStyle && Object.keys(imgStyle).length ? [rule(selectors.image, imgStyle)] : []),
|
|
109
|
+
rule(selectors.layer, { overflow: 'clip', contain: 'layout', ...(isRotate && { 'container-type': 'size' }) }),
|
|
110
|
+
];
|
|
111
|
+
if (isRotate) {
|
|
112
|
+
const angle = toRadians(numberParam(namedEffect, 'angle', BG_ROTATE_ANGLE));
|
|
113
|
+
const grow = (100 * (Math.sqrt(1 + Math.tan(angle) ** 2) - 1)).toFixed(3);
|
|
114
|
+
const sin = (100 * Math.sin(angle)).toFixed(3);
|
|
115
|
+
rules.push(`@container (min-aspect-ratio: ${Math.tan(Math.PI / 2 - angle).toFixed(3)}) {\n${rule(selectors.media, {
|
|
116
|
+
width: `calc(100% + min(${grow}%, ${sin}cqh))`,
|
|
117
|
+
})}\n}`, `@container (max-aspect-ratio: ${Math.tan(angle).toFixed(3)}) {\n${rule(selectors.media, {
|
|
118
|
+
height: `calc(100% + min(${grow}%, ${sin}cqw))`,
|
|
119
|
+
})}\n}`);
|
|
120
|
+
}
|
|
121
|
+
else if (isFixedStyle(namedEffect)) {
|
|
122
|
+
// Safari has a bug like Firefox's for an ImageX media; a transform solves it
|
|
123
|
+
rules.push(rule(selectors.imageXMedia, { transform: 'translate3d(0,0,0)' }));
|
|
124
|
+
}
|
|
125
|
+
return rules;
|
|
126
|
+
};
|
|
127
|
+
const getConditions = (interact, conditionIds) => {
|
|
128
|
+
const conditions = [...new Set(conditionIds)]
|
|
129
|
+
.map((id) => interact.conditions?.[id])
|
|
130
|
+
.filter((condition) => Boolean(condition?.predicate));
|
|
131
|
+
const predicatesOf = (type) => conditions.filter((condition) => condition.type === type).map(({ predicate }) => predicate);
|
|
132
|
+
const media = predicatesOf('media');
|
|
133
|
+
return {
|
|
134
|
+
media: media.length ? `(${media.join(') and (')})` : '',
|
|
135
|
+
selector: predicatesOf('selector')
|
|
136
|
+
.map((predicate) => `:is(${predicate})`)
|
|
137
|
+
.join(''),
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const toMediaBlock = ([media, rules]) => media ? `@media ${media} {\n${[...rules].join('\n')}\n}` : [...rules].join('\n');
|
|
141
|
+
const getBackgroundScrollCss = (interact) => {
|
|
142
|
+
const rulesByMedia = new Map();
|
|
143
|
+
for (const interaction of interact.interactions) {
|
|
144
|
+
// sequences don't play scrub animations, so a background scroll preset is only ever an interaction's effect
|
|
145
|
+
for (const inlineEffect of interaction.effects ?? []) {
|
|
146
|
+
// an effectId points at interact.effects; the inline fields override it, as interact reads them
|
|
147
|
+
const effect = {
|
|
148
|
+
...(inlineEffect.effectId ? interact.effects?.[inlineEffect.effectId] : undefined),
|
|
149
|
+
...inlineEffect,
|
|
150
|
+
};
|
|
151
|
+
const { namedEffect } = effect;
|
|
152
|
+
const key = effect.key ?? interaction.key;
|
|
153
|
+
const type = namedEffect?.type?.startsWith(motionPresets_1.LEGACY_PREFIX)
|
|
154
|
+
? namedEffect.type.slice(motionPresets_1.LEGACY_PREFIX.length)
|
|
155
|
+
: undefined;
|
|
156
|
+
if (!namedEffect || !type || !BACKGROUND_SCROLL_EFFECTS.has(type) || !key) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const params = { ...namedEffect, type };
|
|
160
|
+
const conditions = getConditions(interact, [...(interaction.conditions ?? []), ...(effect.conditions ?? [])]);
|
|
161
|
+
const rules = rulesByMedia.get(conditions.media) ?? new Set();
|
|
162
|
+
getEffectRules(params, key, conditions.selector).forEach((css) => rules.add(css));
|
|
163
|
+
rulesByMedia.set(conditions.media, rules);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return `@media (prefers-reduced-motion: no-preference) {\n${[...[...rulesByMedia].map(toMediaBlock), FIREFOX_CSS].join('\n')}\n}`;
|
|
167
|
+
};
|
|
168
|
+
exports.getBackgroundScrollCss = getBackgroundScrollCss;
|
|
169
|
+
//# sourceMappingURL=backgroundScrollCss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backgroundScrollCss.js","sourceRoot":"","sources":["../../../../src/implementations/v2/backgroundScrollCss.ts"],"names":[],"mappings":";;;AACA,mDAA+C;AAa/C,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,MAAM,eAAe,GAAG,EAAE,CAAA;AAC1B,MAAM,YAAY,GAAG,GAAG,CAAA;AACxB,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC,2GAA2G;AAC3G,MAAM,iBAAiB,GAAU;IAChC,aAAa,EAAE,oCAAoC;IACnD,MAAM,EAAE,qBAAqB;IAC7B,YAAY,EAAE,SAAS;IACvB,QAAQ,EAAE,MAAM;IAChB,yFAAyF;IACzF,SAAS,EAAE,SAAS;CACpB,CAAA;AAED,MAAM,eAAe,GAAU;IAC9B,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,kCAAkC;IAC1C,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,KAAK;IACV,eAAe,EAAE,6DAA6D;IAC9E,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,KAAK;CACd,CAAA;AAED,MAAM,UAAU,GAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAA;AAEjF,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AAC,CAAC,CAAC,CAAA;YAC7G,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,EAAU,CAAA;YACrE,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YACjF,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC1C,CAAC;IACF,CAAC;IAED,OAAO,qDAAqD,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAA;AAClI,CAAC,CAAA;AA7BY,QAAA,sBAAsB,GAAtB,sBAAsB,CA6BlC"}
|
|
@@ -33,12 +33,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getV2ConfigCss = exports.motionPresets = void 0;
|
|
36
|
+
exports.getV2ConfigCss = exports.motionPresets = exports.Interact = void 0;
|
|
37
37
|
const allLegacyPresets = __importStar(require("@wix/wix-motion-presets"));
|
|
38
38
|
const allPresets = __importStar(require("@wix/motion-presets"));
|
|
39
|
-
|
|
39
|
+
// Through the namespace: web.js only re-exports the core and installs `Interact.defineInteractElement`, which
|
|
40
|
+
// `Interact.create` needs to run on `<interact-element>`. With named imports, a bundler that trusts the package's
|
|
41
|
+
// `sideEffects: false` links them past web.js to the core and drops it.
|
|
42
|
+
const interactWeb = __importStar(require("@wix/interact/web"));
|
|
40
43
|
const clickTriggerCss_1 = require("./clickTriggerCss");
|
|
41
44
|
const motionPresets_1 = require("./motionPresets");
|
|
45
|
+
const { generate } = interactWeb;
|
|
46
|
+
({ Interact: exports.Interact } = interactWeb);
|
|
42
47
|
const isEffectModule = (value) => typeof value === 'object' && value !== null && 'web' in value && 'getNames' in value;
|
|
43
48
|
const getPresetModules = (namespace, prefix = '') => Object.fromEntries(Object.entries(namespace)
|
|
44
49
|
.filter(([, value]) => isEffectModule(value))
|
|
@@ -51,12 +56,12 @@ exports.motionPresets = {
|
|
|
51
56
|
...getPresetModules(allPresets),
|
|
52
57
|
...getPresetModules(allLegacyPresets, motionPresets_1.LEGACY_PREFIX),
|
|
53
58
|
};
|
|
54
|
-
// Interact's registry is process-global.
|
|
55
|
-
//
|
|
56
|
-
|
|
59
|
+
// Interact's registry is process-global. Only the server's bundle and the editor's pull this module in (`process.env`
|
|
60
|
+
// DCE), so both namespaces are registered once per Node process or document.
|
|
61
|
+
exports.Interact.registerEffects(exports.motionPresets);
|
|
57
62
|
/** Emit animation FOUC CSS and click-trigger cursor rules. */
|
|
58
63
|
const getV2ConfigCss = (config) => {
|
|
59
|
-
const animationCss =
|
|
64
|
+
const animationCss = generate(config, true).trim();
|
|
60
65
|
const clickCss = (0, clickTriggerCss_1.getClickTriggerCss)(config).trim();
|
|
61
66
|
return [animationCss, clickCss].filter(Boolean).join('\n');
|
|
62
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,gBAAgB,oDAA+B;AAC3D,MAAY,UAAU,gDAA2B;AACjD,
|
|
1
|
+
{"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,gBAAgB,oDAA+B;AAC3D,MAAY,UAAU,gDAA2B;AACjD,8GAA8G;AAC9G,kHAAkH;AAClH,wEAAwE;AACxE,MAAY,WAAW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