@sitecore-jss/sitecore-jss-nextjs 21.1.0-canary.36 → 21.1.0-canary.38
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/cjs/editing/editing-data-cache.js +15 -10
- package/dist/cjs/editing/editing-data-middleware.js +2 -2
- package/dist/cjs/editing/editing-data-service.js +2 -2
- package/dist/esm/editing/editing-data-cache.js +15 -10
- package/dist/esm/editing/editing-data-middleware.js +2 -2
- package/dist/esm/editing/editing-data-service.js +2 -2
- package/package.json +5 -5
- package/types/editing/editing-data-cache.d.ts +4 -4
|
@@ -22,19 +22,24 @@ class EditingDataDiskCache {
|
|
|
22
22
|
}
|
|
23
23
|
set(key, editingData) {
|
|
24
24
|
const filePath = this.cache.set(key, JSON.stringify(editingData));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
if (!filePath || filePath.length === 0) {
|
|
27
|
+
reject(new Error(`Editing data cache not set for key ${key} at ${this.cache.root}`));
|
|
28
|
+
}
|
|
29
|
+
resolve();
|
|
30
|
+
});
|
|
28
31
|
}
|
|
29
32
|
get(key) {
|
|
30
33
|
const entry = this.cache.get(key);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
if (!entry.isCached) {
|
|
36
|
+
console.warn(`Editing data cache miss for key ${key} at ${this.cache.root}`);
|
|
37
|
+
resolve(undefined);
|
|
38
|
+
}
|
|
39
|
+
// Remove to preserve disk-space (as a macrotask so as not to block current execution)
|
|
40
|
+
setTimeout(() => this.cache.remove(key));
|
|
41
|
+
resolve(JSON.parse(entry.value));
|
|
42
|
+
});
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
exports.EditingDataDiskCache = EditingDataDiskCache;
|
|
@@ -36,7 +36,7 @@ class EditingDataMiddleware {
|
|
|
36
36
|
switch (method) {
|
|
37
37
|
case 'GET': {
|
|
38
38
|
// Get cache value
|
|
39
|
-
const data = this.editingDataCache.get(key);
|
|
39
|
+
const data = yield this.editingDataCache.get(key);
|
|
40
40
|
res.status(200).json(data);
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
@@ -46,7 +46,7 @@ class EditingDataMiddleware {
|
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
// Set cache value
|
|
49
|
-
this.editingDataCache.set(key, body);
|
|
49
|
+
yield this.editingDataCache.set(key, body);
|
|
50
50
|
res.status(200).end();
|
|
51
51
|
}
|
|
52
52
|
break;
|
|
@@ -56,7 +56,7 @@ class BasicEditingDataService {
|
|
|
56
56
|
key,
|
|
57
57
|
};
|
|
58
58
|
sitecore_jss_1.debug.editing('storing editing data for %o: %o', previewData, data);
|
|
59
|
-
this.editingDataCache.set(key, data);
|
|
59
|
+
yield this.editingDataCache.set(key, data);
|
|
60
60
|
return { key };
|
|
61
61
|
});
|
|
62
62
|
}
|
|
@@ -69,7 +69,7 @@ class BasicEditingDataService {
|
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
const editingPreviewData = previewData;
|
|
71
71
|
sitecore_jss_1.debug.editing('retrieving editing data for %o', previewData);
|
|
72
|
-
return this.editingDataCache.get(editingPreviewData.key);
|
|
72
|
+
return yield this.editingDataCache.get(editingPreviewData.key);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -16,19 +16,24 @@ export class EditingDataDiskCache {
|
|
|
16
16
|
}
|
|
17
17
|
set(key, editingData) {
|
|
18
18
|
const filePath = this.cache.set(key, JSON.stringify(editingData));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
if (!filePath || filePath.length === 0) {
|
|
21
|
+
reject(new Error(`Editing data cache not set for key ${key} at ${this.cache.root}`));
|
|
22
|
+
}
|
|
23
|
+
resolve();
|
|
24
|
+
});
|
|
22
25
|
}
|
|
23
26
|
get(key) {
|
|
24
27
|
const entry = this.cache.get(key);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
if (!entry.isCached) {
|
|
30
|
+
console.warn(`Editing data cache miss for key ${key} at ${this.cache.root}`);
|
|
31
|
+
resolve(undefined);
|
|
32
|
+
}
|
|
33
|
+
// Remove to preserve disk-space (as a macrotask so as not to block current execution)
|
|
34
|
+
setTimeout(() => this.cache.remove(key));
|
|
35
|
+
resolve(JSON.parse(entry.value));
|
|
36
|
+
});
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
/** EditingDataDiskCache singleton */
|
|
@@ -33,7 +33,7 @@ export class EditingDataMiddleware {
|
|
|
33
33
|
switch (method) {
|
|
34
34
|
case 'GET': {
|
|
35
35
|
// Get cache value
|
|
36
|
-
const data = this.editingDataCache.get(key);
|
|
36
|
+
const data = yield this.editingDataCache.get(key);
|
|
37
37
|
res.status(200).json(data);
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
@@ -43,7 +43,7 @@ export class EditingDataMiddleware {
|
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
// Set cache value
|
|
46
|
-
this.editingDataCache.set(key, body);
|
|
46
|
+
yield this.editingDataCache.set(key, body);
|
|
47
47
|
res.status(200).end();
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
@@ -52,7 +52,7 @@ export class BasicEditingDataService {
|
|
|
52
52
|
key,
|
|
53
53
|
};
|
|
54
54
|
debug.editing('storing editing data for %o: %o', previewData, data);
|
|
55
|
-
this.editingDataCache.set(key, data);
|
|
55
|
+
yield this.editingDataCache.set(key, data);
|
|
56
56
|
return { key };
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -65,7 +65,7 @@ export class BasicEditingDataService {
|
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
66
|
const editingPreviewData = previewData;
|
|
67
67
|
debug.editing('retrieving editing data for %o', previewData);
|
|
68
|
-
return this.editingDataCache.get(editingPreviewData.key);
|
|
68
|
+
return yield this.editingDataCache.get(editingPreviewData.key);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.1.0-canary.
|
|
3
|
+
"version": "21.1.0-canary.38",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"react-dom": "^18.1.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@sitecore-jss/sitecore-jss": "^21.1.0-canary.
|
|
74
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^21.1.0-canary.
|
|
75
|
-
"@sitecore-jss/sitecore-jss-react": "^21.1.0-canary.
|
|
73
|
+
"@sitecore-jss/sitecore-jss": "^21.1.0-canary.38",
|
|
74
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.1.0-canary.38",
|
|
75
|
+
"@sitecore-jss/sitecore-jss-react": "^21.1.0-canary.38",
|
|
76
76
|
"node-html-parser": "^6.0.0",
|
|
77
77
|
"prop-types": "^15.7.2",
|
|
78
78
|
"regex-parser": "^2.2.11",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"description": "",
|
|
82
82
|
"types": "types/index.d.ts",
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "4d7aa5a1b03b28bd641264bd2da806104862b291",
|
|
84
84
|
"files": [
|
|
85
85
|
"dist",
|
|
86
86
|
"types",
|
|
@@ -3,8 +3,8 @@ import { EditingData } from './editing-data';
|
|
|
3
3
|
* Defines an editing data cache implementation
|
|
4
4
|
*/
|
|
5
5
|
export interface EditingDataCache {
|
|
6
|
-
set(key: string, editingData: EditingData): void
|
|
7
|
-
get(key: string): EditingData | undefined
|
|
6
|
+
set(key: string, editingData: EditingData): Promise<void>;
|
|
7
|
+
get(key: string): Promise<EditingData | undefined>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* A disk-based editing data cache implementation (required for hosting on Vercel via Serverless Functions)
|
|
@@ -16,8 +16,8 @@ export declare class EditingDataDiskCache implements EditingDataCache {
|
|
|
16
16
|
* @param {string} [tmpDir] Temp directory to use. Default is the OS temp directory (os.tmpdir()).
|
|
17
17
|
*/
|
|
18
18
|
constructor(tmpDir?: string);
|
|
19
|
-
set(key: string, editingData: EditingData): void
|
|
20
|
-
get(key: string): EditingData | undefined
|
|
19
|
+
set(key: string, editingData: EditingData): Promise<void>;
|
|
20
|
+
get(key: string): Promise<EditingData | undefined>;
|
|
21
21
|
}
|
|
22
22
|
/** EditingDataDiskCache singleton */
|
|
23
23
|
export declare const editingDataDiskCache: EditingDataDiskCache;
|