@lvce-editor/renderer-process 30.8.0 → 30.10.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 +84 -12
- package/package.json +1 -1
|
@@ -119,7 +119,8 @@ const confirm$1 = message => {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
const state$a = {
|
|
122
|
-
styleSheets: Object.create(null)
|
|
122
|
+
styleSheets: Object.create(null),
|
|
123
|
+
texts: Object.create(null)
|
|
123
124
|
};
|
|
124
125
|
const set$a = (id, sheet) => {
|
|
125
126
|
state$a.styleSheets[id] = sheet;
|
|
@@ -127,18 +128,57 @@ const set$a = (id, sheet) => {
|
|
|
127
128
|
const get$b = id => {
|
|
128
129
|
return state$a.styleSheets[id];
|
|
129
130
|
};
|
|
131
|
+
const setText$2 = (id, text) => {
|
|
132
|
+
state$a.texts[id] = text;
|
|
133
|
+
};
|
|
134
|
+
const getText = id => {
|
|
135
|
+
return state$a.texts[id];
|
|
136
|
+
};
|
|
137
|
+
const remove$4 = id => {
|
|
138
|
+
delete state$a.styleSheets[id];
|
|
139
|
+
delete state$a.texts[id];
|
|
140
|
+
};
|
|
130
141
|
|
|
131
142
|
const addCssStyleSheet = (id, text) => {
|
|
132
143
|
const existing = get$b(id);
|
|
133
144
|
if (existing) {
|
|
134
145
|
existing.replaceSync(text);
|
|
146
|
+
setText$2(id, text);
|
|
135
147
|
return;
|
|
136
148
|
}
|
|
137
149
|
const sheet = new CSSStyleSheet({});
|
|
138
150
|
set$a(id, sheet);
|
|
151
|
+
setText$2(id, text);
|
|
139
152
|
sheet.replaceSync(text);
|
|
140
153
|
document.adoptedStyleSheets.push(sheet);
|
|
141
154
|
};
|
|
155
|
+
const patchCssStyleSheet = (id, start, deleteCount, replacement) => {
|
|
156
|
+
const sheet = get$b(id);
|
|
157
|
+
const text = getText(id);
|
|
158
|
+
if (!sheet || typeof text !== 'string') {
|
|
159
|
+
throw new Error(`stylesheet ${id} must be initialized before it can be patched`);
|
|
160
|
+
}
|
|
161
|
+
if (!Number.isSafeInteger(start) || start < 0 || start > text.length) {
|
|
162
|
+
throw new TypeError('start must be an integer within the stylesheet');
|
|
163
|
+
}
|
|
164
|
+
if (!Number.isSafeInteger(deleteCount) || deleteCount < 0 || start + deleteCount > text.length) {
|
|
165
|
+
throw new TypeError('deleteCount must be an integer within the stylesheet');
|
|
166
|
+
}
|
|
167
|
+
if (typeof replacement !== 'string') {
|
|
168
|
+
throw new TypeError('replacement must be a string');
|
|
169
|
+
}
|
|
170
|
+
const newText = text.slice(0, start) + replacement + text.slice(start + deleteCount);
|
|
171
|
+
sheet.replaceSync(newText);
|
|
172
|
+
setText$2(id, newText);
|
|
173
|
+
};
|
|
174
|
+
const removeCssStyleSheet = id => {
|
|
175
|
+
const sheet = get$b(id);
|
|
176
|
+
if (!sheet) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(candidate => candidate !== sheet);
|
|
180
|
+
remove$4(id);
|
|
181
|
+
};
|
|
142
182
|
const getSelectionText = () => {
|
|
143
183
|
return document.getSelection()?.toString() || '';
|
|
144
184
|
};
|
|
@@ -262,6 +302,7 @@ const applyDragInfoMaybe = event => {
|
|
|
262
302
|
};
|
|
263
303
|
|
|
264
304
|
const PointerMove$1 = 'pointermove';
|
|
305
|
+
const PointerUp$1 = 'pointerup';
|
|
265
306
|
const lostpointercapture = 'lostpointercapture';
|
|
266
307
|
|
|
267
308
|
const createEventState = () => {
|
|
@@ -520,8 +561,20 @@ const applyPointerTrackMaybe = (info, map, event) => {
|
|
|
520
561
|
} = event;
|
|
521
562
|
target.setPointerCapture(pointerId);
|
|
522
563
|
const [pointerMoveKey, pointerUpKey] = trackPointerEvents;
|
|
523
|
-
|
|
524
|
-
|
|
564
|
+
const pointerMove = map[pointerMoveKey];
|
|
565
|
+
const pointerUp = map[pointerUpKey];
|
|
566
|
+
const cleanup = () => {
|
|
567
|
+
target.removeEventListener(PointerMove$1, pointerMove);
|
|
568
|
+
target.removeEventListener(PointerUp$1, handlePointerUp);
|
|
569
|
+
target.removeEventListener(lostpointercapture, handlePointerUp);
|
|
570
|
+
};
|
|
571
|
+
const handlePointerUp = event => {
|
|
572
|
+
cleanup();
|
|
573
|
+
pointerUp(event);
|
|
574
|
+
};
|
|
575
|
+
target.addEventListener(PointerMove$1, pointerMove);
|
|
576
|
+
target.addEventListener(PointerUp$1, handlePointerUp);
|
|
577
|
+
target.addEventListener(lostpointercapture, handlePointerUp);
|
|
525
578
|
};
|
|
526
579
|
const createFn = (info, map) => {
|
|
527
580
|
const fn = event => {
|
|
@@ -2794,7 +2847,10 @@ const constructError = (message, type, name) => {
|
|
|
2794
2847
|
if (ErrorConstructor === Error) {
|
|
2795
2848
|
const error = new Error(message);
|
|
2796
2849
|
if (name && name !== 'VError') {
|
|
2797
|
-
error
|
|
2850
|
+
Object.defineProperty(error, 'name', {
|
|
2851
|
+
configurable: true,
|
|
2852
|
+
value: name
|
|
2853
|
+
});
|
|
2798
2854
|
}
|
|
2799
2855
|
return error;
|
|
2800
2856
|
}
|
|
@@ -2825,31 +2881,45 @@ const getParentStack = error => {
|
|
|
2825
2881
|
};
|
|
2826
2882
|
const MethodNotFound = -32601;
|
|
2827
2883
|
const Custom = -32001;
|
|
2884
|
+
const setStack = (error, stack) => {
|
|
2885
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
2886
|
+
if (descriptor) {
|
|
2887
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2890
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
2891
|
+
error.stack = stack;
|
|
2892
|
+
return;
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
Object.defineProperty(error, 'stack', {
|
|
2896
|
+
configurable: true,
|
|
2897
|
+
value: stack,
|
|
2898
|
+
writable: true
|
|
2899
|
+
});
|
|
2900
|
+
};
|
|
2828
2901
|
const restoreExistingError = (error, currentStack) => {
|
|
2829
2902
|
if (typeof error.stack === 'string') {
|
|
2830
|
-
error
|
|
2903
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
2831
2904
|
}
|
|
2832
2905
|
return error;
|
|
2833
2906
|
};
|
|
2834
2907
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
2835
2908
|
const restoredError = new JsonRpcError(error.message);
|
|
2836
2909
|
const parentStack = getParentStack(error);
|
|
2837
|
-
restoredError
|
|
2910
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
2838
2911
|
return restoredError;
|
|
2839
2912
|
};
|
|
2840
2913
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
2841
2914
|
if (error.data.stack && error.data.type && error.message) {
|
|
2842
|
-
restoredError
|
|
2915
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
2843
2916
|
return;
|
|
2844
2917
|
}
|
|
2845
2918
|
if (error.data.stack) {
|
|
2846
|
-
restoredError
|
|
2919
|
+
setStack(restoredError, error.data.stack);
|
|
2847
2920
|
}
|
|
2848
2921
|
};
|
|
2849
2922
|
const applyDataProperties = (restoredError, error) => {
|
|
2850
|
-
if (!error.data) {
|
|
2851
|
-
return;
|
|
2852
|
-
}
|
|
2853
2923
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
2854
2924
|
if (error.data.codeFrame) {
|
|
2855
2925
|
// @ts-ignore
|
|
@@ -2870,7 +2940,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
2870
2940
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2871
2941
|
const parentStack = getParentStack(error);
|
|
2872
2942
|
// @ts-ignore
|
|
2873
|
-
restoredError
|
|
2943
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
2874
2944
|
}
|
|
2875
2945
|
if (error.codeFrame) {
|
|
2876
2946
|
// @ts-ignore
|
|
@@ -8804,6 +8874,7 @@ const dispose$4 = id => {
|
|
|
8804
8874
|
if (instance.state.$Viewlet?.isConnected) {
|
|
8805
8875
|
instance.state.$Viewlet.remove();
|
|
8806
8876
|
}
|
|
8877
|
+
removeCssStyleSheet(id);
|
|
8807
8878
|
set$9(id, undefined);
|
|
8808
8879
|
} catch {
|
|
8809
8880
|
throw new Error(`Failed to dispose ${id}`);
|
|
@@ -9021,6 +9092,7 @@ const commandHandlers = {
|
|
|
9021
9092
|
'Viewlet.focusSelector': focusSelector,
|
|
9022
9093
|
'Viewlet.handleError': handleError$1,
|
|
9023
9094
|
'Viewlet.move': move,
|
|
9095
|
+
'Viewlet.patchCss': patchCssStyleSheet,
|
|
9024
9096
|
'Viewlet.registerEventListeners': registerEventListeners,
|
|
9025
9097
|
'Viewlet.removeKeyBindings': removeKeyBindings,
|
|
9026
9098
|
'Viewlet.replaceChildren': replaceChildren,
|