@seedprotocol/sdk 0.1.15 → 0.1.17
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-DgKqHqww.js → events-CRCYmF7M.js} +366 -346
- package/dist/events-CRCYmF7M.js.map +1 -0
- package/dist/{index-CckG4Nv5.js → index-DR_FgAUY.js} +16 -16
- package/dist/index-DR_FgAUY.js.map +1 -0
- package/dist/main.js +12 -12
- package/dist/{seed-C8JBI4UL.js → seed-BJPS_-pY.js} +17 -17
- package/dist/{seed-C8JBI4UL.js.map → seed-BJPS_-pY.js.map} +1 -1
- package/dist/{seed-CJB6INNH.js → seed-CjMH4SeR.js} +16 -16
- package/dist/{seed-CJB6INNH.js.map → seed-CjMH4SeR.js.map} +1 -1
- package/dist/{seed-z1eQdEXy.js → seed-Dn2R3xbp.js} +2 -2
- package/dist/{seed-z1eQdEXy.js.map → seed-Dn2R3xbp.js.map} +1 -1
- package/dist/{seed.schema.config-C9CEFOxM.js → seed.schema.config-GKCk8sOV.js} +6 -6
- package/dist/{seed.schema.config-C9CEFOxM.js.map → seed.schema.config-GKCk8sOV.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 +3 -2
- package/dist/events-DgKqHqww.js.map +0 -1
- package/dist/index-CckG4Nv5.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$k = 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$k('[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$k('[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$k(response);
|
|
271
|
+
logger$k('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$k(response);
|
|
277
277
|
dbId = response.dbId;
|
|
278
278
|
// logger(`dbId: ${dbId}`)
|
|
279
|
-
logger$
|
|
279
|
+
logger$k('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$k('[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$j = 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$j(`[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$i = 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$i(`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$i(`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$i(`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$i(`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$i(`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-DR_FgAUY.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$i('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$h = 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$h(`[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$h(`[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$g = 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$g('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$g(`[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$g(`[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$f = 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$f('[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$e = 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$e(`[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$d = 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$d('[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();
|
|
@@ -4895,7 +4895,14 @@ const getServiceUniqueKey = (service) => {
|
|
|
4895
4895
|
if (config.id.includes('@seedSdk/')) {
|
|
4896
4896
|
uniqueKey = config.id.match(/^.*@seedSdk\/(\w+)[\.\w]*/)[1];
|
|
4897
4897
|
}
|
|
4898
|
-
|
|
4898
|
+
let snapshot;
|
|
4899
|
+
try {
|
|
4900
|
+
snapshot = service.getSnapshot();
|
|
4901
|
+
}
|
|
4902
|
+
catch (error) {
|
|
4903
|
+
console.error('Error:', error);
|
|
4904
|
+
return;
|
|
4905
|
+
}
|
|
4899
4906
|
if (snapshot) {
|
|
4900
4907
|
const context = snapshot.context;
|
|
4901
4908
|
if (context && context.dbName) {
|
|
@@ -4916,6 +4923,9 @@ const useServices = () => {
|
|
|
4916
4923
|
const actorsMap = new Map();
|
|
4917
4924
|
useEffect(() => {
|
|
4918
4925
|
const globalServiceListener = (event) => {
|
|
4926
|
+
if (event && event.type === 'init') {
|
|
4927
|
+
return;
|
|
4928
|
+
}
|
|
4919
4929
|
if (event.actorRef &&
|
|
4920
4930
|
event.actorRef.logic &&
|
|
4921
4931
|
event.actorRef.logic.config) {
|
|
@@ -4980,7 +4990,7 @@ const useGlobalServiceStatus = () => {
|
|
|
4980
4990
|
};
|
|
4981
4991
|
};
|
|
4982
4992
|
|
|
4983
|
-
const logger$
|
|
4993
|
+
const logger$c = debug('app:react:item');
|
|
4984
4994
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
4985
4995
|
const [item, setItem] = useImmer(undefined);
|
|
4986
4996
|
const [itemSubscription, setItemSubscription] = useState();
|
|
@@ -5003,7 +5013,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
5003
5013
|
seedUid,
|
|
5004
5014
|
});
|
|
5005
5015
|
if (!foundItem) {
|
|
5006
|
-
logger$
|
|
5016
|
+
logger$c('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
5007
5017
|
return;
|
|
5008
5018
|
}
|
|
5009
5019
|
updateItem(foundItem);
|
|
@@ -5019,7 +5029,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
5019
5029
|
const subscription = item.subscribe((_) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5020
5030
|
const newItem = yield Item.find({ modelName, seedLocalId, seedUid });
|
|
5021
5031
|
if (!newItem) {
|
|
5022
|
-
logger$
|
|
5032
|
+
logger$c('[useItem] [itemSubscription] no item found', modelName, seedLocalId);
|
|
5023
5033
|
return;
|
|
5024
5034
|
}
|
|
5025
5035
|
setItem(() => newItem);
|
|
@@ -5147,7 +5157,7 @@ const useDeleteItem = () => {
|
|
|
5147
5157
|
};
|
|
5148
5158
|
};
|
|
5149
5159
|
|
|
5150
|
-
const logger$
|
|
5160
|
+
const logger$b = debug('app:react:property');
|
|
5151
5161
|
const useItemProperty = (propertyName, seedLocalId) => {
|
|
5152
5162
|
const [property, setProperty] = useImmer(undefined);
|
|
5153
5163
|
const [isReadingFromDb, setIsReadingFromDb] = useState(false);
|
|
@@ -5173,7 +5183,7 @@ const useItemProperty = (propertyName, seedLocalId) => {
|
|
|
5173
5183
|
const foundProperty = yield ItemProperty.find({ propertyName, seedLocalId });
|
|
5174
5184
|
setIsReadingFromDb(false);
|
|
5175
5185
|
if (!foundProperty) {
|
|
5176
|
-
logger$
|
|
5186
|
+
logger$b(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
5177
5187
|
return;
|
|
5178
5188
|
}
|
|
5179
5189
|
setProperty(() => foundProperty);
|
|
@@ -5224,52 +5234,7 @@ const useItemProperties = (item) => {
|
|
|
5224
5234
|
};
|
|
5225
5235
|
};
|
|
5226
5236
|
|
|
5227
|
-
const logger$
|
|
5228
|
-
const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
5229
|
-
const { internalService, models, endpoints } = context;
|
|
5230
|
-
const { addresses } = event;
|
|
5231
|
-
let environment = 'browser';
|
|
5232
|
-
if (isNode()) {
|
|
5233
|
-
environment = 'node';
|
|
5234
|
-
}
|
|
5235
|
-
if (isReactNative()) {
|
|
5236
|
-
environment = 'react-native';
|
|
5237
|
-
}
|
|
5238
|
-
let internalSubscription;
|
|
5239
|
-
if (environment === 'browser' && models) {
|
|
5240
|
-
const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5241
|
-
return;
|
|
5242
|
-
// return new Promise((resolve) => {
|
|
5243
|
-
// })
|
|
5244
|
-
});
|
|
5245
|
-
const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5246
|
-
return new Promise((resolve) => {
|
|
5247
|
-
internalSubscription = internalService.subscribe((snapshot) => {
|
|
5248
|
-
logger$6('[sdk] [internal] snapshot', snapshot);
|
|
5249
|
-
if (snapshot.value === 'ready') {
|
|
5250
|
-
resolve();
|
|
5251
|
-
}
|
|
5252
|
-
});
|
|
5253
|
-
internalService.send({ type: 'init', endpoints, addresses });
|
|
5254
|
-
});
|
|
5255
|
-
});
|
|
5256
|
-
_initFileSystem().then(() => {
|
|
5257
|
-
logger$6('[global/actors] File system initialized');
|
|
5258
|
-
});
|
|
5259
|
-
_initInternal().then(() => {
|
|
5260
|
-
logger$6('[global/actors] Internal initialized');
|
|
5261
|
-
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
5262
|
-
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
5263
|
-
});
|
|
5264
|
-
// _initEas().then(() => {
|
|
5265
|
-
// logger('EAS initialized')
|
|
5266
|
-
// })
|
|
5267
|
-
}
|
|
5268
|
-
sendBack({ type: GLOBAL_INITIALIZING_SEND_CONFIG, environment });
|
|
5269
|
-
return () => {
|
|
5270
|
-
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
5271
|
-
};
|
|
5272
|
-
});
|
|
5237
|
+
const logger$a = debug('app:global:actors');
|
|
5273
5238
|
const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5274
5239
|
const { models: models$1 } = context;
|
|
5275
5240
|
const _addModelsToDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -5278,12 +5243,12 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5278
5243
|
if (!models$1) {
|
|
5279
5244
|
return;
|
|
5280
5245
|
}
|
|
5281
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
5246
|
+
const { models: SeedModels } = yield import('./seed.schema.config-GKCk8sOV.js');
|
|
5282
5247
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
5283
5248
|
let hasModelsInDb = false;
|
|
5284
5249
|
const schemaDefsByModelName = new Map();
|
|
5285
5250
|
for (const [modelName, _] of Object.entries(allModels)) {
|
|
5286
|
-
logger$
|
|
5251
|
+
logger$a('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
|
|
5287
5252
|
let foundModel;
|
|
5288
5253
|
const foundModelsQuery = yield sdkConfigDb
|
|
5289
5254
|
.select()
|
|
@@ -5293,7 +5258,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5293
5258
|
yield sdkConfigDb.insert(models).values({
|
|
5294
5259
|
name: modelName,
|
|
5295
5260
|
});
|
|
5296
|
-
logger$
|
|
5261
|
+
logger$a('[global/actors] [addModelsToDb] inserted model:', modelName);
|
|
5297
5262
|
const foundModels = yield sdkConfigDb
|
|
5298
5263
|
.select({
|
|
5299
5264
|
id: models.id,
|
|
@@ -5377,11 +5342,186 @@ const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } })
|
|
|
5377
5342
|
if (!model) {
|
|
5378
5343
|
throw new Error(`Model ${modelName} not found`);
|
|
5379
5344
|
}
|
|
5380
|
-
logger$
|
|
5345
|
+
logger$a('[service/actor] [getSchemaForModel] model:', model);
|
|
5381
5346
|
sendBack({ type: 'schemaForModel', schema: model.schema });
|
|
5382
5347
|
return () => { };
|
|
5383
5348
|
});
|
|
5384
5349
|
|
|
5350
|
+
const logger$9 = debug('app:services:db:machine');
|
|
5351
|
+
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
5352
|
+
const dbMachine = setup({
|
|
5353
|
+
types: {
|
|
5354
|
+
context: {},
|
|
5355
|
+
input: {},
|
|
5356
|
+
},
|
|
5357
|
+
actors: {
|
|
5358
|
+
checkStatus,
|
|
5359
|
+
validate,
|
|
5360
|
+
connectToDb,
|
|
5361
|
+
migrate,
|
|
5362
|
+
},
|
|
5363
|
+
}).createMachine({
|
|
5364
|
+
id: MachineIds.DB,
|
|
5365
|
+
initial: CHECKING_STATUS,
|
|
5366
|
+
context: ({ input }) => input,
|
|
5367
|
+
on: {
|
|
5368
|
+
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
5369
|
+
actions: assign({
|
|
5370
|
+
hasFiles: ({ event }) => {
|
|
5371
|
+
logger$9('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
5372
|
+
return true;
|
|
5373
|
+
},
|
|
5374
|
+
}),
|
|
5375
|
+
},
|
|
5376
|
+
updateHasFiles: {
|
|
5377
|
+
target: `.${CHECKING_STATUS}`,
|
|
5378
|
+
actions: assign({
|
|
5379
|
+
hasFiles: ({ context, event }) => {
|
|
5380
|
+
logger$9('[db/machine] updateHasFiles event:', event);
|
|
5381
|
+
logger$9('[db/machine] updateHasFiles context:', context);
|
|
5382
|
+
return event.hasFiles;
|
|
5383
|
+
},
|
|
5384
|
+
}),
|
|
5385
|
+
},
|
|
5386
|
+
},
|
|
5387
|
+
// always: {
|
|
5388
|
+
// target: `.${CHECKING_STATUS}`,
|
|
5389
|
+
// guard: ({ context, event }) => context.hasFiles && event.type === 'updateHasFiles',
|
|
5390
|
+
// },
|
|
5391
|
+
states: {
|
|
5392
|
+
idle: {
|
|
5393
|
+
on: {
|
|
5394
|
+
start: CHECKING_STATUS,
|
|
5395
|
+
},
|
|
5396
|
+
meta: {
|
|
5397
|
+
displayText: 'DB starting ...',
|
|
5398
|
+
percentComplete: 0,
|
|
5399
|
+
},
|
|
5400
|
+
},
|
|
5401
|
+
[CHECKING_STATUS]: {
|
|
5402
|
+
on: {
|
|
5403
|
+
[DB_CHECK_STATUS_UPDATE_PATHS]: {
|
|
5404
|
+
actions: assign({
|
|
5405
|
+
pathToDb: ({ event }) => event.pathToDb,
|
|
5406
|
+
pathToDir: ({ event }) => event.pathToDir,
|
|
5407
|
+
pathToDbDir: ({ event }) => event.pathToDbDir,
|
|
5408
|
+
}),
|
|
5409
|
+
},
|
|
5410
|
+
[DB_CHECK_STATUS_EXISTS]: CONNECTING_TO_DB,
|
|
5411
|
+
},
|
|
5412
|
+
invoke: {
|
|
5413
|
+
src: 'checkStatus',
|
|
5414
|
+
input: ({ context, event }) => ({ context, event }),
|
|
5415
|
+
},
|
|
5416
|
+
meta: {
|
|
5417
|
+
displayText: 'Checking DB status',
|
|
5418
|
+
percentComplete: 60,
|
|
5419
|
+
},
|
|
5420
|
+
},
|
|
5421
|
+
[CONNECTING_TO_DB]: {
|
|
5422
|
+
on: {
|
|
5423
|
+
[DB_CREATING_SUCCESS]: {
|
|
5424
|
+
target: VALIDATING,
|
|
5425
|
+
actions: assign({
|
|
5426
|
+
dbId: ({ event }) => event.dbId,
|
|
5427
|
+
}),
|
|
5428
|
+
},
|
|
5429
|
+
},
|
|
5430
|
+
invoke: {
|
|
5431
|
+
src: 'connectToDb',
|
|
5432
|
+
input: ({ context }) => ({ context }),
|
|
5433
|
+
},
|
|
5434
|
+
meta: {
|
|
5435
|
+
displayText: 'Connecting to local DB',
|
|
5436
|
+
percentComplete: 70,
|
|
5437
|
+
},
|
|
5438
|
+
},
|
|
5439
|
+
[VALIDATING]: {
|
|
5440
|
+
on: {
|
|
5441
|
+
[DB_VALIDATING_SUCCESS]: {
|
|
5442
|
+
target: MIGRATING,
|
|
5443
|
+
// guard: ({ context }) => context.hasFiles,
|
|
5444
|
+
},
|
|
5445
|
+
[DB_VALIDATING_WAIT]: {
|
|
5446
|
+
target: WAITING_FOR_FILES,
|
|
5447
|
+
// guard: ({ context }) => !context.hasFiles,
|
|
5448
|
+
},
|
|
5449
|
+
},
|
|
5450
|
+
invoke: {
|
|
5451
|
+
src: 'validate',
|
|
5452
|
+
input: ({ context }) => ({ context }),
|
|
5453
|
+
},
|
|
5454
|
+
meta: {
|
|
5455
|
+
displayText: 'Validating DB',
|
|
5456
|
+
percentComplete: 80,
|
|
5457
|
+
},
|
|
5458
|
+
},
|
|
5459
|
+
// Here we're waiting for migration and schema files to be downloaded
|
|
5460
|
+
[WAITING_FOR_FILES]: {
|
|
5461
|
+
on: {
|
|
5462
|
+
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
5463
|
+
target: MIGRATING,
|
|
5464
|
+
actions: assign({
|
|
5465
|
+
hasFiles: true,
|
|
5466
|
+
}),
|
|
5467
|
+
},
|
|
5468
|
+
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
5469
|
+
},
|
|
5470
|
+
entry: ({ context }) => {
|
|
5471
|
+
if (context.hasFiles) {
|
|
5472
|
+
emit({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
5473
|
+
}
|
|
5474
|
+
},
|
|
5475
|
+
},
|
|
5476
|
+
[MIGRATING]: {
|
|
5477
|
+
on: {
|
|
5478
|
+
[DB_MIGRATING_WAIT]: WAITING_FOR_FILES,
|
|
5479
|
+
[DB_MIGRATING_SUCCESS]: {
|
|
5480
|
+
target: 'ready',
|
|
5481
|
+
},
|
|
5482
|
+
},
|
|
5483
|
+
invoke: {
|
|
5484
|
+
src: 'migrate',
|
|
5485
|
+
input: ({ context }) => ({ context }),
|
|
5486
|
+
},
|
|
5487
|
+
meta: {
|
|
5488
|
+
displayText: 'Migrating DB',
|
|
5489
|
+
percentComplete: 90,
|
|
5490
|
+
},
|
|
5491
|
+
},
|
|
5492
|
+
ready: {
|
|
5493
|
+
target: 'idle',
|
|
5494
|
+
meta: {
|
|
5495
|
+
displayText: 'Wrapping up the db ...',
|
|
5496
|
+
percentComplete: 100,
|
|
5497
|
+
},
|
|
5498
|
+
},
|
|
5499
|
+
},
|
|
5500
|
+
});
|
|
5501
|
+
|
|
5502
|
+
const validateInput = fromCallback(({ sendBack, input: { event } }) => {
|
|
5503
|
+
const { endpoints, addresses } = event;
|
|
5504
|
+
if (typeof window === 'undefined') {
|
|
5505
|
+
throw new Error('validateInput called from non-browser context');
|
|
5506
|
+
}
|
|
5507
|
+
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
5508
|
+
throw new Error('validateInput called with invalid endpoints');
|
|
5509
|
+
}
|
|
5510
|
+
if (!addresses || !addresses.length) {
|
|
5511
|
+
throw new Error('validateInput called with invalid addresses');
|
|
5512
|
+
}
|
|
5513
|
+
const _validateInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5514
|
+
sendBack({
|
|
5515
|
+
type: INTERNAL_VALIDATING_INPUT_SUCCESS,
|
|
5516
|
+
endpoints,
|
|
5517
|
+
addresses,
|
|
5518
|
+
});
|
|
5519
|
+
});
|
|
5520
|
+
_validateInput().then(() => {
|
|
5521
|
+
return;
|
|
5522
|
+
});
|
|
5523
|
+
});
|
|
5524
|
+
|
|
5385
5525
|
class SqliteConnectionManager {
|
|
5386
5526
|
constructor(sqliteModule, idleTimeout = 300000) {
|
|
5387
5527
|
// Default idle timeout: 5 minutes
|
|
@@ -5431,12 +5571,40 @@ class SqliteConnectionManager {
|
|
|
5431
5571
|
}
|
|
5432
5572
|
}
|
|
5433
5573
|
|
|
5434
|
-
const
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5574
|
+
const prepareDb = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
5575
|
+
let sqliteWasmClient;
|
|
5576
|
+
const _prepareDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5577
|
+
if (typeof window === 'undefined') {
|
|
5578
|
+
return;
|
|
5579
|
+
}
|
|
5580
|
+
sqliteWasmClient = yield getSqlite();
|
|
5581
|
+
});
|
|
5582
|
+
const interval = setInterval(() => {
|
|
5583
|
+
// TODO: Add a timeout
|
|
5584
|
+
// TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome
|
|
5585
|
+
if (sqliteWasmClient) {
|
|
5586
|
+
clearInterval(interval);
|
|
5587
|
+
const manager = new SqliteConnectionManager(sqliteWasmClient);
|
|
5588
|
+
sendBack({ type: 'prepareDbSuccess', manager });
|
|
5589
|
+
return;
|
|
5590
|
+
}
|
|
5591
|
+
_prepareDb().then(() => {
|
|
5592
|
+
return;
|
|
5593
|
+
});
|
|
5594
|
+
}, 200);
|
|
5595
|
+
return () => {
|
|
5596
|
+
if (interval) {
|
|
5597
|
+
clearInterval(interval);
|
|
5598
|
+
}
|
|
5599
|
+
};
|
|
5600
|
+
});
|
|
5601
|
+
|
|
5602
|
+
const logger$8 = debug('app:services:internal:helpers');
|
|
5603
|
+
/**
|
|
5604
|
+
* Recursively create directories if they don't exist.
|
|
5605
|
+
* @param {string} dirPath - The directory path to create.
|
|
5606
|
+
*/
|
|
5607
|
+
const createDirectories = (dirPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5440
5608
|
const dirPathExists = yield fs.promises.exists(dirPath);
|
|
5441
5609
|
if (dirPathExists) {
|
|
5442
5610
|
return;
|
|
@@ -5507,7 +5675,7 @@ const downloadFile = (url, localFilePath) => __awaiter(void 0, void 0, void 0, f
|
|
|
5507
5675
|
if (JSON.stringify(error).includes('File exists')) {
|
|
5508
5676
|
yield fs.promises.readFile(localFilePath, 'utf-8');
|
|
5509
5677
|
}
|
|
5510
|
-
logger$
|
|
5678
|
+
logger$8(`[Error] Failed to download file from ${url}:`, error);
|
|
5511
5679
|
}
|
|
5512
5680
|
busy = false;
|
|
5513
5681
|
});
|
|
@@ -5545,10 +5713,10 @@ const syncDbFiles = (_a) => __awaiter(void 0, [_a], void 0, function* ({ filePat
|
|
|
5545
5713
|
const fileList = yield fetchDirectory(filePaths);
|
|
5546
5714
|
yield fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList);
|
|
5547
5715
|
yield confirmFilesExist(fileList);
|
|
5548
|
-
logger$
|
|
5716
|
+
logger$8('[syncDbFiles] Files synced!');
|
|
5549
5717
|
});
|
|
5550
5718
|
|
|
5551
|
-
const logger$
|
|
5719
|
+
const logger$7 = debug('app:files:download');
|
|
5552
5720
|
const downloadAllFilesRequestHandler = (_a) => __awaiter(void 0, [_a], void 0, function* ({ endpoints, eventId, }) {
|
|
5553
5721
|
yield syncDbFiles(endpoints);
|
|
5554
5722
|
eventEmitter.emit('fs.downloadAll.success', { eventId });
|
|
@@ -5618,7 +5786,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5618
5786
|
try {
|
|
5619
5787
|
const res = yield fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
|
|
5620
5788
|
if (res.status !== 200) {
|
|
5621
|
-
logger$
|
|
5789
|
+
logger$7(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
5622
5790
|
excludedTransactions.add(transactionId);
|
|
5623
5791
|
yield writeAppState(seedDb, 'excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
5624
5792
|
continue;
|
|
@@ -5632,7 +5800,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5632
5800
|
console.error(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`, error);
|
|
5633
5801
|
});
|
|
5634
5802
|
if (!dataString) {
|
|
5635
|
-
logger$
|
|
5803
|
+
logger$7(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not found`);
|
|
5636
5804
|
}
|
|
5637
5805
|
let contentType = identifyString(dataString);
|
|
5638
5806
|
if (contentType !== 'json' &&
|
|
@@ -5640,7 +5808,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5640
5808
|
contentType !== 'html') {
|
|
5641
5809
|
const possibleImageType = getImageDataType(dataString);
|
|
5642
5810
|
if (!possibleImageType) {
|
|
5643
|
-
logger$
|
|
5811
|
+
logger$7(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`);
|
|
5644
5812
|
continue;
|
|
5645
5813
|
}
|
|
5646
5814
|
contentType = possibleImageType;
|
|
@@ -5703,7 +5871,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5703
5871
|
}
|
|
5704
5872
|
}
|
|
5705
5873
|
catch (error) {
|
|
5706
|
-
logger$
|
|
5874
|
+
logger$7(error);
|
|
5707
5875
|
}
|
|
5708
5876
|
}
|
|
5709
5877
|
});
|
|
@@ -5749,65 +5917,15 @@ const isFsInitialized = () => {
|
|
|
5749
5917
|
return isInitialized;
|
|
5750
5918
|
};
|
|
5751
5919
|
|
|
5752
|
-
const logger$
|
|
5753
|
-
let sqliteWasmClient;
|
|
5754
|
-
let manager;
|
|
5755
|
-
const validateInput = fromCallback(({ sendBack, input: { event } }) => {
|
|
5756
|
-
const { endpoints, addresses } = event;
|
|
5757
|
-
if (typeof window === 'undefined') {
|
|
5758
|
-
throw new Error('validateInput called from non-browser context');
|
|
5759
|
-
}
|
|
5760
|
-
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
5761
|
-
throw new Error('validateInput called with invalid endpoints');
|
|
5762
|
-
}
|
|
5763
|
-
if (!addresses || !addresses.length) {
|
|
5764
|
-
throw new Error('validateInput called with invalid addresses');
|
|
5765
|
-
}
|
|
5766
|
-
const _validateInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5767
|
-
sendBack({
|
|
5768
|
-
type: INTERNAL_VALIDATING_INPUT_SUCCESS,
|
|
5769
|
-
endpoints,
|
|
5770
|
-
addresses,
|
|
5771
|
-
});
|
|
5772
|
-
});
|
|
5773
|
-
_validateInput().then(() => {
|
|
5774
|
-
return;
|
|
5775
|
-
});
|
|
5776
|
-
});
|
|
5777
|
-
const prepareDb = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
5778
|
-
const _prepareDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5779
|
-
if (typeof window === 'undefined') {
|
|
5780
|
-
return;
|
|
5781
|
-
}
|
|
5782
|
-
sqliteWasmClient = yield getSqlite();
|
|
5783
|
-
});
|
|
5784
|
-
const interval = setInterval(() => {
|
|
5785
|
-
// TODO: Add a timeout
|
|
5786
|
-
// TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome
|
|
5787
|
-
if (sqliteWasmClient) {
|
|
5788
|
-
clearInterval(interval);
|
|
5789
|
-
manager = new SqliteConnectionManager(sqliteWasmClient);
|
|
5790
|
-
sendBack({ type: 'prepareDbSuccess', manager });
|
|
5791
|
-
return;
|
|
5792
|
-
}
|
|
5793
|
-
_prepareDb().then(() => {
|
|
5794
|
-
return;
|
|
5795
|
-
});
|
|
5796
|
-
}, 500);
|
|
5797
|
-
return () => {
|
|
5798
|
-
if (interval) {
|
|
5799
|
-
clearInterval(interval);
|
|
5800
|
-
}
|
|
5801
|
-
};
|
|
5802
|
-
});
|
|
5920
|
+
const logger$6 = debug('app:internal:actors:configureFs');
|
|
5803
5921
|
const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
5804
5922
|
const { endpoints, seedDbService, appDbService, sdkDbService } = context;
|
|
5805
|
-
logger$
|
|
5923
|
+
logger$6('[internal/actors] [configureFs] Configuring FS');
|
|
5806
5924
|
const services = [seedDbService, appDbService, sdkDbService];
|
|
5807
5925
|
const _configureFs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5808
|
-
logger$
|
|
5809
|
-
logger$
|
|
5810
|
-
logger$
|
|
5926
|
+
logger$6('[internal/actors] [configureFs] calling _configureFs');
|
|
5927
|
+
logger$6('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
|
|
5928
|
+
logger$6('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
|
|
5811
5929
|
yield waitForEvent({
|
|
5812
5930
|
req: {
|
|
5813
5931
|
eventLabel: 'fs.downloadAll.request',
|
|
@@ -5839,7 +5957,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5839
5957
|
// }, 200)
|
|
5840
5958
|
// })
|
|
5841
5959
|
})));
|
|
5842
|
-
logger$
|
|
5960
|
+
logger$6('[internal/actors] [configureFs] fs configured!');
|
|
5843
5961
|
});
|
|
5844
5962
|
// Some of our dependencies use fs sync functions, which don't work with
|
|
5845
5963
|
// OPFS. ZenFS creates an async cache of all files so that the sync functions
|
|
@@ -5851,6 +5969,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5851
5969
|
});
|
|
5852
5970
|
return () => { };
|
|
5853
5971
|
});
|
|
5972
|
+
|
|
5854
5973
|
const loadSeedDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5855
5974
|
const { seedDbService } = context;
|
|
5856
5975
|
if (seedDbService.getSnapshot().value === 'ready') {
|
|
@@ -5875,6 +5994,8 @@ const loadSeedDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5875
5994
|
}
|
|
5876
5995
|
};
|
|
5877
5996
|
});
|
|
5997
|
+
|
|
5998
|
+
const logger$5 = debug('app:services:internal:actors:saveConfig');
|
|
5878
5999
|
const saveConfig = fromCallback(({ sendBack, receive, input: { context } }) => {
|
|
5879
6000
|
if (typeof window === 'undefined') {
|
|
5880
6001
|
console.error('seedInitBrowser called from non-browser context');
|
|
@@ -5925,18 +6046,20 @@ const saveConfig = fromCallback(({ sendBack, receive, input: { context } }) => {
|
|
|
5925
6046
|
},
|
|
5926
6047
|
setWhere: sql `key = 'addresses'`,
|
|
5927
6048
|
});
|
|
5928
|
-
logger$
|
|
6049
|
+
logger$5('[sdk] [internal/actors] Should be done saving');
|
|
5929
6050
|
}
|
|
5930
6051
|
catch (error) {
|
|
5931
6052
|
console.error('Error saving config:', error);
|
|
5932
6053
|
}
|
|
5933
6054
|
});
|
|
5934
6055
|
_saveConfig().then(() => {
|
|
5935
|
-
logger$
|
|
6056
|
+
logger$5('[sdk] [internal/actors] Successfully saved config');
|
|
5936
6057
|
return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
|
|
5937
6058
|
});
|
|
5938
6059
|
return () => { };
|
|
5939
6060
|
});
|
|
6061
|
+
|
|
6062
|
+
const logger$4 = debug('app:services:internal:actors:loadAppDb');
|
|
5940
6063
|
const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5941
6064
|
const { appDbService } = context;
|
|
5942
6065
|
let subscription;
|
|
@@ -5957,7 +6080,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5957
6080
|
});
|
|
5958
6081
|
_loadAppDb().then(() => {
|
|
5959
6082
|
sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
|
|
5960
|
-
logger$
|
|
6083
|
+
logger$4('[sdk] [internal/actors] Successfully loaded app DB');
|
|
5961
6084
|
});
|
|
5962
6085
|
return () => {
|
|
5963
6086
|
if (subscription) {
|
|
@@ -5965,6 +6088,8 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5965
6088
|
}
|
|
5966
6089
|
};
|
|
5967
6090
|
});
|
|
6091
|
+
|
|
6092
|
+
const logger$3 = debug('app:internal:actors:loadSdkDb');
|
|
5968
6093
|
const loadSdkDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
5969
6094
|
const { sdkDbService } = context;
|
|
5970
6095
|
logger$3('[sdk] [internal/actors] Loading SDK DB');
|
|
@@ -5999,159 +6124,7 @@ const loadSdkDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5999
6124
|
};
|
|
6000
6125
|
});
|
|
6001
6126
|
|
|
6002
|
-
const logger$2 = debug('app:services:
|
|
6003
|
-
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
6004
|
-
const dbMachine = setup({
|
|
6005
|
-
types: {
|
|
6006
|
-
context: {},
|
|
6007
|
-
input: {},
|
|
6008
|
-
},
|
|
6009
|
-
actors: {
|
|
6010
|
-
checkStatus,
|
|
6011
|
-
validate,
|
|
6012
|
-
connectToDb,
|
|
6013
|
-
migrate,
|
|
6014
|
-
},
|
|
6015
|
-
}).createMachine({
|
|
6016
|
-
id: MachineIds.DB,
|
|
6017
|
-
initial: CHECKING_STATUS,
|
|
6018
|
-
context: ({ input }) => input,
|
|
6019
|
-
on: {
|
|
6020
|
-
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
6021
|
-
actions: assign({
|
|
6022
|
-
hasFiles: ({ event }) => {
|
|
6023
|
-
logger$2('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
6024
|
-
return true;
|
|
6025
|
-
},
|
|
6026
|
-
}),
|
|
6027
|
-
},
|
|
6028
|
-
updateHasFiles: {
|
|
6029
|
-
target: `.${CHECKING_STATUS}`,
|
|
6030
|
-
actions: assign({
|
|
6031
|
-
hasFiles: ({ context, event }) => {
|
|
6032
|
-
logger$2('[db/machine] updateHasFiles event:', event);
|
|
6033
|
-
logger$2('[db/machine] updateHasFiles context:', context);
|
|
6034
|
-
return event.hasFiles;
|
|
6035
|
-
},
|
|
6036
|
-
}),
|
|
6037
|
-
},
|
|
6038
|
-
},
|
|
6039
|
-
// always: {
|
|
6040
|
-
// target: `.${CHECKING_STATUS}`,
|
|
6041
|
-
// guard: ({ context, event }) => context.hasFiles && event.type === 'updateHasFiles',
|
|
6042
|
-
// },
|
|
6043
|
-
states: {
|
|
6044
|
-
idle: {
|
|
6045
|
-
on: {
|
|
6046
|
-
start: CHECKING_STATUS,
|
|
6047
|
-
},
|
|
6048
|
-
meta: {
|
|
6049
|
-
displayText: 'DB starting ...',
|
|
6050
|
-
percentComplete: 0,
|
|
6051
|
-
},
|
|
6052
|
-
},
|
|
6053
|
-
[CHECKING_STATUS]: {
|
|
6054
|
-
on: {
|
|
6055
|
-
[DB_CHECK_STATUS_UPDATE_PATHS]: {
|
|
6056
|
-
actions: assign({
|
|
6057
|
-
pathToDb: ({ event }) => event.pathToDb,
|
|
6058
|
-
pathToDir: ({ event }) => event.pathToDir,
|
|
6059
|
-
pathToDbDir: ({ event }) => event.pathToDbDir,
|
|
6060
|
-
}),
|
|
6061
|
-
},
|
|
6062
|
-
[DB_CHECK_STATUS_EXISTS]: CONNECTING_TO_DB,
|
|
6063
|
-
},
|
|
6064
|
-
invoke: {
|
|
6065
|
-
src: 'checkStatus',
|
|
6066
|
-
input: ({ context, event }) => ({ context, event }),
|
|
6067
|
-
},
|
|
6068
|
-
meta: {
|
|
6069
|
-
displayText: 'Checking DB status',
|
|
6070
|
-
percentComplete: 60,
|
|
6071
|
-
},
|
|
6072
|
-
},
|
|
6073
|
-
[CONNECTING_TO_DB]: {
|
|
6074
|
-
on: {
|
|
6075
|
-
[DB_CREATING_SUCCESS]: {
|
|
6076
|
-
target: VALIDATING,
|
|
6077
|
-
actions: assign({
|
|
6078
|
-
dbId: ({ event }) => event.dbId,
|
|
6079
|
-
}),
|
|
6080
|
-
},
|
|
6081
|
-
},
|
|
6082
|
-
invoke: {
|
|
6083
|
-
src: 'connectToDb',
|
|
6084
|
-
input: ({ context }) => ({ context }),
|
|
6085
|
-
},
|
|
6086
|
-
meta: {
|
|
6087
|
-
displayText: 'Connecting to local DB',
|
|
6088
|
-
percentComplete: 70,
|
|
6089
|
-
},
|
|
6090
|
-
},
|
|
6091
|
-
[VALIDATING]: {
|
|
6092
|
-
on: {
|
|
6093
|
-
[DB_VALIDATING_SUCCESS]: {
|
|
6094
|
-
target: MIGRATING,
|
|
6095
|
-
// guard: ({ context }) => context.hasFiles,
|
|
6096
|
-
},
|
|
6097
|
-
[DB_VALIDATING_WAIT]: {
|
|
6098
|
-
target: WAITING_FOR_FILES,
|
|
6099
|
-
// guard: ({ context }) => !context.hasFiles,
|
|
6100
|
-
},
|
|
6101
|
-
},
|
|
6102
|
-
invoke: {
|
|
6103
|
-
src: 'validate',
|
|
6104
|
-
input: ({ context }) => ({ context }),
|
|
6105
|
-
},
|
|
6106
|
-
meta: {
|
|
6107
|
-
displayText: 'Validating DB',
|
|
6108
|
-
percentComplete: 80,
|
|
6109
|
-
},
|
|
6110
|
-
},
|
|
6111
|
-
// Here we're waiting for migration and schema files to be downloaded
|
|
6112
|
-
[WAITING_FOR_FILES]: {
|
|
6113
|
-
on: {
|
|
6114
|
-
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
6115
|
-
target: MIGRATING,
|
|
6116
|
-
actions: assign({
|
|
6117
|
-
hasFiles: true,
|
|
6118
|
-
}),
|
|
6119
|
-
},
|
|
6120
|
-
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
6121
|
-
},
|
|
6122
|
-
entry: ({ context }) => {
|
|
6123
|
-
if (context.hasFiles) {
|
|
6124
|
-
emit({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
6125
|
-
}
|
|
6126
|
-
},
|
|
6127
|
-
},
|
|
6128
|
-
[MIGRATING]: {
|
|
6129
|
-
on: {
|
|
6130
|
-
[DB_MIGRATING_WAIT]: WAITING_FOR_FILES,
|
|
6131
|
-
[DB_MIGRATING_SUCCESS]: {
|
|
6132
|
-
target: 'ready',
|
|
6133
|
-
},
|
|
6134
|
-
},
|
|
6135
|
-
invoke: {
|
|
6136
|
-
src: 'migrate',
|
|
6137
|
-
input: ({ context }) => ({ context }),
|
|
6138
|
-
},
|
|
6139
|
-
meta: {
|
|
6140
|
-
displayText: 'Migrating DB',
|
|
6141
|
-
percentComplete: 90,
|
|
6142
|
-
},
|
|
6143
|
-
},
|
|
6144
|
-
ready: {
|
|
6145
|
-
target: 'idle',
|
|
6146
|
-
meta: {
|
|
6147
|
-
displayText: 'Wrapping up the db ...',
|
|
6148
|
-
percentComplete: 100,
|
|
6149
|
-
},
|
|
6150
|
-
},
|
|
6151
|
-
},
|
|
6152
|
-
});
|
|
6153
|
-
|
|
6154
|
-
const logger$1 = debug('app:services:internal:machine');
|
|
6127
|
+
const logger$2 = debug('app:services:internal:machine');
|
|
6155
6128
|
createBrowserInspector({
|
|
6156
6129
|
autoStart: false,
|
|
6157
6130
|
});
|
|
@@ -6313,7 +6286,7 @@ const internalMachine = setup({
|
|
|
6313
6286
|
[INTERNAL_LOADING_APP_DB_SUCCESS]: {
|
|
6314
6287
|
target: 'appDbLoaded',
|
|
6315
6288
|
actions: () => {
|
|
6316
|
-
logger$
|
|
6289
|
+
logger$2('[sdk] [internal/index] App DB loaded!');
|
|
6317
6290
|
},
|
|
6318
6291
|
},
|
|
6319
6292
|
},
|
|
@@ -6325,7 +6298,7 @@ const internalMachine = setup({
|
|
|
6325
6298
|
appDbLoaded: {
|
|
6326
6299
|
type: 'final',
|
|
6327
6300
|
entry: () => {
|
|
6328
|
-
logger$
|
|
6301
|
+
logger$2('[sdk] [internal/index] Entered appDbLoaded!');
|
|
6329
6302
|
},
|
|
6330
6303
|
},
|
|
6331
6304
|
},
|
|
@@ -6338,7 +6311,7 @@ const internalMachine = setup({
|
|
|
6338
6311
|
[INTERNAL_LOADING_SDK_DB_SUCCESS]: {
|
|
6339
6312
|
target: 'sdkConfigDbLoaded',
|
|
6340
6313
|
actions: () => {
|
|
6341
|
-
logger$
|
|
6314
|
+
logger$2('[sdk] [internal/index] SDK Config DB loaded!');
|
|
6342
6315
|
},
|
|
6343
6316
|
},
|
|
6344
6317
|
},
|
|
@@ -6350,7 +6323,7 @@ const internalMachine = setup({
|
|
|
6350
6323
|
sdkConfigDbLoaded: {
|
|
6351
6324
|
type: 'final',
|
|
6352
6325
|
entry: () => {
|
|
6353
|
-
logger$
|
|
6326
|
+
logger$2('[sdk] [internal/index] Entered sdkConfigDbLoaded!');
|
|
6354
6327
|
},
|
|
6355
6328
|
},
|
|
6356
6329
|
},
|
|
@@ -6359,7 +6332,7 @@ const internalMachine = setup({
|
|
|
6359
6332
|
onDone: {
|
|
6360
6333
|
target: 'ready',
|
|
6361
6334
|
actions: () => {
|
|
6362
|
-
logger$
|
|
6335
|
+
logger$2('[sdk] [internal/index] All DBs loaded! Should be headed to ready');
|
|
6363
6336
|
eventEmitter.emit('allDbsLoaded');
|
|
6364
6337
|
},
|
|
6365
6338
|
},
|
|
@@ -6371,7 +6344,7 @@ const internalMachine = setup({
|
|
|
6371
6344
|
},
|
|
6372
6345
|
ready: {
|
|
6373
6346
|
entry: () => {
|
|
6374
|
-
logger$
|
|
6347
|
+
logger$2('[sdk] [internal/index] Ready!');
|
|
6375
6348
|
},
|
|
6376
6349
|
meta: {
|
|
6377
6350
|
displayText: "Crossing the t's ...",
|
|
@@ -6386,7 +6359,7 @@ const internalMachine = setup({
|
|
|
6386
6359
|
},
|
|
6387
6360
|
},
|
|
6388
6361
|
entry: () => {
|
|
6389
|
-
logger$
|
|
6362
|
+
logger$2('[sdk] [internal/index] Error!');
|
|
6390
6363
|
},
|
|
6391
6364
|
meta: {
|
|
6392
6365
|
displayText: 'Whoops! Something went wrong.',
|
|
@@ -6397,6 +6370,53 @@ const internalMachine = setup({
|
|
|
6397
6370
|
},
|
|
6398
6371
|
});
|
|
6399
6372
|
|
|
6373
|
+
const logger$1 = debug('app:global:actors');
|
|
6374
|
+
const initialize = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
6375
|
+
const { internalService, models, endpoints } = context;
|
|
6376
|
+
const { addresses } = event;
|
|
6377
|
+
let environment = 'browser';
|
|
6378
|
+
if (isNode()) {
|
|
6379
|
+
environment = 'node';
|
|
6380
|
+
}
|
|
6381
|
+
if (isReactNative()) {
|
|
6382
|
+
environment = 'react-native';
|
|
6383
|
+
}
|
|
6384
|
+
let internalSubscription;
|
|
6385
|
+
if (environment === 'browser' && models) {
|
|
6386
|
+
const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6387
|
+
return;
|
|
6388
|
+
// return new Promise((resolve) => {
|
|
6389
|
+
// })
|
|
6390
|
+
});
|
|
6391
|
+
const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6392
|
+
return new Promise((resolve) => {
|
|
6393
|
+
internalSubscription = internalService.subscribe((snapshot) => {
|
|
6394
|
+
logger$1('[sdk] [internal] snapshot', snapshot);
|
|
6395
|
+
if (snapshot.value === 'ready') {
|
|
6396
|
+
resolve();
|
|
6397
|
+
}
|
|
6398
|
+
});
|
|
6399
|
+
internalService.send({ type: 'init', endpoints, addresses });
|
|
6400
|
+
});
|
|
6401
|
+
});
|
|
6402
|
+
_initFileSystem().then(() => {
|
|
6403
|
+
logger$1('[global/actors] File system initialized');
|
|
6404
|
+
});
|
|
6405
|
+
_initInternal().then(() => {
|
|
6406
|
+
logger$1('[global/actors] Internal initialized');
|
|
6407
|
+
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
6408
|
+
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
6409
|
+
});
|
|
6410
|
+
// _initEas().then(() => {
|
|
6411
|
+
// logger('EAS initialized')
|
|
6412
|
+
// })
|
|
6413
|
+
}
|
|
6414
|
+
sendBack({ type: GLOBAL_INITIALIZING_SEND_CONFIG, environment });
|
|
6415
|
+
return () => {
|
|
6416
|
+
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
6417
|
+
};
|
|
6418
|
+
});
|
|
6419
|
+
|
|
6400
6420
|
const { UNINITIALIZED, INITIALIZING, INITIALIZED, GETTING_SEED_CLASS, GETTING_SCHEMA_FOR_MODEL, ADDING_MODELS_TO_DB, } = GlobalState;
|
|
6401
6421
|
createBrowserInspector({
|
|
6402
6422
|
autoStart: false,
|
|
@@ -6528,11 +6548,11 @@ const globalMachine = setup({
|
|
|
6528
6548
|
(_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
|
|
6529
6549
|
let SeedClass;
|
|
6530
6550
|
if (context.environment === 'node') {
|
|
6531
|
-
const { SeedNode } = yield import('./seed-
|
|
6551
|
+
const { SeedNode } = yield import('./seed-BJPS_-pY.js');
|
|
6532
6552
|
SeedClass = SeedNode;
|
|
6533
6553
|
}
|
|
6534
6554
|
else {
|
|
6535
|
-
const { SeedBrowser } = yield import('./seed-
|
|
6555
|
+
const { SeedBrowser } = yield import('./seed-CjMH4SeR.js');
|
|
6536
6556
|
SeedClass = SeedBrowser;
|
|
6537
6557
|
}
|
|
6538
6558
|
return SeedClass;
|
|
@@ -6637,4 +6657,4 @@ const setupServicesEventHandlers = () => {
|
|
|
6637
6657
|
};
|
|
6638
6658
|
|
|
6639
6659
|
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 };
|
|
6640
|
-
//# sourceMappingURL=events-
|
|
6660
|
+
//# sourceMappingURL=events-CRCYmF7M.js.map
|