@seedprotocol/sdk 0.7.9-next.1177.ga3e08ed → 0.7.9-next.1306.g4ff6582
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/BaseFileManager-BAlySv8w.js +650 -0
- package/dist/BaseFileManager-BAlySv8w.js.map +1 -0
- package/dist/{Item-0oDoTPhi.js → Item-Bf4kWKpH.js} +5647 -6573
- package/dist/Item-Bf4kWKpH.js.map +1 -0
- package/dist/{ModelProperty-i5flwzQG.js → ModelProperty-BlaEgb_U.js} +345 -709
- package/dist/ModelProperty-BlaEgb_U.js.map +1 -0
- package/dist/Schema-J_1f6p0c.js +1456 -0
- package/dist/Schema-J_1f6p0c.js.map +1 -0
- package/dist/{SchemaValidationService-DnGKel4V.js → SchemaValidationService-CnmKyzR-.js} +6 -9
- package/dist/{SchemaValidationService-DnGKel4V.js.map → SchemaValidationService-CnmKyzR-.js.map} +1 -1
- package/dist/{configurePlatform-CrMafpMW.js → configurePlatform-CiOJ1R3q.js} +3 -12
- package/dist/configurePlatform-CiOJ1R3q.js.map +1 -0
- package/dist/db/drizzle/0025_add_metadata_retract.sql +1 -0
- package/dist/db/drizzle/0026_add_content_hash_to_schemas.sql +1 -0
- package/dist/db/drizzle/0027_link_metadata_property_ids.sql +74 -0
- package/dist/db/drizzle/0028_add_definition_to_properties.sql +17 -0
- package/dist/db/drizzle/0029_dedupe_chain_uids_add_unique_indexes.sql +120 -0
- package/dist/db/drizzle/meta/0025_snapshot.json +1652 -0
- package/dist/db/drizzle/meta/0026_snapshot.json +1659 -0
- package/dist/db/drizzle/meta/0027_snapshot.json +1659 -0
- package/dist/db/drizzle/meta/0028_snapshot.json +1666 -0
- package/dist/db/drizzle/meta/0029_snapshot.json +1691 -0
- package/dist/db/drizzle/meta/_journal.json +36 -1
- package/dist/{detachRowsBeforeDelete-DXFYSHRR.js → detachRowsBeforeDelete-sEaUwlOU.js} +2 -13
- package/dist/{detachRowsBeforeDelete-DXFYSHRR.js.map → detachRowsBeforeDelete-sEaUwlOU.js.map} +1 -1
- package/dist/dist/{index-Dx_GTdyQ.d.ts → BaseFileManager-BAlySv8w.d.ts} +1424 -2696
- package/dist/dist/BaseFileManager-BAlySv8w.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-CrMafpMW.d.ts → configurePlatform-CiOJ1R3q.d.ts} +1 -1
- package/dist/dist/configurePlatform-CiOJ1R3q.d.ts.map +1 -0
- package/dist/dist/{index-PbnKw2es.d.ts → index-D0V-mjCV.d.ts} +56 -1
- package/dist/dist/{index-PbnKw2es.d.ts.map → index-D0V-mjCV.d.ts.map} +1 -1
- package/dist/dist/{index.node-CzMwMr_d.d.ts → index.node-CYPemH-t.d.ts} +225 -5
- package/dist/dist/{index.node-CzMwMr_d.d.ts.map → index.node-CYPemH-t.d.ts.map} +1 -1
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/eas-wB_fQ8Tc.js +32 -0
- package/dist/eas-wB_fQ8Tc.js.map +1 -0
- package/dist/errors-DLSoqSHG.js +6550 -0
- package/dist/errors-DLSoqSHG.js.map +1 -0
- package/dist/getPublishPayload-BnIwpwz1.js +760 -0
- package/dist/getPublishPayload-BnIwpwz1.js.map +1 -0
- package/dist/getPublishPendingDiff-D6_-A5ns.js +125 -0
- package/dist/getPublishPendingDiff-D6_-A5ns.js.map +1 -0
- package/dist/getPublishUploads-sS6JfPgz.js +783 -0
- package/dist/getPublishUploads-sS6JfPgz.js.map +1 -0
- package/dist/{index-DJmWkVIK.js → index-BVBmz_cc.js} +11 -14
- package/dist/index-BVBmz_cc.js.map +1 -0
- package/dist/index-CYGWPoOx.js +27 -0
- package/dist/index-CYGWPoOx.js.map +1 -0
- package/dist/{index-PbnKw2es.js → index-D0V-mjCV.js} +2 -2
- package/dist/index-D0V-mjCV.js.map +1 -0
- package/dist/index-DmTtj1nk.js +817 -0
- package/dist/index-DmTtj1nk.js.map +1 -0
- package/dist/{index.browser-i9uPJice.js → index.browser-CUmBVYen.js} +436 -379
- package/dist/index.browser-CUmBVYen.js.map +1 -0
- package/dist/{index.node-CzMwMr_d.js → index.node-CYPemH-t.js} +10 -10
- package/dist/index.node-CYPemH-t.js.map +1 -0
- package/dist/main.js +23 -1105
- package/dist/main.js.map +1 -1
- package/dist/modelPropertyRecordSchemas-C7UgA5TH.js +48 -0
- package/dist/modelPropertyRecordSchemas-C7UgA5TH.js.map +1 -0
- package/dist/node.js +14 -18
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +8 -13
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +6 -16
- package/dist/platform.node.js.map +1 -1
- package/dist/property-BxUYznH0.js +87 -0
- package/dist/property-BxUYznH0.js.map +1 -0
- package/dist/publishGraph-EcB40Uii.js +311 -0
- package/dist/publishGraph-EcB40Uii.js.map +1 -0
- package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js +110 -0
- package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js.map +1 -0
- package/dist/seedSchema/MetadataSchema.ts +3 -0
- package/dist/seedSchema/ModelSchema.ts +4 -0
- package/dist/seedSchema/ModelSchemaSchema.ts +5 -2
- package/dist/seedSchema/PendingWriteSchema.ts +4 -1
- package/dist/seedSchema/SchemaSchema.ts +3 -0
- package/dist/seedSchema/SeedSchema.ts +8 -2
- package/dist/seedSchema/VersionSchema.ts +7 -2
- package/dist/seedSchema/attestedUid.ts +10 -0
- package/dist/src/Item/Item.d.ts +32 -30
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/loadItem.d.ts +12 -0
- package/dist/src/Item/loadItem.d.ts.map +1 -0
- package/dist/src/Item/service/itemMachineSingle.d.ts +2 -13
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +98 -41
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/loadProperty.d.ts +11 -0
- package/dist/src/ItemProperty/loadProperty.d.ts.map +1 -0
- package/dist/src/ItemProperty/propertyWrite.d.ts +54 -0
- package/dist/src/ItemProperty/propertyWrite.d.ts.map +1 -0
- package/dist/src/ItemProperty/{service/actors/saveValueToDb/rowContext.d.ts → rowContext.d.ts} +1 -1
- package/dist/src/ItemProperty/rowContext.d.ts.map +1 -0
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +6 -0
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts +5 -15
- package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +3 -46
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +26 -56
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/createModelProperties.d.ts +10 -0
- package/dist/src/Model/createModelProperties.d.ts.map +1 -0
- package/dist/src/Model/loadModel.d.ts +13 -0
- package/dist/src/Model/loadModel.d.ts.map +1 -0
- package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/src/Model/service/modelMachine.d.ts +5 -114
- package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +44 -37
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +6 -77
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +36 -37
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/loadOrCreateSchema.d.ts +21 -0
- package/dist/src/Schema/loadOrCreateSchema.d.ts.map +1 -0
- package/dist/src/Schema/service/schemaMachine.d.ts +7 -125
- package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/changeFeed.d.ts +2 -18
- package/dist/src/browser/db/changeFeed.d.ts.map +1 -1
- package/dist/src/browser/db/drizzleFiles.d.ts +7 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
- package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +90 -57
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts +9 -7
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/dbInit.d.ts +3 -3
- package/dist/src/client/actors/dbInit.d.ts.map +1 -1
- package/dist/src/client/actors/fileSystemInit.d.ts +3 -3
- package/dist/src/client/actors/fileSystemInit.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts +10 -5
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/processSchemaFiles.d.ts +18 -3
- package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts +6 -3
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +22 -20
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/client/constants.d.ts +1 -9
- package/dist/src/client/constants.d.ts.map +1 -1
- package/dist/src/client/readiness.d.ts +26 -0
- package/dist/src/client/readiness.d.ts.map +1 -0
- package/dist/src/db/read/currentPropertyRow.d.ts +61 -0
- package/dist/src/db/read/currentPropertyRow.d.ts.map +1 -0
- package/dist/src/db/read/findSeedRow.d.ts +20 -0
- package/dist/src/db/read/findSeedRow.d.ts.map +1 -0
- package/dist/src/db/read/findSeedRowsByUid.d.ts +4 -1
- package/dist/src/db/read/findSeedRowsByUid.d.ts.map +1 -1
- package/dist/src/db/read/getAttesterForSeed.d.ts +1 -1
- package/dist/src/db/read/getAttesterForSeed.d.ts.map +1 -1
- package/dist/src/db/read/getItemData.d.ts.map +1 -1
- package/dist/src/db/read/getItemProperties.d.ts +5 -0
- package/dist/src/db/read/getItemProperties.d.ts.map +1 -1
- package/dist/src/db/read/getMetadataAttestationUidsForSeedUid.d.ts.map +1 -1
- package/dist/src/db/read/getModelSchemas.d.ts +0 -7
- package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
- package/dist/src/db/read/getModelsData.d.ts.map +1 -1
- package/dist/src/db/read/getPropertyClear.d.ts +49 -0
- package/dist/src/db/read/getPropertyClear.d.ts.map +1 -0
- package/dist/src/db/read/getPublishPayload.d.ts +35 -40
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPendingDiff.d.ts +7 -2
- package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +59 -28
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
- package/dist/src/db/read/getSeedPublishState.d.ts.map +1 -1
- package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -1
- package/dist/src/db/read/getVersionsForSeedUid.d.ts.map +1 -1
- package/dist/src/db/read/isSeedRevoked.d.ts.map +1 -1
- package/dist/src/db/read/localModelSchemaLookups.d.ts +8 -0
- package/dist/src/db/read/localModelSchemaLookups.d.ts.map +1 -0
- package/dist/src/db/read/metadataProperty.d.ts +104 -0
- package/dist/src/db/read/metadataProperty.d.ts.map +1 -0
- package/dist/src/db/read/publishGraph.d.ts +148 -0
- package/dist/src/db/read/publishGraph.d.ts.map +1 -0
- package/dist/src/db/read/resolveModelRecord.d.ts +26 -2
- package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
- package/dist/src/db/read/resolveRelatedSeedRef.d.ts +1 -7
- package/dist/src/db/read/resolveRelatedSeedRef.d.ts.map +1 -1
- package/dist/src/db/read/subqueries/metadataLatest.d.ts +3 -1
- package/dist/src/db/read/subqueries/metadataLatest.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts +18 -5
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +20 -21
- package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createNewItem.d.ts.map +1 -1
- package/dist/src/db/write/createSeeds.d.ts +5 -1
- package/dist/src/db/write/createSeeds.d.ts.map +1 -1
- package/dist/src/db/write/definitions.d.ts +127 -0
- package/dist/src/db/write/definitions.d.ts.map +1 -0
- package/dist/src/db/write/markPropertyAttestationsRetracted.d.ts +11 -0
- package/dist/src/db/write/markPropertyAttestationsRetracted.d.ts.map +1 -0
- package/dist/src/db/write/mergeChainRows.d.ts +22 -0
- package/dist/src/db/write/mergeChainRows.d.ts.map +1 -0
- package/dist/src/db/write/saveDefinition.d.ts +29 -0
- package/dist/src/db/write/saveDefinition.d.ts.map +1 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts +2 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/db/write/updateSeedUid.d.ts +4 -2
- package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
- package/dist/src/db/write/updateVersionUid.d.ts +12 -4
- package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
- package/dist/src/db/write/writeModelUids.d.ts +10 -0
- package/dist/src/db/write/writeModelUids.d.ts.map +1 -0
- package/dist/src/eas.d.ts +8 -6
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/arweaveContentTags.d.ts +1 -1
- package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -1
- package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts +27 -12
- package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts +5 -2
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/dataUrl.d.ts +10 -0
- package/dist/src/helpers/dataUrl.d.ts.map +1 -0
- package/dist/src/helpers/db.d.ts +54 -105
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/ensureImageLocal.d.ts.map +1 -1
- package/dist/src/helpers/entity/contextUpdate.d.ts +20 -0
- package/dist/src/helpers/entity/contextUpdate.d.ts.map +1 -0
- package/dist/src/helpers/entity/draftSaveErrors.d.ts +5 -0
- package/dist/src/helpers/entity/draftSaveErrors.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCache.d.ts +65 -3
- package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCommon.d.ts +0 -22
- package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLifecycle.d.ts +75 -0
- package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -0
- package/dist/src/helpers/entity/entityLiveQuery.d.ts +1 -23
- package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +4 -9
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +2 -24
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/localImageBlobUrl.d.ts +7 -0
- package/dist/src/helpers/localImageBlobUrl.d.ts.map +1 -0
- package/dist/src/helpers/mediaRef.d.ts +3 -70
- package/dist/src/helpers/mediaRef.d.ts.map +1 -1
- package/dist/src/helpers/metadataPropertyNames.d.ts +34 -21
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/mimeTypes.d.ts +2 -1
- package/dist/src/helpers/mimeTypes.d.ts.map +1 -1
- package/dist/src/helpers/model.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/property.d.ts +21 -26
- package/dist/src/helpers/property.d.ts.map +1 -1
- package/dist/src/helpers/propertyDefinition.d.ts +59 -0
- package/dist/src/helpers/propertyDefinition.d.ts.map +1 -0
- package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
- package/dist/src/helpers/relationSeedRef.d.ts +0 -7
- package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
- package/dist/src/helpers/schema.d.ts +24 -38
- package/dist/src/helpers/schema.d.ts.map +1 -1
- package/dist/src/helpers/schemaApply.d.ts +135 -0
- package/dist/src/helpers/schemaApply.d.ts.map +1 -0
- package/dist/src/helpers/tabEvents.d.ts.map +1 -1
- package/dist/src/helpers/updateSchema.d.ts +2 -18
- package/dist/src/helpers/updateSchema.d.ts.map +1 -1
- package/dist/src/imports/index.d.ts +1 -1
- package/dist/src/imports/index.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts +8 -78
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +16 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +5 -0
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/interfaces/IItemProperty.d.ts +13 -7
- package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +3 -2
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/outbox/conflicts.d.ts +2 -0
- package/dist/src/outbox/conflicts.d.ts.map +1 -1
- package/dist/src/outbox/itemAppliers.d.ts +70 -14
- package/dist/src/outbox/itemAppliers.d.ts.map +1 -1
- package/dist/src/outbox/outbox.d.ts +14 -3
- package/dist/src/outbox/outbox.d.ts.map +1 -1
- package/dist/src/outbox/pendingValues.d.ts +3 -1
- package/dist/src/outbox/pendingValues.d.ts.map +1 -1
- package/dist/src/outbox/storageValueRow.d.ts +7 -0
- package/dist/src/outbox/storageValueRow.d.ts.map +1 -0
- package/dist/src/platform/configurePlatform.d.ts.map +1 -1
- package/dist/src/platform/index.browser.d.ts.map +1 -1
- package/dist/src/platform/index.node.d.ts.map +1 -1
- package/dist/src/seedSchema/MetadataSchema.d.ts +17 -0
- package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/ModelSchema.d.ts +19 -0
- package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/ModelSchemaSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/PendingWriteSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/SchemaSchema.d.ts +19 -0
- package/dist/src/seedSchema/SchemaSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/attestedUid.d.ts +9 -0
- package/dist/src/seedSchema/attestedUid.d.ts.map +1 -0
- package/dist/src/storageValue/content.d.ts +45 -0
- package/dist/src/storageValue/content.d.ts.map +1 -0
- package/dist/src/storageValue/findFile.d.ts +7 -0
- package/dist/src/storageValue/findFile.d.ts.map +1 -0
- package/dist/src/storageValue/resolve.d.ts +71 -0
- package/dist/src/storageValue/resolve.d.ts.map +1 -0
- package/dist/src/storageValue/save.d.ts +24 -0
- package/dist/src/storageValue/save.d.ts.map +1 -0
- package/dist/src/storageValue/stage.d.ts +22 -0
- package/dist/src/storageValue/stage.d.ts.map +1 -0
- package/dist/src/types/db.d.ts +0 -14
- package/dist/src/types/db.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +3 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/machines.d.ts +1 -1
- package/dist/src/types/machines.d.ts.map +1 -1
- package/dist/src/types/property.d.ts +9 -16
- package/dist/src/types/property.d.ts.map +1 -1
- package/dist/src/types/publish.d.ts +1 -1
- package/dist/src/types/publish.d.ts.map +1 -1
- package/dist/{syncDbWithEas-DUu_wjUG.js → syncDbWithEas-CA7PvBgu.js} +142 -168
- package/dist/syncDbWithEas-CA7PvBgu.js.map +1 -0
- package/dist/tabEvents-CaVmngqr.js +3804 -0
- package/dist/tabEvents-CaVmngqr.js.map +1 -0
- package/dist/{tolerantWebAccess-DecKDGen.js → tolerantWebAccess-BJqViq08.js} +10 -15
- package/dist/{tolerantWebAccess-DecKDGen.js.map → tolerantWebAccess-BJqViq08.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-4gO9Hfn2.js → updateSeedRevokedAt-BL9Bg-G7.js} +30 -4
- package/dist/updateSeedRevokedAt-BL9Bg-G7.js.map +1 -0
- package/package.json +6 -6
- package/dist/ClientManager-GZfXErDX.js +0 -5279
- package/dist/ClientManager-GZfXErDX.js.map +0 -1
- package/dist/Item-0oDoTPhi.js.map +0 -1
- package/dist/ModelProperty-i5flwzQG.js.map +0 -1
- package/dist/Schema-PFZwG9Nl.js +0 -4370
- package/dist/Schema-PFZwG9Nl.js.map +0 -1
- package/dist/backfillMetadataPropertyIds-BbxgavEQ.js +0 -72
- package/dist/backfillMetadataPropertyIds-BbxgavEQ.js.map +0 -1
- package/dist/changeFeed-DKdVlUmt.js +0 -726
- package/dist/changeFeed-DKdVlUmt.js.map +0 -1
- package/dist/configurePlatform-CrMafpMW.js.map +0 -1
- package/dist/dist/ClientManager-GZfXErDX.d.ts +0 -952
- package/dist/dist/ClientManager-GZfXErDX.d.ts.map +0 -1
- package/dist/dist/Item-0oDoTPhi.d.ts +0 -1076
- package/dist/dist/Item-0oDoTPhi.d.ts.map +0 -1
- package/dist/dist/ModelProperty-i5flwzQG.d.ts +0 -315
- package/dist/dist/ModelProperty-i5flwzQG.d.ts.map +0 -1
- package/dist/dist/Schema-PFZwG9Nl.d.ts +0 -432
- package/dist/dist/Schema-PFZwG9Nl.d.ts.map +0 -1
- package/dist/dist/SchemaValidationService-DnGKel4V.d.ts +0 -118
- package/dist/dist/SchemaValidationService-DnGKel4V.d.ts.map +0 -1
- package/dist/dist/backfillMetadataPropertyIds-BbxgavEQ.d.ts +0 -7
- package/dist/dist/backfillMetadataPropertyIds-BbxgavEQ.d.ts.map +0 -1
- package/dist/dist/changeFeed-DKdVlUmt.d.ts +0 -160
- package/dist/dist/changeFeed-DKdVlUmt.d.ts.map +0 -1
- package/dist/dist/configurePlatform-CrMafpMW.d.ts.map +0 -1
- package/dist/dist/detachRowsBeforeDelete-DXFYSHRR.d.ts +0 -13
- package/dist/dist/detachRowsBeforeDelete-DXFYSHRR.d.ts.map +0 -1
- package/dist/dist/eas-dyepi5jz.d.ts +0 -12
- package/dist/dist/eas-dyepi5jz.d.ts.map +0 -1
- package/dist/dist/errors-C1qUEZ7A.d.ts +0 -25
- package/dist/dist/errors-C1qUEZ7A.d.ts.map +0 -1
- package/dist/dist/errors-D1zHAqjr.d.ts +0 -515
- package/dist/dist/errors-D1zHAqjr.d.ts.map +0 -1
- package/dist/dist/eventBus-7vxTCc3a.d.ts +0 -18
- package/dist/dist/eventBus-7vxTCc3a.d.ts.map +0 -1
- package/dist/dist/findSeedRowsByUid-CT3sOXXw.d.ts +0 -13
- package/dist/dist/findSeedRowsByUid-CT3sOXXw.d.ts.map +0 -1
- package/dist/dist/getItem-Bhjecbia.d.ts +0 -6
- package/dist/dist/getItem-Bhjecbia.d.ts.map +0 -1
- package/dist/dist/getPublishPayload-DH4rMqXG.d.ts +0 -47
- package/dist/dist/getPublishPayload-DH4rMqXG.d.ts.map +0 -1
- package/dist/dist/getPublishUploads-BzUIDA2G.d.ts +0 -89
- package/dist/dist/getPublishUploads-BzUIDA2G.d.ts.map +0 -1
- package/dist/dist/index-CkYb3wcU.d.ts +0 -14
- package/dist/dist/index-CkYb3wcU.d.ts.map +0 -1
- package/dist/dist/index-DJmWkVIK.d.ts +0 -6
- package/dist/dist/index-DJmWkVIK.d.ts.map +0 -1
- package/dist/dist/index-Dx_GTdyQ.d.ts.map +0 -1
- package/dist/dist/index.browser-i9uPJice.d.ts +0 -9908
- package/dist/dist/index.browser-i9uPJice.d.ts.map +0 -1
- package/dist/dist/mimeTypes-C9r76DCH.d.ts +0 -30
- package/dist/dist/mimeTypes-C9r76DCH.d.ts.map +0 -1
- package/dist/dist/model-oHA3YhOd.d.ts +0 -6
- package/dist/dist/model-oHA3YhOd.d.ts.map +0 -1
- package/dist/dist/modelPropertyRecordSchemas-C5lW9aA-.d.ts +0 -7
- package/dist/dist/modelPropertyRecordSchemas-C5lW9aA-.d.ts.map +0 -1
- package/dist/dist/platform.browser.d.ts +0 -3
- package/dist/dist/platform.browser.d.ts.map +0 -1
- package/dist/dist/property-BwYtg5Q_.d.ts +0 -37
- package/dist/dist/property-BwYtg5Q_.d.ts.map +0 -1
- package/dist/dist/propertyValidationRules-CyHdpcPP.d.ts +0 -13
- package/dist/dist/propertyValidationRules-CyHdpcPP.d.ts.map +0 -1
- package/dist/dist/publishDraftGraph-C5F6b7GK.d.ts +0 -93
- package/dist/dist/publishDraftGraph-C5F6b7GK.d.ts.map +0 -1
- package/dist/dist/resolveModelForSyncedSeed-4gO9Hfn2.d.ts +0 -21
- package/dist/dist/resolveModelForSyncedSeed-4gO9Hfn2.d.ts.map +0 -1
- package/dist/dist/syncDbWithEas-DUu_wjUG.d.ts +0 -13
- package/dist/dist/syncDbWithEas-DUu_wjUG.d.ts.map +0 -1
- package/dist/dist/tolerantWebAccess-DecKDGen.d.ts +0 -113
- package/dist/dist/tolerantWebAccess-DecKDGen.d.ts.map +0 -1
- package/dist/dist/updateSeedRevokedAt-CP606vKs.d.ts +0 -11
- package/dist/dist/updateSeedRevokedAt-CP606vKs.d.ts.map +0 -1
- package/dist/eas-dyepi5jz.js +0 -67
- package/dist/eas-dyepi5jz.js.map +0 -1
- package/dist/errors-D1zHAqjr.js +0 -4006
- package/dist/errors-D1zHAqjr.js.map +0 -1
- package/dist/eventBus-7vxTCc3a.js +0 -64
- package/dist/eventBus-7vxTCc3a.js.map +0 -1
- package/dist/findSeedRowsByUid-CT3sOXXw.js +0 -47
- package/dist/findSeedRowsByUid-CT3sOXXw.js.map +0 -1
- package/dist/getItem-Bhjecbia.js +0 -45
- package/dist/getItem-Bhjecbia.js.map +0 -1
- package/dist/getPublishPayload-DH4rMqXG.js +0 -1634
- package/dist/getPublishPayload-DH4rMqXG.js.map +0 -1
- package/dist/getPublishUploads-BzUIDA2G.js +0 -1080
- package/dist/getPublishUploads-BzUIDA2G.js.map +0 -1
- package/dist/index-CkYb3wcU.js +0 -29
- package/dist/index-CkYb3wcU.js.map +0 -1
- package/dist/index-DJmWkVIK.js.map +0 -1
- package/dist/index-Dx_GTdyQ.js +0 -4745
- package/dist/index-Dx_GTdyQ.js.map +0 -1
- package/dist/index-PbnKw2es.js.map +0 -1
- package/dist/index.browser-i9uPJice.js.map +0 -1
- package/dist/index.node-CzMwMr_d.js.map +0 -1
- package/dist/mimeTypes-C9r76DCH.js +0 -209
- package/dist/mimeTypes-C9r76DCH.js.map +0 -1
- package/dist/model-oHA3YhOd.js +0 -29
- package/dist/model-oHA3YhOd.js.map +0 -1
- package/dist/modelPropertyRecordSchemas-C5lW9aA-.js +0 -94
- package/dist/modelPropertyRecordSchemas-C5lW9aA-.js.map +0 -1
- package/dist/property-BwYtg5Q_.js +0 -289
- package/dist/property-BwYtg5Q_.js.map +0 -1
- package/dist/propertyValidationRules-CyHdpcPP.js +0 -73
- package/dist/propertyValidationRules-CyHdpcPP.js.map +0 -1
- package/dist/publishDraftGraph-C5F6b7GK.js +0 -505
- package/dist/publishDraftGraph-C5F6b7GK.js.map +0 -1
- package/dist/resolveModelForSyncedSeed-4gO9Hfn2.js.map +0 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts +0 -5
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +0 -1
- package/dist/src/Item/service/actors/waitForDb.d.ts +0 -4
- package/dist/src/Item/service/actors/waitForDb.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts +0 -6
- package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/rowContext.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts +0 -24
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +0 -10
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts +0 -22
- package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +0 -4
- package/dist/src/ItemProperty/service/actors/waitForDb.d.ts.map +0 -1
- package/dist/src/Model/service/actors/createModelProperties.d.ts +0 -9
- package/dist/src/Model/service/actors/createModelProperties.d.ts.map +0 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts +0 -5
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts +0 -5
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/createModelInstances.d.ts +0 -11
- package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/createPropertyInstances.d.ts +0 -12
- package/dist/src/Schema/service/actors/createPropertyInstances.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/validateSchema.d.ts +0 -5
- package/dist/src/Schema/service/actors/validateSchema.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts +0 -6
- package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts +0 -7
- package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts +0 -8
- package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts +0 -6
- package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts +0 -7
- package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts +0 -9
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts +0 -10
- package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts +0 -11
- package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts.map +0 -1
- package/dist/src/browser/helpers/ArweaveClient.d.ts +0 -14
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +0 -1
- package/dist/src/browser/helpers/EasClient.d.ts +0 -10
- package/dist/src/browser/helpers/EasClient.d.ts.map +0 -1
- package/dist/src/browser/helpers/QueryClient.d.ts +0 -9
- package/dist/src/browser/helpers/QueryClient.d.ts.map +0 -1
- package/dist/src/client/actors/addModelsToStore.d.ts +0 -4
- package/dist/src/client/actors/addModelsToStore.d.ts.map +0 -1
- package/dist/src/db/backfillMetadataPropertyIds.d.ts +0 -7
- package/dist/src/db/backfillMetadataPropertyIds.d.ts.map +0 -1
- package/dist/src/db/read/getItem.d.ts +0 -3
- package/dist/src/db/read/getItem.d.ts.map +0 -1
- package/dist/src/db/read/getPropertyData.d.ts +0 -4
- package/dist/src/db/read/getPropertyData.d.ts.map +0 -1
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts +0 -10
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +0 -1
- package/dist/src/db/read/getSeedData.d.ts +0 -12
- package/dist/src/db/read/getSeedData.d.ts.map +0 -1
- package/dist/src/db/read/itemLoads.d.ts +0 -20
- package/dist/src/db/read/itemLoads.d.ts.map +0 -1
- package/dist/src/db/read/publishDraftGraph.d.ts +0 -64
- package/dist/src/db/read/publishDraftGraph.d.ts.map +0 -1
- package/dist/src/db/write/linkModelToSchema.d.ts +0 -12
- package/dist/src/db/write/linkModelToSchema.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts.map +0 -1
- package/dist/src/helpers/EasClient/BaseEasClient.d.ts +0 -2
- package/dist/src/helpers/EasClient/BaseEasClient.d.ts.map +0 -1
- package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts +0 -2
- package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts.map +0 -1
- package/dist/src/helpers/easUid.d.ts +0 -2
- package/dist/src/helpers/easUid.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityDestroy.d.ts +0 -49
- package/dist/src/helpers/entity/entityDestroy.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityFind.d.ts +0 -52
- package/dist/src/helpers/entity/entityFind.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityState.d.ts +0 -28
- package/dist/src/helpers/entity/entityState.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityUnload.d.ts +0 -56
- package/dist/src/helpers/entity/entityUnload.d.ts.map +0 -1
- package/dist/src/helpers/entity/evictionEpoch.d.ts +0 -43
- package/dist/src/helpers/entity/evictionEpoch.d.ts.map +0 -1
- package/dist/src/helpers/entity/index.d.ts +0 -12
- package/dist/src/helpers/entity/index.d.ts.map +0 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts +0 -2
- package/dist/src/helpers/gateway/gatewayState.d.ts.map +0 -1
- package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +0 -2
- package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +0 -1
- package/dist/src/helpers/gateway/seedGatewayConfig.d.ts +0 -2
- package/dist/src/helpers/gateway/seedGatewayConfig.d.ts.map +0 -1
- package/dist/src/helpers/getSchemaForItemProperty.d.ts +0 -15
- package/dist/src/helpers/getSchemaForItemProperty.d.ts.map +0 -1
- package/dist/src/helpers/getSegmentedItemProperties.d.ts +0 -10
- package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +0 -1
- package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts +0 -7
- package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts.map +0 -1
- package/dist/src/helpers/propertyValidationRules.d.ts +0 -20
- package/dist/src/helpers/propertyValidationRules.d.ts.map +0 -1
- package/dist/src/helpers/propertyWriteTickets.d.ts +0 -11
- package/dist/src/helpers/propertyWriteTickets.d.ts.map +0 -1
- package/dist/src/helpers/reconcilePropertyDraftRows.d.ts +0 -10
- package/dist/src/helpers/reconcilePropertyDraftRows.d.ts.map +0 -1
- package/dist/src/helpers/waitForEntityIdle.d.ts +0 -21
- package/dist/src/helpers/waitForEntityIdle.d.ts.map +0 -1
- package/dist/src/interfaces/IQueryClient.d.ts +0 -15
- package/dist/src/interfaces/IQueryClient.d.ts.map +0 -1
- package/dist/src/node/helpers/ArweaveClient.d.ts +0 -5
- package/dist/src/node/helpers/ArweaveClient.d.ts.map +0 -1
- package/dist/src/node/helpers/EasClient.d.ts +0 -5
- package/dist/src/node/helpers/EasClient.d.ts.map +0 -1
- package/dist/src/node/helpers/QueryClient.d.ts +0 -5
- package/dist/src/node/helpers/QueryClient.d.ts.map +0 -1
- package/dist/src/services/write/actors/validateEntity.d.ts +0 -6
- package/dist/src/services/write/actors/validateEntity.d.ts.map +0 -1
- package/dist/src/services/write/actors/writeToDatabase.d.ts +0 -14
- package/dist/src/services/write/actors/writeToDatabase.d.ts.map +0 -1
- package/dist/src/services/write/writeProcessMachine.d.ts +0 -56
- package/dist/src/services/write/writeProcessMachine.d.ts.map +0 -1
- package/dist/src/stores/eas.d.ts +0 -2
- package/dist/src/stores/eas.d.ts.map +0 -1
- package/dist/src/types/arweave.d.ts +0 -57
- package/dist/src/types/arweave.d.ts.map +0 -1
- package/dist/src/types/gateway.d.ts +0 -2
- package/dist/src/types/gateway.d.ts.map +0 -1
- package/dist/syncDbWithEas-DUu_wjUG.js.map +0 -1
- package/dist/updateSeedRevokedAt-CP606vKs.js +0 -31
- package/dist/updateSeedRevokedAt-CP606vKs.js.map +0 -1
|
@@ -1,726 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import { e as eventEmitter } from './eventBus-7vxTCc3a.js';
|
|
3
|
-
import { am as isBrowser, Q as BaseFileManager, ac as EAS_SEED_DATA_SYNCED_TO_DB_EVENT, w as entityChanges } from './index-Dx_GTdyQ.js';
|
|
4
|
-
import { sql, gt, lt } from 'drizzle-orm';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Phase timings for item creates, finds and property saves, and ready waits that timed out but
|
|
8
|
-
* were allowed to continue, under `DEBUG=seedSdk:timing`. Timing lines are `<label> <ms>ms` plus
|
|
9
|
-
* any details, so an app can report where a slow call spent its time.
|
|
10
|
-
*/
|
|
11
|
-
const timingLogger = debug('seedSdk:timing');
|
|
12
|
-
const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
|
|
13
|
-
/** Runs `fn` and logs how long it took (also when it throws). Costs nothing when the namespace is off. */
|
|
14
|
-
async function timed(label, fn, details) {
|
|
15
|
-
if (!timingLogger.enabled)
|
|
16
|
-
return fn();
|
|
17
|
-
const start = now();
|
|
18
|
-
let failed = false;
|
|
19
|
-
try {
|
|
20
|
-
return await fn();
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
failed = true;
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
27
|
-
const extra = details?.();
|
|
28
|
-
timingLogger(`${label} ${Math.round(now() - start)}ms${failed ? ' (failed)' : ''}${extra ? ` ${extra}` : ''}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Database work counted while the namespace is on, so a timing line can say how much of its time
|
|
33
|
-
* was the SQLite worker. Statements are the ones the SDK sends through the driver; their time runs
|
|
34
|
-
* from send to result, so it includes the wait behind everything queued before them on the one
|
|
35
|
-
* worker. Live-query runs are SQLocal reactive-query results (the first run and every re-run after
|
|
36
|
-
* a write to a watched table), which go through the same worker but not through the driver.
|
|
37
|
-
*/
|
|
38
|
-
const dbTimingCounters = {
|
|
39
|
-
statements: 0,
|
|
40
|
-
statementMs: 0,
|
|
41
|
-
inFlight: 0,
|
|
42
|
-
liveQueryRuns: 0,
|
|
43
|
-
liveQueryFirstRuns: 0,
|
|
44
|
-
liveQueryFirstRunMs: 0,
|
|
45
|
-
};
|
|
46
|
-
const snapshotCounters = () => ({ ...dbTimingCounters });
|
|
47
|
-
/** Wraps a driver function so each call is counted while timing is on. */
|
|
48
|
-
function countDbStatements(driver) {
|
|
49
|
-
return async (...args) => {
|
|
50
|
-
if (!timingLogger.enabled)
|
|
51
|
-
return driver(...args);
|
|
52
|
-
const start = now();
|
|
53
|
-
dbTimingCounters.inFlight += 1;
|
|
54
|
-
try {
|
|
55
|
-
return await driver(...args);
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
dbTimingCounters.inFlight -= 1;
|
|
59
|
-
dbTimingCounters.statements += 1;
|
|
60
|
-
dbTimingCounters.statementMs += now() - start;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/** Starts the clock for one live query; call the result on each of its runs. */
|
|
65
|
-
function countLiveQueryRuns() {
|
|
66
|
-
if (!timingLogger.enabled)
|
|
67
|
-
return () => { };
|
|
68
|
-
const start = now();
|
|
69
|
-
let first = true;
|
|
70
|
-
return () => {
|
|
71
|
-
dbTimingCounters.liveQueryRuns += 1;
|
|
72
|
-
if (!first)
|
|
73
|
-
return;
|
|
74
|
-
first = false;
|
|
75
|
-
dbTimingCounters.liveQueryFirstRuns += 1;
|
|
76
|
-
dbTimingCounters.liveQueryFirstRunMs += now() - start;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const describeDbDelta = (before) => {
|
|
80
|
-
const after = dbTimingCounters;
|
|
81
|
-
const statements = after.statements - before.statements;
|
|
82
|
-
const statementMs = after.statementMs - before.statementMs;
|
|
83
|
-
const liveRuns = after.liveQueryRuns - before.liveQueryRuns;
|
|
84
|
-
const firstRuns = after.liveQueryFirstRuns - before.liveQueryFirstRuns;
|
|
85
|
-
const firstMs = after.liveQueryFirstRunMs - before.liveQueryFirstRunMs;
|
|
86
|
-
const parts = [`queued ${before.inFlight}`];
|
|
87
|
-
if (statements)
|
|
88
|
-
parts.push(`${statements} stmts avg ${Math.round(statementMs / statements)}ms`);
|
|
89
|
-
if (liveRuns)
|
|
90
|
-
parts.push(`${liveRuns} live runs`);
|
|
91
|
-
if (firstRuns)
|
|
92
|
-
parts.push(`${firstRuns} new live queries, first run avg ${Math.round(firstMs / firstRuns)}ms`);
|
|
93
|
-
return `[db: ${parts.join(', ')}]`;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Like `timed`, and the line also says how many statements and live-query runs went through the
|
|
97
|
-
* worker meanwhile (from any caller, since they share the queue) and how many statements were
|
|
98
|
-
* already queued when it started.
|
|
99
|
-
*/
|
|
100
|
-
async function timedDb(label, fn, details) {
|
|
101
|
-
if (!timingLogger.enabled)
|
|
102
|
-
return fn();
|
|
103
|
-
const before = snapshotCounters();
|
|
104
|
-
return timed(label, fn, () => [details?.(), describeDbDelta(before)].filter(Boolean).join(' '));
|
|
105
|
-
}
|
|
106
|
-
/** Milliseconds since `start` (a `timingNow()` value), rounded. */
|
|
107
|
-
const timingSince = (start) => Math.round(now() - start);
|
|
108
|
-
const timingNow = now;
|
|
109
|
-
/**
|
|
110
|
-
* Split timer for one multi-step call: `mark(step)` records the time since the previous mark, and
|
|
111
|
-
* `log(label)` writes one line with the total and every step. Does nothing when timing is off.
|
|
112
|
-
*/
|
|
113
|
-
function timingMarks() {
|
|
114
|
-
if (!timingLogger.enabled)
|
|
115
|
-
return { mark: () => { }, log: () => { } };
|
|
116
|
-
const start = now();
|
|
117
|
-
const before = snapshotCounters();
|
|
118
|
-
let last = start;
|
|
119
|
-
const steps = [];
|
|
120
|
-
return {
|
|
121
|
-
mark: (step) => {
|
|
122
|
-
const t = now();
|
|
123
|
-
steps.push(`${step} ${Math.round(t - last)}`);
|
|
124
|
-
last = t;
|
|
125
|
-
},
|
|
126
|
-
log: (label) => {
|
|
127
|
-
timingLogger(`${label} ${Math.round(now() - start)}ms: ${steps.join(', ')} ${describeDbDelta(before)}`);
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Cross-tab exclusive sections, using the Web Locks API. All tabs of an origin share one SQLite
|
|
134
|
-
* database and OPFS tree; the browser releases a tab's locks when it closes or crashes, so a lock
|
|
135
|
-
* can't go stale. See docs/MULTI_TAB.md.
|
|
136
|
-
*
|
|
137
|
-
* Node has Web Locks from 24.5, scoped to the process. Where they're missing (older Node, old
|
|
138
|
-
* browsers), sections still run one at a time within this JS realm (see `withProcessLock`), which
|
|
139
|
-
* covers a single Node process but not other tabs or worker threads.
|
|
140
|
-
* Not re-entrant: requesting a name the caller already holds waits forever, so take each lock
|
|
141
|
-
* only at the outermost call site.
|
|
142
|
-
*/
|
|
143
|
-
/** Long enough for a slow init in another tab; short enough that a hung tab doesn't block forever. */
|
|
144
|
-
const TAB_LOCK_WAIT_TIMEOUT_MS = 60000;
|
|
145
|
-
function seedDbLockName(scope, filesDir) {
|
|
146
|
-
return `seed:${scope}:${filesDir}/db/seed.db`;
|
|
147
|
-
}
|
|
148
|
-
/** `withTabLock` on the database under `filesDir`; runs `fn` directly when there's no `filesDir` yet. */
|
|
149
|
-
function withSeedDbLock(scope, filesDir, fn) {
|
|
150
|
-
return filesDir ? withTabLock(seedDbLockName(scope, filesDir), fn) : fn();
|
|
151
|
-
}
|
|
152
|
-
class TabLockTimeoutError extends Error {
|
|
153
|
-
constructor(lockName, timeoutMs) {
|
|
154
|
-
super(`Timed out after ${timeoutMs}ms waiting for another tab to release "${lockName}".`);
|
|
155
|
-
this.lockName = lockName;
|
|
156
|
-
this.code = 'TAB_LOCK_TIMEOUT';
|
|
157
|
-
this.name = 'TabLockTimeoutError';
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
async function withTabLock(name, fn, { timeoutMs = TAB_LOCK_WAIT_TIMEOUT_MS } = {}) {
|
|
161
|
-
const locks = typeof navigator !== 'undefined' ? navigator.locks : undefined;
|
|
162
|
-
if (!locks)
|
|
163
|
-
return withProcessLock(name, fn, { timeoutMs });
|
|
164
|
-
try {
|
|
165
|
-
// The timeout bounds the wait only; once granted, fn runs to completion. Infinity waits for as
|
|
166
|
-
// long as the holder runs (it can't outlive its tab).
|
|
167
|
-
const signal = Number.isFinite(timeoutMs) ? AbortSignal.timeout(timeoutMs) : undefined;
|
|
168
|
-
return await locks.request(name, { mode: 'exclusive', signal }, fn);
|
|
169
|
-
}
|
|
170
|
-
catch (error) {
|
|
171
|
-
if (error?.name === 'TimeoutError') {
|
|
172
|
-
throw new TabLockTimeoutError(name, timeoutMs);
|
|
173
|
-
}
|
|
174
|
-
throw error;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Runs `fn` holding lock `name` only if no one holds it or waits for it now; otherwise runs nothing
|
|
179
|
-
* and returns `{ acquired: false }`. For work that has something else to do meanwhile (the outbox
|
|
180
|
-
* drainer).
|
|
181
|
-
*/
|
|
182
|
-
async function tryWithTabLock(name, fn) {
|
|
183
|
-
const locks = typeof navigator !== 'undefined' ? navigator.locks : undefined;
|
|
184
|
-
if (!locks) {
|
|
185
|
-
if (processLockTails.has(name))
|
|
186
|
-
return { acquired: false };
|
|
187
|
-
return { acquired: true, value: await withProcessLock(name, fn) };
|
|
188
|
-
}
|
|
189
|
-
return locks.request(name, { mode: 'exclusive', ifAvailable: true }, async (lock) => lock ? { acquired: true, value: await fn() } : { acquired: false });
|
|
190
|
-
}
|
|
191
|
-
/** Tail of each name's queue: resolves once every section queued so far has finished or given up. */
|
|
192
|
-
const processLockTails = new Map();
|
|
193
|
-
/**
|
|
194
|
-
* The `withTabLock` fallback without Web Locks: an exclusive, first-come-first-served lock per name
|
|
195
|
-
* within this JS realm. Like Web Locks, `timeoutMs` bounds the wait only, and a waiter that times
|
|
196
|
-
* out doesn't let later waiters in before the current holder finishes.
|
|
197
|
-
*/
|
|
198
|
-
async function withProcessLock(name, fn, { timeoutMs = TAB_LOCK_WAIT_TIMEOUT_MS } = {}) {
|
|
199
|
-
const previous = processLockTails.get(name) ?? Promise.resolve();
|
|
200
|
-
let release;
|
|
201
|
-
const done = new Promise((resolve) => (release = resolve));
|
|
202
|
-
const tail = previous.then(() => done);
|
|
203
|
-
processLockTails.set(name, tail);
|
|
204
|
-
void tail.then(() => {
|
|
205
|
-
if (processLockTails.get(name) === tail)
|
|
206
|
-
processLockTails.delete(name);
|
|
207
|
-
});
|
|
208
|
-
try {
|
|
209
|
-
await waitForTurn(previous, name, timeoutMs);
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
release();
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
try {
|
|
216
|
-
return await fn();
|
|
217
|
-
}
|
|
218
|
-
finally {
|
|
219
|
-
release();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
function waitForTurn(previous, name, timeoutMs) {
|
|
223
|
-
if (!Number.isFinite(timeoutMs))
|
|
224
|
-
return previous;
|
|
225
|
-
let timer;
|
|
226
|
-
const timedOut = new Promise((_, reject) => {
|
|
227
|
-
timer = setTimeout(() => reject(new TabLockTimeoutError(name, timeoutMs)), timeoutMs);
|
|
228
|
-
});
|
|
229
|
-
return Promise.race([previous, timedOut]).finally(() => clearTimeout(timer));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const logger$2 = debug('seedSdk:helpers:tabCoordinator');
|
|
233
|
-
/** Identifies this tab (this page's SDK instance) in the messages it sends. */
|
|
234
|
-
const TAB_ID = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
|
235
|
-
? crypto.randomUUID()
|
|
236
|
-
: `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
237
|
-
let state;
|
|
238
|
-
let leader = false;
|
|
239
|
-
let leaderWaiters = [];
|
|
240
|
-
const messageHandlers = new Set();
|
|
241
|
-
/** Starts once per page; later calls (re-init) keep the first database. */
|
|
242
|
-
function startTabCoordination({ filesDir, mode = 'coordinate' }) {
|
|
243
|
-
if (state)
|
|
244
|
-
return;
|
|
245
|
-
const locks = typeof navigator !== 'undefined' ? navigator.locks : undefined;
|
|
246
|
-
const dbKey = `${filesDir}/db/seed.db`;
|
|
247
|
-
const coordinating = mode === 'coordinate' && isBrowser() && !!locks && typeof BroadcastChannel !== 'undefined';
|
|
248
|
-
state = { dbKey, coordinating };
|
|
249
|
-
if (!coordinating) {
|
|
250
|
-
becomeLeader();
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const channel = new BroadcastChannel(`seed:tabs:${dbKey}`);
|
|
254
|
-
channel.onmessage = (event) => {
|
|
255
|
-
// A BroadcastChannel never hears itself, but another channel object in this page would (a
|
|
256
|
-
// second channel opened by a test, or the same module loaded twice): skip our own messages.
|
|
257
|
-
if (event.data?.from === TAB_ID)
|
|
258
|
-
return;
|
|
259
|
-
for (const handler of messageHandlers)
|
|
260
|
-
handler(event.data);
|
|
261
|
-
};
|
|
262
|
-
state.channel = channel;
|
|
263
|
-
const current = state;
|
|
264
|
-
void locks.request(`seed:leader:${dbKey}`, () => {
|
|
265
|
-
// Reset (tests) before the grant: hand the lock straight back.
|
|
266
|
-
if (state !== current)
|
|
267
|
-
return undefined;
|
|
268
|
-
becomeLeader();
|
|
269
|
-
// Held until the tab closes (or a test resets coordination).
|
|
270
|
-
return new Promise((release) => {
|
|
271
|
-
current.releaseLeadership = release;
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function becomeLeader() {
|
|
276
|
-
if (leader)
|
|
277
|
-
return;
|
|
278
|
-
leader = true;
|
|
279
|
-
logger$2(`this tab leads ${state?.dbKey}`);
|
|
280
|
-
const waiters = leaderWaiters;
|
|
281
|
-
leaderWaiters = [];
|
|
282
|
-
for (const resolve of waiters)
|
|
283
|
-
resolve();
|
|
284
|
-
}
|
|
285
|
-
function isLeaderTab() {
|
|
286
|
-
return !state || leader;
|
|
287
|
-
}
|
|
288
|
-
/** Resolves when this tab leads (at once if it already does). */
|
|
289
|
-
function whenLeaderTab() {
|
|
290
|
-
if (isLeaderTab())
|
|
291
|
-
return Promise.resolve();
|
|
292
|
-
return new Promise((resolve) => leaderWaiters.push(resolve));
|
|
293
|
-
}
|
|
294
|
-
/** Sends to the other tabs of this database; a no-op when not coordinating. */
|
|
295
|
-
function postTabMessage(message) {
|
|
296
|
-
state?.channel?.postMessage({ ...message, from: TAB_ID });
|
|
297
|
-
}
|
|
298
|
-
/** Whether postTabMessage reaches other tabs (a browser tab coordinating with Web Locks). */
|
|
299
|
-
function isPostingTabMessages() {
|
|
300
|
-
return !!state?.channel;
|
|
301
|
-
}
|
|
302
|
-
function onTabMessage(handler) {
|
|
303
|
-
messageHandlers.add(handler);
|
|
304
|
-
return () => messageHandlers.delete(handler);
|
|
305
|
-
}
|
|
306
|
-
/** `withTabLock` named for this database (`seed:<scope>:<db>`); runs `fn` directly before init. */
|
|
307
|
-
function withDbTabLock(scope, fn, options) {
|
|
308
|
-
return state ? withTabLock(`seed:${scope}:${state.dbKey}`, fn, options) : fn();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Blob URLs the SDK mints for property values (File and Image display URLs). Only these are revoked
|
|
313
|
-
* by `ItemProperty`: a blob URL the app passed in as a value stays the app's to revoke.
|
|
314
|
-
*/
|
|
315
|
-
const minted = new Set();
|
|
316
|
-
const createSessionObjectUrl = (blob) => {
|
|
317
|
-
const url = URL.createObjectURL(blob);
|
|
318
|
-
minted.add(url);
|
|
319
|
-
return url;
|
|
320
|
-
};
|
|
321
|
-
const isSessionObjectUrl = (value) => typeof value === 'string' && minted.has(value);
|
|
322
|
-
const revokeSessionObjectUrl = (url) => {
|
|
323
|
-
if (!minted.delete(url))
|
|
324
|
-
return;
|
|
325
|
-
URL.revokeObjectURL(url);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
/** Emitted by the client manager after `app_state.addresses` is written (post-`setAddresses`). */
|
|
329
|
-
const ADDRESSES_PERSISTED_EVENT = 'addresses.persisted';
|
|
330
|
-
/** Emitted after hard-deleting local on-chain seed copies for publisher addresses. */
|
|
331
|
-
const LOCAL_COPIES_REMOVED_EVENT = 'localCopies.removed';
|
|
332
|
-
function parseAddressesPersistedPayload(value) {
|
|
333
|
-
if (!value || typeof value !== 'object') {
|
|
334
|
-
return { owned: [], watched: [] };
|
|
335
|
-
}
|
|
336
|
-
const v = value;
|
|
337
|
-
const owned = Array.isArray(v.owned)
|
|
338
|
-
? v.owned.filter((a) => typeof a === 'string')
|
|
339
|
-
: [];
|
|
340
|
-
const watched = Array.isArray(v.watched)
|
|
341
|
-
? v.watched.filter((a) => typeof a === 'string')
|
|
342
|
-
: [];
|
|
343
|
-
return { owned, watched };
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
const logger$1 = debug('seedSdk:helpers:tabEvents');
|
|
347
|
-
/**
|
|
348
|
-
* Keeps other tabs current (docs/MULTI_TAB.md). The event bus is per tab, so events that mean "the
|
|
349
|
-
* shared database or OPFS changed" are also posted to the other tabs, which refresh their caches
|
|
350
|
-
* and emit the same event locally. Events are posted only where they originate, so a relayed event
|
|
351
|
-
* is never relayed again.
|
|
352
|
-
*/
|
|
353
|
-
/** Emitted with the changed paths when files change outside this tab's file-system cache. */
|
|
354
|
-
const FILES_CHANGED_EVENT = 'fs.files.changed';
|
|
355
|
-
/** Emits on this tab's event bus and in every other tab of this database. */
|
|
356
|
-
function emitAcrossTabs(name, payload) {
|
|
357
|
-
if (payload === undefined) {
|
|
358
|
-
eventEmitter.emit(name);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
eventEmitter.emit(name, payload);
|
|
362
|
-
}
|
|
363
|
-
postTabMessage({ type: 'event', name, payload });
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* A file saved through this tab's file system: emits `file-saved` here. Other tabs hear about it
|
|
367
|
-
* from the file system itself (see queueFilesChangedNotice), once the write has reached OPFS.
|
|
368
|
-
*/
|
|
369
|
-
function notifyFileSaved(filePath) {
|
|
370
|
-
eventEmitter.emit('file-saved', filePath);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Files written straight to OPFS by a worker: refreshes this tab's file-system cache, emits
|
|
374
|
-
* FILES_CHANGED_EVENT, and tells other tabs to do the same.
|
|
375
|
-
*/
|
|
376
|
-
async function notifyFilesWrittenOutsideCache(paths) {
|
|
377
|
-
if (paths.length === 0)
|
|
378
|
-
return;
|
|
379
|
-
await BaseFileManager.invalidateCachedPaths(paths);
|
|
380
|
-
eventEmitter.emit(FILES_CHANGED_EVENT, paths);
|
|
381
|
-
queueFilesChangedNotice(paths);
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* How long changed paths gather before one `files-changed` message goes out. Counted from the
|
|
385
|
-
* first queued path, so a steady stream of writes still sends once per window, never later.
|
|
386
|
-
*/
|
|
387
|
-
const FILES_CHANGED_FLUSH_MS = 25;
|
|
388
|
-
/** Keeps a message for a huge batch (a bulk download) from being one giant structured clone. */
|
|
389
|
-
const FILES_CHANGED_MAX_PATHS = 500;
|
|
390
|
-
let pendingChangedPaths = new Set();
|
|
391
|
-
let flushTimer;
|
|
392
|
-
let flushOnPageHide = false;
|
|
393
|
-
/**
|
|
394
|
-
* Tells other tabs that these absolute ZenFS paths changed in OPFS, so they drop and re-read their
|
|
395
|
-
* cached copies (the sync API's in-memory copy in particular). The browser file system calls this
|
|
396
|
-
* for every file it writes, truncates or removes (`TolerantWebAccessFS.onOpfsChange`, wired in
|
|
397
|
-
* `BrowserFileManager.initializeFileSystem`), after the change reached OPFS. Paths are coalesced
|
|
398
|
-
* for FILES_CHANGED_FLUSH_MS, so bulk writes (migrations, schema processing, downloads) send a few
|
|
399
|
-
* messages rather than one per write.
|
|
400
|
-
*
|
|
401
|
-
* Defense in depth only: a tab that misses a message still sees the change on its next async
|
|
402
|
-
* stat() (see TolerantWebAccessFS.stat). A no-op unless this tab coordinates with others.
|
|
403
|
-
*/
|
|
404
|
-
function queueFilesChangedNotice(paths) {
|
|
405
|
-
if (!isPostingTabMessages())
|
|
406
|
-
return;
|
|
407
|
-
for (const path of paths)
|
|
408
|
-
pendingChangedPaths.add(path);
|
|
409
|
-
if (flushTimer !== undefined || pendingChangedPaths.size === 0)
|
|
410
|
-
return;
|
|
411
|
-
flushTimer = setTimeout(flushFilesChangedNotices, FILES_CHANGED_FLUSH_MS);
|
|
412
|
-
if (!flushOnPageHide && typeof addEventListener === 'function') {
|
|
413
|
-
flushOnPageHide = true;
|
|
414
|
-
// A tab closing inside the window still sends what it wrote.
|
|
415
|
-
addEventListener('pagehide', flushFilesChangedNotices);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
/** Sends the queued paths now (page hide, tests). */
|
|
419
|
-
function flushFilesChangedNotices() {
|
|
420
|
-
if (flushTimer !== undefined)
|
|
421
|
-
clearTimeout(flushTimer);
|
|
422
|
-
flushTimer = undefined;
|
|
423
|
-
if (pendingChangedPaths.size === 0)
|
|
424
|
-
return;
|
|
425
|
-
const paths = [...pendingChangedPaths];
|
|
426
|
-
pendingChangedPaths = new Set();
|
|
427
|
-
for (let i = 0; i < paths.length; i += FILES_CHANGED_MAX_PATHS) {
|
|
428
|
-
postTabMessage({ type: 'files-changed', paths: paths.slice(i, i + FILES_CHANGED_MAX_PATHS) });
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
/** Refreshes this tab's in-memory state for an event another tab emitted, before re-emitting it. */
|
|
432
|
-
async function catchUpOn(name, payload) {
|
|
433
|
-
if (name === EAS_SEED_DATA_SYNCED_TO_DB_EVENT) {
|
|
434
|
-
const _mod_0 = await import('./Item-0oDoTPhi.js');
|
|
435
|
-
const _ns_0 = _mod_0.au;
|
|
436
|
-
const { Item } = _ns_0;
|
|
437
|
-
await Item.rehydrateCachedItemsFromDbAfterEasSync();
|
|
438
|
-
}
|
|
439
|
-
else if (name === LOCAL_COPIES_REMOVED_EVENT) {
|
|
440
|
-
const { removedSeedLocalIds = [], removedSeedUids = [] } = (payload ?? {});
|
|
441
|
-
const _mod_1 = await import('./Item-0oDoTPhi.js');
|
|
442
|
-
const _ns_1 = _mod_1.au;
|
|
443
|
-
const { Item } = _ns_1;
|
|
444
|
-
Item.dropCachedInstancesForSeedIds([...removedSeedLocalIds, ...removedSeedUids]);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
const RELAYED_EVENTS = new Set([
|
|
448
|
-
EAS_SEED_DATA_SYNCED_TO_DB_EVENT,
|
|
449
|
-
ADDRESSES_PERSISTED_EVENT,
|
|
450
|
-
LOCAL_COPIES_REMOVED_EVENT,
|
|
451
|
-
]);
|
|
452
|
-
let listening = false;
|
|
453
|
-
/** Applies other tabs' events and file changes in this tab. */
|
|
454
|
-
function listenForOtherTabsEvents() {
|
|
455
|
-
if (listening)
|
|
456
|
-
return;
|
|
457
|
-
listening = true;
|
|
458
|
-
onTabMessage((message) => {
|
|
459
|
-
if (message.type === 'event' && RELAYED_EVENTS.has(message.name)) {
|
|
460
|
-
void catchUpOn(message.name, message.payload)
|
|
461
|
-
.catch((error) => logger$1(`catching up on ${message.name} failed`, error))
|
|
462
|
-
.then(() => {
|
|
463
|
-
if (message.payload === undefined) {
|
|
464
|
-
eventEmitter.emit(message.name);
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
eventEmitter.emit(message.name, message.payload);
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
else if (message.type === 'files-changed') {
|
|
472
|
-
// Only refreshes caches: never writes, so never sends files-changed back.
|
|
473
|
-
void BaseFileManager.invalidateCachedPaths(message.paths)
|
|
474
|
-
.catch((error) => logger$1('refreshing changed files failed', error))
|
|
475
|
-
.then(() => eventEmitter.emit(FILES_CHANGED_EVENT, message.paths));
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
var tabEvents = /*#__PURE__*/Object.freeze({
|
|
481
|
-
__proto__: null,
|
|
482
|
-
FILES_CHANGED_EVENT: FILES_CHANGED_EVENT,
|
|
483
|
-
FILES_CHANGED_FLUSH_MS: FILES_CHANGED_FLUSH_MS,
|
|
484
|
-
FILES_CHANGED_MAX_PATHS: FILES_CHANGED_MAX_PATHS,
|
|
485
|
-
emitAcrossTabs: emitAcrossTabs,
|
|
486
|
-
flushFilesChangedNotices: flushFilesChangedNotices,
|
|
487
|
-
listenForOtherTabsEvents: listenForOtherTabsEvents,
|
|
488
|
-
notifyFileSaved: notifyFileSaved,
|
|
489
|
-
notifyFilesWrittenOutsideCache: notifyFilesWrittenOutsideCache,
|
|
490
|
-
queueFilesChangedNotice: queueFilesChangedNotice
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
const logger = debug('seedSdk:browser:db:changeFeed');
|
|
494
|
-
/** Log rows older than this are pruned by the leader tab. */
|
|
495
|
-
const ENTITY_CHANGES_RETENTION_MS = 10 * 60000;
|
|
496
|
-
/** The leader prunes at most this often. */
|
|
497
|
-
const ENTITY_CHANGES_PRUNE_EVERY_MS = 60000;
|
|
498
|
-
const byLocalId = new Map();
|
|
499
|
-
const byUid = new Map();
|
|
500
|
-
const registrations = new Set();
|
|
501
|
-
let feed;
|
|
502
|
-
let cursor = 0;
|
|
503
|
-
let reading;
|
|
504
|
-
let readAgain = false;
|
|
505
|
-
let lastPrunedAt = 0;
|
|
506
|
-
const addTo = (map, key, registration) => {
|
|
507
|
-
let set = map.get(key);
|
|
508
|
-
if (!set)
|
|
509
|
-
map.set(key, (set = new Set()));
|
|
510
|
-
set.add(registration);
|
|
511
|
-
};
|
|
512
|
-
const removeFrom = (map, key, registration) => {
|
|
513
|
-
const set = map.get(key);
|
|
514
|
-
if (!set)
|
|
515
|
-
return;
|
|
516
|
-
set.delete(registration);
|
|
517
|
-
if (set.size === 0)
|
|
518
|
-
map.delete(key);
|
|
519
|
-
};
|
|
520
|
-
/**
|
|
521
|
-
* Calls `listener` after a committed write to one of `watch.tables` for the watched seed, matched
|
|
522
|
-
* by local id or (case-insensitively) by uid. A read of the log that has several matching rows
|
|
523
|
-
* calls it once. When the tab missed rows (its cursor is older than the oldest kept row), every
|
|
524
|
-
* listener is called once. Returns the unregister function.
|
|
525
|
-
*/
|
|
526
|
-
function watchEntityChanges(watch, listener) {
|
|
527
|
-
const registration = {
|
|
528
|
-
watch,
|
|
529
|
-
tables: new Set(watch.tables),
|
|
530
|
-
propertyNames: watch.propertyNames ? new Set(watch.propertyNames) : undefined,
|
|
531
|
-
listener,
|
|
532
|
-
};
|
|
533
|
-
const localId = watch.seedLocalId || undefined;
|
|
534
|
-
const uid = watch.seedUid ? watch.seedUid.toLowerCase() : undefined;
|
|
535
|
-
registrations.add(registration);
|
|
536
|
-
if (localId)
|
|
537
|
-
addTo(byLocalId, localId, registration);
|
|
538
|
-
if (uid)
|
|
539
|
-
addTo(byUid, uid, registration);
|
|
540
|
-
return () => {
|
|
541
|
-
registrations.delete(registration);
|
|
542
|
-
if (localId)
|
|
543
|
-
removeFrom(byLocalId, localId, registration);
|
|
544
|
-
if (uid)
|
|
545
|
-
removeFrom(byUid, uid, registration);
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Watches `watch` and runs `read` once per dispatch, handing its result to `onRows` when it differs
|
|
550
|
-
* from the last one handed over. A read that finishes after a newer one started is dropped, so an
|
|
551
|
-
* older result never replaces a newer one.
|
|
552
|
-
*
|
|
553
|
-
* Pass `since` (the `changeFeedCursor()` taken before the caller's own initial read) to run `read`
|
|
554
|
-
* once right away when the feed moved on in between: a change dispatched before this watch was
|
|
555
|
-
* registered would otherwise be missed. Pass `immediate` to run it once right away regardless, as
|
|
556
|
-
* a liveQuery's first emission does.
|
|
557
|
-
*/
|
|
558
|
-
function watchEntityRows(watch, read, onRows, options = {}) {
|
|
559
|
-
let latest = 0;
|
|
560
|
-
let closed = false;
|
|
561
|
-
let lastJson;
|
|
562
|
-
const run = () => {
|
|
563
|
-
const token = ++latest;
|
|
564
|
-
read().then((rows) => {
|
|
565
|
-
if (closed || token !== latest)
|
|
566
|
-
return;
|
|
567
|
-
// Like BaseDb.liveQuery's distinctUntilChanged: a write that left these rows as they were
|
|
568
|
-
// (this entity's own write, read back) doesn't reach the handler again.
|
|
569
|
-
const json = JSON.stringify(rows);
|
|
570
|
-
if (json === lastJson)
|
|
571
|
-
return;
|
|
572
|
-
lastJson = json;
|
|
573
|
-
onRows(rows);
|
|
574
|
-
}, (error) => {
|
|
575
|
-
if (closed || token !== latest)
|
|
576
|
-
return;
|
|
577
|
-
if (options.onError)
|
|
578
|
-
options.onError(error);
|
|
579
|
-
else
|
|
580
|
-
logger('entity read failed', error);
|
|
581
|
-
});
|
|
582
|
-
};
|
|
583
|
-
const unregister = watchEntityChanges(watch, run);
|
|
584
|
-
if (options.immediate || (options.since !== undefined && cursor > options.since))
|
|
585
|
-
run();
|
|
586
|
-
return {
|
|
587
|
-
unsubscribe: () => {
|
|
588
|
-
closed = true;
|
|
589
|
-
unregister();
|
|
590
|
-
},
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Runs an SQL-tag query once, the way BaseDb.liveQuery's query function is written
|
|
595
|
-
* (`(sql) => sql\`SELECT ...\``), so an entity can keep its liveQuery's text for its feed reads.
|
|
596
|
-
*/
|
|
597
|
-
async function queryEntityRows(query) {
|
|
598
|
-
if (!feed)
|
|
599
|
-
throw new Error('The change feed has not started');
|
|
600
|
-
return (await query(feed.sql));
|
|
601
|
-
}
|
|
602
|
-
/** Whether this tab's feed runs (a browser database is open); Node has none. */
|
|
603
|
-
function isChangeFeedRunning() {
|
|
604
|
-
return feed !== undefined;
|
|
605
|
-
}
|
|
606
|
-
const callAll = (targets) => {
|
|
607
|
-
for (const registration of targets) {
|
|
608
|
-
try {
|
|
609
|
-
registration.listener();
|
|
610
|
-
}
|
|
611
|
-
catch (error) {
|
|
612
|
-
logger('listener threw', error);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
const dispatch = (rows) => {
|
|
617
|
-
const targets = new Set();
|
|
618
|
-
for (const row of rows) {
|
|
619
|
-
const candidates = [
|
|
620
|
-
...(row.seedLocalId ? byLocalId.get(row.seedLocalId) ?? [] : []),
|
|
621
|
-
...(row.seedUid ? byUid.get(row.seedUid.toLowerCase()) ?? [] : []),
|
|
622
|
-
];
|
|
623
|
-
for (const registration of candidates) {
|
|
624
|
-
if (!registration.tables.has(row.tbl))
|
|
625
|
-
continue;
|
|
626
|
-
if (row.tbl === 'metadata' &&
|
|
627
|
-
registration.propertyNames &&
|
|
628
|
-
row.propertyName != null &&
|
|
629
|
-
!registration.propertyNames.has(row.propertyName)) {
|
|
630
|
-
continue;
|
|
631
|
-
}
|
|
632
|
-
targets.add(registration);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
callAll(targets);
|
|
636
|
-
};
|
|
637
|
-
const readNewRows = async (db) => {
|
|
638
|
-
const rows = await db
|
|
639
|
-
.select({
|
|
640
|
-
seq: entityChanges.seq,
|
|
641
|
-
tbl: entityChanges.tbl,
|
|
642
|
-
seedLocalId: entityChanges.seedLocalId,
|
|
643
|
-
seedUid: entityChanges.seedUid,
|
|
644
|
-
propertyName: entityChanges.propertyName,
|
|
645
|
-
})
|
|
646
|
-
.from(entityChanges)
|
|
647
|
-
.where(gt(entityChanges.seq, cursor))
|
|
648
|
-
.orderBy(entityChanges.seq);
|
|
649
|
-
if (feed?.db !== db || rows.length === 0)
|
|
650
|
-
return;
|
|
651
|
-
// Writers are serialized, so committed seqs have no holes: a missing first row was pruned.
|
|
652
|
-
const missed = rows[0].seq > cursor + 1;
|
|
653
|
-
cursor = rows[rows.length - 1].seq;
|
|
654
|
-
if (missed) {
|
|
655
|
-
logger(`cursor fell behind the log; notifying all ${registrations.size} watches`);
|
|
656
|
-
callAll([...registrations]);
|
|
657
|
-
}
|
|
658
|
-
else {
|
|
659
|
-
dispatch(rows);
|
|
660
|
-
}
|
|
661
|
-
await maybePrune(db);
|
|
662
|
-
};
|
|
663
|
-
const maybePrune = async (db) => {
|
|
664
|
-
const now = Date.now();
|
|
665
|
-
if (!isLeaderTab() || now - lastPrunedAt < ENTITY_CHANGES_PRUNE_EVERY_MS)
|
|
666
|
-
return;
|
|
667
|
-
lastPrunedAt = now;
|
|
668
|
-
try {
|
|
669
|
-
await pruneEntityChanges(db, now);
|
|
670
|
-
}
|
|
671
|
-
catch (error) {
|
|
672
|
-
logger('prune failed', error);
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
/** Deletes log rows older than ENTITY_CHANGES_RETENTION_MS. Deleting doesn't raise max(seq), so it dispatches nothing. */
|
|
676
|
-
async function pruneEntityChanges(db, now = Date.now()) {
|
|
677
|
-
await db.delete(entityChanges).where(lt(entityChanges.at, now - ENTITY_CHANGES_RETENTION_MS));
|
|
678
|
-
}
|
|
679
|
-
/** Reads once at a time; an emission during a read makes it read once more. */
|
|
680
|
-
const scheduleRead = (db) => {
|
|
681
|
-
if (reading) {
|
|
682
|
-
readAgain = true;
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
reading = (async () => {
|
|
686
|
-
try {
|
|
687
|
-
do {
|
|
688
|
-
readAgain = false;
|
|
689
|
-
await readNewRows(db);
|
|
690
|
-
} while (readAgain && feed?.db === db);
|
|
691
|
-
}
|
|
692
|
-
catch (error) {
|
|
693
|
-
logger('read failed', error);
|
|
694
|
-
}
|
|
695
|
-
finally {
|
|
696
|
-
reading = undefined;
|
|
697
|
-
}
|
|
698
|
-
})();
|
|
699
|
-
};
|
|
700
|
-
/**
|
|
701
|
-
* Starts this tab's feed on `db` (once its migrations ran), at the newest seq allocated so far:
|
|
702
|
-
* entities do their own initial read. A second call replaces the first feed.
|
|
703
|
-
*/
|
|
704
|
-
async function startChangeFeed(db, { liveQuery, sql: sqlTag }) {
|
|
705
|
-
stopChangeFeed();
|
|
706
|
-
// sqlite_sequence keeps the last seq even when pruning emptied the table.
|
|
707
|
-
const [row] = await db.all(sql `SELECT seq FROM sqlite_sequence WHERE name = 'entity_changes'`);
|
|
708
|
-
cursor = Number(row?.seq ?? 0);
|
|
709
|
-
const subscription = liveQuery((tag) => tag `SELECT max(seq) AS seq FROM entity_changes`).subscribe({
|
|
710
|
-
next: ([latest]) => {
|
|
711
|
-
if (latest?.seq != null && Number(latest.seq) > cursor)
|
|
712
|
-
scheduleRead(db);
|
|
713
|
-
},
|
|
714
|
-
error: (error) => logger('feed query failed', error),
|
|
715
|
-
});
|
|
716
|
-
feed = { db, sql: sqlTag, unsubscribe: () => subscription.unsubscribe() };
|
|
717
|
-
logger(`started at seq ${cursor}`);
|
|
718
|
-
}
|
|
719
|
-
function stopChangeFeed() {
|
|
720
|
-
feed?.unsubscribe();
|
|
721
|
-
feed = undefined;
|
|
722
|
-
readAgain = false;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
export { ADDRESSES_PERSISTED_EVENT as A, revokeSessionObjectUrl as B, queryEntityRows as C, isSessionObjectUrl as D, timedDb as E, FILES_CHANGED_EVENT as F, tabEvents as G, LOCAL_COPIES_REMOVED_EVENT as L, TabLockTimeoutError as T, isLeaderTab as a, watchEntityRows as b, whenLeaderTab as c, withDbTabLock as d, emitAcrossTabs as e, createSessionObjectUrl as f, withSeedDbLock as g, countDbStatements as h, isChangeFeedRunning as i, countLiveQueryRuns as j, postTabMessage as k, listenForOtherTabsEvents as l, startTabCoordination as m, notifyFilesWrittenOutsideCache as n, onTabMessage as o, parseAddressesPersistedPayload as p, tryWithTabLock as q, notifyFileSaved as r, startChangeFeed as s, timingMarks as t, timingNow as u, timingSince as v, watchEntityChanges as w, timingLogger as x, TAB_ID as y, timed as z };
|
|
726
|
-
//# sourceMappingURL=changeFeed-DKdVlUmt.js.map
|