@openfin/remote-adapter 43.101.2 → 44.100.1

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.
Files changed (2) hide show
  1. package/out/remote-adapter.js +57 -198
  2. package/package.json +2 -2
@@ -20,6 +20,35 @@ var InteropBroker$1 = {};
20
20
 
21
21
  var base = {};
22
22
 
23
+ var promises = {};
24
+
25
+ Object.defineProperty(promises, "__esModule", { value: true });
26
+ promises.promiseMapSerial = promises.serial = promises.promiseMap = promises.promisify = void 0;
27
+ function promisify(func) {
28
+ return (...args) => new Promise((resolve, reject) => {
29
+ func(...args, (err, val) => (err ? reject(err) : resolve(val)));
30
+ });
31
+ }
32
+ promises.promisify = promisify;
33
+ async function promiseMap(arr, asyncF) {
34
+ return Promise.all(arr.map(asyncF));
35
+ }
36
+ promises.promiseMap = promiseMap;
37
+ async function serial(arr) {
38
+ const ret = [];
39
+ for (const func of arr) {
40
+ // eslint-disable-next-line no-await-in-loop
41
+ const next = await func();
42
+ ret.push(next);
43
+ }
44
+ return ret;
45
+ }
46
+ promises.serial = serial;
47
+ async function promiseMapSerial(arr, func) {
48
+ return serial(arr.map((value, index, array) => () => func(value, index, array)));
49
+ }
50
+ promises.promiseMapSerial = promiseMapSerial;
51
+
23
52
  var __classPrivateFieldSet$h = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
24
53
  if (kind === "m") throw new TypeError("Private method is not writable");
25
54
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -34,6 +63,7 @@ var __classPrivateFieldGet$i = (commonjsGlobal && commonjsGlobal.__classPrivateF
34
63
  var _EmitterBase_emitterAccessor, _EmitterBase_deregisterOnceListeners;
35
64
  Object.defineProperty(base, "__esModule", { value: true });
36
65
  base.Reply = base.EmitterBase = base.Base = void 0;
66
+ const promises_1 = promises;
37
67
  class Base {
38
68
  /**
39
69
  * @internal
@@ -111,8 +141,27 @@ class EmitterBase extends Base {
111
141
  return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
112
142
  };
113
143
  this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
144
+ /**
145
+ * Cleans up after removal of a listener, e.g. deleting any lingering deregistration handlers for a
146
+ * `once` subscription.
147
+ *
148
+ * @remarks Implementing this as a `removeListener` handler ensures that direct removal of a listener
149
+ * on the base emitter will not leak additional core handlers. We could do this in the forwarding method,
150
+ * which would involve less "magic," but would be more-vulnerable to accidental re-introduction of a leak.
151
+ */
152
+ this.cleanUpRemovedListener = (eventType, listener) => {
153
+ const deregister = __classPrivateFieldGet$i(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
154
+ if (deregister) {
155
+ const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
156
+ emitter.removeListener(eventType, deregister);
157
+ }
158
+ };
114
159
  this.getOrCreateEmitter = () => {
115
- return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
160
+ const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
161
+ if (!emitter.listeners('removeListener').includes(this.cleanUpRemovedListener)) {
162
+ emitter.on('removeListener', this.cleanUpRemovedListener);
163
+ }
164
+ return emitter;
116
165
  };
117
166
  this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
118
167
  this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
@@ -152,6 +201,7 @@ class EmitterBase extends Base {
152
201
  };
153
202
  __classPrivateFieldSet$h(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
154
203
  __classPrivateFieldSet$h(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
204
+ this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
155
205
  }
156
206
  /**
157
207
  * Adds a listener to the end of the listeners array for the specified event.
@@ -229,10 +279,6 @@ class EmitterBase extends Base {
229
279
  const emitter = await this.deregisterEventListener(eventType, options);
230
280
  if (emitter) {
231
281
  emitter.removeListener(eventType, listener);
232
- const deregister = __classPrivateFieldGet$i(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
233
- if (deregister) {
234
- emitter.removeListener(eventType, deregister);
235
- }
236
282
  this.deleteEmitterIfNothingRegistered(emitter);
237
283
  }
238
284
  return this;
@@ -268,13 +314,12 @@ class EmitterBase extends Base {
268
314
  }
269
315
  else if (this.hasEmitter()) {
270
316
  const events = this.getOrCreateEmitter().eventNames();
271
- await Promise.all(events.map(removeByEvent));
317
+ await (0, promises_1.promiseMap)(events, removeByEvent);
272
318
  }
273
319
  return this;
274
320
  }
275
321
  deleteEmitterIfNothingRegistered(emitter) {
276
- // TODO: maybe emitterMap should clean up itself..
277
- if (emitter.eventNames().length === 0) {
322
+ if (emitter.eventNames().every((type) => type === 'removeListener')) {
278
323
  this.wire.eventAggregator.delete(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
279
324
  }
280
325
  }
@@ -6277,68 +6322,6 @@ function requireInstance$1 () {
6277
6322
  return undefined;
6278
6323
  }
6279
6324
  }
6280
- /**
6281
- * Displays the download bubble UI. If an anchor is provided, the bubble
6282
- * will be positioned according to the specified rectangle and anchor point.
6283
- *
6284
- * @param {OpenFin.Anchor} options
6285
- * Anchor configuration used to position the download bubble. This includes
6286
- * the bounding rectangle and the anchor location within that rectangle.
6287
- *
6288
- * @returns {Promise<void>}
6289
- * A promise that resolves once the request to show the download bubble
6290
- * has been processed.
6291
- * @example
6292
- * ```js
6293
- * const w = fin.Window.getCurrentSync();
6294
- * const el = document.getElementById("download-bubble-button");
6295
- * const rect = el.getBoundingClientRect();
6296
- * const anchor = {
6297
- * bounds: rect,
6298
- * location: "topRight"
6299
- * };
6300
- * w.showDownloadBubble(anchor);
6301
- * ```
6302
- */
6303
- async showDownloadBubble(anchor) {
6304
- return this.wire.sendAction('show-download-bubble', { ...this.identity, anchor }).then(() => undefined);
6305
- }
6306
- /**
6307
- * Updates the anchor used for positioning the download bubble. This allows
6308
- * moving the bubble reactively—for example, in response to window resizes,
6309
- * layout changes, or DOM element repositioning.
6310
- *
6311
- * @param {OpenFin.Anchor} options
6312
- * New anchor configuration describing the updated position and anchor
6313
- * location for the download bubble.
6314
- *
6315
- * @returns {Promise<void>}
6316
- * A promise that resolves once the anchor update has been applied.
6317
- * @example
6318
- * ```js
6319
- * var w = fin.Window.getCurrentSync();
6320
- * w.on('download-button-visibility-changed', (evt) => {
6321
- * if (evt.visible) {
6322
- * const el = document.getElementById("download-bubble-button");
6323
- * //We show our button and get it's bounding rect
6324
- * el.classList.remove("hidden");
6325
- * const rect = el.getBoundingClientRect();
6326
- * const anchor = {
6327
- * bounds: rect,
6328
- * location: "topRight"
6329
- * }
6330
- * w.updateDownloadBubbleAnchor(anchor);
6331
- * } else {
6332
- * //We hide our button
6333
- * document.getElementById("download-bubble-button")?.classList.add("hidden");
6334
- * }
6335
- });
6336
- */
6337
- async updateDownloadBubbleAnchor(anchor) {
6338
- return this.wire
6339
- .sendAction('update-download-bubble-anchor', { ...this.identity, anchor })
6340
- .then(() => undefined);
6341
- }
6342
6325
  }
6343
6326
  Instance$6._Window = _Window;
6344
6327
  return Instance$6;
@@ -8796,15 +8779,14 @@ class System extends base_1$h.EmitterBase {
8796
8779
  * Writes the passed message into both the log file and the console.
8797
8780
  * @param level The log level for the entry. Can be either "info", "warning" or "error"
8798
8781
  * @param message The log message text
8799
- * @param target The log stream this message will be sent to, defaults to 'debug.log'. Specify 'app.log' to log to the app log of the sending View / Window. Note, when using `app.log`, it will always log to app.log irrespective of the `enableAppLogging` setting for the sender. This is particularly useful if you wish to log certain things from a View / Window but ignore generic console logs.
8800
8782
  *
8801
8783
  * @example
8802
8784
  * ```js
8803
- * fin.System.log("info", "An example log message", { type: 'debug.log' }).then(() => console.log('Log info message')).catch(err => console.log(err));
8785
+ * fin.System.log("info", "An example log message").then(() => console.log('Log info message')).catch(err => console.log(err));
8804
8786
  * ```
8805
8787
  */
8806
- log(level, message, target) {
8807
- return this.wire.sendAction('write-to-log', { level, message, target: target ?? {} }).then(() => undefined);
8788
+ log(level, message) {
8789
+ return this.wire.sendAction('write-to-log', { level, message }).then(() => undefined);
8808
8790
  }
8809
8791
  /**
8810
8792
  * Opens the passed URL in the default web browser.
@@ -9820,88 +9802,6 @@ class System extends base_1$h.EmitterBase {
9820
9802
  async serveAsset(options) {
9821
9803
  return (await this.wire.sendAction('serve-asset', { options })).payload.data;
9822
9804
  }
9823
- /**
9824
- * Get's the native theme preferences for the current runtime.
9825
- * Prefer css media-queries wherever possible, but this can be useful to see if the system setting has been overridden.
9826
- * See @link OpenFin.NativeTheme for more information.
9827
- * @example Theme selector menu
9828
- * ```ts
9829
- async function handleThemeMenu(e: React.MouseEvent<HTMLDivElement>) {
9830
- const currentTheme = await fin.System.getThemePreferences();
9831
- const result = await (fin.me as OpenFin.Window).showPopupMenu({
9832
- x: e.clientX,
9833
- y: e.clientY,
9834
- template: [
9835
- {
9836
- label: 'Light',
9837
- type: 'checkbox',
9838
- checked: currentTheme.themeSource === 'light',
9839
- data: { themeSource: 'light' } as const
9840
- },
9841
- {
9842
- label: 'Dark',
9843
- type: 'checkbox',
9844
- checked: currentTheme.themeSource === 'dark',
9845
- data: { themeSource: 'dark' } as const
9846
- },
9847
- {
9848
- label: 'System',
9849
- type: 'checkbox',
9850
- checked: currentTheme.themeSource === 'system',
9851
- data: { themeSource: 'system' } as const
9852
- }
9853
- ]
9854
- });
9855
- if (result.result === 'clicked') {
9856
- await fin.System.setThemePreferences(result.data);
9857
- }
9858
- }
9859
- ```
9860
- */
9861
- async getThemePreferences() {
9862
- return (await this.wire.sendAction('get-theme-preferences')).payload.data;
9863
- }
9864
- /**
9865
- * Sets the native theme preferences for the current runtime.
9866
- * Can be used to force runtime-wide light or dark mode.
9867
- * @important Due to this impacting all applications on a runtime, this method is only usable if a security realm has been set.
9868
- * @example Theme selector menu
9869
- * ```ts
9870
- async function handleThemeMenu(e: React.MouseEvent<HTMLDivElement>) {
9871
- const currentTheme = await fin.System.getThemePreferences();
9872
- const result = await (fin.me as OpenFin.Window).showPopupMenu({
9873
- x: e.clientX,
9874
- y: e.clientY,
9875
- template: [
9876
- {
9877
- label: 'Light',
9878
- type: 'checkbox',
9879
- checked: currentTheme.themeSource === 'light',
9880
- data: { themeSource: 'light' } as const
9881
- },
9882
- {
9883
- label: 'Dark',
9884
- type: 'checkbox',
9885
- checked: currentTheme.themeSource === 'dark',
9886
- data: { themeSource: 'dark' } as const
9887
- },
9888
- {
9889
- label: 'System',
9890
- type: 'checkbox',
9891
- checked: currentTheme.themeSource === 'system',
9892
- data: { themeSource: 'system' } as const
9893
- }
9894
- ]
9895
- });
9896
- if (result.result === 'clicked') {
9897
- await fin.System.setThemePreferences(result.data);
9898
- }
9899
- }
9900
- ```
9901
- */
9902
- async setThemePreferences(preferences) {
9903
- return (await this.wire.sendAction('set-theme-preferences', { preferences })).payload.data;
9904
- }
9905
9805
  /**
9906
9806
  * Launches the Log Uploader. Full documentation can be found [here](https://resources.here.io/docs/core/develop/debug/log-uploader/).
9907
9807
  * @experimental
@@ -9909,45 +9809,6 @@ class System extends base_1$h.EmitterBase {
9909
9809
  async launchLogUploader(options) {
9910
9810
  return (await this.wire.sendAction('launch-log-uploader', { options })).payload.data;
9911
9811
  }
9912
- /**
9913
- * Overrides original Chromium theme color providers matching key (currently except high contrast ones). Only colors passed in the map will be overridden.
9914
- * @param overrides - Array of ColorProviderOverrides objects
9915
- * @example
9916
- * ```ts
9917
- * await fin.System.setThemePalette([
9918
- * {
9919
- * colorProviderKey: { colorMode: 'light' },
9920
- * colorsMap: {
9921
- * kColorLabelForeground: 4278190080,
9922
- * kColorBubbleBackground: 4293980400
9923
- * }
9924
- * },
9925
- * {
9926
- * colorProviderKey: { colorMode: 'dark' },
9927
- * colorsMap: {
9928
- * kColorLabelForeground: 4293980400,
9929
- * kColorBubbleBackground: 4293980400
9930
- * }
9931
- * }
9932
- * ]);
9933
- * ```
9934
- */
9935
- async setThemePalette(themePalette) {
9936
- return (await this.wire.sendAction('set-theme-palette', { themePalette })).payload.data;
9937
- }
9938
- /**
9939
- * Retrieves currently used color overrides
9940
- * @returns Array of ColorProviderOverrides objects
9941
- * @example
9942
- * ```ts
9943
- * const themePalette = await fin.System.getThemePalette();
9944
- * console.log(themePalette);
9945
- * ```
9946
- */
9947
- async getThemePalette() {
9948
- const { payload } = await this.wire.sendAction('get-theme-palette');
9949
- return payload.data;
9950
- }
9951
9812
  }
9952
9813
  system.System = System;
9953
9814
 
@@ -13998,7 +13859,7 @@ class LayoutNode {
13998
13859
  * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
13999
13860
  * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
14000
13861
  * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
14001
- * Note: This issue does not occur when using `tabOverflowBehavior: 'scroll'` in the layout configuration.
13862
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
14002
13863
  *
14003
13864
  * @param views The views that will populate the new TabStack.
14004
13865
  * @param options Additional options that control new TabStack creation.
@@ -14134,7 +13995,6 @@ class TabStack extends LayoutNode {
14134
13995
  * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
14135
13996
  * If that happens and then getViews() is called, it will return the identities in a different order than
14136
13997
  * than the currently rendered tab order.
14137
- * Note: This issue does not occur when using `tabOverflowBehavior: 'scroll'` in the layout configuration.
14138
13998
  *
14139
13999
  *
14140
14000
  * @throws If the {@link TabStack} has been destroyed.
@@ -14159,7 +14019,6 @@ class TabStack extends LayoutNode {
14159
14019
  *
14160
14020
  * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
14161
14021
  * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
14162
- * Note: This issue does not occur when using `tabOverflowBehavior: 'scroll'` in the layout configuration.
14163
14022
  *
14164
14023
  * @param view The identity of an existing view to add, or options to create a view.
14165
14024
  * @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/remote-adapter",
3
- "version": "43.101.2",
3
+ "version": "44.100.1",
4
4
  "description": "Establish intermachine runtime connections using webRTC.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,
@@ -20,6 +20,6 @@
20
20
  "author": "OpenFin",
21
21
  "dependencies": {
22
22
  "lodash": "^4.17.21",
23
- "@openfin/core": "43.101.2"
23
+ "@openfin/core": "44.100.1"
24
24
  }
25
25
  }