@elliemae/microfe-common 2.5.3 → 2.6.0

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/dist/cjs/event.js CHANGED
@@ -51,10 +51,8 @@ class Event {
51
51
  */
52
52
  constructor(param) {
53
53
  const { name, requiresFeedback = false, so } = param;
54
- if (!name)
55
- throw new Error("Event name is required");
56
- if (!so)
57
- throw new Error("Scripting object is required");
54
+ if (!name) throw new Error("Event name is required");
55
+ if (!so) throw new Error("Scripting object is required");
58
56
  this.scriptingObject = so;
59
57
  this.objectId = so.id;
60
58
  this.name = name;
@@ -67,10 +67,8 @@ class Remoting {
67
67
  * @param correlationId unique id for the current session
68
68
  */
69
69
  constructor(logger, correlationId) {
70
- if (!logger)
71
- throw new Error("logger is required");
72
- if (!correlationId)
73
- throw new Error("correlationId is required");
70
+ if (!logger) throw new Error("logger is required");
71
+ if (!correlationId) throw new Error("correlationId is required");
74
72
  this.#correlationId = correlationId;
75
73
  this.#logger = logger;
76
74
  }
@@ -169,8 +167,7 @@ class Remoting {
169
167
  }) => {
170
168
  this.#logger.debug(`Received message of type "${message.type}"`);
171
169
  const callbacks = this.#listeners.get(message.type);
172
- if (!callbacks)
173
- return false;
170
+ if (!callbacks) return false;
174
171
  callbacks.forEach((callback) => {
175
172
  this.#logger.debug(`Invoking message handler ${callback.name}`);
176
173
  callback({
@@ -188,15 +185,11 @@ class Remoting {
188
185
  this.#logger.debug(
189
186
  `Remoting: Received message ${JSON.stringify(message.data)}`
190
187
  );
191
- if (this.#allowedSenders.size === 0)
192
- return false;
193
- if (!message.source)
194
- return false;
188
+ if (this.#allowedSenders.size === 0) return false;
189
+ if (!message.source) return false;
195
190
  const senderOrigin = this.#allowedSenders.get(message.source);
196
- if (!senderOrigin)
197
- return false;
198
- if (message?.data?.source !== MESSAGE_SOURCE)
199
- return false;
191
+ if (!senderOrigin) return false;
192
+ if (message?.data?.source !== MESSAGE_SOURCE) return false;
200
193
  if (message.data.type === RESPONSE_MESSAGE_TYPE)
201
194
  this.#processResponse(message.data);
202
195
  else if (message.data.type === EXCEPTION_MESSAGE_TYPE)
@@ -215,10 +208,8 @@ class Remoting {
215
208
  */
216
209
  addSender = (param) => {
217
210
  const { origin, window: window2 } = param;
218
- if (!origin)
219
- throw new Error("origin is required");
220
- if (!window2)
221
- throw new Error("window is required");
211
+ if (!origin) throw new Error("origin is required");
212
+ if (!window2) throw new Error("window is required");
222
213
  this.#allowedSenders.set(window2, origin);
223
214
  };
224
215
  /**
@@ -301,8 +292,7 @@ class Remoting {
301
292
  */
302
293
  removeSender = (param) => {
303
294
  const { window: window2 } = param;
304
- if (window2)
305
- this.#allowedSenders.delete(window2);
295
+ if (window2) this.#allowedSenders.delete(window2);
306
296
  };
307
297
  /**
308
298
  * Send a response message to a window
@@ -81,15 +81,13 @@ class ScriptingObjectManager {
81
81
  const moduleSOs = this.#guestScriptingObjects.get(guestId);
82
82
  if (moduleSOs) {
83
83
  const soInfo = moduleSOs.get(objectId);
84
- if (soInfo)
85
- this.#disposeSO(soInfo);
84
+ if (soInfo) this.#disposeSO(soInfo);
86
85
  moduleSOs.delete(objectId);
87
86
  }
88
87
  } else if (objectId) {
89
88
  this.#guestScriptingObjects.forEach((moduleSOs) => {
90
89
  const soInfo = moduleSOs.get(objectId);
91
- if (soInfo)
92
- this.#disposeSO(soInfo);
90
+ if (soInfo) this.#disposeSO(soInfo);
93
91
  moduleSOs.delete(objectId);
94
92
  });
95
93
  }
@@ -161,10 +159,8 @@ class ScriptingObjectManager {
161
159
  }
162
160
  soInfo = soInfo ?? this.#scriptingObjects.get(id);
163
161
  const { so } = soInfo || {};
164
- if (!so)
165
- return null;
166
- if (!guest)
167
- return so;
162
+ if (!so) return null;
163
+ if (!guest) return so;
168
164
  const guestSO = this.#attachCallContext({ so, guest });
169
165
  Object.defineProperty(guestSO, "target", {
170
166
  value: so,
@@ -186,8 +182,7 @@ class ScriptingObjectManager {
186
182
  } else {
187
183
  this.#removeGuestScriptingObject({ objectId: id });
188
184
  const soInfo = this.#scriptingObjects.get(id);
189
- if (soInfo)
190
- this.#disposeSO(soInfo);
185
+ if (soInfo) this.#disposeSO(soInfo);
191
186
  this.#scriptingObjects.delete(id);
192
187
  }
193
188
  };
package/dist/esm/event.js CHANGED
@@ -26,10 +26,8 @@ class Event {
26
26
  */
27
27
  constructor(param) {
28
28
  const { name, requiresFeedback = false, so } = param;
29
- if (!name)
30
- throw new Error("Event name is required");
31
- if (!so)
32
- throw new Error("Scripting object is required");
29
+ if (!name) throw new Error("Event name is required");
30
+ if (!so) throw new Error("Scripting object is required");
33
31
  this.scriptingObject = so;
34
32
  this.objectId = so.id;
35
33
  this.name = name;
@@ -43,10 +43,8 @@ class Remoting {
43
43
  * @param correlationId unique id for the current session
44
44
  */
45
45
  constructor(logger, correlationId) {
46
- if (!logger)
47
- throw new Error("logger is required");
48
- if (!correlationId)
49
- throw new Error("correlationId is required");
46
+ if (!logger) throw new Error("logger is required");
47
+ if (!correlationId) throw new Error("correlationId is required");
50
48
  this.#correlationId = correlationId;
51
49
  this.#logger = logger;
52
50
  }
@@ -145,8 +143,7 @@ class Remoting {
145
143
  }) => {
146
144
  this.#logger.debug(`Received message of type "${message.type}"`);
147
145
  const callbacks = this.#listeners.get(message.type);
148
- if (!callbacks)
149
- return false;
146
+ if (!callbacks) return false;
150
147
  callbacks.forEach((callback) => {
151
148
  this.#logger.debug(`Invoking message handler ${callback.name}`);
152
149
  callback({
@@ -164,15 +161,11 @@ class Remoting {
164
161
  this.#logger.debug(
165
162
  `Remoting: Received message ${JSON.stringify(message.data)}`
166
163
  );
167
- if (this.#allowedSenders.size === 0)
168
- return false;
169
- if (!message.source)
170
- return false;
164
+ if (this.#allowedSenders.size === 0) return false;
165
+ if (!message.source) return false;
171
166
  const senderOrigin = this.#allowedSenders.get(message.source);
172
- if (!senderOrigin)
173
- return false;
174
- if (message?.data?.source !== MESSAGE_SOURCE)
175
- return false;
167
+ if (!senderOrigin) return false;
168
+ if (message?.data?.source !== MESSAGE_SOURCE) return false;
176
169
  if (message.data.type === RESPONSE_MESSAGE_TYPE)
177
170
  this.#processResponse(message.data);
178
171
  else if (message.data.type === EXCEPTION_MESSAGE_TYPE)
@@ -191,10 +184,8 @@ class Remoting {
191
184
  */
192
185
  addSender = (param) => {
193
186
  const { origin, window: window2 } = param;
194
- if (!origin)
195
- throw new Error("origin is required");
196
- if (!window2)
197
- throw new Error("window is required");
187
+ if (!origin) throw new Error("origin is required");
188
+ if (!window2) throw new Error("window is required");
198
189
  this.#allowedSenders.set(window2, origin);
199
190
  };
200
191
  /**
@@ -277,8 +268,7 @@ class Remoting {
277
268
  */
278
269
  removeSender = (param) => {
279
270
  const { window: window2 } = param;
280
- if (window2)
281
- this.#allowedSenders.delete(window2);
271
+ if (window2) this.#allowedSenders.delete(window2);
282
272
  };
283
273
  /**
284
274
  * Send a response message to a window
@@ -57,15 +57,13 @@ class ScriptingObjectManager {
57
57
  const moduleSOs = this.#guestScriptingObjects.get(guestId);
58
58
  if (moduleSOs) {
59
59
  const soInfo = moduleSOs.get(objectId);
60
- if (soInfo)
61
- this.#disposeSO(soInfo);
60
+ if (soInfo) this.#disposeSO(soInfo);
62
61
  moduleSOs.delete(objectId);
63
62
  }
64
63
  } else if (objectId) {
65
64
  this.#guestScriptingObjects.forEach((moduleSOs) => {
66
65
  const soInfo = moduleSOs.get(objectId);
67
- if (soInfo)
68
- this.#disposeSO(soInfo);
66
+ if (soInfo) this.#disposeSO(soInfo);
69
67
  moduleSOs.delete(objectId);
70
68
  });
71
69
  }
@@ -137,10 +135,8 @@ class ScriptingObjectManager {
137
135
  }
138
136
  soInfo = soInfo ?? this.#scriptingObjects.get(id);
139
137
  const { so } = soInfo || {};
140
- if (!so)
141
- return null;
142
- if (!guest)
143
- return so;
138
+ if (!so) return null;
139
+ if (!guest) return so;
144
140
  const guestSO = this.#attachCallContext({ so, guest });
145
141
  Object.defineProperty(guestSO, "target", {
146
142
  value: so,
@@ -162,8 +158,7 @@ class ScriptingObjectManager {
162
158
  } else {
163
159
  this.#removeGuestScriptingObject({ objectId: id });
164
160
  const soInfo = this.#scriptingObjects.get(id);
165
- if (soInfo)
166
- this.#disposeSO(soInfo);
161
+ if (soInfo) this.#disposeSO(soInfo);
167
162
  this.#scriptingObjects.delete(id);
168
163
  }
169
164
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/microfe-common",
3
- "version": "2.5.3",
3
+ "version": "2.6.0",
4
4
  "description": "common micro frontend functional modules",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,17 +29,16 @@
29
29
  "jestSonar": {
30
30
  "reportPath": "reports",
31
31
  "reportFile": "tests.xml",
32
- "indent": 4,
33
- "sonar56x": true
32
+ "indent": 4
34
33
  },
35
34
  "peerDependencies": {
36
- "@elliemae/pui-diagnostics": "~3.4.1",
35
+ "@elliemae/pui-diagnostics": "~3.5.1",
37
36
  "uuid": "~9.0.1"
38
37
  },
39
38
  "devDependencies": {
40
- "@elliemae/browserslist-config-elliemae-latest-browsers": "~1.8.0",
41
- "@elliemae/pui-diagnostics": "~3.4.1",
42
- "@elliemae/pui-scripting-object": "~1.32.2",
39
+ "@elliemae/browserslist-config-elliemae-latest-browsers": "~1.9.0",
40
+ "@elliemae/pui-diagnostics": "~3.5.1",
41
+ "@elliemae/pui-scripting-object": "~1.37.0",
43
42
  "@types/uuid": "~9.0.8"
44
43
  },
45
44
  "scripts": {