@seedprotocol/sdk 0.7.5-next.871.g8788c94 → 0.7.5

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.
Files changed (82) hide show
  1. package/dist/{BasePathResolver-B-fK7_N_.js → BasePathResolver-CBTXCMFL.js} +18 -4
  2. package/dist/BasePathResolver-CBTXCMFL.js.map +1 -0
  3. package/dist/{ClientManager-C7VkO5Hg.js → ClientManager-DRf4uuei.js} +48 -48
  4. package/dist/ClientManager-DRf4uuei.js.map +1 -0
  5. package/dist/{Item-BDmsdNTQ.js → Item-DTJPMjFk.js} +69 -56
  6. package/dist/Item-DTJPMjFk.js.map +1 -0
  7. package/dist/{ModelProperty-Cqw6yn7y.js → ModelProperty-Dto5C0om.js} +65 -30
  8. package/dist/ModelProperty-Dto5C0om.js.map +1 -0
  9. package/dist/{Schema-BJLYOUgp.js → Schema-8DxGcORY.js} +38 -36
  10. package/dist/{Schema-BJLYOUgp.js.map → Schema-8DxGcORY.js.map} +1 -1
  11. package/dist/{SchemaValidationService-CzybXLiS.js → SchemaValidationService-CE92y1TT.js} +6 -6
  12. package/dist/{SchemaValidationService-CzybXLiS.js.map → SchemaValidationService-CE92y1TT.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-DAsETfD_.js → backfillMetadataPropertyIds-CRqp-BqX.js} +3 -3
  14. package/dist/{backfillMetadataPropertyIds-DAsETfD_.js.map → backfillMetadataPropertyIds-CRqp-BqX.js.map} +1 -1
  15. package/dist/{configurePlatform-CFQF_i1T.js → configurePlatform-D4aGjKNk.js} +2 -2
  16. package/dist/{configurePlatform-CFQF_i1T.js.map → configurePlatform-D4aGjKNk.js.map} +1 -1
  17. package/dist/{detachRowsBeforeDelete-D4gxxk46.js → detachRowsBeforeDelete-BVetHtn2.js} +2 -2
  18. package/dist/{detachRowsBeforeDelete-D4gxxk46.js.map → detachRowsBeforeDelete-BVetHtn2.js.map} +1 -1
  19. package/dist/{discardNewDraft-g8w3uHFM.js → discardNewDraft-CEOouygG.js} +5 -5
  20. package/dist/{discardNewDraft-g8w3uHFM.js.map → discardNewDraft-CEOouygG.js.map} +1 -1
  21. package/dist/{eas-BcXZ2hIn.js → eas-D7jvWMnI.js} +3 -3
  22. package/dist/{eas-BcXZ2hIn.js.map → eas-D7jvWMnI.js.map} +1 -1
  23. package/dist/{errors-CCMxedOB.js → errors-CIrbsN_i.js} +43 -38
  24. package/dist/errors-CIrbsN_i.js.map +1 -0
  25. package/dist/{getItem-BUs1Xa48.js → getItem-CxU_kT5W.js} +4 -4
  26. package/dist/{getItem-BUs1Xa48.js.map → getItem-CxU_kT5W.js.map} +1 -1
  27. package/dist/{getPublishPayload-CwNOhnir.js → getPublishPayload-DTjOKd3y.js} +13 -13
  28. package/dist/{getPublishPayload-CwNOhnir.js.map → getPublishPayload-DTjOKd3y.js.map} +1 -1
  29. package/dist/{getPublishUploads-pEOrXJbF.js → getPublishUploads-CVTBo_OV.js} +6 -6
  30. package/dist/{getPublishUploads-pEOrXJbF.js.map → getPublishUploads-CVTBo_OV.js.map} +1 -1
  31. package/dist/{index-zAs84LDi.js → index-CMxEil8T.js} +8 -8
  32. package/dist/index-CMxEil8T.js.map +1 -0
  33. package/dist/{index-BQSK-r_A.js → index-DWK-LOUY.js} +2 -2
  34. package/dist/index-DWK-LOUY.js.map +1 -0
  35. package/dist/{index.browser-irwaBIj0.js → index.browser-shRXMeB3.js} +10 -10
  36. package/dist/{index.browser-irwaBIj0.js.map → index.browser-shRXMeB3.js.map} +1 -1
  37. package/dist/{index.node-BYkndQN7.js → index.node-DAKJNYp5.js} +20 -6
  38. package/dist/index.node-DAKJNYp5.js.map +1 -0
  39. package/dist/main.js +22 -22
  40. package/dist/node.js +10 -10
  41. package/dist/platform.browser.js +5 -5
  42. package/dist/platform.node.js +4 -4
  43. package/dist/{property-5AD2naVS.js → property-lz9yIpyA.js} +6 -6
  44. package/dist/{property-5AD2naVS.js.map → property-lz9yIpyA.js.map} +1 -1
  45. package/dist/{propertyValidationRules-Bdgz0Nrr.js → propertyValidationRules-LuIwoQoJ.js} +6 -6
  46. package/dist/{propertyValidationRules-Bdgz0Nrr.js.map → propertyValidationRules-LuIwoQoJ.js.map} +1 -1
  47. package/dist/{publishDraftGraph-DGhC9ifI.js → publishDraftGraph-CgSLPKvQ.js} +6 -6
  48. package/dist/{publishDraftGraph-DGhC9ifI.js.map → publishDraftGraph-CgSLPKvQ.js.map} +1 -1
  49. package/dist/{resetAmbiguousLegacyItemData-HSB77N9c.js → resetAmbiguousLegacyItemData-CuamkAAh.js} +2 -2
  50. package/dist/{resetAmbiguousLegacyItemData-HSB77N9c.js.map → resetAmbiguousLegacyItemData-CuamkAAh.js.map} +1 -1
  51. package/dist/{resolveModelForSyncedSeed-CAKAJgr6.js → resolveModelForSyncedSeed-BbSctSvz.js} +2 -2
  52. package/dist/{resolveModelForSyncedSeed-CAKAJgr6.js.map → resolveModelForSyncedSeed-BbSctSvz.js.map} +1 -1
  53. package/dist/src/Item/Item.d.ts +5 -0
  54. package/dist/src/Item/Item.d.ts.map +1 -1
  55. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  56. package/dist/src/Model/Model.d.ts.map +1 -1
  57. package/dist/src/Model/service/actors/createModelProperties.d.ts.map +1 -1
  58. package/dist/src/ModelProperty/ModelProperty.d.ts +17 -0
  59. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  60. package/dist/src/Schema/Schema.d.ts.map +1 -1
  61. package/dist/src/client/ClientManager.d.ts +2 -2
  62. package/dist/src/client/ClientManager.d.ts.map +1 -1
  63. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  64. package/dist/src/helpers/db.d.ts.map +1 -1
  65. package/dist/src/node/db/Db.d.ts.map +1 -1
  66. package/dist/{syncDbWithEas-BmJXqfgN.js → syncDbWithEas-CrAY9Rl2.js} +13 -13
  67. package/dist/{syncDbWithEas-BmJXqfgN.js.map → syncDbWithEas-CrAY9Rl2.js.map} +1 -1
  68. package/dist/{tabEvents-DXun7vdK.js → tabEvents-BGBYV65P.js} +4 -4
  69. package/dist/{tabEvents-DXun7vdK.js.map → tabEvents-BGBYV65P.js.map} +1 -1
  70. package/dist/{tolerantWebAccess-DXxgX2x7.js → tolerantWebAccess-DVHCEulL.js} +6 -6
  71. package/dist/{tolerantWebAccess-DXxgX2x7.js.map → tolerantWebAccess-DVHCEulL.js.map} +1 -1
  72. package/dist/{updateSeedRevokedAt-DkLSDwUX.js → updateSeedRevokedAt-Dy5J8CfQ.js} +3 -3
  73. package/dist/{updateSeedRevokedAt-DkLSDwUX.js.map → updateSeedRevokedAt-Dy5J8CfQ.js.map} +1 -1
  74. package/package.json +5 -5
  75. package/dist/BasePathResolver-B-fK7_N_.js.map +0 -1
  76. package/dist/ClientManager-C7VkO5Hg.js.map +0 -1
  77. package/dist/Item-BDmsdNTQ.js.map +0 -1
  78. package/dist/ModelProperty-Cqw6yn7y.js.map +0 -1
  79. package/dist/errors-CCMxedOB.js.map +0 -1
  80. package/dist/index-BQSK-r_A.js.map +0 -1
  81. package/dist/index-zAs84LDi.js.map +0 -1
  82. package/dist/index.node-BYkndQN7.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { startCase, isEqual } from 'lodash-es';
2
- import { B as BaseDb, o as easSyncProcesses, I as eventEmitter, a4 as isNode, af as isBrowser, K as BasePathResolver, aF as normalizeAddressConfig, j as appState, aS as downloadAllFilesRequestHandler, aT as downloadAllFilesBinaryRequestHandler, h as BaseFileManager, t as models$1, s as modelUids, C as seeds, aG as normalizeAddressList, A as schemas, aQ as loadModelsFromDbForSchema, aN as addSchemaToDb, aK as isInternalSchema, aU as warnOnInvalidNameMatch, aV as INTERNAL_SCHEMA_IDS, al as generateId, aW as linkModelToSchema, aR as clearNameMatchLevels, n as normalizeDataType, ae as easPropertyNameForPublish, av as SEED_PROTOCOL_SCHEMA_NAME, r as modelSchemas, m as metadata$1, v as properties, N as resolveItemModelFileId, F as versions, ah as normalizePublisher, aj as loadNameMatchLevels, p as htmlEmbeddedImageCoPublish, k as arweaveL1FinalizeJobs, z as publishProcesses, aX as getWatchedAddressesFromDb, aY as getOwnedAddressesFromDb, aZ as CLIENT_NOT_INITIALIZED } from './BasePathResolver-B-fK7_N_.js';
2
+ import { B as BaseDb, o as easSyncProcesses, I as eventEmitter, a4 as isNode, af as isBrowser, K as BasePathResolver, aF as normalizeAddressConfig, j as appState, aS as downloadAllFilesRequestHandler, aT as downloadAllFilesBinaryRequestHandler, h as BaseFileManager, t as models$1, s as modelUids, C as seeds, aG as normalizeAddressList, A as schemas, aQ as loadModelsFromDbForSchema, aN as addSchemaToDb, aK as isInternalSchema, aU as warnOnInvalidNameMatch, aV as INTERNAL_SCHEMA_IDS, al as generateId, aW as linkModelToSchema, aR as clearNameMatchLevels, n as normalizeDataType, ae as easPropertyNameForPublish, av as SEED_PROTOCOL_SCHEMA_NAME, r as modelSchemas, m as metadata$1, v as properties, N as resolveItemModelFileId, F as versions, ah as normalizePublisher, aj as loadNameMatchLevels, p as htmlEmbeddedImageCoPublish, k as arweaveL1FinalizeJobs, z as publishProcesses, aX as getWatchedAddressesFromDb, aY as getOwnedAddressesFromDb, aZ as CLIENT_NOT_INITIALIZED } from './BasePathResolver-CBTXCMFL.js';
3
3
  import debug from 'debug';
4
4
  import { createActor, setup, assign, fromPromise, fromCallback, waitFor } from 'xstate';
5
- import { u as MachineIds, a0 as ClientManagerEvents, a1 as withLockedItemStorageRow, a2 as getItemStorageFilePath, a3 as writeItemStorageFile, e as compareMetadataRowsLatestFirst, w as writeInBatches, a4 as resolvePublisherFromSeedRow, C as ClientManagerState, G as isLocalUnsealedDraft, s as selectInBatches, I as Item } from './Item-BDmsdNTQ.js';
5
+ import { u as MachineIds, a0 as ClientManagerEvents, a1 as withLockedItemStorageRow, a2 as getItemStorageFilePath, a3 as writeItemStorageFile, e as compareMetadataRowsLatestFirst, w as writeInBatches, a4 as resolvePublisherFromSeedRow, C as ClientManagerState, G as isLocalUnsealedDraft, s as selectInBatches, I as Item } from './Item-DTJPMjFk.js';
6
6
  import { eq, inArray, and, isNotNull, ne, desc, countDistinct, isNull, or, sql, like } from 'drizzle-orm';
7
- import { a as withDbTabLock, i as isLeaderTab, c as postTabMessage, o as onTabMessage, w as whenLeaderTab, l as listenForOtherTabsEvents, s as startTabCoordination, b as withSeedDbLock, e as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, p as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT } from './tabEvents-DXun7vdK.js';
7
+ import { a as withDbTabLock, i as isLeaderTab, c as postTabMessage, o as onTabMessage, w as whenLeaderTab, l as listenForOtherTabsEvents, s as startTabCoordination, b as withSeedDbLock, e as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, p as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT } from './tabEvents-BGBYV65P.js';
8
8
  import { seedGatewayConfigFromSeedConfig, setPreferredArweaveReadBaseUrls, resolveSeedGatewayEndpoints, setResolvedSeedGatewayEndpoints, BaseArweaveClient, ensureReadGatewaySelected, DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
9
9
  import { configureEasReadChain, easName, BaseQueryClient, BaseEasClient, GET_SCHEMAS, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, isPlaceholderUid, localNamesInBestMatchTier, isValidEasAttestationUid } from '@seedprotocol/eas';
10
10
  import 'pluralize';
@@ -212,7 +212,7 @@ function toRunSyncArg(options) {
212
212
  return undefined;
213
213
  }
214
214
  const runEasSync = fromPromise(async ({ input, }) => {
215
- const { runSyncFromEas } = await import('./syncDbWithEas-BmJXqfgN.js');
215
+ const { runSyncFromEas } = await import('./syncDbWithEas-CrAY9Rl2.js');
216
216
  // Sync checks for rows and then inserts the rest (no unique index on uids), so syncs in
217
217
  // different tabs take turns. A sync can run for minutes, so wait without a timeout.
218
218
  await withDbTabLock('eas-sync', async () => {
@@ -609,7 +609,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
609
609
  }
610
610
  // Prefer the condition-resolved factory when available; fall back to explicit
611
611
  // platform imports so source/vitest resolution stays reliable.
612
- const { configurePlatform } = await import('./configurePlatform-CFQF_i1T.js');
612
+ const { configurePlatform } = await import('./configurePlatform-D4aGjKNk.js');
613
613
  if (isBrowser()) {
614
614
  const { createPlatformServices } = await import('./platform.browser.js');
615
615
  configurePlatform(createPlatformServices());
@@ -651,11 +651,9 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
651
651
  if (isNode() && !isBrowser() && normalizedFilesDir) {
652
652
  const path = (await import('node:path')).default;
653
653
  const fs = (await import('node:fs')).default;
654
+ // Not created here: prepareDb creates filesDir (under .seed when it's relative), so an absolute
655
+ // filesDir works from a read-only working directory (e.g. a packaged Electron app's cwd `/`).
654
656
  const dotSeedDir = BasePathResolver.getDotSeedDir();
655
- // Ensure .seed directory exists
656
- if (!fs.existsSync(dotSeedDir)) {
657
- fs.mkdirSync(dotSeedDir, { recursive: true });
658
- }
659
657
  // Check if filesDir is a browser OPFS-style path (absolute path starting with '/'
660
658
  // that is a simple single-level path like '/app-files', not a real filesystem path)
661
659
  // Browser OPFS paths are typically simple like '/app-files', '/files', etc.
@@ -2025,7 +2023,7 @@ function getRefValueType(prop) {
2025
2023
  * @returns Promise that resolves when properties are found, or rejects if not found after max retries
2026
2024
  */
2027
2025
  const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10, retryDelay = 100) => {
2028
- const _mod_0 = await import('./BasePathResolver-B-fK7_N_.js');
2026
+ const _mod_0 = await import('./BasePathResolver-CBTXCMFL.js');
2029
2027
  const _ns_0 = _mod_0.bb;
2030
2028
  const modelSchemaMod = _ns_0;
2031
2029
  const { properties: propertiesTable } = modelSchemaMod;
@@ -2418,7 +2416,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2418
2416
  // Check DB for existing schema by name+version (same as minimal path)
2419
2417
  const db = BaseDb.getAppDb();
2420
2418
  if (db) {
2421
- const _mod_1 = await import('./BasePathResolver-B-fK7_N_.js');
2419
+ const _mod_1 = await import('./BasePathResolver-CBTXCMFL.js');
2422
2420
  const _ns_1 = _mod_1.bd;
2423
2421
  const schemaSchemaMod = _ns_1;
2424
2422
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -2503,7 +2501,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2503
2501
  // For minimal imports: check DB for existing schema before creating new file
2504
2502
  const db = BaseDb.getAppDb();
2505
2503
  if (db) {
2506
- const _mod_2 = await import('./BasePathResolver-B-fK7_N_.js');
2504
+ const _mod_2 = await import('./BasePathResolver-CBTXCMFL.js');
2507
2505
  const _ns_2 = _mod_2.bd;
2508
2506
  const schemaSchemaMod = _ns_2;
2509
2507
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -2684,7 +2682,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2684
2682
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
2685
2683
  };
2686
2684
  // Use dynamic import to break circular dependency
2687
- const _mod_3 = await import('./BasePathResolver-B-fK7_N_.js');
2685
+ const _mod_3 = await import('./BasePathResolver-CBTXCMFL.js');
2688
2686
  const _ns_3 = _mod_3.bg;
2689
2687
  const dbMod = _ns_3;
2690
2688
  const { addSchemaToDb, addModelsToDb } = dbMod;
@@ -2706,11 +2704,11 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2706
2704
  });
2707
2705
  // Verify expected models are linked (single attempt - addModelsToDb already confirmed)
2708
2706
  const expectedModelNames = Object.keys(schemaFile.models || {});
2709
- const _mod_4 = await import('./BasePathResolver-B-fK7_N_.js');
2707
+ const _mod_4 = await import('./BasePathResolver-CBTXCMFL.js');
2710
2708
  const _ns_4 = _mod_4.be;
2711
2709
  const modelSchemaSchemaMod = _ns_4;
2712
2710
  const { modelSchemas } = modelSchemaSchemaMod;
2713
- const _mod_5 = await import('./BasePathResolver-B-fK7_N_.js');
2711
+ const _mod_5 = await import('./BasePathResolver-CBTXCMFL.js');
2714
2712
  const _ns_5 = _mod_5.bb;
2715
2713
  const modelSchemaMod = _ns_5;
2716
2714
  const { models: modelsTable } = modelSchemaMod;
@@ -2909,7 +2907,7 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
2909
2907
  createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
2910
2908
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
2911
2909
  };
2912
- const _mod_6 = await import('./BasePathResolver-B-fK7_N_.js');
2910
+ const _mod_6 = await import('./BasePathResolver-CBTXCMFL.js');
2913
2911
  const _ns_6 = _mod_6.bg;
2914
2912
  const dbMod = _ns_6;
2915
2913
  const { addSchemaToDb, addModelsToDb } = dbMod;
@@ -3078,11 +3076,11 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3078
3076
  ]));
3079
3077
  const { schemaRecord } = await applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, propertyFileIds, propertyDefinitions);
3080
3078
  // Query the database to get model IDs that were just created
3081
- const _mod_7 = await import('./BasePathResolver-B-fK7_N_.js');
3079
+ const _mod_7 = await import('./BasePathResolver-CBTXCMFL.js');
3082
3080
  const _ns_7 = _mod_7.be;
3083
3081
  const modelSchemaSchemaMod = _ns_7;
3084
3082
  const { modelSchemas } = modelSchemaSchemaMod;
3085
- const _mod_8 = await import('./BasePathResolver-B-fK7_N_.js');
3083
+ const _mod_8 = await import('./BasePathResolver-CBTXCMFL.js');
3086
3084
  const _ns_8 = _mod_8.bb;
3087
3085
  const modelSchemaMod = _ns_8;
3088
3086
  const { models: modelsTable } = modelSchemaMod;
@@ -3148,7 +3146,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3148
3146
  // After properties are created (file path), ensure schemaFile has the correct IDs from database
3149
3147
  // Query the database to get the actual schemaFileId values that were used
3150
3148
  // This ensures schemaData matches what's actually in the database
3151
- const _mod_9 = await import('./BasePathResolver-B-fK7_N_.js');
3149
+ const _mod_9 = await import('./BasePathResolver-CBTXCMFL.js');
3152
3150
  const _ns_9 = _mod_9.bb;
3153
3151
  const modelSchemaMod2 = _ns_9;
3154
3152
  const { properties: propertiesTable } = modelSchemaMod2;
@@ -3184,7 +3182,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3184
3182
  // This is important even if nothing changed, to ensure consistency
3185
3183
  const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
3186
3184
  // Update the schema record in the database with current schemaData
3187
- const _mod_10 = await import('./BasePathResolver-B-fK7_N_.js');
3185
+ const _mod_10 = await import('./BasePathResolver-CBTXCMFL.js');
3188
3186
  const _ns_10 = _mod_10.bd;
3189
3187
  const schemaSchemaMod = _ns_10;
3190
3188
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -3295,7 +3293,7 @@ const jsonPropertiesToSchemaProperties = (modelName, modelDef, propertyFileIds)
3295
3293
  */
3296
3294
  const createModelFromJson = async (modelName, modelDef, schemaName, modelFileId, // Optional modelFileId from JSON file
3297
3295
  propertyFileIds) => {
3298
- const _mod_11 = await import('./errors-CCMxedOB.js');
3296
+ const _mod_11 = await import('./errors-CIrbsN_i.js');
3299
3297
  const _ns_11 = _mod_11.h;
3300
3298
  const modelMod = _ns_11;
3301
3299
  const { Model } = modelMod;
@@ -5366,19 +5364,24 @@ async function claimUnpublishedDrafts(publisher) {
5366
5364
  }
5367
5365
 
5368
5366
  const logger = debug('seedSdk:client');
5369
- const clientManager = createActor(clientManagerMachine, {
5370
- input: {
5371
- isInitialized: false,
5372
- addressesSet: false,
5373
- isSaving: false,
5374
- syncFromEasOnAddressChange: false,
5375
- }
5376
- });
5377
- const subscription = clientManager.subscribe((snapshot) => {
5378
- logger('ClientManager snapshot.value:', snapshot.value);
5379
- logger('ClientManager snapshot.context.isInitialized:', snapshot.context.isInitialized);
5380
- });
5381
- clientManager.start();
5367
+ const createClientManager = () => {
5368
+ const actor = createActor(clientManagerMachine, {
5369
+ input: {
5370
+ isInitialized: false,
5371
+ addressesSet: false,
5372
+ isSaving: false,
5373
+ syncFromEasOnAddressChange: false,
5374
+ }
5375
+ });
5376
+ const actorSubscription = actor.subscribe((snapshot) => {
5377
+ logger('ClientManager snapshot.value:', snapshot.value);
5378
+ logger('ClientManager snapshot.context.isInitialized:', snapshot.context.isInitialized);
5379
+ });
5380
+ actor.start();
5381
+ return { actor, actorSubscription };
5382
+ };
5383
+ // Replaced when init runs after stop(): an xstate actor can't be started again once stopped.
5384
+ let { actor: clientManager, actorSubscription: subscription } = createClientManager();
5382
5385
  /** Config of the init that is running or has succeeded; cleared when init fails or the client stops. */
5383
5386
  let activeInitConfig;
5384
5387
  const INIT_CONFIG_CONFLICT_MESSAGE = 'client.init was already called with a different config. The SDK keeps the config it was ' +
@@ -5395,19 +5398,13 @@ const coalescedInit = createCoalescedAsync(async (options) => {
5395
5398
  const currentState = snapshot.value;
5396
5399
  const isStopped = snapshot.status === 'stopped';
5397
5400
  if (isStopped) {
5398
- logger('Client manager was stopped, restarting...');
5399
- clientManager.start();
5400
- // Wait for the actor to be ready
5401
- try {
5402
- await waitFor(clientManager, (snapshot) => snapshot.status !== 'stopped', { timeout: 1000 });
5403
- }
5404
- catch (e) {
5405
- logger('Timeout waiting for actor to restart, continuing anyway...');
5406
- }
5401
+ // stop() (or a failed test) stopped it: start over with a new actor and a clean context.
5402
+ logger('Client manager was stopped, creating a new one');
5403
+ ({ actor: clientManager, actorSubscription: subscription } = createClientManager());
5407
5404
  }
5408
5405
  // Clear any stale context from previous failed initializations
5409
5406
  // This ensures we start with a clean slate before the new init updates it
5410
- if (currentState !== 'uninitialized') {
5407
+ if (!isStopped && currentState !== 'uninitialized') {
5411
5408
  logger(`Client manager is in state ${currentState}, clearing stale context before re-init...`);
5412
5409
  clientManager.send({
5413
5410
  type: 'updateContext',
@@ -5466,7 +5463,9 @@ const coalescedInit = createCoalescedAsync(async (options) => {
5466
5463
  registerSeedQueryLocalSource({ force: true });
5467
5464
  }, () => {
5468
5465
  const snapshot = clientManager.getSnapshot();
5469
- return (snapshot.value === ClientManagerState.IDLE &&
5466
+ // A stopped client keeps its last state and context: init must run again, not be skipped.
5467
+ return (snapshot.status === 'active' &&
5468
+ snapshot.value === ClientManagerState.IDLE &&
5470
5469
  snapshot.context.isInitialized === true &&
5471
5470
  !snapshot.context.initError);
5472
5471
  });
@@ -5474,7 +5473,8 @@ const coalescedInit = createCoalescedAsync(async (options) => {
5474
5473
  // ES modules cache exports, ensuring all imports get the same instance
5475
5474
  const clientInstance = {
5476
5475
  isInitialized: () => {
5477
- return clientManager.getSnapshot().context.isInitialized;
5476
+ const snapshot = clientManager.getSnapshot();
5477
+ return snapshot.status === 'active' && snapshot.context.isInitialized;
5478
5478
  },
5479
5479
  getService: () => {
5480
5480
  // ensureInitialized();
@@ -5646,9 +5646,9 @@ var ClientManager$1 = /*#__PURE__*/Object.freeze({
5646
5646
  __proto__: null,
5647
5647
  ClientManager: ClientManager,
5648
5648
  INIT_CONFIG_CONFLICT_MESSAGE: INIT_CONFIG_CONFLICT_MESSAGE,
5649
- clientManager: clientManager,
5649
+ get clientManager () { return clientManager; },
5650
5650
  getClient: getClient
5651
5651
  });
5652
5652
 
5653
5653
  export { requestEasSyncFromEventBus as A, requestEasSyncFromModelsInit as B, ClientManager as C, sendEasSyncClientRequest as D, EAS_CHAIN_ID_APP_STATE_KEY as E, setRetriesWhenOnlineEnabled as F, startEasSyncActor as G, unregisterSeedQueryLocalSource as H, INIT_CONFIG_CONFLICT_MESSAGE as I, createModelsFromJson as J, getLatestSchemaVersion as K, jsonPropertiesToSchemaProperties as L, schema as M, ClientManager$1 as N, SEEDPROTOCOL_Seed_Protocol_v1 as S, getContentHash as a, isVerbatimItemStorageDraftRow as b, convertVerbatimItemStorageRow as c, assertLocalDbChain as d, claimUnpublishedDrafts as e, createLocalQueryDataSource as f, getRefValueType as g, hardDeleteLocalSeedsByLocalIds as h, importJsonSchema as i, createSchema as j, easSyncActor as k, loadSchemaFromFile as l, getClient as m, getPublishedSeedRecord as n, getSchemaNameFromId as o, isSeedQueryLocalSourceRegistered as p, listCompleteSchemaFiles as q, readJsonImportFile as r, syncSchemaFromSource as s, transformImportToSchemaFile as t, loadAllSchemasFromDb as u, mergeEasSyncRequestIntents as v, waitForEasReadChain as w, readSchema as x, registerSeedQueryLocalSource as y, requestEasSyncFromAddressChange as z };
5654
- //# sourceMappingURL=ClientManager-C7VkO5Hg.js.map
5654
+ //# sourceMappingURL=ClientManager-DRf4uuei.js.map