@remkoj/optimizely-cms-react 4.1.0 → 4.3.0
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.
|
@@ -49,7 +49,7 @@ export async function getContentType(link, gqlClient) {
|
|
|
49
49
|
export default getContentType;
|
|
50
50
|
const getContentTypeQuery = gql `query getContentType($key: String!, $version: String, $locale: [Locales])
|
|
51
51
|
{
|
|
52
|
-
_Content(
|
|
52
|
+
Content: _Content(
|
|
53
53
|
where: {
|
|
54
54
|
_metadata: {
|
|
55
55
|
key: { eq: $key }
|
package/dist/context/rsc.d.ts
CHANGED
|
@@ -30,4 +30,12 @@ declare class ServerContext implements GenericContext {
|
|
|
30
30
|
setComponentFactory(factory: ComponentFactory | ((currentClient: ComponentFactory | undefined) => ComponentFactory)): void;
|
|
31
31
|
setEditableContentId(link: ContentLink): void;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Obtain an instance of the servercontext, this either uses `React.cache`,
|
|
35
|
+
* when available in the current context. If `React.cache` is not available, the
|
|
36
|
+
* fall-back is to create a new instance every time this method is called.
|
|
37
|
+
*
|
|
38
|
+
* It the cache fallback will notify in development or debug mode when it is in
|
|
39
|
+
* use.
|
|
40
|
+
*/
|
|
33
41
|
export declare const getServerContext: () => ServerContext;
|
package/dist/context/rsc.js
CHANGED
|
@@ -5,7 +5,7 @@ import { DefaultComponentFactory } from '../factory/index.js';
|
|
|
5
5
|
import { isDebug, isDevelopment } from '../rsc-utilities.js';
|
|
6
6
|
export * from "./types.js";
|
|
7
7
|
const cachePlaceholder = (factory) => {
|
|
8
|
-
if (isDebug())
|
|
8
|
+
if (isDebug() || isDevelopment())
|
|
9
9
|
console.warn("🚧 [React Context] Running client/server react code instead of server context, no cache() available.");
|
|
10
10
|
return factory;
|
|
11
11
|
};
|
|
@@ -46,26 +46,44 @@ class ServerContext {
|
|
|
46
46
|
this._locale = locale;
|
|
47
47
|
}
|
|
48
48
|
setMode(mode) {
|
|
49
|
+
if (this.isDebug)
|
|
50
|
+
console.log(`🦺 [ServerContext] Updating mode from ${this._mode} to ${mode}`);
|
|
49
51
|
this._mode = mode;
|
|
50
52
|
return this;
|
|
51
53
|
}
|
|
52
54
|
setLocale(locale) {
|
|
55
|
+
if (this.isDebug)
|
|
56
|
+
console.log(`🦺 [ServerContext] Updating locale from ${this._locale} to ${locale}`);
|
|
53
57
|
this._locale = locale;
|
|
54
58
|
return this;
|
|
55
59
|
}
|
|
56
60
|
setOptimizelyGraphClient(client) {
|
|
61
|
+
if (this.isDebug)
|
|
62
|
+
console.log(`🦺 [ServerContext] Assigning new Optimizely Graph Client`);
|
|
57
63
|
this._client = typeof (client) == 'function' ? client(this._client) : isOptiGraphClient(client) ? client : undefined;
|
|
58
64
|
}
|
|
59
65
|
setComponentFactory(factory) {
|
|
66
|
+
if (this.isDebug)
|
|
67
|
+
console.log(`🦺 [ServerContext] Assigning new Component Factory`);
|
|
60
68
|
const newFactory = typeof (factory) == 'function' ? factory(this._factory) : factory;
|
|
61
69
|
if (!newFactory)
|
|
62
70
|
throw new Error("Unsetting the context factory is not allowed!");
|
|
63
71
|
this._factory = newFactory;
|
|
64
72
|
}
|
|
65
73
|
setEditableContentId(link) {
|
|
74
|
+
if (this.isDebug)
|
|
75
|
+
console.log(`🦺 [ServerContext] Assigning editable content id: ${JSON.stringify(link)}`);
|
|
66
76
|
this._editable = link;
|
|
67
77
|
}
|
|
68
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Obtain an instance of the servercontext, this either uses `React.cache`,
|
|
81
|
+
* when available in the current context. If `React.cache` is not available, the
|
|
82
|
+
* fall-back is to create a new instance every time this method is called.
|
|
83
|
+
*
|
|
84
|
+
* It the cache fallback will notify in development or debug mode when it is in
|
|
85
|
+
* use.
|
|
86
|
+
*/
|
|
69
87
|
export const getServerContext = cache(() => {
|
|
70
88
|
const ctx = new ServerContext({});
|
|
71
89
|
if (ctx.isDebug)
|
package/dist/context/rsc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/context/rsc.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAA2C,MAAM,iCAAiC,CAAA;AAC1H,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAyB,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE5D,cAAc,YAAY,CAAA;AAG1B,MAAM,gBAAgB,GAAsB,CAAkC,OAAU,EAAE,EAAE;IAExF,IAAI,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../src/context/rsc.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAA2C,MAAM,iCAAiC,CAAA;AAC1H,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAyB,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE5D,cAAc,YAAY,CAAA;AAG1B,MAAM,gBAAgB,GAAsB,CAAkC,OAAU,EAAE,EAAE;IAExF,IAAI,OAAO,EAAE,IAAI,aAAa,EAAE;QAC5B,OAAO,CAAC,IAAI,CAAC,sGAAsG,CAAC,CAAA;IACxH,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA;AAED,4EAA4E;AAC5E,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,gBAAgB,CAAqB,CAAA;AAInE,MAAM,aAAa;IAQf,IAAI,MAAM;QAEN,OAAO,IAAI,CAAC,OAAO,CAAA;IACvB,CAAC;IACD,IAAI,OAAO;QAEP,OAAO,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED,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1
1
|
{
|
|
2
2
|
"name": "@remkoj/optimizely-cms-react",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
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,31 +27,31 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@remkoj/optimizely-graph-client": "4.
|
|
30
|
+
"@remkoj/optimizely-graph-client": "4.3.0",
|
|
31
31
|
"@types/crypto-js": "^4.2.2",
|
|
32
|
-
"@types/node": "^22.
|
|
33
|
-
"@types/react": "^18.3.
|
|
32
|
+
"@types/node": "^22.13.5",
|
|
33
|
+
"@types/react": "^18.3.18",
|
|
34
34
|
"@types/react-dom": "18.3.5",
|
|
35
|
-
"entities": "^
|
|
35
|
+
"entities": "^6.0.0",
|
|
36
36
|
"graphql": "^16.10.0",
|
|
37
37
|
"graphql-request": "^6.1.0",
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
39
|
"react": "^18.3.1",
|
|
40
40
|
"react-dom": "^18.3.1",
|
|
41
41
|
"scheduler": "^0.25.0",
|
|
42
|
-
"typescript": "^5.7.
|
|
42
|
+
"typescript": "^5.7.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
46
46
|
"crypto-js": "^4.2.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@remkoj/optimizely-graph-client": "
|
|
50
|
-
"entities": "
|
|
51
|
-
"graphql": "^16
|
|
52
|
-
"graphql-request": "^6
|
|
53
|
-
"react": "
|
|
54
|
-
"react-dom": "
|
|
49
|
+
"@remkoj/optimizely-graph-client": "^4",
|
|
50
|
+
"entities": "^6",
|
|
51
|
+
"graphql": "^16",
|
|
52
|
+
"graphql-request": "^6",
|
|
53
|
+
"react": "^18",
|
|
54
|
+
"react-dom": "^18"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"clean": "tsc --build --clean",
|