@arcote.tech/arc 0.0.20 → 0.0.21

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.js CHANGED
@@ -693,7 +693,6 @@ class ForkedDataStorage extends DataStorage {
693
693
  store: store.storeName,
694
694
  changes: store.changes
695
695
  }));
696
- console.log(changes);
697
696
  await this.master.commitChanges(changes);
698
697
  }
699
698
  }
@@ -736,7 +735,6 @@ class MasterStoreState extends StoreState {
736
735
  if (change.type === "modify") {
737
736
  const existing = await transaction.findById(this.storeName, change.id);
738
737
  const updated = existing ? deepMerge(existing, change.data) : { _id: change.id, ...change.data };
739
- console.log("updated", updated);
740
738
  await transaction.set(this.storeName, updated);
741
739
  const item = this.deserialize ? this.deserialize(updated) : updated;
742
740
  this.items.set(change.id, item);
@@ -1209,14 +1207,16 @@ class ArcStringEnum extends ArcAbstract {
1209
1207
  // rtc/client.ts
1210
1208
  class RTCClient {
1211
1209
  storage;
1210
+ token;
1212
1211
  _socket;
1213
1212
  openSocket;
1214
1213
  reconnectAttempts = 0;
1215
1214
  maxReconnectAttempts = 5;
1216
1215
  syncProgressCallback;
1217
1216
  syncPromise = null;
1218
- constructor(storage) {
1217
+ constructor(storage, token) {
1219
1218
  this.storage = storage;
1219
+ this.token = token;
1220
1220
  }
1221
1221
  async sync(progressCallback) {
1222
1222
  if (this.syncPromise)
@@ -1231,7 +1231,8 @@ class RTCClient {
1231
1231
  const response = await fetch(`/ws/sync?lastSync=${arcState?.lastSyncDate || ""}`, {
1232
1232
  method: "GET",
1233
1233
  headers: {
1234
- "Content-Type": "application/json"
1234
+ "Content-Type": "application/json",
1235
+ Authorization: `Bearer ${this.token}`
1235
1236
  }
1236
1237
  });
1237
1238
  if (!response.ok) {
@@ -1270,7 +1271,7 @@ class RTCClient {
1270
1271
  ]);
1271
1272
  }
1272
1273
  async connectWebSocket() {
1273
- this._socket = new WebSocket(`wss://${window.location.host}/ws`);
1274
+ this._socket = new WebSocket(`wss://${window.location.host}/ws?token=${this.token}`);
1274
1275
  this.openSocket = new Promise((resolve) => {
1275
1276
  this._socket.addEventListener("open", () => {
1276
1277
  this.reconnectAttempts = 0;
@@ -1317,8 +1318,8 @@ class RTCClient {
1317
1318
  socket.send(JSON.stringify(message));
1318
1319
  }
1319
1320
  }
1320
- var rtcClientFactory = (storage) => {
1321
- return new RTCClient(storage);
1321
+ var rtcClientFactory = (token) => (storage) => {
1322
+ return new RTCClient(storage, token);
1322
1323
  };
1323
1324
  // state/query.ts
1324
1325
  class ArcStateQuery extends ArcQuery {
@@ -1,3 +1,3 @@
1
1
  import type { RealTimeCommunicationAdapterFactory } from "./rtc";
2
- export declare const rtcClientFactory: RealTimeCommunicationAdapterFactory;
2
+ export declare const rtcClientFactory: (token: string) => RealTimeCommunicationAdapterFactory;
3
3
  //# sourceMappingURL=client.d.ts.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
- "version": "0.0.20",
7
+ "version": "0.0.21",
8
8
  "private": false,
9
9
  "author": "Przemysław Krasiński [arcote.tech]",
10
10
  "description": "Arc is a framework designed to align code closely with business logic, streamlining development and enhancing productivity.",