@lvce-editor/find-widget-worker 3.13.2 → 3.15.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/findWidgetWorkerMain.js +609 -216
- package/package.json +1 -1
|
@@ -96,7 +96,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
96
96
|
for (const property of Object.values(value)) {
|
|
97
97
|
walkValue(property, transferrables, isTransferrable);
|
|
98
98
|
}
|
|
99
|
-
return;
|
|
100
99
|
}
|
|
101
100
|
};
|
|
102
101
|
const getTransferrables = value => {
|
|
@@ -250,7 +249,14 @@ class IpcError extends VError {
|
|
|
250
249
|
const cause = new Error(message);
|
|
251
250
|
// @ts-ignore
|
|
252
251
|
cause.code = code;
|
|
253
|
-
|
|
252
|
+
if (stack) {
|
|
253
|
+
Object.defineProperty(cause, 'stack', {
|
|
254
|
+
configurable: true,
|
|
255
|
+
enumerable: false,
|
|
256
|
+
value: stack,
|
|
257
|
+
writable: true
|
|
258
|
+
});
|
|
259
|
+
}
|
|
254
260
|
super(cause, betterMessage);
|
|
255
261
|
} else {
|
|
256
262
|
super(betterMessage);
|
|
@@ -369,6 +375,27 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
369
375
|
wrap: wrap$e
|
|
370
376
|
};
|
|
371
377
|
|
|
378
|
+
class CommandNotFoundError extends Error {
|
|
379
|
+
constructor(command) {
|
|
380
|
+
super(`Command not found ${command}`);
|
|
381
|
+
this.name = 'CommandNotFoundError';
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const commands = Object.create(null);
|
|
385
|
+
const register = commandMap => {
|
|
386
|
+
Object.assign(commands, commandMap);
|
|
387
|
+
};
|
|
388
|
+
const getCommand = key => {
|
|
389
|
+
return commands[key];
|
|
390
|
+
};
|
|
391
|
+
const execute = (command, ...args) => {
|
|
392
|
+
const fn = getCommand(command);
|
|
393
|
+
if (!fn) {
|
|
394
|
+
throw new CommandNotFoundError(command);
|
|
395
|
+
}
|
|
396
|
+
return fn(...args);
|
|
397
|
+
};
|
|
398
|
+
|
|
372
399
|
const Two$1 = '2.0';
|
|
373
400
|
const callbacks = Object.create(null);
|
|
374
401
|
const get$2 = id => {
|
|
@@ -393,12 +420,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
393
420
|
switch (type) {
|
|
394
421
|
case DomException:
|
|
395
422
|
return DOMException;
|
|
396
|
-
case TypeError$1:
|
|
397
|
-
return TypeError;
|
|
398
|
-
case SyntaxError$1:
|
|
399
|
-
return SyntaxError;
|
|
400
423
|
case ReferenceError$1:
|
|
401
424
|
return ReferenceError;
|
|
425
|
+
case SyntaxError$1:
|
|
426
|
+
return SyntaxError;
|
|
427
|
+
case TypeError$1:
|
|
428
|
+
return TypeError;
|
|
402
429
|
default:
|
|
403
430
|
return Error;
|
|
404
431
|
}
|
|
@@ -422,7 +449,10 @@ const constructError = (message, type, name) => {
|
|
|
422
449
|
if (ErrorConstructor === Error) {
|
|
423
450
|
const error = new Error(message);
|
|
424
451
|
if (name && name !== 'VError') {
|
|
425
|
-
error
|
|
452
|
+
Object.defineProperty(error, 'name', {
|
|
453
|
+
configurable: true,
|
|
454
|
+
value: name
|
|
455
|
+
});
|
|
426
456
|
}
|
|
427
457
|
return error;
|
|
428
458
|
}
|
|
@@ -439,8 +469,10 @@ const getCurrentStack = () => {
|
|
|
439
469
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
440
470
|
return currentStack;
|
|
441
471
|
};
|
|
442
|
-
const getNewLineIndex = (string, startIndex
|
|
443
|
-
|
|
472
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
473
|
+
{
|
|
474
|
+
return string.indexOf(NewLine);
|
|
475
|
+
}
|
|
444
476
|
};
|
|
445
477
|
const getParentStack = error => {
|
|
446
478
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -451,55 +483,91 @@ const getParentStack = error => {
|
|
|
451
483
|
};
|
|
452
484
|
const MethodNotFound = -32601;
|
|
453
485
|
const Custom = -32001;
|
|
486
|
+
const setStack = (error, stack) => {
|
|
487
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
488
|
+
if (descriptor) {
|
|
489
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
493
|
+
error.stack = stack;
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
Object.defineProperty(error, 'stack', {
|
|
498
|
+
configurable: true,
|
|
499
|
+
value: stack,
|
|
500
|
+
writable: true
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
const restoreExistingError = (error, currentStack) => {
|
|
504
|
+
if (typeof error.stack === 'string') {
|
|
505
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
506
|
+
}
|
|
507
|
+
return error;
|
|
508
|
+
};
|
|
509
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
510
|
+
const restoredError = new JsonRpcError(error.message);
|
|
511
|
+
const parentStack = getParentStack(error);
|
|
512
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
513
|
+
return restoredError;
|
|
514
|
+
};
|
|
515
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
516
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
517
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (error.data.stack) {
|
|
521
|
+
setStack(restoredError, error.data.stack);
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
const applyDataProperties = (restoredError, error) => {
|
|
525
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
526
|
+
if (error.data.codeFrame) {
|
|
527
|
+
// @ts-ignore
|
|
528
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
529
|
+
}
|
|
530
|
+
if (error.data.code) {
|
|
531
|
+
// @ts-ignore
|
|
532
|
+
restoredError.code = error.data.code;
|
|
533
|
+
}
|
|
534
|
+
if (error.data.type) {
|
|
535
|
+
// @ts-ignore
|
|
536
|
+
restoredError.name = error.data.type;
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
540
|
+
if (error.stack) {
|
|
541
|
+
const lowerStack = restoredError.stack || '';
|
|
542
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
543
|
+
const parentStack = getParentStack(error);
|
|
544
|
+
// @ts-ignore
|
|
545
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
546
|
+
}
|
|
547
|
+
if (error.codeFrame) {
|
|
548
|
+
// @ts-ignore
|
|
549
|
+
restoredError.codeFrame = error.codeFrame;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
553
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
554
|
+
if (error.data) {
|
|
555
|
+
applyDataProperties(restoredError, error);
|
|
556
|
+
} else {
|
|
557
|
+
applyDirectProperties(restoredError, error);
|
|
558
|
+
}
|
|
559
|
+
return restoredError;
|
|
560
|
+
};
|
|
454
561
|
const restoreJsonRpcError = error => {
|
|
455
562
|
const currentStack = getCurrentStack();
|
|
456
563
|
if (error && error instanceof Error) {
|
|
457
|
-
|
|
458
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
459
|
-
}
|
|
460
|
-
return error;
|
|
564
|
+
return restoreExistingError(error, currentStack);
|
|
461
565
|
}
|
|
462
566
|
if (error && error.code && error.code === MethodNotFound) {
|
|
463
|
-
|
|
464
|
-
const parentStack = getParentStack(error);
|
|
465
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
466
|
-
return restoredError;
|
|
567
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
467
568
|
}
|
|
468
569
|
if (error && error.message) {
|
|
469
|
-
|
|
470
|
-
if (error.data) {
|
|
471
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
472
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
473
|
-
} else if (error.data.stack) {
|
|
474
|
-
restoredError.stack = error.data.stack;
|
|
475
|
-
}
|
|
476
|
-
if (error.data.codeFrame) {
|
|
477
|
-
// @ts-ignore
|
|
478
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
479
|
-
}
|
|
480
|
-
if (error.data.code) {
|
|
481
|
-
// @ts-ignore
|
|
482
|
-
restoredError.code = error.data.code;
|
|
483
|
-
}
|
|
484
|
-
if (error.data.type) {
|
|
485
|
-
// @ts-ignore
|
|
486
|
-
restoredError.name = error.data.type;
|
|
487
|
-
}
|
|
488
|
-
} else {
|
|
489
|
-
if (error.stack) {
|
|
490
|
-
const lowerStack = restoredError.stack || '';
|
|
491
|
-
// @ts-ignore
|
|
492
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
493
|
-
const parentStack = getParentStack(error);
|
|
494
|
-
// @ts-ignore
|
|
495
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
496
|
-
}
|
|
497
|
-
if (error.codeFrame) {
|
|
498
|
-
// @ts-ignore
|
|
499
|
-
restoredError.codeFrame = error.codeFrame;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return restoredError;
|
|
570
|
+
return restoreMessageError(error);
|
|
503
571
|
}
|
|
504
572
|
if (typeof error === 'string') {
|
|
505
573
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -554,56 +622,56 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
554
622
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
555
623
|
return {
|
|
556
624
|
code: MethodNotFound,
|
|
557
|
-
|
|
558
|
-
|
|
625
|
+
data: error.stack,
|
|
626
|
+
message: error.message
|
|
559
627
|
};
|
|
560
628
|
}
|
|
561
629
|
return {
|
|
562
630
|
code: Custom,
|
|
563
|
-
message: prettyError.message,
|
|
564
631
|
data: {
|
|
565
|
-
stack: getStack(prettyError),
|
|
566
|
-
codeFrame: prettyError.codeFrame,
|
|
567
|
-
type: getErrorType(prettyError),
|
|
568
632
|
code: prettyError.code,
|
|
569
|
-
|
|
570
|
-
|
|
633
|
+
codeFrame: prettyError.codeFrame,
|
|
634
|
+
name: prettyError.name,
|
|
635
|
+
stack: getStack(prettyError),
|
|
636
|
+
type: getErrorType(prettyError)
|
|
637
|
+
},
|
|
638
|
+
message: prettyError.message
|
|
571
639
|
};
|
|
572
640
|
};
|
|
573
|
-
const create$1$
|
|
641
|
+
const create$1$1 = (id, error) => {
|
|
574
642
|
return {
|
|
575
|
-
|
|
643
|
+
error,
|
|
576
644
|
id,
|
|
577
|
-
|
|
645
|
+
jsonrpc: Two$1
|
|
578
646
|
};
|
|
579
647
|
};
|
|
580
648
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
581
649
|
const prettyError = preparePrettyError(error);
|
|
582
650
|
logError(error, prettyError);
|
|
583
651
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
584
|
-
return create$1$
|
|
652
|
+
return create$1$1(id, errorProperty);
|
|
585
653
|
};
|
|
586
|
-
const create$
|
|
654
|
+
const create$7 = (message, result) => {
|
|
587
655
|
return {
|
|
588
|
-
jsonrpc: Two$1,
|
|
589
656
|
id: message.id,
|
|
657
|
+
jsonrpc: Two$1,
|
|
590
658
|
result: result ?? null
|
|
591
659
|
};
|
|
592
660
|
};
|
|
593
661
|
const getSuccessResponse = (message, result) => {
|
|
594
662
|
const resultProperty = result ?? null;
|
|
595
|
-
return create$
|
|
663
|
+
return create$7(message, resultProperty);
|
|
596
664
|
};
|
|
597
665
|
const getErrorResponseSimple = (id, error) => {
|
|
598
666
|
return {
|
|
599
|
-
jsonrpc: Two$1,
|
|
600
|
-
id,
|
|
601
667
|
error: {
|
|
602
668
|
code: Custom,
|
|
669
|
+
data: error,
|
|
603
670
|
// @ts-ignore
|
|
604
|
-
message: error.message
|
|
605
|
-
|
|
606
|
-
|
|
671
|
+
message: error.message
|
|
672
|
+
},
|
|
673
|
+
id,
|
|
674
|
+
jsonrpc: Two$1
|
|
607
675
|
};
|
|
608
676
|
};
|
|
609
677
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -633,35 +701,35 @@ const normalizeParams = args => {
|
|
|
633
701
|
if (args.length === 1) {
|
|
634
702
|
const options = args[0];
|
|
635
703
|
return {
|
|
704
|
+
execute: options.execute,
|
|
636
705
|
ipc: options.ipc,
|
|
706
|
+
logError: options.logError || defaultLogError,
|
|
637
707
|
message: options.message,
|
|
638
|
-
execute: options.execute,
|
|
639
|
-
resolve: options.resolve || defaultResolve,
|
|
640
708
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
641
|
-
|
|
642
|
-
|
|
709
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
710
|
+
resolve: options.resolve || defaultResolve
|
|
643
711
|
};
|
|
644
712
|
}
|
|
645
713
|
return {
|
|
714
|
+
execute: args[2],
|
|
646
715
|
ipc: args[0],
|
|
716
|
+
logError: args[5],
|
|
647
717
|
message: args[1],
|
|
648
|
-
execute: args[2],
|
|
649
|
-
resolve: args[3],
|
|
650
718
|
preparePrettyError: args[4],
|
|
651
|
-
|
|
652
|
-
|
|
719
|
+
requiresSocket: args[6],
|
|
720
|
+
resolve: args[3]
|
|
653
721
|
};
|
|
654
722
|
};
|
|
655
723
|
const handleJsonRpcMessage = async (...args) => {
|
|
656
724
|
const options = normalizeParams(args);
|
|
657
725
|
const {
|
|
658
|
-
message,
|
|
659
|
-
ipc,
|
|
660
726
|
execute,
|
|
661
|
-
|
|
662
|
-
preparePrettyError,
|
|
727
|
+
ipc,
|
|
663
728
|
logError,
|
|
664
|
-
|
|
729
|
+
message,
|
|
730
|
+
preparePrettyError,
|
|
731
|
+
requiresSocket,
|
|
732
|
+
resolve
|
|
665
733
|
} = options;
|
|
666
734
|
if ('id' in message) {
|
|
667
735
|
if ('method' in message) {
|
|
@@ -684,36 +752,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
684
752
|
throw new JsonRpcError('unexpected message');
|
|
685
753
|
};
|
|
686
754
|
|
|
687
|
-
class CommandNotFoundError extends Error {
|
|
688
|
-
constructor(command) {
|
|
689
|
-
super(`Command not found ${command}`);
|
|
690
|
-
this.name = 'CommandNotFoundError';
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
const commands = Object.create(null);
|
|
694
|
-
const register = commandMap => {
|
|
695
|
-
Object.assign(commands, commandMap);
|
|
696
|
-
};
|
|
697
|
-
const getCommand = key => {
|
|
698
|
-
return commands[key];
|
|
699
|
-
};
|
|
700
|
-
const execute = (command, ...args) => {
|
|
701
|
-
const fn = getCommand(command);
|
|
702
|
-
if (!fn) {
|
|
703
|
-
throw new CommandNotFoundError(command);
|
|
704
|
-
}
|
|
705
|
-
return fn(...args);
|
|
706
|
-
};
|
|
707
|
-
|
|
708
755
|
const Two = '2.0';
|
|
709
|
-
|
|
756
|
+
|
|
757
|
+
const create$6 = (method, params) => {
|
|
710
758
|
return {
|
|
711
759
|
jsonrpc: Two,
|
|
712
760
|
method,
|
|
713
761
|
params
|
|
714
762
|
};
|
|
715
763
|
};
|
|
716
|
-
|
|
764
|
+
|
|
765
|
+
const create$5 = (id, method, params) => {
|
|
717
766
|
const message = {
|
|
718
767
|
id,
|
|
719
768
|
jsonrpc: Two,
|
|
@@ -722,15 +771,14 @@ const create$r = (id, method, params) => {
|
|
|
722
771
|
};
|
|
723
772
|
return message;
|
|
724
773
|
};
|
|
774
|
+
|
|
725
775
|
let id = 0;
|
|
726
|
-
const create$
|
|
776
|
+
const create$4 = () => {
|
|
727
777
|
return ++id;
|
|
728
778
|
};
|
|
729
779
|
|
|
730
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
731
|
-
|
|
732
780
|
const registerPromise = map => {
|
|
733
|
-
const id = create$
|
|
781
|
+
const id = create$4();
|
|
734
782
|
const {
|
|
735
783
|
promise,
|
|
736
784
|
resolve
|
|
@@ -742,13 +790,12 @@ const registerPromise = map => {
|
|
|
742
790
|
};
|
|
743
791
|
};
|
|
744
792
|
|
|
745
|
-
// @ts-ignore
|
|
746
793
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
747
794
|
const {
|
|
748
795
|
id,
|
|
749
796
|
promise
|
|
750
797
|
} = registerPromise(callbacks);
|
|
751
|
-
const message = create$
|
|
798
|
+
const message = create$5(id, method, params);
|
|
752
799
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
753
800
|
ipc.sendAndTransfer(message);
|
|
754
801
|
} else {
|
|
@@ -784,12 +831,13 @@ const createRpc = ipc => {
|
|
|
784
831
|
* @deprecated
|
|
785
832
|
*/
|
|
786
833
|
send(method, ...params) {
|
|
787
|
-
const message = create$
|
|
834
|
+
const message = create$6(method, params);
|
|
788
835
|
ipc.send(message);
|
|
789
836
|
}
|
|
790
837
|
};
|
|
791
838
|
return rpc;
|
|
792
839
|
};
|
|
840
|
+
|
|
793
841
|
const requiresSocket = () => {
|
|
794
842
|
return false;
|
|
795
843
|
};
|
|
@@ -804,6 +852,7 @@ const handleMessage = event => {
|
|
|
804
852
|
const actualExecute = event?.target?.execute || execute;
|
|
805
853
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
806
854
|
};
|
|
855
|
+
|
|
807
856
|
const handleIpc = ipc => {
|
|
808
857
|
if ('addEventListener' in ipc) {
|
|
809
858
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -812,6 +861,7 @@ const handleIpc = ipc => {
|
|
|
812
861
|
ipc.on('message', handleMessage);
|
|
813
862
|
}
|
|
814
863
|
};
|
|
864
|
+
|
|
815
865
|
const listen$1 = async (module, options) => {
|
|
816
866
|
const rawIpc = await module.listen(options);
|
|
817
867
|
if (module.signal) {
|
|
@@ -820,7 +870,8 @@ const listen$1 = async (module, options) => {
|
|
|
820
870
|
const ipc = module.wrap(rawIpc);
|
|
821
871
|
return ipc;
|
|
822
872
|
};
|
|
823
|
-
|
|
873
|
+
|
|
874
|
+
const create$3 = async ({
|
|
824
875
|
commandMap
|
|
825
876
|
}) => {
|
|
826
877
|
// TODO create a commandMap per rpc instance
|
|
@@ -830,10 +881,7 @@ const create$1$1 = async ({
|
|
|
830
881
|
const rpc = createRpc(ipc);
|
|
831
882
|
return rpc;
|
|
832
883
|
};
|
|
833
|
-
|
|
834
|
-
__proto__: null,
|
|
835
|
-
create: create$1$1
|
|
836
|
-
};
|
|
884
|
+
|
|
837
885
|
const createMockRpc = ({
|
|
838
886
|
commandMap
|
|
839
887
|
}) => {
|
|
@@ -854,15 +902,227 @@ const createMockRpc = ({
|
|
|
854
902
|
return mockRpc;
|
|
855
903
|
};
|
|
856
904
|
|
|
905
|
+
const rpcs = Object.create(null);
|
|
906
|
+
const set$2 = (id, rpc) => {
|
|
907
|
+
rpcs[id] = rpc;
|
|
908
|
+
};
|
|
909
|
+
const get$1 = id => {
|
|
910
|
+
return rpcs[id];
|
|
911
|
+
};
|
|
912
|
+
const remove = id => {
|
|
913
|
+
delete rpcs[id];
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
917
|
+
const create$2 = rpcId => {
|
|
918
|
+
return {
|
|
919
|
+
async dispose() {
|
|
920
|
+
const rpc = get$1(rpcId);
|
|
921
|
+
await rpc.dispose();
|
|
922
|
+
},
|
|
923
|
+
// @ts-ignore
|
|
924
|
+
invoke(method, ...params) {
|
|
925
|
+
const rpc = get$1(rpcId);
|
|
926
|
+
// @ts-ignore
|
|
927
|
+
return rpc.invoke(method, ...params);
|
|
928
|
+
},
|
|
929
|
+
// @ts-ignore
|
|
930
|
+
invokeAndTransfer(method, ...params) {
|
|
931
|
+
const rpc = get$1(rpcId);
|
|
932
|
+
// @ts-ignore
|
|
933
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
934
|
+
},
|
|
935
|
+
registerMockRpc(commandMap) {
|
|
936
|
+
const mockRpc = createMockRpc({
|
|
937
|
+
commandMap
|
|
938
|
+
});
|
|
939
|
+
set$2(rpcId, mockRpc);
|
|
940
|
+
// @ts-ignore
|
|
941
|
+
mockRpc[Symbol.dispose] = () => {
|
|
942
|
+
remove(rpcId);
|
|
943
|
+
};
|
|
944
|
+
// @ts-ignore
|
|
945
|
+
return mockRpc;
|
|
946
|
+
},
|
|
947
|
+
set(rpc) {
|
|
948
|
+
set$2(rpcId, rpc);
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
};
|
|
952
|
+
|
|
857
953
|
const Alert = 'alert';
|
|
858
954
|
const CheckBox = 'checkbox';
|
|
859
955
|
const Group = 'group';
|
|
860
956
|
const None = 'none';
|
|
861
957
|
|
|
958
|
+
const Audio = 0;
|
|
862
959
|
const Button = 1;
|
|
960
|
+
const Col = 2;
|
|
961
|
+
const ColGroup = 3;
|
|
863
962
|
const Div = 4;
|
|
963
|
+
const H1 = 5;
|
|
964
|
+
const Input = 6;
|
|
965
|
+
const Kbd = 7;
|
|
966
|
+
const Span = 8;
|
|
967
|
+
const Table = 9;
|
|
968
|
+
const TBody = 10;
|
|
969
|
+
const Td = 11;
|
|
864
970
|
const Text = 12;
|
|
971
|
+
const Th = 13;
|
|
972
|
+
const THead = 14;
|
|
973
|
+
const Tr = 15;
|
|
974
|
+
const I = 16;
|
|
975
|
+
const Img = 17;
|
|
976
|
+
const Root = 0;
|
|
977
|
+
const Ins = 20;
|
|
978
|
+
const Del = 21;
|
|
979
|
+
const H2 = 22;
|
|
980
|
+
const H3 = 23;
|
|
981
|
+
const H4 = 24;
|
|
982
|
+
const H5 = 25;
|
|
983
|
+
const H6 = 26;
|
|
984
|
+
const Article = 27;
|
|
985
|
+
const Aside = 28;
|
|
986
|
+
const Footer = 29;
|
|
987
|
+
const Header = 30;
|
|
988
|
+
const Nav = 40;
|
|
989
|
+
const Section = 41;
|
|
990
|
+
const Search = 42;
|
|
991
|
+
const Dd = 43;
|
|
992
|
+
const Dl = 44;
|
|
993
|
+
const Figcaption = 45;
|
|
994
|
+
const Figure = 46;
|
|
995
|
+
const Hr = 47;
|
|
996
|
+
const Li = 48;
|
|
997
|
+
const Ol = 49;
|
|
998
|
+
const P = 50;
|
|
999
|
+
const Pre = 51;
|
|
1000
|
+
const A = 53;
|
|
1001
|
+
const Abbr = 54;
|
|
1002
|
+
const Br = 55;
|
|
1003
|
+
const Cite = 56;
|
|
1004
|
+
const Data = 57;
|
|
1005
|
+
const Time = 58;
|
|
1006
|
+
const Tfoot = 59;
|
|
1007
|
+
const Ul = 60;
|
|
1008
|
+
const Video = 61;
|
|
865
1009
|
const TextArea = 62;
|
|
1010
|
+
const Select = 63;
|
|
1011
|
+
const Option = 64;
|
|
1012
|
+
const Code = 65;
|
|
1013
|
+
const Label = 66;
|
|
1014
|
+
const Dt = 67;
|
|
1015
|
+
const Iframe = 68;
|
|
1016
|
+
const Main = 69;
|
|
1017
|
+
const Strong = 70;
|
|
1018
|
+
const Em = 71;
|
|
1019
|
+
const Style = 72;
|
|
1020
|
+
const Html = 73;
|
|
1021
|
+
const Head = 74;
|
|
1022
|
+
const Title = 75;
|
|
1023
|
+
const Meta = 76;
|
|
1024
|
+
const Canvas = 77;
|
|
1025
|
+
const Form = 78;
|
|
1026
|
+
const BlockQuote = 79;
|
|
1027
|
+
const Quote = 80;
|
|
1028
|
+
const Circle = 81;
|
|
1029
|
+
const Defs = 82;
|
|
1030
|
+
const Ellipse = 83;
|
|
1031
|
+
const G = 84;
|
|
1032
|
+
const Line = 85;
|
|
1033
|
+
const Path = 86;
|
|
1034
|
+
const Polygon = 87;
|
|
1035
|
+
const Polyline = 88;
|
|
1036
|
+
const Rect = 89;
|
|
1037
|
+
const Svg = 90;
|
|
1038
|
+
const Use = 91;
|
|
1039
|
+
const Reference = 100;
|
|
1040
|
+
|
|
1041
|
+
const VirtualDomElements = {
|
|
1042
|
+
__proto__: null,
|
|
1043
|
+
A,
|
|
1044
|
+
Abbr,
|
|
1045
|
+
Article,
|
|
1046
|
+
Aside,
|
|
1047
|
+
Audio,
|
|
1048
|
+
BlockQuote,
|
|
1049
|
+
Br,
|
|
1050
|
+
Button,
|
|
1051
|
+
Canvas,
|
|
1052
|
+
Circle,
|
|
1053
|
+
Cite,
|
|
1054
|
+
Code,
|
|
1055
|
+
Col,
|
|
1056
|
+
ColGroup,
|
|
1057
|
+
Data,
|
|
1058
|
+
Dd,
|
|
1059
|
+
Defs,
|
|
1060
|
+
Del,
|
|
1061
|
+
Div,
|
|
1062
|
+
Dl,
|
|
1063
|
+
Dt,
|
|
1064
|
+
Ellipse,
|
|
1065
|
+
Em,
|
|
1066
|
+
Figcaption,
|
|
1067
|
+
Figure,
|
|
1068
|
+
Footer,
|
|
1069
|
+
Form,
|
|
1070
|
+
G,
|
|
1071
|
+
H1,
|
|
1072
|
+
H2,
|
|
1073
|
+
H3,
|
|
1074
|
+
H4,
|
|
1075
|
+
H5,
|
|
1076
|
+
H6,
|
|
1077
|
+
Head,
|
|
1078
|
+
Header,
|
|
1079
|
+
Hr,
|
|
1080
|
+
Html,
|
|
1081
|
+
I,
|
|
1082
|
+
Iframe,
|
|
1083
|
+
Img,
|
|
1084
|
+
Input,
|
|
1085
|
+
Ins,
|
|
1086
|
+
Kbd,
|
|
1087
|
+
Label,
|
|
1088
|
+
Li,
|
|
1089
|
+
Line,
|
|
1090
|
+
Main,
|
|
1091
|
+
Meta,
|
|
1092
|
+
Nav,
|
|
1093
|
+
Ol,
|
|
1094
|
+
Option,
|
|
1095
|
+
P,
|
|
1096
|
+
Path,
|
|
1097
|
+
Polygon,
|
|
1098
|
+
Polyline,
|
|
1099
|
+
Pre,
|
|
1100
|
+
Quote,
|
|
1101
|
+
Rect,
|
|
1102
|
+
Reference,
|
|
1103
|
+
Root,
|
|
1104
|
+
Search,
|
|
1105
|
+
Section,
|
|
1106
|
+
Select,
|
|
1107
|
+
Span,
|
|
1108
|
+
Strong,
|
|
1109
|
+
Style,
|
|
1110
|
+
Svg,
|
|
1111
|
+
TBody,
|
|
1112
|
+
THead,
|
|
1113
|
+
Table,
|
|
1114
|
+
Td,
|
|
1115
|
+
Text,
|
|
1116
|
+
TextArea,
|
|
1117
|
+
Tfoot,
|
|
1118
|
+
Th,
|
|
1119
|
+
Time,
|
|
1120
|
+
Title,
|
|
1121
|
+
Tr,
|
|
1122
|
+
Ul,
|
|
1123
|
+
Use,
|
|
1124
|
+
Video
|
|
1125
|
+
};
|
|
866
1126
|
|
|
867
1127
|
const ClientX = 'event.clientX';
|
|
868
1128
|
const ClientY = 'event.clientY';
|
|
@@ -911,54 +1171,6 @@ const FocusSearchWholeWord = 34;
|
|
|
911
1171
|
const FocusToggleDetails = 1010;
|
|
912
1172
|
const FocusToggleReplace = 1020;
|
|
913
1173
|
|
|
914
|
-
const rpcs = Object.create(null);
|
|
915
|
-
const set$2 = (id, rpc) => {
|
|
916
|
-
rpcs[id] = rpc;
|
|
917
|
-
};
|
|
918
|
-
const get$1 = id => {
|
|
919
|
-
return rpcs[id];
|
|
920
|
-
};
|
|
921
|
-
const remove = id => {
|
|
922
|
-
delete rpcs[id];
|
|
923
|
-
};
|
|
924
|
-
|
|
925
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
926
|
-
const create$2 = rpcId => {
|
|
927
|
-
return {
|
|
928
|
-
async dispose() {
|
|
929
|
-
const rpc = get$1(rpcId);
|
|
930
|
-
await rpc.dispose();
|
|
931
|
-
},
|
|
932
|
-
// @ts-ignore
|
|
933
|
-
invoke(method, ...params) {
|
|
934
|
-
const rpc = get$1(rpcId);
|
|
935
|
-
// @ts-ignore
|
|
936
|
-
return rpc.invoke(method, ...params);
|
|
937
|
-
},
|
|
938
|
-
// @ts-ignore
|
|
939
|
-
invokeAndTransfer(method, ...params) {
|
|
940
|
-
const rpc = get$1(rpcId);
|
|
941
|
-
// @ts-ignore
|
|
942
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
943
|
-
},
|
|
944
|
-
registerMockRpc(commandMap) {
|
|
945
|
-
const mockRpc = createMockRpc({
|
|
946
|
-
commandMap
|
|
947
|
-
});
|
|
948
|
-
set$2(rpcId, mockRpc);
|
|
949
|
-
// @ts-ignore
|
|
950
|
-
mockRpc[Symbol.dispose] = () => {
|
|
951
|
-
remove(rpcId);
|
|
952
|
-
};
|
|
953
|
-
// @ts-ignore
|
|
954
|
-
return mockRpc;
|
|
955
|
-
},
|
|
956
|
-
set(rpc) {
|
|
957
|
-
set$2(rpcId, rpc);
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
};
|
|
961
|
-
|
|
962
1174
|
const {
|
|
963
1175
|
invoke,
|
|
964
1176
|
set: set$1
|
|
@@ -977,45 +1189,145 @@ const toCommandId = key => {
|
|
|
977
1189
|
return key.slice(dotIndex + 1);
|
|
978
1190
|
};
|
|
979
1191
|
const create$1 = () => {
|
|
1192
|
+
const commandQueues = new Map();
|
|
1193
|
+
const generations = Object.create(null);
|
|
980
1194
|
const states = Object.create(null);
|
|
981
1195
|
const commandMapRef = {};
|
|
1196
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1197
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1198
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1199
|
+
};
|
|
1200
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1201
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1202
|
+
return Promise.resolve(fallbackState);
|
|
1203
|
+
}
|
|
1204
|
+
const current = states[uid];
|
|
1205
|
+
const updatedState = updater(current.newState);
|
|
1206
|
+
if (updatedState !== current.newState) {
|
|
1207
|
+
states[uid] = {
|
|
1208
|
+
newState: updatedState,
|
|
1209
|
+
oldState: current.oldState,
|
|
1210
|
+
scheduledState: updatedState
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
return Promise.resolve(updatedState);
|
|
1214
|
+
};
|
|
1215
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1216
|
+
let latestState = states[uid].newState;
|
|
1217
|
+
return {
|
|
1218
|
+
getState: () => {
|
|
1219
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1220
|
+
latestState = states[uid].newState;
|
|
1221
|
+
}
|
|
1222
|
+
return latestState;
|
|
1223
|
+
},
|
|
1224
|
+
updateState: async updater => {
|
|
1225
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1226
|
+
return latestState;
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
};
|
|
1230
|
+
const enqueueCommand = async (uid, command) => {
|
|
1231
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1232
|
+
const run = async () => {
|
|
1233
|
+
try {
|
|
1234
|
+
await previous;
|
|
1235
|
+
} catch {
|
|
1236
|
+
// The previous caller receives its error; later commands must still run.
|
|
1237
|
+
}
|
|
1238
|
+
await command();
|
|
1239
|
+
};
|
|
1240
|
+
const current = run();
|
|
1241
|
+
commandQueues.set(uid, current);
|
|
1242
|
+
try {
|
|
1243
|
+
await current;
|
|
1244
|
+
} finally {
|
|
1245
|
+
if (commandQueues.get(uid) === current) {
|
|
1246
|
+
commandQueues.delete(uid);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
982
1250
|
return {
|
|
983
|
-
|
|
984
|
-
|
|
1251
|
+
clear() {
|
|
1252
|
+
commandQueues.clear();
|
|
1253
|
+
for (const key of Object.keys(states)) {
|
|
1254
|
+
delete states[key];
|
|
1255
|
+
}
|
|
985
1256
|
},
|
|
986
|
-
|
|
987
|
-
|
|
1257
|
+
diff(uid, modules, numbers) {
|
|
1258
|
+
const {
|
|
988
1259
|
oldState,
|
|
989
|
-
|
|
990
|
-
};
|
|
1260
|
+
scheduledState
|
|
1261
|
+
} = states[uid];
|
|
1262
|
+
const diffResult = [];
|
|
1263
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1264
|
+
const fn = modules[i];
|
|
1265
|
+
if (!fn(oldState, scheduledState)) {
|
|
1266
|
+
diffResult.push(numbers[i]);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return diffResult;
|
|
991
1270
|
},
|
|
992
1271
|
dispose(uid) {
|
|
1272
|
+
commandQueues.delete(uid);
|
|
993
1273
|
delete states[uid];
|
|
994
1274
|
},
|
|
1275
|
+
get(uid) {
|
|
1276
|
+
return states[uid];
|
|
1277
|
+
},
|
|
1278
|
+
getCommandIds() {
|
|
1279
|
+
const keys = Object.keys(commandMapRef);
|
|
1280
|
+
const ids = keys.map(toCommandId);
|
|
1281
|
+
return ids;
|
|
1282
|
+
},
|
|
995
1283
|
getKeys() {
|
|
996
|
-
return Object.keys(states).map(
|
|
997
|
-
return Number.parseInt(key);
|
|
998
|
-
});
|
|
1284
|
+
return Object.keys(states).map(Number);
|
|
999
1285
|
},
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1286
|
+
registerCommands(commandMap) {
|
|
1287
|
+
Object.assign(commandMapRef, commandMap);
|
|
1288
|
+
},
|
|
1289
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1290
|
+
const current = states[uid];
|
|
1291
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1292
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1003
1293
|
}
|
|
1294
|
+
states[uid] = {
|
|
1295
|
+
newState,
|
|
1296
|
+
oldState,
|
|
1297
|
+
scheduledState: scheduledState ?? newState
|
|
1298
|
+
};
|
|
1299
|
+
},
|
|
1300
|
+
wrapAsyncCommand(fn) {
|
|
1301
|
+
const wrapped = async (uid, ...args) => {
|
|
1302
|
+
const generation = getGeneration(uid);
|
|
1303
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1304
|
+
await fn(context, ...args);
|
|
1305
|
+
};
|
|
1306
|
+
return wrapped;
|
|
1004
1307
|
},
|
|
1005
1308
|
wrapCommand(fn) {
|
|
1006
1309
|
const wrapped = async (uid, ...args) => {
|
|
1310
|
+
const generation = getGeneration(uid);
|
|
1007
1311
|
const {
|
|
1008
|
-
|
|
1009
|
-
|
|
1312
|
+
newState,
|
|
1313
|
+
oldState
|
|
1010
1314
|
} = states[uid];
|
|
1011
1315
|
const newerState = await fn(newState, ...args);
|
|
1012
1316
|
if (oldState === newerState || newState === newerState) {
|
|
1013
1317
|
return;
|
|
1014
1318
|
}
|
|
1015
|
-
|
|
1319
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
const latestOld = states[uid];
|
|
1323
|
+
const latestNew = {
|
|
1324
|
+
...latestOld.newState,
|
|
1325
|
+
...newerState
|
|
1326
|
+
};
|
|
1016
1327
|
states[uid] = {
|
|
1017
|
-
|
|
1018
|
-
|
|
1328
|
+
newState: latestNew,
|
|
1329
|
+
oldState: latestOld.oldState,
|
|
1330
|
+
scheduledState: latestNew
|
|
1019
1331
|
};
|
|
1020
1332
|
};
|
|
1021
1333
|
return wrapped;
|
|
@@ -1029,27 +1341,88 @@ const create$1 = () => {
|
|
|
1029
1341
|
};
|
|
1030
1342
|
return wrapped;
|
|
1031
1343
|
},
|
|
1032
|
-
|
|
1033
|
-
const {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
|
|
1344
|
+
wrapLoadContent(fn) {
|
|
1345
|
+
const wrapped = async (uid, ...args) => {
|
|
1346
|
+
const generation = getGeneration(uid);
|
|
1347
|
+
const {
|
|
1348
|
+
newState,
|
|
1349
|
+
oldState
|
|
1350
|
+
} = states[uid];
|
|
1351
|
+
const result = await fn(newState, ...args);
|
|
1352
|
+
const {
|
|
1353
|
+
error,
|
|
1354
|
+
state
|
|
1355
|
+
} = result;
|
|
1356
|
+
if (oldState === state || newState === state) {
|
|
1357
|
+
return {
|
|
1358
|
+
error
|
|
1359
|
+
};
|
|
1042
1360
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1361
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1362
|
+
return {
|
|
1363
|
+
error
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
const latestOld = states[uid];
|
|
1367
|
+
const latestNew = {
|
|
1368
|
+
...latestOld.newState,
|
|
1369
|
+
...state
|
|
1370
|
+
};
|
|
1371
|
+
states[uid] = {
|
|
1372
|
+
newState: latestNew,
|
|
1373
|
+
oldState: latestOld.oldState,
|
|
1374
|
+
scheduledState: latestNew
|
|
1375
|
+
};
|
|
1376
|
+
return {
|
|
1377
|
+
error
|
|
1378
|
+
};
|
|
1379
|
+
};
|
|
1380
|
+
return wrapped;
|
|
1045
1381
|
},
|
|
1046
|
-
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1382
|
+
wrapSerialAsyncCommand(fn) {
|
|
1383
|
+
const wrapped = async (uid, ...args) => {
|
|
1384
|
+
await enqueueCommand(uid, async () => {
|
|
1385
|
+
if (!states[uid]) {
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
const generation = getGeneration(uid);
|
|
1389
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1390
|
+
await fn(context, ...args);
|
|
1391
|
+
});
|
|
1392
|
+
};
|
|
1393
|
+
return wrapped;
|
|
1050
1394
|
},
|
|
1051
|
-
|
|
1052
|
-
|
|
1395
|
+
wrapSerialCommand(fn) {
|
|
1396
|
+
const wrapped = async (uid, ...args) => {
|
|
1397
|
+
await enqueueCommand(uid, async () => {
|
|
1398
|
+
if (!states[uid]) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
const generation = getGeneration(uid);
|
|
1402
|
+
const {
|
|
1403
|
+
newState,
|
|
1404
|
+
oldState
|
|
1405
|
+
} = states[uid];
|
|
1406
|
+
const newerState = await fn(newState, ...args);
|
|
1407
|
+
if (oldState === newerState || newState === newerState) {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
const latestOld = states[uid];
|
|
1414
|
+
const latestNew = {
|
|
1415
|
+
...latestOld.newState,
|
|
1416
|
+
...newerState
|
|
1417
|
+
};
|
|
1418
|
+
states[uid] = {
|
|
1419
|
+
newState: latestNew,
|
|
1420
|
+
oldState: latestOld.oldState,
|
|
1421
|
+
scheduledState: latestNew
|
|
1422
|
+
};
|
|
1423
|
+
});
|
|
1424
|
+
};
|
|
1425
|
+
return wrapped;
|
|
1053
1426
|
}
|
|
1054
1427
|
};
|
|
1055
1428
|
};
|
|
@@ -1097,8 +1470,13 @@ const resolveUid = instanceId => {
|
|
|
1097
1470
|
};
|
|
1098
1471
|
const dispose$1 = uid => {
|
|
1099
1472
|
const state = registry.get(uid)?.newState;
|
|
1100
|
-
if (state
|
|
1101
|
-
|
|
1473
|
+
if (state) {
|
|
1474
|
+
const {
|
|
1475
|
+
instanceId
|
|
1476
|
+
} = state;
|
|
1477
|
+
if (instanceId) {
|
|
1478
|
+
instanceUids.delete(instanceId);
|
|
1479
|
+
}
|
|
1102
1480
|
}
|
|
1103
1481
|
registry.dispose(uid);
|
|
1104
1482
|
};
|
|
@@ -1293,7 +1671,10 @@ const FocusFindWidgetReplaceButton = 46;
|
|
|
1293
1671
|
const FocusFindWidgetToggleReplace = 42;
|
|
1294
1672
|
|
|
1295
1673
|
const setFindWidgetFocus = (state, focusKey) => {
|
|
1296
|
-
|
|
1674
|
+
const {
|
|
1675
|
+
focus
|
|
1676
|
+
} = state;
|
|
1677
|
+
if (focus === focusKey) {
|
|
1297
1678
|
return state;
|
|
1298
1679
|
}
|
|
1299
1680
|
return {
|
|
@@ -1308,10 +1689,13 @@ const focusCloseButton = state => {
|
|
|
1308
1689
|
};
|
|
1309
1690
|
|
|
1310
1691
|
const focusFind = state => {
|
|
1692
|
+
const {
|
|
1693
|
+
focusVersion
|
|
1694
|
+
} = state;
|
|
1311
1695
|
const newState = setFindWidgetFocus(state, FocusSearchInput);
|
|
1312
1696
|
return {
|
|
1313
1697
|
...newState,
|
|
1314
|
-
focusVersion:
|
|
1698
|
+
focusVersion: focusVersion + 1
|
|
1315
1699
|
};
|
|
1316
1700
|
};
|
|
1317
1701
|
|
|
@@ -1407,6 +1791,7 @@ const escapeRegExpCharacters = value => {
|
|
|
1407
1791
|
return RegExp.escape(value);
|
|
1408
1792
|
};
|
|
1409
1793
|
|
|
1794
|
+
const invalidRegex = /.^/;
|
|
1410
1795
|
const buildRegex = (searchString, options) => {
|
|
1411
1796
|
const {
|
|
1412
1797
|
matchCase,
|
|
@@ -1425,7 +1810,7 @@ const buildRegex = (searchString, options) => {
|
|
|
1425
1810
|
} catch (error) {
|
|
1426
1811
|
return {
|
|
1427
1812
|
error: String(error),
|
|
1428
|
-
regex:
|
|
1813
|
+
regex: invalidRegex
|
|
1429
1814
|
};
|
|
1430
1815
|
}
|
|
1431
1816
|
};
|
|
@@ -1552,8 +1937,12 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1552
1937
|
};
|
|
1553
1938
|
};
|
|
1554
1939
|
|
|
1555
|
-
const refresh = (state, value
|
|
1556
|
-
|
|
1940
|
+
const refresh = (state, value, inputSource = User$1) => {
|
|
1941
|
+
const {
|
|
1942
|
+
value: currentValue
|
|
1943
|
+
} = state;
|
|
1944
|
+
const newValue = value === undefined ? currentValue : value;
|
|
1945
|
+
return refresh$1(state, newValue, inputSource);
|
|
1557
1946
|
};
|
|
1558
1947
|
|
|
1559
1948
|
const toggleMatchCase = state => {
|
|
@@ -1618,6 +2007,8 @@ const applyEdits = async (editorId, edits) => {
|
|
|
1618
2007
|
await invoke('Editor.applyDocumentEdits', editorId, edits);
|
|
1619
2008
|
};
|
|
1620
2009
|
|
|
2010
|
+
const backReferenceRegex = /\$(\d{1,2})/g;
|
|
2011
|
+
|
|
1621
2012
|
/**
|
|
1622
2013
|
* Apply regex replacement with back-reference substitution ($1, $2, etc.)
|
|
1623
2014
|
*/
|
|
@@ -1648,7 +2039,7 @@ const applyRegexReplacement = (originalText, regex, replacement) => {
|
|
|
1648
2039
|
result = result.replaceAll('$$', '\u{0}DOLLAR\u{0}');
|
|
1649
2040
|
|
|
1650
2041
|
// Handle $n and $nn (numbered capture groups)
|
|
1651
|
-
result = result.replaceAll(
|
|
2042
|
+
result = result.replaceAll(backReferenceRegex, (_match, groupNumber) => {
|
|
1652
2043
|
const index = Number(groupNumber);
|
|
1653
2044
|
if (index < match.length) {
|
|
1654
2045
|
return match[index] ?? '';
|
|
@@ -2365,15 +2756,15 @@ const HandleResizerPointerUp = 17;
|
|
|
2365
2756
|
const HandleToggleReplaceFocus = 19;
|
|
2366
2757
|
|
|
2367
2758
|
const emptyObject = {};
|
|
2368
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
2369
2759
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
2370
2760
|
if (placeholders === emptyObject) {
|
|
2371
2761
|
return key;
|
|
2372
2762
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2763
|
+
let result = key;
|
|
2764
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
2765
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
2766
|
+
}
|
|
2767
|
+
return result;
|
|
2377
2768
|
};
|
|
2378
2769
|
|
|
2379
2770
|
const MatchOf = '{PH1} of {PH2}';
|
|
@@ -2530,6 +2921,8 @@ const text = data => {
|
|
|
2530
2921
|
};
|
|
2531
2922
|
};
|
|
2532
2923
|
|
|
2924
|
+
new Set(Object.values(VirtualDomElements));
|
|
2925
|
+
|
|
2533
2926
|
const FindWidget = 'FindWidget';
|
|
2534
2927
|
const FindWidgetFind = 'FindWidgetFind';
|
|
2535
2928
|
const FindWidgetMatchCount = 'FindWidgetMatchCount';
|
|
@@ -3106,7 +3499,7 @@ const commandMap = {
|
|
|
3106
3499
|
|
|
3107
3500
|
const listen = async () => {
|
|
3108
3501
|
registerCommands(commandMap);
|
|
3109
|
-
const rpc = await
|
|
3502
|
+
const rpc = await create$3({
|
|
3110
3503
|
commandMap: commandMap
|
|
3111
3504
|
});
|
|
3112
3505
|
set$1(rpc);
|