@lvce-editor/test-worker 4.27.0 → 4.28.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/api.d.ts +10 -2
- package/dist/testWorkerMain.js +52 -17
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ declare const updateEditingValue: (value: string) => Promise<void>;
|
|
|
114
114
|
declare const expandAll: () => Promise<void>;
|
|
115
115
|
declare const handleDragOver: (x: number, y: number) => Promise<void>;
|
|
116
116
|
declare const handleCut: () => Promise<void>;
|
|
117
|
+
declare const handleCopy: () => Promise<void>;
|
|
117
118
|
declare const handlePaste: () => Promise<void>;
|
|
118
119
|
declare const selectIndices: (indices: readonly number[]) => Promise<void>;
|
|
119
120
|
declare const addWebExtension: (relativePath: string) => Promise<void>;
|
|
@@ -246,11 +247,14 @@ declare const handleKeySpace: () => Promise<void>;
|
|
|
246
247
|
declare const handleKeyEscape: () => Promise<void>;
|
|
247
248
|
declare const toggleIndex: (index: number) => Promise<void>;
|
|
248
249
|
declare const toggleMenu: () => Promise<void>;
|
|
250
|
+
declare const setUrl: (newUrl: string) => void;
|
|
251
|
+
declare const resolve: (relativePath: string) => string;
|
|
249
252
|
declare const fromId: (webViewId: string) => Promise<any>;
|
|
250
253
|
declare const setPath: (path: string) => Promise<void>;
|
|
254
|
+
declare const openTmpDir: () => Promise<string>;
|
|
251
255
|
|
|
252
256
|
declare namespace Workspace {
|
|
253
|
-
export { setPath };
|
|
257
|
+
export { openTmpDir, setPath };
|
|
254
258
|
}
|
|
255
259
|
declare namespace About {
|
|
256
260
|
export { focusNext, focusPrevious, handleClickClose, handleClickCopy, handleClickOk, show };
|
|
@@ -280,7 +284,7 @@ declare namespace EditorCompletion {
|
|
|
280
284
|
export { selectCurrentIndex, selectIndex };
|
|
281
285
|
}
|
|
282
286
|
declare namespace Explorer {
|
|
283
|
-
export { acceptEdit, cancelEdit, clickCurrent, expandAll, expandRecursively, focus$1 as focus, focusFirst$1 as focusFirst, focusIndex, focusLast$1 as focusLast, focusNext$2 as focusNext, handleArrowLeft, handleBlur, handleClick$1 as handleClick, handleClickAt, handleCut, handleDragLeave, handleDragOver, handleDrop, handleInputBlur, handlePaste, newFile, newFolder, openContextMenu$1 as openContextMenu, refresh, removeDirent, rename$1 as rename, renameDirent, selectAll$1 as selectAll, selectDown, selectIndices, selectUp, updateEditingValue };
|
|
287
|
+
export { acceptEdit, cancelEdit, clickCurrent, expandAll, expandRecursively, focus$1 as focus, focusFirst$1 as focusFirst, focusIndex, focusLast$1 as focusLast, focusNext$2 as focusNext, handleArrowLeft, handleBlur, handleClick$1 as handleClick, handleClickAt, handleCopy, handleCut, handleDragLeave, handleDragOver, handleDrop, handleInputBlur, handlePaste, newFile, newFolder, openContextMenu$1 as openContextMenu, refresh, removeDirent, rename$1 as rename, renameDirent, selectAll$1 as selectAll, selectDown, selectIndices, selectUp, updateEditingValue };
|
|
284
288
|
}
|
|
285
289
|
declare namespace Extension {
|
|
286
290
|
export { addNodeExtension, addWebExtension };
|
|
@@ -342,6 +346,9 @@ declare namespace StatusBar {
|
|
|
342
346
|
declare namespace TitleBarMenuBar {
|
|
343
347
|
export { closeMenu, focus$2 as focus, focusFirst$7 as focusFirst, focusIndex$3 as focusIndex, focusLast$6 as focusLast, focusNext$9 as focusNext, focusPrevious$7 as focusPrevious, handleKeyArrowDown, handleKeyArrowLeft, handleKeyArrowRight, handleKeyArrowUp, handleKeyEnd, handleKeyEscape, handleKeyHome, handleKeySpace, toggleIndex, toggleMenu };
|
|
344
348
|
}
|
|
349
|
+
declare namespace Url {
|
|
350
|
+
export { resolve, setUrl };
|
|
351
|
+
}
|
|
345
352
|
declare namespace WebView {
|
|
346
353
|
export { fromId };
|
|
347
354
|
}
|
|
@@ -377,6 +384,7 @@ export interface TestApi {
|
|
|
377
384
|
readonly SourceControl: typeof SourceControl,
|
|
378
385
|
readonly StatusBar: typeof StatusBar,
|
|
379
386
|
readonly TitleBarMenuBar: typeof TitleBarMenuBar,
|
|
387
|
+
readonly Url: typeof Url,
|
|
380
388
|
readonly WebView: typeof WebView,
|
|
381
389
|
readonly Workspace: typeof Workspace,
|
|
382
390
|
readonly expect: any
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -60,37 +60,45 @@ let AssertionError$1 = class AssertionError extends Error {
|
|
|
60
60
|
this.name = 'AssertionError';
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
+
const Object$1 = 1;
|
|
64
|
+
const Number$1 = 2;
|
|
65
|
+
const Array$1 = 3;
|
|
66
|
+
const String = 4;
|
|
67
|
+
const Boolean = 5;
|
|
68
|
+
const Function = 6;
|
|
69
|
+
const Null = 7;
|
|
70
|
+
const Unknown = 8;
|
|
63
71
|
const getType = value => {
|
|
64
72
|
switch (typeof value) {
|
|
65
73
|
case 'number':
|
|
66
|
-
return
|
|
74
|
+
return Number$1;
|
|
67
75
|
case 'function':
|
|
68
|
-
return
|
|
76
|
+
return Function;
|
|
69
77
|
case 'string':
|
|
70
|
-
return
|
|
78
|
+
return String;
|
|
71
79
|
case 'object':
|
|
72
80
|
if (value === null) {
|
|
73
|
-
return
|
|
81
|
+
return Null;
|
|
74
82
|
}
|
|
75
83
|
if (Array.isArray(value)) {
|
|
76
|
-
return
|
|
84
|
+
return Array$1;
|
|
77
85
|
}
|
|
78
|
-
return
|
|
86
|
+
return Object$1;
|
|
79
87
|
case 'boolean':
|
|
80
|
-
return
|
|
88
|
+
return Boolean;
|
|
81
89
|
default:
|
|
82
|
-
return
|
|
90
|
+
return Unknown;
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
const object = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
95
|
+
if (type !== Object$1) {
|
|
88
96
|
throw new AssertionError$1('expected value to be of type object');
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
const string$1 = value => {
|
|
92
100
|
const type = getType(value);
|
|
93
|
-
if (type !==
|
|
101
|
+
if (type !== String) {
|
|
94
102
|
throw new AssertionError$1('expected value to be of type string');
|
|
95
103
|
}
|
|
96
104
|
};
|
|
@@ -695,7 +703,7 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
695
703
|
const warn = (...args) => {
|
|
696
704
|
console.warn(...args);
|
|
697
705
|
};
|
|
698
|
-
const resolve = (id, response) => {
|
|
706
|
+
const resolve$1 = (id, response) => {
|
|
699
707
|
const fn = get$2(id);
|
|
700
708
|
if (!fn) {
|
|
701
709
|
console.log(response);
|
|
@@ -802,7 +810,7 @@ const defaultLogError = () => {
|
|
|
802
810
|
const defaultRequiresSocket = () => {
|
|
803
811
|
return false;
|
|
804
812
|
};
|
|
805
|
-
const defaultResolve = resolve;
|
|
813
|
+
const defaultResolve = resolve$1;
|
|
806
814
|
|
|
807
815
|
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
808
816
|
const normalizeParams = args => {
|
|
@@ -932,7 +940,7 @@ const logError = () => {
|
|
|
932
940
|
const handleMessage = event => {
|
|
933
941
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
934
942
|
const actualExecute = event?.target?.execute || execute$2;
|
|
935
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
943
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve$1, preparePrettyError, logError, actualRequiresSocket);
|
|
936
944
|
};
|
|
937
945
|
const handleIpc = ipc => {
|
|
938
946
|
if ('addEventListener' in ipc) {
|
|
@@ -950,7 +958,7 @@ const listen$1 = async (module, options) => {
|
|
|
950
958
|
const ipc = module.wrap(rawIpc);
|
|
951
959
|
return ipc;
|
|
952
960
|
};
|
|
953
|
-
const create$
|
|
961
|
+
const create$a = async ({
|
|
954
962
|
commandMap,
|
|
955
963
|
messagePort,
|
|
956
964
|
isMessagePortOpen
|
|
@@ -968,7 +976,7 @@ const create$9 = async ({
|
|
|
968
976
|
};
|
|
969
977
|
const MessagePortRpcParent = {
|
|
970
978
|
__proto__: null,
|
|
971
|
-
create: create$
|
|
979
|
+
create: create$a
|
|
972
980
|
};
|
|
973
981
|
const create$2 = async ({
|
|
974
982
|
commandMap
|
|
@@ -1037,12 +1045,12 @@ const create$1 = rpcId => {
|
|
|
1037
1045
|
};
|
|
1038
1046
|
const RendererWorker$1 = 1;
|
|
1039
1047
|
const {
|
|
1040
|
-
invoke: invoke$
|
|
1048
|
+
invoke: invoke$4,
|
|
1041
1049
|
invokeAndTransfer: invokeAndTransfer$3,
|
|
1042
1050
|
set: set$3} = create$1(RendererWorker$1);
|
|
1043
1051
|
const RendererWorker = {
|
|
1044
1052
|
__proto__: null,
|
|
1045
|
-
invoke: invoke$
|
|
1053
|
+
invoke: invoke$4,
|
|
1046
1054
|
invokeAndTransfer: invokeAndTransfer$3,
|
|
1047
1055
|
set: set$3
|
|
1048
1056
|
};
|
|
@@ -2084,6 +2092,10 @@ const handleCut = async () => {
|
|
|
2084
2092
|
// @ts-ignore
|
|
2085
2093
|
await invoke('Explorer.handleCut');
|
|
2086
2094
|
};
|
|
2095
|
+
const handleCopy = async () => {
|
|
2096
|
+
// @ts-ignore
|
|
2097
|
+
await invoke('Explorer.handleCopy');
|
|
2098
|
+
};
|
|
2087
2099
|
const handlePaste = async () => {
|
|
2088
2100
|
// @ts-ignore
|
|
2089
2101
|
await invoke('Explorer.handlePaste');
|
|
@@ -2108,6 +2120,7 @@ const TestFrameWorkComponentExplorer = {
|
|
|
2108
2120
|
handleBlur,
|
|
2109
2121
|
handleClick: handleClick$1,
|
|
2110
2122
|
handleClickAt: handleClickAt$1,
|
|
2123
|
+
handleCopy,
|
|
2111
2124
|
handleCut,
|
|
2112
2125
|
handleDragLeave,
|
|
2113
2126
|
handleDragOver,
|
|
@@ -2890,6 +2903,20 @@ const TestFrameWorkComponentTitleBarMenuBar = {
|
|
|
2890
2903
|
toggleMenu
|
|
2891
2904
|
};
|
|
2892
2905
|
|
|
2906
|
+
let url = '';
|
|
2907
|
+
const setUrl = newUrl => {
|
|
2908
|
+
url = newUrl;
|
|
2909
|
+
};
|
|
2910
|
+
const resolve = relativePath => {
|
|
2911
|
+
return new URL(relativePath, url).toString();
|
|
2912
|
+
};
|
|
2913
|
+
|
|
2914
|
+
const TestFrameWorkComponentUrl = {
|
|
2915
|
+
__proto__: null,
|
|
2916
|
+
resolve,
|
|
2917
|
+
setUrl
|
|
2918
|
+
};
|
|
2919
|
+
|
|
2893
2920
|
const getPortTuple = () => {
|
|
2894
2921
|
const {
|
|
2895
2922
|
port1,
|
|
@@ -2964,9 +2991,15 @@ const TestFrameWorkComponentWebView = {
|
|
|
2964
2991
|
const setPath = async path => {
|
|
2965
2992
|
await invoke('Workspace.setPath', path);
|
|
2966
2993
|
};
|
|
2994
|
+
const openTmpDir = async () => {
|
|
2995
|
+
const tmpDir = await getTmpDir();
|
|
2996
|
+
await setPath(tmpDir);
|
|
2997
|
+
return tmpDir;
|
|
2998
|
+
};
|
|
2967
2999
|
|
|
2968
3000
|
const TestFrameWorkComponentWorkspace = {
|
|
2969
3001
|
__proto__: null,
|
|
3002
|
+
openTmpDir,
|
|
2970
3003
|
setPath
|
|
2971
3004
|
};
|
|
2972
3005
|
|
|
@@ -3002,6 +3035,7 @@ const TestFrameWorkComponent = {
|
|
|
3002
3035
|
SourceControl: TestFrameWorkComponentSourceControl,
|
|
3003
3036
|
StatusBar: TestFrameWorkComponentStatusBar,
|
|
3004
3037
|
TitleBarMenuBar: TestFrameWorkComponentTitleBarMenuBar,
|
|
3038
|
+
Url: TestFrameWorkComponentUrl,
|
|
3005
3039
|
WebView: TestFrameWorkComponentWebView,
|
|
3006
3040
|
Workspace: TestFrameWorkComponentWorkspace
|
|
3007
3041
|
};
|
|
@@ -3015,6 +3049,7 @@ const execute = async href => {
|
|
|
3015
3049
|
// 0. wait for page to be ready
|
|
3016
3050
|
// 1. get script to import from renderer process (url or from html)
|
|
3017
3051
|
const scriptUrl = href;
|
|
3052
|
+
setUrl(scriptUrl);
|
|
3018
3053
|
// 2. import that script
|
|
3019
3054
|
const module = await importTest(scriptUrl);
|
|
3020
3055
|
if (module.mockRpc) {
|