@openfin/remote-adapter 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.
@@ -2179,6 +2179,26 @@ function isNewConnectConfig(config) {
2179
2179
  return hasUuid(config) && hasRuntimeVersion(config);
2180
2180
  }
2181
2181
 
2182
+ const V8Error = Error;
2183
+ function isCallSiteArray(stack) {
2184
+ if (!Array.isArray(stack) || stack.length === 0) {
2185
+ return Array.isArray(stack);
2186
+ }
2187
+ const first = stack[0];
2188
+ return typeof first === 'object' && first !== null && typeof first.getFileName === 'function';
2189
+ }
2190
+ function isStackFrameLine(line) {
2191
+ return /^\s*at\s/.test(line) || line.includes('@');
2192
+ }
2193
+ /**
2194
+ * Split a native `error.stack` string into frames and drop the dummy Error header plus `framesToRemove` frames.
2195
+ * Safari/Firefox ignore V8's Error.prepareStackTrace, so `.stack` stays a string and `.slice(n)` would cut characters.
2196
+ */
2197
+ function stackStringToFrames(stack, framesToRemove) {
2198
+ const lines = stack.split('\n').filter((line) => line.length > 0);
2199
+ const start = lines[0] !== undefined && !isStackFrameLine(lines[0]) ? 1 : 0;
2200
+ return lines.slice(start + framesToRemove);
2201
+ }
2182
2202
  class DisconnectedError extends Error {
2183
2203
  constructor(readyState) {
2184
2204
  super(`Expected websocket state OPEN but found ${readyState}`);
@@ -2215,17 +2235,17 @@ class DeserializedError extends Error {
2215
2235
  class RuntimeError extends Error {
2216
2236
  static trimEndCallSites(err, takeUntilRegex) {
2217
2237
  // save original props
2218
- const length = Error.stackTraceLimit;
2238
+ const length = V8Error.stackTraceLimit;
2219
2239
  // eslint-disable-next-line no-underscore-dangle
2220
- const _prepareStackTrace = Error.prepareStackTrace;
2240
+ const _prepareStackTrace = V8Error.prepareStackTrace;
2221
2241
  // This will be called when we access the `stack` property
2222
- Error.prepareStackTrace = (_, stack) => stack;
2242
+ V8Error.prepareStackTrace = (_, stack) => stack;
2223
2243
  // in channel errors, the error was already serialized so we need to handle both string and CallSite[]
2224
2244
  const isString = typeof err.stack === 'string';
2225
2245
  const stack = (isString ? err.stack?.split('\n') : err.stack) ?? [];
2226
2246
  // restore original props
2227
- Error.prepareStackTrace = _prepareStackTrace;
2228
- Error.stackTraceLimit = length;
2247
+ V8Error.prepareStackTrace = _prepareStackTrace;
2248
+ V8Error.stackTraceLimit = length;
2229
2249
  // stack is optional in non chromium contexts
2230
2250
  if (stack.length) {
2231
2251
  const newStack = [];
@@ -2247,31 +2267,47 @@ class RuntimeError extends Error {
2247
2267
  }
2248
2268
  }
2249
2269
  static getCallSite(callsToRemove = 0) {
2250
- const length = Error.stackTraceLimit;
2270
+ const length = V8Error.stackTraceLimit;
2251
2271
  const realCallsToRemove = callsToRemove + 1; // remove this call;
2252
- Error.stackTraceLimit = length + realCallsToRemove;
2272
+ const limit = typeof length === 'number' && Number.isFinite(length) ? length : 10;
2253
2273
  // eslint-disable-next-line no-underscore-dangle
2254
- const _prepareStackTrace = Error.prepareStackTrace;
2255
- // This will be called when we access the `stack` property
2256
- Error.prepareStackTrace = (_, stack) => stack;
2257
- // stack is optional in non chromium contexts
2258
- const stack = new Error().stack?.slice(realCallsToRemove) ?? [];
2259
- Error.prepareStackTrace = _prepareStackTrace;
2260
- Error.stackTraceLimit = length;
2261
- return stack;
2274
+ const _prepareStackTrace = V8Error.prepareStackTrace;
2275
+ try {
2276
+ V8Error.stackTraceLimit = limit + realCallsToRemove;
2277
+ // V8 only: accessing `.stack` invokes this and returns CallSite[]. Safari/Firefox ignore it.
2278
+ V8Error.prepareStackTrace = (_, stack) => stack;
2279
+ const rawStack = new Error().stack;
2280
+ if (Array.isArray(rawStack)) {
2281
+ return rawStack.slice(realCallsToRemove);
2282
+ }
2283
+ if (typeof rawStack === 'string' && rawStack.length > 0) {
2284
+ return stackStringToFrames(rawStack, realCallsToRemove);
2285
+ }
2286
+ return [];
2287
+ }
2288
+ finally {
2289
+ V8Error.prepareStackTrace = _prepareStackTrace;
2290
+ V8Error.stackTraceLimit = length;
2291
+ }
2262
2292
  }
2263
2293
  static prepareStackTrace(err, callSites) {
2264
- if (typeof Error.prepareStackTrace === 'function') {
2265
- return Error.prepareStackTrace(err, callSites);
2266
- }
2267
- // TODO: this is just a first iteration, we can make this "nicer" at some point
2268
- // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
2269
- let stackTrace = `${err.name || 'Error'}: ${err.message || ''}\n`;
2270
- stackTrace += callSites
2271
- .map((line) => ` at ${line}`)
2272
- // .filter((line) => !EXCLUSIONS.some((l) => line.includes(l)))
2273
- .join('\n');
2274
- return stackTrace;
2294
+ const header = `${err.name || 'Error'}: ${err.message || ''}`;
2295
+ const frames = typeof callSites === 'string' ? stackStringToFrames(callSites, 0) : callSites;
2296
+ if (!Array.isArray(frames) || frames.length === 0) {
2297
+ return header;
2298
+ }
2299
+ if (isCallSiteArray(frames)) {
2300
+ const prepare = V8Error.prepareStackTrace;
2301
+ // Only V8 CallSite[] may be passed to a user-supplied Error.prepareStackTrace.
2302
+ if (typeof prepare === 'function') {
2303
+ return prepare(err, frames);
2304
+ }
2305
+ // TODO: this is just a first iteration, we can make this "nicer" at some point
2306
+ // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
2307
+ return `${header}\n${frames.map((line) => ` at ${line}`).join('\n')}`;
2308
+ }
2309
+ // Native Safari/Firefox frames already include their engine's format (`func@file:line:col`).
2310
+ return `${header}\n${frames.join('\n')}`;
2275
2311
  }
2276
2312
  /*
2277
2313
 
@@ -11729,16 +11765,21 @@ class InterApplicationBus extends Base {
11729
11765
  * Subscribes to messages from the specified application on the specified topic.
11730
11766
  * @param source This object is described in the Identity in the typedef
11731
11767
  * @param topic The topic on which the message is sent
11732
- * @param listener A function that is called when a message has
11733
- * been received. It is passed the message, uuid and name of the sending application.
11768
+ * @param listener A function that is called when a message has been received. It is passed
11769
+ * two arguments: the message, and the identity (`{ uuid, name }`) of the sender.
11734
11770
  * The message can be either a primitive data type (string, number, or boolean) or
11735
11771
  * composite data type (object, array) that is composed of other primitive or composite
11736
11772
  * data types
11737
11773
  *
11774
+ * @remarks This differs from the legacy `fin.desktop.InterApplicationBus.subscribe` API,
11775
+ * which passes `(message, uuid, name)` as separate arguments.
11776
+ *
11738
11777
  * @example
11739
11778
  * ```js
11740
11779
  * // subscribe to a specified application
11741
- * 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));
11780
+ * fin.InterApplicationBus.subscribe(fin.me, 'topic', (message, sender) => {
11781
+ * console.log(`Received from ${sender.uuid}/${sender.name}:`, message);
11782
+ * }).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
11742
11783
  *
11743
11784
  * // subscribe to wildcard
11744
11785
  * 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/remote-adapter",
3
- "version": "43.104.2",
3
+ "version": "43.104.3",
4
4
  "description": "Establish intermachine runtime connections using webRTC.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "es-toolkit": "^1.39.3",
18
18
  "tslib": "2.8.1",
19
- "@openfin/core": "43.104.2"
19
+ "@openfin/core": "43.104.3"
20
20
  },
21
21
  "scripts": {
22
22
  "prebuild": "rimraf ./out",