@openfin/core 43.104.2 → 43.104.3

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.
@@ -2137,6 +2137,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
2137
2137
  */
2138
2138
  declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
2139
2139
 
2140
+ /** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
2141
+ declare interface CallSite {
2142
+ getFileName(): string | null;
2143
+ toString(): string;
2144
+ }
2145
+
2146
+ /** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
2147
+ declare type CapturedStack = CallSite[] | string[];
2148
+
2140
2149
  /**
2141
2150
  * Configuration for page capture.
2142
2151
  *
@@ -6680,16 +6689,21 @@ declare class InterApplicationBus extends Base {
6680
6689
  * Subscribes to messages from the specified application on the specified topic.
6681
6690
  * @param source This object is described in the Identity in the typedef
6682
6691
  * @param topic The topic on which the message is sent
6683
- * @param listener A function that is called when a message has
6684
- * been received. It is passed the message, uuid and name of the sending application.
6692
+ * @param listener A function that is called when a message has been received. It is passed
6693
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
6685
6694
  * The message can be either a primitive data type (string, number, or boolean) or
6686
6695
  * composite data type (object, array) that is composed of other primitive or composite
6687
6696
  * data types
6688
6697
  *
6698
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
6699
+ * which passes `(message, uuid, name)` as separate arguments.
6700
+ *
6689
6701
  * @example
6690
6702
  * ```js
6691
6703
  * // subscribe to a specified application
6692
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6704
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
6705
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
6706
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6693
6707
  *
6694
6708
  * // subscribe to wildcard
6695
6709
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
@@ -17048,7 +17062,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
17048
17062
  connectByPort(config: ExistingConnectConfig): Promise<void>;
17049
17063
  private authorize;
17050
17064
  sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
17051
- protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
17065
+ protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
17052
17066
  ferryAction(origData: any): Promise<Message<any>>;
17053
17067
  registerMessageHandler(handler: MessageHandler): void;
17054
17068
  protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
@@ -2137,6 +2137,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
2137
2137
  */
2138
2138
  declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
2139
2139
 
2140
+ /** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
2141
+ declare interface CallSite {
2142
+ getFileName(): string | null;
2143
+ toString(): string;
2144
+ }
2145
+
2146
+ /** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
2147
+ declare type CapturedStack = CallSite[] | string[];
2148
+
2140
2149
  /**
2141
2150
  * Configuration for page capture.
2142
2151
  *
@@ -6680,16 +6689,21 @@ declare class InterApplicationBus extends Base {
6680
6689
  * Subscribes to messages from the specified application on the specified topic.
6681
6690
  * @param source This object is described in the Identity in the typedef
6682
6691
  * @param topic The topic on which the message is sent
6683
- * @param listener A function that is called when a message has
6684
- * been received. It is passed the message, uuid and name of the sending application.
6692
+ * @param listener A function that is called when a message has been received. It is passed
6693
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
6685
6694
  * The message can be either a primitive data type (string, number, or boolean) or
6686
6695
  * composite data type (object, array) that is composed of other primitive or composite
6687
6696
  * data types
6688
6697
  *
6698
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
6699
+ * which passes `(message, uuid, name)` as separate arguments.
6700
+ *
6689
6701
  * @example
6690
6702
  * ```js
6691
6703
  * // subscribe to a specified application
6692
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6704
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
6705
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
6706
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6693
6707
  *
6694
6708
  * // subscribe to wildcard
6695
6709
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
@@ -17048,7 +17062,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
17048
17062
  connectByPort(config: ExistingConnectConfig): Promise<void>;
17049
17063
  private authorize;
17050
17064
  sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
17051
- protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
17065
+ protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
17052
17066
  ferryAction(origData: any): Promise<Message<any>>;
17053
17067
  registerMessageHandler(handler: MessageHandler): void;
17054
17068
  protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
@@ -2137,6 +2137,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
2137
2137
  */
2138
2138
  declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
2139
2139
 
2140
+ /** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
2141
+ declare interface CallSite {
2142
+ getFileName(): string | null;
2143
+ toString(): string;
2144
+ }
2145
+
2146
+ /** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
2147
+ declare type CapturedStack = CallSite[] | string[];
2148
+
2140
2149
  /**
2141
2150
  * Configuration for page capture.
2142
2151
  *
@@ -6680,16 +6689,21 @@ declare class InterApplicationBus extends Base {
6680
6689
  * Subscribes to messages from the specified application on the specified topic.
6681
6690
  * @param source This object is described in the Identity in the typedef
6682
6691
  * @param topic The topic on which the message is sent
6683
- * @param listener A function that is called when a message has
6684
- * been received. It is passed the message, uuid and name of the sending application.
6692
+ * @param listener A function that is called when a message has been received. It is passed
6693
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
6685
6694
  * The message can be either a primitive data type (string, number, or boolean) or
6686
6695
  * composite data type (object, array) that is composed of other primitive or composite
6687
6696
  * data types
6688
6697
  *
6698
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
6699
+ * which passes `(message, uuid, name)` as separate arguments.
6700
+ *
6689
6701
  * @example
6690
6702
  * ```js
6691
6703
  * // subscribe to a specified application
6692
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6704
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
6705
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
6706
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6693
6707
  *
6694
6708
  * // subscribe to wildcard
6695
6709
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
@@ -17048,7 +17062,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
17048
17062
  connectByPort(config: ExistingConnectConfig): Promise<void>;
17049
17063
  private authorize;
17050
17064
  sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
17051
- protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
17065
+ protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
17052
17066
  ferryAction(origData: any): Promise<Message<any>>;
17053
17067
  registerMessageHandler(handler: MessageHandler): void;
17054
17068
  protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
package/out/stub.d.ts CHANGED
@@ -2169,6 +2169,15 @@ declare type ByType_8<Type extends EventType_8> = Payload_10<Type>;
2169
2169
  */
2170
2170
  declare type ByType_9<Type extends EventType_9> = Payload_11<Type>;
2171
2171
 
2172
+ /** Minimal V8 CallSite shape — js-adapter does not include @types/node. */
2173
+ declare interface CallSite {
2174
+ getFileName(): string | null;
2175
+ toString(): string;
2176
+ }
2177
+
2178
+ /** V8 CallSite objects, or native stack-frame strings from browsers that ignore Error.prepareStackTrace. */
2179
+ declare type CapturedStack = CallSite[] | string[];
2180
+
2172
2181
  /**
2173
2182
  * Configuration for page capture.
2174
2183
  *
@@ -6777,16 +6786,21 @@ declare class InterApplicationBus extends Base {
6777
6786
  * Subscribes to messages from the specified application on the specified topic.
6778
6787
  * @param source This object is described in the Identity in the typedef
6779
6788
  * @param topic The topic on which the message is sent
6780
- * @param listener A function that is called when a message has
6781
- * been received. It is passed the message, uuid and name of the sending application.
6789
+ * @param listener A function that is called when a message has been received. It is passed
6790
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
6782
6791
  * The message can be either a primitive data type (string, number, or boolean) or
6783
6792
  * composite data type (object, array) that is composed of other primitive or composite
6784
6793
  * data types
6785
6794
  *
6795
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
6796
+ * which passes `(message, uuid, name)` as separate arguments.
6797
+ *
6786
6798
  * @example
6787
6799
  * ```js
6788
6800
  * // subscribe to a specified application
6789
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6801
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
6802
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
6803
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
6790
6804
  *
6791
6805
  * // subscribe to wildcard
6792
6806
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
@@ -17478,7 +17492,7 @@ declare class Transport<MeType extends EntityType = EntityType> extends EventEmi
17478
17492
  connectByPort(config: ExistingConnectConfig): Promise<void>;
17479
17493
  private authorize;
17480
17494
  sendAction<T extends keyof ProtocolMap>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
17481
- protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
17495
+ protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: CapturedStack): void;
17482
17496
  ferryAction(origData: any): Promise<Message<any>>;
17483
17497
  registerMessageHandler(handler: MessageHandler): void;
17484
17498
  protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
package/out/stub.js CHANGED
@@ -472,6 +472,26 @@ class EmitterBase extends Base {
472
472
  }
473
473
  _EmitterBase_emitterAccessor = new WeakMap(), _EmitterBase_deregisterOnceListeners = new WeakMap();
474
474
 
475
+ const V8Error = Error;
476
+ function isCallSiteArray(stack) {
477
+ if (!Array.isArray(stack) || stack.length === 0) {
478
+ return Array.isArray(stack);
479
+ }
480
+ const first = stack[0];
481
+ return typeof first === 'object' && first !== null && typeof first.getFileName === 'function';
482
+ }
483
+ function isStackFrameLine(line) {
484
+ return /^\s*at\s/.test(line) || line.includes('@');
485
+ }
486
+ /**
487
+ * Split a native `error.stack` string into frames and drop the dummy Error header plus `framesToRemove` frames.
488
+ * Safari/Firefox ignore V8's Error.prepareStackTrace, so `.stack` stays a string and `.slice(n)` would cut characters.
489
+ */
490
+ function stackStringToFrames(stack, framesToRemove) {
491
+ const lines = stack.split('\n').filter((line) => line.length > 0);
492
+ const start = lines[0] !== undefined && !isStackFrameLine(lines[0]) ? 1 : 0;
493
+ return lines.slice(start + framesToRemove);
494
+ }
475
495
  class UnexpectedActionError extends Error {
476
496
  }
477
497
  class DuplicateCorrelationError extends Error {
@@ -500,17 +520,17 @@ class DeserializedError extends Error {
500
520
  class RuntimeError extends Error {
501
521
  static trimEndCallSites(err, takeUntilRegex) {
502
522
  // save original props
503
- const length = Error.stackTraceLimit;
523
+ const length = V8Error.stackTraceLimit;
504
524
  // eslint-disable-next-line no-underscore-dangle
505
- const _prepareStackTrace = Error.prepareStackTrace;
525
+ const _prepareStackTrace = V8Error.prepareStackTrace;
506
526
  // This will be called when we access the `stack` property
507
- Error.prepareStackTrace = (_, stack) => stack;
527
+ V8Error.prepareStackTrace = (_, stack) => stack;
508
528
  // in channel errors, the error was already serialized so we need to handle both string and CallSite[]
509
529
  const isString = typeof err.stack === 'string';
510
530
  const stack = (isString ? err.stack?.split('\n') : err.stack) ?? [];
511
531
  // restore original props
512
- Error.prepareStackTrace = _prepareStackTrace;
513
- Error.stackTraceLimit = length;
532
+ V8Error.prepareStackTrace = _prepareStackTrace;
533
+ V8Error.stackTraceLimit = length;
514
534
  // stack is optional in non chromium contexts
515
535
  if (stack.length) {
516
536
  const newStack = [];
@@ -532,31 +552,47 @@ class RuntimeError extends Error {
532
552
  }
533
553
  }
534
554
  static getCallSite(callsToRemove = 0) {
535
- const length = Error.stackTraceLimit;
555
+ const length = V8Error.stackTraceLimit;
536
556
  const realCallsToRemove = callsToRemove + 1; // remove this call;
537
- Error.stackTraceLimit = length + realCallsToRemove;
557
+ const limit = typeof length === 'number' && Number.isFinite(length) ? length : 10;
538
558
  // eslint-disable-next-line no-underscore-dangle
539
- const _prepareStackTrace = Error.prepareStackTrace;
540
- // This will be called when we access the `stack` property
541
- Error.prepareStackTrace = (_, stack) => stack;
542
- // stack is optional in non chromium contexts
543
- const stack = new Error().stack?.slice(realCallsToRemove) ?? [];
544
- Error.prepareStackTrace = _prepareStackTrace;
545
- Error.stackTraceLimit = length;
546
- return stack;
559
+ const _prepareStackTrace = V8Error.prepareStackTrace;
560
+ try {
561
+ V8Error.stackTraceLimit = limit + realCallsToRemove;
562
+ // V8 only: accessing `.stack` invokes this and returns CallSite[]. Safari/Firefox ignore it.
563
+ V8Error.prepareStackTrace = (_, stack) => stack;
564
+ const rawStack = new Error().stack;
565
+ if (Array.isArray(rawStack)) {
566
+ return rawStack.slice(realCallsToRemove);
567
+ }
568
+ if (typeof rawStack === 'string' && rawStack.length > 0) {
569
+ return stackStringToFrames(rawStack, realCallsToRemove);
570
+ }
571
+ return [];
572
+ }
573
+ finally {
574
+ V8Error.prepareStackTrace = _prepareStackTrace;
575
+ V8Error.stackTraceLimit = length;
576
+ }
547
577
  }
548
578
  static prepareStackTrace(err, callSites) {
549
- if (typeof Error.prepareStackTrace === 'function') {
550
- return Error.prepareStackTrace(err, callSites);
551
- }
552
- // TODO: this is just a first iteration, we can make this "nicer" at some point
553
- // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
554
- let stackTrace = `${err.name || 'Error'}: ${err.message || ''}\n`;
555
- stackTrace += callSites
556
- .map((line) => ` at ${line}`)
557
- // .filter((line) => !EXCLUSIONS.some((l) => line.includes(l)))
558
- .join('\n');
559
- return stackTrace;
579
+ const header = `${err.name || 'Error'}: ${err.message || ''}`;
580
+ const frames = typeof callSites === 'string' ? stackStringToFrames(callSites, 0) : callSites;
581
+ if (!Array.isArray(frames) || frames.length === 0) {
582
+ return header;
583
+ }
584
+ if (isCallSiteArray(frames)) {
585
+ const prepare = V8Error.prepareStackTrace;
586
+ // Only V8 CallSite[] may be passed to a user-supplied Error.prepareStackTrace.
587
+ if (typeof prepare === 'function') {
588
+ return prepare(err, frames);
589
+ }
590
+ // TODO: this is just a first iteration, we can make this "nicer" at some point
591
+ // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
592
+ return `${header}\n${frames.map((line) => ` at ${line}`).join('\n')}`;
593
+ }
594
+ // Native Safari/Firefox frames already include their engine's format (`func@file:line:col`).
595
+ return `${header}\n${frames.join('\n')}`;
560
596
  }
561
597
  /*
562
598
 
@@ -9350,16 +9386,21 @@ class InterApplicationBus extends Base {
9350
9386
  * Subscribes to messages from the specified application on the specified topic.
9351
9387
  * @param source This object is described in the Identity in the typedef
9352
9388
  * @param topic The topic on which the message is sent
9353
- * @param listener A function that is called when a message has
9354
- * been received. It is passed the message, uuid and name of the sending application.
9389
+ * @param listener A function that is called when a message has been received. It is passed
9390
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
9355
9391
  * The message can be either a primitive data type (string, number, or boolean) or
9356
9392
  * composite data type (object, array) that is composed of other primitive or composite
9357
9393
  * data types
9358
9394
  *
9395
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
9396
+ * which passes `(message, uuid, name)` as separate arguments.
9397
+ *
9359
9398
  * @example
9360
9399
  * ```js
9361
9400
  * // subscribe to a specified application
9362
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
9401
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
9402
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
9403
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
9363
9404
  *
9364
9405
  * // subscribe to wildcard
9365
9406
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
package/out/stub.mjs CHANGED
@@ -468,6 +468,26 @@ class EmitterBase extends Base {
468
468
  }
469
469
  _EmitterBase_emitterAccessor = new WeakMap(), _EmitterBase_deregisterOnceListeners = new WeakMap();
470
470
 
471
+ const V8Error = Error;
472
+ function isCallSiteArray(stack) {
473
+ if (!Array.isArray(stack) || stack.length === 0) {
474
+ return Array.isArray(stack);
475
+ }
476
+ const first = stack[0];
477
+ return typeof first === 'object' && first !== null && typeof first.getFileName === 'function';
478
+ }
479
+ function isStackFrameLine(line) {
480
+ return /^\s*at\s/.test(line) || line.includes('@');
481
+ }
482
+ /**
483
+ * Split a native `error.stack` string into frames and drop the dummy Error header plus `framesToRemove` frames.
484
+ * Safari/Firefox ignore V8's Error.prepareStackTrace, so `.stack` stays a string and `.slice(n)` would cut characters.
485
+ */
486
+ function stackStringToFrames(stack, framesToRemove) {
487
+ const lines = stack.split('\n').filter((line) => line.length > 0);
488
+ const start = lines[0] !== undefined && !isStackFrameLine(lines[0]) ? 1 : 0;
489
+ return lines.slice(start + framesToRemove);
490
+ }
471
491
  class UnexpectedActionError extends Error {
472
492
  }
473
493
  class DuplicateCorrelationError extends Error {
@@ -496,17 +516,17 @@ class DeserializedError extends Error {
496
516
  class RuntimeError extends Error {
497
517
  static trimEndCallSites(err, takeUntilRegex) {
498
518
  // save original props
499
- const length = Error.stackTraceLimit;
519
+ const length = V8Error.stackTraceLimit;
500
520
  // eslint-disable-next-line no-underscore-dangle
501
- const _prepareStackTrace = Error.prepareStackTrace;
521
+ const _prepareStackTrace = V8Error.prepareStackTrace;
502
522
  // This will be called when we access the `stack` property
503
- Error.prepareStackTrace = (_, stack) => stack;
523
+ V8Error.prepareStackTrace = (_, stack) => stack;
504
524
  // in channel errors, the error was already serialized so we need to handle both string and CallSite[]
505
525
  const isString = typeof err.stack === 'string';
506
526
  const stack = (isString ? err.stack?.split('\n') : err.stack) ?? [];
507
527
  // restore original props
508
- Error.prepareStackTrace = _prepareStackTrace;
509
- Error.stackTraceLimit = length;
528
+ V8Error.prepareStackTrace = _prepareStackTrace;
529
+ V8Error.stackTraceLimit = length;
510
530
  // stack is optional in non chromium contexts
511
531
  if (stack.length) {
512
532
  const newStack = [];
@@ -528,31 +548,47 @@ class RuntimeError extends Error {
528
548
  }
529
549
  }
530
550
  static getCallSite(callsToRemove = 0) {
531
- const length = Error.stackTraceLimit;
551
+ const length = V8Error.stackTraceLimit;
532
552
  const realCallsToRemove = callsToRemove + 1; // remove this call;
533
- Error.stackTraceLimit = length + realCallsToRemove;
553
+ const limit = typeof length === 'number' && Number.isFinite(length) ? length : 10;
534
554
  // eslint-disable-next-line no-underscore-dangle
535
- const _prepareStackTrace = Error.prepareStackTrace;
536
- // This will be called when we access the `stack` property
537
- Error.prepareStackTrace = (_, stack) => stack;
538
- // stack is optional in non chromium contexts
539
- const stack = new Error().stack?.slice(realCallsToRemove) ?? [];
540
- Error.prepareStackTrace = _prepareStackTrace;
541
- Error.stackTraceLimit = length;
542
- return stack;
555
+ const _prepareStackTrace = V8Error.prepareStackTrace;
556
+ try {
557
+ V8Error.stackTraceLimit = limit + realCallsToRemove;
558
+ // V8 only: accessing `.stack` invokes this and returns CallSite[]. Safari/Firefox ignore it.
559
+ V8Error.prepareStackTrace = (_, stack) => stack;
560
+ const rawStack = new Error().stack;
561
+ if (Array.isArray(rawStack)) {
562
+ return rawStack.slice(realCallsToRemove);
563
+ }
564
+ if (typeof rawStack === 'string' && rawStack.length > 0) {
565
+ return stackStringToFrames(rawStack, realCallsToRemove);
566
+ }
567
+ return [];
568
+ }
569
+ finally {
570
+ V8Error.prepareStackTrace = _prepareStackTrace;
571
+ V8Error.stackTraceLimit = length;
572
+ }
543
573
  }
544
574
  static prepareStackTrace(err, callSites) {
545
- if (typeof Error.prepareStackTrace === 'function') {
546
- return Error.prepareStackTrace(err, callSites);
547
- }
548
- // TODO: this is just a first iteration, we can make this "nicer" at some point
549
- // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
550
- let stackTrace = `${err.name || 'Error'}: ${err.message || ''}\n`;
551
- stackTrace += callSites
552
- .map((line) => ` at ${line}`)
553
- // .filter((line) => !EXCLUSIONS.some((l) => line.includes(l)))
554
- .join('\n');
555
- return stackTrace;
575
+ const header = `${err.name || 'Error'}: ${err.message || ''}`;
576
+ const frames = typeof callSites === 'string' ? stackStringToFrames(callSites, 0) : callSites;
577
+ if (!Array.isArray(frames) || frames.length === 0) {
578
+ return header;
579
+ }
580
+ if (isCallSiteArray(frames)) {
581
+ const prepare = V8Error.prepareStackTrace;
582
+ // Only V8 CallSite[] may be passed to a user-supplied Error.prepareStackTrace.
583
+ if (typeof prepare === 'function') {
584
+ return prepare(err, frames);
585
+ }
586
+ // TODO: this is just a first iteration, we can make this "nicer" at some point
587
+ // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
588
+ return `${header}\n${frames.map((line) => ` at ${line}`).join('\n')}`;
589
+ }
590
+ // Native Safari/Firefox frames already include their engine's format (`func@file:line:col`).
591
+ return `${header}\n${frames.join('\n')}`;
556
592
  }
557
593
  /*
558
594
 
@@ -9346,16 +9382,21 @@ class InterApplicationBus extends Base {
9346
9382
  * Subscribes to messages from the specified application on the specified topic.
9347
9383
  * @param source This object is described in the Identity in the typedef
9348
9384
  * @param topic The topic on which the message is sent
9349
- * @param listener A function that is called when a message has
9350
- * been received. It is passed the message, uuid and name of the sending application.
9385
+ * @param listener A function that is called when a message has been received. It is passed
9386
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
9351
9387
  * The message can be either a primitive data type (string, number, or boolean) or
9352
9388
  * composite data type (object, array) that is composed of other primitive or composite
9353
9389
  * data types
9354
9390
  *
9391
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
9392
+ * which passes `(message, uuid, name)` as separate arguments.
9393
+ *
9355
9394
  * @example
9356
9395
  * ```js
9357
9396
  * // subscribe to a specified application
9358
- * fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
9397
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
9398
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
9399
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
9359
9400
  *
9360
9401
  * // subscribe to wildcard
9361
9402
  * fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "43.104.2",
3
+ "version": "43.104.3",
4
4
  "description": "The core renderer entry point of OpenFin",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "out/stub.js",