@lvce-editor/renderer-process 21.9.0 → 21.11.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.
- package/dist/rendererProcessMain.js +34 -0
- package/package.json +1 -1
|
@@ -9208,6 +9208,36 @@ const setPatches = (uid, patches) => {
|
|
|
9208
9208
|
}
|
|
9209
9209
|
applyPatch($Viewlet, patches, {}, uid);
|
|
9210
9210
|
};
|
|
9211
|
+
const waitForElement = selector => {
|
|
9212
|
+
const element = document.querySelector(selector);
|
|
9213
|
+
if (element) {
|
|
9214
|
+
return Promise.resolve(element);
|
|
9215
|
+
}
|
|
9216
|
+
const {
|
|
9217
|
+
promise,
|
|
9218
|
+
resolve
|
|
9219
|
+
} = withResolvers();
|
|
9220
|
+
const observer = new MutationObserver(() => {
|
|
9221
|
+
const element = document.querySelector(selector);
|
|
9222
|
+
if (element) {
|
|
9223
|
+
observer.disconnect();
|
|
9224
|
+
resolve(element);
|
|
9225
|
+
}
|
|
9226
|
+
});
|
|
9227
|
+
observer.observe(document.body, {
|
|
9228
|
+
childList: true,
|
|
9229
|
+
subtree: true
|
|
9230
|
+
});
|
|
9231
|
+
return promise;
|
|
9232
|
+
};
|
|
9233
|
+
const move = async (uid, selector, target) => {
|
|
9234
|
+
const $Source = document.querySelector(selector);
|
|
9235
|
+
if (!$Source) {
|
|
9236
|
+
throw new Error(`Source element not found: ${selector}`);
|
|
9237
|
+
}
|
|
9238
|
+
const $Target = await waitForElement(target);
|
|
9239
|
+
$Target.append($Source);
|
|
9240
|
+
};
|
|
9211
9241
|
|
|
9212
9242
|
// TODO this code is bad
|
|
9213
9243
|
const sendMultiple = commands => {
|
|
@@ -9291,6 +9321,10 @@ const sendMultiple = commands => {
|
|
|
9291
9321
|
handleError$1(viewletId, method, ...args);
|
|
9292
9322
|
break;
|
|
9293
9323
|
}
|
|
9324
|
+
case 'Viewlet.move':
|
|
9325
|
+
// @ts-ignore
|
|
9326
|
+
move(viewletId, method, ...args);
|
|
9327
|
+
break;
|
|
9294
9328
|
case 'Viewlet.registerEventListeners':
|
|
9295
9329
|
// @ts-ignore
|
|
9296
9330
|
registerEventListeners(viewletId, method, ...args);
|