@openfin/core 46.100.63 → 46.100.65
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/out/mock-alpha.d.ts +24 -1
- package/out/mock-beta.d.ts +24 -1
- package/out/mock-public.d.ts +24 -1
- package/out/stub.d.ts +24 -1
- package/out/stub.js +62 -26
- package/out/stub.mjs +62 -26
- package/package.json +1 -1
package/out/mock-alpha.d.ts
CHANGED
|
@@ -2166,6 +2166,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
|
|
|
2166
2166
|
*/
|
|
2167
2167
|
declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
|
|
2168
2168
|
|
|
2169
|
+
/** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
|
|
2170
|
+
declare interface CallSite {
|
|
2171
|
+
getFileName(): string | null;
|
|
2172
|
+
toString(): string;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
/** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
|
|
2176
|
+
declare type CapturedStack = CallSite[] | string[];
|
|
2177
|
+
|
|
2169
2178
|
/**
|
|
2170
2179
|
* Configuration for page capture.
|
|
2171
2180
|
*
|
|
@@ -12003,6 +12012,20 @@ declare type PlatformOptions = ApplicationCreationOptions & {
|
|
|
12003
12012
|
* @default true
|
|
12004
12013
|
*/
|
|
12005
12014
|
allowLaunchIntoPlatform?: boolean;
|
|
12015
|
+
/**
|
|
12016
|
+
* @experimental
|
|
12017
|
+
*
|
|
12018
|
+
* Creates window chrome before views. `createWindow` resolves when the window exists
|
|
12019
|
+
* (`window-created`) instead of waiting for layout creation to finish (`layout-ready`).
|
|
12020
|
+
*
|
|
12021
|
+
* Views start after the window exists. During `applySnapshot`, every window shell is
|
|
12022
|
+
* created first; view creation starts after `platform-snapshot-applied`.
|
|
12023
|
+
*
|
|
12024
|
+
* Tradeoff: windows appear sooner, but view content and `layout-ready` are delayed.
|
|
12025
|
+
*
|
|
12026
|
+
* @default false
|
|
12027
|
+
*/
|
|
12028
|
+
deferViewCreation?: boolean;
|
|
12006
12029
|
};
|
|
12007
12030
|
|
|
12008
12031
|
/**
|
|
@@ -17553,7 +17576,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
|
|
|
17553
17576
|
connectByPort(config: ExistingConnectConfig): Promise<void>;
|
|
17554
17577
|
private authorize;
|
|
17555
17578
|
sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
|
|
17556
|
-
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?:
|
|
17579
|
+
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
|
|
17557
17580
|
ferryAction(origData: any): Promise<Message<any>>;
|
|
17558
17581
|
registerMessageHandler(handler: MessageHandler): void;
|
|
17559
17582
|
protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
|
package/out/mock-beta.d.ts
CHANGED
|
@@ -2166,6 +2166,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
|
|
|
2166
2166
|
*/
|
|
2167
2167
|
declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
|
|
2168
2168
|
|
|
2169
|
+
/** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
|
|
2170
|
+
declare interface CallSite {
|
|
2171
|
+
getFileName(): string | null;
|
|
2172
|
+
toString(): string;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
/** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
|
|
2176
|
+
declare type CapturedStack = CallSite[] | string[];
|
|
2177
|
+
|
|
2169
2178
|
/**
|
|
2170
2179
|
* Configuration for page capture.
|
|
2171
2180
|
*
|
|
@@ -12003,6 +12012,20 @@ declare type PlatformOptions = ApplicationCreationOptions & {
|
|
|
12003
12012
|
* @default true
|
|
12004
12013
|
*/
|
|
12005
12014
|
allowLaunchIntoPlatform?: boolean;
|
|
12015
|
+
/**
|
|
12016
|
+
* @experimental
|
|
12017
|
+
*
|
|
12018
|
+
* Creates window chrome before views. `createWindow` resolves when the window exists
|
|
12019
|
+
* (`window-created`) instead of waiting for layout creation to finish (`layout-ready`).
|
|
12020
|
+
*
|
|
12021
|
+
* Views start after the window exists. During `applySnapshot`, every window shell is
|
|
12022
|
+
* created first; view creation starts after `platform-snapshot-applied`.
|
|
12023
|
+
*
|
|
12024
|
+
* Tradeoff: windows appear sooner, but view content and `layout-ready` are delayed.
|
|
12025
|
+
*
|
|
12026
|
+
* @default false
|
|
12027
|
+
*/
|
|
12028
|
+
deferViewCreation?: boolean;
|
|
12006
12029
|
};
|
|
12007
12030
|
|
|
12008
12031
|
/**
|
|
@@ -17553,7 +17576,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
|
|
|
17553
17576
|
connectByPort(config: ExistingConnectConfig): Promise<void>;
|
|
17554
17577
|
private authorize;
|
|
17555
17578
|
sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
|
|
17556
|
-
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?:
|
|
17579
|
+
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
|
|
17557
17580
|
ferryAction(origData: any): Promise<Message<any>>;
|
|
17558
17581
|
registerMessageHandler(handler: MessageHandler): void;
|
|
17559
17582
|
protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
|
package/out/mock-public.d.ts
CHANGED
|
@@ -2166,6 +2166,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
|
|
|
2166
2166
|
*/
|
|
2167
2167
|
declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
|
|
2168
2168
|
|
|
2169
|
+
/** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
|
|
2170
|
+
declare interface CallSite {
|
|
2171
|
+
getFileName(): string | null;
|
|
2172
|
+
toString(): string;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
/** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
|
|
2176
|
+
declare type CapturedStack = CallSite[] | string[];
|
|
2177
|
+
|
|
2169
2178
|
/**
|
|
2170
2179
|
* Configuration for page capture.
|
|
2171
2180
|
*
|
|
@@ -12003,6 +12012,20 @@ declare type PlatformOptions = ApplicationCreationOptions & {
|
|
|
12003
12012
|
* @default true
|
|
12004
12013
|
*/
|
|
12005
12014
|
allowLaunchIntoPlatform?: boolean;
|
|
12015
|
+
/**
|
|
12016
|
+
* @experimental
|
|
12017
|
+
*
|
|
12018
|
+
* Creates window chrome before views. `createWindow` resolves when the window exists
|
|
12019
|
+
* (`window-created`) instead of waiting for layout creation to finish (`layout-ready`).
|
|
12020
|
+
*
|
|
12021
|
+
* Views start after the window exists. During `applySnapshot`, every window shell is
|
|
12022
|
+
* created first; view creation starts after `platform-snapshot-applied`.
|
|
12023
|
+
*
|
|
12024
|
+
* Tradeoff: windows appear sooner, but view content and `layout-ready` are delayed.
|
|
12025
|
+
*
|
|
12026
|
+
* @default false
|
|
12027
|
+
*/
|
|
12028
|
+
deferViewCreation?: boolean;
|
|
12006
12029
|
};
|
|
12007
12030
|
|
|
12008
12031
|
/**
|
|
@@ -17553,7 +17576,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
|
|
|
17553
17576
|
connectByPort(config: ExistingConnectConfig): Promise<void>;
|
|
17554
17577
|
private authorize;
|
|
17555
17578
|
sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
|
|
17556
|
-
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?:
|
|
17579
|
+
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
|
|
17557
17580
|
ferryAction(origData: any): Promise<Message<any>>;
|
|
17558
17581
|
registerMessageHandler(handler: MessageHandler): void;
|
|
17559
17582
|
protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
|
package/out/stub.d.ts
CHANGED
|
@@ -2198,6 +2198,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
|
|
|
2198
2198
|
*/
|
|
2199
2199
|
declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
|
|
2200
2200
|
|
|
2201
|
+
/** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
|
|
2202
|
+
declare interface CallSite {
|
|
2203
|
+
getFileName(): string | null;
|
|
2204
|
+
toString(): string;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
/** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
|
|
2208
|
+
declare type CapturedStack = CallSite[] | string[];
|
|
2209
|
+
|
|
2201
2210
|
/**
|
|
2202
2211
|
* Configuration for page capture.
|
|
2203
2212
|
*
|
|
@@ -12450,6 +12459,20 @@ declare type PlatformOptions = ApplicationCreationOptions & {
|
|
|
12450
12459
|
* @default true
|
|
12451
12460
|
*/
|
|
12452
12461
|
allowLaunchIntoPlatform?: boolean;
|
|
12462
|
+
/**
|
|
12463
|
+
* @experimental
|
|
12464
|
+
*
|
|
12465
|
+
* Creates window chrome before views. `createWindow` resolves when the window exists
|
|
12466
|
+
* (`window-created`) instead of waiting for layout creation to finish (`layout-ready`).
|
|
12467
|
+
*
|
|
12468
|
+
* Views start after the window exists. During `applySnapshot`, every window shell is
|
|
12469
|
+
* created first; view creation starts after `platform-snapshot-applied`.
|
|
12470
|
+
*
|
|
12471
|
+
* Tradeoff: windows appear sooner, but view content and `layout-ready` are delayed.
|
|
12472
|
+
*
|
|
12473
|
+
* @default false
|
|
12474
|
+
*/
|
|
12475
|
+
deferViewCreation?: boolean;
|
|
12453
12476
|
};
|
|
12454
12477
|
|
|
12455
12478
|
/**
|
|
@@ -18058,7 +18081,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
|
|
|
18058
18081
|
connectByPort(config: ExistingConnectConfig): Promise<void>;
|
|
18059
18082
|
private authorize;
|
|
18060
18083
|
sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
|
|
18061
|
-
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?:
|
|
18084
|
+
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
|
|
18062
18085
|
ferryAction(origData: any): Promise<Message<any>>;
|
|
18063
18086
|
registerMessageHandler(handler: MessageHandler): void;
|
|
18064
18087
|
protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
|
package/out/stub.js
CHANGED
|
@@ -469,6 +469,26 @@ class EmitterBase extends Base {
|
|
|
469
469
|
}
|
|
470
470
|
_EmitterBase_emitterAccessor = new WeakMap(), _EmitterBase_deregisterOnceListeners = new WeakMap();
|
|
471
471
|
|
|
472
|
+
const V8Error = Error;
|
|
473
|
+
function isCallSiteArray(stack) {
|
|
474
|
+
if (!Array.isArray(stack) || stack.length === 0) {
|
|
475
|
+
return Array.isArray(stack);
|
|
476
|
+
}
|
|
477
|
+
const first = stack[0];
|
|
478
|
+
return typeof first === 'object' && first !== null && typeof first.getFileName === 'function';
|
|
479
|
+
}
|
|
480
|
+
function isStackFrameLine(line) {
|
|
481
|
+
return /^\s*at\s/.test(line) || line.includes('@');
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Split a native `error.stack` string into frames and drop the dummy Error header plus `framesToRemove` frames.
|
|
485
|
+
* Safari/Firefox ignore V8's Error.prepareStackTrace, so `.stack` stays a string and `.slice(n)` would cut characters.
|
|
486
|
+
*/
|
|
487
|
+
function stackStringToFrames(stack, framesToRemove) {
|
|
488
|
+
const lines = stack.split('\n').filter((line) => line.length > 0);
|
|
489
|
+
const start = lines[0] !== undefined && !isStackFrameLine(lines[0]) ? 1 : 0;
|
|
490
|
+
return lines.slice(start + framesToRemove);
|
|
491
|
+
}
|
|
472
492
|
class UnexpectedActionError extends Error {
|
|
473
493
|
}
|
|
474
494
|
class DuplicateCorrelationError extends Error {
|
|
@@ -497,17 +517,17 @@ class DeserializedError extends Error {
|
|
|
497
517
|
class RuntimeError extends Error {
|
|
498
518
|
static trimEndCallSites(err, takeUntilRegex) {
|
|
499
519
|
// save original props
|
|
500
|
-
const length =
|
|
520
|
+
const length = V8Error.stackTraceLimit;
|
|
501
521
|
// eslint-disable-next-line no-underscore-dangle
|
|
502
|
-
const _prepareStackTrace =
|
|
522
|
+
const _prepareStackTrace = V8Error.prepareStackTrace;
|
|
503
523
|
// This will be called when we access the `stack` property
|
|
504
|
-
|
|
524
|
+
V8Error.prepareStackTrace = (_, stack) => stack;
|
|
505
525
|
// in channel errors, the error was already serialized so we need to handle both string and CallSite[]
|
|
506
526
|
const isString = typeof err.stack === 'string';
|
|
507
527
|
const stack = (isString ? err.stack?.split('\n') : err.stack) ?? [];
|
|
508
528
|
// restore original props
|
|
509
|
-
|
|
510
|
-
|
|
529
|
+
V8Error.prepareStackTrace = _prepareStackTrace;
|
|
530
|
+
V8Error.stackTraceLimit = length;
|
|
511
531
|
// stack is optional in non chromium contexts
|
|
512
532
|
if (stack.length) {
|
|
513
533
|
const newStack = [];
|
|
@@ -529,31 +549,47 @@ class RuntimeError extends Error {
|
|
|
529
549
|
}
|
|
530
550
|
}
|
|
531
551
|
static getCallSite(callsToRemove = 0) {
|
|
532
|
-
const length =
|
|
552
|
+
const length = V8Error.stackTraceLimit;
|
|
533
553
|
const realCallsToRemove = callsToRemove + 1; // remove this call;
|
|
534
|
-
|
|
554
|
+
const limit = typeof length === 'number' && Number.isFinite(length) ? length : 10;
|
|
535
555
|
// eslint-disable-next-line no-underscore-dangle
|
|
536
|
-
const _prepareStackTrace =
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
556
|
+
const _prepareStackTrace = V8Error.prepareStackTrace;
|
|
557
|
+
try {
|
|
558
|
+
V8Error.stackTraceLimit = limit + realCallsToRemove;
|
|
559
|
+
// V8 only: accessing `.stack` invokes this and returns CallSite[]. Safari/Firefox ignore it.
|
|
560
|
+
V8Error.prepareStackTrace = (_, stack) => stack;
|
|
561
|
+
const rawStack = new Error().stack;
|
|
562
|
+
if (Array.isArray(rawStack)) {
|
|
563
|
+
return rawStack.slice(realCallsToRemove);
|
|
564
|
+
}
|
|
565
|
+
if (typeof rawStack === 'string' && rawStack.length > 0) {
|
|
566
|
+
return stackStringToFrames(rawStack, realCallsToRemove);
|
|
567
|
+
}
|
|
568
|
+
return [];
|
|
569
|
+
}
|
|
570
|
+
finally {
|
|
571
|
+
V8Error.prepareStackTrace = _prepareStackTrace;
|
|
572
|
+
V8Error.stackTraceLimit = length;
|
|
573
|
+
}
|
|
544
574
|
}
|
|
545
575
|
static prepareStackTrace(err, callSites) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
576
|
+
const header = `${err.name || 'Error'}: ${err.message || ''}`;
|
|
577
|
+
const frames = typeof callSites === 'string' ? stackStringToFrames(callSites, 0) : callSites;
|
|
578
|
+
if (!Array.isArray(frames) || frames.length === 0) {
|
|
579
|
+
return header;
|
|
580
|
+
}
|
|
581
|
+
if (isCallSiteArray(frames)) {
|
|
582
|
+
const prepare = V8Error.prepareStackTrace;
|
|
583
|
+
// Only V8 CallSite[] may be passed to a user-supplied Error.prepareStackTrace.
|
|
584
|
+
if (typeof prepare === 'function') {
|
|
585
|
+
return prepare(err, frames);
|
|
586
|
+
}
|
|
587
|
+
// TODO: this is just a first iteration, we can make this "nicer" at some point
|
|
588
|
+
// const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
|
|
589
|
+
return `${header}\n${frames.map((line) => ` at ${line}`).join('\n')}`;
|
|
590
|
+
}
|
|
591
|
+
// Native Safari/Firefox frames already include their engine's format (`func@file:line:col`).
|
|
592
|
+
return `${header}\n${frames.join('\n')}`;
|
|
557
593
|
}
|
|
558
594
|
/*
|
|
559
595
|
|
package/out/stub.mjs
CHANGED
|
@@ -465,6 +465,26 @@ class EmitterBase extends Base {
|
|
|
465
465
|
}
|
|
466
466
|
_EmitterBase_emitterAccessor = new WeakMap(), _EmitterBase_deregisterOnceListeners = new WeakMap();
|
|
467
467
|
|
|
468
|
+
const V8Error = Error;
|
|
469
|
+
function isCallSiteArray(stack) {
|
|
470
|
+
if (!Array.isArray(stack) || stack.length === 0) {
|
|
471
|
+
return Array.isArray(stack);
|
|
472
|
+
}
|
|
473
|
+
const first = stack[0];
|
|
474
|
+
return typeof first === 'object' && first !== null && typeof first.getFileName === 'function';
|
|
475
|
+
}
|
|
476
|
+
function isStackFrameLine(line) {
|
|
477
|
+
return /^\s*at\s/.test(line) || line.includes('@');
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Split a native `error.stack` string into frames and drop the dummy Error header plus `framesToRemove` frames.
|
|
481
|
+
* Safari/Firefox ignore V8's Error.prepareStackTrace, so `.stack` stays a string and `.slice(n)` would cut characters.
|
|
482
|
+
*/
|
|
483
|
+
function stackStringToFrames(stack, framesToRemove) {
|
|
484
|
+
const lines = stack.split('\n').filter((line) => line.length > 0);
|
|
485
|
+
const start = lines[0] !== undefined && !isStackFrameLine(lines[0]) ? 1 : 0;
|
|
486
|
+
return lines.slice(start + framesToRemove);
|
|
487
|
+
}
|
|
468
488
|
class UnexpectedActionError extends Error {
|
|
469
489
|
}
|
|
470
490
|
class DuplicateCorrelationError extends Error {
|
|
@@ -493,17 +513,17 @@ class DeserializedError extends Error {
|
|
|
493
513
|
class RuntimeError extends Error {
|
|
494
514
|
static trimEndCallSites(err, takeUntilRegex) {
|
|
495
515
|
// save original props
|
|
496
|
-
const length =
|
|
516
|
+
const length = V8Error.stackTraceLimit;
|
|
497
517
|
// eslint-disable-next-line no-underscore-dangle
|
|
498
|
-
const _prepareStackTrace =
|
|
518
|
+
const _prepareStackTrace = V8Error.prepareStackTrace;
|
|
499
519
|
// This will be called when we access the `stack` property
|
|
500
|
-
|
|
520
|
+
V8Error.prepareStackTrace = (_, stack) => stack;
|
|
501
521
|
// in channel errors, the error was already serialized so we need to handle both string and CallSite[]
|
|
502
522
|
const isString = typeof err.stack === 'string';
|
|
503
523
|
const stack = (isString ? err.stack?.split('\n') : err.stack) ?? [];
|
|
504
524
|
// restore original props
|
|
505
|
-
|
|
506
|
-
|
|
525
|
+
V8Error.prepareStackTrace = _prepareStackTrace;
|
|
526
|
+
V8Error.stackTraceLimit = length;
|
|
507
527
|
// stack is optional in non chromium contexts
|
|
508
528
|
if (stack.length) {
|
|
509
529
|
const newStack = [];
|
|
@@ -525,31 +545,47 @@ class RuntimeError extends Error {
|
|
|
525
545
|
}
|
|
526
546
|
}
|
|
527
547
|
static getCallSite(callsToRemove = 0) {
|
|
528
|
-
const length =
|
|
548
|
+
const length = V8Error.stackTraceLimit;
|
|
529
549
|
const realCallsToRemove = callsToRemove + 1; // remove this call;
|
|
530
|
-
|
|
550
|
+
const limit = typeof length === 'number' && Number.isFinite(length) ? length : 10;
|
|
531
551
|
// eslint-disable-next-line no-underscore-dangle
|
|
532
|
-
const _prepareStackTrace =
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
552
|
+
const _prepareStackTrace = V8Error.prepareStackTrace;
|
|
553
|
+
try {
|
|
554
|
+
V8Error.stackTraceLimit = limit + realCallsToRemove;
|
|
555
|
+
// V8 only: accessing `.stack` invokes this and returns CallSite[]. Safari/Firefox ignore it.
|
|
556
|
+
V8Error.prepareStackTrace = (_, stack) => stack;
|
|
557
|
+
const rawStack = new Error().stack;
|
|
558
|
+
if (Array.isArray(rawStack)) {
|
|
559
|
+
return rawStack.slice(realCallsToRemove);
|
|
560
|
+
}
|
|
561
|
+
if (typeof rawStack === 'string' && rawStack.length > 0) {
|
|
562
|
+
return stackStringToFrames(rawStack, realCallsToRemove);
|
|
563
|
+
}
|
|
564
|
+
return [];
|
|
565
|
+
}
|
|
566
|
+
finally {
|
|
567
|
+
V8Error.prepareStackTrace = _prepareStackTrace;
|
|
568
|
+
V8Error.stackTraceLimit = length;
|
|
569
|
+
}
|
|
540
570
|
}
|
|
541
571
|
static prepareStackTrace(err, callSites) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
572
|
+
const header = `${err.name || 'Error'}: ${err.message || ''}`;
|
|
573
|
+
const frames = typeof callSites === 'string' ? stackStringToFrames(callSites, 0) : callSites;
|
|
574
|
+
if (!Array.isArray(frames) || frames.length === 0) {
|
|
575
|
+
return header;
|
|
576
|
+
}
|
|
577
|
+
if (isCallSiteArray(frames)) {
|
|
578
|
+
const prepare = V8Error.prepareStackTrace;
|
|
579
|
+
// Only V8 CallSite[] may be passed to a user-supplied Error.prepareStackTrace.
|
|
580
|
+
if (typeof prepare === 'function') {
|
|
581
|
+
return prepare(err, frames);
|
|
582
|
+
}
|
|
583
|
+
// TODO: this is just a first iteration, we can make this "nicer" at some point
|
|
584
|
+
// const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
|
|
585
|
+
return `${header}\n${frames.map((line) => ` at ${line}`).join('\n')}`;
|
|
586
|
+
}
|
|
587
|
+
// Native Safari/Firefox frames already include their engine's format (`func@file:line:col`).
|
|
588
|
+
return `${header}\n${frames.join('\n')}`;
|
|
553
589
|
}
|
|
554
590
|
/*
|
|
555
591
|
|