@mulanjs/mulanjs 1.0.1-dev.20260220121828 → 1.0.1-dev.20260220131258
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/core/hooks.js +1 -1
- package/dist/core/surge.js +7 -12
- package/dist/core/vault.js +3 -8
- package/dist/mulan.esm.js +1645 -1945
- package/dist/mulan.esm.js.map +1 -0
- package/dist/mulan.js +2022 -177
- package/dist/mulan.js.map +1 -0
- package/dist/types/core/vault.d.ts +1 -0
- package/package.json +13 -2
- package/src/cli/index.js +14 -6
package/dist/core/hooks.js
CHANGED
|
@@ -225,5 +225,5 @@ export function muPulse() {
|
|
|
225
225
|
* Powered by the Iron Fortress persistent primitive.
|
|
226
226
|
*/
|
|
227
227
|
export function muVault(key, initial, options = {}) {
|
|
228
|
-
return persistent(key, initial, options);
|
|
228
|
+
return persistent(key, initial, Object.assign(Object.assign({}, options), { onCleanup: (fn) => onMuDestroy(fn) }));
|
|
229
229
|
}
|
package/dist/core/surge.js
CHANGED
|
@@ -44,18 +44,13 @@ export function muSurge(array, taskFn, onProgress) {
|
|
|
44
44
|
let completedItems = 0;
|
|
45
45
|
// Convert function to string if it isn't already
|
|
46
46
|
const fnStr = typeof taskFn === 'function' ? taskFn.toString() : taskFn;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} catch (err) {
|
|
55
|
-
self.postMessage({ error: err.message, startIndex });
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
`;
|
|
47
|
+
const workerPart1 = `const taskFn = ${fnStr};`;
|
|
48
|
+
const workerPart2 = `self.onmessage = function(e) {`;
|
|
49
|
+
const workerPart3 = ` const { chunk, startIndex } = e.data;`;
|
|
50
|
+
const workerPart4 = ` try { const results = chunk.map(taskFn); self.postMessage({ results, startIndex }); }`;
|
|
51
|
+
const workerPart5 = ` catch (err) { self.postMessage({ error: err.message, startIndex }); }`;
|
|
52
|
+
const workerPart6 = `};`;
|
|
53
|
+
const workerCode = [workerPart1, workerPart2, workerPart3, workerPart4, workerPart5, workerPart6].join('\n');
|
|
59
54
|
const blob = new Blob([workerCode], { type: 'application/javascript' });
|
|
60
55
|
const workerUrl = URL.createObjectURL(blob);
|
|
61
56
|
return new Promise((resolve) => {
|
package/dist/core/vault.js
CHANGED
|
@@ -47,16 +47,11 @@ export function persistent(key, initialValue, options = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
window.addEventListener('storage', sync);
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onMuDestroy(() => {
|
|
50
|
+
// Explicit cleanup if provided by the environment (e.g. Mulan Hooks)
|
|
51
|
+
if (options.onCleanup) {
|
|
52
|
+
options.onCleanup(() => {
|
|
54
53
|
window.removeEventListener('storage', sync);
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
// muVault might be used outside component setup in some advanced cases,
|
|
59
|
-
// fallback to manual or no-cleanup if so.
|
|
60
|
-
}
|
|
61
56
|
return state;
|
|
62
57
|
}
|