@seedprotocol/sdk 0.1.16 → 0.1.18
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/bin.js +13 -13
- package/dist/{events-Coj2v7ep.js → events-So24__c6.js} +364 -353
- package/dist/events-So24__c6.js.map +1 -0
- package/dist/{index-DiVYILvi.js → index-Cgo0-c0n.js} +16 -16
- package/dist/index-Cgo0-c0n.js.map +1 -0
- package/dist/main.js +12 -12
- package/dist/{seed-D4FumM_8.js → seed-BgRaREFr.js} +16 -16
- package/dist/{seed-D4FumM_8.js.map → seed-BgRaREFr.js.map} +1 -1
- package/dist/{seed-Bqa5CPoS.js → seed-CFk2xaH7.js} +2 -2
- package/dist/{seed-Bqa5CPoS.js.map → seed-CFk2xaH7.js.map} +1 -1
- package/dist/{seed-CnyxDQnB.js → seed-DGCfCUOn.js} +17 -17
- package/dist/{seed-CnyxDQnB.js.map → seed-DGCfCUOn.js.map} +1 -1
- package/dist/{seed.schema.config-fpg0HLo5.js → seed.schema.config-DYkIbj49.js} +11 -11
- package/dist/{seed.schema.config-fpg0HLo5.js.map → seed.schema.config-DYkIbj49.js.map} +1 -1
- package/dist/types/src/browser/db/sqlWasmClient.d.ts +6 -0
- package/dist/types/src/browser/db/sqlWasmClient.d.ts.map +1 -0
- package/dist/types/src/browser/react/services.d.ts +1 -6
- package/dist/types/src/browser/react/services.d.ts.map +1 -1
- package/dist/types/src/browser/services/global/actors/initialize.d.ts +2 -0
- package/dist/types/src/browser/services/global/actors/initialize.d.ts.map +1 -0
- package/dist/types/src/browser/services/global/actors.d.ts +3 -3
- package/dist/types/src/browser/services/global/actors.d.ts.map +1 -1
- package/dist/types/src/browser/services/global/{machine.d.ts → globalMachine.d.ts} +1 -1
- package/dist/types/src/browser/services/global/globalMachine.d.ts.map +1 -0
- package/dist/types/src/browser/services/global/index.d.ts +1 -1
- package/dist/types/src/browser/services/global/index.d.ts.map +1 -1
- package/dist/types/src/browser/services/internal/actors/configureFs.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/configureFs.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/actors/loadAppDb.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/loadAppDb.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/actors/loadSdkDb.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/loadSdkDb.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/actors/loadSeedDb.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/loadSeedDb.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/actors/prepareDb.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/prepareDb.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/actors/saveConfig.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/saveConfig.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/actors/validateInput.d.ts +2 -0
- package/dist/types/src/browser/services/internal/actors/validateInput.d.ts.map +1 -0
- package/dist/types/src/browser/services/internal/{machine.d.ts → internalMachine.d.ts} +1 -1
- package/dist/types/src/browser/services/internal/internalMachine.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/machines.d.ts +3 -0
- package/dist/types/src/types/machines.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/events-Coj2v7ep.js.map +0 -1
- package/dist/index-DiVYILvi.js.map +0 -1
- package/dist/types/src/browser/services/global/machine.d.ts.map +0 -1
- package/dist/types/src/browser/services/internal/actors.d.ts +0 -10
- package/dist/types/src/browser/services/internal/actors.d.ts.map +0 -1
- package/dist/types/src/browser/services/internal/machine.d.ts.map +0 -1
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { useImmer } from 'use-immer';
|
|
2
|
-
import { sql, count, max, eq, and, or, isNull, relations } from 'drizzle-orm';
|
|
3
|
-
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
4
|
-
import debug from 'debug';
|
|
5
1
|
import { fromCallback, setup, assign, createActor, waitFor, emit } from 'xstate';
|
|
6
|
-
import { BehaviorSubject } from 'rxjs';
|
|
7
|
-
import { fs, configureSingle } from '@zenfs/core';
|
|
8
|
-
import { startCase, debounce, camelCase, orderBy } from 'lodash-es';
|
|
9
|
-
import { immerable, produce } from 'immer';
|
|
10
|
-
import pluralize from 'pluralize';
|
|
11
|
-
import { useSelector } from '@xstate/react';
|
|
12
2
|
import { createBrowserInspector } from '@statelyai/inspect';
|
|
13
|
-
import '
|
|
14
|
-
import {
|
|
15
|
-
import Arweave from 'arweave';
|
|
16
|
-
import { WebAccess } from '@zenfs/dom';
|
|
3
|
+
import { fs, configureSingle } from '@zenfs/core';
|
|
4
|
+
import { sql, count, max, eq, and, or, isNull, relations } from 'drizzle-orm';
|
|
17
5
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
6
|
+
import debug from 'debug';
|
|
18
7
|
import { QueryClient } from '@tanstack/react-query';
|
|
19
8
|
import { GraphQLClient } from 'graphql-request';
|
|
20
9
|
import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister';
|
|
@@ -24,6 +13,17 @@ import { sqliteTable, text, int, blob, check, unique } from 'drizzle-orm/sqlite-
|
|
|
24
13
|
import 'dayjs';
|
|
25
14
|
import { customAlphabet } from 'nanoid';
|
|
26
15
|
import * as nanoIdDictionary from 'nanoid-dictionary';
|
|
16
|
+
import { WebAccess } from '@zenfs/dom';
|
|
17
|
+
import Arweave from 'arweave';
|
|
18
|
+
import { startCase, debounce, camelCase, orderBy } from 'lodash-es';
|
|
19
|
+
import pluralize from 'pluralize';
|
|
20
|
+
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
21
|
+
import { BehaviorSubject } from 'rxjs';
|
|
22
|
+
import { immerable, produce } from 'immer';
|
|
23
|
+
import { useImmer } from 'use-immer';
|
|
24
|
+
import { useSelector } from '@xstate/react';
|
|
25
|
+
import 'reflect-metadata';
|
|
26
|
+
import { Type } from '@sinclair/typebox';
|
|
27
27
|
import EventEmitter from 'eventemitter3';
|
|
28
28
|
|
|
29
29
|
const isNode = () => {
|
|
@@ -172,12 +172,12 @@ const EAS_ENDPOINT = process.env.NEXT_PUBLIC_EAS_ENDPOINT ||
|
|
|
172
172
|
const ARWEAVE_HOST = process.env.NEXT_PUBLIC_ARWEAVE_HOST || 'permagate.io';
|
|
173
173
|
|
|
174
174
|
let sqlite3InitModule;
|
|
175
|
-
let sqliteWasmClient$
|
|
175
|
+
let sqliteWasmClient$1;
|
|
176
176
|
let isPreparing = false;
|
|
177
177
|
|
|
178
178
|
const getSqlite = async () => {
|
|
179
|
-
if (sqliteWasmClient$
|
|
180
|
-
return sqliteWasmClient$
|
|
179
|
+
if (sqliteWasmClient$1) {
|
|
180
|
+
return sqliteWasmClient$1
|
|
181
181
|
}
|
|
182
182
|
if (typeof window === 'undefined') {
|
|
183
183
|
throw new Error('validateInput called from non-browser context')
|
|
@@ -204,7 +204,7 @@ const getSqlite = async () => {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
try {
|
|
207
|
-
sqliteWasmClient$
|
|
207
|
+
sqliteWasmClient$1 = await window.sqlite3Worker1Promiser.v2().catch((err) => {
|
|
208
208
|
console.error('Error initializing sqliteWasmClient:', err);
|
|
209
209
|
isPreparing = false;
|
|
210
210
|
});
|
|
@@ -214,14 +214,14 @@ const getSqlite = async () => {
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
-
const logger$
|
|
217
|
+
const logger$l = debug('app:db:actors');
|
|
218
218
|
let seedDb;
|
|
219
219
|
let appDb;
|
|
220
220
|
let sdkConfigDb;
|
|
221
|
-
let sqliteWasmClient
|
|
221
|
+
let sqliteWasmClient;
|
|
222
222
|
const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
223
223
|
const { dbName, dirName } = context;
|
|
224
|
-
logger$
|
|
224
|
+
logger$l('[db/actors] checkStatus context', context);
|
|
225
225
|
const pathToDir = `${BROWSER_FS_TOP_DIR}/${dirName}`;
|
|
226
226
|
const pathToDbDir = `${pathToDir}/db`;
|
|
227
227
|
const pathToDb = `${pathToDbDir}/${dbName}.sqlite3`;
|
|
@@ -252,7 +252,7 @@ const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
255
|
-
logger$
|
|
255
|
+
logger$l('[db/actors] connectToDb context', context);
|
|
256
256
|
const { dbName, pathToDir } = context;
|
|
257
257
|
let isConnecting = false;
|
|
258
258
|
let dbId;
|
|
@@ -262,21 +262,21 @@ const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
262
262
|
}
|
|
263
263
|
isConnecting = true;
|
|
264
264
|
let response;
|
|
265
|
-
if (!sqliteWasmClient
|
|
266
|
-
sqliteWasmClient
|
|
265
|
+
if (!sqliteWasmClient) {
|
|
266
|
+
sqliteWasmClient = yield getSqlite();
|
|
267
267
|
}
|
|
268
268
|
//@ts-ignore
|
|
269
|
-
response = yield sqliteWasmClient
|
|
270
|
-
logger$
|
|
271
|
-
logger$
|
|
269
|
+
response = yield sqliteWasmClient('config-get', {});
|
|
270
|
+
logger$l(response);
|
|
271
|
+
logger$l('Running SQLite3 version', response.result.version.libVersion);
|
|
272
272
|
//@ts-ignore
|
|
273
|
-
response = yield sqliteWasmClient
|
|
273
|
+
response = yield sqliteWasmClient('open', {
|
|
274
274
|
filename: `file:${pathToDir}/db/${dbName}.sqlite3?vfs=opfs`,
|
|
275
275
|
});
|
|
276
|
-
logger$
|
|
276
|
+
logger$l(response);
|
|
277
277
|
dbId = response.dbId;
|
|
278
278
|
// logger(`dbId: ${dbId}`)
|
|
279
|
-
logger$
|
|
279
|
+
logger$l('OPFS is available, created persisted database at', response.result.filename.replace(/^file:(.*?)\?vfs=opfs$/, '$1'));
|
|
280
280
|
});
|
|
281
281
|
const interval = setInterval(() => {
|
|
282
282
|
// TODO: Add a timeout
|
|
@@ -396,12 +396,12 @@ const dbExec = (dbId_1, params_1, sql_1, dbName_1, ...args_1) => __awaiter(void
|
|
|
396
396
|
});
|
|
397
397
|
const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
398
398
|
const { pathToDbDir, dirName, dbId, dbName } = context;
|
|
399
|
-
logger$
|
|
399
|
+
logger$l('[db/actors] migrate context', context);
|
|
400
400
|
const schemaGlobString = `${BROWSER_FS_TOP_DIR}/${dirName}/schema/*`;
|
|
401
401
|
const isSeedDb = dbName === DB_NAME_SEED;
|
|
402
402
|
const isAppDb = dbName === DB_NAME_APP;
|
|
403
403
|
const isSdkConfigDb = dbName === DB_NAME_SDK_CONFIG;
|
|
404
|
-
if (!sqliteWasmClient
|
|
404
|
+
if (!sqliteWasmClient) {
|
|
405
405
|
throw new Error('Sqlite wasm client not initialized');
|
|
406
406
|
}
|
|
407
407
|
let journalExists = false;
|
|
@@ -676,7 +676,7 @@ const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
676
676
|
}
|
|
677
677
|
});
|
|
678
678
|
|
|
679
|
-
const logger$
|
|
679
|
+
const logger$k = debug('app:shared:helpers');
|
|
680
680
|
const { alphanumeric } = nanoIdDictionary;
|
|
681
681
|
const generateId = () => {
|
|
682
682
|
return customAlphabet(alphanumeric, 10)();
|
|
@@ -739,7 +739,7 @@ const convertTxIdToImageSrc = (txId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
739
739
|
const imageFilePath = `/files/images/${txId}`;
|
|
740
740
|
const fileExists = yield fs.promises.exists(imageFilePath);
|
|
741
741
|
if (!fileExists) {
|
|
742
|
-
logger$
|
|
742
|
+
logger$k(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
|
|
743
743
|
return;
|
|
744
744
|
}
|
|
745
745
|
const uint = yield fs.promises.readFile(imageFilePath);
|
|
@@ -1518,7 +1518,7 @@ const getAddressesFromDb = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
1518
1518
|
return JSON.parse(addressArrayString);
|
|
1519
1519
|
});
|
|
1520
1520
|
|
|
1521
|
-
const logger$
|
|
1521
|
+
const logger$j = debug('app:property:actors:hydrateFromDb');
|
|
1522
1522
|
const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
1523
1523
|
const { seedUid, seedLocalId, propertyName: propertyNameRaw, propertyValue, propertyRecordSchema, itemModelName, } = context;
|
|
1524
1524
|
let propertyName = propertyNameRaw;
|
|
@@ -1586,23 +1586,23 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1586
1586
|
const firstRow = rows[0];
|
|
1587
1587
|
const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, seedLocalId: seedLocalIdFromDb, seedUid: seedUidFromDb, schemaUid: schemaUidFromDb, refResolvedValue, refResolvedDisplayValue, } = firstRow;
|
|
1588
1588
|
if (propertyName && !propertyNameFromDb) {
|
|
1589
|
-
logger$
|
|
1589
|
+
logger$j(`Property name from code is ${propertyName} but has not value in db ${propertyNameFromDb} for Property.${localId}`);
|
|
1590
1590
|
}
|
|
1591
1591
|
if (propertyName &&
|
|
1592
1592
|
propertyNameFromDb &&
|
|
1593
1593
|
!propertyNameFromDb.includes(propertyName) &&
|
|
1594
1594
|
!propertyName.includes(propertyNameFromDb) &&
|
|
1595
1595
|
propertyNameFromDb !== propertyName) {
|
|
1596
|
-
logger$
|
|
1596
|
+
logger$j(`Property name from db ${propertyNameFromDb} does not match property name ${propertyName} for Property.${localId}`);
|
|
1597
1597
|
}
|
|
1598
1598
|
if (propertyValue && propertyValueFromDb !== propertyValue) {
|
|
1599
|
-
logger$
|
|
1599
|
+
logger$j(`Property value from db ${propertyValueFromDb} does not match property value ${propertyValue} for Property.${localId}`);
|
|
1600
1600
|
}
|
|
1601
1601
|
if (seedLocalIdFromDb !== seedLocalId) {
|
|
1602
|
-
logger$
|
|
1602
|
+
logger$j(`Seed local id from db ${seedLocalIdFromDb} does not match seed local id ${seedLocalId} for Property.${localId}`);
|
|
1603
1603
|
}
|
|
1604
1604
|
if (seedUidFromDb !== seedUid) {
|
|
1605
|
-
logger$
|
|
1605
|
+
logger$j(`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`);
|
|
1606
1606
|
}
|
|
1607
1607
|
sendBack({
|
|
1608
1608
|
type: 'updateContext',
|
|
@@ -1617,7 +1617,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1617
1617
|
renderValue: refResolvedDisplayValue,
|
|
1618
1618
|
});
|
|
1619
1619
|
if (propertyNameFromDb === 'storageTransactionId') {
|
|
1620
|
-
const { Item } = yield import('./index-
|
|
1620
|
+
const { Item } = yield import('./index-Cgo0-c0n.js');
|
|
1621
1621
|
const item = yield Item.find({
|
|
1622
1622
|
seedLocalId,
|
|
1623
1623
|
modelName: itemModelName,
|
|
@@ -1635,7 +1635,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1635
1635
|
const renderValue = yield fs.promises
|
|
1636
1636
|
.readFile(htmlFilePath, 'utf8')
|
|
1637
1637
|
.catch((error) => {
|
|
1638
|
-
logger$
|
|
1638
|
+
logger$j('Error reading html file', error);
|
|
1639
1639
|
});
|
|
1640
1640
|
property
|
|
1641
1641
|
.getService()
|
|
@@ -1716,7 +1716,7 @@ const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seed
|
|
|
1716
1716
|
|
|
1717
1717
|
const eventEmitter = new EventEmitter();
|
|
1718
1718
|
|
|
1719
|
-
const logger$
|
|
1719
|
+
const logger$i = debug('app:write');
|
|
1720
1720
|
const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
1721
1721
|
if (!modelName || (!seedLocalId && !seedUid)) {
|
|
1722
1722
|
return;
|
|
@@ -1794,7 +1794,7 @@ const deleteItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLoca
|
|
|
1794
1794
|
});
|
|
1795
1795
|
const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function* ({ propertyLocalId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, }) {
|
|
1796
1796
|
if (!propertyLocalId && !seedLocalId) {
|
|
1797
|
-
logger$
|
|
1797
|
+
logger$i(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
1798
1798
|
return;
|
|
1799
1799
|
}
|
|
1800
1800
|
let safeNewValue = newValue;
|
|
@@ -1833,7 +1833,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
1833
1833
|
const schemaUid = mostRecentRecord[9];
|
|
1834
1834
|
const easDataType = mostRecentRecord[10];
|
|
1835
1835
|
if (propertyValueFromDb === newValue) {
|
|
1836
|
-
logger$
|
|
1836
|
+
logger$i(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
1837
1837
|
return;
|
|
1838
1838
|
}
|
|
1839
1839
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -2248,7 +2248,7 @@ const setModel = (modelName, model) => {
|
|
|
2248
2248
|
};
|
|
2249
2249
|
|
|
2250
2250
|
var _a$1;
|
|
2251
|
-
const logger$
|
|
2251
|
+
const logger$h = debug('app:property:class');
|
|
2252
2252
|
const namesThatEndWithId = [];
|
|
2253
2253
|
class ItemProperty {
|
|
2254
2254
|
// private constructor(localIdOrUid) {
|
|
@@ -2296,7 +2296,7 @@ class ItemProperty {
|
|
|
2296
2296
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
2297
2297
|
}
|
|
2298
2298
|
catch (e) {
|
|
2299
|
-
logger$
|
|
2299
|
+
logger$h('List property value is not JSON', e);
|
|
2300
2300
|
}
|
|
2301
2301
|
}
|
|
2302
2302
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -2358,7 +2358,7 @@ class ItemProperty {
|
|
|
2358
2358
|
this._service.start();
|
|
2359
2359
|
}
|
|
2360
2360
|
_updateResponseListener(event) {
|
|
2361
|
-
logger$
|
|
2361
|
+
logger$h(`[ItemProperty] [_updateResponseListener] [${this.itemModelName}.${this.seedLocalId}] ${this.propertyName} event`, event);
|
|
2362
2362
|
}
|
|
2363
2363
|
static create(props) {
|
|
2364
2364
|
const { propertyName, seedLocalId, uid } = props;
|
|
@@ -2494,7 +2494,7 @@ class ItemProperty {
|
|
|
2494
2494
|
}
|
|
2495
2495
|
unload() {
|
|
2496
2496
|
this._service.stop();
|
|
2497
|
-
logger$
|
|
2497
|
+
logger$h(`[XXXXXX] [ItemProperty] [${this.seedLocalId}] [unload] removing listener`, this._updateResponseEvent);
|
|
2498
2498
|
eventEmitter.removeListener(this._updateResponseEvent, this._updateResponseListener);
|
|
2499
2499
|
}
|
|
2500
2500
|
}
|
|
@@ -3783,7 +3783,7 @@ const getPropertiesForSeed = (seedLocalId, seedUid) => __awaiter(void 0, void 0,
|
|
|
3783
3783
|
return propertiesData;
|
|
3784
3784
|
});
|
|
3785
3785
|
|
|
3786
|
-
const logger$
|
|
3786
|
+
const logger$g = debug('app:db:queries:getItem');
|
|
3787
3787
|
const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName, seedLocalId, seedUid, }) {
|
|
3788
3788
|
if (!seedLocalId && !seedUid) {
|
|
3789
3789
|
throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
|
|
@@ -3791,7 +3791,7 @@ const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
3791
3791
|
if (seedUid && !seedLocalId) {
|
|
3792
3792
|
const seedData = yield getSeedData({ seedUid });
|
|
3793
3793
|
if (!seedData) {
|
|
3794
|
-
logger$
|
|
3794
|
+
logger$g('[db/queries] [getItem] no seedData seedUid', seedUid);
|
|
3795
3795
|
return;
|
|
3796
3796
|
}
|
|
3797
3797
|
seedLocalId = seedData.localId;
|
|
@@ -4219,7 +4219,7 @@ const fetchDbData = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4219
4219
|
return () => { };
|
|
4220
4220
|
});
|
|
4221
4221
|
|
|
4222
|
-
const logger$
|
|
4222
|
+
const logger$f = debug('app:allItemsActors:fetchSeeds');
|
|
4223
4223
|
const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
4224
4224
|
const { queryVariables, modelName } = context;
|
|
4225
4225
|
if (!queryVariables) {
|
|
@@ -4229,7 +4229,7 @@ const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4229
4229
|
const _fetchSeeds = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4230
4230
|
const queryKey = [`getSeeds${modelName}`];
|
|
4231
4231
|
const cachedResults = queryClient.getQueryData(queryKey);
|
|
4232
|
-
logger$
|
|
4232
|
+
logger$f(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
|
|
4233
4233
|
const results = yield queryClient.fetchQuery({
|
|
4234
4234
|
queryKey,
|
|
4235
4235
|
queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return easClient.request(GET_SEEDS, queryVariables); }),
|
|
@@ -4800,7 +4800,7 @@ const getArweave = () => {
|
|
|
4800
4800
|
});
|
|
4801
4801
|
};
|
|
4802
4802
|
|
|
4803
|
-
const logger$
|
|
4803
|
+
const logger$e = debug('app:react:db');
|
|
4804
4804
|
const useDbsAreReady = () => {
|
|
4805
4805
|
const [dbsAreReady, setDbsAreReady] = useState(false);
|
|
4806
4806
|
const update = useCallback(() => {
|
|
@@ -4816,7 +4816,7 @@ const useDbsAreReady = () => {
|
|
|
4816
4816
|
const globalService = getGlobalService();
|
|
4817
4817
|
const internalService = globalService.getSnapshot().context.internalService;
|
|
4818
4818
|
if (!internalService) {
|
|
4819
|
-
logger$
|
|
4819
|
+
logger$e('[useDbsAreReady] [useEffect] no internalService');
|
|
4820
4820
|
globalSubscription = globalService.subscribe(({ context }) => {
|
|
4821
4821
|
if (!internalSubscription && context && context.internalService) {
|
|
4822
4822
|
globalSubscription === null || globalSubscription === void 0 ? void 0 : globalSubscription.unsubscribe();
|
|
@@ -4857,6 +4857,7 @@ const useDbsAreReady = () => {
|
|
|
4857
4857
|
};
|
|
4858
4858
|
};
|
|
4859
4859
|
|
|
4860
|
+
const logger$d = debug('app:react:services');
|
|
4860
4861
|
const finalStrings = ['idle', 'ready', 'done', 'success'];
|
|
4861
4862
|
const getServiceName = (service) => {
|
|
4862
4863
|
let name = 'actor';
|
|
@@ -4900,8 +4901,8 @@ const getServiceUniqueKey = (service) => {
|
|
|
4900
4901
|
snapshot = service.getSnapshot();
|
|
4901
4902
|
}
|
|
4902
4903
|
catch (error) {
|
|
4903
|
-
|
|
4904
|
-
return;
|
|
4904
|
+
logger$d('Error:', error);
|
|
4905
|
+
return uniqueKey;
|
|
4905
4906
|
}
|
|
4906
4907
|
if (snapshot) {
|
|
4907
4908
|
const context = snapshot.context;
|
|
@@ -4990,7 +4991,7 @@ const useGlobalServiceStatus = () => {
|
|
|
4990
4991
|
};
|
|
4991
4992
|
};
|
|
4992
4993
|
|
|
4993
|
-
const logger$
|
|
4994
|
+
const logger$c = debug('app:react:item');
|
|
4994
4995
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
4995
4996
|
const [item, setItem] = useImmer(undefined);
|
|
4996
4997
|
const [itemSubscription, setItemSubscription] = useState();
|
|
@@ -5013,7 +5014,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
5013
5014
|
seedUid,
|
|
5014
5015
|
});
|
|
5015
5016
|
if (!foundItem) {
|
|
5016
|
-
logger$
|
|
5017
|
+
logger$c('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
5017
5018
|
return;
|
|
5018
5019
|
}
|
|
5019
5020
|
updateItem(foundItem);
|
|
@@ -5029,7 +5030,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
5029
5030
|
const subscription = item.subscribe((_) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5030
5031
|
const newItem = yield Item.find({ modelName, seedLocalId, seedUid });
|
|
5031
5032
|
if (!newItem) {
|
|
5032
|
-
logger$
|
|
5033
|
+
logger$c('[useItem] [itemSubscription] no item found', modelName, seedLocalId);
|
|
5033
5034
|
return;
|
|
5034
5035
|
}
|
|
5035
5036
|
setItem(() => newItem);
|
|
@@ -5157,12 +5158,12 @@ const useDeleteItem = () => {
|
|
|
5157
5158
|
};
|
|
5158
5159
|
};
|
|
5159
5160
|
|
|
5160
|
-
const logger$
|
|
5161
|
+
const logger$b = debug('app:react:property');
|
|
5161
5162
|
const useItemProperty = (propertyName, seedLocalId) => {
|
|
5162
5163
|
const [property, setProperty] = useImmer(undefined);
|
|
5163
5164
|
const [isReadingFromDb, setIsReadingFromDb] = useState(false);
|
|
5164
5165
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
5165
|
-
const dbsAreReady = useDbsAreReady();
|
|
5166
|
+
const { dbsAreReady } = useDbsAreReady();
|
|
5166
5167
|
const value = useSelector(property === null || property === void 0 ? void 0 : property.getService(), (snapshot) => {
|
|
5167
5168
|
if (!snapshot || !snapshot.context) {
|
|
5168
5169
|
return;
|
|
@@ -5183,7 +5184,7 @@ const useItemProperty = (propertyName, seedLocalId) => {
|
|
|
5183
5184
|
const foundProperty = yield ItemProperty.find({ propertyName, seedLocalId });
|
|
5184
5185
|
setIsReadingFromDb(false);
|
|
5185
5186
|
if (!foundProperty) {
|
|
5186
|
-
logger$
|
|
5187
|
+
logger$b(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
5187
5188
|
return;
|
|
5188
5189
|
}
|
|
5189
5190
|
setProperty(() => foundProperty);
|
|
@@ -5234,52 +5235,7 @@ const useItemProperties = (item) => {
|
|
|
5234
5235
|
};
|
|
5235
5236
|
};
|
|
5236
5237
|
|
|
5237
|
-
const logger$
|
|
5238
|
-
const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
5239
|
-
const { internalService, models, endpoints } = context;
|
|
5240
|
-
const { addresses } = event;
|
|
5241
|
-
let environment = 'browser';
|
|
5242
|
-
if (isNode()) {
|
|
5243
|
-
environment = 'node';
|
|
5244
|
-
}
|
|
5245
|
-
if (isReactNative()) {
|
|
5246
|
-
environment = 'react-native';
|
|
5247
|
-
}
|
|
5248
|
-
let internalSubscription;
|
|
5249
|
-
if (environment === 'browser' && models) {
|
|
5250
|
-
const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5251
|
-
return;
|
|
5252
|
-
// return new Promise((resolve) => {
|
|
5253
|
-
// })
|
|
5254
|
-
});
|
|
5255
|
-
const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5256
|
-
return new Promise((resolve) => {
|
|
5257
|
-
internalSubscription = internalService.subscribe((snapshot) => {
|
|
5258
|
-
logger$6('[sdk] [internal] snapshot', snapshot);
|
|
5259
|
-
if (snapshot.value === 'ready') {
|
|
5260
|
-
resolve();
|
|
5261
|
-
}
|
|
5262
|
-
});
|
|
5263
|
-
internalService.send({ type: 'init', endpoints, addresses });
|
|
5264
|
-
});
|
|
5265
|
-
});
|
|
5266
|
-
_initFileSystem().then(() => {
|
|
5267
|
-
logger$6('[global/actors] File system initialized');
|
|
5268
|
-
});
|
|
5269
|
-
_initInternal().then(() => {
|
|
5270
|
-
logger$6('[global/actors] Internal initialized');
|
|
5271
|
-
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
5272
|
-
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
5273
|
-
});
|
|
5274
|
-
// _initEas().then(() => {
|
|
5275
|
-
// logger('EAS initialized')
|
|
5276
|
-
// })
|
|
5277
|
-
}
|
|
5278
|
-
sendBack({ type: GLOBAL_INITIALIZING_SEND_CONFIG, environment });
|
|
5279
|
-
return () => {
|
|
5280
|
-
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
5281
|
-
};
|
|
5282
|
-
});
|
|
5238
|
+
const logger$a = debug('app:global:actors');
|
|
5283
5239
|
const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5284
5240
|
const { models: models$1 } = context;
|
|
5285
5241
|
const _addModelsToDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -5288,12 +5244,12 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5288
5244
|
if (!models$1) {
|
|
5289
5245
|
return;
|
|
5290
5246
|
}
|
|
5291
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
5247
|
+
const { models: SeedModels } = yield import('./seed.schema.config-DYkIbj49.js');
|
|
5292
5248
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
5293
5249
|
let hasModelsInDb = false;
|
|
5294
5250
|
const schemaDefsByModelName = new Map();
|
|
5295
5251
|
for (const [modelName, _] of Object.entries(allModels)) {
|
|
5296
|
-
logger$
|
|
5252
|
+
logger$a('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
|
|
5297
5253
|
let foundModel;
|
|
5298
5254
|
const foundModelsQuery = yield sdkConfigDb
|
|
5299
5255
|
.select()
|
|
@@ -5303,7 +5259,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5303
5259
|
yield sdkConfigDb.insert(models).values({
|
|
5304
5260
|
name: modelName,
|
|
5305
5261
|
});
|
|
5306
|
-
logger$
|
|
5262
|
+
logger$a('[global/actors] [addModelsToDb] inserted model:', modelName);
|
|
5307
5263
|
const foundModels = yield sdkConfigDb
|
|
5308
5264
|
.select({
|
|
5309
5265
|
id: models.id,
|
|
@@ -5387,11 +5343,186 @@ const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } })
|
|
|
5387
5343
|
if (!model) {
|
|
5388
5344
|
throw new Error(`Model ${modelName} not found`);
|
|
5389
5345
|
}
|
|
5390
|
-
logger$
|
|
5346
|
+
logger$a('[service/actor] [getSchemaForModel] model:', model);
|
|
5391
5347
|
sendBack({ type: 'schemaForModel', schema: model.schema });
|
|
5392
5348
|
return () => { };
|
|
5393
5349
|
});
|
|
5394
5350
|
|
|
5351
|
+
const logger$9 = debug('app:services:db:machine');
|
|
5352
|
+
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
5353
|
+
const dbMachine = setup({
|
|
5354
|
+
types: {
|
|
5355
|
+
context: {},
|
|
5356
|
+
input: {},
|
|
5357
|
+
},
|
|
5358
|
+
actors: {
|
|
5359
|
+
checkStatus,
|
|
5360
|
+
validate,
|
|
5361
|
+
connectToDb,
|
|
5362
|
+
migrate,
|
|
5363
|
+
},
|
|
5364
|
+
}).createMachine({
|
|
5365
|
+
id: MachineIds.DB,
|
|
5366
|
+
initial: CHECKING_STATUS,
|
|
5367
|
+
context: ({ input }) => input,
|
|
5368
|
+
on: {
|
|
5369
|
+
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
5370
|
+
actions: assign({
|
|
5371
|
+
hasFiles: ({ event }) => {
|
|
5372
|
+
logger$9('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
5373
|
+
return true;
|
|
5374
|
+
},
|
|
5375
|
+
}),
|
|
5376
|
+
},
|
|
5377
|
+
updateHasFiles: {
|
|
5378
|
+
target: `.${CHECKING_STATUS}`,
|
|
5379
|
+
actions: assign({
|
|
5380
|
+
hasFiles: ({ context, event }) => {
|
|
5381
|
+
logger$9('[db/machine] updateHasFiles event:', event);
|
|
5382
|
+
logger$9('[db/machine] updateHasFiles context:', context);
|
|
5383
|
+
return event.hasFiles;
|
|
5384
|
+
},
|
|
5385
|
+
}),
|
|
5386
|
+
},
|
|
5387
|
+
},
|
|
5388
|
+
// always: {
|
|
5389
|
+
// target: `.${CHECKING_STATUS}`,
|
|
5390
|
+
// guard: ({ context, event }) => context.hasFiles && event.type === 'updateHasFiles',
|
|
5391
|
+
// },
|
|
5392
|
+
states: {
|
|
5393
|
+
idle: {
|
|
5394
|
+
on: {
|
|
5395
|
+
start: CHECKING_STATUS,
|
|
5396
|
+
},
|
|
5397
|
+
meta: {
|
|
5398
|
+
displayText: 'DB starting ...',
|
|
5399
|
+
percentComplete: 0,
|
|
5400
|
+
},
|
|
5401
|
+
},
|
|
5402
|
+
[CHECKING_STATUS]: {
|
|
5403
|
+
on: {
|
|
5404
|
+
[DB_CHECK_STATUS_UPDATE_PATHS]: {
|
|
5405
|
+
actions: assign({
|
|
5406
|
+
pathToDb: ({ event }) => event.pathToDb,
|
|
5407
|
+
pathToDir: ({ event }) => event.pathToDir,
|
|
5408
|
+
pathToDbDir: ({ event }) => event.pathToDbDir,
|
|
5409
|
+
}),
|
|
5410
|
+
},
|
|
5411
|
+
[DB_CHECK_STATUS_EXISTS]: CONNECTING_TO_DB,
|
|
5412
|
+
},
|
|
5413
|
+
invoke: {
|
|
5414
|
+
src: 'checkStatus',
|
|
5415
|
+
input: ({ context, event }) => ({ context, event }),
|
|
5416
|
+
},
|
|
5417
|
+
meta: {
|
|
5418
|
+
displayText: 'Checking DB status',
|
|
5419
|
+
percentComplete: 60,
|
|
5420
|
+
},
|
|
5421
|
+
},
|
|
5422
|
+
[CONNECTING_TO_DB]: {
|
|
5423
|
+
on: {
|
|
5424
|
+
[DB_CREATING_SUCCESS]: {
|
|
5425
|
+
target: VALIDATING,
|
|
5426
|
+
actions: assign({
|
|
5427
|
+
dbId: ({ event }) => event.dbId,
|
|
5428
|
+
}),
|
|
5429
|
+
},
|
|
5430
|
+
},
|
|
5431
|
+
invoke: {
|
|
5432
|
+
src: 'connectToDb',
|
|
5433
|
+
input: ({ context }) => ({ context }),
|
|
5434
|
+
},
|
|
5435
|
+
meta: {
|
|
5436
|
+
displayText: 'Connecting to local DB',
|
|
5437
|
+
percentComplete: 70,
|
|
5438
|
+
},
|
|
5439
|
+
},
|
|
5440
|
+
[VALIDATING]: {
|
|
5441
|
+
on: {
|
|
5442
|
+
[DB_VALIDATING_SUCCESS]: {
|
|
5443
|
+
target: MIGRATING,
|
|
5444
|
+
// guard: ({ context }) => context.hasFiles,
|
|
5445
|
+
},
|
|
5446
|
+
[DB_VALIDATING_WAIT]: {
|
|
5447
|
+
target: WAITING_FOR_FILES,
|
|
5448
|
+
// guard: ({ context }) => !context.hasFiles,
|
|
5449
|
+
},
|
|
5450
|
+
},
|
|
5451
|
+
invoke: {
|
|
5452
|
+
src: 'validate',
|
|
5453
|
+
input: ({ context }) => ({ context }),
|
|
5454
|
+
},
|
|
5455
|
+
meta: {
|
|
5456
|
+
displayText: 'Validating DB',
|
|
5457
|
+
percentComplete: 80,
|
|
5458
|
+
},
|
|
5459
|
+
},
|
|
5460
|
+
// Here we're waiting for migration and schema files to be downloaded
|
|
5461
|
+
[WAITING_FOR_FILES]: {
|
|
5462
|
+
on: {
|
|
5463
|
+
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
5464
|
+
target: MIGRATING,
|
|
5465
|
+
actions: assign({
|
|
5466
|
+
hasFiles: true,
|
|
5467
|
+
}),
|
|
5468
|
+
},
|
|
5469
|
+
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
5470
|
+
},
|
|
5471
|
+
entry: ({ context }) => {
|
|
5472
|
+
if (context.hasFiles) {
|
|
5473
|
+
emit({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
5474
|
+
}
|
|
5475
|
+
},
|
|
5476
|
+
},
|
|
5477
|
+
[MIGRATING]: {
|
|
5478
|
+
on: {
|
|
5479
|
+
[DB_MIGRATING_WAIT]: WAITING_FOR_FILES,
|
|
5480
|
+
[DB_MIGRATING_SUCCESS]: {
|
|
5481
|
+
target: 'ready',
|
|
5482
|
+
},
|
|
5483
|
+
},
|
|
5484
|
+
invoke: {
|
|
5485
|
+
src: 'migrate',
|
|
5486
|
+
input: ({ context }) => ({ context }),
|
|
5487
|
+
},
|
|
5488
|
+
meta: {
|
|
5489
|
+
displayText: 'Migrating DB',
|
|
5490
|
+
percentComplete: 90,
|
|
5491
|
+
},
|
|
5492
|
+
},
|
|
5493
|
+
ready: {
|
|
5494
|
+
target: 'idle',
|
|
5495
|
+
meta: {
|
|
5496
|
+
displayText: 'Wrapping up the db ...',
|
|
5497
|
+
percentComplete: 100,
|
|
5498
|
+
},
|
|
5499
|
+
},
|
|
5500
|
+
},
|
|
5501
|
+
});
|
|
5502
|
+
|
|
5503
|
+
const validateInput = fromCallback(({ sendBack, input: { event } }) => {
|
|
5504
|
+
const { endpoints, addresses } = event;
|
|
5505
|
+
if (typeof window === 'undefined') {
|
|
5506
|
+
throw new Error('validateInput called from non-browser context');
|
|
5507
|
+
}
|
|
5508
|
+
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
5509
|
+
throw new Error('validateInput called with invalid endpoints');
|
|
5510
|
+
}
|
|
5511
|
+
if (!addresses || !addresses.length) {
|
|
5512
|
+
throw new Error('validateInput called with invalid addresses');
|
|
5513
|
+
}
|
|
5514
|
+
const _validateInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5515
|
+
sendBack({
|
|
5516
|
+
type: INTERNAL_VALIDATING_INPUT_SUCCESS,
|
|
5517
|
+
endpoints,
|
|
5518
|
+
addresses,
|
|
5519
|
+
});
|
|
5520
|
+
});
|
|
5521
|
+
_validateInput().then(() => {
|
|
5522
|
+
return;
|
|
5523
|
+
});
|
|
5524
|
+
});
|
|
5525
|
+
|
|
5395
5526
|
class SqliteConnectionManager {
|
|
5396
5527
|
constructor(sqliteModule, idleTimeout = 300000) {
|
|
5397
5528
|
// Default idle timeout: 5 minutes
|
|
@@ -5441,17 +5572,45 @@ class SqliteConnectionManager {
|
|
|
5441
5572
|
}
|
|
5442
5573
|
}
|
|
5443
5574
|
|
|
5444
|
-
const
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5575
|
+
const prepareDb = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
5576
|
+
let sqliteWasmClient;
|
|
5577
|
+
const _prepareDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5578
|
+
if (typeof window === 'undefined') {
|
|
5579
|
+
return;
|
|
5580
|
+
}
|
|
5581
|
+
sqliteWasmClient = yield getSqlite();
|
|
5582
|
+
});
|
|
5583
|
+
const interval = setInterval(() => {
|
|
5584
|
+
// TODO: Add a timeout
|
|
5585
|
+
// TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome
|
|
5586
|
+
if (sqliteWasmClient) {
|
|
5587
|
+
clearInterval(interval);
|
|
5588
|
+
const manager = new SqliteConnectionManager(sqliteWasmClient);
|
|
5589
|
+
sendBack({ type: 'prepareDbSuccess', manager });
|
|
5590
|
+
return;
|
|
5591
|
+
}
|
|
5592
|
+
_prepareDb().then(() => {
|
|
5593
|
+
return;
|
|
5594
|
+
});
|
|
5595
|
+
}, 200);
|
|
5596
|
+
return () => {
|
|
5597
|
+
if (interval) {
|
|
5598
|
+
clearInterval(interval);
|
|
5599
|
+
}
|
|
5600
|
+
};
|
|
5601
|
+
});
|
|
5602
|
+
|
|
5603
|
+
const logger$8 = debug('app:services:internal:helpers');
|
|
5604
|
+
/**
|
|
5605
|
+
* Recursively create directories if they don't exist.
|
|
5606
|
+
* @param {string} dirPath - The directory path to create.
|
|
5607
|
+
*/
|
|
5608
|
+
const createDirectories = (dirPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5609
|
+
const dirPathExists = yield fs.promises.exists(dirPath);
|
|
5610
|
+
if (dirPathExists) {
|
|
5611
|
+
return;
|
|
5612
|
+
}
|
|
5613
|
+
const parentDir = path.dirname(dirPath);
|
|
5455
5614
|
const parentDirExists = yield fs.promises.exists(parentDir);
|
|
5456
5615
|
if (!parentDirExists) {
|
|
5457
5616
|
yield createDirectories(parentDir);
|
|
@@ -5517,7 +5676,7 @@ const downloadFile = (url, localFilePath) => __awaiter(void 0, void 0, void 0, f
|
|
|
5517
5676
|
if (JSON.stringify(error).includes('File exists')) {
|
|
5518
5677
|
yield fs.promises.readFile(localFilePath, 'utf-8');
|
|
5519
5678
|
}
|
|
5520
|
-
logger$
|
|
5679
|
+
logger$8(`[Error] Failed to download file from ${url}:`, error);
|
|
5521
5680
|
}
|
|
5522
5681
|
busy = false;
|
|
5523
5682
|
});
|
|
@@ -5555,10 +5714,10 @@ const syncDbFiles = (_a) => __awaiter(void 0, [_a], void 0, function* ({ filePat
|
|
|
5555
5714
|
const fileList = yield fetchDirectory(filePaths);
|
|
5556
5715
|
yield fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList);
|
|
5557
5716
|
yield confirmFilesExist(fileList);
|
|
5558
|
-
logger$
|
|
5717
|
+
logger$8('[syncDbFiles] Files synced!');
|
|
5559
5718
|
});
|
|
5560
5719
|
|
|
5561
|
-
const logger$
|
|
5720
|
+
const logger$7 = debug('app:files:download');
|
|
5562
5721
|
const downloadAllFilesRequestHandler = (_a) => __awaiter(void 0, [_a], void 0, function* ({ endpoints, eventId, }) {
|
|
5563
5722
|
yield syncDbFiles(endpoints);
|
|
5564
5723
|
eventEmitter.emit('fs.downloadAll.success', { eventId });
|
|
@@ -5628,7 +5787,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5628
5787
|
try {
|
|
5629
5788
|
const res = yield fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
|
|
5630
5789
|
if (res.status !== 200) {
|
|
5631
|
-
logger$
|
|
5790
|
+
logger$7(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
5632
5791
|
excludedTransactions.add(transactionId);
|
|
5633
5792
|
yield writeAppState(seedDb, 'excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
5634
5793
|
continue;
|
|
@@ -5642,7 +5801,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5642
5801
|
console.error(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`, error);
|
|
5643
5802
|
});
|
|
5644
5803
|
if (!dataString) {
|
|
5645
|
-
logger$
|
|
5804
|
+
logger$7(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not found`);
|
|
5646
5805
|
}
|
|
5647
5806
|
let contentType = identifyString(dataString);
|
|
5648
5807
|
if (contentType !== 'json' &&
|
|
@@ -5650,7 +5809,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5650
5809
|
contentType !== 'html') {
|
|
5651
5810
|
const possibleImageType = getImageDataType(dataString);
|
|
5652
5811
|
if (!possibleImageType) {
|
|
5653
|
-
logger$
|
|
5812
|
+
logger$7(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`);
|
|
5654
5813
|
continue;
|
|
5655
5814
|
}
|
|
5656
5815
|
contentType = possibleImageType;
|
|
@@ -5713,7 +5872,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5713
5872
|
}
|
|
5714
5873
|
}
|
|
5715
5874
|
catch (error) {
|
|
5716
|
-
logger$
|
|
5875
|
+
logger$7(error);
|
|
5717
5876
|
}
|
|
5718
5877
|
}
|
|
5719
5878
|
});
|
|
@@ -5759,65 +5918,15 @@ const isFsInitialized = () => {
|
|
|
5759
5918
|
return isInitialized;
|
|
5760
5919
|
};
|
|
5761
5920
|
|
|
5762
|
-
const logger$
|
|
5763
|
-
let sqliteWasmClient;
|
|
5764
|
-
let manager;
|
|
5765
|
-
const validateInput = fromCallback(({ sendBack, input: { event } }) => {
|
|
5766
|
-
const { endpoints, addresses } = event;
|
|
5767
|
-
if (typeof window === 'undefined') {
|
|
5768
|
-
throw new Error('validateInput called from non-browser context');
|
|
5769
|
-
}
|
|
5770
|
-
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
5771
|
-
throw new Error('validateInput called with invalid endpoints');
|
|
5772
|
-
}
|
|
5773
|
-
if (!addresses || !addresses.length) {
|
|
5774
|
-
throw new Error('validateInput called with invalid addresses');
|
|
5775
|
-
}
|
|
5776
|
-
const _validateInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5777
|
-
sendBack({
|
|
5778
|
-
type: INTERNAL_VALIDATING_INPUT_SUCCESS,
|
|
5779
|
-
endpoints,
|
|
5780
|
-
addresses,
|
|
5781
|
-
});
|
|
5782
|
-
});
|
|
5783
|
-
_validateInput().then(() => {
|
|
5784
|
-
return;
|
|
5785
|
-
});
|
|
5786
|
-
});
|
|
5787
|
-
const prepareDb = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
5788
|
-
const _prepareDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5789
|
-
if (typeof window === 'undefined') {
|
|
5790
|
-
return;
|
|
5791
|
-
}
|
|
5792
|
-
sqliteWasmClient = yield getSqlite();
|
|
5793
|
-
});
|
|
5794
|
-
const interval = setInterval(() => {
|
|
5795
|
-
// TODO: Add a timeout
|
|
5796
|
-
// TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome
|
|
5797
|
-
if (sqliteWasmClient) {
|
|
5798
|
-
clearInterval(interval);
|
|
5799
|
-
manager = new SqliteConnectionManager(sqliteWasmClient);
|
|
5800
|
-
sendBack({ type: 'prepareDbSuccess', manager });
|
|
5801
|
-
return;
|
|
5802
|
-
}
|
|
5803
|
-
_prepareDb().then(() => {
|
|
5804
|
-
return;
|
|
5805
|
-
});
|
|
5806
|
-
}, 500);
|
|
5807
|
-
return () => {
|
|
5808
|
-
if (interval) {
|
|
5809
|
-
clearInterval(interval);
|
|
5810
|
-
}
|
|
5811
|
-
};
|
|
5812
|
-
});
|
|
5921
|
+
const logger$6 = debug('app:internal:actors:configureFs');
|
|
5813
5922
|
const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
5814
5923
|
const { endpoints, seedDbService, appDbService, sdkDbService } = context;
|
|
5815
|
-
logger$
|
|
5924
|
+
logger$6('[internal/actors] [configureFs] Configuring FS');
|
|
5816
5925
|
const services = [seedDbService, appDbService, sdkDbService];
|
|
5817
5926
|
const _configureFs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5818
|
-
logger$
|
|
5819
|
-
logger$
|
|
5820
|
-
logger$
|
|
5927
|
+
logger$6('[internal/actors] [configureFs] calling _configureFs');
|
|
5928
|
+
logger$6('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
|
|
5929
|
+
logger$6('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
|
|
5821
5930
|
yield waitForEvent({
|
|
5822
5931
|
req: {
|
|
5823
5932
|
eventLabel: 'fs.downloadAll.request',
|
|
@@ -5849,7 +5958,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5849
5958
|
// }, 200)
|
|
5850
5959
|
// })
|
|
5851
5960
|
})));
|
|
5852
|
-
logger$
|
|
5961
|
+
logger$6('[internal/actors] [configureFs] fs configured!');
|
|
5853
5962
|
});
|
|
5854
5963
|
// Some of our dependencies use fs sync functions, which don't work with
|
|
5855
5964
|
// OPFS. ZenFS creates an async cache of all files so that the sync functions
|
|
@@ -5861,6 +5970,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5861
5970
|
});
|
|
5862
5971
|
return () => { };
|
|
5863
5972
|
});
|
|
5973
|
+
|
|
5864
5974
|
const loadSeedDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5865
5975
|
const { seedDbService } = context;
|
|
5866
5976
|
if (seedDbService.getSnapshot().value === 'ready') {
|
|
@@ -5885,6 +5995,8 @@ const loadSeedDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5885
5995
|
}
|
|
5886
5996
|
};
|
|
5887
5997
|
});
|
|
5998
|
+
|
|
5999
|
+
const logger$5 = debug('app:services:internal:actors:saveConfig');
|
|
5888
6000
|
const saveConfig = fromCallback(({ sendBack, receive, input: { context } }) => {
|
|
5889
6001
|
if (typeof window === 'undefined') {
|
|
5890
6002
|
console.error('seedInitBrowser called from non-browser context');
|
|
@@ -5935,18 +6047,20 @@ const saveConfig = fromCallback(({ sendBack, receive, input: { context } }) => {
|
|
|
5935
6047
|
},
|
|
5936
6048
|
setWhere: sql `key = 'addresses'`,
|
|
5937
6049
|
});
|
|
5938
|
-
logger$
|
|
6050
|
+
logger$5('[sdk] [internal/actors] Should be done saving');
|
|
5939
6051
|
}
|
|
5940
6052
|
catch (error) {
|
|
5941
6053
|
console.error('Error saving config:', error);
|
|
5942
6054
|
}
|
|
5943
6055
|
});
|
|
5944
6056
|
_saveConfig().then(() => {
|
|
5945
|
-
logger$
|
|
6057
|
+
logger$5('[sdk] [internal/actors] Successfully saved config');
|
|
5946
6058
|
return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
|
|
5947
6059
|
});
|
|
5948
6060
|
return () => { };
|
|
5949
6061
|
});
|
|
6062
|
+
|
|
6063
|
+
const logger$4 = debug('app:services:internal:actors:loadAppDb');
|
|
5950
6064
|
const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5951
6065
|
const { appDbService } = context;
|
|
5952
6066
|
let subscription;
|
|
@@ -5967,7 +6081,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5967
6081
|
});
|
|
5968
6082
|
_loadAppDb().then(() => {
|
|
5969
6083
|
sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
|
|
5970
|
-
logger$
|
|
6084
|
+
logger$4('[sdk] [internal/actors] Successfully loaded app DB');
|
|
5971
6085
|
});
|
|
5972
6086
|
return () => {
|
|
5973
6087
|
if (subscription) {
|
|
@@ -5975,6 +6089,8 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5975
6089
|
}
|
|
5976
6090
|
};
|
|
5977
6091
|
});
|
|
6092
|
+
|
|
6093
|
+
const logger$3 = debug('app:internal:actors:loadSdkDb');
|
|
5978
6094
|
const loadSdkDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5979
6095
|
const { sdkDbService } = context;
|
|
5980
6096
|
logger$3('[sdk] [internal/actors] Loading SDK DB');
|
|
@@ -6009,159 +6125,7 @@ const loadSdkDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6009
6125
|
};
|
|
6010
6126
|
});
|
|
6011
6127
|
|
|
6012
|
-
const logger$2 = debug('app:services:
|
|
6013
|
-
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
6014
|
-
const dbMachine = setup({
|
|
6015
|
-
types: {
|
|
6016
|
-
context: {},
|
|
6017
|
-
input: {},
|
|
6018
|
-
},
|
|
6019
|
-
actors: {
|
|
6020
|
-
checkStatus,
|
|
6021
|
-
validate,
|
|
6022
|
-
connectToDb,
|
|
6023
|
-
migrate,
|
|
6024
|
-
},
|
|
6025
|
-
}).createMachine({
|
|
6026
|
-
id: MachineIds.DB,
|
|
6027
|
-
initial: CHECKING_STATUS,
|
|
6028
|
-
context: ({ input }) => input,
|
|
6029
|
-
on: {
|
|
6030
|
-
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
6031
|
-
actions: assign({
|
|
6032
|
-
hasFiles: ({ event }) => {
|
|
6033
|
-
logger$2('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
6034
|
-
return true;
|
|
6035
|
-
},
|
|
6036
|
-
}),
|
|
6037
|
-
},
|
|
6038
|
-
updateHasFiles: {
|
|
6039
|
-
target: `.${CHECKING_STATUS}`,
|
|
6040
|
-
actions: assign({
|
|
6041
|
-
hasFiles: ({ context, event }) => {
|
|
6042
|
-
logger$2('[db/machine] updateHasFiles event:', event);
|
|
6043
|
-
logger$2('[db/machine] updateHasFiles context:', context);
|
|
6044
|
-
return event.hasFiles;
|
|
6045
|
-
},
|
|
6046
|
-
}),
|
|
6047
|
-
},
|
|
6048
|
-
},
|
|
6049
|
-
// always: {
|
|
6050
|
-
// target: `.${CHECKING_STATUS}`,
|
|
6051
|
-
// guard: ({ context, event }) => context.hasFiles && event.type === 'updateHasFiles',
|
|
6052
|
-
// },
|
|
6053
|
-
states: {
|
|
6054
|
-
idle: {
|
|
6055
|
-
on: {
|
|
6056
|
-
start: CHECKING_STATUS,
|
|
6057
|
-
},
|
|
6058
|
-
meta: {
|
|
6059
|
-
displayText: 'DB starting ...',
|
|
6060
|
-
percentComplete: 0,
|
|
6061
|
-
},
|
|
6062
|
-
},
|
|
6063
|
-
[CHECKING_STATUS]: {
|
|
6064
|
-
on: {
|
|
6065
|
-
[DB_CHECK_STATUS_UPDATE_PATHS]: {
|
|
6066
|
-
actions: assign({
|
|
6067
|
-
pathToDb: ({ event }) => event.pathToDb,
|
|
6068
|
-
pathToDir: ({ event }) => event.pathToDir,
|
|
6069
|
-
pathToDbDir: ({ event }) => event.pathToDbDir,
|
|
6070
|
-
}),
|
|
6071
|
-
},
|
|
6072
|
-
[DB_CHECK_STATUS_EXISTS]: CONNECTING_TO_DB,
|
|
6073
|
-
},
|
|
6074
|
-
invoke: {
|
|
6075
|
-
src: 'checkStatus',
|
|
6076
|
-
input: ({ context, event }) => ({ context, event }),
|
|
6077
|
-
},
|
|
6078
|
-
meta: {
|
|
6079
|
-
displayText: 'Checking DB status',
|
|
6080
|
-
percentComplete: 60,
|
|
6081
|
-
},
|
|
6082
|
-
},
|
|
6083
|
-
[CONNECTING_TO_DB]: {
|
|
6084
|
-
on: {
|
|
6085
|
-
[DB_CREATING_SUCCESS]: {
|
|
6086
|
-
target: VALIDATING,
|
|
6087
|
-
actions: assign({
|
|
6088
|
-
dbId: ({ event }) => event.dbId,
|
|
6089
|
-
}),
|
|
6090
|
-
},
|
|
6091
|
-
},
|
|
6092
|
-
invoke: {
|
|
6093
|
-
src: 'connectToDb',
|
|
6094
|
-
input: ({ context }) => ({ context }),
|
|
6095
|
-
},
|
|
6096
|
-
meta: {
|
|
6097
|
-
displayText: 'Connecting to local DB',
|
|
6098
|
-
percentComplete: 70,
|
|
6099
|
-
},
|
|
6100
|
-
},
|
|
6101
|
-
[VALIDATING]: {
|
|
6102
|
-
on: {
|
|
6103
|
-
[DB_VALIDATING_SUCCESS]: {
|
|
6104
|
-
target: MIGRATING,
|
|
6105
|
-
// guard: ({ context }) => context.hasFiles,
|
|
6106
|
-
},
|
|
6107
|
-
[DB_VALIDATING_WAIT]: {
|
|
6108
|
-
target: WAITING_FOR_FILES,
|
|
6109
|
-
// guard: ({ context }) => !context.hasFiles,
|
|
6110
|
-
},
|
|
6111
|
-
},
|
|
6112
|
-
invoke: {
|
|
6113
|
-
src: 'validate',
|
|
6114
|
-
input: ({ context }) => ({ context }),
|
|
6115
|
-
},
|
|
6116
|
-
meta: {
|
|
6117
|
-
displayText: 'Validating DB',
|
|
6118
|
-
percentComplete: 80,
|
|
6119
|
-
},
|
|
6120
|
-
},
|
|
6121
|
-
// Here we're waiting for migration and schema files to be downloaded
|
|
6122
|
-
[WAITING_FOR_FILES]: {
|
|
6123
|
-
on: {
|
|
6124
|
-
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
6125
|
-
target: MIGRATING,
|
|
6126
|
-
actions: assign({
|
|
6127
|
-
hasFiles: true,
|
|
6128
|
-
}),
|
|
6129
|
-
},
|
|
6130
|
-
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
6131
|
-
},
|
|
6132
|
-
entry: ({ context }) => {
|
|
6133
|
-
if (context.hasFiles) {
|
|
6134
|
-
emit({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
6135
|
-
}
|
|
6136
|
-
},
|
|
6137
|
-
},
|
|
6138
|
-
[MIGRATING]: {
|
|
6139
|
-
on: {
|
|
6140
|
-
[DB_MIGRATING_WAIT]: WAITING_FOR_FILES,
|
|
6141
|
-
[DB_MIGRATING_SUCCESS]: {
|
|
6142
|
-
target: 'ready',
|
|
6143
|
-
},
|
|
6144
|
-
},
|
|
6145
|
-
invoke: {
|
|
6146
|
-
src: 'migrate',
|
|
6147
|
-
input: ({ context }) => ({ context }),
|
|
6148
|
-
},
|
|
6149
|
-
meta: {
|
|
6150
|
-
displayText: 'Migrating DB',
|
|
6151
|
-
percentComplete: 90,
|
|
6152
|
-
},
|
|
6153
|
-
},
|
|
6154
|
-
ready: {
|
|
6155
|
-
target: 'idle',
|
|
6156
|
-
meta: {
|
|
6157
|
-
displayText: 'Wrapping up the db ...',
|
|
6158
|
-
percentComplete: 100,
|
|
6159
|
-
},
|
|
6160
|
-
},
|
|
6161
|
-
},
|
|
6162
|
-
});
|
|
6163
|
-
|
|
6164
|
-
const logger$1 = debug('app:services:internal:machine');
|
|
6128
|
+
const logger$2 = debug('app:services:internal:machine');
|
|
6165
6129
|
createBrowserInspector({
|
|
6166
6130
|
autoStart: false,
|
|
6167
6131
|
});
|
|
@@ -6323,7 +6287,7 @@ const internalMachine = setup({
|
|
|
6323
6287
|
[INTERNAL_LOADING_APP_DB_SUCCESS]: {
|
|
6324
6288
|
target: 'appDbLoaded',
|
|
6325
6289
|
actions: () => {
|
|
6326
|
-
logger$
|
|
6290
|
+
logger$2('[sdk] [internal/index] App DB loaded!');
|
|
6327
6291
|
},
|
|
6328
6292
|
},
|
|
6329
6293
|
},
|
|
@@ -6335,7 +6299,7 @@ const internalMachine = setup({
|
|
|
6335
6299
|
appDbLoaded: {
|
|
6336
6300
|
type: 'final',
|
|
6337
6301
|
entry: () => {
|
|
6338
|
-
logger$
|
|
6302
|
+
logger$2('[sdk] [internal/index] Entered appDbLoaded!');
|
|
6339
6303
|
},
|
|
6340
6304
|
},
|
|
6341
6305
|
},
|
|
@@ -6348,7 +6312,7 @@ const internalMachine = setup({
|
|
|
6348
6312
|
[INTERNAL_LOADING_SDK_DB_SUCCESS]: {
|
|
6349
6313
|
target: 'sdkConfigDbLoaded',
|
|
6350
6314
|
actions: () => {
|
|
6351
|
-
logger$
|
|
6315
|
+
logger$2('[sdk] [internal/index] SDK Config DB loaded!');
|
|
6352
6316
|
},
|
|
6353
6317
|
},
|
|
6354
6318
|
},
|
|
@@ -6360,7 +6324,7 @@ const internalMachine = setup({
|
|
|
6360
6324
|
sdkConfigDbLoaded: {
|
|
6361
6325
|
type: 'final',
|
|
6362
6326
|
entry: () => {
|
|
6363
|
-
logger$
|
|
6327
|
+
logger$2('[sdk] [internal/index] Entered sdkConfigDbLoaded!');
|
|
6364
6328
|
},
|
|
6365
6329
|
},
|
|
6366
6330
|
},
|
|
@@ -6369,7 +6333,7 @@ const internalMachine = setup({
|
|
|
6369
6333
|
onDone: {
|
|
6370
6334
|
target: 'ready',
|
|
6371
6335
|
actions: () => {
|
|
6372
|
-
logger$
|
|
6336
|
+
logger$2('[sdk] [internal/index] All DBs loaded! Should be headed to ready');
|
|
6373
6337
|
eventEmitter.emit('allDbsLoaded');
|
|
6374
6338
|
},
|
|
6375
6339
|
},
|
|
@@ -6381,7 +6345,7 @@ const internalMachine = setup({
|
|
|
6381
6345
|
},
|
|
6382
6346
|
ready: {
|
|
6383
6347
|
entry: () => {
|
|
6384
|
-
logger$
|
|
6348
|
+
logger$2('[sdk] [internal/index] Ready!');
|
|
6385
6349
|
},
|
|
6386
6350
|
meta: {
|
|
6387
6351
|
displayText: "Crossing the t's ...",
|
|
@@ -6396,7 +6360,7 @@ const internalMachine = setup({
|
|
|
6396
6360
|
},
|
|
6397
6361
|
},
|
|
6398
6362
|
entry: () => {
|
|
6399
|
-
logger$
|
|
6363
|
+
logger$2('[sdk] [internal/index] Error!');
|
|
6400
6364
|
},
|
|
6401
6365
|
meta: {
|
|
6402
6366
|
displayText: 'Whoops! Something went wrong.',
|
|
@@ -6407,6 +6371,53 @@ const internalMachine = setup({
|
|
|
6407
6371
|
},
|
|
6408
6372
|
});
|
|
6409
6373
|
|
|
6374
|
+
const logger$1 = debug('app:global:actors');
|
|
6375
|
+
const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
6376
|
+
const { internalService, models, endpoints } = context;
|
|
6377
|
+
const { addresses } = event;
|
|
6378
|
+
let environment = 'browser';
|
|
6379
|
+
if (isNode()) {
|
|
6380
|
+
environment = 'node';
|
|
6381
|
+
}
|
|
6382
|
+
if (isReactNative()) {
|
|
6383
|
+
environment = 'react-native';
|
|
6384
|
+
}
|
|
6385
|
+
let internalSubscription;
|
|
6386
|
+
if (environment === 'browser' && models) {
|
|
6387
|
+
const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6388
|
+
return;
|
|
6389
|
+
// return new Promise((resolve) => {
|
|
6390
|
+
// })
|
|
6391
|
+
});
|
|
6392
|
+
const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6393
|
+
return new Promise((resolve) => {
|
|
6394
|
+
internalSubscription = internalService.subscribe((snapshot) => {
|
|
6395
|
+
logger$1('[sdk] [internal] snapshot', snapshot);
|
|
6396
|
+
if (snapshot.value === 'ready') {
|
|
6397
|
+
resolve();
|
|
6398
|
+
}
|
|
6399
|
+
});
|
|
6400
|
+
internalService.send({ type: 'init', endpoints, addresses });
|
|
6401
|
+
});
|
|
6402
|
+
});
|
|
6403
|
+
_initFileSystem().then(() => {
|
|
6404
|
+
logger$1('[global/actors] File system initialized');
|
|
6405
|
+
});
|
|
6406
|
+
_initInternal().then(() => {
|
|
6407
|
+
logger$1('[global/actors] Internal initialized');
|
|
6408
|
+
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
6409
|
+
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
6410
|
+
});
|
|
6411
|
+
// _initEas().then(() => {
|
|
6412
|
+
// logger('EAS initialized')
|
|
6413
|
+
// })
|
|
6414
|
+
}
|
|
6415
|
+
sendBack({ type: GLOBAL_INITIALIZING_SEND_CONFIG, environment });
|
|
6416
|
+
return () => {
|
|
6417
|
+
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
6418
|
+
};
|
|
6419
|
+
});
|
|
6420
|
+
|
|
6410
6421
|
const { UNINITIALIZED, INITIALIZING, INITIALIZED, GETTING_SEED_CLASS, GETTING_SCHEMA_FOR_MODEL, ADDING_MODELS_TO_DB, } = GlobalState;
|
|
6411
6422
|
createBrowserInspector({
|
|
6412
6423
|
autoStart: false,
|
|
@@ -6538,11 +6549,11 @@ const globalMachine = setup({
|
|
|
6538
6549
|
(_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
|
|
6539
6550
|
let SeedClass;
|
|
6540
6551
|
if (context.environment === 'node') {
|
|
6541
|
-
const { SeedNode } = yield import('./seed-
|
|
6552
|
+
const { SeedNode } = yield import('./seed-DGCfCUOn.js');
|
|
6542
6553
|
SeedClass = SeedNode;
|
|
6543
6554
|
}
|
|
6544
6555
|
else {
|
|
6545
|
-
const { SeedBrowser } = yield import('./seed-
|
|
6556
|
+
const { SeedBrowser } = yield import('./seed-BgRaREFr.js');
|
|
6546
6557
|
SeedClass = SeedBrowser;
|
|
6547
6558
|
}
|
|
6548
6559
|
return SeedClass;
|
|
@@ -6647,4 +6658,4 @@ const setupServicesEventHandlers = () => {
|
|
|
6647
6658
|
};
|
|
6648
6659
|
|
|
6649
6660
|
export { useDeleteItem as $, APP_DB_CONFIG as A, setupFsListeners as B, CHILD_SNAPSHOT as C, DB_NAME_SDK_CONFIG as D, setupAllItemsEventHandlers as E, setupServicesEventHandlers as F, GET_SCHEMAS as G, globalService as H, Item as I, Json as J, getModel as K, List as L, Model as M, getModels as N, getModelNames as O, Property as P, areFsListenersReady as Q, Relation as R, SCHEMA_NJK as S, Text as T, ItemProperty as U, useItems as V, useItem as W, useItemProperties as X, useCreateItem as Y, useItemProperty as Z, __awaiter as _, GET_SEEDS as a, useServices as a0, getGlobalService as a1, getCorrectId as a2, 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, __decorate as m, __metadata as n, models as o, SCHEMA_TS as p, SDK_DB_CONFIG as q, SEED_DB_CONFIG as r, addModelsToInternalDb as s, ImageSrc as t, createNewMetadataFromExistingRecord as u, generateId as v, eventEmitter as w, getDb as x, DB_NAME_APP as y, setModel as z };
|
|
6650
|
-
//# sourceMappingURL=events-
|
|
6661
|
+
//# sourceMappingURL=events-So24__c6.js.map
|