@connecttomahdi/rxdb 17.0.0-beta.17 → 17.1.0
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/AGENTS.md +4 -0
- package/CHANGELOG.md +47 -4
- package/CLAUDE.md +2 -0
- package/dist/cjs/change-event-buffer.js +2 -1
- package/dist/cjs/change-event-buffer.js.map +1 -1
- package/dist/cjs/custom-index.js +85 -12
- package/dist/cjs/custom-index.js.map +1 -1
- package/dist/cjs/doc-cache.js +117 -35
- package/dist/cjs/doc-cache.js.map +1 -1
- package/dist/cjs/event-reduce.js +10 -1
- package/dist/cjs/event-reduce.js.map +1 -1
- package/dist/cjs/plugin-helpers.js +16 -0
- package/dist/cjs/plugin-helpers.js.map +1 -1
- package/dist/cjs/plugins/attachments/index.js +3 -3
- package/dist/cjs/plugins/attachments/index.js.map +1 -1
- package/dist/cjs/plugins/cleanup/cleanup.js +5 -3
- package/dist/cjs/plugins/cleanup/cleanup.js.map +1 -1
- package/dist/cjs/plugins/crdt/index.js +52 -0
- package/dist/cjs/plugins/crdt/index.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/check-query.js +7 -1
- package/dist/cjs/plugins/dev-mode/check-query.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/check-schema.js +2 -1
- package/dist/cjs/plugins/dev-mode/check-schema.js.map +1 -1
- package/dist/cjs/plugins/dev-mode/error-messages.js +43 -5
- package/dist/cjs/plugins/dev-mode/error-messages.js.map +1 -1
- package/dist/cjs/plugins/encryption-crypto-js/index.js +22 -6
- package/dist/cjs/plugins/encryption-crypto-js/index.js.map +1 -1
- package/dist/cjs/plugins/leader-election/index.js +5 -5
- package/dist/cjs/plugins/leader-election/index.js.map +1 -1
- package/dist/cjs/plugins/local-documents/local-documents.js +20 -13
- package/dist/cjs/plugins/local-documents/local-documents.js.map +1 -1
- package/dist/cjs/plugins/migration-schema/migration-helpers.js +3 -0
- package/dist/cjs/plugins/migration-schema/migration-helpers.js.map +1 -1
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js +1 -1
- package/dist/cjs/plugins/migration-schema/rx-migration-state.js.map +1 -1
- package/dist/cjs/plugins/pipeline/rx-pipeline.js +5 -1
- package/dist/cjs/plugins/pipeline/rx-pipeline.js.map +1 -1
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
- package/dist/cjs/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
- package/dist/cjs/plugins/replication/index.js +40 -2
- package/dist/cjs/plugins/replication/index.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/document-handling.js +17 -6
- package/dist/cjs/plugins/replication-google-drive/document-handling.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/google-drive-types.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/signaling.js +4 -1
- package/dist/cjs/plugins/replication-google-drive/signaling.js.map +1 -1
- package/dist/cjs/plugins/replication-google-drive/upstream.js +7 -4
- package/dist/cjs/plugins/replication-google-drive/upstream.js.map +1 -1
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js +4 -1
- package/dist/cjs/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
- package/dist/cjs/plugins/state/rx-state.js +14 -3
- package/dist/cjs/plugins/state/rx-state.js.map +1 -1
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js +10 -17
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js +112 -40
- package/dist/cjs/plugins/storage-memory/binary-search-bounds.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-helper.js +127 -40
- package/dist/cjs/plugins/storage-memory/memory-helper.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-indexes.js +1 -0
- package/dist/cjs/plugins/storage-memory/memory-indexes.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/memory-types.js.map +1 -1
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js +97 -37
- package/dist/cjs/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js +42 -1
- package/dist/cjs/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js +7 -7
- package/dist/cjs/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
- package/dist/cjs/plugins/test-utils/config.js +1 -1
- package/dist/cjs/plugins/test-utils/config.js.map +1 -1
- package/dist/cjs/plugins/test-utils/performance.js +122 -92
- package/dist/cjs/plugins/test-utils/performance.js.map +1 -1
- package/dist/cjs/plugins/test-utils/schema-objects.js +1 -1
- package/dist/cjs/plugins/test-utils/schema-objects.js.map +1 -1
- package/dist/cjs/plugins/test-utils/test-util.js +62 -0
- package/dist/cjs/plugins/test-utils/test-util.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-map.js +2 -2
- package/dist/cjs/plugins/utils/utils-map.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js +3 -2
- package/dist/cjs/plugins/utils/utils-object-deep-equal.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js +25 -0
- package/dist/cjs/plugins/utils/utils-object-dot-prop.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-object.js +102 -27
- package/dist/cjs/plugins/utils/utils-object.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-other.js +9 -4
- package/dist/cjs/plugins/utils/utils-other.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-premium.js +1 -19
- package/dist/cjs/plugins/utils/utils-premium.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-revision.js +20 -10
- package/dist/cjs/plugins/utils/utils-revision.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-rxdb-version.js +1 -1
- package/dist/cjs/plugins/utils/utils-rxdb-version.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-string.js +11 -8
- package/dist/cjs/plugins/utils/utils-string.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-time.js +21 -16
- package/dist/cjs/plugins/utils/utils-time.js.map +1 -1
- package/dist/cjs/query-cache.js +6 -4
- package/dist/cjs/query-cache.js.map +1 -1
- package/dist/cjs/query-planner.js +2 -2
- package/dist/cjs/query-planner.js.map +1 -1
- package/dist/cjs/replication-protocol/downstream.js +1 -1
- package/dist/cjs/replication-protocol/downstream.js.map +1 -1
- package/dist/cjs/rx-collection-helper.js +11 -6
- package/dist/cjs/rx-collection-helper.js.map +1 -1
- package/dist/cjs/rx-collection.js +34 -6
- package/dist/cjs/rx-collection.js.map +1 -1
- package/dist/cjs/rx-database.js +40 -7
- package/dist/cjs/rx-database.js.map +1 -1
- package/dist/cjs/rx-document.js +10 -3
- package/dist/cjs/rx-document.js.map +1 -1
- package/dist/cjs/rx-query-helper.js +35 -12
- package/dist/cjs/rx-query-helper.js.map +1 -1
- package/dist/cjs/rx-query-single-result.js +9 -2
- package/dist/cjs/rx-query-single-result.js.map +1 -1
- package/dist/cjs/rx-query.js +72 -29
- package/dist/cjs/rx-query.js.map +1 -1
- package/dist/cjs/rx-schema-helper.js +9 -3
- package/dist/cjs/rx-schema-helper.js.map +1 -1
- package/dist/cjs/rx-schema.js +1 -0
- package/dist/cjs/rx-schema.js.map +1 -1
- package/dist/cjs/rx-storage-helper.js +212 -129
- package/dist/cjs/rx-storage-helper.js.map +1 -1
- package/dist/cjs/types/rx-error.d.js.map +1 -1
- package/dist/cjs/types/rx-schema.d.js.map +1 -1
- package/dist/esm/change-event-buffer.js +2 -1
- package/dist/esm/change-event-buffer.js.map +1 -1
- package/dist/esm/custom-index.js +85 -12
- package/dist/esm/custom-index.js.map +1 -1
- package/dist/esm/doc-cache.js +118 -36
- package/dist/esm/doc-cache.js.map +1 -1
- package/dist/esm/event-reduce.js +10 -1
- package/dist/esm/event-reduce.js.map +1 -1
- package/dist/esm/plugin-helpers.js +16 -0
- package/dist/esm/plugin-helpers.js.map +1 -1
- package/dist/esm/plugins/attachments/index.js +3 -3
- package/dist/esm/plugins/attachments/index.js.map +1 -1
- package/dist/esm/plugins/cleanup/cleanup.js +5 -3
- package/dist/esm/plugins/cleanup/cleanup.js.map +1 -1
- package/dist/esm/plugins/crdt/index.js +52 -0
- package/dist/esm/plugins/crdt/index.js.map +1 -1
- package/dist/esm/plugins/dev-mode/check-query.js +7 -1
- package/dist/esm/plugins/dev-mode/check-query.js.map +1 -1
- package/dist/esm/plugins/dev-mode/check-schema.js +2 -1
- package/dist/esm/plugins/dev-mode/check-schema.js.map +1 -1
- package/dist/esm/plugins/dev-mode/error-messages.js +43 -5
- package/dist/esm/plugins/dev-mode/error-messages.js.map +1 -1
- package/dist/esm/plugins/encryption-crypto-js/index.js +22 -6
- package/dist/esm/plugins/encryption-crypto-js/index.js.map +1 -1
- package/dist/esm/plugins/leader-election/index.js +4 -4
- package/dist/esm/plugins/leader-election/index.js.map +1 -1
- package/dist/esm/plugins/local-documents/local-documents.js +20 -13
- package/dist/esm/plugins/local-documents/local-documents.js.map +1 -1
- package/dist/esm/plugins/migration-schema/migration-helpers.js +3 -0
- package/dist/esm/plugins/migration-schema/migration-helpers.js.map +1 -1
- package/dist/esm/plugins/migration-schema/rx-migration-state.js +1 -1
- package/dist/esm/plugins/migration-schema/rx-migration-state.js.map +1 -1
- package/dist/esm/plugins/pipeline/rx-pipeline.js +5 -1
- package/dist/esm/plugins/pipeline/rx-pipeline.js.map +1 -1
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js +4 -2
- package/dist/esm/plugins/query-builder/mquery/nosql-query-builder.js.map +1 -1
- package/dist/esm/plugins/replication/index.js +40 -2
- package/dist/esm/plugins/replication/index.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/document-handling.js +17 -6
- package/dist/esm/plugins/replication-google-drive/document-handling.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-helper.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/google-drive-types.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/signaling.js +4 -1
- package/dist/esm/plugins/replication-google-drive/signaling.js.map +1 -1
- package/dist/esm/plugins/replication-google-drive/upstream.js +7 -4
- package/dist/esm/plugins/replication-google-drive/upstream.js.map +1 -1
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js +4 -1
- package/dist/esm/plugins/replication-microsoft-onedrive/signaling.js.map +1 -1
- package/dist/esm/plugins/state/rx-state.js +15 -4
- package/dist/esm/plugins/state/rx-state.js.map +1 -1
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js +11 -18
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js +107 -40
- package/dist/esm/plugins/storage-memory/binary-search-bounds.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-helper.js +128 -41
- package/dist/esm/plugins/storage-memory/memory-helper.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-indexes.js +1 -0
- package/dist/esm/plugins/storage-memory/memory-indexes.js.map +1 -1
- package/dist/esm/plugins/storage-memory/memory-types.js.map +1 -1
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js +90 -30
- package/dist/esm/plugins/storage-memory/rx-storage-instance-memory.js.map +1 -1
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js +39 -0
- package/dist/esm/plugins/storage-mongodb/mongodb-helper.js.map +1 -1
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js +8 -8
- package/dist/esm/plugins/storage-mongodb/rx-storage-instance-mongodb.js.map +1 -1
- package/dist/esm/plugins/test-utils/config.js +1 -1
- package/dist/esm/plugins/test-utils/config.js.map +1 -1
- package/dist/esm/plugins/test-utils/performance.js +122 -92
- package/dist/esm/plugins/test-utils/performance.js.map +1 -1
- package/dist/esm/plugins/test-utils/schema-objects.js +1 -1
- package/dist/esm/plugins/test-utils/schema-objects.js.map +1 -1
- package/dist/esm/plugins/test-utils/test-util.js +59 -0
- package/dist/esm/plugins/test-utils/test-util.js.map +1 -1
- package/dist/esm/plugins/utils/utils-map.js +2 -2
- package/dist/esm/plugins/utils/utils-map.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object-deep-equal.js +3 -2
- package/dist/esm/plugins/utils/utils-object-deep-equal.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object-dot-prop.js +25 -0
- package/dist/esm/plugins/utils/utils-object-dot-prop.js.map +1 -1
- package/dist/esm/plugins/utils/utils-object.js +102 -27
- package/dist/esm/plugins/utils/utils-object.js.map +1 -1
- package/dist/esm/plugins/utils/utils-other.js +9 -4
- package/dist/esm/plugins/utils/utils-other.js.map +1 -1
- package/dist/esm/plugins/utils/utils-premium.js +1 -19
- package/dist/esm/plugins/utils/utils-premium.js.map +1 -1
- package/dist/esm/plugins/utils/utils-revision.js +20 -10
- package/dist/esm/plugins/utils/utils-revision.js.map +1 -1
- package/dist/esm/plugins/utils/utils-rxdb-version.js +1 -1
- package/dist/esm/plugins/utils/utils-rxdb-version.js.map +1 -1
- package/dist/esm/plugins/utils/utils-string.js +11 -8
- package/dist/esm/plugins/utils/utils-string.js.map +1 -1
- package/dist/esm/plugins/utils/utils-time.js +21 -16
- package/dist/esm/plugins/utils/utils-time.js.map +1 -1
- package/dist/esm/query-cache.js +7 -5
- package/dist/esm/query-cache.js.map +1 -1
- package/dist/esm/query-planner.js +2 -2
- package/dist/esm/query-planner.js.map +1 -1
- package/dist/esm/replication-protocol/downstream.js +1 -1
- package/dist/esm/replication-protocol/downstream.js.map +1 -1
- package/dist/esm/rx-collection-helper.js +12 -7
- package/dist/esm/rx-collection-helper.js.map +1 -1
- package/dist/esm/rx-collection.js +35 -7
- package/dist/esm/rx-collection.js.map +1 -1
- package/dist/esm/rx-database.js +40 -7
- package/dist/esm/rx-database.js.map +1 -1
- package/dist/esm/rx-document.js +11 -4
- package/dist/esm/rx-document.js.map +1 -1
- package/dist/esm/rx-query-helper.js +35 -12
- package/dist/esm/rx-query-helper.js.map +1 -1
- package/dist/esm/rx-query-single-result.js +10 -3
- package/dist/esm/rx-query-single-result.js.map +1 -1
- package/dist/esm/rx-query.js +72 -29
- package/dist/esm/rx-query.js.map +1 -1
- package/dist/esm/rx-schema-helper.js +9 -3
- package/dist/esm/rx-schema-helper.js.map +1 -1
- package/dist/esm/rx-schema.js +1 -0
- package/dist/esm/rx-schema.js.map +1 -1
- package/dist/esm/rx-storage-helper.js +176 -94
- package/dist/esm/rx-storage-helper.js.map +1 -1
- package/dist/esm/types/rx-error.d.js.map +1 -1
- package/dist/esm/types/rx-schema.d.js.map +1 -1
- package/dist/types/custom-index.d.ts +5 -0
- package/dist/types/doc-cache.d.ts +1 -1
- package/dist/types/index.d.ts +25 -26
- package/dist/types/plugins/dev-mode/error-messages.d.ts +36 -0
- package/dist/types/plugins/leader-election/index.d.ts +1 -0
- package/dist/types/plugins/replication-google-drive/document-handling.d.ts +4 -1
- package/dist/types/plugins/replication-google-drive/google-drive-types.d.ts +1 -0
- package/dist/types/plugins/state/rx-state.d.ts +1 -1
- package/dist/types/plugins/storage-denokv/index.d.ts +1 -1
- package/dist/types/plugins/storage-dexie/rx-storage-dexie.d.ts +1 -1
- package/dist/types/plugins/storage-localstorage/index.d.ts +1 -1
- package/dist/types/plugins/storage-memory/binary-search-bounds.d.ts +21 -10
- package/dist/types/plugins/storage-memory/memory-helper.d.ts +7 -3
- package/dist/types/plugins/storage-memory/memory-types.d.ts +5 -0
- package/dist/types/plugins/storage-mongodb/mongodb-helper.d.ts +9 -1
- package/dist/types/plugins/storage-mongodb/rx-storage-instance-mongodb.d.ts +2 -2
- package/dist/types/plugins/storage-mongodb/rx-storage-mongodb.d.ts +1 -1
- package/dist/types/plugins/storage-remote/rx-storage-remote.d.ts +1 -1
- package/dist/types/plugins/storage-sqlite/index.d.ts +1 -1
- package/dist/types/plugins/test-utils/performance.d.ts +36 -0
- package/dist/types/plugins/test-utils/test-util.d.ts +17 -0
- package/dist/types/plugins/utils/utils-object.d.ts +8 -3
- package/dist/types/plugins/utils/utils-premium.d.ts +0 -2
- package/dist/types/plugins/utils/utils-rxdb-version.d.ts +1 -1
- package/dist/types/rx-database.d.ts +1 -1
- package/dist/types/rx-query-single-result.d.ts +1 -1
- package/dist/types/rx-query.d.ts +3 -2
- package/dist/types/rx-storage-helper.d.ts +15 -0
- package/eslint.config.mjs +2 -1
- package/package.json +732 -729
- package/scripts/check-code-block-line-length.js +91 -0
- package/scripts/check-em-dashes.js +53 -0
- package/scripts/docs-fetch-git-history.mjs +36 -0
- package/scripts/install-foundationdb.sh +0 -6
- package/scripts/notify-indexnow.mjs +171 -0
- package/scripts/start-foundationdb-docker.sh +73 -0
- package/src/change-event-buffer.ts +4 -1
- package/src/custom-index.ts +93 -16
- package/src/doc-cache.ts +117 -41
- package/src/event-reduce.ts +10 -1
- package/src/plugin-helpers.ts +10 -0
- package/src/plugins/attachments/index.ts +10 -12
- package/src/plugins/cleanup/cleanup.ts +5 -3
- package/src/plugins/crdt/index.ts +55 -0
- package/src/plugins/dev-mode/check-query.ts +7 -1
- package/src/plugins/dev-mode/check-schema.ts +2 -1
- package/src/plugins/dev-mode/error-messages.ts +45 -5
- package/src/plugins/encryption-crypto-js/index.ts +18 -6
- package/src/plugins/leader-election/index.ts +9 -8
- package/src/plugins/local-documents/local-documents.ts +21 -12
- package/src/plugins/migration-schema/migration-helpers.ts +3 -0
- package/src/plugins/migration-schema/rx-migration-state.ts +1 -1
- package/src/plugins/pipeline/rx-pipeline.ts +5 -1
- package/src/plugins/query-builder/mquery/nosql-query-builder.ts +8 -2
- package/src/plugins/replication/index.ts +41 -3
- package/src/plugins/replication-google-drive/document-handling.ts +17 -5
- package/src/plugins/replication-google-drive/google-drive-helper.ts +1 -1
- package/src/plugins/replication-google-drive/google-drive-types.ts +1 -0
- package/src/plugins/replication-google-drive/signaling.ts +4 -1
- package/src/plugins/replication-google-drive/upstream.ts +7 -4
- package/src/plugins/replication-microsoft-onedrive/signaling.ts +4 -1
- package/src/plugins/state/rx-state.ts +17 -5
- package/src/plugins/storage-dexie/rx-storage-instance-dexie.ts +0 -27
- package/src/plugins/storage-memory/binary-search-bounds.ts +105 -40
- package/src/plugins/storage-memory/memory-helper.ts +158 -67
- package/src/plugins/storage-memory/memory-indexes.ts +1 -0
- package/src/plugins/storage-memory/memory-types.ts +5 -0
- package/src/plugins/storage-memory/rx-storage-instance-memory.ts +104 -53
- package/src/plugins/storage-mongodb/mongodb-helper.ts +43 -1
- package/src/plugins/storage-mongodb/rx-storage-instance-mongodb.ts +11 -9
- package/src/plugins/test-utils/config.ts +2 -1
- package/src/plugins/test-utils/performance.ts +159 -85
- package/src/plugins/test-utils/schema-objects.ts +1 -1
- package/src/plugins/test-utils/test-util.ts +71 -0
- package/src/plugins/utils/utils-map.ts +2 -2
- package/src/plugins/utils/utils-object-deep-equal.ts +2 -4
- package/src/plugins/utils/utils-object-dot-prop.ts +25 -0
- package/src/plugins/utils/utils-object.ts +103 -28
- package/src/plugins/utils/utils-other.ts +9 -4
- package/src/plugins/utils/utils-premium.ts +11 -37
- package/src/plugins/utils/utils-revision.ts +20 -9
- package/src/plugins/utils/utils-rxdb-version.ts +1 -1
- package/src/plugins/utils/utils-string.ts +11 -9
- package/src/plugins/utils/utils-time.ts +21 -17
- package/src/query-cache.ts +6 -5
- package/src/query-planner.ts +2 -2
- package/src/replication-protocol/downstream.ts +1 -1
- package/src/rx-collection-helper.ts +12 -6
- package/src/rx-collection.ts +39 -8
- package/src/rx-database.ts +49 -17
- package/src/rx-document.ts +12 -3
- package/src/rx-query-helper.ts +36 -15
- package/src/rx-query-single-result.ts +10 -3
- package/src/rx-query.ts +48 -8
- package/src/rx-schema-helper.ts +7 -4
- package/src/rx-schema.ts +1 -0
- package/src/rx-storage-helper.ts +210 -139
- package/src/types/rx-error.d.ts +3 -0
- package/src/types/rx-schema.d.ts +5 -0
- package/dist/esm/package.json +0 -1
- package/dist/types/types/conflict-handling.d.ts +0 -48
- package/dist/types/types/couchdb.d.ts +0 -293
- package/dist/types/types/index.d.ts +0 -32
- package/dist/types/types/modules/index.d.ts +0 -0
- package/dist/types/types/modules/mocha.parallel.d.ts +0 -1
- package/dist/types/types/plugins/backup.d.ts +0 -35
- package/dist/types/types/plugins/cleanup.d.ts +0 -38
- package/dist/types/types/plugins/crdt.d.ts +0 -76
- package/dist/types/types/plugins/dexie.d.ts +0 -30
- package/dist/types/types/plugins/local-documents.d.ts +0 -49
- package/dist/types/types/plugins/migration.d.ts +0 -14
- package/dist/types/types/plugins/reactivity.d.ts +0 -40
- package/dist/types/types/plugins/replication-graphql.d.ts +0 -98
- package/dist/types/types/plugins/replication.d.ts +0 -175
- package/dist/types/types/plugins/state.d.ts +0 -4
- package/dist/types/types/plugins/update.d.ts +0 -23
- package/dist/types/types/plugins/webmcp.d.ts +0 -40
- package/dist/types/types/query-planner.d.ts +0 -47
- package/dist/types/types/replication-protocol.d.ts +0 -296
- package/dist/types/types/rx-attachment.d.ts +0 -46
- package/dist/types/types/rx-change-event.d.ts +0 -85
- package/dist/types/types/rx-collection.d.ts +0 -117
- package/dist/types/types/rx-database-internal-store.d.ts +0 -54
- package/dist/types/types/rx-database.d.ts +0 -124
- package/dist/types/types/rx-document.d.ts +0 -160
- package/dist/types/types/rx-error.d.ts +0 -222
- package/dist/types/types/rx-plugin.d.ts +0 -167
- package/dist/types/types/rx-query.d.ts +0 -144
- package/dist/types/types/rx-schema.d.ts +0 -209
- package/dist/types/types/rx-storage.d.ts +0 -347
- package/dist/types/types/rx-storage.interface.d.ts +0 -312
- package/dist/types/types/util.d.ts +0 -180
|
@@ -4,25 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.boundEQ = boundEQ;
|
|
7
|
+
exports.boundEQByIndexString = boundEQByIndexString;
|
|
7
8
|
exports.boundGE = boundGE;
|
|
9
|
+
exports.boundGEByIndexString = boundGEByIndexString;
|
|
8
10
|
exports.boundGT = boundGT;
|
|
11
|
+
exports.boundGTByIndexString = boundGTByIndexString;
|
|
9
12
|
exports.boundLE = boundLE;
|
|
13
|
+
exports.boundLEByIndexString = boundLEByIndexString;
|
|
10
14
|
exports.boundLT = boundLT;
|
|
15
|
+
exports.boundLTByIndexString = boundLTByIndexString;
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* Optimized binary search functions for the memory storage.
|
|
18
|
+
* Based on https://github.com/mikolalysenko/binary-search-bounds
|
|
19
|
+
* but with performance improvements:
|
|
20
|
+
* - Removed unnecessary undefined checks for comparator
|
|
21
|
+
* - Inlined the norm() wrapper to avoid extra function calls
|
|
22
|
+
* - Added string-specialized variants to avoid temporary array allocations
|
|
17
23
|
*/
|
|
18
24
|
|
|
19
|
-
function
|
|
25
|
+
function boundGE(a, y, c, lo, hi) {
|
|
26
|
+
var l = lo === undefined ? 0 : lo | 0;
|
|
27
|
+
var h = hi === undefined ? a.length - 1 : hi | 0;
|
|
20
28
|
var i = h + 1;
|
|
21
29
|
while (l <= h) {
|
|
22
30
|
var m = l + h >>> 1;
|
|
23
|
-
|
|
24
|
-
var p = c !== undefined ? c(x, y) : x - y;
|
|
25
|
-
if (p >= 0) {
|
|
31
|
+
if (c(a[m], y) >= 0) {
|
|
26
32
|
i = m;
|
|
27
33
|
h = m - 1;
|
|
28
34
|
} else {
|
|
@@ -31,13 +37,13 @@ function ge(a, y, c, l, h) {
|
|
|
31
37
|
}
|
|
32
38
|
return i;
|
|
33
39
|
}
|
|
34
|
-
function
|
|
40
|
+
function boundGT(a, y, c, lo, hi) {
|
|
41
|
+
var l = lo === undefined ? 0 : lo | 0;
|
|
42
|
+
var h = hi === undefined ? a.length - 1 : hi | 0;
|
|
35
43
|
var i = h + 1;
|
|
36
44
|
while (l <= h) {
|
|
37
45
|
var m = l + h >>> 1;
|
|
38
|
-
|
|
39
|
-
var p = c !== undefined ? c(x, y) : x - y;
|
|
40
|
-
if (p > 0) {
|
|
46
|
+
if (c(a[m], y) > 0) {
|
|
41
47
|
i = m;
|
|
42
48
|
h = m - 1;
|
|
43
49
|
} else {
|
|
@@ -46,13 +52,13 @@ function gt(a, y, c, l, h) {
|
|
|
46
52
|
}
|
|
47
53
|
return i;
|
|
48
54
|
}
|
|
49
|
-
function
|
|
55
|
+
function boundLT(a, y, c, lo, hi) {
|
|
56
|
+
var l = lo === undefined ? 0 : lo | 0;
|
|
57
|
+
var h = hi === undefined ? a.length - 1 : hi | 0;
|
|
50
58
|
var i = l - 1;
|
|
51
59
|
while (l <= h) {
|
|
52
|
-
var m = l + h >>> 1
|
|
53
|
-
|
|
54
|
-
var p = c !== undefined ? c(x, y) : x - y;
|
|
55
|
-
if (p < 0) {
|
|
60
|
+
var m = l + h >>> 1;
|
|
61
|
+
if (c(a[m], y) < 0) {
|
|
56
62
|
i = m;
|
|
57
63
|
l = m + 1;
|
|
58
64
|
} else {
|
|
@@ -61,13 +67,13 @@ function lt(a, y, c, l, h) {
|
|
|
61
67
|
}
|
|
62
68
|
return i;
|
|
63
69
|
}
|
|
64
|
-
function
|
|
70
|
+
function boundLE(a, y, c, lo, hi) {
|
|
71
|
+
var l = lo === undefined ? 0 : lo | 0;
|
|
72
|
+
var h = hi === undefined ? a.length - 1 : hi | 0;
|
|
65
73
|
var i = l - 1;
|
|
66
74
|
while (l <= h) {
|
|
67
|
-
var m = l + h >>> 1
|
|
68
|
-
|
|
69
|
-
var p = c !== undefined ? c(x, y) : x - y;
|
|
70
|
-
if (p <= 0) {
|
|
75
|
+
var m = l + h >>> 1;
|
|
76
|
+
if (c(a[m], y) <= 0) {
|
|
71
77
|
i = m;
|
|
72
78
|
l = m + 1;
|
|
73
79
|
} else {
|
|
@@ -76,11 +82,12 @@ function le(a, y, c, l, h) {
|
|
|
76
82
|
}
|
|
77
83
|
return i;
|
|
78
84
|
}
|
|
79
|
-
function
|
|
85
|
+
function boundEQ(a, y, c, lo, hi) {
|
|
86
|
+
var l = lo === undefined ? 0 : lo | 0;
|
|
87
|
+
var h = hi === undefined ? a.length - 1 : hi | 0;
|
|
80
88
|
while (l <= h) {
|
|
81
|
-
var m = l + h >>> 1
|
|
82
|
-
|
|
83
|
-
var p = c !== undefined ? c(x, y) : x - y;
|
|
89
|
+
var m = l + h >>> 1;
|
|
90
|
+
var p = c(a[m], y);
|
|
84
91
|
if (p === 0) {
|
|
85
92
|
return m;
|
|
86
93
|
}
|
|
@@ -92,22 +99,87 @@ function eq(a, y, c, l, h) {
|
|
|
92
99
|
}
|
|
93
100
|
return -1;
|
|
94
101
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Specialized binary search functions that compare DocWithIndexString
|
|
105
|
+
* entries directly against an index string, avoiding temporary array allocations.
|
|
106
|
+
* Used in query() and count() hot paths.
|
|
107
|
+
*/
|
|
108
|
+
function boundGEByIndexString(a, indexString) {
|
|
109
|
+
var l = 0;
|
|
110
|
+
var h = a.length - 1;
|
|
111
|
+
var i = h + 1;
|
|
112
|
+
while (l <= h) {
|
|
113
|
+
var m = l + h >>> 1;
|
|
114
|
+
if (a[m][0] >= indexString) {
|
|
115
|
+
i = m;
|
|
116
|
+
h = m - 1;
|
|
117
|
+
} else {
|
|
118
|
+
l = m + 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return i;
|
|
100
122
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
123
|
+
function boundGTByIndexString(a, indexString) {
|
|
124
|
+
var l = 0;
|
|
125
|
+
var h = a.length - 1;
|
|
126
|
+
var i = h + 1;
|
|
127
|
+
while (l <= h) {
|
|
128
|
+
var m = l + h >>> 1;
|
|
129
|
+
if (a[m][0] > indexString) {
|
|
130
|
+
i = m;
|
|
131
|
+
h = m - 1;
|
|
132
|
+
} else {
|
|
133
|
+
l = m + 1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return i;
|
|
103
137
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
138
|
+
function boundEQByIndexString(a, indexString) {
|
|
139
|
+
var l = 0;
|
|
140
|
+
var h = a.length - 1;
|
|
141
|
+
while (l <= h) {
|
|
142
|
+
var m = l + h >>> 1;
|
|
143
|
+
var s = a[m][0];
|
|
144
|
+
if (s === indexString) {
|
|
145
|
+
return m;
|
|
146
|
+
}
|
|
147
|
+
if (s < indexString) {
|
|
148
|
+
l = m + 1;
|
|
149
|
+
} else {
|
|
150
|
+
h = m - 1;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return -1;
|
|
106
154
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
155
|
+
function boundLTByIndexString(a, indexString) {
|
|
156
|
+
var l = 0;
|
|
157
|
+
var h = a.length - 1;
|
|
158
|
+
var i = l - 1;
|
|
159
|
+
while (l <= h) {
|
|
160
|
+
var m = l + h >>> 1;
|
|
161
|
+
if (a[m][0] < indexString) {
|
|
162
|
+
i = m;
|
|
163
|
+
l = m + 1;
|
|
164
|
+
} else {
|
|
165
|
+
h = m - 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return i;
|
|
109
169
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
170
|
+
function boundLEByIndexString(a, indexString) {
|
|
171
|
+
var l = 0;
|
|
172
|
+
var h = a.length - 1;
|
|
173
|
+
var i = l - 1;
|
|
174
|
+
while (l <= h) {
|
|
175
|
+
var m = l + h >>> 1;
|
|
176
|
+
if (a[m][0] <= indexString) {
|
|
177
|
+
i = m;
|
|
178
|
+
l = m + 1;
|
|
179
|
+
} else {
|
|
180
|
+
h = m - 1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return i;
|
|
112
184
|
}
|
|
113
185
|
//# sourceMappingURL=binary-search-bounds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-search-bounds.js","names":["ge","a","y","c","l","h","i","m","x","p","undefined","gt","lt","le","eq","norm","f","length","boundGE","boundGT","boundLT","boundLE","boundEQ"],"sources":["../../../../src/plugins/storage-memory/binary-search-bounds.ts"],"sourcesContent":["/**\r\n * Everything in this file was copied and adapted from\r\n * @link https://github.com/mikolalysenko/binary-search-bounds\r\n *\r\n * We should use the original npm module instead when this bug is fixed:\r\n * @link https://github.com/mikolalysenko/binary-search-bounds/pull/14\r\n */\r\n\r\n\r\n\r\ntype Compare<T> = ((a: T, b: T) => number | null | undefined);\r\n\r\nfunction ge<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {\r\n let i: number = h + 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n const x: any = a[m];\r\n const p: any = (c !== undefined) ? c(x, y) : (x - (y as any));\r\n if (p >= 0) {\r\n i = m; h = m - 1;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nfunction gt<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {\r\n let i = h + 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n const x = a[m];\r\n const p: any = (c !== undefined) ? c(x, y) : ((x as any) - (y as any));\r\n if (p > 0) {\r\n i = m; h = m - 1;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nfunction lt<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {\r\n let i = l - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1, x = a[m];\r\n const p: any = (c !== undefined) ? c(x, y) : ((x as any) - (y as any));\r\n if (p < 0) {\r\n i = m; l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nfunction le<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {\r\n let i = l - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1, x = a[m];\r\n const p: any = (c !== undefined) ? c(x, y) : ((x as any) - (y as any));\r\n if (p <= 0) {\r\n i = m; l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nfunction eq<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any): number {\r\n while (l <= h) {\r\n const m = (l + h) >>> 1, x = a[m];\r\n const p: any = (c !== undefined) ? c(x, y) : ((x as any) - (y as any));\r\n if (p === 0) {\r\n return m;\r\n }\r\n if (p <= 0) {\r\n l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return -1;\r\n}\r\n\r\nfunction norm<T>(a: T[], y: T, c: Compare<T>, l: any, h: any, f: any) {\r\n return f(a, y, c, (l === undefined) ? 0 : l | 0, (h === undefined) ? a.length - 1 : h | 0);\r\n}\r\n\r\n\r\nexport function boundGE<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any) {\r\n return norm(a, y, c, l, h, ge);\r\n}\r\nexport function boundGT<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any) {\r\n return norm(a, y, c, l, h, gt);\r\n}\r\nexport function boundLT<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any) {\r\n return norm(a, y, c, l, h, lt);\r\n}\r\nexport function boundLE<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any) {\r\n return norm(a, y, c, l, h, le);\r\n}\r\nexport function boundEQ<T>(a: T[], y: T, c: Compare<T>, l?: any, h?: any) {\r\n return norm(a, y, c, l, h, eq);\r\n}\r\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,EAAEA,CAAIC,CAAM,EAAEC,CAAI,EAAEC,CAAa,EAAEC,CAAO,EAAEC,CAAO,EAAU;EAClE,IAAIC,CAAS,GAAGD,CAAC,GAAG,CAAC;EACrB,OAAOD,CAAC,IAAIC,CAAC,EAAE;IACX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,EAAEC,CAAI,EAAEC,CAAa,EAAEC,CAAO,EAAEC,CAAO,EAAE;EACtE,OAAOU,IAAI,CAACd,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEQ,EAAE,CAAC;AAClC;AACO,SAASS,OAAOA,CAAIrB,CAAM,EAAEC,CAAI,EAAEC,CAAa,EAAEC,CAAO,EAAEC,CAAO,EAAE;EACtE,OAAOU,IAAI,CAACd,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAES,EAAE,CAAC;AAClC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"binary-search-bounds.js","names":["boundGE","a","y","c","lo","hi","l","undefined","h","length","i","m","boundGT","boundLT","boundLE","boundEQ","p","boundGEByIndexString","indexString","boundGTByIndexString","boundEQByIndexString","s","boundLTByIndexString","boundLEByIndexString"],"sources":["../../../../src/plugins/storage-memory/binary-search-bounds.ts"],"sourcesContent":["/**\r\n * Optimized binary search functions for the memory storage.\r\n * Based on https://github.com/mikolalysenko/binary-search-bounds\r\n * but with performance improvements:\r\n * - Removed unnecessary undefined checks for comparator\r\n * - Inlined the norm() wrapper to avoid extra function calls\r\n * - Added string-specialized variants to avoid temporary array allocations\r\n */\r\n\r\ntype Compare<T> = ((a: T, b: T) => number | null | undefined);\r\n\r\nexport function boundGE<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {\r\n let l: number = lo === undefined ? 0 : lo | 0;\r\n let h: number = hi === undefined ? a.length - 1 : hi | 0;\r\n let i: number = h + 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if ((c(a[m], y) as number) >= 0) {\r\n i = m; h = m - 1;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundGT<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {\r\n let l: number = lo === undefined ? 0 : lo | 0;\r\n let h: number = hi === undefined ? a.length - 1 : hi | 0;\r\n let i = h + 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if ((c(a[m], y) as number) > 0) {\r\n i = m; h = m - 1;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundLT<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {\r\n let l: number = lo === undefined ? 0 : lo | 0;\r\n let h: number = hi === undefined ? a.length - 1 : hi | 0;\r\n let i = l - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if ((c(a[m], y) as number) < 0) {\r\n i = m; l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundLE<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {\r\n let l: number = lo === undefined ? 0 : lo | 0;\r\n let h: number = hi === undefined ? a.length - 1 : hi | 0;\r\n let i = l - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if ((c(a[m], y) as number) <= 0) {\r\n i = m; l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundEQ<T>(a: T[], y: T, c: Compare<T>, lo?: any, hi?: any): number {\r\n let l: number = lo === undefined ? 0 : lo | 0;\r\n let h: number = hi === undefined ? a.length - 1 : hi | 0;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n const p = c(a[m], y) as number;\r\n if (p === 0) {\r\n return m;\r\n }\r\n if (p <= 0) {\r\n l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return -1;\r\n}\r\n\r\n/**\r\n * Specialized binary search functions that compare DocWithIndexString\r\n * entries directly against an index string, avoiding temporary array allocations.\r\n * Used in query() and count() hot paths.\r\n */\r\nexport function boundGEByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {\r\n let l = 0;\r\n let h = a.length - 1;\r\n let i: number = h + 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if (a[m][0] >= indexString) {\r\n i = m; h = m - 1;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundGTByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {\r\n let l = 0;\r\n let h = a.length - 1;\r\n let i = h + 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if (a[m][0] > indexString) {\r\n i = m; h = m - 1;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundEQByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {\r\n let l = 0;\r\n let h = a.length - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n const s = a[m][0];\r\n if (s === indexString) {\r\n return m;\r\n }\r\n if (s < indexString) {\r\n l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return -1;\r\n}\r\n\r\nexport function boundLTByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {\r\n let l = 0;\r\n let h = a.length - 1;\r\n let i = l - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if (a[m][0] < indexString) {\r\n i = m; l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return i;\r\n}\r\n\r\nexport function boundLEByIndexString<T extends [string, ...any[]]>(a: T[], indexString: string): number {\r\n let l = 0;\r\n let h = a.length - 1;\r\n let i = l - 1;\r\n while (l <= h) {\r\n const m = (l + h) >>> 1;\r\n if (a[m][0] <= indexString) {\r\n i = m; l = m + 1;\r\n } else {\r\n h = m - 1;\r\n }\r\n }\r\n return i;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,SAASA,OAAOA,CAAIC,CAAM,EAAEC,CAAI,EAAEC,CAAa,EAAEC,EAAQ,EAAEC,EAAQ,EAAU;EAChF,IAAIC,CAAS,GAAGF,EAAE,KAAKG,SAAS,GAA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T,IAAIE,CAAC,GAAGP,CAAC,CAACQ,MAAM,GAAG,CAAC;EACpB,IAAIC,CAAC,GAAGJ,CAAC,GAAG,CAAC;EACb,OAAOA,CAAC,IAAIE,CAAC,EAAE;IACX,IAAMG,CAAC,GAAIL,CAAC,GAAGE,CAAC,KAAM,CAAC;IACvB,IAAIP,CAAC,CAACU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAGO,WAAW,EAAE;MACvBR,CAAC,GAAGC,CAAC;MAAEL,CAAC,GAAGK,CAAC,GAAG,CAAC;IACpB,CAAC,MAAM;MACHH,CAAC,GAAGG,CAAC,GAAG,CAAC;IACb;EACJ;EACA,OAAOD,CAAC;AACZ;AAEO,SAASa,oBAAoBA,CAA+BtB,CAAM,EAAEiB,WAAmB,EAAU;EACpG,IAAIZ,CAAC,GAAG,CAAC;EACT,IAAIE,CAAC,GAAGP,CAAC,CAACQ,MAAM,GAAG,CAAC;EACpB,IAAIC,CAAC,GAAGJ,CAAC,GAAG,CAAC;EACb,OAAOA,CAAC,IAAIE,CAAC,EAAE;IACX,IAAMG,CAAC,GAAIL,CAAC,GAAGE,CAAC,KAAM,CAAC;IACvB,IAAIP,CAAC,CAACU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAIO,WAAW,EAAE;MACxBR,CAAC,GAAGC,CAAC;MAAEL,CAAC,GAAGK,CAAC,GAAG,CAAC;IACpB,CAAC,MAAM;MACHH,CAAC,GAAGG,CAAC,GAAG,CAAC;IACb;EACJ;EACA,OAAOD,CAAC;AACZ","ignoreList":[]}
|
|
@@ -24,6 +24,14 @@ function ensureNotRemoved(instance) {
|
|
|
24
24
|
function attachmentMapKey(documentId, attachmentId) {
|
|
25
25
|
return documentId + '||' + attachmentId;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @performance
|
|
30
|
+
* Threshold for using in-place splice vs. full merge-sort when inserting
|
|
31
|
+
* documents into indexes. Below this batch size, in-place binary search + splice
|
|
32
|
+
* is faster because it avoids allocating a new full-size array and copying all elements.
|
|
33
|
+
*/
|
|
34
|
+
var IN_PLACE_INSERT_THRESHOLD = 64;
|
|
27
35
|
function sortByIndexStringComparator(a, b) {
|
|
28
36
|
if (a[0] < b[0]) {
|
|
29
37
|
return -1;
|
|
@@ -37,29 +45,57 @@ function sortByIndexStringComparator(a, b) {
|
|
|
37
45
|
*/
|
|
38
46
|
function putWriteRowToState(docId, state, stateByIndex, document, docInState) {
|
|
39
47
|
state.documents.set(docId, document);
|
|
40
|
-
|
|
48
|
+
var stateByIndexLength = stateByIndex.length;
|
|
49
|
+
for (var i = 0; i < stateByIndexLength; ++i) {
|
|
41
50
|
var byIndex = stateByIndex[i];
|
|
42
51
|
var docsWithIndex = byIndex.docsWithIndex;
|
|
43
52
|
var getIndexableString = byIndex.getIndexableString;
|
|
44
53
|
var newIndexString = getIndexableString(document);
|
|
45
|
-
var insertPosition = (0, _arrayPushAtSortPosition.pushAtSortPosition)(docsWithIndex, [newIndexString, document, docId], sortByIndexStringComparator, 0);
|
|
46
54
|
|
|
47
55
|
/**
|
|
48
|
-
*
|
|
56
|
+
* @performance
|
|
57
|
+
* When updating a document, first compute whether the index changed.
|
|
58
|
+
* If it did not change, we only need to update the document reference
|
|
59
|
+
* in-place without any splice operations.
|
|
49
60
|
*/
|
|
50
61
|
if (docInState) {
|
|
51
62
|
var previousIndexString = getIndexableString(docInState);
|
|
52
63
|
if (previousIndexString === newIndexString) {
|
|
53
64
|
/**
|
|
54
65
|
* Performance shortcut.
|
|
55
|
-
*
|
|
66
|
+
* Index did not change, so the old entry is at the same position.
|
|
67
|
+
* We can find it by string-specialized binary search and update in-place.
|
|
56
68
|
*/
|
|
57
|
-
var
|
|
58
|
-
if (
|
|
69
|
+
var eqPos = (0, _binarySearchBounds.boundEQByIndexString)(docsWithIndex, previousIndexString);
|
|
70
|
+
if (eqPos !== -1) {
|
|
71
|
+
/**
|
|
72
|
+
* There might be multiple entries with the same index string
|
|
73
|
+
* (e.g. different documents). Search around eqPos for ours.
|
|
74
|
+
*/
|
|
75
|
+
if (docsWithIndex[eqPos][2] === docId) {
|
|
76
|
+
docsWithIndex[eqPos][1] = document;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Check neighbors
|
|
80
|
+
var prev = docsWithIndex[eqPos - 1];
|
|
81
|
+
if (prev && prev[0] === previousIndexString && prev[2] === docId) {
|
|
82
|
+
docsWithIndex[eqPos - 1][1] = document;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
var next = docsWithIndex[eqPos + 1];
|
|
86
|
+
if (next && next[0] === previousIndexString && next[2] === docId) {
|
|
87
|
+
docsWithIndex[eqPos + 1][1] = document;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Fallback: use the old insert+remove approach
|
|
92
|
+
var insertPosition = (0, _arrayPushAtSortPosition.pushAtSortPosition)(docsWithIndex, [newIndexString, document, docId], sortByIndexStringComparator, 0);
|
|
93
|
+
var prevEntry = docsWithIndex[insertPosition - 1];
|
|
94
|
+
if (prevEntry && prevEntry[2] === docId) {
|
|
59
95
|
docsWithIndex.splice(insertPosition - 1, 1);
|
|
60
96
|
} else {
|
|
61
|
-
var
|
|
62
|
-
if (
|
|
97
|
+
var nextEntry = docsWithIndex[insertPosition + 1];
|
|
98
|
+
if (nextEntry[2] === docId) {
|
|
63
99
|
docsWithIndex.splice(insertPosition + 1, 1);
|
|
64
100
|
} else {
|
|
65
101
|
throw (0, _rxError.newRxError)('SNH', {
|
|
@@ -70,26 +106,35 @@ function putWriteRowToState(docId, state, stateByIndex, document, docInState) {
|
|
|
70
106
|
});
|
|
71
107
|
}
|
|
72
108
|
}
|
|
109
|
+
continue;
|
|
73
110
|
} else {
|
|
74
111
|
/**
|
|
75
|
-
* Index changed, we must
|
|
112
|
+
* Index changed, we must remove the old entry and insert the new one.
|
|
76
113
|
*/
|
|
77
|
-
var indexBefore = (0, _binarySearchBounds.
|
|
78
|
-
|
|
114
|
+
var indexBefore = (0, _binarySearchBounds.boundEQByIndexString)(docsWithIndex, previousIndexString);
|
|
115
|
+
if (indexBefore !== -1) {
|
|
116
|
+
docsWithIndex.splice(indexBefore, 1);
|
|
117
|
+
}
|
|
79
118
|
}
|
|
80
119
|
}
|
|
120
|
+
(0, _arrayPushAtSortPosition.pushAtSortPosition)(docsWithIndex, [newIndexString, document, docId], sortByIndexStringComparator, 0);
|
|
81
121
|
}
|
|
82
122
|
}
|
|
83
123
|
|
|
84
124
|
/**
|
|
85
125
|
* @hotPath
|
|
86
126
|
* Efficiently inserts multiple documents into the state at once.
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
127
|
+
*
|
|
128
|
+
* Uses two strategies based on batch size:
|
|
129
|
+
* - For small batches (relative to existing index size), uses in-place
|
|
130
|
+
* binary search + splice per document. This avoids allocating a new
|
|
131
|
+
* full-size array and copying all elements, reducing GC pressure.
|
|
132
|
+
* - For large batches (or empty indexes), pre-computes all index entries,
|
|
133
|
+
* sorts them, and merges into the existing sorted arrays in a single pass.
|
|
90
134
|
*/
|
|
91
135
|
function bulkInsertToState(primaryPath, state, stateByIndex, docs) {
|
|
92
136
|
var docsLength = docs.length;
|
|
137
|
+
var stateByIndexLength = stateByIndex.length;
|
|
93
138
|
|
|
94
139
|
// Extract documents and docIds once, store in Map
|
|
95
140
|
var documents = new Array(docsLength);
|
|
@@ -102,36 +147,74 @@ function bulkInsertToState(primaryPath, state, stateByIndex, docs) {
|
|
|
102
147
|
state.documents.set(docId, doc);
|
|
103
148
|
}
|
|
104
149
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
150
|
+
/**
|
|
151
|
+
* @performance
|
|
152
|
+
* For small batch sizes, use in-place binary search + splice
|
|
153
|
+
* instead of creating a full merged array copy. This is faster
|
|
154
|
+
* for serial inserts and small bulk inserts because it avoids:
|
|
155
|
+
* - Allocating a new array of size n+m
|
|
156
|
+
* - Copying all n existing elements
|
|
157
|
+
* - GC pressure from discarding the old array
|
|
158
|
+
*
|
|
159
|
+
* The threshold is based on when the merge approach becomes more
|
|
160
|
+
* efficient than individual splices.
|
|
161
|
+
*/
|
|
162
|
+
var useInPlaceInsert = docsLength < IN_PLACE_INSERT_THRESHOLD;
|
|
163
|
+
if (useInPlaceInsert) {
|
|
164
|
+
for (var indexI = 0; indexI < stateByIndexLength; ++indexI) {
|
|
165
|
+
var byIndex = stateByIndex[indexI];
|
|
166
|
+
var docsWithIndex = byIndex.docsWithIndex;
|
|
167
|
+
var getIndexableString = byIndex.getIndexableString;
|
|
168
|
+
if (docsWithIndex.length === 0) {
|
|
169
|
+
for (var _i = 0; _i < docsLength; ++_i) {
|
|
170
|
+
var _doc = documents[_i];
|
|
171
|
+
var indexString = getIndexableString(_doc);
|
|
172
|
+
docsWithIndex.push([indexString, _doc, docIds[_i]]);
|
|
173
|
+
}
|
|
174
|
+
docsWithIndex.sort(sortByIndexStringComparator);
|
|
175
|
+
} else {
|
|
176
|
+
for (var _i2 = 0; _i2 < docsLength; ++_i2) {
|
|
177
|
+
var _doc2 = documents[_i2];
|
|
178
|
+
var _indexString = getIndexableString(_doc2);
|
|
179
|
+
var newEntry = [_indexString, _doc2, docIds[_i2]];
|
|
180
|
+
(0, _arrayPushAtSortPosition.pushAtSortPosition)(docsWithIndex, newEntry, sortByIndexStringComparator, 0);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
116
183
|
}
|
|
184
|
+
} else {
|
|
185
|
+
// For each index, batch-compute entries, sort, and merge
|
|
186
|
+
for (var _indexI = 0; _indexI < stateByIndexLength; ++_indexI) {
|
|
187
|
+
var _byIndex = stateByIndex[_indexI];
|
|
188
|
+
var _docsWithIndex = _byIndex.docsWithIndex;
|
|
189
|
+
var _getIndexableString = _byIndex.getIndexableString;
|
|
117
190
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
191
|
+
// Build new entries
|
|
192
|
+
var newEntries = new Array(docsLength);
|
|
193
|
+
for (var _i3 = 0; _i3 < docsLength; ++_i3) {
|
|
194
|
+
var _doc3 = documents[_i3];
|
|
195
|
+
newEntries[_i3] = [_getIndexableString(_doc3), _doc3, docIds[_i3]];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Sort by index string
|
|
199
|
+
newEntries.sort(sortByIndexStringComparator);
|
|
200
|
+
if (_docsWithIndex.length === 0) {
|
|
201
|
+
// Index is empty, just assign sorted entries
|
|
202
|
+
_byIndex.docsWithIndex = newEntries;
|
|
203
|
+
} else {
|
|
204
|
+
// Merge sorted arrays
|
|
205
|
+
_byIndex.docsWithIndex = mergeSortedArrays(_docsWithIndex, newEntries);
|
|
206
|
+
}
|
|
126
207
|
}
|
|
127
208
|
}
|
|
128
209
|
}
|
|
129
210
|
|
|
130
211
|
/**
|
|
131
|
-
* Merges two sorted arrays into a single sorted array.
|
|
212
|
+
* Merges two sorted DocWithIndexString arrays into a single sorted array.
|
|
132
213
|
* Runs in O(n + m) where n and m are the lengths of the input arrays.
|
|
214
|
+
* @performance Comparator is inlined to avoid function call overhead
|
|
215
|
+
* per comparison, which is significant for large arrays.
|
|
133
216
|
*/
|
|
134
|
-
function mergeSortedArrays(a, b
|
|
217
|
+
function mergeSortedArrays(a, b) {
|
|
135
218
|
var aLen = a.length;
|
|
136
219
|
var bLen = b.length;
|
|
137
220
|
var result = new Array(aLen + bLen);
|
|
@@ -139,7 +222,7 @@ function mergeSortedArrays(a, b, comparator) {
|
|
|
139
222
|
var bi = 0;
|
|
140
223
|
var ri = 0;
|
|
141
224
|
while (ai < aLen && bi < bLen) {
|
|
142
|
-
if (
|
|
225
|
+
if (a[ai][0] <= b[bi][0]) {
|
|
143
226
|
result[ri++] = a[ai++];
|
|
144
227
|
} else {
|
|
145
228
|
result[ri++] = b[bi++];
|
|
@@ -156,12 +239,16 @@ function mergeSortedArrays(a, b, comparator) {
|
|
|
156
239
|
function removeDocFromState(primaryPath, schema, state, doc) {
|
|
157
240
|
var docId = doc[primaryPath];
|
|
158
241
|
state.documents.delete(docId);
|
|
159
|
-
|
|
242
|
+
var stateByIndex = state.byIndexArray;
|
|
243
|
+
for (var i = 0; i < stateByIndex.length; ++i) {
|
|
244
|
+
var byIndex = stateByIndex[i];
|
|
160
245
|
var docsWithIndex = byIndex.docsWithIndex;
|
|
161
246
|
var indexString = byIndex.getIndexableString(doc);
|
|
162
|
-
var positionInIndex = (0, _binarySearchBounds.
|
|
163
|
-
|
|
164
|
-
|
|
247
|
+
var positionInIndex = (0, _binarySearchBounds.boundEQByIndexString)(docsWithIndex, indexString);
|
|
248
|
+
if (positionInIndex !== -1) {
|
|
249
|
+
docsWithIndex.splice(positionInIndex, 1);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
165
252
|
}
|
|
166
253
|
function compareDocsWithIndex(a, b) {
|
|
167
254
|
var indexStringA = a[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-helper.js","names":["_arrayPushAtSortPosition","require","_rxError","_binarySearchBounds","getMemoryCollectionKey","databaseName","collectionName","schemaVersion","join","ensureNotRemoved","instance","internals","removed","Error","schema","version","attachmentMapKey","documentId","attachmentId","sortByIndexStringComparator","a","b","putWriteRowToState","docId","state","stateByIndex","document","docInState","documents","set","i","length","byIndex","docsWithIndex","getIndexableString","newIndexString","insertPosition","pushAtSortPosition","previousIndexString","prev","splice","next","newRxError","args","indexBefore","boundEQ","compareDocsWithIndex","bulkInsertToState","primaryPath","docs","docsLength","Array","docIds","doc","indexI","newEntries","sort","mergeSortedArrays","comparator","aLen","bLen","result","ai","bi","ri","removeDocFromState","delete","Object","values","forEach","indexString","positionInIndex","indexStringA","indexStringB"],"sources":["../../../../src/plugins/storage-memory/memory-helper.ts"],"sourcesContent":["import type {\r\n BulkWriteRow,\r\n RxDocumentData,\r\n RxJsonSchema\r\n} from '../../types/index.d.ts';\r\nimport type {\r\n DocWithIndexString,\r\n MemoryStorageInternals,\r\n MemoryStorageInternalsByIndex\r\n} from './memory-types.ts';\r\nimport type { RxStorageInstanceMemory } from './rx-storage-instance-memory.ts';\r\nimport {\r\n pushAtSortPosition\r\n} from 'array-push-at-sort-position';\r\nimport { newRxError } from '../../rx-error.ts';\r\nimport { boundEQ } from './binary-search-bounds.ts';\r\n\r\n\r\nexport function getMemoryCollectionKey(\r\n databaseName: string,\r\n collectionName: string,\r\n schemaVersion: number\r\n): string {\r\n return [\r\n databaseName,\r\n collectionName,\r\n schemaVersion\r\n ].join('--memory--');\r\n}\r\n\r\n\r\nexport function ensureNotRemoved(\r\n instance: RxStorageInstanceMemory<any>\r\n) {\r\n if (instance.internals.removed) {\r\n throw new Error(\r\n 'removed already ' +\r\n instance.databaseName + ' - ' + instance.collectionName +\r\n ' - ' + instance.schema.version\r\n );\r\n }\r\n}\r\n\r\nexport function attachmentMapKey(documentId: string, attachmentId: string): string {\r\n return documentId + '||' + attachmentId;\r\n}\r\n\r\n\r\nfunction sortByIndexStringComparator<RxDocType>(a: DocWithIndexString<RxDocType>, b: DocWithIndexString<RxDocType>) {\r\n if (a[0] < b[0]) {\r\n return -1;\r\n } else {\r\n return 1;\r\n }\r\n}\r\n\r\n\r\n\r\n/**\r\n * @hotPath\r\n */\r\nexport function putWriteRowToState<RxDocType>(\r\n docId: string,\r\n state: MemoryStorageInternals<RxDocType>,\r\n stateByIndex: MemoryStorageInternalsByIndex<RxDocType>[],\r\n document: RxDocumentData<RxDocType>,\r\n docInState?: RxDocumentData<RxDocType>\r\n) {\r\n state.documents.set(docId, document as any);\r\n for (let i = 0; i < stateByIndex.length; ++i) {\r\n const byIndex = stateByIndex[i];\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const getIndexableString = byIndex.getIndexableString;\r\n const newIndexString = getIndexableString(document as any);\r\n const insertPosition = pushAtSortPosition(\r\n docsWithIndex,\r\n [\r\n newIndexString,\r\n document,\r\n docId,\r\n ],\r\n sortByIndexStringComparator,\r\n 0\r\n );\r\n\r\n /**\r\n * Remove previous if it was in the state\r\n */\r\n if (docInState) {\r\n const previousIndexString = getIndexableString(docInState);\r\n if (previousIndexString === newIndexString) {\r\n /**\r\n * Performance shortcut.\r\n * If index was not changed -> The old doc must be before or after the new one.\r\n */\r\n const prev = docsWithIndex[insertPosition - 1];\r\n if (prev && prev[2] === docId) {\r\n docsWithIndex.splice(insertPosition - 1, 1);\r\n } else {\r\n const next = docsWithIndex[insertPosition + 1];\r\n if (next[2] === docId) {\r\n docsWithIndex.splice(insertPosition + 1, 1);\r\n } else {\r\n throw newRxError('SNH', {\r\n document,\r\n args: {\r\n byIndex\r\n }\r\n });\r\n }\r\n }\r\n } else {\r\n /**\r\n * Index changed, we must search for the old one and remove it.\r\n */\r\n const indexBefore = boundEQ(\r\n docsWithIndex,\r\n [\r\n previousIndexString\r\n ] as any,\r\n compareDocsWithIndex\r\n );\r\n docsWithIndex.splice(indexBefore, 1);\r\n }\r\n }\r\n }\r\n}\r\n\r\n\r\n/**\r\n * @hotPath\r\n * Efficiently inserts multiple documents into the state at once.\r\n * Instead of inserting one-by-one with Array.splice() (O(n) per insert),\r\n * this pre-computes all index entries, sorts them, and merges them into\r\n * the existing sorted arrays in a single pass (O(n log n + n + m)).\r\n */\r\nexport function bulkInsertToState<RxDocType>(\r\n primaryPath: string,\r\n state: MemoryStorageInternals<RxDocType>,\r\n stateByIndex: MemoryStorageInternalsByIndex<RxDocType>[],\r\n docs: { document: RxDocumentData<RxDocType> }[]\r\n) {\r\n const docsLength = docs.length;\r\n\r\n // Extract documents and docIds once, store in Map\r\n const documents: RxDocumentData<RxDocType>[] = new Array(docsLength);\r\n const docIds: string[] = new Array(docsLength);\r\n for (let i = 0; i < docsLength; ++i) {\r\n const doc = docs[i].document;\r\n const docId: string = (doc as any)[primaryPath];\r\n documents[i] = doc;\r\n docIds[i] = docId;\r\n state.documents.set(docId, doc as any);\r\n }\r\n\r\n // For each index, batch-compute entries, sort, and merge\r\n for (let indexI = 0; indexI < stateByIndex.length; ++indexI) {\r\n const byIndex = stateByIndex[indexI];\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const getIndexableString = byIndex.getIndexableString;\r\n\r\n // Build new entries\r\n const newEntries: DocWithIndexString<RxDocType>[] = new Array(docsLength);\r\n for (let i = 0; i < docsLength; ++i) {\r\n const doc = documents[i];\r\n newEntries[i] = [\r\n getIndexableString(doc as any),\r\n doc,\r\n docIds[i]\r\n ];\r\n }\r\n\r\n // Sort by index string\r\n newEntries.sort(sortByIndexStringComparator);\r\n\r\n if (docsWithIndex.length === 0) {\r\n // Index is empty, just assign sorted entries\r\n byIndex.docsWithIndex = newEntries;\r\n } else {\r\n // Merge sorted arrays\r\n byIndex.docsWithIndex = mergeSortedArrays(docsWithIndex, newEntries, sortByIndexStringComparator);\r\n }\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Merges two sorted arrays into a single sorted array.\r\n * Runs in O(n + m) where n and m are the lengths of the input arrays.\r\n */\r\nfunction mergeSortedArrays<T>(\r\n a: T[],\r\n b: T[],\r\n comparator: (x: T, y: T) => number\r\n): T[] {\r\n const aLen = a.length;\r\n const bLen = b.length;\r\n const result: T[] = new Array(aLen + bLen);\r\n let ai = 0;\r\n let bi = 0;\r\n let ri = 0;\r\n\r\n while (ai < aLen && bi < bLen) {\r\n if (comparator(a[ai], b[bi]) <= 0) {\r\n result[ri++] = a[ai++];\r\n } else {\r\n result[ri++] = b[bi++];\r\n }\r\n }\r\n\r\n while (ai < aLen) {\r\n result[ri++] = a[ai++];\r\n }\r\n while (bi < bLen) {\r\n result[ri++] = b[bi++];\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function removeDocFromState<RxDocType>(\r\n primaryPath: string,\r\n schema: RxJsonSchema<RxDocumentData<RxDocType>>,\r\n state: MemoryStorageInternals<RxDocType>,\r\n doc: RxDocumentData<RxDocType>\r\n) {\r\n const docId: string = (doc as any)[primaryPath];\r\n state.documents.delete(docId);\r\n\r\n Object.values(state.byIndex).forEach(byIndex => {\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const indexString = byIndex.getIndexableString(doc);\r\n\r\n const positionInIndex = boundEQ(\r\n docsWithIndex,\r\n [\r\n indexString\r\n ] as any,\r\n compareDocsWithIndex\r\n );\r\n docsWithIndex.splice(positionInIndex, 1);\r\n });\r\n}\r\n\r\n\r\nexport function compareDocsWithIndex<RxDocType>(\r\n a: DocWithIndexString<RxDocType>,\r\n b: DocWithIndexString<RxDocType>\r\n): 1 | 0 | -1 {\r\n const indexStringA = a[0];\r\n const indexStringB = b[0];\r\n if (indexStringA < indexStringB) {\r\n return -1;\r\n } else if (indexStringA === indexStringB) {\r\n return 0;\r\n } else {\r\n return 1;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAWA,IAAAA,wBAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAGO,SAASG,sBAAsBA,CAClCC,YAAoB,EACpBC,cAAsB,EACtBC,aAAqB,EACf;EACN,OAAO,CACHF,YAAY,EACZC,cAAc,EACdC,aAAa,CAChB,CAACC,IAAI,CAAC,YAAY,CAAC;AACxB;AAGO,SAASC,gBAAgBA,CAC5BC,QAAsC,EACxC;EACE,IAAIA,QAAQ,CAACC,SAAS,CAACC,OAAO,EAAE;IAC5B,MAAM,IAAIC,KAAK,CACX,kBAAkB,GAClBH,QAAQ,CAACL,YAAY,GAAG,KAAK,GAAGK,QAAQ,CAACJ,cAAc,GACvD,KAAK,GAAGI,QAAQ,CAACI,MAAM,CAACC,OAC5B,CAAC;EACL;AACJ;AAEO,SAASC,gBAAgBA,CAACC,UAAkB,EAAEC,YAAoB,EAAU;EAC/E,OAAOD,UAAU,GAAG,IAAI,GAAGC,YAAY;AAC3C;AAGA,SAASC,2BAA2BA,CAAYC,CAAgC,EAAEC,CAA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C,CAAC,CAAC,CAAC;EACzB,IAAMqD,YAAY,GAAGpD,CAAC,CAAC,CAAC,CAAC;EACzB,IAAImD,YAAY,GAAGC,YAAY,EAAE;IAC7B,OAAO,CAAC,CAAC;EACb,CAAC,MAAM,IAAID,YAAY,KAAKC,YAAY,EAAE;IACtC,OAAO,CAAC;EACZ,CAAC,MAAM;IACH,OAAO,CAAC;EACZ;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"memory-helper.js","names":["_arrayPushAtSortPosition","require","_rxError","_binarySearchBounds","getMemoryCollectionKey","databaseName","collectionName","schemaVersion","join","ensureNotRemoved","instance","internals","removed","Error","schema","version","attachmentMapKey","documentId","attachmentId","IN_PLACE_INSERT_THRESHOLD","sortByIndexStringComparator","a","b","putWriteRowToState","docId","state","stateByIndex","document","docInState","documents","set","stateByIndexLength","length","i","byIndex","docsWithIndex","getIndexableString","newIndexString","previousIndexString","eqPos","boundEQByIndexString","prev","next","insertPosition","pushAtSortPosition","prevEntry","splice","nextEntry","newRxError","args","indexBefore","bulkInsertToState","primaryPath","docs","docsLength","Array","docIds","doc","useInPlaceInsert","indexI","indexString","push","sort","newEntry","newEntries","mergeSortedArrays","aLen","bLen","result","ai","bi","ri","removeDocFromState","delete","byIndexArray","positionInIndex","compareDocsWithIndex","indexStringA","indexStringB"],"sources":["../../../../src/plugins/storage-memory/memory-helper.ts"],"sourcesContent":["import type {\r\n RxDocumentData,\r\n RxJsonSchema\r\n} from '../../types/index.d.ts';\r\nimport type {\r\n DocWithIndexString,\r\n MemoryStorageInternals,\r\n MemoryStorageInternalsByIndex\r\n} from './memory-types.ts';\r\nimport type { RxStorageInstanceMemory } from './rx-storage-instance-memory.ts';\r\nimport {\r\n pushAtSortPosition\r\n} from 'array-push-at-sort-position';\r\nimport { newRxError } from '../../rx-error.ts';\r\nimport { boundEQByIndexString } from './binary-search-bounds.ts';\r\n\r\n\r\nexport function getMemoryCollectionKey(\r\n databaseName: string,\r\n collectionName: string,\r\n schemaVersion: number\r\n): string {\r\n return [\r\n databaseName,\r\n collectionName,\r\n schemaVersion\r\n ].join('--memory--');\r\n}\r\n\r\n\r\nexport function ensureNotRemoved(\r\n instance: RxStorageInstanceMemory<any>\r\n) {\r\n if (instance.internals.removed) {\r\n throw new Error(\r\n 'removed already ' +\r\n instance.databaseName + ' - ' + instance.collectionName +\r\n ' - ' + instance.schema.version\r\n );\r\n }\r\n}\r\n\r\nexport function attachmentMapKey(documentId: string, attachmentId: string): string {\r\n return documentId + '||' + attachmentId;\r\n}\r\n\r\n\r\n/**\r\n * @performance\r\n * Threshold for using in-place splice vs. full merge-sort when inserting\r\n * documents into indexes. Below this batch size, in-place binary search + splice\r\n * is faster because it avoids allocating a new full-size array and copying all elements.\r\n */\r\nconst IN_PLACE_INSERT_THRESHOLD = 64;\r\n\r\nfunction sortByIndexStringComparator<RxDocType>(a: DocWithIndexString<RxDocType>, b: DocWithIndexString<RxDocType>) {\r\n if (a[0] < b[0]) {\r\n return -1;\r\n } else {\r\n return 1;\r\n }\r\n}\r\n\r\n\r\n\r\n/**\r\n * @hotPath\r\n */\r\nexport function putWriteRowToState<RxDocType>(\r\n docId: string,\r\n state: MemoryStorageInternals<RxDocType>,\r\n stateByIndex: MemoryStorageInternalsByIndex<RxDocType>[],\r\n document: RxDocumentData<RxDocType>,\r\n docInState?: RxDocumentData<RxDocType>\r\n) {\r\n state.documents.set(docId, document as any);\r\n const stateByIndexLength = stateByIndex.length;\r\n for (let i = 0; i < stateByIndexLength; ++i) {\r\n const byIndex = stateByIndex[i];\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const getIndexableString = byIndex.getIndexableString;\r\n const newIndexString = getIndexableString(document as any);\r\n\r\n /**\r\n * @performance\r\n * When updating a document, first compute whether the index changed.\r\n * If it did not change, we only need to update the document reference\r\n * in-place without any splice operations.\r\n */\r\n if (docInState) {\r\n const previousIndexString = getIndexableString(docInState);\r\n if (previousIndexString === newIndexString) {\r\n /**\r\n * Performance shortcut.\r\n * Index did not change, so the old entry is at the same position.\r\n * We can find it by string-specialized binary search and update in-place.\r\n */\r\n const eqPos = boundEQByIndexString(\r\n docsWithIndex,\r\n previousIndexString\r\n );\r\n if (eqPos !== -1) {\r\n /**\r\n * There might be multiple entries with the same index string\r\n * (e.g. different documents). Search around eqPos for ours.\r\n */\r\n if (docsWithIndex[eqPos][2] === docId) {\r\n docsWithIndex[eqPos][1] = document;\r\n continue;\r\n }\r\n // Check neighbors\r\n const prev = docsWithIndex[eqPos - 1];\r\n if (prev && prev[0] === previousIndexString && prev[2] === docId) {\r\n docsWithIndex[eqPos - 1][1] = document;\r\n continue;\r\n }\r\n const next = docsWithIndex[eqPos + 1];\r\n if (next && next[0] === previousIndexString && next[2] === docId) {\r\n docsWithIndex[eqPos + 1][1] = document;\r\n continue;\r\n }\r\n }\r\n // Fallback: use the old insert+remove approach\r\n const insertPosition = pushAtSortPosition(\r\n docsWithIndex,\r\n [newIndexString, document, docId],\r\n sortByIndexStringComparator,\r\n 0\r\n );\r\n const prevEntry = docsWithIndex[insertPosition - 1];\r\n if (prevEntry && prevEntry[2] === docId) {\r\n docsWithIndex.splice(insertPosition - 1, 1);\r\n } else {\r\n const nextEntry = docsWithIndex[insertPosition + 1];\r\n if (nextEntry[2] === docId) {\r\n docsWithIndex.splice(insertPosition + 1, 1);\r\n } else {\r\n throw newRxError('SNH', {\r\n document,\r\n args: {\r\n byIndex\r\n }\r\n });\r\n }\r\n }\r\n continue;\r\n } else {\r\n /**\r\n * Index changed, we must remove the old entry and insert the new one.\r\n */\r\n const indexBefore = boundEQByIndexString(\r\n docsWithIndex,\r\n previousIndexString\r\n );\r\n if (indexBefore !== -1) {\r\n docsWithIndex.splice(indexBefore, 1);\r\n }\r\n }\r\n }\r\n\r\n pushAtSortPosition(\r\n docsWithIndex,\r\n [newIndexString, document, docId],\r\n sortByIndexStringComparator,\r\n 0\r\n );\r\n }\r\n}\r\n\r\n\r\n/**\r\n * @hotPath\r\n * Efficiently inserts multiple documents into the state at once.\r\n *\r\n * Uses two strategies based on batch size:\r\n * - For small batches (relative to existing index size), uses in-place\r\n * binary search + splice per document. This avoids allocating a new\r\n * full-size array and copying all elements, reducing GC pressure.\r\n * - For large batches (or empty indexes), pre-computes all index entries,\r\n * sorts them, and merges into the existing sorted arrays in a single pass.\r\n */\r\nexport function bulkInsertToState<RxDocType>(\r\n primaryPath: string,\r\n state: MemoryStorageInternals<RxDocType>,\r\n stateByIndex: MemoryStorageInternalsByIndex<RxDocType>[],\r\n docs: { document: RxDocumentData<RxDocType> }[]\r\n) {\r\n const docsLength = docs.length;\r\n const stateByIndexLength = stateByIndex.length;\r\n\r\n // Extract documents and docIds once, store in Map\r\n const documents: RxDocumentData<RxDocType>[] = new Array(docsLength);\r\n const docIds: string[] = new Array(docsLength);\r\n for (let i = 0; i < docsLength; ++i) {\r\n const doc = docs[i].document;\r\n const docId: string = (doc as any)[primaryPath];\r\n documents[i] = doc;\r\n docIds[i] = docId;\r\n state.documents.set(docId, doc as any);\r\n }\r\n\r\n /**\r\n * @performance\r\n * For small batch sizes, use in-place binary search + splice\r\n * instead of creating a full merged array copy. This is faster\r\n * for serial inserts and small bulk inserts because it avoids:\r\n * - Allocating a new array of size n+m\r\n * - Copying all n existing elements\r\n * - GC pressure from discarding the old array\r\n *\r\n * The threshold is based on when the merge approach becomes more\r\n * efficient than individual splices.\r\n */\r\n const useInPlaceInsert = docsLength < IN_PLACE_INSERT_THRESHOLD;\r\n\r\n if (useInPlaceInsert) {\r\n for (let indexI = 0; indexI < stateByIndexLength; ++indexI) {\r\n const byIndex = stateByIndex[indexI];\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const getIndexableString = byIndex.getIndexableString;\r\n\r\n if (docsWithIndex.length === 0) {\r\n for (let i = 0; i < docsLength; ++i) {\r\n const doc = documents[i];\r\n const indexString = getIndexableString(doc as any);\r\n docsWithIndex.push([indexString, doc, docIds[i]]);\r\n }\r\n docsWithIndex.sort(sortByIndexStringComparator);\r\n } else {\r\n for (let i = 0; i < docsLength; ++i) {\r\n const doc = documents[i];\r\n const indexString = getIndexableString(doc as any);\r\n const newEntry: DocWithIndexString<RxDocType> = [indexString, doc, docIds[i]];\r\n pushAtSortPosition(\r\n docsWithIndex,\r\n newEntry,\r\n sortByIndexStringComparator,\r\n 0\r\n );\r\n }\r\n }\r\n }\r\n } else {\r\n // For each index, batch-compute entries, sort, and merge\r\n for (let indexI = 0; indexI < stateByIndexLength; ++indexI) {\r\n const byIndex = stateByIndex[indexI];\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const getIndexableString = byIndex.getIndexableString;\r\n\r\n // Build new entries\r\n const newEntries: DocWithIndexString<RxDocType>[] = new Array(docsLength);\r\n for (let i = 0; i < docsLength; ++i) {\r\n const doc = documents[i];\r\n newEntries[i] = [\r\n getIndexableString(doc as any),\r\n doc,\r\n docIds[i]\r\n ];\r\n }\r\n\r\n // Sort by index string\r\n newEntries.sort(sortByIndexStringComparator);\r\n\r\n if (docsWithIndex.length === 0) {\r\n // Index is empty, just assign sorted entries\r\n byIndex.docsWithIndex = newEntries;\r\n } else {\r\n // Merge sorted arrays\r\n byIndex.docsWithIndex = mergeSortedArrays(docsWithIndex, newEntries);\r\n }\r\n }\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Merges two sorted DocWithIndexString arrays into a single sorted array.\r\n * Runs in O(n + m) where n and m are the lengths of the input arrays.\r\n * @performance Comparator is inlined to avoid function call overhead\r\n * per comparison, which is significant for large arrays.\r\n */\r\nfunction mergeSortedArrays<RxDocType>(\r\n a: DocWithIndexString<RxDocType>[],\r\n b: DocWithIndexString<RxDocType>[]\r\n): DocWithIndexString<RxDocType>[] {\r\n const aLen = a.length;\r\n const bLen = b.length;\r\n const result: DocWithIndexString<RxDocType>[] = new Array(aLen + bLen);\r\n let ai = 0;\r\n let bi = 0;\r\n let ri = 0;\r\n\r\n while (ai < aLen && bi < bLen) {\r\n if (a[ai][0] <= b[bi][0]) {\r\n result[ri++] = a[ai++];\r\n } else {\r\n result[ri++] = b[bi++];\r\n }\r\n }\r\n\r\n while (ai < aLen) {\r\n result[ri++] = a[ai++];\r\n }\r\n while (bi < bLen) {\r\n result[ri++] = b[bi++];\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function removeDocFromState<RxDocType>(\r\n primaryPath: string,\r\n schema: RxJsonSchema<RxDocumentData<RxDocType>>,\r\n state: MemoryStorageInternals<RxDocType>,\r\n doc: RxDocumentData<RxDocType>\r\n) {\r\n const docId: string = (doc as any)[primaryPath];\r\n state.documents.delete(docId);\r\n\r\n const stateByIndex = state.byIndexArray;\r\n for (let i = 0; i < stateByIndex.length; ++i) {\r\n const byIndex = stateByIndex[i];\r\n const docsWithIndex = byIndex.docsWithIndex;\r\n const indexString = byIndex.getIndexableString(doc);\r\n\r\n const positionInIndex = boundEQByIndexString(\r\n docsWithIndex,\r\n indexString\r\n );\r\n if (positionInIndex !== -1) {\r\n docsWithIndex.splice(positionInIndex, 1);\r\n }\r\n }\r\n}\r\n\r\n\r\nexport function compareDocsWithIndex<RxDocType>(\r\n a: DocWithIndexString<RxDocType>,\r\n b: DocWithIndexString<RxDocType>\r\n): 1 | 0 | -1 {\r\n const indexStringA = a[0];\r\n const indexStringB = b[0];\r\n if (indexStringA < indexStringB) {\r\n return -1;\r\n } else if (indexStringA === indexStringB) {\r\n return 0;\r\n } else {\r\n return 1;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAUA,IAAAA,wBAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAGO,SAASG,sBAAsBA,CAClCC,YAAoB,EACpBC,cAAsB,EACtBC,aAAqB,EACf;EACN,OAAO,CACHF,YAAY,EACZC,cAAc,EACdC,aAAa,CAChB,CAACC,IAAI,CAAC,YAAY,CAAC;AACxB;AAGO,SAASC,gBAAgBA,CAC5BC,QAAsC,EACxC;EACE,IAAIA,QAAQ,CAACC,SAAS,CAACC,OAAO,EAA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AAa;IAC3C,IAAMyB,WAAW,GAAG1B,OAAO,CAACE,kBAAkB,CAACqB,GAAG,CAAC;IAEnD,IAAMkB,eAAe,GAAG,IAAAnC,wCAAoB,EACxCL,aAAa,EACbyB,WACJ,CAAC;IACD,IAAIe,eAAe,KAAK,CAAC,CAAC,EAAE;MACxBxC,aAAa,CAACW,MAAM,CAAC6B,eAAe,EAAE,CAAC,CAAC;IAC5C;EACJ;AACJ;AAGO,SAASC,oBAAoBA,CAChCvD,CAAgC,EAChCC,CAAgC,EACtB;EACV,IAAMuD,YAAY,GAAGxD,CAAC,CAAC,CAAC,CAAC;EACzB,IAAMyD,YAAY,GAAGxD,CAAC,CAAC,CAAC,CAAC;EACzB,IAAIuD,YAAY,GAAGC,YAAY,EAAE;IAC7B,OAAO,CAAC,CAAC;EACb,CAAC,MAAM,IAAID,YAAY,KAAKC,YAAY,EAAE;IACtC,OAAO,CAAC;EACZ,CAAC,MAAM;IACH,OAAO,CAAC;EACZ;AACJ","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ function addIndexesToInternalsState(state, schema) {
|
|
|
21
21
|
getIndexableString: (0, _customIndex.getIndexableStringMonad)(schema, indexAr)
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
|
+
state.byIndexArray = Object.values(state.byIndex);
|
|
24
25
|
}
|
|
25
26
|
function getMemoryIndexName(index) {
|
|
26
27
|
return index.join(',');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-indexes.js","names":["_customIndex","require","_rxSchemaHelper","_index","addIndexesToInternalsState","state","schema","primaryPath","getPrimaryFieldOfPrimaryKey","primaryKey","useIndexes","indexes","map","row","toArray","push","forEach","indexAr","byIndex","getMemoryIndexName","index","docsWithIndex","getIndexableString","getIndexableStringMonad","join"],"sources":["../../../../src/plugins/storage-memory/memory-indexes.ts"],"sourcesContent":["import { getIndexableStringMonad } from '../../custom-index.ts';\r\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\r\nimport type { RxDocumentData, RxJsonSchema } from '../../types/index.d.ts';\r\nimport { toArray } from '../../plugins/utils/index.ts';\r\nimport type { MemoryStorageInternals } from './memory-types.ts';\r\n\r\nexport function addIndexesToInternalsState<RxDocType>(\r\n state: MemoryStorageInternals<RxDocType>,\r\n schema: RxJsonSchema<RxDocumentData<RxDocType>>\r\n) {\r\n const primaryPath = getPrimaryFieldOfPrimaryKey(schema.primaryKey);\r\n const useIndexes: string[][] = !schema.indexes ? [] : schema.indexes.map(row => toArray(row)) as any;\r\n\r\n // we need this index for running cleanup()\r\n useIndexes.push([\r\n '_deleted',\r\n '_meta.lwt',\r\n primaryPath\r\n ]);\r\n\r\n\r\n useIndexes.forEach(indexAr => {\r\n state.byIndex[getMemoryIndexName(indexAr)] = {\r\n index: indexAr,\r\n docsWithIndex: [],\r\n getIndexableString: getIndexableStringMonad(schema, indexAr)\r\n };\r\n });\r\n}\r\n\r\n\r\nexport function getMemoryIndexName(index: string[]): string {\r\n return index.join(',');\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAGO,SAASG,0BAA0BA,CACtCC,KAAwC,EACxCC,MAA+C,EACjD;EACE,IAAMC,WAAW,GAAG,IAAAC,2CAA2B,EAACF,MAAM,CAACG,UAAU,CAAC;EAClE,IAAMC,UAAsB,GAAG,CAACJ,MAAM,CAACK,OAAO,GAAG,EAAE,GAAGL,MAAM,CAACK,OAAO,CAACC,GAAG,CAACC,GAAG,IAAI,IAAAC,cAAO,EAACD,GAAG,CAAC,CAAQ;;EAEpG;EACAH,UAAU,CAACK,IAAI,CAAC,CACZ,UAAU,EACV,WAAW,EACXR,WAAW,CACd,CAAC;EAGFG,UAAU,CAACM,OAAO,CAACC,OAAO,IAAI;IAC1BZ,KAAK,CAACa,OAAO,CAACC,kBAAkB,CAACF,OAAO,CAAC,CAAC,GAAG;MACzCG,KAAK,EAAEH,OAAO;MACdI,aAAa,EAAE,EAAE;MACjBC,kBAAkB,EAAE,IAAAC,oCAAuB,EAACjB,MAAM,EAAEW,OAAO;IAC/D,CAAC;EACL,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-indexes.js","names":["_customIndex","require","_rxSchemaHelper","_index","addIndexesToInternalsState","state","schema","primaryPath","getPrimaryFieldOfPrimaryKey","primaryKey","useIndexes","indexes","map","row","toArray","push","forEach","indexAr","byIndex","getMemoryIndexName","index","docsWithIndex","getIndexableString","getIndexableStringMonad","byIndexArray","Object","values","join"],"sources":["../../../../src/plugins/storage-memory/memory-indexes.ts"],"sourcesContent":["import { getIndexableStringMonad } from '../../custom-index.ts';\r\nimport { getPrimaryFieldOfPrimaryKey } from '../../rx-schema-helper.ts';\r\nimport type { RxDocumentData, RxJsonSchema } from '../../types/index.d.ts';\r\nimport { toArray } from '../../plugins/utils/index.ts';\r\nimport type { MemoryStorageInternals } from './memory-types.ts';\r\n\r\nexport function addIndexesToInternalsState<RxDocType>(\r\n state: MemoryStorageInternals<RxDocType>,\r\n schema: RxJsonSchema<RxDocumentData<RxDocType>>\r\n) {\r\n const primaryPath = getPrimaryFieldOfPrimaryKey(schema.primaryKey);\r\n const useIndexes: string[][] = !schema.indexes ? [] : schema.indexes.map(row => toArray(row)) as any;\r\n\r\n // we need this index for running cleanup()\r\n useIndexes.push([\r\n '_deleted',\r\n '_meta.lwt',\r\n primaryPath\r\n ]);\r\n\r\n\r\n useIndexes.forEach(indexAr => {\r\n state.byIndex[getMemoryIndexName(indexAr)] = {\r\n index: indexAr,\r\n docsWithIndex: [],\r\n getIndexableString: getIndexableStringMonad(schema, indexAr)\r\n };\r\n });\r\n state.byIndexArray = Object.values(state.byIndex);\r\n}\r\n\r\n\r\nexport function getMemoryIndexName(index: string[]): string {\r\n return index.join(',');\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAGO,SAASG,0BAA0BA,CACtCC,KAAwC,EACxCC,MAA+C,EACjD;EACE,IAAMC,WAAW,GAAG,IAAAC,2CAA2B,EAACF,MAAM,CAACG,UAAU,CAAC;EAClE,IAAMC,UAAsB,GAAG,CAACJ,MAAM,CAACK,OAAO,GAAG,EAAE,GAAGL,MAAM,CAACK,OAAO,CAACC,GAAG,CAACC,GAAG,IAAI,IAAAC,cAAO,EAACD,GAAG,CAAC,CAAQ;;EAEpG;EACAH,UAAU,CAACK,IAAI,CAAC,CACZ,UAAU,EACV,WAAW,EACXR,WAAW,CACd,CAAC;EAGFG,UAAU,CAACM,OAAO,CAACC,OAAO,IAAI;IAC1BZ,KAAK,CAACa,OAAO,CAACC,kBAAkB,CAACF,OAAO,CAAC,CAAC,GAAG;MACzCG,KAAK,EAAEH,OAAO;MACdI,aAAa,EAAE,EAAE;MACjBC,kBAAkB,EAAE,IAAAC,oCAAuB,EAACjB,MAAM,EAAEW,OAAO;IAC/D,CAAC;EACL,CAAC,CAAC;EACFZ,KAAK,CAACmB,YAAY,GAAGC,MAAM,CAACC,MAAM,CAACrB,KAAK,CAACa,OAAO,CAAC;AACrD;AAGO,SAASC,kBAAkBA,CAACC,KAAe,EAAU;EACxD,OAAOA,KAAK,CAACO,IAAI,CAAC,GAAG,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-types.js","names":[],"sources":["../../../../src/plugins/storage-memory/memory-types.ts"],"sourcesContent":["import { Subject } from 'rxjs';\r\nimport type {\r\n CategorizeBulkWriteRowsOutput,\r\n EventBulk,\r\n RxAttachmentWriteData,\r\n RxDocumentData,\r\n RxJsonSchema,\r\n RxStorage,\r\n RxStorageChangeEvent,\r\n RxStorageDefaultCheckpoint\r\n} from '../../types/index.d.ts';\r\n\r\nexport type RxStorageMemorySettings = {};\r\nexport type RxStorageMemoryInstanceCreationOptions = {};\r\nexport type RxStorageMemory = RxStorage<MemoryStorageInternals<any>, RxStorageMemoryInstanceCreationOptions> & {\r\n /**\r\n * State by collectionKey\r\n */\r\n collectionStates: Map<string, MemoryStorageInternals<any>>;\r\n};\r\n\r\nexport type MemoryStorageInternalsByIndex<RxDocType> = {\r\n index: string[];\r\n docsWithIndex: DocWithIndexString<RxDocType>[];\r\n getIndexableString: (docData: RxDocumentData<RxDocType>) => string;\r\n};\r\n\r\n/**\r\n * The internals are shared between multiple storage instances\r\n * that have been created with the same [databaseName+collectionName] combination.\r\n */\r\nexport type MemoryStorageInternals<RxDocType> = {\r\n // used to debug stuff and identify instances\r\n id: string;\r\n\r\n /**\r\n * Schema of the first instance created with the given settings.\r\n * Used to ensure that the same storage is not re-created with\r\n * a different schema.\r\n */\r\n schema: RxJsonSchema<RxDocumentData<RxDocType>>;\r\n\r\n /**\r\n * We reuse the memory state when multiple instances\r\n * are created with the same params.\r\n * If refCount becomes 0, we can delete the state.\r\n */\r\n refCount: number;\r\n /**\r\n * If this becomes true,\r\n * it means that an instance has called remove()\r\n * so all other instances should also not work anymore.\r\n */\r\n removed: boolean;\r\n documents: Map<string, RxDocumentData<RxDocType>>;\r\n /**\r\n * Attachments data, indexed by a combined string\r\n * consisting of [documentId + '||' + attachmentId]\r\n */\r\n attachments: Map<string, {\r\n writeData: RxAttachmentWriteData;\r\n digest: string;\r\n }>;\r\n byIndex: {\r\n /**\r\n * Because RxDB requires a deterministic sorting\r\n * on all indexes, we can be sure that the composed index key\r\n * of each document is unique, because it contains the primaryKey\r\n * as last index part.\r\n * So we do not have to store the index-position when we want to do fast\r\n * writes. Instead we can do a binary search over the existing array\r\n * because RxDB also knows the previous state of the document when we do a bulkWrite().\r\n */\r\n [indexName: string]: MemoryStorageInternalsByIndex<RxDocType>;\r\n };\r\n\r\n /**\r\n * We need these to do lazy writes.\r\n */\r\n ensurePersistenceTask?: CategorizeBulkWriteRowsOutput<RxDocType>;\r\n ensurePersistenceIdlePromise?: Promise<void>;\r\n\r\n changes$: Subject<EventBulk<RxStorageChangeEvent<RxDocumentData<RxDocType>>, RxStorageDefaultCheckpoint>>;\r\n};\r\n\r\nexport type DocWithIndexString<RxDocType> = [\r\n string, // indexString, must be first because often we only need that one.\r\n RxDocumentData<RxDocType>, // document\r\n string, // id\r\n];\r\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"memory-types.js","names":[],"sources":["../../../../src/plugins/storage-memory/memory-types.ts"],"sourcesContent":["import { Subject } from 'rxjs';\r\nimport type {\r\n CategorizeBulkWriteRowsOutput,\r\n EventBulk,\r\n RxAttachmentWriteData,\r\n RxDocumentData,\r\n RxJsonSchema,\r\n RxStorage,\r\n RxStorageChangeEvent,\r\n RxStorageDefaultCheckpoint\r\n} from '../../types/index.d.ts';\r\n\r\nexport type RxStorageMemorySettings = {};\r\nexport type RxStorageMemoryInstanceCreationOptions = {};\r\nexport type RxStorageMemory = RxStorage<MemoryStorageInternals<any>, RxStorageMemoryInstanceCreationOptions> & {\r\n /**\r\n * State by collectionKey\r\n */\r\n collectionStates: Map<string, MemoryStorageInternals<any>>;\r\n};\r\n\r\nexport type MemoryStorageInternalsByIndex<RxDocType> = {\r\n index: string[];\r\n docsWithIndex: DocWithIndexString<RxDocType>[];\r\n getIndexableString: (docData: RxDocumentData<RxDocType>) => string;\r\n};\r\n\r\n/**\r\n * The internals are shared between multiple storage instances\r\n * that have been created with the same [databaseName+collectionName] combination.\r\n */\r\nexport type MemoryStorageInternals<RxDocType> = {\r\n // used to debug stuff and identify instances\r\n id: string;\r\n\r\n /**\r\n * Schema of the first instance created with the given settings.\r\n * Used to ensure that the same storage is not re-created with\r\n * a different schema.\r\n */\r\n schema: RxJsonSchema<RxDocumentData<RxDocType>>;\r\n\r\n /**\r\n * We reuse the memory state when multiple instances\r\n * are created with the same params.\r\n * If refCount becomes 0, we can delete the state.\r\n */\r\n refCount: number;\r\n /**\r\n * If this becomes true,\r\n * it means that an instance has called remove()\r\n * so all other instances should also not work anymore.\r\n */\r\n removed: boolean;\r\n documents: Map<string, RxDocumentData<RxDocType>>;\r\n /**\r\n * Attachments data, indexed by a combined string\r\n * consisting of [documentId + '||' + attachmentId]\r\n */\r\n attachments: Map<string, {\r\n writeData: RxAttachmentWriteData;\r\n digest: string;\r\n }>;\r\n byIndex: {\r\n /**\r\n * Because RxDB requires a deterministic sorting\r\n * on all indexes, we can be sure that the composed index key\r\n * of each document is unique, because it contains the primaryKey\r\n * as last index part.\r\n * So we do not have to store the index-position when we want to do fast\r\n * writes. Instead we can do a binary search over the existing array\r\n * because RxDB also knows the previous state of the document when we do a bulkWrite().\r\n */\r\n [indexName: string]: MemoryStorageInternalsByIndex<RxDocType>;\r\n };\r\n /**\r\n * Cached array of all MemoryStorageInternalsByIndex values.\r\n * Avoids calling Object.values(byIndex) on every write operation.\r\n */\r\n byIndexArray: MemoryStorageInternalsByIndex<RxDocType>[];\r\n\r\n /**\r\n * We need these to do lazy writes.\r\n */\r\n ensurePersistenceTask?: CategorizeBulkWriteRowsOutput<RxDocType>;\r\n ensurePersistenceIdlePromise?: Promise<void>;\r\n\r\n changes$: Subject<EventBulk<RxStorageChangeEvent<RxDocumentData<RxDocType>>, RxStorageDefaultCheckpoint>>;\r\n};\r\n\r\nexport type DocWithIndexString<RxDocType> = [\r\n string, // indexString, must be first because often we only need that one.\r\n RxDocumentData<RxDocType>, // document\r\n string, // id\r\n];\r\n"],"mappings":"","ignoreList":[]}
|