@jay-framework/secure 0.22.2 → 0.24.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _jay_framework_runtime from '@jay-framework/runtime';
2
- import { Coordinate, JayEventHandler, JayNativeFunction, JayElement, PreRenderElement, BaseJayElement, JayComponent, JayComponentConstructor, PrivateRef, HTMLElementCollectionProxy, HTMLElementProxy, ComponentCollectionProxy, updateFunc, MountFunc, BaseReferencesManager, JayEventHandlerWrapper, ManagedRefType, ManagedRefs, PrivateRefConstructor, HTMLElementProxyTarget, HTMLElementCollectionProxyTarget, GlobalJayEvents } from '@jay-framework/runtime';
2
+ import { Coordinate, JayEventHandler, JayNativeFunction, JayElement, PreRenderElement, BaseJayElement, JayComponent, JayComponentConstructor, PrivateRef, HTMLElementCollectionProxy, HTMLElementProxy, ComponentCollectionProxy, updateFunc, MountFunc, HTMLElementProxyTarget, HTMLElementCollectionProxyTarget, ManagedRefs, JayEventHandlerWrapper, BaseReferencesManager, ManagedRefType, PrivateRefConstructor, GlobalJayEvents } from '@jay-framework/runtime';
3
3
  import { JSONPatch, ArrayContexts } from '@jay-framework/json-patch';
4
4
  import * as _jay_framework_component from '@jay-framework/component';
5
5
  import { JayComponentCore } from '@jay-framework/component';
package/dist/index.js CHANGED
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { createJayContext, currentConstructionContext, withContext, childComp, useContext, GetTrapProxy, EVENT_TRAP, BaseReferencesManager, ManagedRefType, ComponentCollectionRefImpl, ComponentRefsImpl, normalizeUpdates, saveContext, restoreContext } from "@jay-framework/runtime";
8
5
  import { makeJayComponent, createSignal, useReactive, COMPONENT_CONTEXT } from "@jay-framework/component";
9
6
  import { deserialize, serialize } from "@jay-framework/serialization";
@@ -50,8 +47,7 @@ class JayPort {
50
47
  }
51
48
  getEndpoint(parentCompId, parentCoordinate) {
52
49
  let compId = this.getCompId(parentCompId, parentCoordinate);
53
- if (this.endpoints.has(compId))
54
- return this.endpoints.get(compId);
50
+ if (this.endpoints.has(compId)) return this.endpoints.get(compId);
55
51
  let ep = new JayEndpoint(compId, this);
56
52
  this.endpoints.set(compId, ep);
57
53
  ep.setInitMessages(this.futureEndpointMessages.get(compId) || []);
@@ -62,21 +58,17 @@ class JayPort {
62
58
  return this.getEndpoint(-1, [""]);
63
59
  }
64
60
  post(compId, outMessage) {
65
- if (this.logger)
66
- this.logger.logPost(compId, outMessage);
61
+ if (this.logger) this.logger.logPost(compId, outMessage);
67
62
  this.messages.push([compId, outMessage]);
68
- if (!this.inBatch)
69
- this.scheduleFlush();
63
+ if (!this.inBatch) this.scheduleFlush();
70
64
  }
71
65
  batch(handler) {
72
- if (this.inBatch)
73
- return handler();
66
+ if (this.inBatch) return handler();
74
67
  this.inBatch = true;
75
68
  try {
76
69
  return handler();
77
70
  } finally {
78
- if (this.messages.length > 0)
79
- this.flush();
71
+ if (this.messages.length > 0) this.flush();
80
72
  this.inBatch = false;
81
73
  }
82
74
  }
@@ -88,15 +80,12 @@ class JayPort {
88
80
  this.batch(() => {
89
81
  messages.forEach(([compId, message]) => {
90
82
  let endpoint = this.endpoints.get(compId);
91
- if (this.logger)
92
- this.logger.logInvoke(compId, message, !!endpoint);
93
- if (endpoint)
94
- endpoint.invoke(message);
83
+ if (this.logger) this.logger.logInvoke(compId, message, !!endpoint);
84
+ if (endpoint) endpoint.invoke(message);
95
85
  else {
96
86
  if (!this.futureEndpointMessages.has(compId))
97
87
  this.futureEndpointMessages.set(compId, [message]);
98
- else
99
- this.futureEndpointMessages.get(compId).push(message);
88
+ else this.futureEndpointMessages.get(compId).push(message);
100
89
  }
101
90
  });
102
91
  });
@@ -160,16 +149,14 @@ class HandshakeMessageJayChannel {
160
149
  __publicField(this, "workerOnMessage", (ev) => {
161
150
  if (ev.data === SYN || ev.data === ACK) {
162
151
  if (!this.handshakeComplete) {
163
- if (ev.data === SYN)
164
- this.worker.postMessage(ACK);
152
+ if (ev.data === SYN) this.worker.postMessage(ACK);
165
153
  this.handshakeComplete = true;
166
154
  this.pendingMessages.forEach((message) => this.worker.postMessage(message));
167
155
  this.pendingMessages = [];
168
156
  }
169
157
  } else {
170
158
  let { messages, newCompIdMessages } = ev.data;
171
- if (this.handler)
172
- this.handler(messages, newCompIdMessages);
159
+ if (this.handler) this.handler(messages, newCompIdMessages);
173
160
  }
174
161
  });
175
162
  worker.addEventListener("message", this.workerOnMessage);
@@ -180,10 +167,8 @@ class HandshakeMessageJayChannel {
180
167
  this.handler = handler;
181
168
  }
182
169
  postMessages(messages, newCompIdMessages) {
183
- if (!this.handshakeComplete)
184
- this.pendingMessages.push({ messages, newCompIdMessages });
185
- else
186
- this.worker.postMessage({ messages, newCompIdMessages });
170
+ if (!this.handshakeComplete) this.pendingMessages.push({ messages, newCompIdMessages });
171
+ else this.worker.postMessage({ messages, newCompIdMessages });
187
172
  }
188
173
  }
189
174
  const SECURE_COMPONENT_MARKER = createJayContext("secm");
@@ -328,10 +313,8 @@ function makeComponentBridgeConstructor(props, refs) {
328
313
  case JayPortMessageType.rootApiReturns:
329
314
  let { callId, error, returns } = message;
330
315
  if (ongoingAPICalls[callId]) {
331
- if (error)
332
- ongoingAPICalls[callId][1](error);
333
- else
334
- ongoingAPICalls[callId][0](returns);
316
+ if (error) ongoingAPICalls[callId][1](error);
317
+ else ongoingAPICalls[callId][0](returns);
335
318
  delete ongoingAPICalls[callId];
336
319
  }
337
320
  break;
@@ -489,10 +472,8 @@ function correlatedPromise() {
489
472
  return corrPromise;
490
473
  }
491
474
  function completeCorrelatedPromise(message) {
492
- if (message.error)
493
- promises$.get(message.correlationId)?.reject(message.error);
494
- else
495
- promises$.get(message.correlationId)?.resolve(message.result);
475
+ if (message.error) promises$.get(message.correlationId)?.reject(message.error);
476
+ else promises$.get(message.correlationId)?.resolve(message.result);
496
477
  promises$.delete(message.correlationId);
497
478
  }
498
479
  const SANDBOX_BRIDGE_CONTEXT = createJayContext("sbc");
@@ -675,8 +656,7 @@ class SecureHTMLElementCollectionRefsImpl extends SecurePrivateRefs {
675
656
  let promises = [];
676
657
  for (const [, item] of this.items) {
677
658
  const handlerResponse = handler(item.getPublicAPI(), item.viewState, item.coordinate);
678
- if (handlerResponse)
679
- promises.push(handlerResponse);
659
+ if (handlerResponse) promises.push(handlerResponse);
680
660
  }
681
661
  return promises;
682
662
  }
@@ -688,8 +668,7 @@ const SECURE_EVENT$_TRAP = (target, prop) => {
688
668
  return (func$2) => {
689
669
  let regularHandler;
690
670
  const handler = ({ event, viewState, coordinate }) => {
691
- if (regularHandler)
692
- regularHandler({ event, viewState, coordinate });
671
+ if (regularHandler) regularHandler({ event, viewState, coordinate });
693
672
  };
694
673
  target.addEventListener(eventName, handler, void 0, func$2.id);
695
674
  return {
@@ -723,8 +702,7 @@ function mkBridgeElement(viewState, sandboxElements, endpoint, reactive, refMana
723
702
  let patch, nextSerialize = serialize;
724
703
  let postUpdateMessage = (newViewState) => {
725
704
  [patch, nextSerialize] = nextSerialize(newViewState, arraySerializationContext);
726
- if (patch.length)
727
- endpoint.post(renderMessage(patch));
705
+ if (patch.length) endpoint.post(renderMessage(patch));
728
706
  };
729
707
  let update = normalizeUpdates([postUpdateMessage, ...elements.map((el) => el.update)]);
730
708
  update(viewState);
@@ -845,17 +823,14 @@ function compareLists(oldList, newList, matchBy) {
845
823
  let newListIds = new Set(newList.map((item) => item[matchBy]));
846
824
  let oldListIdsMap = new Map(oldList.map((item) => [item[matchBy], item]));
847
825
  oldList.forEach((oldItem) => {
848
- if (!newListIds.has(oldItem[matchBy]))
849
- removedItems.push(oldItem);
826
+ if (!newListIds.has(oldItem[matchBy])) removedItems.push(oldItem);
850
827
  });
851
828
  newList.forEach((newItem) => {
852
- if (!oldListIdsMap.has(newItem[matchBy]))
853
- addedItems.push(newItem);
829
+ if (!oldListIdsMap.has(newItem[matchBy])) addedItems.push(newItem);
854
830
  else {
855
831
  let oldItem = oldListIdsMap.get(newItem[matchBy]);
856
832
  let isModified = newItem !== oldItem;
857
- if (isModified)
858
- itemsToUpdate.push(newItem);
833
+ if (isModified) itemsToUpdate.push(newItem);
859
834
  }
860
835
  });
861
836
  return { removedItems, addedItems, itemsToUpdate };
@@ -932,8 +907,7 @@ function sandboxCondition(condition, children) {
932
907
  childMounted = newState;
933
908
  }
934
909
  } else {
935
- if (childMounted)
936
- children.forEach((_) => _.unmount());
910
+ if (childMounted) children.forEach((_) => _.unmount());
937
911
  childMounted = false;
938
912
  }
939
913
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/secure",
3
- "version": "0.22.2",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -36,14 +36,14 @@
36
36
  "runtime:top-level-collection-conditions": "jay-cli runtime test/top-level-collection-conditions/regular"
37
37
  },
38
38
  "dependencies": {
39
- "@jay-framework/component": "^0.22.2",
40
- "@jay-framework/json-patch": "^0.22.2",
41
- "@jay-framework/reactive": "^0.22.2",
42
- "@jay-framework/runtime": "^0.22.2",
43
- "@jay-framework/serialization": "^0.22.2"
39
+ "@jay-framework/component": "^0.24.0",
40
+ "@jay-framework/json-patch": "^0.24.0",
41
+ "@jay-framework/reactive": "^0.24.0",
42
+ "@jay-framework/runtime": "^0.24.0",
43
+ "@jay-framework/serialization": "^0.24.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@jay-framework/dev-environment": "^0.22.2",
46
+ "@jay-framework/dev-environment": "^0.24.0",
47
47
  "@testing-library/jest-dom": "^6.2.0",
48
48
  "@types/node": "^20.11.5",
49
49
  "caniuse-lite": "^1.0.30001579",