@contentstorage/core 0.3.40 → 0.3.42
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/lib/contentManagement.js +13 -15
- package/package.json +1 -1
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { populateTextWithVariables } from '../helpers/populateTextWithVariables.js';
|
|
2
2
|
export let activeContent = null;
|
|
3
3
|
export let appConfig = null;
|
|
4
|
-
/**
|
|
5
|
-
* The time in milliseconds an ID will remain in the memoryMap after its last call.
|
|
6
|
-
* @type {number}
|
|
7
|
-
*/
|
|
8
|
-
const EVICTION_TIME_MS = 10000;
|
|
9
4
|
/**
|
|
10
5
|
* NB! Only used when live editor mode is on
|
|
11
6
|
*/
|
|
@@ -79,19 +74,11 @@ export function getText(contentKey, variables) {
|
|
|
79
74
|
if (window.parent && window.parent !== window) {
|
|
80
75
|
const key = current;
|
|
81
76
|
const existingEntry = window.memoryMap.get(key);
|
|
82
|
-
if (existingEntry) {
|
|
83
|
-
clearTimeout(existingEntry.timerId);
|
|
84
|
-
}
|
|
85
77
|
const idSet = existingEntry ? existingEntry.ids : new Set();
|
|
86
78
|
idSet.add(contentKey); // Add the current ID to the set.
|
|
87
|
-
const newTimerId = setTimeout(() => {
|
|
88
|
-
console.log(`%cEvicting text: %c"${key}"`);
|
|
89
|
-
window.memoryMap.delete(key);
|
|
90
|
-
}, EVICTION_TIME_MS);
|
|
91
79
|
window.memoryMap.set(key, {
|
|
92
|
-
timerId: newTimerId,
|
|
93
|
-
expiresAt: Date.now() + EVICTION_TIME_MS,
|
|
94
80
|
ids: idSet,
|
|
81
|
+
type: 'text',
|
|
95
82
|
});
|
|
96
83
|
}
|
|
97
84
|
if (!variables || Object.keys(variables).length === 0) {
|
|
@@ -140,9 +127,20 @@ export function getImage(contentKey) {
|
|
|
140
127
|
typeof current === 'object' &&
|
|
141
128
|
current.contentstorage_type === 'image' &&
|
|
142
129
|
typeof current.url === 'string') {
|
|
130
|
+
const currentData = current;
|
|
131
|
+
if (window.parent && window.parent !== window) {
|
|
132
|
+
const key = currentData.url;
|
|
133
|
+
const existingEntry = window.memoryMap.get(key);
|
|
134
|
+
const idSet = existingEntry ? existingEntry.ids : new Set();
|
|
135
|
+
idSet.add(contentKey); // Add the current ID to the set.
|
|
136
|
+
window.memoryMap.set(key, {
|
|
137
|
+
ids: idSet,
|
|
138
|
+
type: 'image',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
143
141
|
return {
|
|
144
142
|
contentKey,
|
|
145
|
-
data:
|
|
143
|
+
data: currentData,
|
|
146
144
|
};
|
|
147
145
|
}
|
|
148
146
|
else {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@contentstorage/core",
|
|
3
3
|
"author": "Kaido Hussar <kaidohus@gmail.com>",
|
|
4
4
|
"homepage": "https://contentstorage.app",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.42",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Fetch content from contentstorage and generate TypeScript types",
|
|
8
8
|
"module": "dist/index.js",
|