@powerhousedao/reactor-browser 3.3.0-dev.2 → 3.3.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +13 -5
- package/dist/src/global/types.d.ts +7 -0
- package/dist/src/global/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/operational/hooks/index.d.ts +3 -0
- package/dist/src/operational/hooks/index.d.ts.map +1 -0
- package/dist/src/operational/hooks/index.js +3 -0
- package/dist/src/operational/hooks/index.js.map +1 -0
- package/dist/src/operational/hooks/useOperationalQuery.d.ts +12 -0
- package/dist/src/operational/hooks/useOperationalQuery.d.ts.map +1 -0
- package/dist/src/operational/hooks/useOperationalQuery.js +27 -0
- package/dist/src/operational/hooks/useOperationalQuery.js.map +1 -0
- package/dist/src/operational/hooks/useOperationalStore.d.ts +12 -0
- package/dist/src/operational/hooks/useOperationalStore.d.ts.map +1 -0
- package/dist/src/operational/hooks/useOperationalStore.js +33 -0
- package/dist/src/operational/hooks/useOperationalStore.js.map +1 -0
- package/dist/src/operational/index.d.ts +3 -0
- package/dist/src/operational/index.d.ts.map +1 -0
- package/dist/src/operational/index.js +3 -0
- package/dist/src/operational/index.js.map +1 -0
- package/dist/src/operational/utils/createTypedQuery.d.ts +16 -0
- package/dist/src/operational/utils/createTypedQuery.d.ts.map +1 -0
- package/dist/src/operational/utils/createTypedQuery.js +24 -0
- package/dist/src/operational/utils/createTypedQuery.js.map +1 -0
- package/dist/src/operational/utils/index.d.ts +2 -0
- package/dist/src/operational/utils/index.d.ts.map +1 -0
- package/dist/src/operational/utils/index.js +2 -0
- package/dist/src/operational/utils/index.js.map +1 -0
- package/dist/src/pglite/hooks/index.d.ts +2 -0
- package/dist/src/pglite/hooks/index.d.ts.map +1 -0
- package/dist/src/pglite/hooks/index.js +2 -0
- package/dist/src/pglite/hooks/index.js.map +1 -0
- package/dist/src/pglite/hooks/usePGlite.d.ts +11 -0
- package/dist/src/pglite/hooks/usePGlite.d.ts.map +1 -0
- package/dist/src/pglite/hooks/usePGlite.js +37 -0
- package/dist/src/pglite/hooks/usePGlite.js.map +1 -0
- package/dist/src/pglite/index.d.ts +6 -0
- package/dist/src/pglite/index.d.ts.map +1 -0
- package/dist/src/pglite/index.js +6 -0
- package/dist/src/pglite/index.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +15 -7
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/reactor-browser",
|
|
3
|
-
"version": "3.3.0-dev.
|
|
3
|
+
"version": "3.3.0-dev.2",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": "./dist/src/index.js",
|
|
20
20
|
"./analytics": "./dist/src/analytics/analytics.js",
|
|
21
|
+
"./pglite": "./dist/src/pglite/index.js",
|
|
22
|
+
"./operational": "./dist/src/operational/index.js",
|
|
21
23
|
"./*": "./dist/src/*.js"
|
|
22
24
|
},
|
|
23
25
|
"scripts": {
|
|
@@ -34,25 +36,28 @@
|
|
|
34
36
|
"install:playwright": "playwright install"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
39
|
+
"@types/lodash.isequal": "^4.5.8",
|
|
37
40
|
"@types/luxon": "^3.6.2",
|
|
38
41
|
"@types/react": "^18.3.1",
|
|
39
42
|
"@types/react-dom": "^18.3.1",
|
|
40
43
|
"@vitejs/plugin-react": "^4.4.1",
|
|
41
44
|
"@vitest/browser": "^3.1.2",
|
|
45
|
+
"jotai": "^2.10.3",
|
|
42
46
|
"playwright": "^1.51.1",
|
|
43
47
|
"react": "^18.3.1",
|
|
44
48
|
"react-dom": "^18.3.1",
|
|
45
49
|
"vite-plugin-node-polyfills": "^0.23.0",
|
|
46
50
|
"vitest": "^3.1.2",
|
|
47
|
-
"vitest-browser-react": "^0.2.0"
|
|
48
|
-
"jotai": "^2.10.3"
|
|
51
|
+
"vitest-browser-react": "^0.2.0"
|
|
49
52
|
},
|
|
50
53
|
"peerDependencies": {
|
|
54
|
+
"jotai": "^2.10.3",
|
|
51
55
|
"react": "^18.3.1",
|
|
52
|
-
"react-dom": "^18.3.1"
|
|
53
|
-
"jotai": "^2.10.3"
|
|
56
|
+
"react-dom": "^18.3.1"
|
|
54
57
|
},
|
|
55
58
|
"dependencies": {
|
|
59
|
+
"@electric-sql/pglite": "^0.2.17",
|
|
60
|
+
"@electric-sql/pglite-react": "^0.2.17",
|
|
56
61
|
"@powerhousedao/analytics-engine-browser": "^0.6.0",
|
|
57
62
|
"@powerhousedao/analytics-engine-core": "^0.5.0",
|
|
58
63
|
"@powerhousedao/analytics-engine-knex": "^0.6.0",
|
|
@@ -61,6 +66,9 @@
|
|
|
61
66
|
"did-key-creator": "^1.2.0",
|
|
62
67
|
"document-drive": "workspace:*",
|
|
63
68
|
"document-model": "workspace:*",
|
|
69
|
+
"kysely": "^0.28.2",
|
|
70
|
+
"kysely-pglite-dialect": "^1.1.1",
|
|
71
|
+
"lodash.isequal": "^4.5.0",
|
|
64
72
|
"luxon": "^3.6.1",
|
|
65
73
|
"lz-string": "^1.5.0"
|
|
66
74
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { type PGliteWithLive } from "@electric-sql/pglite/live";
|
|
1
2
|
import { type IPowerhouseAnalytics } from "../analytics/types.js";
|
|
3
|
+
export interface PGliteState {
|
|
4
|
+
db: PGliteWithLive | null;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
}
|
|
2
8
|
export interface PowerhouseGlobal {
|
|
3
9
|
analytics?: Promise<IPowerhouseAnalytics>;
|
|
10
|
+
pglite?: PGliteState;
|
|
4
11
|
}
|
|
5
12
|
declare global {
|
|
6
13
|
interface Window {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/global/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/global/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,CAAC,EAAE,gBAAgB,CAAC;KAC/B;CACF"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { type IDocumentDriveServer } from "document-drive";
|
|
|
2
2
|
export * from "./context/index.js";
|
|
3
3
|
export * from "./document-model.js";
|
|
4
4
|
export * from "./hooks/index.js";
|
|
5
|
+
export * from "./operational/index.js";
|
|
6
|
+
export * from "./pglite/index.js";
|
|
5
7
|
export * from "./reactor.js";
|
|
6
8
|
export * from "./renown/types.js";
|
|
7
9
|
export * from "./types/index.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./context/index.js";
|
|
2
2
|
export * from "./document-model.js";
|
|
3
3
|
export * from "./hooks/index.js";
|
|
4
|
+
export * from "./operational/index.js";
|
|
5
|
+
export * from "./pglite/index.js";
|
|
4
6
|
export * from "./reactor.js";
|
|
5
7
|
export * from "./renown/types.js";
|
|
6
8
|
export * from "./types/index.js";
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operational/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/operational/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LiveQueryResults } from "@electric-sql/pglite/live";
|
|
2
|
+
import { type Kysely } from "kysely";
|
|
3
|
+
export type QueryCallbackReturnType = {
|
|
4
|
+
sql: string;
|
|
5
|
+
parameters?: readonly unknown[];
|
|
6
|
+
};
|
|
7
|
+
export declare function useOperationalQuery<Schema, T = unknown, TParams = undefined>(queryCallback: (db: Kysely<Schema>, parameters?: TParams) => QueryCallbackReturnType, parameters?: TParams): {
|
|
8
|
+
readonly isLoading: boolean;
|
|
9
|
+
readonly error: Error | null;
|
|
10
|
+
readonly result: LiveQueryResults<T> | null;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useOperationalQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOperationalQuery.d.ts","sourceRoot":"","sources":["../../../../src/operational/hooks/useOperationalQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACjC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,SAAS,EAC1E,aAAa,EAAE,CACb,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAClB,UAAU,CAAC,EAAE,OAAO,KACjB,uBAAuB,EAC5B,UAAU,CAAC,EAAE,OAAO;;;;EAkCrB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useOperationalStore } from "./useOperationalStore.js";
|
|
3
|
+
export function useOperationalQuery(queryCallback, parameters) {
|
|
4
|
+
const [result, setResult] = useState(null);
|
|
5
|
+
const [queryLoading, setQueryLoading] = useState(true);
|
|
6
|
+
const operationalStore = useOperationalStore();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
let live = Promise.resolve(null);
|
|
9
|
+
if (operationalStore.db) {
|
|
10
|
+
const compiledQuery = queryCallback(operationalStore.db, parameters);
|
|
11
|
+
const { sql, parameters: queryParameters } = compiledQuery;
|
|
12
|
+
live = operationalStore.db.live.query(sql, queryParameters ? [...queryParameters] : [], (result) => {
|
|
13
|
+
setResult(result);
|
|
14
|
+
setQueryLoading(false);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return () => {
|
|
18
|
+
void live.then((l) => l?.unsubscribe());
|
|
19
|
+
};
|
|
20
|
+
}, [operationalStore.db, queryCallback, parameters]);
|
|
21
|
+
return {
|
|
22
|
+
isLoading: operationalStore.isLoading || queryLoading,
|
|
23
|
+
error: operationalStore.error,
|
|
24
|
+
result,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=useOperationalQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOperationalQuery.js","sourceRoot":"","sources":["../../../../src/operational/hooks/useOperationalQuery.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAO/D,MAAM,UAAU,mBAAmB,CACjC,aAG4B,EAC5B,UAAoB;IAEpB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAA6B,IAAI,CAAC,CAAC;IACvE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEvD,MAAM,gBAAgB,GAAG,mBAAmB,EAAU,CAAC;IAEvD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,GAAiC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/D,IAAI,gBAAgB,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;YACrE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,aAAa,CAAC;YAE3D,IAAI,GAAG,gBAAgB,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CACnC,GAAG,EACH,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,EAC3C,CAAC,MAAM,EAAE,EAAE;gBACT,SAAS,CAAC,MAAM,CAAC,CAAC;gBAClB,eAAe,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC,CACF,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,EAAE;YACV,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;IAErD,OAAO;QACL,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,YAAY;QACrD,KAAK,EAAE,gBAAgB,CAAC,KAAK;QAC7B,MAAM;KACE,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LiveNamespace } from "@electric-sql/pglite/live";
|
|
2
|
+
import { Kysely } from "kysely";
|
|
3
|
+
export type EnhancedKysely<Schema> = Kysely<Schema> & {
|
|
4
|
+
live: LiveNamespace;
|
|
5
|
+
};
|
|
6
|
+
export interface IOperationalStore<Schema> {
|
|
7
|
+
db: EnhancedKysely<Schema> | null;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const useOperationalStore: <Schema>() => IOperationalStore<Schema>;
|
|
12
|
+
//# sourceMappingURL=useOperationalStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOperationalStore.d.ts","sourceRoot":"","sources":["../../../../src/operational/hooks/useOperationalStore.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,MAAM,MAAM,cAAc,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9E,MAAM,WAAW,iBAAiB,CAAC,MAAM;IACvC,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAgBD,eAAO,MAAM,mBAAmB,GAAI,MAAM,gCAsBzC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import { PGliteDialect } from "kysely-pglite-dialect";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { usePGliteDB } from "../../pglite/hooks/usePGlite.js";
|
|
5
|
+
// Custom initializer that creates enhanced Kysely instance with live capabilities
|
|
6
|
+
function createEnhancedKysely(pgliteInstance) {
|
|
7
|
+
const db = new Kysely({
|
|
8
|
+
dialect: new PGliteDialect(pgliteInstance),
|
|
9
|
+
});
|
|
10
|
+
// Inject the live namespace with proper typing
|
|
11
|
+
db.live = pgliteInstance.live;
|
|
12
|
+
return db;
|
|
13
|
+
}
|
|
14
|
+
export const useOperationalStore = () => {
|
|
15
|
+
const pglite = usePGliteDB();
|
|
16
|
+
const operationalDB = useMemo(() => {
|
|
17
|
+
if (!pglite.db || pglite.isLoading || pglite.error) {
|
|
18
|
+
return {
|
|
19
|
+
db: null,
|
|
20
|
+
isLoading: pglite.isLoading,
|
|
21
|
+
error: pglite.error,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const db = createEnhancedKysely(pglite.db);
|
|
25
|
+
return {
|
|
26
|
+
db,
|
|
27
|
+
isLoading: false,
|
|
28
|
+
error: null,
|
|
29
|
+
};
|
|
30
|
+
}, [pglite]);
|
|
31
|
+
return operationalDB;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=useOperationalStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOperationalStore.js","sourceRoot":"","sources":["../../../../src/operational/hooks/useOperationalStore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAW9D,kFAAkF;AAClF,SAAS,oBAAoB,CAC3B,cAA8B;IAE9B,MAAM,EAAE,GAAG,IAAI,MAAM,CAAS;QAC5B,OAAO,EAAE,IAAI,aAAa,CAAC,cAAmC,CAAC;KAChE,CAAC,CAAC;IAEH,+CAA+C;IAC9C,EAA6B,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;IAE1D,OAAO,EAA4B,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAW,EAAE;IAC9C,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAE7B,MAAM,aAAa,GAAG,OAAO,CAA4B,GAAG,EAAE;QAC5D,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACnD,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,GAAG,oBAAoB,CAAS,MAAM,CAAC,EAAE,CAAC,CAAC;QAEnD,OAAO;YACL,EAAE;YACF,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operational/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/operational/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type LiveQueryResults } from "@electric-sql/pglite/live";
|
|
2
|
+
import { type CompiledQuery, type Kysely } from "kysely";
|
|
3
|
+
import { type QueryCallbackReturnType } from "../hooks/useOperationalQuery.js";
|
|
4
|
+
export declare function createTypedQuery<Schema>(): {
|
|
5
|
+
<TQueryBuilder extends (db: Kysely<Schema>) => QueryCallbackReturnType>(queryCallback: TQueryBuilder): {
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
result: LiveQueryResults<ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any> | null;
|
|
9
|
+
};
|
|
10
|
+
<TParams, TQueryBuilder extends (db: Kysely<Schema>, parameters: TParams) => QueryCallbackReturnType>(queryCallback: TQueryBuilder, parameters: TParams): {
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
result: LiveQueryResults<ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any> | null;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=createTypedQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTypedQuery.d.ts","sourceRoot":"","sources":["../../../../src/operational/utils/createTypedQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIzD,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,iCAAiC,CAAC;AAczC,wBAAgB,gBAAgB,CAAC,MAAM;KAGnC,aAAa,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,uBAAuB,iBAEtD,aAAa,GAC3B;QACD,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,MAAM,EAAE,gBAAgB,CACtB,UAAU,CAAC,aAAa,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CACnE,GAAG,IAAI,CAAC;KACV;KAIC,OAAO,EACP,aAAa,SAAS,CACpB,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAClB,UAAU,EAAE,OAAO,KAChB,uBAAuB,iBAEb,aAAa,cAChB,OAAO,GAClB;QACD,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,MAAM,EAAE,gBAAgB,CACtB,UAAU,CAAC,aAAa,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CACnE,GAAG,IAAI,CAAC;KACV;EAsCF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import deepEqual from "lodash.isequal";
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { useOperationalQuery, } from "../hooks/useOperationalQuery.js";
|
|
4
|
+
// Custom hook for parameter memoization
|
|
5
|
+
function useStableParams(params) {
|
|
6
|
+
const prevParamsRef = useRef();
|
|
7
|
+
return useMemo(() => {
|
|
8
|
+
if (!deepEqual(prevParamsRef.current, params)) {
|
|
9
|
+
prevParamsRef.current = params;
|
|
10
|
+
}
|
|
11
|
+
return prevParamsRef.current;
|
|
12
|
+
}, [params]);
|
|
13
|
+
}
|
|
14
|
+
export function createTypedQuery() {
|
|
15
|
+
function useQuery(queryCallback, parameters) {
|
|
16
|
+
// Automatically memoize parameters using deep comparison
|
|
17
|
+
const stableParams = useStableParams(parameters);
|
|
18
|
+
// Memoize the callback to prevent infinite loops, updating when parameters change
|
|
19
|
+
const memoizedCallback = useCallback(queryCallback, [stableParams]);
|
|
20
|
+
return useOperationalQuery(memoizedCallback, stableParams);
|
|
21
|
+
}
|
|
22
|
+
return useQuery;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=createTypedQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTypedQuery.js","sourceRoot":"","sources":["../../../../src/operational/utils/createTypedQuery.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAEL,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,wCAAwC;AACxC,SAAS,eAAe,CAAI,MAAS;IACnC,MAAM,aAAa,GAAG,MAAM,EAAK,CAAC;IAElC,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;YAC9C,aAAa,CAAC,OAAO,GAAG,MAAM,CAAC;QACjC,CAAC;QACD,OAAO,aAAa,CAAC,OAAY,CAAC;IACpC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB;IAgC9B,SAAS,QAAQ,CAOf,aAA4B,EAC5B,UAAoB;QAWpB,yDAAyD;QACzD,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAEjD,kFAAkF;QAClF,MAAM,gBAAgB,GAAG,WAAW,CAAC,aAAa,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAEpE,OAAO,mBAAmB,CACxB,gBAAgB,EAChB,YAAY,CAKb,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operational/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/operational/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pglite/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/pglite/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PGliteWithLive } from "@electric-sql/pglite/live";
|
|
2
|
+
export declare const PGLITE_UPDATE_EVENT = "ph:pglite-update";
|
|
3
|
+
export interface PGliteState {
|
|
4
|
+
db: PGliteWithLive | null;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
}
|
|
8
|
+
export declare const usePGliteDB: () => PGliteState;
|
|
9
|
+
export declare const useSetPGliteDB: () => (pglite: Partial<PGliteState>) => void;
|
|
10
|
+
export declare const usePGlite: () => (PGliteState | ((pglite: Partial<PGliteState>) => void))[];
|
|
11
|
+
//# sourceMappingURL=usePGlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePGlite.d.ts","sourceRoot":"","sources":["../../../../src/pglite/hooks/usePGlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAQD,eAAO,MAAM,WAAW,mBAgBvB,CAAC;AAEF,eAAO,MAAM,cAAc,iBACO,OAAO,CAAC,WAAW,CAAC,SAerD,CAAC;AAEF,eAAO,MAAM,SAAS,iCAjBY,OAAO,CAAC,WAAW,CAAC,aAsBrD,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
export const PGLITE_UPDATE_EVENT = "ph:pglite-update";
|
|
3
|
+
const defaultPGliteState = {
|
|
4
|
+
db: null,
|
|
5
|
+
isLoading: true,
|
|
6
|
+
error: null,
|
|
7
|
+
};
|
|
8
|
+
export const usePGliteDB = () => {
|
|
9
|
+
const [state, setState] = useState(() => window.powerhouse?.pglite ?? defaultPGliteState);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const handlePgliteUpdate = () => setState(window.powerhouse?.pglite ?? defaultPGliteState);
|
|
12
|
+
window.addEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);
|
|
13
|
+
return () => window.removeEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);
|
|
14
|
+
}, []);
|
|
15
|
+
return state;
|
|
16
|
+
};
|
|
17
|
+
export const useSetPGliteDB = () => {
|
|
18
|
+
const setPGliteState = (pglite) => {
|
|
19
|
+
const currentPowerhouse = window.powerhouse ?? {};
|
|
20
|
+
const currentPGliteState = window.powerhouse?.pglite ?? defaultPGliteState;
|
|
21
|
+
window.powerhouse = {
|
|
22
|
+
...currentPowerhouse,
|
|
23
|
+
pglite: {
|
|
24
|
+
...currentPGliteState,
|
|
25
|
+
...pglite,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
window.dispatchEvent(new CustomEvent(PGLITE_UPDATE_EVENT));
|
|
29
|
+
};
|
|
30
|
+
return setPGliteState;
|
|
31
|
+
};
|
|
32
|
+
export const usePGlite = () => {
|
|
33
|
+
const pglite = usePGliteDB();
|
|
34
|
+
const setPGlite = useSetPGliteDB();
|
|
35
|
+
return [pglite, setPGlite];
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=usePGlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePGlite.js","sourceRoot":"","sources":["../../../../src/pglite/hooks/usePGlite.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAQtD,MAAM,kBAAkB,GAAgB;IACtC,EAAE,EAAE,IAAI;IACR,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAChC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,IAAI,kBAAkB,CACtD,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAC9B,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,IAAI,kBAAkB,CAAC,CAAC;QAE5D,MAAM,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;QAEjE,OAAO,GAAG,EAAE,CACV,MAAM,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;IACxE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,cAAc,GAAG,CAAC,MAA4B,EAAE,EAAE;QACtD,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;QAClD,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,IAAI,kBAAkB,CAAC;QAE3E,MAAM,CAAC,UAAU,GAAG;YAClB,GAAG,iBAAiB;YACpB,MAAM,EAAE;gBACN,GAAG,kBAAkB;gBACrB,GAAG,MAAM;aACV;SACF,CAAC;QACF,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC;IAEnC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { PGliteWorker, worker } from "@electric-sql/pglite/worker";
|
|
2
|
+
export type { PGliteWorkerOptions } from "@electric-sql/pglite/worker";
|
|
3
|
+
export { IdbFs, PGlite } from "@electric-sql/pglite";
|
|
4
|
+
export * from "@electric-sql/pglite/live";
|
|
5
|
+
export * from "./hooks/index.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pglite/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAErD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Re-export electric-sql types and utilities for consuming packages
|
|
2
|
+
export { PGliteWorker, worker } from "@electric-sql/pglite/worker";
|
|
3
|
+
export { IdbFs, PGlite } from "@electric-sql/pglite";
|
|
4
|
+
export * from "@electric-sql/pglite/live";
|
|
5
|
+
export * from "./hooks/index.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pglite/index.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAErD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,kBAAkB,CAAC"}
|