@openfin/node-adapter 46.100.4 → 46.100.6

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/node-adapter.js +107 -31
  2. package/package.json +2 -2
@@ -35,13 +35,13 @@ var net__namespace = /*#__PURE__*/_interopNamespaceDefault(net);
35
35
  var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
36
36
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
37
37
 
38
- var __classPrivateFieldSet$k = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
38
+ var __classPrivateFieldSet$l = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
39
39
  if (kind === "m") throw new TypeError("Private method is not writable");
40
40
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
41
41
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
42
42
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
43
43
  };
44
- var __classPrivateFieldGet$l = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
44
+ var __classPrivateFieldGet$m = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
45
45
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
46
46
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
47
47
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -122,9 +122,9 @@ class EmitterBase extends Base {
122
122
  this.emit = (eventType, payload, ...args) => {
123
123
  return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
124
124
  };
125
- this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$l(this, _EmitterBase_emitterAccessor, "f"));
125
+ this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$m(this, _EmitterBase_emitterAccessor, "f"));
126
126
  this.getOrCreateEmitter = () => {
127
- return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$l(this, _EmitterBase_emitterAccessor, "f"));
127
+ return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$m(this, _EmitterBase_emitterAccessor, "f"));
128
128
  };
129
129
  this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
130
130
  this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
@@ -162,8 +162,8 @@ class EmitterBase extends Base {
162
162
  // This will only be reached if unsubscribe from event that does not exist but do not want to error here
163
163
  return Promise.resolve();
164
164
  };
165
- __classPrivateFieldSet$k(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
166
- __classPrivateFieldSet$k(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
165
+ __classPrivateFieldSet$l(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
166
+ __classPrivateFieldSet$l(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
167
167
  }
168
168
  /**
169
169
  * Adds a listener to the end of the listeners array for the specified event.
@@ -191,7 +191,7 @@ class EmitterBase extends Base {
191
191
  */
192
192
  async once(eventType, listener, options) {
193
193
  const deregister = () => this.deregisterEventListener(eventType);
194
- __classPrivateFieldGet$l(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
194
+ __classPrivateFieldGet$m(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
195
195
  await this.registerEventListener(eventType, options, (emitter) => {
196
196
  emitter.once(eventType, deregister);
197
197
  emitter.once(eventType, listener);
@@ -222,7 +222,7 @@ class EmitterBase extends Base {
222
222
  */
223
223
  async prependOnceListener(eventType, listener, options) {
224
224
  const deregister = () => this.deregisterEventListener(eventType);
225
- __classPrivateFieldGet$l(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
225
+ __classPrivateFieldGet$m(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
226
226
  await this.registerEventListener(eventType, options, (emitter) => {
227
227
  emitter.prependOnceListener(eventType, listener);
228
228
  emitter.once(eventType, deregister);
@@ -241,7 +241,7 @@ class EmitterBase extends Base {
241
241
  const emitter = await this.deregisterEventListener(eventType, options);
242
242
  if (emitter) {
243
243
  emitter.removeListener(eventType, listener);
244
- const deregister = __classPrivateFieldGet$l(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
244
+ const deregister = __classPrivateFieldGet$m(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
245
245
  if (deregister) {
246
246
  emitter.removeListener(eventType, deregister);
247
247
  }
@@ -287,7 +287,7 @@ class EmitterBase extends Base {
287
287
  deleteEmitterIfNothingRegistered(emitter) {
288
288
  // TODO: maybe emitterMap should clean up itself..
289
289
  if (emitter.eventNames().length === 0) {
290
- this.wire.eventAggregator.delete(__classPrivateFieldGet$l(this, _EmitterBase_emitterAccessor, "f"));
290
+ this.wire.eventAggregator.delete(__classPrivateFieldGet$m(this, _EmitterBase_emitterAccessor, "f"));
291
291
  }
292
292
  }
293
293
  }
@@ -4917,18 +4917,36 @@ class SystemContentTracing extends Base {
4917
4917
  *
4918
4918
  * @packageDocumentation
4919
4919
  */
4920
+ var __classPrivateFieldGet$l = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4921
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4922
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4923
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4924
+ };
4925
+ var __classPrivateFieldSet$k = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4926
+ if (kind === "m") throw new TypeError("Private method is not writable");
4927
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4928
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
4929
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4930
+ };
4931
+ var _System_instances, _System_registeredUsageKeys, _System_pendingUsageKeys, _System_usageBatch, _System_usageFlushScheduled, _System_flushUsageBatch;
4920
4932
  /**
4921
4933
  * An object representing the core of OpenFin Runtime. Allows the developer
4922
4934
  * to perform system-level actions, such as accessing logs, viewing processes,
4923
4935
  * clearing the cache and exiting the runtime as well as listen to {@link OpenFin.SystemEvents system events}.
4924
4936
  *
4925
4937
  */
4938
+ const sortedKeysReplacer = (_, v) => v && typeof v === 'object' && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort()) : v;
4926
4939
  class System extends EmitterBase {
4927
4940
  /**
4928
4941
  * @internal
4929
4942
  */
4930
4943
  constructor(wire) {
4931
4944
  super(wire, 'system');
4945
+ _System_instances.add(this);
4946
+ _System_registeredUsageKeys.set(this, new Set());
4947
+ _System_pendingUsageKeys.set(this, new Set());
4948
+ _System_usageBatch.set(this, []);
4949
+ _System_usageFlushScheduled.set(this, false);
4932
4950
  this.ContentTracing = new SystemContentTracing(wire);
4933
4951
  }
4934
4952
  sendExternalProcessRequest(action, options) {
@@ -6665,31 +6683,58 @@ class System extends EmitterBase {
6665
6683
  return payload.data;
6666
6684
  }
6667
6685
  /**
6668
- * (Internal) Register the usage of a component with a platform
6669
- * @param options - Object with data and type
6686
+ * (Internal) Register the usage of a component with a platform.
6687
+ *
6688
+ * @param options - Object with `data` and `type`.
6689
+ *
6690
+ * @remarks
6691
+ * **This method never throws.** All errors — including IPC failures, RVM timeouts, and
6692
+ * serialization errors — are caught internally and logged at `debug` level. Usage tracking
6693
+ * must never break the calling feature.
6694
+ *
6695
+ * Calls are automatically deduplicated client-side for the lifetime of the current window
6696
+ * (i.e. until the window is closed or the page is reloaded). The first call with a given
6697
+ * `type` + `data` combination is forwarded to the Runtime as normal. Any subsequent call
6698
+ * with the same `type` and `data` values within the same window lifetime is silently
6699
+ * suppressed without making an IPC round-trip.
6700
+ *
6701
+ * If `data` cannot be serialized to JSON (for example, a circular reference), deduplication
6702
+ * is skipped for that call and the IPC call is still forwarded unconditionally.
6670
6703
  *
6671
6704
  * @example
6672
6705
  * ```js
6673
- * async function registerUsage() {
6674
- * const app = await fin.System.getCurrent();
6675
- * return await fin.System.registerUsage({
6676
- * type: 'workspace-licensing',
6677
- * // example values for the following data object
6678
- * data: {
6679
- * apiVersion: '1.0',
6680
- * componentName: 'home',
6681
- * componentVersion: '1.0',
6682
- * allowed: true,
6683
- * rejectionCode: ''
6684
- * }
6685
- * });
6686
- * }
6687
- *
6688
- * registerUsage().then(() => console.log('Successfully registered component application')).catch(err => console.log(err));
6706
+ * // Safe to fire-and-forget — will never throw or reject.
6707
+ * // Duplicate calls within the same window lifetime are suppressed automatically.
6708
+ * fin.System.registerUsage({
6709
+ * type: 'workspace-licensing',
6710
+ * data: {
6711
+ * apiVersion: '1.0',
6712
+ * componentName: 'home',
6713
+ * componentVersion: '1.0',
6714
+ * allowed: true,
6715
+ * rejectionCode: ''
6716
+ * }
6717
+ * });
6689
6718
  * ```
6690
6719
  */
6691
- async registerUsage({ data, type }) {
6692
- await this.wire.sendAction('register-usage', { data, type });
6720
+ registerUsage({ data, type }) {
6721
+ let dedupKey;
6722
+ try {
6723
+ const key = `${type}\0${JSON.stringify(data, sortedKeysReplacer)}`;
6724
+ if (__classPrivateFieldGet$l(this, _System_registeredUsageKeys, "f").has(key) || __classPrivateFieldGet$l(this, _System_pendingUsageKeys, "f").has(key)) {
6725
+ return;
6726
+ }
6727
+ __classPrivateFieldGet$l(this, _System_pendingUsageKeys, "f").add(key);
6728
+ dedupKey = key;
6729
+ }
6730
+ catch {
6731
+ console.debug(`[registerUsage] Failed to serialize 'data' for deduplication (type: "${type}"). Sending unconditionally.`);
6732
+ }
6733
+ __classPrivateFieldGet$l(this, _System_usageBatch, "f").push({ payload: { data, type }, dedupKey });
6734
+ if (!__classPrivateFieldGet$l(this, _System_usageFlushScheduled, "f")) {
6735
+ __classPrivateFieldSet$k(this, _System_usageFlushScheduled, true, "f");
6736
+ queueMicrotask(() => __classPrivateFieldGet$l(this, _System_instances, "m", _System_flushUsageBatch).call(this));
6737
+ }
6693
6738
  }
6694
6739
  /**
6695
6740
  * Returns an array with all printers of the caller and not all the printers on the desktop.
@@ -6995,6 +7040,37 @@ class System extends EmitterBase {
6995
7040
  return payload.data;
6996
7041
  }
6997
7042
  }
7043
+ _System_registeredUsageKeys = new WeakMap(), _System_pendingUsageKeys = new WeakMap(), _System_usageBatch = new WeakMap(), _System_usageFlushScheduled = new WeakMap(), _System_instances = new WeakSet(), _System_flushUsageBatch = function _System_flushUsageBatch() {
7044
+ __classPrivateFieldSet$k(this, _System_usageFlushScheduled, false, "f");
7045
+ const batch = __classPrivateFieldGet$l(this, _System_usageBatch, "f");
7046
+ __classPrivateFieldSet$k(this, _System_usageBatch, [], "f");
7047
+ if (batch.length === 0)
7048
+ return;
7049
+ const items = batch.map(({ payload }) => payload);
7050
+ const keys = batch.map(({ dedupKey }) => dedupKey);
7051
+ const commitKeys = () => {
7052
+ for (const key of keys) {
7053
+ if (key !== undefined) {
7054
+ __classPrivateFieldGet$l(this, _System_pendingUsageKeys, "f").delete(key);
7055
+ __classPrivateFieldGet$l(this, _System_registeredUsageKeys, "f").add(key);
7056
+ }
7057
+ }
7058
+ };
7059
+ const rollbackKeys = () => {
7060
+ for (const key of keys) {
7061
+ if (key !== undefined) {
7062
+ __classPrivateFieldGet$l(this, _System_pendingUsageKeys, "f").delete(key);
7063
+ }
7064
+ }
7065
+ };
7066
+ const action = items.length === 1
7067
+ ? this.wire.sendAction('register-usage', items[0])
7068
+ : this.wire.sendAction('register-usage-batch', { items });
7069
+ action.then(commitKeys).catch((e) => {
7070
+ rollbackKeys();
7071
+ console.debug('[registerUsage] Failed to send usage data.', e);
7072
+ });
7073
+ };
6998
7074
 
6999
7075
  class RefCounter {
7000
7076
  constructor() {
@@ -17338,7 +17414,7 @@ class NodeEnvironment extends BaseEnvironment {
17338
17414
  };
17339
17415
  }
17340
17416
  getAdapterVersionSync() {
17341
- return "46.100.4";
17417
+ return "46.100.6";
17342
17418
  }
17343
17419
  observeBounds(element, onChange) {
17344
17420
  throw new Error('Method not implemented.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/node-adapter",
3
- "version": "46.100.4",
3
+ "version": "46.100.6",
4
4
  "description": "See README.md",
5
5
  "main": "out/node-adapter.js",
6
6
  "types": "out/node-adapter.d.ts",
@@ -20,7 +20,7 @@
20
20
  "es-toolkit": "^1.39.3",
21
21
  "ws": "^7.5.10",
22
22
  "tslib": "2.8.1",
23
- "@openfin/core": "46.100.4"
23
+ "@openfin/core": "46.100.6"
24
24
  },
25
25
  "scripts": {
26
26
  "prebuild": "rimraf ./out",