@seedprotocol/sdk 0.2.12 → 0.2.14

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.
@@ -1,4 +1,4 @@
1
- import { a as BaseDb } from './index-BmK_mt6d.js';
1
+ import { a as BaseDb } from './index-B8uGwSbV.js';
2
2
  import 'immer';
3
3
  import 'reflect-metadata';
4
4
  import 'tslib';
@@ -36,4 +36,4 @@ class Db extends BaseDb {
36
36
  }
37
37
 
38
38
  export { Db };
39
- //# sourceMappingURL=Db-CU-Gwjw5.js.map
39
+ //# sourceMappingURL=Db-DOaWOiNg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Db-CU-Gwjw5.js","sources":["../../src/node/db/Db.ts"],"sourcesContent":["import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces\";\n\nexport class Db extends BaseDb implements IDb {\n constructor() {\n super()\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGM,MAAO,EAAG,SAAQ,MAAM,CAAA;AAC5B,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;;AAEV;;;;"}
1
+ {"version":3,"file":"Db-DOaWOiNg.js","sources":["../../src/node/db/Db.ts"],"sourcesContent":["import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces\";\n\nexport class Db extends BaseDb implements IDb {\n constructor() {\n super()\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGM,MAAO,EAAG,SAAQ,MAAM,CAAA;AAC5B,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;;AAEV;;;;"}
@@ -1,4 +1,4 @@
1
- import { a as BaseDb, g as getAppDb, i as isAppDbReady, b as getSqliteWasmClient } from './index-BmK_mt6d.js';
1
+ import { a as BaseDb, g as getAppDb, i as isAppDbReady, b as getSqliteWasmClient } from './index-B8uGwSbV.js';
2
2
  import { __awaiter } from 'tslib';
3
3
  import debug from 'debug';
4
4
  import 'immer';
@@ -135,4 +135,4 @@ class Db extends BaseDb {
135
135
  BaseDb.setPlatformClass(Db);
136
136
 
137
137
  export { Db };
138
- //# sourceMappingURL=Db-f1qduW04.js.map
138
+ //# sourceMappingURL=Db-DuTuGf68.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Db-f1qduW04.js","sources":["../../src/services/db/connectionManager.ts","../../src/browser/db/Db.ts"],"sourcesContent":["type SqliteDatabase = {\n open: (filename: string) => Promise<void>\n exec: (sql: string, params?: any[]) => any\n close: () => void\n}\n\nclass SqliteConnectionManager {\n private sqliteModule: SqliteDatabase\n private idleTimeout: number\n private databases: { [key: string]: SqliteDatabase }\n private idleTimers: { [key: string]: NodeJS.Timeout }\n\n constructor(sqliteModule: SqliteDatabase, idleTimeout: number = 300000) {\n // Default idle timeout: 5 minutes\n this.sqliteModule = sqliteModule\n this.idleTimeout = idleTimeout\n this.databases = {}\n this.idleTimers = {}\n }\n\n private resetIdleTimer(dbName: string): void {\n if (this.idleTimers[dbName]) {\n clearTimeout(this.idleTimers[dbName])\n }\n\n this.idleTimers[dbName] = setTimeout(() => {\n this.closeConnection(dbName)\n }, this.idleTimeout)\n }\n\n private async getConnection(dbName: string): Promise<SqliteDatabase> {\n if (this.databases[dbName]) {\n this.resetIdleTimer(dbName)\n return this.databases[dbName]\n }\n\n const db = new this.sqliteModule()\n await db.open(dbName)\n this.databases[dbName] = db\n this.resetIdleTimer(dbName)\n return db\n }\n\n public async execute(\n dbName: string,\n sql: string,\n params: any[] = [],\n ): Promise<any> {\n const db = await this.getConnection(dbName)\n const result = db.exec(sql, params)\n this.resetIdleTimer(dbName)\n return result\n }\n\n public closeConnection(dbName: string): void {\n if (this.databases[dbName]) {\n this.databases[dbName].close()\n delete this.databases[dbName]\n if (this.idleTimers[dbName]) {\n clearTimeout(this.idleTimers[dbName])\n delete this.idleTimers[dbName]\n }\n }\n }\n}\n\nexport { SqliteConnectionManager }\n","import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces/IDb\";\nimport { getAppDb, getSqliteWasmClient, isAppDbReady } from \"./sqlWasmClient\";\nimport { SqliteConnectionManager } from \"@/services/db\";\nimport debug from \"debug\";\n\nconst logger = debug('app:browser:db:Db')\n\nclass Db extends BaseDb implements IDb {\n constructor() {\n super()\n }\n\n static getAppDb() {\n return getAppDb()\n }\n\n static isAppDbReady() {\n return isAppDbReady()\n }\n\n static prepareDb() {\n\n return new Promise((resolve, reject) => {\n let sqliteWasmClient\n const interval = setInterval(() => {\n // TODO: Add a timeout\n // TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome\n getSqliteWasmClient().then((sqliteWasmClient) => {\n\n if (sqliteWasmClient) {\n clearInterval(interval)\n const manager = new SqliteConnectionManager(sqliteWasmClient)\n resolve(manager)\n }\n })\n\n }, 200)\n })\n }\n\n static connectToDb(pathToDir: string, dbName: string) {\n\n return new Promise((resolve, reject) => {\n const interval = setInterval(() => {\n\n // TODO: Add a timeout\n // TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome\n getSqliteWasmClient().then((sqliteWasmClient) => {\n\n //@ts-ignore\n sqliteWasmClient('config-get', {}).then((response) => {\n logger(response)\n logger('Running SQLite3 version', response.result.version.libVersion)\n\n //@ts-ignore\n sqliteWasmClient('open', {\n filename: `file:${pathToDir}/db/${dbName}.sqlite3?vfs=opfs`,\n }).then((response: { dbId: string, result: { filename: string } }) => {\n\n logger(response)\n const dbId = response.dbId\n logger(\n 'OPFS is available, created persisted database at',\n response.result.filename.replace(/^file:(.*?)\\?vfs=opfs$/, '$1'),\n )\n\n if (dbId) {\n clearInterval(interval)\n resolve(dbId)\n }\n })\n })\n })\n }, 500)\n })\n }\n}\n\nBaseDb.setPlatformClass(Db)\n\nexport { Db }"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,uBAAuB,CAAA;IAM3B,WAAY,CAAA,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G,CAAC;AACT,SAAC,CAAC;;AAGJ,IAAA,OAAO,WAAW,CAAC,SAAiB,EAAE,MAAc,EAAA;QAElD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACrC,YAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAK;;;AAIhC,gBAAA,mBAAmB,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAI;;oBAG9C,gBAAgB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;wBACnD,MAAM,CAAC,QAAQ,CAAC;wBAChB,MAAM,CAAC,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;;wBAGrE,gBAAgB,CAAC,MAAM,EAAE;AACvB,4BAAA,QAAQ,EAAE,CAAA,KAAA,EAAQ,SAAS,CAAA,IAAA,EAAO,MAAM,CAAmB,iBAAA,CAAA;AAC5D,yBAAA,CAAC,CAAC,IAAI,CAAC,CAAC,QAAwD,KAAI;4BAEnE,MAAM,CAAC,QAAQ,CAAC;AAChB,4BAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI;AAC1B,4BAAA,MAAM,CACJ,kDAAkD,EAClD,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CACjE;4BAED,IAAI,IAAI,EAAE;gCACR,aAAa,CAAC,QAAQ,CAAC;gCACvB,OAAO,CAAC,IAAI,CAAC;;AAEjB,yBAAC,CAAC;AACJ,qBAAC,CAAC;AACJ,iBAAC,CAAC;aACH,EAAE,GAAG,CAAC;AACT,SAAC,CAAC;;AAEL;AAED,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;;;;"}
1
+ {"version":3,"file":"Db-DuTuGf68.js","sources":["../../src/services/db/connectionManager.ts","../../src/browser/db/Db.ts"],"sourcesContent":["type SqliteDatabase = {\n open: (filename: string) => Promise<void>\n exec: (sql: string, params?: any[]) => any\n close: () => void\n}\n\nclass SqliteConnectionManager {\n private sqliteModule: SqliteDatabase\n private idleTimeout: number\n private databases: { [key: string]: SqliteDatabase }\n private idleTimers: { [key: string]: NodeJS.Timeout }\n\n constructor(sqliteModule: SqliteDatabase, idleTimeout: number = 300000) {\n // Default idle timeout: 5 minutes\n this.sqliteModule = sqliteModule\n this.idleTimeout = idleTimeout\n this.databases = {}\n this.idleTimers = {}\n }\n\n private resetIdleTimer(dbName: string): void {\n if (this.idleTimers[dbName]) {\n clearTimeout(this.idleTimers[dbName])\n }\n\n this.idleTimers[dbName] = setTimeout(() => {\n this.closeConnection(dbName)\n }, this.idleTimeout)\n }\n\n private async getConnection(dbName: string): Promise<SqliteDatabase> {\n if (this.databases[dbName]) {\n this.resetIdleTimer(dbName)\n return this.databases[dbName]\n }\n\n const db = new this.sqliteModule()\n await db.open(dbName)\n this.databases[dbName] = db\n this.resetIdleTimer(dbName)\n return db\n }\n\n public async execute(\n dbName: string,\n sql: string,\n params: any[] = [],\n ): Promise<any> {\n const db = await this.getConnection(dbName)\n const result = db.exec(sql, params)\n this.resetIdleTimer(dbName)\n return result\n }\n\n public closeConnection(dbName: string): void {\n if (this.databases[dbName]) {\n this.databases[dbName].close()\n delete this.databases[dbName]\n if (this.idleTimers[dbName]) {\n clearTimeout(this.idleTimers[dbName])\n delete this.idleTimers[dbName]\n }\n }\n }\n}\n\nexport { SqliteConnectionManager }\n","import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces/IDb\";\nimport { getAppDb, getSqliteWasmClient, isAppDbReady } from \"./sqlWasmClient\";\nimport { SqliteConnectionManager } from \"@/services/db\";\nimport debug from \"debug\";\n\nconst logger = debug('app:browser:db:Db')\n\nclass Db extends BaseDb implements IDb {\n constructor() {\n super()\n }\n\n static getAppDb() {\n return getAppDb()\n }\n\n static isAppDbReady() {\n return isAppDbReady()\n }\n\n static prepareDb() {\n\n return new Promise((resolve, reject) => {\n let sqliteWasmClient\n const interval = setInterval(() => {\n // TODO: Add a timeout\n // TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome\n getSqliteWasmClient().then((sqliteWasmClient) => {\n\n if (sqliteWasmClient) {\n clearInterval(interval)\n const manager = new SqliteConnectionManager(sqliteWasmClient)\n resolve(manager)\n }\n })\n\n }, 200)\n })\n }\n\n static connectToDb(pathToDir: string, dbName: string) {\n\n return new Promise((resolve, reject) => {\n const interval = setInterval(() => {\n\n // TODO: Add a timeout\n // TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome\n getSqliteWasmClient().then((sqliteWasmClient) => {\n\n //@ts-ignore\n sqliteWasmClient('config-get', {}).then((response) => {\n logger(response)\n logger('Running SQLite3 version', response.result.version.libVersion)\n\n //@ts-ignore\n sqliteWasmClient('open', {\n filename: `file:${pathToDir}/db/${dbName}.sqlite3?vfs=opfs`,\n }).then((response: { dbId: string, result: { filename: string } }) => {\n\n logger(response)\n const dbId = response.dbId\n logger(\n 'OPFS is available, created persisted database at',\n response.result.filename.replace(/^file:(.*?)\\?vfs=opfs$/, '$1'),\n )\n\n if (dbId) {\n clearInterval(interval)\n resolve(dbId)\n }\n })\n })\n })\n }, 500)\n })\n }\n}\n\nBaseDb.setPlatformClass(Db)\n\nexport { Db }"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,uBAAuB,CAAA;IAM3B,WAAY,CAAA,YAA4B,EAAE,WAAA,GAAsB,MAAM,EAAA;;AAEpE,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY;AAChC,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,SAAS,GAAG,EAAE;AACnB,QAAA,IAAI,CAAC,UAAU,GAAG,EAAE;;AAGd,IAAA,cAAc,CAAC,MAAc,EAAA;AACnC,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC3B,YAAY,CAAC,IAAI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C,QAAQ,KAAI;wBACnD,MAAM,CAAC,QAAQ,CAAC;wBAChB,MAAM,CAAC,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;;wBAGrE,gBAAgB,CAAC,MAAM,EAAE;AACvB,4BAAA,QAAQ,EAAE,CAAA,KAAA,EAAQ,SAAS,CAAA,IAAA,EAAO,MAAM,CAAmB,iBAAA,CAAA;AAC5D,yBAAA,CAAC,CAAC,IAAI,CAAC,CAAC,QAAwD,KAAI;4BAEnE,MAAM,CAAC,QAAQ,CAAC;AAChB,4BAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI;AAC1B,4BAAA,MAAM,CACJ,kDAAkD,EAClD,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CACjE;4BAED,IAAI,IAAI,EAAE;gCACR,aAAa,CAAC,QAAQ,CAAC;gCACvB,OAAO,CAAC,IAAI,CAAC;;AAEjB,yBAAC,CAAC;AACJ,qBAAC,CAAC;AACJ,iBAAC,CAAC;aACH,EAAE,GAAG,CAAC;AACT,SAAC,CAAC;;AAEL;AAED,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import { B as BaseItem } from './index-BmK_mt6d.js';
1
+ import { B as BaseItem } from './index-B8uGwSbV.js';
2
2
  import 'immer';
3
3
  import 'reflect-metadata';
4
4
  import 'tslib';
@@ -37,4 +37,4 @@ class Item extends BaseItem {
37
37
  BaseItem.setPlatformClass(Item);
38
38
 
39
39
  export { Item };
40
- //# sourceMappingURL=Item-DL_Dp5wS.js.map
40
+ //# sourceMappingURL=Item-CLlF0KW4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Item-DL_Dp5wS.js","sources":["../../src/node/Item/Item.ts"],"sourcesContent":["import { IItem } from '@/interfaces';\nimport { BaseItem } from '@/Item/BaseItem';\nimport { ModelSchema, ModelValues } from '@/types';\n\nexport class Item<T extends ModelValues<ModelSchema>> extends BaseItem<T> implements IItem<T> {\n constructor(initialValues: any) {\n super(initialValues);\n }\n\n}\n\nBaseItem.setPlatformClass(Item)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIM,MAAO,IAAyC,SAAQ,QAAW,CAAA;AACvE,IAAA,WAAA,CAAY,aAAkB,EAAA;QAC5B,KAAK,CAAC,aAAa,CAAC;;AAGvB;AAED,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;;;;"}
1
+ {"version":3,"file":"Item-CLlF0KW4.js","sources":["../../src/node/Item/Item.ts"],"sourcesContent":["import { IItem } from '@/interfaces';\nimport { BaseItem } from '@/Item/BaseItem';\nimport { ModelSchema, ModelValues } from '@/types';\n\nexport class Item<T extends ModelValues<ModelSchema>> extends BaseItem<T> implements IItem<T> {\n constructor(initialValues: any) {\n super(initialValues);\n }\n\n}\n\nBaseItem.setPlatformClass(Item)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIM,MAAO,IAAyC,SAAQ,QAAW,CAAA;AACvE,IAAA,WAAA,CAAY,aAAkB,EAAA;QAC5B,KAAK,CAAC,aAAa,CAAC;;AAGvB;AAED,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;;;;"}
@@ -1262,7 +1262,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
1262
1262
  if (propertyRecordSchema &&
1263
1263
  propertyRecordSchema.storageType &&
1264
1264
  propertyRecordSchema.storageType === 'ItemStorage') {
1265
- const { Item } = yield import('./index-CH_EtiuR.js');
1265
+ const { Item } = yield import('./index-DI6gojqO.js');
1266
1266
  const item = yield Item.find({
1267
1267
  seedLocalId,
1268
1268
  modelName,
@@ -2218,7 +2218,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
2218
2218
  if (!models$1) {
2219
2219
  return;
2220
2220
  }
2221
- const { models: SeedModels } = yield import('./seed.schema.config-CgSo_hHB.js');
2221
+ const { models: SeedModels } = yield import('./seed.schema.config-jYCP0EPe.js');
2222
2222
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
2223
2223
  let hasModelsInDb = false;
2224
2224
  const schemaDefsByModelName = new Map();
@@ -6282,6 +6282,78 @@ const useService = (service) => {
6282
6282
  uniqueKey: getServiceUniqueKey(service),
6283
6283
  };
6284
6284
  };
6285
+ const useIsDbReady = () => {
6286
+ const [isDbReady, setIsDbReady] = useState(false);
6287
+ const { internalStatus } = useGlobalServiceStatus();
6288
+ useEffect(() => {
6289
+ if (internalStatus === 'ready') {
6290
+ setIsDbReady(true);
6291
+ }
6292
+ }, [internalStatus]);
6293
+ return isDbReady;
6294
+ };
6295
+ const usePersistedSnapshots = () => {
6296
+ const [initialized, setInitialized] = useState(false);
6297
+ const hasSavedSnapshots = useHasSavedSnapshots();
6298
+ const { services, percentComplete } = useServices();
6299
+ // Helper function to save all actor snapshots to the database
6300
+ const save = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
6301
+ for (const actor of services) {
6302
+ const uniqueKey = getServiceUniqueKey(actor);
6303
+ console.log(`would save to db with snapshot__${uniqueKey}:`, JSON.stringify(actor.getPersistedSnapshot()));
6304
+ // await writeAppState(
6305
+ // `snapshot__${uniqueKey}`,
6306
+ // JSON.stringify(actor.getPersistedSnapshot()),
6307
+ // )
6308
+ }
6309
+ }), [services]);
6310
+ // Helper function to load persisted snapshots from the database
6311
+ const load = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
6312
+ const appDb = BaseDb.getAppDb();
6313
+ if (!appDb) {
6314
+ return [];
6315
+ }
6316
+ const persistedSnapshots = yield appDb
6317
+ .select()
6318
+ .from(appState)
6319
+ .where(like(appState.key, 'snapshot__%'));
6320
+ return persistedSnapshots;
6321
+ }), []);
6322
+ useEffect(() => {
6323
+ if (!hasSavedSnapshots || initialized) {
6324
+ return;
6325
+ }
6326
+ const initialize = () => __awaiter(void 0, void 0, void 0, function* () {
6327
+ const persistedSnapshots = yield load();
6328
+ console.log('persistedSnapshots:', persistedSnapshots);
6329
+ setInitialized(true);
6330
+ });
6331
+ initialize();
6332
+ return () => {
6333
+ save(); // Save snapshots on unmount
6334
+ };
6335
+ }, [hasSavedSnapshots, initialized]);
6336
+ };
6337
+ const useHasSavedSnapshots = () => {
6338
+ const [hasSavedSnapshots, setHasSavedSnapshots] = useState(false);
6339
+ const isDbReady = useIsDbReady();
6340
+ useEffect(() => {
6341
+ if (isDbReady) {
6342
+ const _checkForSnapshots = () => __awaiter(void 0, void 0, void 0, function* () {
6343
+ const appDb = BaseDb.getAppDb();
6344
+ const rows = yield appDb
6345
+ .select()
6346
+ .from(appState)
6347
+ .where(like(appState.key, 'snapshot__%'));
6348
+ if (rows && rows.length > 0) {
6349
+ setHasSavedSnapshots(true);
6350
+ }
6351
+ });
6352
+ _checkForSnapshots();
6353
+ }
6354
+ }, [isDbReady]);
6355
+ return hasSavedSnapshots;
6356
+ };
6285
6357
  const useServices = () => {
6286
6358
  const [actors, setActors] = useState([]);
6287
6359
  const [percentComplete, setPercentComplete] = useState(5);
@@ -6584,6 +6656,35 @@ const useCreateItem = (modelName) => {
6584
6656
  isCreatingItem,
6585
6657
  };
6586
6658
  };
6659
+ const usePublishItem = () => {
6660
+ const [isPublishing, setIsPublishing] = useState(false);
6661
+ const isLocked = useRef(false);
6662
+ const publishItem = useCallback((item, callback) => __awaiter(void 0, void 0, void 0, function* () {
6663
+ if (!item || isLocked.current) {
6664
+ return;
6665
+ }
6666
+ isLocked.current = true;
6667
+ setIsPublishing(true);
6668
+ try {
6669
+ // await item.publish()
6670
+ const payload = yield item.getPublishPayload();
6671
+ if (callback) {
6672
+ callback();
6673
+ }
6674
+ }
6675
+ catch (e) {
6676
+ if (callback) {
6677
+ callback(e);
6678
+ }
6679
+ }
6680
+ setIsPublishing(false);
6681
+ isLocked.current = false;
6682
+ }), []);
6683
+ return {
6684
+ publishItem,
6685
+ isPublishing,
6686
+ };
6687
+ };
6587
6688
 
6588
6689
  const logger$3 = debug('app:react:property');
6589
6690
  const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
@@ -8038,7 +8139,7 @@ const initItem = () => __awaiter(void 0, void 0, void 0, function* () {
8038
8139
  (yield Promise.resolve().then(function () { return Item$1; })).Item;
8039
8140
  }
8040
8141
  else {
8041
- (yield import('./Item-DL_Dp5wS.js')).Item;
8142
+ (yield import('./Item-CLlF0KW4.js')).Item;
8042
8143
  }
8043
8144
  });
8044
8145
 
@@ -8080,10 +8181,10 @@ const initFileManager = () => __awaiter(void 0, void 0, void 0, function* () {
8080
8181
 
8081
8182
  const initDb = () => __awaiter(void 0, void 0, void 0, function* () {
8082
8183
  if (typeof window !== 'undefined') {
8083
- (yield import('./Db-f1qduW04.js')).Db;
8184
+ (yield import('./Db-DuTuGf68.js')).Db;
8084
8185
  }
8085
8186
  else {
8086
- (yield import('./Db-CU-Gwjw5.js')).Db;
8187
+ (yield import('./Db-DOaWOiNg.js')).Db;
8087
8188
  }
8088
8189
  });
8089
8190
 
@@ -8119,7 +8220,7 @@ const client = {
8119
8220
  addresses,
8120
8221
  arweaveDomain,
8121
8222
  });
8122
- const { models: internalModels } = yield import('./seed.schema.config-CgSo_hHB.js');
8223
+ const { models: internalModels } = yield import('./seed.schema.config-jYCP0EPe.js');
8123
8224
  for (const [key, value] of Object.entries(internalModels)) {
8124
8225
  setModel(key, value);
8125
8226
  }
@@ -8169,5 +8270,5 @@ const client = {
8169
8270
 
8170
8271
  enableMapSet();
8171
8272
 
8172
- export { BaseItem as B, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, BaseDb as a, getSqliteWasmClient as b, ImageSrc as c, ItemProperty as d, useItem as e, useItemProperties as f, getAppDb as g, useCreateItem as h, isAppDbReady as i, useItemProperty as j, useDeleteItem as k, useGlobalServiceStatus as l, useServices as m, useService as n, getGlobalService as o, getCorrectId as p, eventEmitter as q, client as r, useItems as u, withSeed as w };
8173
- //# sourceMappingURL=index-BmK_mt6d.js.map
8273
+ export { BaseItem as B, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, BaseDb as a, getSqliteWasmClient as b, ImageSrc as c, ItemProperty as d, useItem as e, useItemProperties as f, getAppDb as g, useCreateItem as h, isAppDbReady as i, useItemProperty as j, useDeleteItem as k, useGlobalServiceStatus as l, usePublishItem as m, usePersistedSnapshots as n, useServices as o, useService as p, getGlobalService as q, getCorrectId as r, eventEmitter as s, client as t, useItems as u, withSeed as w };
8274
+ //# sourceMappingURL=index-B8uGwSbV.js.map