@remkoj/optimizely-cms-react 5.1.5 → 5.1.7
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/dist/factory/default.d.ts +10 -0
- package/dist/factory/default.js +25 -18
- package/dist/factory/default.js.map +1 -1
- package/dist/factory/types.d.ts +9 -0
- package/dist/factory/undef.d.ts +2 -0
- package/dist/factory/undef.js +6 -0
- package/dist/factory/undef.js.map +1 -1
- package/package.json +2 -2
|
@@ -8,6 +8,15 @@ export declare const EmptyComponentHandle = "$$fragment$$";
|
|
|
8
8
|
export declare class DefaultComponentFactory implements ComponentFactory {
|
|
9
9
|
private registry;
|
|
10
10
|
private dbg;
|
|
11
|
+
/**
|
|
12
|
+
* A list of interfaces to ignore when resolving components. Adjust this
|
|
13
|
+
* list if you're experiencing issues with resolving components due to
|
|
14
|
+
* contracts. Values **must be** provided lowercase and without leading
|
|
15
|
+
* underscore. For example `_Item` must be provided as `item`.
|
|
16
|
+
*
|
|
17
|
+
* The default value includes the common ones for SaaS CMS.
|
|
18
|
+
*/
|
|
19
|
+
ignoredContracts: string[];
|
|
11
20
|
/**
|
|
12
21
|
* Create a new instance of the DefaultComponentFactory
|
|
13
22
|
*
|
|
@@ -21,4 +30,5 @@ export declare class DefaultComponentFactory implements ComponentFactory {
|
|
|
21
30
|
resolve(type: ComponentTypeHandle): undefined | ComponentType;
|
|
22
31
|
extract(): ComponentTypeDictionary;
|
|
23
32
|
remove(type: ComponentTypeHandle): boolean;
|
|
33
|
+
private processComponentTypeHandle;
|
|
24
34
|
}
|
package/dist/factory/default.js
CHANGED
|
@@ -15,6 +15,15 @@ export class DefaultComponentFactory {
|
|
|
15
15
|
*/
|
|
16
16
|
constructor(initialComponents) {
|
|
17
17
|
this.registry = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* A list of interfaces to ignore when resolving components. Adjust this
|
|
20
|
+
* list if you're experiencing issues with resolving components due to
|
|
21
|
+
* contracts. Values **must be** provided lowercase and without leading
|
|
22
|
+
* underscore. For example `_Item` must be provided as `item`.
|
|
23
|
+
*
|
|
24
|
+
* The default value includes the common ones for SaaS CMS.
|
|
25
|
+
*/
|
|
26
|
+
this.ignoredContracts = ['item', 'assetitem', 'imageitem', 'content'];
|
|
18
27
|
// Resolve debug mode
|
|
19
28
|
try {
|
|
20
29
|
this.dbg = process.env.OPTIMIZELY_DEBUG == '1';
|
|
@@ -27,30 +36,29 @@ export class DefaultComponentFactory {
|
|
|
27
36
|
this.registerAll(initialComponents);
|
|
28
37
|
}
|
|
29
38
|
register(type, component, useSuspense = false, loader) {
|
|
30
|
-
const registryKey = processComponentTypeHandle(type);
|
|
39
|
+
const registryKey = this.processComponentTypeHandle(type);
|
|
31
40
|
if (this.dbg)
|
|
32
41
|
console.log(`➕ [DefaultComponentFactory] Registering ${registryKey}`);
|
|
33
42
|
this.registry.set(registryKey, { type, component, useSuspense, loader });
|
|
34
43
|
}
|
|
35
44
|
registerAll(components) {
|
|
36
45
|
components.forEach((c) => {
|
|
37
|
-
const registryKey = processComponentTypeHandle(c.type);
|
|
46
|
+
const registryKey = this.processComponentTypeHandle(c.type);
|
|
38
47
|
if (this.dbg)
|
|
39
48
|
console.log(`➕ [DefaultComponentFactory] Registering ${registryKey}`);
|
|
40
49
|
this.registry.set(registryKey, c);
|
|
41
50
|
});
|
|
42
51
|
}
|
|
43
52
|
has(type) {
|
|
44
|
-
const registryKey = processComponentTypeHandle(type);
|
|
53
|
+
const registryKey = this.processComponentTypeHandle(type);
|
|
45
54
|
//if (this.dbg) console.log(`🔎 [DefaultComponentFactory] Checking for ${ registryKey }`)
|
|
46
55
|
return this.registry.has(registryKey);
|
|
47
56
|
}
|
|
48
57
|
resolve(type) {
|
|
49
|
-
const registryKey = processComponentTypeHandle(type);
|
|
58
|
+
const registryKey = this.processComponentTypeHandle(type);
|
|
50
59
|
const entry = this.registry.get(registryKey);
|
|
51
60
|
if (!entry) {
|
|
52
|
-
|
|
53
|
-
console.warn(`⚡ [DefaultComponentFactory] Unable to resolve ${registryKey}`);
|
|
61
|
+
console.warn(`❌ [DefaultComponentFactory] Unable to resolve ${registryKey}, this will prevent the item from rendering`);
|
|
54
62
|
return undefined; // The key is not registered in the factory
|
|
55
63
|
}
|
|
56
64
|
if (entry.useSuspense != true)
|
|
@@ -69,23 +77,22 @@ export class DefaultComponentFactory {
|
|
|
69
77
|
});
|
|
70
78
|
}
|
|
71
79
|
remove(type) {
|
|
72
|
-
const registryKey = processComponentTypeHandle(type);
|
|
80
|
+
const registryKey = this.processComponentTypeHandle(type);
|
|
73
81
|
if (this.dbg)
|
|
74
82
|
console.log(`🔎 [DefaultComponentFactory] Removing ${registryKey}`);
|
|
75
83
|
if (!this.registry.has(registryKey))
|
|
76
84
|
return true;
|
|
77
85
|
return this.registry.delete(registryKey);
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
throw new Error(`Invalid component type handle: ${typeof handle}`);
|
|
87
|
+
processComponentTypeHandle(handle) {
|
|
88
|
+
let handleToProcess = typeof handle === 'string' ? handle.split(MERGE_SYMBOL) : handle;
|
|
89
|
+
if (Array.isArray(handleToProcess) && handleToProcess.every((s) => typeof s === 'string'))
|
|
90
|
+
return handleToProcess
|
|
91
|
+
.map((s) => s === '' ? EmptyComponentHandle : (s.startsWith('_') ? s.substring(1) : s)) // Remove all leading underscores
|
|
92
|
+
.filter((s) => !this.ignoredContracts.includes(s.toLocaleLowerCase())) // Remove from ignored contracts
|
|
93
|
+
.filter((s, i, a) => i === 0 || a[i - 1] !== s) // Remove duplicates (i.e. Component/Component/...)
|
|
94
|
+
.join(MERGE_SYMBOL);
|
|
95
|
+
throw new Error(`Invalid component type handle: ${typeof handle}`);
|
|
96
|
+
}
|
|
90
97
|
}
|
|
91
98
|
//# sourceMappingURL=default.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/factory/default.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA;AAElD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/factory/default.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA;AAElD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAclC;;;;;OAKG;IACH,YAAmB,iBAA2C;QAnBtD,aAAQ,GAAG,IAAI,GAAG,EAAwC,CAAA;QAGlE;;;;;;;WAOG;QACI,qBAAgB,GAAa,CAAC,MAAM,EAAC,WAAW,EAAC,WAAW,EAAC,SAAS,CAAC,CAAA;QAS5E,qBAAqB;QACrB,IAAI,CAAC;YACH,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAA;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,GAAG,GAAG,KAAK,CAAA;QAClB,CAAC;QAED,kCAAkC;QAClC,IAAI,iBAAiB;YAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAA;IAC5D,CAAC;IAEM,QAAQ,CACb,IAAyB,EACzB,SAAwB,EACxB,cAAuB,KAAK,EAC5B,MAAsB;QAEtB,MAAM,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;QACzD,IAAI,IAAI,CAAC,GAAG;YACV,OAAO,CAAC,GAAG,CAAC,2CAA2C,WAAW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E,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iCAAiC;iBACxH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,gCAAgC;iBACtG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,KAAK,CAAC,CAAE,CAAC,mDAAmD;iBACjG,IAAI,CAAC,YAAY,CAAC,CAAA;QACvB,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,MAAM,EAAE,CAAC,CAAA;IACpE,CAAC;CACF"}
|
package/dist/factory/types.d.ts
CHANGED
|
@@ -30,6 +30,15 @@ export type ComponentTypeDictionaryEntry = {
|
|
|
30
30
|
* Component Factory
|
|
31
31
|
*/
|
|
32
32
|
export interface ComponentFactory {
|
|
33
|
+
/**
|
|
34
|
+
* A list of interfaces to ignore when resolving components. Adjust this
|
|
35
|
+
* list if you're experiencing issues with resolving components due to
|
|
36
|
+
* contracts. Values **must be** provided lowercase and without leading
|
|
37
|
+
* underscore. For example `_Item` must be provided as `item`.
|
|
38
|
+
*
|
|
39
|
+
* The default value includes the common ones for SaaS CMS.
|
|
40
|
+
*/
|
|
41
|
+
ignoredContracts: string[];
|
|
33
42
|
/**
|
|
34
43
|
* Check if the component type has been registered within the factory
|
|
35
44
|
*
|
package/dist/factory/undef.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ComponentType, ComponentTypeDictionary, ComponentTypeHandle, type ComponentFactory } from "./types.js";
|
|
2
2
|
export declare class UndefinedComponentFactory implements ComponentFactory {
|
|
3
|
+
get ignoredContracts(): string[];
|
|
4
|
+
set ignoredContracts(newList: string[]);
|
|
3
5
|
has(type: ComponentTypeHandle): boolean;
|
|
4
6
|
register(type: ComponentTypeHandle, componentType: ComponentType): void;
|
|
5
7
|
registerAll(components: ComponentTypeDictionary): void;
|
package/dist/factory/undef.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export class UndefinedComponentFactory {
|
|
2
|
+
get ignoredContracts() {
|
|
3
|
+
throw new Error("Factory not specified, please specify a factory.");
|
|
4
|
+
}
|
|
5
|
+
set ignoredContracts(newList) {
|
|
6
|
+
throw new Error("Factory not specified, please specify a factory.");
|
|
7
|
+
}
|
|
2
8
|
has(type) {
|
|
3
9
|
throw new Error("Factory not specified, please specify a factory.");
|
|
4
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undef.js","sourceRoot":"","sources":["../../src/factory/undef.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,yBAAyB;
|
|
1
|
+
{"version":3,"file":"undef.js","sourceRoot":"","sources":["../../src/factory/undef.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,yBAAyB;IACpC,IAAI,gBAAgB;QAClB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,gBAAgB,CAAC,OAAiB;QACpC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,GAAG,CAAC,IAAyB;QAC3B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,QAAQ,CAAC,IAAyB,EAAE,aAA4B;QAC9D,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,WAAW,CAAC,UAAmC;QAC7C,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,CAAC,IAAyB;QAC/B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;CACF;AAED,eAAe,yBAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remkoj/optimizely-cms-react",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.7",
|
|
5
5
|
"repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
|
|
6
6
|
"author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
|
|
7
7
|
"homepage": "https://github.com/remkoj/optimizely-dxp-clients/tree/main/packages/optimizely-cms-react",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@remkoj/optimizely-graph-client": "5.1.
|
|
30
|
+
"@remkoj/optimizely-graph-client": "5.1.7",
|
|
31
31
|
"@types/crypto-js": "^4.2.2",
|
|
32
32
|
"@types/node": "^22.16.5",
|
|
33
33
|
"@types/react": "^18.3.23",
|