@wix/site-service-interactions 1.0.30 → 1.0.32
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/definition/index.d.ts +4 -1
- package/cjs/build/definition/index.js.map +1 -1
- package/cjs/build/implementations/configEntries.d.ts +6 -4
- package/cjs/build/implementations/configEntries.js +17 -8
- package/cjs/build/implementations/configEntries.js.map +1 -1
- package/dist/definition/index.d.ts +4 -1
- package/dist/definition/index.js.map +1 -1
- package/dist/implementations/configEntries.d.ts +6 -4
- package/dist/implementations/configEntries.js +17 -8
- package/dist/implementations/configEntries.js.map +1 -1
- package/package.json +3 -3
- package/src/definition/index.ts +4 -1
- package/src/implementations/configEntries.ts +22 -8
|
@@ -18,7 +18,10 @@ export type InteractStyleRule = {
|
|
|
18
18
|
};
|
|
19
19
|
/** Set of interactions in the host's config, with the CSS rules that go with it. */
|
|
20
20
|
export type InteractConfigEntry = {
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Key of the component that scopes the entry's CSS rules. Required when `styles` isn't empty. Outside the
|
|
23
|
+
* reactions entry it also claims that component and everything inside it: reactions there are dropped.
|
|
24
|
+
*/
|
|
22
25
|
namespace?: string;
|
|
23
26
|
/** The entry's interactions and effects, in the `@wix/interact` config format. */
|
|
24
27
|
interact: InteractConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyD;AA0G5C,QAAA,sBAAsB,GAAG,IAAA,oCAAmB,EACxD,gCAAgC,CAChC,CAAA"}
|
|
@@ -5,9 +5,11 @@ export declare const getResolvedConfigEntries: (config: IInteractionsServiceConf
|
|
|
5
5
|
export declare const getInteractiveKeys: ({ interact }: InteractConfigEntry) => Set<string>;
|
|
6
6
|
/**
|
|
7
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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* by two entries would silently drop one of them. Experience entries own the keys they declare, and an
|
|
9
|
+
* experience's namespace (its section's comp path) is a scope no reaction may touch: the section and
|
|
10
|
+
* every component inside it belong to the experience, whatever keys the experience itself declares.
|
|
11
|
+
* Both are stripped from the reactions entry by dropping whole interactions whose resolved keys overlap.
|
|
12
|
+
* Top-level effect and sequence libraries are left intact. A collision between two experience entries
|
|
13
|
+
* stays an error, since neither of them is authoritative.
|
|
12
14
|
*/
|
|
13
15
|
export declare const resolveInteractKeyConflicts: (entries: InteractConfigEntry[]) => InteractConfigEntry[];
|
|
@@ -35,29 +35,38 @@ const getInteractiveKeys = ({ interact }) => {
|
|
|
35
35
|
return keys;
|
|
36
36
|
};
|
|
37
37
|
exports.getInteractiveKeys = getInteractiveKeys;
|
|
38
|
-
|
|
38
|
+
/** Keys are comp paths, so a component inside a section has the section's path as a prefix. */
|
|
39
|
+
const isInScope = (key, scope) => key === scope || key.startsWith(`${scope}/`);
|
|
40
|
+
const dropOverriddenKeys = (entry, overriddenKeys, scopes) => {
|
|
39
41
|
const { interact } = entry;
|
|
42
|
+
const isOverridden = (key) => overriddenKeys.has(key) || scopes.some((scope) => isInScope(key, scope));
|
|
40
43
|
return {
|
|
41
44
|
...entry,
|
|
42
45
|
interact: {
|
|
43
46
|
...interact,
|
|
44
|
-
interactions: interact.interactions.filter((interaction) => ![...getInteractionKeys(interact, interaction)].some(
|
|
47
|
+
interactions: interact.interactions.filter((interaction) => ![...getInteractionKeys(interact, interaction)].some(isOverridden)),
|
|
45
48
|
},
|
|
46
49
|
};
|
|
47
50
|
};
|
|
48
51
|
/**
|
|
49
52
|
* Interact resolves a custom-element key to the first instance containing that key, so a key shared
|
|
50
|
-
* by two entries would silently drop one of them. Experience entries own the keys they declare
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
53
|
+
* by two entries would silently drop one of them. Experience entries own the keys they declare, and an
|
|
54
|
+
* experience's namespace (its section's comp path) is a scope no reaction may touch: the section and
|
|
55
|
+
* every component inside it belong to the experience, whatever keys the experience itself declares.
|
|
56
|
+
* Both are stripped from the reactions entry by dropping whole interactions whose resolved keys overlap.
|
|
57
|
+
* Top-level effect and sequence libraries are left intact. A collision between two experience entries
|
|
58
|
+
* stays an error, since neither of them is authoritative.
|
|
54
59
|
*/
|
|
55
60
|
const resolveInteractKeyConflicts = (entries) => {
|
|
56
61
|
const owners = new Map();
|
|
62
|
+
const scopes = [];
|
|
57
63
|
entries.forEach((entry, index) => {
|
|
58
64
|
if (entry.namespace === exports.REACTIONS_NAMESPACE) {
|
|
59
65
|
return;
|
|
60
66
|
}
|
|
67
|
+
if (entry.namespace) {
|
|
68
|
+
scopes.push(entry.namespace);
|
|
69
|
+
}
|
|
61
70
|
const owner = entry.namespace ?? `entry-${index}`;
|
|
62
71
|
for (const key of (0, exports.getInteractiveKeys)(entry)) {
|
|
63
72
|
const existingOwner = owners.get(key);
|
|
@@ -68,11 +77,11 @@ const resolveInteractKeyConflicts = (entries) => {
|
|
|
68
77
|
owners.set(key, owner);
|
|
69
78
|
}
|
|
70
79
|
});
|
|
71
|
-
if (!owners.size) {
|
|
80
|
+
if (!owners.size && !scopes.length) {
|
|
72
81
|
return entries;
|
|
73
82
|
}
|
|
74
83
|
const overriddenKeys = new Set(owners.keys());
|
|
75
|
-
return entries.map((entry) => entry.namespace === exports.REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys) : entry);
|
|
84
|
+
return entries.map((entry) => entry.namespace === exports.REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys, scopes) : entry);
|
|
76
85
|
};
|
|
77
86
|
exports.resolveInteractKeyConflicts = resolveInteractKeyConflicts;
|
|
78
87
|
//# sourceMappingURL=config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AC,SAAS,CAAC,CAAA;QAC7B,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,IAAI,SAAS,KAAK,EAAE,CAAA;QACjD,KAAK,MAAM,GAAG,IAAI,IAAA,QAAA,kBAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACrC,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CACd,4BAA4B,GAAG,mBAAmB,aAAa,UAAU,KAAK,KAAK;oBAClF,4CAA4C,CAC7C,CAAA;YACF,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACvB,CAAC;IACF,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpC,OAAO,OAAO,CAAA;IACf,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC5B,KAAK,CAAC,SAAS,KAAK,QAAA,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CACnG,CAAA;AACF,CAAC,CAAA;AAhCY,QAAA,2BAA2B,GAA3B,2BAA2B,CAgCvC"}
|
|
@@ -18,7 +18,10 @@ export type InteractStyleRule = {
|
|
|
18
18
|
};
|
|
19
19
|
/** Set of interactions in the host's config, with the CSS rules that go with it. */
|
|
20
20
|
export type InteractConfigEntry = {
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Key of the component that scopes the entry's CSS rules. Required when `styles` isn't empty. Outside the
|
|
23
|
+
* reactions entry it also claims that component and everything inside it: reactions there are dropped.
|
|
24
|
+
*/
|
|
22
25
|
namespace?: string;
|
|
23
26
|
/** The entry's interactions and effects, in the `@wix/interact` config format. */
|
|
24
27
|
interact: InteractConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AA0GzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CACxD,gCAAgC,CAChC,CAAA"}
|
|
@@ -5,9 +5,11 @@ export declare const getResolvedConfigEntries: (config: IInteractionsServiceConf
|
|
|
5
5
|
export declare const getInteractiveKeys: ({ interact }: InteractConfigEntry) => Set<string>;
|
|
6
6
|
/**
|
|
7
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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* by two entries would silently drop one of them. Experience entries own the keys they declare, and an
|
|
9
|
+
* experience's namespace (its section's comp path) is a scope no reaction may touch: the section and
|
|
10
|
+
* every component inside it belong to the experience, whatever keys the experience itself declares.
|
|
11
|
+
* Both are stripped from the reactions entry by dropping whole interactions whose resolved keys overlap.
|
|
12
|
+
* Top-level effect and sequence libraries are left intact. A collision between two experience entries
|
|
13
|
+
* stays an error, since neither of them is authoritative.
|
|
12
14
|
*/
|
|
13
15
|
export declare const resolveInteractKeyConflicts: (entries: InteractConfigEntry[]) => InteractConfigEntry[];
|
|
@@ -29,29 +29,38 @@ export const getInteractiveKeys = ({ interact }) => {
|
|
|
29
29
|
}
|
|
30
30
|
return keys;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
/** Keys are comp paths, so a component inside a section has the section's path as a prefix. */
|
|
33
|
+
const isInScope = (key, scope) => key === scope || key.startsWith(`${scope}/`);
|
|
34
|
+
const dropOverriddenKeys = (entry, overriddenKeys, scopes) => {
|
|
33
35
|
const { interact } = entry;
|
|
36
|
+
const isOverridden = (key) => overriddenKeys.has(key) || scopes.some((scope) => isInScope(key, scope));
|
|
34
37
|
return {
|
|
35
38
|
...entry,
|
|
36
39
|
interact: {
|
|
37
40
|
...interact,
|
|
38
|
-
interactions: interact.interactions.filter((interaction) => ![...getInteractionKeys(interact, interaction)].some(
|
|
41
|
+
interactions: interact.interactions.filter((interaction) => ![...getInteractionKeys(interact, interaction)].some(isOverridden)),
|
|
39
42
|
},
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
45
|
/**
|
|
43
46
|
* Interact resolves a custom-element key to the first instance containing that key, so a key shared
|
|
44
|
-
* by two entries would silently drop one of them. Experience entries own the keys they declare
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
47
|
+
* by two entries would silently drop one of them. Experience entries own the keys they declare, and an
|
|
48
|
+
* experience's namespace (its section's comp path) is a scope no reaction may touch: the section and
|
|
49
|
+
* every component inside it belong to the experience, whatever keys the experience itself declares.
|
|
50
|
+
* Both are stripped from the reactions entry by dropping whole interactions whose resolved keys overlap.
|
|
51
|
+
* Top-level effect and sequence libraries are left intact. A collision between two experience entries
|
|
52
|
+
* stays an error, since neither of them is authoritative.
|
|
48
53
|
*/
|
|
49
54
|
export const resolveInteractKeyConflicts = (entries) => {
|
|
50
55
|
const owners = new Map();
|
|
56
|
+
const scopes = [];
|
|
51
57
|
entries.forEach((entry, index) => {
|
|
52
58
|
if (entry.namespace === REACTIONS_NAMESPACE) {
|
|
53
59
|
return;
|
|
54
60
|
}
|
|
61
|
+
if (entry.namespace) {
|
|
62
|
+
scopes.push(entry.namespace);
|
|
63
|
+
}
|
|
55
64
|
const owner = entry.namespace ?? `entry-${index}`;
|
|
56
65
|
for (const key of getInteractiveKeys(entry)) {
|
|
57
66
|
const existingOwner = owners.get(key);
|
|
@@ -62,10 +71,10 @@ export const resolveInteractKeyConflicts = (entries) => {
|
|
|
62
71
|
owners.set(key, owner);
|
|
63
72
|
}
|
|
64
73
|
});
|
|
65
|
-
if (!owners.size) {
|
|
74
|
+
if (!owners.size && !scopes.length) {
|
|
66
75
|
return entries;
|
|
67
76
|
}
|
|
68
77
|
const overriddenKeys = new Set(owners.keys());
|
|
69
|
-
return entries.map((entry) => entry.namespace === REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys) : entry);
|
|
78
|
+
return entries.map((entry) => entry.namespace === REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys, scopes) : entry);
|
|
70
79
|
};
|
|
71
80
|
//# sourceMappingURL=configEntries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configEntries.js","sourceRoot":"","sources":["../../src/implementations/configEntries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAA;AAM9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAkC,EAAyB,EAAE,CACrG,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC,CAAA;AAE9F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAkC,EAAyB,EAAE,CACrG,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC9C,KAAK,CAAC,SAAS,KAAK,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,uBAAuB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,K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AAA;AACF,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.32",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@wix/services-manager-react": "^0.1.26",
|
|
64
64
|
"@wix/site-service-device-info": "1.0.8",
|
|
65
65
|
"@wix/site-service-experiments": "1.0.8",
|
|
66
|
-
"@wix/site-service-head-appender": "1.0.
|
|
66
|
+
"@wix/site-service-head-appender": "1.0.8",
|
|
67
67
|
"@wix/site-service-provide-css": "1.0.8",
|
|
68
68
|
"@wix/static-service": "1.0.22",
|
|
69
69
|
"@wix/viewer-service-pages": "1.0.18",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
]
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
-
"falconPackageHash": "
|
|
100
|
+
"falconPackageHash": "6fc4513abae14f4d5be58d0feefc85187d0f033dc6f629ce74f18c02"
|
|
101
101
|
}
|
package/src/definition/index.ts
CHANGED
|
@@ -22,7 +22,10 @@ export type InteractStyleRule = {
|
|
|
22
22
|
|
|
23
23
|
/** Set of interactions in the host's config, with the CSS rules that go with it. */
|
|
24
24
|
export type InteractConfigEntry = {
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Key of the component that scopes the entry's CSS rules. Required when `styles` isn't empty. Outside the
|
|
27
|
+
* reactions entry it also claims that component and everything inside it: reactions there are dropped.
|
|
28
|
+
*/
|
|
26
29
|
namespace?: string
|
|
27
30
|
/** The entry's interactions and effects, in the `@wix/interact` config format. */
|
|
28
31
|
interact: InteractConfig
|
|
@@ -51,15 +51,23 @@ export const getInteractiveKeys = ({ interact }: InteractConfigEntry): Set<strin
|
|
|
51
51
|
return keys
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
/** Keys are comp paths, so a component inside a section has the section's path as a prefix. */
|
|
55
|
+
const isInScope = (key: string, scope: string): boolean => key === scope || key.startsWith(`${scope}/`)
|
|
56
|
+
|
|
57
|
+
const dropOverriddenKeys = (
|
|
58
|
+
entry: InteractConfigEntry,
|
|
59
|
+
overriddenKeys: Set<string>,
|
|
60
|
+
scopes: readonly string[]
|
|
61
|
+
): InteractConfigEntry => {
|
|
55
62
|
const { interact } = entry
|
|
63
|
+
const isOverridden = (key: string) => overriddenKeys.has(key) || scopes.some((scope) => isInScope(key, scope))
|
|
56
64
|
|
|
57
65
|
return {
|
|
58
66
|
...entry,
|
|
59
67
|
interact: {
|
|
60
68
|
...interact,
|
|
61
69
|
interactions: interact.interactions.filter(
|
|
62
|
-
(interaction) => ![...getInteractionKeys(interact, interaction)].some(
|
|
70
|
+
(interaction) => ![...getInteractionKeys(interact, interaction)].some(isOverridden)
|
|
63
71
|
),
|
|
64
72
|
},
|
|
65
73
|
}
|
|
@@ -67,18 +75,24 @@ const dropOverriddenKeys = (entry: InteractConfigEntry, overriddenKeys: Set<stri
|
|
|
67
75
|
|
|
68
76
|
/**
|
|
69
77
|
* Interact resolves a custom-element key to the first instance containing that key, so a key shared
|
|
70
|
-
* by two entries would silently drop one of them. Experience entries own the keys they declare
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
78
|
+
* by two entries would silently drop one of them. Experience entries own the keys they declare, and an
|
|
79
|
+
* experience's namespace (its section's comp path) is a scope no reaction may touch: the section and
|
|
80
|
+
* every component inside it belong to the experience, whatever keys the experience itself declares.
|
|
81
|
+
* Both are stripped from the reactions entry by dropping whole interactions whose resolved keys overlap.
|
|
82
|
+
* Top-level effect and sequence libraries are left intact. A collision between two experience entries
|
|
83
|
+
* stays an error, since neither of them is authoritative.
|
|
74
84
|
*/
|
|
75
85
|
export const resolveInteractKeyConflicts = (entries: InteractConfigEntry[]): InteractConfigEntry[] => {
|
|
76
86
|
const owners = new Map<string, string>()
|
|
87
|
+
const scopes: string[] = []
|
|
77
88
|
|
|
78
89
|
entries.forEach((entry, index) => {
|
|
79
90
|
if (entry.namespace === REACTIONS_NAMESPACE) {
|
|
80
91
|
return
|
|
81
92
|
}
|
|
93
|
+
if (entry.namespace) {
|
|
94
|
+
scopes.push(entry.namespace)
|
|
95
|
+
}
|
|
82
96
|
const owner = entry.namespace ?? `entry-${index}`
|
|
83
97
|
for (const key of getInteractiveKeys(entry)) {
|
|
84
98
|
const existingOwner = owners.get(key)
|
|
@@ -92,12 +106,12 @@ export const resolveInteractKeyConflicts = (entries: InteractConfigEntry[]): Int
|
|
|
92
106
|
}
|
|
93
107
|
})
|
|
94
108
|
|
|
95
|
-
if (!owners.size) {
|
|
109
|
+
if (!owners.size && !scopes.length) {
|
|
96
110
|
return entries
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
const overriddenKeys = new Set(owners.keys())
|
|
100
114
|
return entries.map((entry) =>
|
|
101
|
-
entry.namespace === REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys) : entry
|
|
115
|
+
entry.namespace === REACTIONS_NAMESPACE ? dropOverriddenKeys(entry, overriddenKeys, scopes) : entry
|
|
102
116
|
)
|
|
103
117
|
}
|