@powerhousedao/reactor-local 1.9.4 → 1.10.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/CHANGELOG.md CHANGED
@@ -1,11 +1,27 @@
1
- ## 1.9.4 (2024-12-10)
1
+ ## 1.10.0 (2024-12-11)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **reactor-api:** Added support for processors ([#655](https://github.com/powerhouse-inc/powerhouse/pull/655))
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - **reactor-local:** start issues ([#670](https://github.com/powerhouse-inc/powerhouse/pull/670))
10
+ - **monorepo:** remove nx cloud id ([45da8784](https://github.com/powerhouse-inc/powerhouse/commit/45da8784))
2
11
 
3
12
  ### 🧱 Updated Dependencies
4
13
 
5
- - Updated @powerhousedao/general-document-indexer to 1.7.4
6
- - Updated document-model-libs to 1.120.3
7
- - Updated document-drive to 1.8.4
8
- - Updated @powerhousedao/reactor-api to 1.9.4
14
+ - Updated document-model-libs to 1.121.0
15
+ - Updated document-drive to 1.9.0
16
+ - Updated document-model to 2.11.0
17
+ - Updated @powerhousedao/reactor-api to 1.10.0
18
+ - Updated @powerhousedao/scalars to 1.13.0
19
+
20
+ ### ❤️ Thank You
21
+
22
+ - acaldas
23
+ - frankp.eth @froid1911
24
+ - ryanwolhuter @ryanwolhuter
9
25
 
10
26
  ## 1.1.0 (2024-10-29)
11
27
 
@@ -1,7 +1,4 @@
1
- import { require_main, createServer } from './chunk-ULLZUAKM.js';
2
- import { init_esm_shims, __toESM } from './chunk-GFYRWMMU.js';
3
- import { PGlite } from '@electric-sql/pglite';
4
- import { startAPI } from '@powerhousedao/reactor-api';
1
+ import { startAPI, isProcessorClass } from '@powerhousedao/reactor-api';
5
2
  import * as DocumentDrive from 'document-model-libs/document-drive';
6
3
  import { isFileNode, utils as utils$1, actions, documentModel } from 'document-model-libs/document-drive';
7
4
  import { utils } from 'document-model/document';
@@ -20,18 +17,11 @@ import { module } from 'document-model/document-model';
20
17
  import dotenv from 'dotenv';
21
18
  import path2 from 'node:path';
22
19
  import { fileURLToPath } from 'node:url';
20
+ import { createServer } from 'vite';
23
21
 
24
22
  // src/server.ts
25
- init_esm_shims();
26
-
27
- // ../document-drive/src/index.ts
28
- init_esm_shims();
29
-
30
- // ../document-drive/src/server/index.ts
31
- init_esm_shims();
32
23
 
33
24
  // ../document-drive/src/cache/memory.ts
34
- init_esm_shims();
35
25
  var InMemoryCache = class {
36
26
  cache = /* @__PURE__ */ new Map();
37
27
  async setDocument(drive, id, document) {
@@ -59,14 +49,7 @@ var InMemoryCache = class {
59
49
  };
60
50
  var memory_default = InMemoryCache;
61
51
 
62
- // ../document-drive/src/queue/base.ts
63
- init_esm_shims();
64
-
65
- // ../document-drive/src/utils/index.ts
66
- init_esm_shims();
67
-
68
52
  // ../document-drive/src/server/error.ts
69
- init_esm_shims();
70
53
  var DocumentModelNotFoundError = class extends Error {
71
54
  constructor(id, cause) {
72
55
  super(`Document model "${id}" not found`, { cause });
@@ -115,7 +98,6 @@ var SynchronizationUnitNotFoundError = class extends Error {
115
98
  };
116
99
 
117
100
  // ../document-drive/src/utils/run-asap.ts
118
- init_esm_shims();
119
101
  var RunAsap;
120
102
  ((RunAsap2) => {
121
103
  RunAsap2.useMessageChannel = (() => {
@@ -278,7 +260,6 @@ function isBefore(dateA, dateB) {
278
260
  }
279
261
 
280
262
  // ../document-drive/src/utils/logger.ts
281
- init_esm_shims();
282
263
  var Logger = class {
283
264
  #logger = console;
284
265
  set logger(logger2) {
@@ -307,7 +288,6 @@ var loggerInstance = new Logger();
307
288
  var logger = loggerInstance;
308
289
 
309
290
  // ../document-drive/src/queue/types.ts
310
- init_esm_shims();
311
291
  function isOperationJob(job) {
312
292
  return "operations" in job;
313
293
  }
@@ -544,15 +524,6 @@ var BaseQueueManager = class {
544
524
  return `queue:${driveId}${documentId ? `:${documentId}` : ""}`;
545
525
  }
546
526
  };
547
-
548
- // ../document-drive/src/read-mode/index.ts
549
- init_esm_shims();
550
-
551
- // ../document-drive/src/read-mode/service.ts
552
- init_esm_shims();
553
-
554
- // ../document-drive/src/utils/graphql.ts
555
- init_esm_shims();
556
527
  async function requestGraphql(...args) {
557
528
  const [url, ...requestArgs] = args;
558
529
  const client = new GraphQLClient(url, { fetch });
@@ -725,7 +696,6 @@ async function fetchDocument(url, documentId, documentModelLib) {
725
696
  }
726
697
 
727
698
  // ../document-drive/src/read-mode/errors.ts
728
- init_esm_shims();
729
699
  var ReadDriveError = class extends Error {
730
700
  };
731
701
  var ReadDriveNotFoundError = class extends ReadDriveError {
@@ -868,9 +838,6 @@ var ReadModeService = class {
868
838
  }
869
839
  };
870
840
 
871
- // ../document-drive/src/read-mode/types.ts
872
- init_esm_shims();
873
-
874
841
  // ../document-drive/src/read-mode/index.ts
875
842
  function ReadModeServer(Base) {
876
843
  return class ReadMode extends Base {
@@ -951,7 +918,6 @@ function ReadModeServer(Base) {
951
918
  }
952
919
 
953
920
  // ../document-drive/src/storage/memory.ts
954
- init_esm_shims();
955
921
  var MemoryStorage = class {
956
922
  documents;
957
923
  drives;
@@ -1100,7 +1066,6 @@ var MemoryStorage = class {
1100
1066
  };
1101
1067
 
1102
1068
  // ../document-drive/src/utils/default-drives-manager.ts
1103
- init_esm_shims();
1104
1069
  function isReadModeDriveServer(obj) {
1105
1070
  return typeof obj.getReadDrives === "function";
1106
1071
  }
@@ -1329,9 +1294,6 @@ var DefaultDrivesManager = class {
1329
1294
  }
1330
1295
  }
1331
1296
  };
1332
-
1333
- // ../document-drive/src/utils/document-helpers.ts
1334
- init_esm_shims();
1335
1297
  var {
1336
1298
  attachBranch,
1337
1299
  garbageCollect,
@@ -1352,11 +1314,7 @@ var {
1352
1314
  IntegrityIssueType
1353
1315
  } = utils.documentHelpers;
1354
1316
 
1355
- // ../document-drive/src/server/listener/manager.ts
1356
- init_esm_shims();
1357
-
1358
1317
  // ../document-drive/src/server/types.ts
1359
- init_esm_shims();
1360
1318
  var AbstractDocumentDriveServer = class {
1361
1319
  };
1362
1320
  var DefaultListenerManagerOptions = {
@@ -1374,36 +1332,6 @@ var BaseListenerManager = class {
1374
1332
  }
1375
1333
  };
1376
1334
 
1377
- // ../document-drive/src/server/listener/transmitter/index.ts
1378
- init_esm_shims();
1379
-
1380
- // ../document-drive/src/server/listener/transmitter/internal.ts
1381
- init_esm_shims();
1382
-
1383
- // ../document-drive/src/server/utils.ts
1384
- init_esm_shims();
1385
- function buildRevisionsFilter(strands, driveId, documentId) {
1386
- return strands.reduce((acc, s) => {
1387
- if (!(s.driveId === driveId && s.documentId === documentId)) {
1388
- return acc;
1389
- }
1390
- acc[s.scope] = s.operations[s.operations.length - 1]?.index ?? -1;
1391
- return acc;
1392
- }, {});
1393
- }
1394
- function filterOperationsByRevision(operations, revisions) {
1395
- if (!revisions) {
1396
- return operations;
1397
- }
1398
- return Object.keys(operations).reduce((acc, scope) => {
1399
- const revision = revisions[scope];
1400
- if (revision !== void 0) {
1401
- acc[scope] = operations[scope].filter((op) => op.index <= revision);
1402
- }
1403
- return acc;
1404
- }, operations);
1405
- }
1406
-
1407
1335
  // ../document-drive/src/server/listener/transmitter/internal.ts
1408
1336
  var InternalTransmitter = class {
1409
1337
  drive;
@@ -1413,45 +1341,67 @@ var InternalTransmitter = class {
1413
1341
  this.listener = listener;
1414
1342
  this.drive = drive;
1415
1343
  }
1416
- async transmit(strands) {
1344
+ async #buildInternalOperationUpdate(strand) {
1345
+ const operations = [];
1346
+ const stateByIndex = /* @__PURE__ */ new Map();
1347
+ const getStateByIndex = async (index) => {
1348
+ const state = stateByIndex.get(index);
1349
+ if (state) {
1350
+ return state;
1351
+ }
1352
+ const document = await this.drive.getDocument(
1353
+ strand.driveId,
1354
+ strand.documentId,
1355
+ {
1356
+ revisions: {
1357
+ [strand.scope]: index
1358
+ },
1359
+ checkHashes: false
1360
+ }
1361
+ );
1362
+ if (index < 0) {
1363
+ stateByIndex.set(index, document.initialState.state[strand.scope]);
1364
+ } else {
1365
+ stateByIndex.set(index, document.state[strand.scope]);
1366
+ }
1367
+ return stateByIndex.get(index);
1368
+ };
1369
+ for (const operation of strand.operations) {
1370
+ operations.push({
1371
+ ...operation,
1372
+ state: await getStateByIndex(operation.index),
1373
+ previousState: await getStateByIndex(operation.index - 1)
1374
+ });
1375
+ }
1376
+ return operations;
1377
+ }
1378
+ async transmit(strands, _source) {
1417
1379
  if (!this.receiver) {
1418
1380
  return [];
1419
1381
  }
1420
- const retrievedDocuments = /* @__PURE__ */ new Map();
1421
1382
  const updates = [];
1422
1383
  for (const strand of strands) {
1423
- let document = retrievedDocuments.get(
1424
- `${strand.driveId}:${strand.documentId}`
1425
- );
1426
- if (!document) {
1427
- const revisions = buildRevisionsFilter(
1428
- strands,
1429
- strand.driveId,
1430
- strand.documentId
1431
- );
1432
- document = await (strand.documentId ? this.drive.getDocument(strand.driveId, strand.documentId, {
1433
- revisions
1434
- }) : this.drive.getDrive(strand.driveId, { revisions }));
1435
- retrievedDocuments.set(
1436
- `${strand.driveId}:${strand.documentId}`,
1437
- document
1438
- );
1439
- }
1440
- updates.push({ ...strand, state: document.state[strand.scope] });
1384
+ const operations = await this.#buildInternalOperationUpdate(strand);
1385
+ const state = operations.at(-1)?.state ?? {};
1386
+ updates.push({
1387
+ ...strand,
1388
+ operations,
1389
+ state
1390
+ });
1441
1391
  }
1442
1392
  try {
1443
- await this.receiver.transmit(updates);
1393
+ await this.receiver.onStrands(updates);
1444
1394
  return strands.map(({ operations, ...s }) => ({
1445
1395
  ...s,
1446
1396
  status: "SUCCESS",
1447
- revision: operations[operations.length - 1]?.index ?? -1
1397
+ revision: operations.at(operations.length - 1)?.index ?? -1
1448
1398
  }));
1449
1399
  } catch (error) {
1450
1400
  logger.error(error);
1451
1401
  return strands.map(({ operations, ...s }) => ({
1452
1402
  ...s,
1453
1403
  status: "ERROR",
1454
- revision: (operations[0]?.index ?? 0) - 1
1404
+ revision: (operations.at(0)?.index ?? 0) - 1
1455
1405
  }));
1456
1406
  }
1457
1407
  }
@@ -1459,12 +1409,14 @@ var InternalTransmitter = class {
1459
1409
  this.receiver = receiver;
1460
1410
  }
1461
1411
  async disconnect() {
1462
- await this.receiver?.disconnect();
1412
+ await this.receiver?.onDisconnect();
1413
+ }
1414
+ getListener() {
1415
+ return this.listener;
1463
1416
  }
1464
1417
  };
1465
1418
 
1466
1419
  // ../document-drive/src/server/listener/transmitter/pull-responder.ts
1467
- init_esm_shims();
1468
1420
  var PullResponderTransmitter = class _PullResponderTransmitter {
1469
1421
  drive;
1470
1422
  listener;
@@ -1729,9 +1681,6 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
1729
1681
  return trigger.type === "PullResponder";
1730
1682
  }
1731
1683
  };
1732
-
1733
- // ../document-drive/src/server/listener/transmitter/switchboard-push.ts
1734
- init_esm_shims();
1735
1684
  var SwitchboardPushTransmitter = class {
1736
1685
  drive;
1737
1686
  listener;
@@ -1790,9 +1739,6 @@ var SwitchboardPushTransmitter = class {
1790
1739
  }
1791
1740
  };
1792
1741
 
1793
- // ../document-drive/src/server/listener/transmitter/types.ts
1794
- init_esm_shims();
1795
-
1796
1742
  // ../document-drive/src/server/listener/manager.ts
1797
1743
  function debounce(func, delay = 250) {
1798
1744
  let timer;
@@ -1854,6 +1800,7 @@ var ListenerManager = class _ListenerManager extends BaseListenerManager {
1854
1800
  const driveTransmitters = this.transmitters[drive] || {};
1855
1801
  driveTransmitters[listener.listenerId] = transmitter;
1856
1802
  this.transmitters[drive] = driveTransmitters;
1803
+ this.triggerUpdate(true, { type: "local" });
1857
1804
  return Promise.resolve(transmitter);
1858
1805
  }
1859
1806
  async removeListener(driveId, listenerId) {
@@ -2181,8 +2128,19 @@ var ListenerManager = class _ListenerManager extends BaseListenerManager {
2181
2128
  }
2182
2129
  };
2183
2130
 
2184
- // ../document-drive/src/server/listener/index.ts
2185
- init_esm_shims();
2131
+ // ../document-drive/src/server/utils.ts
2132
+ function filterOperationsByRevision(operations, revisions) {
2133
+ if (!revisions) {
2134
+ return operations;
2135
+ }
2136
+ return Object.keys(operations).reduce((acc, scope) => {
2137
+ const revision = revisions[scope];
2138
+ if (revision !== void 0) {
2139
+ acc[scope] = operations[scope].filter((op) => op.index <= revision);
2140
+ }
2141
+ return acc;
2142
+ }, operations);
2143
+ }
2186
2144
 
2187
2145
  // ../document-drive/src/server/index.ts
2188
2146
  var PULL_DRIVE_INTERVAL = 5e3;
@@ -3742,15 +3700,6 @@ var BaseDocumentDriveServer = class extends AbstractDocumentDriveServer {
3742
3700
  }
3743
3701
  };
3744
3702
  var DocumentDriveServer = ReadModeServer(BaseDocumentDriveServer);
3745
-
3746
- // ../document-drive/src/storage/index.ts
3747
- init_esm_shims();
3748
-
3749
- // ../document-drive/src/storage/base.ts
3750
- init_esm_shims();
3751
-
3752
- // ../document-drive/src/storage/filesystem.ts
3753
- init_esm_shims();
3754
3703
  function ensureDir(dir) {
3755
3704
  if (!existsSync(dir)) {
3756
3705
  mkdirSync(dir, { recursive: true });
@@ -3947,12 +3896,6 @@ var FilesystemStorage = class _FilesystemStorage {
3947
3896
  }, []);
3948
3897
  }
3949
3898
  };
3950
-
3951
- // ../../node_modules/.pnpm/vite@6.0.2_@types+node@22.10.1_jiti@2.4.0_lightningcss@1.28.2_terser@5.36.0_tsx@4.19.2_yaml@2.6.1/node_modules/vite/dist/node/index.js
3952
- init_esm_shims();
3953
- __toESM(require_main(), 1);
3954
-
3955
- // src/server.ts
3956
3899
  var dirname = import.meta.dirname || path2.dirname(fileURLToPath(import.meta.url));
3957
3900
  dotenv.config();
3958
3901
  var DefaultStartServerOptions = {
@@ -4006,42 +3949,17 @@ var startServer = async (options) => {
4006
3949
  }
4007
3950
  }
4008
3951
  try {
4009
- const client = new PGlite(options?.dbPath ?? process.cwd() + "/dev.db");
4010
- const { app, reactorRouterManager } = await startAPI(driveServer, {
3952
+ const api = await startAPI(driveServer, {
4011
3953
  port: serverPort,
4012
- client
3954
+ dbConnection: options?.dbPath ?? process.cwd() + "/dev.db"
4013
3955
  });
4014
3956
  driveUrl = `http://localhost:${serverPort}/${driveId ? `d/${drive.global.slug ?? drive.global.id}` : ""}`;
4015
3957
  console.log(` \u279C Reactor: ${driveUrl}`);
4016
3958
  if (dev) {
4017
- const vite = await createServer({
4018
- server: { middlewareMode: true },
4019
- appType: "custom",
4020
- build: {
4021
- rollupOptions: {
4022
- input: []
4023
- }
4024
- }
4025
- });
4026
- app.use(vite.middlewares);
4027
- const documentModelsPath = path2.join(process.cwd(), "./document-models");
4028
- console.log("Loading document models from", documentModelsPath);
4029
- const localDMs = await vite.ssrLoadModule(documentModelsPath);
4030
- driveServer.setDocumentModels([
4031
- ...baseDocumentModels,
4032
- ...Object.values(localDMs)
4033
- ]);
4034
- const processorsPath = path2.join(process.cwd(), "./processors");
4035
- console.log("Loading processors from", processorsPath);
4036
- const localProcessors = await vite.ssrLoadModule(processorsPath);
4037
- for (const [name, processor] of Object.entries(localProcessors)) {
4038
- await reactorRouterManager.registerProcessor({
4039
- ...processor
4040
- });
4041
- }
3959
+ await startDevMode(api, driveServer);
4042
3960
  }
4043
3961
  } catch (e) {
4044
- console.error("App crashed", e);
3962
+ console.error("Error starting API", e);
4045
3963
  }
4046
3964
  return {
4047
3965
  driveUrl,
@@ -4051,5 +3969,39 @@ var startServer = async (options) => {
4051
3969
  addListener: (driveId2, receiver, options2) => driveServer.addInternalListener(driveId2, receiver, options2)
4052
3970
  };
4053
3971
  };
3972
+ var startDevMode = async (api, driveServer) => {
3973
+ const vite = await createServer({
3974
+ server: { middlewareMode: true, watch: null },
3975
+ appType: "custom",
3976
+ build: {
3977
+ rollupOptions: {
3978
+ input: []
3979
+ }
3980
+ }
3981
+ });
3982
+ api.app.use(vite.middlewares);
3983
+ const documentModelsPath = path2.join(process.cwd(), "./document-models");
3984
+ await loadDocumentModels(documentModelsPath, vite, driveServer);
3985
+ const processorsPath = path2.join(process.cwd(), "./processors");
3986
+ await loadProcessors(processorsPath, vite, api.processorManager);
3987
+ };
3988
+ async function loadDocumentModels(path3, vite, driveServer) {
3989
+ console.log("Loading document models from", path3);
3990
+ const localDMs = await vite.ssrLoadModule(path3);
3991
+ driveServer.setDocumentModels([
3992
+ ...baseDocumentModels,
3993
+ ...Object.values(localDMs)
3994
+ ]);
3995
+ }
3996
+ async function loadProcessors(path3, vite, processorManager) {
3997
+ console.log("Loading processors from", path3);
3998
+ const localProcessors = await vite.ssrLoadModule(path3);
3999
+ for (const [name, processor] of Object.entries(localProcessors)) {
4000
+ const ProcessorClass = processor[name];
4001
+ if (isProcessorClass(ProcessorClass)) {
4002
+ await processorManager.registerProcessor(ProcessorClass);
4003
+ }
4004
+ }
4005
+ }
4054
4006
 
4055
4007
  export { DefaultStartServerOptions, startServer };
package/dist/cli.js CHANGED
@@ -1,12 +1,7 @@
1
1
  #! /usr/bin/env node
2
- import { startServer } from './chunk-DRNIS4SG.js';
3
- import './chunk-ULLZUAKM.js';
4
- import './chunk-MSJXUT2A.js';
5
- import { init_esm_shims } from './chunk-GFYRWMMU.js';
2
+ import { startServer } from './chunk-PS645UBL.js';
6
3
  import { Command } from 'commander';
7
4
 
8
- // src/cli.ts
9
- init_esm_shims();
10
5
  var reactorLocalAction = (options) => {
11
6
  if (options.port) {
12
7
  process.env.PORT = options.port;
package/dist/index.js CHANGED
@@ -1,11 +1,7 @@
1
- import { startServer } from './chunk-DRNIS4SG.js';
2
- export { DefaultStartServerOptions, startServer } from './chunk-DRNIS4SG.js';
3
- import './chunk-ULLZUAKM.js';
4
- import './chunk-MSJXUT2A.js';
5
- import { init_esm_shims } from './chunk-GFYRWMMU.js';
1
+ import { startServer } from './chunk-PS645UBL.js';
2
+ export { DefaultStartServerOptions, startServer } from './chunk-PS645UBL.js';
6
3
 
7
4
  // src/index.ts
8
- init_esm_shims();
9
- startServer().catch((error) => {
5
+ startServer({ dev: true }).catch((error) => {
10
6
  throw error;
11
7
  });
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Trigger, PullResponderTriggerData, DocumentDriveState, DocumentDriveLocalState, ListenerFilter, ListenerCallInfo, DocumentDriveDocument, DocumentDriveAction } from 'document-model-libs/document-drive';
2
- import { Document, OperationScope, Operation, State, ActionContext, DocumentModel, Action, BaseAction, CreateChildDocumentInput, ReducerOptions, Signal } from 'document-model/document';
2
+ import { Operation, Document, OperationScope, State, ActionContext, DocumentModel, Action, BaseAction, CreateChildDocumentInput, ReducerOptions, Signal } from 'document-model/document';
3
3
  import { Unsubscribe } from 'nanoevents';
4
4
 
5
5
  type StrandUpdateSource = {
@@ -17,31 +17,6 @@ type PullResponderTrigger = Omit<Trigger, "data" | "type"> & {
17
17
  type: "PullResponder";
18
18
  };
19
19
 
20
- interface IReceiver {
21
- transmit: (strands: InternalTransmitterUpdate[]) => Promise<void>;
22
- disconnect: () => Promise<void>;
23
- }
24
- type InternalTransmitterUpdate<T extends Document = Document, S extends OperationScope = OperationScope> = {
25
- driveId: string;
26
- documentId: string;
27
- scope: S;
28
- branch: string;
29
- operations: OperationUpdate[];
30
- state: T["state"][S];
31
- };
32
- interface IInternalTransmitter extends ITransmitter {
33
- setReceiver(receiver: IReceiver): void;
34
- }
35
- declare class InternalTransmitter implements ITransmitter {
36
- private drive;
37
- private listener;
38
- private receiver;
39
- constructor(listener: Listener, drive: IBaseDocumentDriveServer);
40
- transmit(strands: InternalTransmitterUpdate[]): Promise<ListenerRevision[]>;
41
- setReceiver(receiver: IReceiver): void;
42
- disconnect(): Promise<void>;
43
- }
44
-
45
20
  declare class OperationError extends Error {
46
21
  status: ErrorStatus;
47
22
  operation: Operation | undefined;
@@ -59,6 +34,39 @@ type DriveInfo = {
59
34
  icon?: string;
60
35
  };
61
36
 
37
+ type InferDocumentOperation<D extends Document> = D extends Document<unknown, infer A> ? A : never;
38
+
39
+ interface IReceiver<T extends Document = Document, S extends OperationScope = OperationScope> {
40
+ onStrands: (strands: InternalTransmitterUpdate<T, S>[]) => Promise<void>;
41
+ onDisconnect: () => Promise<void>;
42
+ }
43
+ type InternalOperationUpdate<D extends Document = Document, S extends OperationScope = OperationScope> = Omit<Operation<InferDocumentOperation<D>>, "scope"> & {
44
+ state: D["state"][S];
45
+ previousState: D["state"][S];
46
+ };
47
+ type InternalTransmitterUpdate<D extends Document = Document, S extends OperationScope = OperationScope> = {
48
+ driveId: string;
49
+ documentId: string;
50
+ scope: S;
51
+ branch: string;
52
+ operations: InternalOperationUpdate<D, S>[];
53
+ state: D["state"][S];
54
+ };
55
+ interface IInternalTransmitter extends ITransmitter {
56
+ setReceiver(receiver: IReceiver): void;
57
+ }
58
+ declare class InternalTransmitter implements ITransmitter {
59
+ #private;
60
+ protected drive: IBaseDocumentDriveServer;
61
+ protected listener: Listener;
62
+ protected receiver: IReceiver | undefined;
63
+ constructor(listener: Listener, drive: IBaseDocumentDriveServer);
64
+ transmit(strands: StrandUpdate[], _source: StrandUpdateSource): Promise<ListenerRevision[]>;
65
+ setReceiver(receiver: IReceiver): void;
66
+ disconnect(): Promise<void>;
67
+ getListener(): Listener;
68
+ }
69
+
62
70
  type DriveInput = State<Omit<DocumentDriveState, "__typename" | "id" | "nodes"> & {
63
71
  id?: string;
64
72
  }, DocumentDriveLocalState>;
package/dist/server.js CHANGED
@@ -1,4 +1 @@
1
- export { DefaultStartServerOptions, startServer } from './chunk-DRNIS4SG.js';
2
- import './chunk-ULLZUAKM.js';
3
- import './chunk-MSJXUT2A.js';
4
- import './chunk-GFYRWMMU.js';
1
+ export { DefaultStartServerOptions, startServer } from './chunk-PS645UBL.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/reactor-local",
3
3
  "type": "module",
4
- "version": "1.9.4",
4
+ "version": "1.10.0",
5
5
  "main": "dist/server.js",
6
6
  "bin": {
7
7
  "reactor-local": "dist/cli.js"
@@ -20,31 +20,30 @@
20
20
  "commander": "^12.1.0",
21
21
  "dotenv": "^16.4.5",
22
22
  "express": "^4.21.0",
23
- "graphql": "^16.8.1",
23
+ "graphql": "^16.9.0",
24
24
  "graphql-request": "^6.1.0",
25
25
  "json-stringify-deterministic": "^1.0.12",
26
26
  "ms": "^2.1.3",
27
27
  "nanoevents": "^9.0.0",
28
28
  "sanitize-filename": "^1.6.3",
29
29
  "uuid": "^11.0.2",
30
- "@powerhousedao/general-document-indexer": "1.7.4",
31
- "@powerhousedao/reactor-api": "1.9.4",
32
- "@powerhousedao/scalars": "1.12.0",
33
- "document-model": "2.10.0",
34
- "document-model-libs": "1.120.3"
30
+ "@powerhousedao/reactor-api": "1.10.0",
31
+ "document-model": "2.11.0",
32
+ "@powerhousedao/scalars": "1.13.0",
33
+ "document-model-libs": "1.121.0"
35
34
  },
36
35
  "devDependencies": {
36
+ "@powerhousedao/analytics-engine-graphql": "^0.2.0",
37
37
  "@types/body-parser": "^1.19.5",
38
38
  "@types/cors": "^2.8.17",
39
39
  "@types/express": "^5.0.0",
40
40
  "@types/ms": "^0.7.34",
41
41
  "@types/node": "^22.7.5",
42
42
  "tsup": "^8.3.5",
43
- "document-drive": "1.8.4"
43
+ "document-drive": "1.9.0"
44
44
  },
45
45
  "scripts": {
46
46
  "start": "vite-node src/index.ts",
47
- "build": "tsup",
48
- "prestart": "pnpm db:migrate"
47
+ "build": "tsup"
49
48
  }
50
49
  }
package/src/index.ts CHANGED
@@ -2,6 +2,6 @@ import { startServer } from "./server.js";
2
2
 
3
3
  export * from "./server.js";
4
4
 
5
- startServer().catch((error: unknown) => {
5
+ startServer({ dev: true }).catch((error: unknown) => {
6
6
  throw error;
7
7
  });