@livestore/livestore 0.0.12 → 0.0.15
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/README.md +7 -7
- package/dist/.tsbuildinfo +1 -0
- package/dist/QueryCache.d.ts +20 -0
- package/dist/QueryCache.d.ts.map +1 -0
- package/dist/QueryCache.js +71 -0
- package/dist/QueryCache.js.map +1 -0
- package/dist/__tests__/react/fixture.d.ts +25 -0
- package/dist/__tests__/react/fixture.d.ts.map +1 -0
- package/dist/__tests__/react/fixture.js +60 -0
- package/dist/__tests__/react/fixture.js.map +1 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.d.ts +2 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.d.ts.map +1 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.js +78 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.js.map +1 -0
- package/dist/__tests__/reactive.test.d.ts +2 -0
- package/dist/__tests__/reactive.test.d.ts.map +1 -0
- package/dist/__tests__/reactive.test.js +197 -0
- package/dist/__tests__/reactive.test.js.map +1 -0
- package/dist/bounded-collections.d.ts +34 -0
- package/dist/bounded-collections.d.ts.map +1 -0
- package/dist/bounded-collections.js +103 -0
- package/dist/bounded-collections.js.map +1 -0
- package/dist/componentKey.d.ts +20 -0
- package/dist/componentKey.d.ts.map +1 -0
- package/dist/componentKey.js +3 -0
- package/dist/componentKey.js.map +1 -0
- package/dist/effect/LiveStore.d.ts +36 -0
- package/dist/effect/LiveStore.d.ts.map +1 -0
- package/dist/effect/LiveStore.js +41 -0
- package/dist/effect/LiveStore.js.map +1 -0
- package/dist/effect/index.d.ts +2 -0
- package/dist/effect/index.d.ts.map +1 -0
- package/dist/effect/index.js +2 -0
- package/dist/effect/index.js.map +1 -0
- package/dist/events.d.ts +7 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/inMemoryDatabase.d.ts +56 -0
- package/dist/inMemoryDatabase.d.ts.map +1 -0
- package/dist/inMemoryDatabase.js +223 -0
- package/dist/inMemoryDatabase.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations.d.ts +16 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +67 -0
- package/dist/migrations.js.map +1 -0
- package/dist/otel.d.ts +4 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +6 -0
- package/dist/otel.js.map +1 -0
- package/dist/react/LiveStoreContext.d.ts +11 -0
- package/dist/react/LiveStoreContext.d.ts.map +1 -0
- package/dist/react/LiveStoreContext.js +10 -0
- package/dist/react/LiveStoreContext.js.map +1 -0
- package/dist/react/LiveStoreProvider.d.ts +20 -0
- package/dist/react/LiveStoreProvider.d.ts.map +1 -0
- package/dist/react/LiveStoreProvider.js +52 -0
- package/dist/react/LiveStoreProvider.js.map +1 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +6 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useGraphQL.d.ts +13 -0
- package/dist/react/useGraphQL.d.ts.map +1 -0
- package/dist/react/useGraphQL.js +85 -0
- package/dist/react/useGraphQL.js.map +1 -0
- package/dist/react/useLiveStoreComponent.d.ts +75 -0
- package/dist/react/useLiveStoreComponent.d.ts.map +1 -0
- package/dist/react/useLiveStoreComponent.js +317 -0
- package/dist/react/useLiveStoreComponent.js.map +1 -0
- package/dist/react/useQuery.d.ts +3 -0
- package/dist/react/useQuery.d.ts.map +1 -0
- package/dist/react/useQuery.js +38 -0
- package/dist/react/useQuery.js.map +1 -0
- package/dist/react/utils/useStateRefWithReactiveInput.d.ts +13 -0
- package/dist/react/utils/useStateRefWithReactiveInput.d.ts.map +1 -0
- package/dist/react/utils/useStateRefWithReactiveInput.js +38 -0
- package/dist/react/utils/useStateRefWithReactiveInput.js.map +1 -0
- package/dist/reactive.d.ts +140 -0
- package/dist/reactive.d.ts.map +1 -0
- package/dist/reactive.js +302 -0
- package/dist/reactive.js.map +1 -0
- package/dist/reactiveQueries/base-class.d.ts +27 -0
- package/dist/reactiveQueries/base-class.d.ts.map +1 -0
- package/dist/reactiveQueries/base-class.js +23 -0
- package/dist/reactiveQueries/base-class.js.map +1 -0
- package/dist/reactiveQueries/graphql.d.ts +25 -0
- package/dist/reactiveQueries/graphql.d.ts.map +1 -0
- package/dist/reactiveQueries/graphql.js +18 -0
- package/dist/reactiveQueries/graphql.js.map +1 -0
- package/dist/reactiveQueries/js.d.ts +19 -0
- package/dist/reactiveQueries/js.d.ts.map +1 -0
- package/dist/reactiveQueries/js.js +13 -0
- package/dist/reactiveQueries/js.js.map +1 -0
- package/dist/reactiveQueries/sql.d.ts +31 -0
- package/dist/reactiveQueries/sql.d.ts.map +1 -0
- package/dist/reactiveQueries/sql.js +32 -0
- package/dist/reactiveQueries/sql.js.map +1 -0
- package/dist/schema.d.ts +81 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +46 -0
- package/dist/schema.js.map +1 -0
- package/dist/storage/in-memory/index.d.ts +15 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -0
- package/dist/storage/in-memory/index.js +14 -0
- package/dist/storage/in-memory/index.js.map +1 -0
- package/dist/storage/index.d.ts +14 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +9 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/tauri/index.d.ts +19 -0
- package/dist/storage/tauri/index.d.ts.map +1 -0
- package/dist/storage/tauri/index.js +38 -0
- package/dist/storage/tauri/index.js.map +1 -0
- package/dist/storage/utils/idb.d.ts +10 -0
- package/dist/storage/utils/idb.d.ts.map +1 -0
- package/dist/storage/utils/idb.js +58 -0
- package/dist/storage/utils/idb.js.map +1 -0
- package/dist/storage/web-worker/index.d.ts +27 -0
- package/dist/storage/web-worker/index.d.ts.map +1 -0
- package/dist/storage/web-worker/index.js +74 -0
- package/dist/storage/web-worker/index.js.map +1 -0
- package/dist/storage/web-worker/worker.d.ts +13 -0
- package/dist/storage/web-worker/worker.d.ts.map +1 -0
- package/dist/storage/web-worker/worker.js +110 -0
- package/dist/storage/web-worker/worker.js.map +1 -0
- package/dist/store.d.ts +199 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +603 -0
- package/dist/store.js.map +1 -0
- package/dist/util.d.ts +28 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +55 -0
- package/dist/util.js.map +1 -0
- package/package.json +46 -19
- package/src/__tests__/react/fixture.tsx +23 -32
- package/src/__tests__/reactive.test.ts +3 -4
- package/src/effect/LiveStore.ts +22 -31
- package/src/events.ts +1 -1
- package/src/inMemoryDatabase.ts +115 -140
- package/src/index.ts +20 -20
- package/src/migrations.ts +119 -0
- package/src/otel.ts +0 -11
- package/src/react/LiveStoreProvider.tsx +24 -23
- package/src/react/index.ts +10 -1
- package/src/react/useGraphQL.ts +28 -2
- package/src/react/useLiveStoreComponent.ts +134 -50
- package/src/react/useQuery.ts +56 -0
- package/src/reactive.ts +6 -4
- package/src/reactiveQueries/base-class.ts +9 -3
- package/src/reactiveQueries/graphql.ts +4 -4
- package/src/reactiveQueries/js.ts +2 -2
- package/src/reactiveQueries/sql.ts +6 -6
- package/src/schema.ts +69 -145
- package/src/storage/in-memory/index.ts +21 -0
- package/src/storage/index.ts +27 -0
- package/src/{backends/tauri.ts → storage/tauri/index.ts} +14 -28
- package/src/storage/web-worker/index.ts +116 -0
- package/src/{backends/web-worker.ts → storage/web-worker/worker.ts} +17 -52
- package/src/store.ts +171 -98
- package/src/util.ts +13 -3
- package/tsconfig.json +1 -3
- package/src/backends/base.ts +0 -67
- package/src/backends/index.ts +0 -98
- package/src/backends/noop.ts +0 -32
- package/src/backends/web-in-memory.ts +0 -65
- package/src/backends/web.ts +0 -97
- package/src/react/useGlobalQuery.ts +0 -40
- /package/src/{backends → storage}/utils/idb.ts +0 -0
package/dist/schema.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { mapObjectValues } from '@livestore/utils';
|
|
2
|
+
import { SqliteDsl } from 'effect-db-schema';
|
|
3
|
+
import { DbSchema } from './index.js';
|
|
4
|
+
// A global variable representing component state tables we should create in the database
|
|
5
|
+
export const componentStateTables = {};
|
|
6
|
+
export const makeSchema = (schema) => ({
|
|
7
|
+
tables: { ...mapObjectValues(schema.tables, (_tableName, table) => table.ast), ...systemTables },
|
|
8
|
+
materializedViews: schema.materializedViews ?? {},
|
|
9
|
+
actions: schema.actions,
|
|
10
|
+
});
|
|
11
|
+
// TODO get rid of "side effect" in this function (via explicit register fn)
|
|
12
|
+
export const defineComponentStateSchema = (
|
|
13
|
+
// TODO get rid of the `name` param here and use the `componentKey` name instead
|
|
14
|
+
name, columns) => {
|
|
15
|
+
const tablePath = `components__${name}`;
|
|
16
|
+
if (Object.keys(componentStateTables).includes(tablePath)) {
|
|
17
|
+
// throw new Error(`Can't register duplicate component: ${name}`)
|
|
18
|
+
console.error(`Can't register duplicate component: ${tablePath}`);
|
|
19
|
+
}
|
|
20
|
+
const schemaWithId = columns;
|
|
21
|
+
schemaWithId.id = DbSchema.text({ primaryKey: true });
|
|
22
|
+
const tableDef = SqliteDsl.table(tablePath, schemaWithId, []);
|
|
23
|
+
// TODO move into register fn
|
|
24
|
+
componentStateTables[tablePath] = tableDef.ast;
|
|
25
|
+
return tableDef;
|
|
26
|
+
};
|
|
27
|
+
export const SCHEMA_META_TABLE = '__livestore_schema';
|
|
28
|
+
const schemaMetaTable = SqliteDsl.table(SCHEMA_META_TABLE, {
|
|
29
|
+
tableName: SqliteDsl.text({ primaryKey: true }),
|
|
30
|
+
schemaHash: SqliteDsl.integer({ nullable: false }),
|
|
31
|
+
/** ISO date format */
|
|
32
|
+
updatedAt: SqliteDsl.text({ nullable: false }),
|
|
33
|
+
});
|
|
34
|
+
export const systemTables = {
|
|
35
|
+
// [EVENTS_TABLE_NAME]: SqliteDsl.table(EVENTS_TABLE_NAME, {
|
|
36
|
+
// id: SqliteDsl.text({ primaryKey: true }),
|
|
37
|
+
// type: SqliteDsl.text({ nullable: false }),
|
|
38
|
+
// args: SqliteDsl.text({ nullable: false }),
|
|
39
|
+
// }).ast,
|
|
40
|
+
[SCHEMA_META_TABLE]: schemaMetaTable.ast,
|
|
41
|
+
};
|
|
42
|
+
export const defineTables = (tables) => tables;
|
|
43
|
+
export const defineMaterializedViews = (materializedViews) => materializedViews;
|
|
44
|
+
export const defineActions = (actions) => actions;
|
|
45
|
+
export const defineAction = (action) => action;
|
|
46
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AASrC,yFAAyF;AACzF,MAAM,CAAC,MAAM,oBAAoB,GAAuC,EAAE,CAAA;AAU1E,MAAM,CAAC,MAAM,UAAU,GAAG,CAA8B,MAAe,EAAU,EAAE,CACjF,CAAC;IACC,MAAM,EAAE,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,YAAY,EAAE;IAChG,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC,OAAO;CACxB,CAAkB,CAAA;AAOrB,4EAA4E;AAC5E,MAAM,CAAC,MAAM,0BAA0B,GAAG;AACxC,gFAAgF;AAChF,IAAW,EACX,OAAiB,EAIjB,EAAE;IACF,MAAM,SAAS,GAAG,eAAe,IAAI,EAAW,CAAA;IAChD,IAAI,MAAM,CAAC,IAAI,CAAC,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MAAM,aAAa,GAAG,CAAmC,OAAU,EAAE,EAAE,CAAC,OAAO,CAAA;AACtF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAA+B,EACN,EAAE,CAAC,MAAM,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as otel from '@opentelemetry/api';
|
|
2
|
+
import type { PreparedBindValues } from '../../util.js';
|
|
3
|
+
import type { Storage, StorageOtelProps } from '../index.js';
|
|
4
|
+
export type StorageOptionsWebInMemory = {
|
|
5
|
+
type: 'web-in-memory';
|
|
6
|
+
};
|
|
7
|
+
/** NOTE: This storage is currently only used for testing */
|
|
8
|
+
export declare class InMemoryStorage implements Storage {
|
|
9
|
+
readonly otelTracer: otel.Tracer;
|
|
10
|
+
constructor(otelTracer: otel.Tracer);
|
|
11
|
+
static load: (_options?: StorageOptionsWebInMemory) => Promise<({ otelTracer }: StorageOtelProps) => InMemoryStorage>;
|
|
12
|
+
execute: (_query: string, _bindValues?: PreparedBindValues) => void;
|
|
13
|
+
getPersistedData: () => Promise<Uint8Array>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/in-memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE5D,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,eAAe,CAAA;CACtB,CAAA;AAED,4DAA4D;AAC5D,qBAAa,eAAgB,YAAW,OAAO;IACjC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM;gBAAvB,UAAU,EAAE,IAAI,CAAC,MAAM;IAE5C,MAAM,CAAC,IAAI,cAAqB,yBAAyB,8BAC/B,gBAAgB,sBACzC;IAED,OAAO,WAAY,MAAM,gBAAgB,kBAAkB,KAAG,IAAI,CAAM;IAExE,gBAAgB,QAAa,QAAQ,UAAU,CAAC,CAAoB;CACrE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
/** NOTE: This storage is currently only used for testing */
|
|
3
|
+
export class InMemoryStorage {
|
|
4
|
+
constructor(otelTracer) {
|
|
5
|
+
this.otelTracer = otelTracer;
|
|
6
|
+
this.execute = (_query, _bindValues) => { };
|
|
7
|
+
this.getPersistedData = async () => new Uint8Array();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
_a = InMemoryStorage;
|
|
11
|
+
InMemoryStorage.load = async (_options) => {
|
|
12
|
+
return ({ otelTracer }) => new _a(otelTracer);
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/in-memory/index.ts"],"names":[],"mappings":";AASA,4DAA4D;AAC5D,MAAM,OAAO,eAAe;IAC1B,YAAqB,UAAuB;QAAvB,eAAU,GAAV,UAAU,CAAa;QAM5C,YAAO,GAAG,CAAC,MAAc,EAAE,WAAgC,EAAQ,EAAE,GAAE,CAAC,CAAA;QAExE,qBAAgB,GAAG,KAAK,IAAyB,EAAE,CAAC,IAAI,UAAU,EAAE,CAAA;IARrB,CAAC;;;AAEzC,oBAAI,GAAG,KAAK,EAAE,QAAoC,EAAE,EAAE;IAC3D,OAAO,CAAC,EAAE,UAAU,EAAoB,EAAE,EAAE,CAAC,IAAI,EAAe,CAAC,UAAU,CAAC,CAAA;AAC9E,CAAC,AAFU,CAEV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as otel from '@opentelemetry/api';
|
|
2
|
+
import type { PreparedBindValues } from '../util.js';
|
|
3
|
+
export type StorageInit = (otelProps: StorageOtelProps) => Promise<Storage> | Storage;
|
|
4
|
+
export interface Storage {
|
|
5
|
+
execute(query: string, bindValues?: PreparedBindValues, parentSpan?: otel.Span): void;
|
|
6
|
+
/** Return a snapshot of persisted data from the storage */
|
|
7
|
+
getPersistedData(parentSpan?: otel.Span): Promise<Uint8Array>;
|
|
8
|
+
}
|
|
9
|
+
export type StorageType = 'tauri' | 'web' | 'web-in-memory';
|
|
10
|
+
export type StorageOtelProps = {
|
|
11
|
+
otelTracer: otel.Tracer;
|
|
12
|
+
parentSpan: otel.Span;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;AAErF,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,kBAAkB,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAErF,2DAA2D;IAC3D,gBAAgB,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC9D;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,eAAe,CAAA;AAE3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,IAAI,CAAC,MAAM,CAAA;IACvB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAA;CACtB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// A storage represents a raw SQLite database.
|
|
2
|
+
// Examples include:
|
|
3
|
+
// - A native SQLite process running in a Tauri Rust process
|
|
4
|
+
// - A SQL.js WASM version of SQLite running in a web worker
|
|
5
|
+
//
|
|
6
|
+
// We can send commands to execute various kinds of queries,
|
|
7
|
+
// and respond to various events from the database.
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,oBAAoB;AACpB,4DAA4D;AAC5D,4DAA4D;AAC5D,EAAE;AACF,4DAA4D;AAC5D,mDAAmD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as otel from '@opentelemetry/api';
|
|
2
|
+
import type { PreparedBindValues } from '../../util.js';
|
|
3
|
+
import type { Storage, StorageOtelProps } from '../index.js';
|
|
4
|
+
export type StorageOptionsTauri = {
|
|
5
|
+
dbDirPath: string;
|
|
6
|
+
appDbFileName: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class TauriStorage implements Storage {
|
|
9
|
+
readonly dbFilePath: string;
|
|
10
|
+
readonly dbDirPath: string;
|
|
11
|
+
readonly otelTracer: otel.Tracer;
|
|
12
|
+
readonly parentSpan: otel.Span;
|
|
13
|
+
constructor(dbFilePath: string, dbDirPath: string, otelTracer: otel.Tracer, parentSpan: otel.Span);
|
|
14
|
+
static load: ({ dbDirPath, appDbFileName }: StorageOptionsTauri) => ({ otelTracer, parentSpan }: StorageOtelProps) => Promise<TauriStorage>;
|
|
15
|
+
execute: (query: string, bindValues?: PreparedBindValues, parentSpan?: otel.Span) => void;
|
|
16
|
+
getPersistedData: (parentSpan?: otel.Span) => Promise<Uint8Array>;
|
|
17
|
+
private getOtelData;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/tauri/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAG/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,qBAAa,YAAa,YAAW,OAAO;IAExC,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM;IAChC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI;gBAHrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,IAAI,CAAC,MAAM,EACvB,UAAU,EAAE,IAAI,CAAC,IAAI;IAGhC,MAAM,CAAC,IAAI,iCACsB,mBAAmB,kCACf,gBAAgB,2BAKlD;IAEH,OAAO,UAAW,MAAM,eAAe,kBAAkB,eAAe,KAAK,IAAI,KAAG,IAAI,CAQvF;IAED,gBAAgB,gBAAuB,KAAK,IAAI,KAAG,QAAQ,UAAU,CAAC,CAOrE;IAED,OAAO,CAAC,WAAW,CAA2E;CAC/F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { getTraceParentHeader } from '@livestore/utils';
|
|
3
|
+
import { invoke } from '@tauri-apps/api';
|
|
4
|
+
import { prepareBindValues } from '../../util.js';
|
|
5
|
+
export class TauriStorage {
|
|
6
|
+
constructor(dbFilePath, dbDirPath, otelTracer, parentSpan) {
|
|
7
|
+
this.dbFilePath = dbFilePath;
|
|
8
|
+
this.dbDirPath = dbDirPath;
|
|
9
|
+
this.otelTracer = otelTracer;
|
|
10
|
+
this.parentSpan = parentSpan;
|
|
11
|
+
this.execute = (query, bindValues, parentSpan) => {
|
|
12
|
+
// console.log({ query, bindValues, prepared: prepareBindValues(bindValues ?? {}, query) })
|
|
13
|
+
void invoke('execute', {
|
|
14
|
+
dbName: this.dbFilePath,
|
|
15
|
+
query,
|
|
16
|
+
values: prepareBindValues(bindValues ?? {}, query),
|
|
17
|
+
otelData: this.getOtelData(parentSpan),
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
this.getPersistedData = async (parentSpan) => {
|
|
21
|
+
const headers = new Headers();
|
|
22
|
+
headers.set('traceparent', getTraceParentHeader(parentSpan ?? this.parentSpan));
|
|
23
|
+
return fetch(`http://localhost:38787/get-persisted-data?file_path=${this.dbFilePath}`, { headers }).then((response) => response.arrayBuffer().then((buffer) => new Uint8Array(buffer)));
|
|
24
|
+
};
|
|
25
|
+
this.getOtelData = (parentSpan) => getOtelData_(parentSpan ?? this.parentSpan);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
_a = TauriStorage;
|
|
29
|
+
TauriStorage.load = ({ dbDirPath, appDbFileName }) => async ({ otelTracer, parentSpan }) => {
|
|
30
|
+
const dbFilePath = `${dbDirPath}/${appDbFileName}`;
|
|
31
|
+
await invoke('initialize_connection', { dbName: dbFilePath, otelData: getOtelData_(parentSpan) });
|
|
32
|
+
return new _a(dbFilePath, dbDirPath, otelTracer, parentSpan);
|
|
33
|
+
};
|
|
34
|
+
const getOtelData_ = (parentSpan) => {
|
|
35
|
+
const spanContext = parentSpan?.spanContext();
|
|
36
|
+
return spanContext ? { trace_id: spanContext.traceId, span_id: spanContext.spanId } : undefined;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/tauri/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAA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AAEG,iBAAI,GACT,CAAC,EAAE,SAAS,EAAE,aAAa,EAAuB,EAAE,EAAE,CACtD,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAoB,EAAE,EAAE;IACrD,MAAM,UAAU,GAAG,GAAG,SAAS,IAAI,aAAa,EAAE,CAAA;IAClD,MAAM,MAAM,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAEjG,OAAO,IAAI,EAAY,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;AACxE,CAAC,AAPQ,CAOR;AAwBL,MAAM,YAAY,GAAG,CAAC,UAAiC,EAAE,EAAE;IACzD,MAAM,WAAW,GAAG,UAAU,EAAE,WAAW,EAAE,CAAA;IAC7C,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACjG,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class IDB {
|
|
2
|
+
private dbName;
|
|
3
|
+
private storeName;
|
|
4
|
+
private db;
|
|
5
|
+
constructor(dbName: string, storeName?: string);
|
|
6
|
+
private open;
|
|
7
|
+
get(key: string): Promise<Uint8Array | undefined>;
|
|
8
|
+
put(key: string, value: Uint8Array): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=idb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idb.d.ts","sourceRoot":"","sources":["../../../src/storage/utils/idb.ts"],"names":[],"mappings":"AAGA,qBAAa,GAAG;IAIZ,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;IAJnB,OAAO,CAAC,EAAE,CAA2B;gBAG3B,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAuB;YAG9B,IAAI;IAwBL,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAkBjD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBhE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* eslint-disable unicorn/prefer-add-event-listener */
|
|
2
|
+
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
3
|
+
export class IDB {
|
|
4
|
+
constructor(dbName, storeName = 'binary_store') {
|
|
5
|
+
this.dbName = dbName;
|
|
6
|
+
this.storeName = storeName;
|
|
7
|
+
this.db = null;
|
|
8
|
+
}
|
|
9
|
+
async open() {
|
|
10
|
+
if (this.db)
|
|
11
|
+
return this.db;
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const openRequest = indexedDB.open(this.dbName, 1);
|
|
14
|
+
openRequest.onupgradeneeded = () => {
|
|
15
|
+
const db = openRequest.result;
|
|
16
|
+
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
17
|
+
db.createObjectStore(this.storeName);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
openRequest.onsuccess = () => {
|
|
21
|
+
this.db = openRequest.result;
|
|
22
|
+
resolve(this.db);
|
|
23
|
+
};
|
|
24
|
+
openRequest.onerror = () => {
|
|
25
|
+
reject(new Error('Failed to open database.'));
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async get(key) {
|
|
30
|
+
const db = await this.open();
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const transaction = db.transaction(this.storeName, 'readonly');
|
|
33
|
+
const store = transaction.objectStore(this.storeName);
|
|
34
|
+
const getRequest = store.get(key);
|
|
35
|
+
getRequest.onsuccess = () => {
|
|
36
|
+
resolve(getRequest.result);
|
|
37
|
+
};
|
|
38
|
+
getRequest.onerror = () => {
|
|
39
|
+
reject(new Error('Failed to get data.'));
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async put(key, value) {
|
|
44
|
+
const db = await this.open();
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const transaction = db.transaction(this.storeName, 'readwrite');
|
|
47
|
+
const store = transaction.objectStore(this.storeName);
|
|
48
|
+
const putRequest = store.put(value, key);
|
|
49
|
+
putRequest.onsuccess = () => {
|
|
50
|
+
resolve();
|
|
51
|
+
};
|
|
52
|
+
putRequest.onerror = () => {
|
|
53
|
+
reject(new Error('Failed to write data.'));
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=idb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idb.js","sourceRoot":"","sources":["../../../src/storage/utils/idb.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,wDAAwD;AAExD,MAAM,OAAO,GAAG;IAGd,YACU,MAAc,EACd,YAAoB,cAAc;QADlC,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAyB;QAJpC,OAAE,GAAuB,IAAI,CAAA;IAKlC,CAAC;IAEI,KAAK,CAAC,IAAI;QAChB,IAAI,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC,EAAE,CAAA;QAE3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;YAElD,WAAW,CAAC,eAAe,GAAG,GAAG,EAAE;gBACjC,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAA;gBAC7B,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;oBACjD,EAAE,CAAC,iBAAiB,CAAC,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rC,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;YAC/D,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACrD,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAExC,UAAU,CAAC,SAAS,GAAG,GAAG,EAAE;gBAC1B,OAAO,EAAE,CAAA;YACX,CAAC,CAAA;YAED,UAAU,CAAC,OAAO,GAAG,GAAG,EAAE;gBACxB,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAA;YAC5C,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type * as otel from '@opentelemetry/api';
|
|
2
|
+
import * as Comlink from 'comlink';
|
|
3
|
+
import type { PreparedBindValues } from '../../util.js';
|
|
4
|
+
import type { Storage, StorageOtelProps } from '../index.js';
|
|
5
|
+
import type { WrappedWorker } from './worker.js';
|
|
6
|
+
export type StorageType = 'opfs' | 'indexeddb';
|
|
7
|
+
export type StorageOptionsWeb = {
|
|
8
|
+
/** Specifies where to persist data for this storage */
|
|
9
|
+
type: StorageType;
|
|
10
|
+
fileName: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class WebWorkerStorage implements Storage {
|
|
13
|
+
worker: Comlink.Remote<WrappedWorker>;
|
|
14
|
+
options: StorageOptionsWeb;
|
|
15
|
+
otelTracer: otel.Tracer;
|
|
16
|
+
executionBacklog: {
|
|
17
|
+
query: string;
|
|
18
|
+
bindValues?: PreparedBindValues;
|
|
19
|
+
}[];
|
|
20
|
+
executionPromise: Promise<void> | undefined;
|
|
21
|
+
private constructor();
|
|
22
|
+
static load: (options: StorageOptionsWeb) => ({ otelTracer }: StorageOtelProps) => WebWorkerStorage;
|
|
23
|
+
execute: (query: string, bindValues?: PreparedBindValues) => void;
|
|
24
|
+
private executeBacklog;
|
|
25
|
+
getPersistedData: (_parentSpan?: otel.Span) => Promise<Uint8Array>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/web-worker/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,CAAA;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uDAAuD;IACvD,IAAI,EAAE,WAAW,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,qBAAa,gBAAiB,YAAW,OAAO;IAC9C,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IACrC,OAAO,EAAE,iBAAiB,CAAA;IAC1B,UAAU,EAAE,IAAI,CAAC,MAAM,CAAA;IAEvB,gBAAgB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,kBAAkB,CAAA;KAAE,EAAE,CAAK;IAC3E,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAA;IAE3C,OAAO;IAmBP,MAAM,CAAC,IAAI,YAAa,iBAAiB,sBASf,gBAAgB,sBAOzC;IAED,OAAO,UAAW,MAAM,eAAe,kBAAkB,UAaxD;IAED,OAAO,CAAC,cAAc,CAIrB;IAED,gBAAgB,iBAAwB,KAAK,IAAI,KAAG,QAAQ,UAAU,CAAC,CAAkC;CAC1G"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { casesHandled } from '@livestore/utils';
|
|
2
|
+
import * as Comlink from 'comlink';
|
|
3
|
+
import { IDB } from '../utils/idb.js';
|
|
4
|
+
export class WebWorkerStorage {
|
|
5
|
+
constructor({ worker, options, otelTracer, executionPromise, }) {
|
|
6
|
+
this.executionBacklog = [];
|
|
7
|
+
this.execute = (query, bindValues) => {
|
|
8
|
+
this.executionBacklog.push({ query, bindValues });
|
|
9
|
+
// Instead of sending the queries to the worker immediately, we wait a bit and batch them up (which reduces the number of messages sent to the worker)
|
|
10
|
+
if (this.executionPromise === undefined) {
|
|
11
|
+
this.executionPromise = new Promise((resolve) => {
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
this.executeBacklog();
|
|
14
|
+
resolve();
|
|
15
|
+
}, 10);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
this.executeBacklog = () => {
|
|
20
|
+
void this.worker.executeBulk(this.executionBacklog);
|
|
21
|
+
this.executionBacklog = [];
|
|
22
|
+
this.executionPromise = undefined;
|
|
23
|
+
};
|
|
24
|
+
this.getPersistedData = async (_parentSpan) => getPersistedData(this.options);
|
|
25
|
+
this.worker = worker;
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.otelTracer = otelTracer;
|
|
28
|
+
this.executionPromise = executionPromise;
|
|
29
|
+
executionPromise.then(() => this.executeBacklog());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
WebWorkerStorage.load = (options) => {
|
|
33
|
+
// TODO: Importing the worker like this only works with Vite;
|
|
34
|
+
// should this really be inside the LiveStore library?
|
|
35
|
+
// Doesn't work with Firefox right now during dev https://bugzilla.mozilla.org/show_bug.cgi?id=1247687
|
|
36
|
+
const worker = new Worker(new URL('./worker.js', import.meta.url), {
|
|
37
|
+
type: 'module',
|
|
38
|
+
});
|
|
39
|
+
const wrappedWorker = Comlink.wrap(worker);
|
|
40
|
+
return ({ otelTracer }) => new WebWorkerStorage({
|
|
41
|
+
worker: wrappedWorker,
|
|
42
|
+
options,
|
|
43
|
+
otelTracer,
|
|
44
|
+
executionPromise: wrappedWorker.initialize(options),
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const getPersistedData = async (options) => {
|
|
48
|
+
switch (options.type) {
|
|
49
|
+
case 'opfs': {
|
|
50
|
+
try {
|
|
51
|
+
const rootHandle = await navigator.storage.getDirectory();
|
|
52
|
+
const fileHandle = await rootHandle.getFileHandle(options.fileName + '.db');
|
|
53
|
+
const file = await fileHandle.getFile();
|
|
54
|
+
const buffer = await file.arrayBuffer();
|
|
55
|
+
const data = new Uint8Array(buffer);
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof DOMException && error.name === 'NotFoundError') {
|
|
60
|
+
return new Uint8Array();
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
case 'indexeddb': {
|
|
66
|
+
const idb = new IDB(options.fileName);
|
|
67
|
+
return (await idb.get('db')) ?? new Uint8Array();
|
|
68
|
+
}
|
|
69
|
+
default: {
|
|
70
|
+
casesHandled(options.type);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/web-worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAIlC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAWrC,MAAM,OAAO,gBAAgB;IAQ3B,YAAoB,EAClB,MAAM,EACN,OAAO,EACP,UAAU,EACV,gBAAgB,GAMjB;QAbD,qBAAgB,GAAyD,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AAC,IAAI,CAAC,CAAC,IAAI,IAAI,UAAU,EAAE,CAAA;SACjD;QACD,OAAO,CAAC,CAAC;YACP,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SAC3B;KACF;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Bindable } from '../../util.js';
|
|
2
|
+
import type { StorageOptionsWeb } from './index.js';
|
|
3
|
+
type ExecutionQueueItem = {
|
|
4
|
+
query: string;
|
|
5
|
+
bindValues?: Bindable;
|
|
6
|
+
};
|
|
7
|
+
declare const wrappedWorker: {
|
|
8
|
+
initialize: (options: StorageOptionsWeb) => Promise<void>;
|
|
9
|
+
executeBulk: (executionItems: ExecutionQueueItem[]) => void;
|
|
10
|
+
};
|
|
11
|
+
export type WrappedWorker = typeof wrappedWorker;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/storage/web-worker/worker.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAsEnD,KAAK,kBAAkB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAA;AA8ClE,QAAA,MAAM,aAAa;0BA5FgB,iBAAiB;kCAgDf,kBAAkB,EAAE,KAAG,IAAI;CA4Cf,CAAA;AAEjD,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Web Worker file for running SQLite in a web worker.
|
|
2
|
+
// TODO: create types for these libraries? SQL.js already should have types;
|
|
3
|
+
// we just need the types to apply to the fork.
|
|
4
|
+
import { shouldNeverHappen } from '@livestore/utils';
|
|
5
|
+
import * as Comlink from 'comlink';
|
|
6
|
+
import sqlite3InitModule from 'sqlite-esm';
|
|
7
|
+
import { casesHandled, sql } from '../../util.js';
|
|
8
|
+
import { IDB } from '../utils/idb.js';
|
|
9
|
+
// A global variable to hold the database connection.
|
|
10
|
+
// let db: SqliteWasm.Database
|
|
11
|
+
let db;
|
|
12
|
+
let sqlite3;
|
|
13
|
+
// TODO get rid of this in favour of a "proper" IDB SQLite storage
|
|
14
|
+
let idb;
|
|
15
|
+
/** The location where this database storage persists its data */
|
|
16
|
+
let options_;
|
|
17
|
+
const configureConnection = () => db.exec(sql `
|
|
18
|
+
PRAGMA page_size=8192;
|
|
19
|
+
PRAGMA journal_mode=MEMORY;
|
|
20
|
+
PRAGMA foreign_keys='ON'; -- we want foreign key constraints to be enforced
|
|
21
|
+
`);
|
|
22
|
+
/** A full virtual filename in the IDB FS */
|
|
23
|
+
const fullyQualifiedFilename = (name) => `${name}.db`;
|
|
24
|
+
const initialize = async (options) => {
|
|
25
|
+
options_ = options;
|
|
26
|
+
sqlite3 = await sqlite3InitModule({
|
|
27
|
+
print: (message) => console.log(`[sql-client] ${message}`),
|
|
28
|
+
printErr: (message) => console.error(`[sql-client] ${message}`),
|
|
29
|
+
});
|
|
30
|
+
switch (options.type) {
|
|
31
|
+
case 'opfs': {
|
|
32
|
+
try {
|
|
33
|
+
db = new sqlite3.oo1.OpfsDb(fullyQualifiedFilename(options.fileName)); // , 'c'
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
debugger;
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'indexeddb': {
|
|
41
|
+
try {
|
|
42
|
+
db = new sqlite3.oo1.DB({ filename: ':memory:', flags: 'c' });
|
|
43
|
+
idb = new IDB(options.fileName);
|
|
44
|
+
const bytes = await idb.get('db');
|
|
45
|
+
if (bytes !== undefined) {
|
|
46
|
+
// Based on https://sqlite.org/forum/forumpost/2119230da8ac5357a13b731f462dc76e08621a4a29724f7906d5f35bb8508465
|
|
47
|
+
// TODO find cleaner way to do this once possible in sqlite3-wasm
|
|
48
|
+
const p = sqlite3.wasm.allocFromTypedArray(bytes);
|
|
49
|
+
const _rc = sqlite3.capi.sqlite3_deserialize(db.pointer, 'main', p, bytes.length, bytes.length, 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
debugger;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
default: {
|
|
58
|
+
casesHandled(options.type);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
configureConnection();
|
|
62
|
+
};
|
|
63
|
+
// TODO get rid of this in favour of a "proper" IDB SQLite storage
|
|
64
|
+
let idbPersistTimeout;
|
|
65
|
+
const executeBulk = (executionItems) => {
|
|
66
|
+
let batchItems = [];
|
|
67
|
+
while (executionItems.length > 0) {
|
|
68
|
+
try {
|
|
69
|
+
db.exec('BEGIN TRANSACTION'); // Start the transaction
|
|
70
|
+
batchItems = executionItems.splice(0, 50);
|
|
71
|
+
for (const { query, bindValues } of batchItems) {
|
|
72
|
+
db.exec({
|
|
73
|
+
sql: query,
|
|
74
|
+
bind: bindValues,
|
|
75
|
+
returnValue: 'resultRows',
|
|
76
|
+
rowMode: 'object',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
db.exec('COMMIT'); // Commit the transaction
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
try {
|
|
83
|
+
db.exec('ROLLBACK'); // Rollback in case of an error
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
console.error('Error rolling back transaction', e);
|
|
87
|
+
}
|
|
88
|
+
shouldNeverHappen(`Error executing query: ${error} \n ${JSON.stringify(batchItems)}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// TODO get rid of this in favour of a "proper" IDB SQLite storage
|
|
92
|
+
if (options_.type === 'indexeddb') {
|
|
93
|
+
if (idbPersistTimeout !== undefined) {
|
|
94
|
+
clearTimeout(idbPersistTimeout);
|
|
95
|
+
}
|
|
96
|
+
idbPersistTimeout = setTimeout(() => {
|
|
97
|
+
const data = sqlite3.capi.sqlite3_js_db_export(db.pointer);
|
|
98
|
+
void idb.put('db', data);
|
|
99
|
+
}, 1000);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const wrappedWorker = { initialize, executeBulk };
|
|
103
|
+
Comlink.expose(wrappedWorker);
|
|
104
|
+
// NOTE keep this around for debugging
|
|
105
|
+
// db.exec({
|
|
106
|
+
// sql: `select * from sqlite_master where name = 'library_tracks'`,
|
|
107
|
+
// callback: (_: TODO) => console.log(_),
|
|
108
|
+
// rowMode: 'object',
|
|
109
|
+
// } as TODO)
|
|
110
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/storage/web-worker/worker.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,4EAA4E;AAC5E,+CAA+C;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,OAAO,iBAAiB,MAAM,YAAY,CAAA;AAI1C,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAGrC,qDAAqD;AACrD,8BAA8B;AAC9B,IAAI,EAA0B,CAAA;AAE9B,IAAI,OAAiC,CAAA;AAErC,kEAAkE;AAClE,IAAI,GAAoB,CAAA;AAExB,iEAAiE;AACjE,IAAI,QAA2B,CAAA;AAE/B,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAC/B,EAAE,CAAC,IAAI,CAAC,GAAG,CAAA;;;;GAIV,CAAC,CAAA;AAEJ,4CAA4C;AAC5C,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,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