@seedprotocol/sdk 0.1.28 → 0.1.30

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.
@@ -20,7 +20,7 @@ import { BehaviorSubject } from 'rxjs';
20
20
  import { immerable, produce, enableMapSet } from 'immer';
21
21
  import pluralize from 'pluralize';
22
22
  import Arweave from 'arweave';
23
- import { useState, useCallback, useEffect, useRef } from 'react';
23
+ import { useState, useEffect, useRef, useCallback } from 'react';
24
24
  import { useImmer } from 'use-immer';
25
25
  import { useSelector } from '@xstate/react';
26
26
  import { createBrowserInspector } from '@statelyai/inspect';
@@ -199,7 +199,7 @@ const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
199
199
  }
200
200
  });
201
201
 
202
- const logger$n = debug('app:shared:helpers');
202
+ const logger$m = debug('app:shared:helpers');
203
203
  const { alphanumeric } = nanoIdDictionary;
204
204
  const generateId = () => {
205
205
  return customAlphabet(alphanumeric, 10)();
@@ -262,7 +262,7 @@ const convertTxIdToImageSrc = (txId) => __awaiter(void 0, void 0, void 0, functi
262
262
  const imageFilePath = `/files/images/${txId}`;
263
263
  const fileExists = yield fs.promises.exists(imageFilePath);
264
264
  if (!fileExists) {
265
- logger$n(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
265
+ logger$m(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
266
266
  return;
267
267
  }
268
268
  const uint = yield fs.promises.readFile(imageFilePath);
@@ -900,7 +900,7 @@ const getAddressesFromDb = () => __awaiter(void 0, void 0, void 0, function* ()
900
900
  return JSON.parse(addressArrayString);
901
901
  });
902
902
 
903
- const logger$m = debug('app:property:actors:hydrateFromDb');
903
+ const logger$l = debug('app:property:actors:hydrateFromDb');
904
904
  const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
905
905
  const { seedUid, seedLocalId, propertyName: propertyNameRaw, propertyValue, propertyRecordSchema, itemModelName, } = context;
906
906
  let propertyName = propertyNameRaw;
@@ -968,23 +968,23 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
968
968
  const firstRow = rows[0];
969
969
  const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, seedLocalId: seedLocalIdFromDb, seedUid: seedUidFromDb, schemaUid: schemaUidFromDb, refResolvedValue, refResolvedDisplayValue, } = firstRow;
970
970
  if (propertyName && !propertyNameFromDb) {
971
- logger$m(`Property name from code is ${propertyName} but has not value in db ${propertyNameFromDb} for Property.${localId}`);
971
+ logger$l(`Property name from code is ${propertyName} but has not value in db ${propertyNameFromDb} for Property.${localId}`);
972
972
  }
973
973
  if (propertyName &&
974
974
  propertyNameFromDb &&
975
975
  !propertyNameFromDb.includes(propertyName) &&
976
976
  !propertyName.includes(propertyNameFromDb) &&
977
977
  propertyNameFromDb !== propertyName) {
978
- logger$m(`Property name from db ${propertyNameFromDb} does not match property name ${propertyName} for Property.${localId}`);
978
+ logger$l(`Property name from db ${propertyNameFromDb} does not match property name ${propertyName} for Property.${localId}`);
979
979
  }
980
980
  if (propertyValue && propertyValueFromDb !== propertyValue) {
981
- logger$m(`Property value from db ${propertyValueFromDb} does not match property value ${propertyValue} for Property.${localId}`);
981
+ logger$l(`Property value from db ${propertyValueFromDb} does not match property value ${propertyValue} for Property.${localId}`);
982
982
  }
983
983
  if (seedLocalIdFromDb !== seedLocalId) {
984
- logger$m(`Seed local id from db ${seedLocalIdFromDb} does not match seed local id ${seedLocalId} for Property.${localId}`);
984
+ logger$l(`Seed local id from db ${seedLocalIdFromDb} does not match seed local id ${seedLocalId} for Property.${localId}`);
985
985
  }
986
986
  if (seedUidFromDb !== seedUid) {
987
- logger$m(`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`);
987
+ logger$l(`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`);
988
988
  }
989
989
  sendBack({
990
990
  type: 'updateContext',
@@ -999,7 +999,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
999
999
  renderValue: refResolvedDisplayValue,
1000
1000
  });
1001
1001
  if (propertyNameFromDb === 'storageTransactionId') {
1002
- const { Item } = yield import('./index-D0rZ64nV.js');
1002
+ const { Item } = yield import('./index-BTdiFCLE.js');
1003
1003
  const item = yield Item.find({
1004
1004
  seedLocalId,
1005
1005
  modelName: itemModelName,
@@ -1017,7 +1017,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
1017
1017
  const renderValue = yield fs.promises
1018
1018
  .readFile(htmlFilePath, 'utf8')
1019
1019
  .catch((error) => {
1020
- logger$m('Error reading html file', error);
1020
+ logger$l('Error reading html file', error);
1021
1021
  });
1022
1022
  property
1023
1023
  .getService()
@@ -1084,7 +1084,7 @@ const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seed
1084
1084
 
1085
1085
  const eventEmitter = new EventEmitter();
1086
1086
 
1087
- const logger$l = debug('app:write');
1087
+ const logger$k = debug('app:write');
1088
1088
  const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
1089
1089
  if (!modelName || (!seedLocalId && !seedUid)) {
1090
1090
  return;
@@ -1162,7 +1162,7 @@ const deleteItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLoca
1162
1162
  });
1163
1163
  const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function* ({ propertyLocalId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, }) {
1164
1164
  if (!propertyLocalId && !seedLocalId) {
1165
- logger$l(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
1165
+ logger$k(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
1166
1166
  return;
1167
1167
  }
1168
1168
  let safeNewValue = newValue;
@@ -1201,7 +1201,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
1201
1201
  const schemaUid = mostRecentRecord[9];
1202
1202
  const easDataType = mostRecentRecord[10];
1203
1203
  if (propertyValueFromDb === newValue) {
1204
- logger$l(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
1204
+ logger$k(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
1205
1205
  return;
1206
1206
  }
1207
1207
  // This means we already have a local-only record so we should just update that one
@@ -1643,7 +1643,7 @@ const setModel = (modelName, model) => {
1643
1643
  };
1644
1644
 
1645
1645
  var _a$2;
1646
- const logger$k = debug('app:property:class');
1646
+ const logger$j = debug('app:property:class');
1647
1647
  const namesThatEndWithId = [];
1648
1648
  class ItemProperty {
1649
1649
  // private constructor(localIdOrUid) {
@@ -1691,7 +1691,7 @@ class ItemProperty {
1691
1691
  serviceInput.propertyValue = JSON.parse(propertyValue);
1692
1692
  }
1693
1693
  catch (e) {
1694
- logger$k('List property value is not JSON', e);
1694
+ logger$j('List property value is not JSON', e);
1695
1695
  }
1696
1696
  }
1697
1697
  const propertyNameSingular = pluralize(propertyName, 1);
@@ -1745,15 +1745,13 @@ class ItemProperty {
1745
1745
  }
1746
1746
  if (skipTransform && !this._alias) ;
1747
1747
  this._subject.next(renderValue);
1748
- // eventEmitter.emit(
1749
- // `item.${itemModelName},${seedUid || seedLocalId}.update`,
1750
- // )
1748
+ eventEmitter.emit(`item.${itemModelName},${seedUid || seedLocalId}.update`);
1751
1749
  // this._lastRenderedValue = renderValue
1752
1750
  });
1753
1751
  this._service.start();
1754
1752
  }
1755
1753
  _updateResponseListener(event) {
1756
- logger$k(`[ItemProperty] [_updateResponseListener] [${this.itemModelName}.${this.seedLocalId}] ${this.propertyName} event`, event);
1754
+ logger$j(`[ItemProperty] [_updateResponseListener] [${this.itemModelName}.${this.seedLocalId}] ${this.propertyName} event`, event);
1757
1755
  }
1758
1756
  static create(props) {
1759
1757
  const { propertyName, seedLocalId, seedUid } = props;
@@ -1897,7 +1895,7 @@ class ItemProperty {
1897
1895
  }
1898
1896
  unload() {
1899
1897
  this._service.stop();
1900
- logger$k(`[XXXXXX] [ItemProperty] [${this.seedLocalId}] [unload] removing listener`, this._updateResponseEvent);
1898
+ logger$j(`[XXXXXX] [ItemProperty] [${this.seedLocalId}] [unload] removing listener`, this._updateResponseEvent);
1901
1899
  eventEmitter.removeListener(this._updateResponseEvent, this._updateResponseListener);
1902
1900
  }
1903
1901
  }
@@ -3206,7 +3204,7 @@ const getPropertiesForSeed = (seedLocalId, seedUid) => __awaiter(void 0, void 0,
3206
3204
  return propertiesData;
3207
3205
  });
3208
3206
 
3209
- const logger$j = debug('app:db:queries:getItem');
3207
+ const logger$i = debug('app:db:queries:getItem');
3210
3208
  const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName, seedLocalId, seedUid, }) {
3211
3209
  if (!seedLocalId && !seedUid) {
3212
3210
  throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
@@ -3214,7 +3212,7 @@ const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
3214
3212
  if (seedUid && !seedLocalId) {
3215
3213
  const seedData = yield getSeedData({ seedUid });
3216
3214
  if (!seedData) {
3217
- logger$j('[db/queries] [getItem] no seedData seedUid', seedUid);
3215
+ logger$i('[db/queries] [getItem] no seedData seedUid', seedUid);
3218
3216
  return;
3219
3217
  }
3220
3218
  seedLocalId = seedData.localId;
@@ -3644,7 +3642,7 @@ const fetchDbData = fromCallback(({ sendBack, input: { context } }) => {
3644
3642
  return () => { };
3645
3643
  });
3646
3644
 
3647
- const logger$i = debug('app:allItemsActors:fetchSeeds');
3645
+ const logger$h = debug('app:allItemsActors:fetchSeeds');
3648
3646
  const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
3649
3647
  const { queryVariables, modelName } = context;
3650
3648
  if (!queryVariables) {
@@ -3654,7 +3652,7 @@ const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
3654
3652
  const _fetchSeeds = () => __awaiter(void 0, void 0, void 0, function* () {
3655
3653
  const queryKey = [`getSeeds${modelName}`];
3656
3654
  const cachedResults = queryClient.getQueryData(queryKey);
3657
- logger$i(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
3655
+ logger$h(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
3658
3656
  const results = yield queryClient.fetchQuery({
3659
3657
  queryKey,
3660
3658
  queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return easClient.request(GET_SEEDS, queryVariables); }),
@@ -4244,7 +4242,7 @@ const initSeedSync = () => {
4244
4242
  }
4245
4243
  };
4246
4244
 
4247
- const logger$h = debug('app:services:global:actors:initialize');
4245
+ const logger$g = debug('app:services:global:actors:initialize');
4248
4246
  const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
4249
4247
  const { internalService, models, endpoints } = context;
4250
4248
  const { addresses } = event;
@@ -4265,7 +4263,7 @@ const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
4265
4263
  const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
4266
4264
  return new Promise((resolve) => {
4267
4265
  internalSubscription = internalService.subscribe((snapshot) => {
4268
- logger$h('[sdk] [internal] snapshot', snapshot);
4266
+ logger$g('[sdk] [internal] snapshot', snapshot);
4269
4267
  if (snapshot.value === 'ready') {
4270
4268
  resolve();
4271
4269
  }
@@ -4274,10 +4272,10 @@ const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
4274
4272
  });
4275
4273
  });
4276
4274
  _initFileSystem().then(() => {
4277
- logger$h('[global/actors] File system initialized');
4275
+ logger$g('[global/actors] File system initialized');
4278
4276
  });
4279
4277
  _initInternal().then(() => {
4280
- logger$h('[global/actors] Internal initialized');
4278
+ logger$g('[global/actors] Internal initialized');
4281
4279
  sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
4282
4280
  internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
4283
4281
  });
@@ -4291,7 +4289,7 @@ const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
4291
4289
  };
4292
4290
  });
4293
4291
 
4294
- const logger$g = debug('app:services:global:actors:getSchemaForModel');
4292
+ const logger$f = debug('app:services:global:actors:getSchemaForModel');
4295
4293
  const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } }) => {
4296
4294
  const { modelName } = event;
4297
4295
  if (!modelName) {
@@ -4307,12 +4305,12 @@ const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } })
4307
4305
  if (!model) {
4308
4306
  throw new Error(`Model ${modelName} not found`);
4309
4307
  }
4310
- logger$g('[service/actor] [getSchemaForModel] model:', model);
4308
+ logger$f('[service/actor] [getSchemaForModel] model:', model);
4311
4309
  sendBack({ type: 'schemaForModel', schema: model.schema });
4312
4310
  return () => { };
4313
4311
  });
4314
4312
 
4315
- const logger$f = debug('app:services:global:actors:addModelsToDb');
4313
+ const logger$e = debug('app:services:global:actors:addModelsToDb');
4316
4314
  const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
4317
4315
  const { models: models$1 } = context;
4318
4316
  const _addModelsToDb = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -4321,12 +4319,12 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
4321
4319
  if (!models$1) {
4322
4320
  return;
4323
4321
  }
4324
- const { models: SeedModels } = yield import('./seed.schema.config-yz1aTqaQ.js');
4322
+ const { models: SeedModels } = yield import('./seed.schema.config-DPZGkbBX.js');
4325
4323
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
4326
4324
  let hasModelsInDb = false;
4327
4325
  const schemaDefsByModelName = new Map();
4328
4326
  for (const [modelName, _] of Object.entries(allModels)) {
4329
- logger$f('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
4327
+ logger$e('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
4330
4328
  let foundModel;
4331
4329
  const foundModelsQuery = yield appDb
4332
4330
  .select()
@@ -4336,7 +4334,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
4336
4334
  yield appDb.insert(models).values({
4337
4335
  name: modelName,
4338
4336
  });
4339
- logger$f('[global/actors] [addModelsToDb] inserted model:', modelName);
4337
+ logger$e('[global/actors] [addModelsToDb] inserted model:', modelName);
4340
4338
  const foundModels = yield appDb
4341
4339
  .select({
4342
4340
  id: models.id,
@@ -4406,10 +4404,10 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
4406
4404
  return () => { };
4407
4405
  });
4408
4406
 
4409
- const logger$e = debug('app:services:db:actors:checkStatus');
4407
+ const logger$d = debug('app:services:db:actors:checkStatus');
4410
4408
  const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
4411
4409
  const { dbName } = context;
4412
- logger$e('[db/actors] checkStatus context', context);
4410
+ logger$d('[db/actors] checkStatus context', context);
4413
4411
  const pathToDir = `${BROWSER_FS_TOP_DIR}`;
4414
4412
  const pathToDbDir = `${pathToDir}/db`;
4415
4413
  const pathToDb = `${pathToDbDir}/${dbName}.sqlite3`;
@@ -4440,9 +4438,9 @@ const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
4440
4438
  });
4441
4439
  });
4442
4440
 
4443
- const logger$d = debug('app:services:db:actors:connectToDb');
4441
+ const logger$c = debug('app:services:db:actors:connectToDb');
4444
4442
  const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
4445
- logger$d('[db/actors] connectToDb context', context);
4443
+ logger$c('[db/actors] connectToDb context', context);
4446
4444
  const { dbName, pathToDir } = context;
4447
4445
  let isConnecting = false;
4448
4446
  let dbId;
@@ -4455,16 +4453,16 @@ const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
4455
4453
  const sqliteWasmClient = yield getSqliteWasmClient();
4456
4454
  //@ts-ignore
4457
4455
  response = yield sqliteWasmClient('config-get', {});
4458
- logger$d(response);
4459
- logger$d('Running SQLite3 version', response.result.version.libVersion);
4456
+ logger$c(response);
4457
+ logger$c('Running SQLite3 version', response.result.version.libVersion);
4460
4458
  //@ts-ignore
4461
4459
  response = yield sqliteWasmClient('open', {
4462
4460
  filename: `file:${pathToDir}/db/${dbName}.sqlite3?vfs=opfs`,
4463
4461
  });
4464
- logger$d(response);
4462
+ logger$c(response);
4465
4463
  dbId = response.dbId;
4466
4464
  // logger(`dbId: ${dbId}`)
4467
- logger$d('OPFS is available, created persisted database at', response.result.filename.replace(/^file:(.*?)\?vfs=opfs$/, '$1'));
4465
+ logger$c('OPFS is available, created persisted database at', response.result.filename.replace(/^file:(.*?)\?vfs=opfs$/, '$1'));
4468
4466
  });
4469
4467
  const interval = setInterval(() => {
4470
4468
  // TODO: Add a timeout
@@ -4521,7 +4519,7 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
4521
4519
  });
4522
4520
  });
4523
4521
 
4524
- const logger$c = debug('app:services:db:actors:migrate');
4522
+ const logger$b = debug('app:services:db:actors:migrate');
4525
4523
  const dbExec = (dbId_1, params_1, sql_1, dbName_1, ...args_1) => __awaiter(void 0, [dbId_1, params_1, sql_1, dbName_1, ...args_1], void 0, function* (dbId, params, sql, dbName, retries = 2) {
4526
4524
  const rowsToReturnRaw = [];
4527
4525
  const sqliteWasmClient = yield getSqliteWasmClient();
@@ -4587,7 +4585,7 @@ const dbExec = (dbId_1, params_1, sql_1, dbName_1, ...args_1) => __awaiter(void
4587
4585
  });
4588
4586
  const migrate = fromCallback(({ sendBack, input: { context } }) => {
4589
4587
  const { pathToDbDir, dbId, dbName } = context;
4590
- logger$c('[db/actors] migrate context', context);
4588
+ logger$b('[db/actors] migrate context', context);
4591
4589
  const schemaGlobString = `${BROWSER_FS_TOP_DIR}/schema/*`;
4592
4590
  let journalExists = false;
4593
4591
  // const _initFs = async (): Promise<void> => {
@@ -4751,7 +4749,7 @@ const migrate = fromCallback(({ sendBack, input: { context } }) => {
4751
4749
  return () => { };
4752
4750
  });
4753
4751
 
4754
- const logger$b = debug('app:services:db:machine');
4752
+ const logger$a = debug('app:services:db:machine');
4755
4753
  const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
4756
4754
  const dbMachine = setup({
4757
4755
  types: {
@@ -4772,7 +4770,7 @@ const dbMachine = setup({
4772
4770
  [DB_WAITING_FOR_FILES_RECEIVED]: {
4773
4771
  actions: assign({
4774
4772
  hasFiles: ({ event }) => {
4775
- logger$b('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
4773
+ logger$a('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
4776
4774
  return true;
4777
4775
  },
4778
4776
  }),
@@ -4781,8 +4779,8 @@ const dbMachine = setup({
4781
4779
  target: `.${CHECKING_STATUS}`,
4782
4780
  actions: assign({
4783
4781
  hasFiles: ({ context, event }) => {
4784
- logger$b('[db/machine] updateHasFiles event:', event);
4785
- logger$b('[db/machine] updateHasFiles context:', context);
4782
+ logger$a('[db/machine] updateHasFiles event:', event);
4783
+ logger$a('[db/machine] updateHasFiles context:', context);
4786
4784
  return event.hasFiles;
4787
4785
  },
4788
4786
  }),
@@ -5003,7 +5001,7 @@ const prepareDb = fromCallback(({ sendBack }) => {
5003
5001
  };
5004
5002
  });
5005
5003
 
5006
- const logger$a = debug('app:services:internal:helpers');
5004
+ const logger$9 = debug('app:services:internal:helpers');
5007
5005
  /**
5008
5006
  * Recursively create directories if they don't exist.
5009
5007
  * @param {string} dirPath - The directory path to create.
@@ -5079,7 +5077,7 @@ const downloadFile = (url, localFilePath) => __awaiter(void 0, void 0, void 0, f
5079
5077
  if (JSON.stringify(error).includes('File exists')) {
5080
5078
  yield fs.promises.readFile(localFilePath, 'utf-8');
5081
5079
  }
5082
- logger$a(`[Error] Failed to download file from ${url}:`, error);
5080
+ logger$9(`[Error] Failed to download file from ${url}:`, error);
5083
5081
  }
5084
5082
  busy = false;
5085
5083
  });
@@ -5117,10 +5115,10 @@ const syncDbFiles = (_a) => __awaiter(void 0, [_a], void 0, function* ({ filePat
5117
5115
  const fileList = yield fetchDirectory(filePaths);
5118
5116
  yield fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList);
5119
5117
  yield confirmFilesExist(fileList);
5120
- logger$a('[syncDbFiles] Files synced!');
5118
+ logger$9('[syncDbFiles] Files synced!');
5121
5119
  });
5122
5120
 
5123
- const logger$9 = debug('app:files:download');
5121
+ const logger$8 = debug('app:files:download');
5124
5122
  const downloadAllFilesRequestHandler = (_a) => __awaiter(void 0, [_a], void 0, function* ({ endpoints, eventId, }) {
5125
5123
  yield syncDbFiles(endpoints);
5126
5124
  eventEmitter.emit('fs.downloadAll.success', { eventId });
@@ -5204,7 +5202,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
5204
5202
  try {
5205
5203
  const res = yield fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
5206
5204
  if (res.status !== 200) {
5207
- logger$9(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
5205
+ logger$8(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
5208
5206
  excludedTransactions.add(transactionId);
5209
5207
  yield writeAppState(appDb, 'excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
5210
5208
  continue;
@@ -5218,7 +5216,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
5218
5216
  console.error(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`, error);
5219
5217
  });
5220
5218
  if (!dataString) {
5221
- logger$9(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not found`);
5219
+ logger$8(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not found`);
5222
5220
  }
5223
5221
  let contentType = identifyString(dataString);
5224
5222
  if (contentType !== 'json' &&
@@ -5226,7 +5224,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
5226
5224
  contentType !== 'html') {
5227
5225
  const possibleImageType = getImageDataType(dataString);
5228
5226
  if (!possibleImageType) {
5229
- logger$9(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`);
5227
+ logger$8(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`);
5230
5228
  continue;
5231
5229
  }
5232
5230
  contentType = possibleImageType;
@@ -5289,7 +5287,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
5289
5287
  }
5290
5288
  }
5291
5289
  catch (error) {
5292
- logger$9(error);
5290
+ logger$8(error);
5293
5291
  }
5294
5292
  }
5295
5293
  });
@@ -5335,14 +5333,14 @@ const isFsInitialized = () => {
5335
5333
  return isInitialized;
5336
5334
  };
5337
5335
 
5338
- const logger$8 = debug('app:internal:actors:configureFs');
5336
+ const logger$7 = debug('app:internal:actors:configureFs');
5339
5337
  const configureFs = fromCallback(({ sendBack, input: { context } }) => {
5340
5338
  const { endpoints, appDbService } = context;
5341
- logger$8('[internal/actors] [configureFs] Configuring FS');
5339
+ logger$7('[internal/actors] [configureFs] Configuring FS');
5342
5340
  const _configureFs = () => __awaiter(void 0, void 0, void 0, function* () {
5343
- logger$8('[internal/actors] [configureFs] calling _configureFs');
5344
- logger$8('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
5345
- logger$8('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
5341
+ logger$7('[internal/actors] [configureFs] calling _configureFs');
5342
+ logger$7('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
5343
+ logger$7('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
5346
5344
  yield waitForEvent({
5347
5345
  req: {
5348
5346
  eventLabel: 'fs.downloadAll.request',
@@ -5371,7 +5369,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
5371
5369
  // }
5372
5370
  // }, 200)
5373
5371
  // })
5374
- logger$8('[internal/actors] [configureFs] fs configured!');
5372
+ logger$7('[internal/actors] [configureFs] fs configured!');
5375
5373
  });
5376
5374
  // Some of our dependencies use fs sync functions, which don't work with
5377
5375
  // OPFS. ZenFS creates an async cache of all files so that the sync functions
@@ -5384,7 +5382,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
5384
5382
  return () => { };
5385
5383
  });
5386
5384
 
5387
- const logger$7 = debug('app:services:internal:actors:saveConfig');
5385
+ const logger$6 = debug('app:services:internal:actors:saveConfig');
5388
5386
  const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
5389
5387
  if (typeof window === 'undefined') {
5390
5388
  console.error('seedInitBrowser called from non-browser context');
@@ -5435,20 +5433,20 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
5435
5433
  },
5436
5434
  setWhere: sql `key = 'addresses'`,
5437
5435
  });
5438
- logger$7('[sdk] [internal/actors] Should be done saving');
5436
+ logger$6('[sdk] [internal/actors] Should be done saving');
5439
5437
  }
5440
5438
  catch (error) {
5441
5439
  console.error('Error saving config:', error);
5442
5440
  }
5443
5441
  });
5444
5442
  _saveConfig().then(() => {
5445
- logger$7('[sdk] [internal/actors] Successfully saved config');
5443
+ logger$6('[sdk] [internal/actors] Successfully saved config');
5446
5444
  return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
5447
5445
  });
5448
5446
  return () => { };
5449
5447
  });
5450
5448
 
5451
- const logger$6 = debug('app:services:internal:actors:loadAppDb');
5449
+ const logger$5 = debug('app:services:internal:actors:loadAppDb');
5452
5450
  const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
5453
5451
  const { appDbService } = context;
5454
5452
  let subscription;
@@ -5469,7 +5467,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
5469
5467
  });
5470
5468
  _loadAppDb().then(() => {
5471
5469
  sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
5472
- logger$6('[sdk] [internal/actors] Successfully loaded app DB');
5470
+ logger$5('[sdk] [internal/actors] Successfully loaded app DB');
5473
5471
  });
5474
5472
  return () => {
5475
5473
  if (subscription) {
@@ -5478,7 +5476,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
5478
5476
  };
5479
5477
  });
5480
5478
 
5481
- const logger$5 = debug('app:services:internal:machine');
5479
+ const logger$4 = debug('app:services:internal:machine');
5482
5480
  createBrowserInspector({
5483
5481
  autoStart: false,
5484
5482
  });
@@ -5577,7 +5575,7 @@ const internalMachine = setup({
5577
5575
  [INTERNAL_LOADING_APP_DB_SUCCESS]: {
5578
5576
  target: SAVING_CONFIG,
5579
5577
  actions: () => {
5580
- logger$5('[sdk] [internal/index] App DB loaded!');
5578
+ logger$4('[sdk] [internal/index] App DB loaded!');
5581
5579
  },
5582
5580
  },
5583
5581
  },
@@ -5603,7 +5601,7 @@ const internalMachine = setup({
5603
5601
  },
5604
5602
  ready: {
5605
5603
  entry: () => {
5606
- logger$5('[sdk] [internal/index] Ready!');
5604
+ logger$4('[sdk] [internal/index] Ready!');
5607
5605
  },
5608
5606
  meta: {
5609
5607
  displayText: "Crossing the t's ...",
@@ -5618,7 +5616,7 @@ const internalMachine = setup({
5618
5616
  },
5619
5617
  },
5620
5618
  entry: () => {
5621
- logger$5('[sdk] [internal/index] Error!');
5619
+ logger$4('[sdk] [internal/index] Error!');
5622
5620
  },
5623
5621
  meta: {
5624
5622
  displayText: 'Whoops! Something went wrong.',
@@ -5785,11 +5783,11 @@ const globalMachine = setup({
5785
5783
  (_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
5786
5784
  let SeedClass;
5787
5785
  if (context.environment === 'node') {
5788
- const { SeedNode } = yield import('./seed-BvhBPoan.js');
5786
+ const { SeedNode } = yield import('./seed-B80PS8n5.js');
5789
5787
  SeedClass = SeedNode;
5790
5788
  }
5791
5789
  else {
5792
- const { SeedBrowser } = yield import('./seed-j9PdVqyP.js');
5790
+ const { SeedBrowser } = yield import('./seed-mwVG1tot.js');
5793
5791
  SeedClass = SeedBrowser;
5794
5792
  }
5795
5793
  return SeedClass;
@@ -5883,63 +5881,6 @@ const globalService = createActor(globalMachine, {
5883
5881
  globalService.start();
5884
5882
  const getGlobalService = () => globalService;
5885
5883
 
5886
- const logger$4 = debug('app:react:db');
5887
- const useDbsAreReady = () => {
5888
- const [dbsAreReady, setDbsAreReady] = useState(false);
5889
- const update = useCallback(() => {
5890
- if (dbsAreReady) {
5891
- return;
5892
- }
5893
- setDbsAreReady(true);
5894
- }, []);
5895
- useEffect(() => {
5896
- let globalSubscription;
5897
- let internalSubscription;
5898
- const _waitForDbs = () => __awaiter(void 0, void 0, void 0, function* () {
5899
- const globalService = getGlobalService();
5900
- const internalService = globalService.getSnapshot().context.internalService;
5901
- if (!internalService) {
5902
- logger$4('[useDbsAreReady] [useEffect] no internalService');
5903
- globalSubscription = globalService.subscribe(({ context }) => {
5904
- if (!internalSubscription && context && context.internalService) {
5905
- globalSubscription === null || globalSubscription === void 0 ? void 0 : globalSubscription.unsubscribe();
5906
- internalSubscription = context.internalService.subscribe((snapshot) => {
5907
- if (snapshot.value === 'ready') {
5908
- update();
5909
- internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
5910
- }
5911
- });
5912
- }
5913
- });
5914
- return;
5915
- }
5916
- const currentState = internalService.getSnapshot().value;
5917
- if (currentState === 'ready') {
5918
- update();
5919
- return;
5920
- }
5921
- internalSubscription = internalService.subscribe((snapshot) => {
5922
- if (snapshot.value === 'ready') {
5923
- update();
5924
- internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
5925
- }
5926
- });
5927
- });
5928
- _waitForDbs();
5929
- return () => {
5930
- if (globalSubscription) {
5931
- globalSubscription.unsubscribe();
5932
- }
5933
- if (internalSubscription) {
5934
- internalSubscription.unsubscribe();
5935
- }
5936
- };
5937
- }, []);
5938
- return {
5939
- dbsAreReady,
5940
- };
5941
- };
5942
-
5943
5884
  const logger$3 = debug('app:react:services');
5944
5885
  const finalStrings = ['idle', 'ready', 'done', 'success'];
5945
5886
  const getServiceName = (service) => {
@@ -6143,7 +6084,6 @@ const useItems = ({ modelName, options }) => {
6143
6084
  const [items, setItems] = useImmer([]);
6144
6085
  const [isReadingDb, setIsReadingDb] = useState(false);
6145
6086
  const [isInitialized, setIsInitialized] = useState(false);
6146
- const { dbsAreReady } = useDbsAreReady();
6147
6087
  const modelNameRef = useRef(modelName);
6148
6088
  const readFromDb = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
6149
6089
  if (!event ||
@@ -6158,14 +6098,14 @@ const useItems = ({ modelName, options }) => {
6158
6098
  setIsReadingDb(false);
6159
6099
  }), [modelName]);
6160
6100
  useEffect(() => {
6161
- if (dbsAreReady && !isInitialized) {
6101
+ if (isAppDbReady() && !isInitialized) {
6162
6102
  const _fetchItems = () => __awaiter(void 0, void 0, void 0, function* () {
6163
6103
  yield readFromDb({ modelName });
6164
6104
  setIsInitialized(true);
6165
6105
  });
6166
6106
  _fetchItems();
6167
6107
  }
6168
- }, [dbsAreReady, isInitialized]);
6108
+ }, [isInitialized]);
6169
6109
  useEffect(() => {
6170
6110
  eventEmitter.addListener('item.requestAll', readFromDb);
6171
6111
  return () => {
@@ -6249,7 +6189,6 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
6249
6189
  const [property, setProperty] = useImmer(undefined);
6250
6190
  const [isReadingFromDb, setIsReadingFromDb] = useState(false);
6251
6191
  const [isInitialized, setIsInitialized] = useState(false);
6252
- const { dbsAreReady } = useDbsAreReady();
6253
6192
  const value = useSelector(property === null || property === void 0 ? void 0 : property.getService(), (snapshot) => {
6254
6193
  if (!snapshot || !snapshot.context) {
6255
6194
  return;
@@ -6258,14 +6197,12 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
6258
6197
  });
6259
6198
  const status = useSelector(property === null || property === void 0 ? void 0 : property.getService(), (snapshot) => snapshot === null || snapshot === void 0 ? void 0 : snapshot.value);
6260
6199
  useEffect(() => {
6261
- if (dbsAreReady && property && property.value !== value) {
6200
+ if (property && property.value !== value) {
6262
6201
  readFromDb();
6263
6202
  }
6264
- }, [dbsAreReady, property, value]);
6203
+ }, [property, value]);
6265
6204
  const readFromDb = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
6266
- if (!propertyName ||
6267
- (!seedLocalId && !seedUid) ||
6268
- (!dbsAreReady && isReadingFromDb)) {
6205
+ if (!isAppDbReady() || isReadingFromDb || (!seedLocalId && !seedUid)) {
6269
6206
  return;
6270
6207
  }
6271
6208
  setIsReadingFromDb(true);
@@ -6281,7 +6218,7 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
6281
6218
  }
6282
6219
  setProperty(() => foundProperty);
6283
6220
  setIsInitialized(true);
6284
- }), [dbsAreReady, isReadingFromDb]);
6221
+ }), [isReadingFromDb]);
6285
6222
  useEffect(() => {
6286
6223
  readFromDb();
6287
6224
  }, []);
@@ -6327,6 +6264,8 @@ const useItemProperties = (item) => {
6327
6264
  };
6328
6265
  };
6329
6266
 
6267
+ debug('app:react:db');
6268
+
6330
6269
  const logger = debug('app:services:events');
6331
6270
  const handleServiceSaveState = (event) => {
6332
6271
  const { state, serviceId } = event;
@@ -6602,7 +6541,7 @@ const client = {
6602
6541
  console.error('fs listeners not ready during init');
6603
6542
  }
6604
6543
  globalService.send({ type: 'init', endpoints, models, addresses });
6605
- import('./seed.schema.config-yz1aTqaQ.js').then(({ models }) => {
6544
+ import('./seed.schema.config-DPZGkbBX.js').then(({ models }) => {
6606
6545
  for (const [key, value] of Object.entries(models)) {
6607
6546
  setModel(key, value);
6608
6547
  }
@@ -6659,4 +6598,4 @@ if (isNode()) {
6659
6598
  }
6660
6599
 
6661
6600
  export { CHILD_SNAPSHOT as C, GET_SCHEMAS as G, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, GET_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, internalMachine as h, itemMachineSingle as i, isNode as j, isBrowser as k, isReactNative as l, ImageSrc as m, ItemProperty as n, useItem as o, useItemProperties as p, useCreateItem as q, useItemProperty as r, useDeleteItem as s, useServices as t, useItems as u, getGlobalService as v, withSeed as w, client as x, getCorrectId as y };
6662
- //# sourceMappingURL=index-Dv3N222g.js.map
6601
+ //# sourceMappingURL=index-B5_L9jvL.js.map