@routier/core 0.1.0-rc.0 → 0.1.0-rc.2

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.
@@ -320,6 +320,41 @@ function forEach(expression, callback) {
320
320
  }
321
321
 
322
322
 
323
+ }),
324
+ "./src/performance/index.ts":
325
+ /*!**********************************!*\
326
+ !*** ./src/performance/index.ts ***!
327
+ \**********************************/
328
+ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
329
+ __webpack_require__.r(__webpack_exports__);
330
+ __webpack_require__.d(__webpack_exports__, {
331
+ measure: () => (measure),
332
+ now: () => (now)
333
+ });
334
+ /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utilities */ "./src/utilities/logger.ts");
335
+
336
+ const measurements = {};
337
+ const now = () => {
338
+ if (typeof performance !== 'undefined' && performance.now) {
339
+ // Browser or modern Node.js
340
+ return performance.now();
341
+ }
342
+ // Fallback for older environments
343
+ return Date.now();
344
+ };
345
+ const measure = {
346
+ start: (name) => {
347
+ measurements[name] = now();
348
+ },
349
+ end: (name) => {
350
+ const start = measurements[name];
351
+ delete measurements[name];
352
+ const delta = now() - start;
353
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
354
+ }
355
+ };
356
+
357
+
323
358
  }),
324
359
  "./src/pipeline/TrampolinePipeline.ts":
325
360
  /*!********************************************!*\
@@ -328,11 +363,12 @@ function forEach(expression, callback) {
328
363
  (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
329
364
  __webpack_require__.r(__webpack_exports__);
330
365
  __webpack_require__.d(__webpack_exports__, {
331
- AsyncPipeline: () => (AsyncPipeline),
332
366
  TrampolinePipeline: () => (TrampolinePipeline),
333
367
  WorkPipeline: () => (WorkPipeline)
334
368
  });
335
- /* ESM import */var _results__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../results */ "./src/results/Result.ts");
369
+ /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utilities */ "./src/utilities/logger.ts");
370
+ /* ESM import */var _results__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../results */ "./src/results/Result.ts");
371
+
336
372
 
337
373
  class TrampolinePipeline {
338
374
  _list = [];
@@ -370,7 +406,7 @@ class TrampolinePipeline {
370
406
  processor(currentData, (result, error) => {
371
407
  // --- Error Handling ---
372
408
  if (error) {
373
- console.error(`Error reported by processor at index ${idx}:`, error);
409
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error reported by processor at index ${idx}:`, error);
374
410
  this._hasErrored = true; // Set flag
375
411
  // Throw the error to be caught by outer try...catch blocks
376
412
  throw error;
@@ -393,7 +429,7 @@ class TrampolinePipeline {
393
429
  }
394
430
  catch (error) {
395
431
  if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
396
- console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
432
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
397
433
  this._hasErrored = true;
398
434
  }
399
435
  // Rethrow to be caught by the trampoline's catch block
@@ -428,7 +464,7 @@ class TrampolinePipeline {
428
464
  catch (trampolineError) {
429
465
  // Catch errors propagated from step execution (processor or callback errors)
430
466
  if (!this._hasErrored) { // Avoid double logging
431
- console.error("Error during trampoline step execution:", trampolineError);
467
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error("Error during trampoline step execution:", trampolineError);
432
468
  this._hasErrored = true;
433
469
  }
434
470
  currentStep = null; // Stop the loop
@@ -457,135 +493,11 @@ class TrampolinePipeline {
457
493
  pipeEach(items, fn, map) {
458
494
  for (let i = 0, length = items.length; i < length; i++) {
459
495
  this.pipe((previous, done) => {
460
- fn(map(previous, _results__WEBPACK_IMPORTED_MODULE_0__.Result.success(items[i])), done);
496
+ fn(map(previous, _results__WEBPACK_IMPORTED_MODULE_1__.Result.success(items[i])), done);
461
497
  });
462
498
  }
463
499
  }
464
500
  }
465
- class AsyncPipeline {
466
- _list = [];
467
- _hasErrored = false; // Flag to prevent calling done on error
468
- filter(done) {
469
- this._hasErrored = false; // Reset error flag on new execution
470
- let currentData = [];
471
- if (this._list.length === 0) {
472
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
473
- return;
474
- }
475
- let index = 0;
476
- let isRunning = false; // Guard against overlapping trampoline calls
477
- try {
478
- // --- Revised Completion Logic --- (Moved up for clarity)
479
- const finalStepSentinel = () => {
480
- // Only call done if no error has occurred
481
- if (!this._hasErrored) {
482
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success(currentData)));
483
- }
484
- return null; // Stop the trampoline
485
- };
486
- const createStepRevised = (idx) => {
487
- return () => {
488
- if (this._hasErrored)
489
- return null; // Stop if an error occurred elsewhere
490
- if (idx >= this._list.length) {
491
- return finalStepSentinel(); // Execute the dedicated final step
492
- }
493
- const [payload, processor] = this._list[idx];
494
- // Initialize syncCallbackResult to null to satisfy StepResult type
495
- let syncCallbackResult = null;
496
- let calledSync = false;
497
- try {
498
- processor(payload, (result) => {
499
- // --- Error Handling ---
500
- if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
501
- console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
502
- this._hasErrored = true; // Set flag
503
- // Throw the error to be caught by outer try...catch blocks
504
- throw result.error;
505
- }
506
- // --- /Error Handling ---
507
- // If no error, proceed as before
508
- currentData.push(result.data);
509
- index = idx + 1; // Update index for the next step
510
- const nextStep = createStepRevised(index); // Use updated index
511
- if (isRunning) {
512
- // Callback was synchronous
513
- syncCallbackResult = nextStep; // Store next step function
514
- calledSync = true;
515
- }
516
- else {
517
- // Callback was asynchronous, restart trampoline
518
- trampoline(nextStep);
519
- }
520
- });
521
- }
522
- catch (error) {
523
- if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
524
- console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
525
- this._hasErrored = true;
526
- }
527
- // Rethrow to be caught by the trampoline's catch block
528
- throw error;
529
- }
530
- if (calledSync) {
531
- // Return the next step function for the sync loop
532
- return syncCallbackResult;
533
- }
534
- else {
535
- // Pause trampoline for async, loop will stop as step returns null
536
- return null;
537
- }
538
- };
539
- };
540
- // The trampoline loop
541
- const trampoline = (step) => {
542
- if (isRunning) {
543
- return;
544
- }
545
- isRunning = true;
546
- let currentStep = step;
547
- while (typeof currentStep === 'function') {
548
- try {
549
- // Stop immediately if an error was flagged elsewhere
550
- if (this._hasErrored) {
551
- currentStep = null;
552
- break;
553
- }
554
- currentStep = currentStep(); // Execute step, get next step or null
555
- }
556
- catch (trampolineError) {
557
- // Catch errors propagated from step execution (processor or callback errors)
558
- if (!this._hasErrored) { // Avoid double logging
559
- console.error("Error during trampoline step execution:", trampolineError);
560
- this._hasErrored = true;
561
- }
562
- currentStep = null; // Stop the loop
563
- // We don't call `done` here because an error occurred.
564
- // The application should handle the uncaught exception if desired.
565
- break; // Explicitly break loop on error
566
- }
567
- }
568
- // Loop ends when currentStep is null or loop is broken by error
569
- isRunning = false;
570
- // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
571
- };
572
- // --- Start the process ---
573
- index = 0; // Reset index
574
- trampoline(createStepRevised(0)); // Start with the revised step creator
575
- }
576
- catch (error) {
577
- done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.error(error));
578
- }
579
- }
580
- pipe(data, processor) {
581
- this._list.push([data, processor]);
582
- }
583
- pipeEach(items, processor) {
584
- for (let i = 0, length = items.length; i < length; i++) {
585
- this.pipe(items[i], processor);
586
- }
587
- }
588
- }
589
501
  /**
590
502
  * Processes functions with callbacks asynchronously.
591
503
  *
@@ -599,7 +511,7 @@ class WorkPipeline {
599
511
  filter(done) {
600
512
  this._hasErrored = false; // Reset error flag on new execution
601
513
  if (this.unitsOfWork.length === 0) {
602
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
514
+ queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_1__.Result.success()));
603
515
  return;
604
516
  }
605
517
  let index = 0;
@@ -609,7 +521,7 @@ class WorkPipeline {
609
521
  const finalStepSentinel = () => {
610
522
  // Only call done if no error has occurred
611
523
  if (!this._hasErrored) {
612
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
524
+ queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_1__.Result.success()));
613
525
  }
614
526
  return null; // Stop the trampoline
615
527
  };
@@ -627,8 +539,8 @@ class WorkPipeline {
627
539
  try {
628
540
  processor((result) => {
629
541
  // --- Error Handling ---
630
- if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
631
- console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
542
+ if (result.ok === _results__WEBPACK_IMPORTED_MODULE_1__.Result.ERROR) {
543
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
632
544
  this._hasErrored = true; // Set flag
633
545
  // Throw the error to be caught by outer try...catch blocks
634
546
  throw result.error;
@@ -650,7 +562,7 @@ class WorkPipeline {
650
562
  }
651
563
  catch (error) {
652
564
  if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
653
- console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
565
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
654
566
  this._hasErrored = true;
655
567
  }
656
568
  // Rethrow to be caught by the trampoline's catch block
@@ -685,7 +597,7 @@ class WorkPipeline {
685
597
  catch (trampolineError) {
686
598
  // Catch errors propagated from step execution (processor or callback errors)
687
599
  if (!this._hasErrored) { // Avoid double logging
688
- console.error("Error during trampoline step execution:", trampolineError);
600
+ _utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error("Error during trampoline step execution:", trampolineError);
689
601
  this._hasErrored = true;
690
602
  }
691
603
  currentStep = null; // Stop the loop
@@ -703,7 +615,7 @@ class WorkPipeline {
703
615
  trampoline(createStepRevised(0)); // Start with the revised step creator
704
616
  }
705
617
  catch (error) {
706
- done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.error(error));
618
+ done(_results__WEBPACK_IMPORTED_MODULE_1__.Result.error(error));
707
619
  }
708
620
  }
709
621
  pipe(work) {
@@ -1073,23 +985,27 @@ __webpack_require__.d(__webpack_exports__, {
1073
985
  OptimisticReplicationDbPlugin: () => (OptimisticReplicationDbPlugin)
1074
986
  });
1075
987
  /* ESM import */var _results__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../results */ "./src/results/Result.ts");
1076
- /* ESM import */var _pipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../pipeline */ "./src/pipeline/TrampolinePipeline.ts");
988
+ /* ESM import */var _pipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../pipeline */ "./src/pipeline/TrampolinePipeline.ts");
1077
989
  /* ESM import */var _query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../query */ "./src/plugins/query/Query.ts");
1078
990
  /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/uuid.ts");
1079
- /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/replication.ts");
991
+ /* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/replication.ts");
1080
992
  /* ESM import */var _collections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../collections */ "./src/collections/Changes.ts");
993
+ /* ESM import */var _performance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../performance */ "./src/performance/index.ts");
1081
994
 
1082
995
 
1083
996
  7;
1084
997
 
1085
998
 
1086
999
 
1000
+
1087
1001
  const getMemoryPluginCollectionSize = (plugin, schema) => {
1088
1002
  if ("getCollectionSize" in plugin && typeof plugin.getCollectionSize === "function") {
1089
1003
  return plugin.getCollectionSize(schema.collectionName);
1090
1004
  }
1091
1005
  throw new Error("Cannot get size of collection for MemoryPlugin, not an instance of MemoryPlugin");
1092
1006
  };
1007
+ const MAX_HYDRATION_WAIT_MS = 60_000; // 60 seconds max wait
1008
+ const HYDRATION_POLL_INTERVAL_MS = 10; // Check ever 10 ms
1093
1009
  let hydrationStatus = "hydration-not-started";
1094
1010
  class OptimisticReplicationDbPlugin {
1095
1011
  plugins;
@@ -1117,7 +1033,6 @@ class OptimisticReplicationDbPlugin {
1117
1033
  if (collectionSize === 0 && hydrationStatus === "hydration-not-started") {
1118
1034
  // Notify the cache that the db was hydrated right away
1119
1035
  hydrationStatus = "hydration-pending";
1120
- console.log('[ROUTIER] - Optimistic Query', hydrationStatus);
1121
1036
  // nothing is hydrated, let's try and hydrate before querying
1122
1037
  // Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
1123
1038
  // Other queries will do the same and hydrate if needed
@@ -1132,28 +1047,20 @@ class OptimisticReplicationDbPlugin {
1132
1047
  if (sourceResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1133
1048
  // Notify that hydration failed
1134
1049
  hydrationStatus = "hydration-error";
1135
- console.log("[ROUTIER] - Hydration Error - Source Query", sourceResult);
1136
- done(sourceResult);
1137
- return;
1138
- }
1139
- if (sourceResult == null || (Array.isArray(sourceResult.data) && sourceResult.data.length === 0)) {
1140
- // Notify that hydration had no data
1141
- hydrationStatus = "hydration-error";
1142
- console.log("[ROUTIER] - Hydration Error - No Data", sourceResult);
1143
1050
  done(sourceResult);
1144
1051
  return;
1145
1052
  }
1146
- if (Array.isArray(sourceResult.data) === false) {
1053
+ // Source plugin can have no data, still should succeed
1054
+ if (Array.isArray(sourceResult.data.value) === false) {
1147
1055
  // Notify that hydration failed
1148
1056
  hydrationStatus = "hydration-error";
1149
- console.log("[ROUTIER] - Hydration Error - Bad Result", sourceResult);
1150
1057
  done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Query result is not an array"));
1151
1058
  return;
1152
1059
  }
1153
1060
  const changesCollection = new _collections__WEBPACK_IMPORTED_MODULE_3__.BulkPersistChanges();
1154
1061
  const schemaChanges = changesCollection.resolve(event.operation.schema.id);
1155
1062
  // Add the existing items into the persist payload as adds
1156
- schemaChanges.adds = sourceResult.data;
1063
+ schemaChanges.adds = sourceResult.data.value;
1157
1064
  readPlugin.bulkPersist({
1158
1065
  id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
1159
1066
  schemas: event.schemas,
@@ -1163,7 +1070,6 @@ class OptimisticReplicationDbPlugin {
1163
1070
  if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1164
1071
  // Notify that hydration failed
1165
1072
  hydrationStatus = "hydration-error";
1166
- console.log("[ROUTIER] - Hydration Error - Could Not Save", readPersistResult);
1167
1073
  done(readPersistResult);
1168
1074
  return;
1169
1075
  }
@@ -1174,6 +1080,41 @@ class OptimisticReplicationDbPlugin {
1174
1080
  });
1175
1081
  return;
1176
1082
  }
1083
+ if (hydrationStatus === "hydration-error") {
1084
+ done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Hydration failed, unable to query read plugin"));
1085
+ return;
1086
+ }
1087
+ // If hydration is pending, do not query empty collection, wait for hydration
1088
+ if (hydrationStatus === "hydration-pending") {
1089
+ const start = (0,_performance__WEBPACK_IMPORTED_MODULE_4__.now)();
1090
+ const pollHydrationStatus = () => {
1091
+ const delta = (0,_performance__WEBPACK_IMPORTED_MODULE_4__.now)() - start;
1092
+ if (delta > MAX_HYDRATION_WAIT_MS) {
1093
+ hydrationStatus = "hydration-error";
1094
+ done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, `Hydration timeout: exceeded maximum wait time of ${MAX_HYDRATION_WAIT_MS}ms`));
1095
+ return;
1096
+ }
1097
+ if (hydrationStatus === "hydration-error") {
1098
+ done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Hydration failed, unable to query read plugin"));
1099
+ return;
1100
+ }
1101
+ if (hydrationStatus === "hydration-success") {
1102
+ // Hydration completed successfully, proceed with query
1103
+ readPlugin.query(event, (readResult) => {
1104
+ if (readResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1105
+ done(readResult);
1106
+ return;
1107
+ }
1108
+ done(readResult);
1109
+ });
1110
+ return;
1111
+ }
1112
+ // Still pending, check again after interval
1113
+ setTimeout(pollHydrationStatus, HYDRATION_POLL_INTERVAL_MS);
1114
+ };
1115
+ pollHydrationStatus();
1116
+ return;
1117
+ }
1177
1118
  // Collection is hydrated for the targeted collection and should be in sync
1178
1119
  readPlugin.query(event, (readResult) => {
1179
1120
  if (readResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
@@ -1190,7 +1131,7 @@ class OptimisticReplicationDbPlugin {
1190
1131
  }
1191
1132
  destroy(event, done) {
1192
1133
  try {
1193
- const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_4__.WorkPipeline();
1134
+ const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_5__.WorkPipeline();
1194
1135
  const plugins = [this.plugins.source, ...this.plugins.replicas];
1195
1136
  for (let i = 0, length = plugins.length; i < length; i++) {
1196
1137
  workPipeline.pipe((done) => plugins[i].destroy(event, done));
@@ -1209,7 +1150,7 @@ class OptimisticReplicationDbPlugin {
1209
1150
  }
1210
1151
  bulkPersist(event, done) {
1211
1152
  try {
1212
- const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_4__.WorkPipeline();
1153
+ const workPipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_5__.WorkPipeline();
1213
1154
  const deferredPlugins = [this.plugins.source, ...this.plugins.replicas];
1214
1155
  // Since we are doing optimistic, we insert into the read plugin first and assume later plugins will succeed
1215
1156
  // This means the read plugin will generate ids for the source plugin
@@ -1229,7 +1170,7 @@ class OptimisticReplicationDbPlugin {
1229
1170
  const optimisticBulkPersistChanges = new _collections__WEBPACK_IMPORTED_MODULE_3__.BulkPersistChanges();
1230
1171
  // make sure we swap the adds here, that way we can make sure other persist events
1231
1172
  // don't take their additions and try to change subsequent calls
1232
- (0,_utilities__WEBPACK_IMPORTED_MODULE_5__.resolveBulkPersistChanges)(event, r.data, optimisticBulkPersistChanges);
1173
+ (0,_utilities__WEBPACK_IMPORTED_MODULE_6__.resolveBulkPersistChanges)(event, r.data, optimisticBulkPersistChanges);
1233
1174
  for (let i = 0, length = deferredPlugins.length; i < length; i++) {
1234
1175
  workPipeline.pipe((d) => {
1235
1176
  const plugin = deferredPlugins[i];
@@ -1308,10 +1249,10 @@ class ReplicationDbPlugin {
1308
1249
  }
1309
1250
  destroy(event, done) {
1310
1251
  try {
1311
- const pipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_1__.AsyncPipeline();
1252
+ const pipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_1__.WorkPipeline();
1312
1253
  const plugins = [this.plugins.source, ...this.plugins.replicas];
1313
1254
  for (let i = 0, length = plugins.length; i < length; i++) {
1314
- pipeline.pipe(plugins[i], (plugin, done) => plugin.destroy(event, done));
1255
+ pipeline.pipe((done) => plugins[i].destroy(event, done));
1315
1256
  }
1316
1257
  pipeline.filter((result) => {
1317
1258
  if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
@@ -1964,6 +1905,51 @@ const isDate = (data) => {
1964
1905
  };
1965
1906
 
1966
1907
 
1908
+ }),
1909
+ "./src/utilities/logger.ts":
1910
+ /*!*********************************!*\
1911
+ !*** ./src/utilities/logger.ts ***!
1912
+ \*********************************/
1913
+ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1914
+ __webpack_require__.r(__webpack_exports__);
1915
+ __webpack_require__.d(__webpack_exports__, {
1916
+ logger: () => (logger)
1917
+ });
1918
+ const isDevelopment = () => {
1919
+ if (typeof process === 'undefined' || process.env == null) {
1920
+ return false;
1921
+ }
1922
+ const env = "development"?.toLowerCase();
1923
+ return env === 'dev' || env === 'development' || env === 'test';
1924
+ };
1925
+ const shouldLog = isDevelopment();
1926
+ const tryLog = (type, ...args) => {
1927
+ if (shouldLog) {
1928
+ console[type](...args);
1929
+ }
1930
+ };
1931
+ const logger = {
1932
+ log: (...args) => {
1933
+ tryLog("log", ...args);
1934
+ },
1935
+ info: (...args) => {
1936
+ tryLog("info", ...args);
1937
+ },
1938
+ warn: (...args) => {
1939
+ tryLog("warn", ...args);
1940
+ },
1941
+ error: (...args) => {
1942
+ tryLog("error", ...args);
1943
+ },
1944
+ debug: (...args) => {
1945
+ tryLog("debug", ...args);
1946
+ },
1947
+ table: (...args) => {
1948
+ tryLog("table", ...args);
1949
+ },
1950
+ };
1951
+
1952
+
1967
1953
  }),
1968
1954
  "./src/utilities/replication.ts":
1969
1955
  /*!**************************************!*\