@sqlrooms/mosaic 0.8.1 → 0.9.1

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/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * {@include ../README.md}
3
3
  * @packageDocumentation
4
4
  */
5
- export { getMosaicConnector, useMosaic } from './use-mosaic';
5
+ export { useMosaic } from './use-mosaic';
6
6
  export { VgPlotChart } from './VgPlotChart';
7
7
  export type { Spec } from '@uwdata/mosaic-spec';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -2,6 +2,6 @@
2
2
  * {@include ../README.md}
3
3
  * @packageDocumentation
4
4
  */
5
- export { getMosaicConnector, useMosaic } from './use-mosaic';
5
+ export { useMosaic } from './use-mosaic';
6
6
  export { VgPlotChart } from './VgPlotChart';
7
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\nexport {getMosaicConnector, useMosaic} from './use-mosaic';\nexport {VgPlotChart} from './VgPlotChart';\nexport type {Spec} from '@uwdata/mosaic-spec';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\nexport {useMosaic} from './use-mosaic';\nexport {VgPlotChart} from './VgPlotChart';\nexport type {Spec} from '@uwdata/mosaic-spec';\n"]}
@@ -1,9 +1,3 @@
1
- /**
2
- * Retrieves a Mosaic connector for the DuckDB database.
3
- *
4
- * @returns {Promise<MosaicConnector>} The Mosaic connector for the DuckDB database.
5
- */
6
- export declare function getMosaicConnector(): Promise<(db?: any) => any>;
7
1
  /**
8
2
  * Hook to manage the Mosaic connector.
9
3
  *
@@ -1 +1 @@
1
- {"version":3,"file":"use-mosaic.d.ts","sourceRoot":"","sources":["../src/use-mosaic.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAsB,kBAAkB,+BAYvC;AAED;;;;GAIG;AACH,wBAAgB,SAAS;;;EASxB"}
1
+ {"version":3,"file":"use-mosaic.d.ts","sourceRoot":"","sources":["../src/use-mosaic.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,wBAAgB,SAAS;;;EAUxB"}
@@ -1,22 +1,26 @@
1
- import { getDuckDb } from '@sqlrooms/duckdb';
1
+ import { useDuckDb, WasmDuckDbConnector, } from '@sqlrooms/duckdb';
2
2
  import { coordinator, wasmConnector } from '@uwdata/mosaic-core';
3
3
  import { useEffect, useState } from 'react';
4
- let connector;
4
+ let mosaicConnector;
5
+ // TODO: Create MosaicSlice and keep the connector in the store
5
6
  /**
6
7
  * Retrieves a Mosaic connector for the DuckDB database.
7
8
  *
8
9
  * @returns {Promise<MosaicConnector>} The Mosaic connector for the DuckDB database.
9
10
  */
10
- export async function getMosaicConnector() {
11
- if (connector) {
12
- return connector;
11
+ async function getMosaicConnector(duckDb) {
12
+ if (mosaicConnector) {
13
+ return mosaicConnector;
13
14
  }
14
- const duckDb = await getDuckDb();
15
- connector = await coordinator().databaseConnector(wasmConnector({
16
- duckDb: duckDb.db,
17
- connection: duckDb.conn,
15
+ if (!(duckDb instanceof WasmDuckDbConnector)) {
16
+ throw new Error('Only WasmDuckDbConnector is currently supported');
17
+ }
18
+ await duckDb.initialize();
19
+ mosaicConnector = await coordinator().databaseConnector(wasmConnector({
20
+ duckDb: duckDb.getDb(),
21
+ connection: duckDb.getConnection(),
18
22
  }));
19
- return connector;
23
+ return mosaicConnector;
20
24
  }
21
25
  /**
22
26
  * Hook to manage the Mosaic connector.
@@ -26,11 +30,12 @@ export async function getMosaicConnector() {
26
30
  export function useMosaic() {
27
31
  const [isLoading, setIsLoading] = useState(true);
28
32
  const [connector, setConnector] = useState();
33
+ const duckDb = useDuckDb();
29
34
  useEffect(() => {
30
- getMosaicConnector()
35
+ getMosaicConnector(duckDb)
31
36
  .then(setConnector)
32
37
  .finally(() => setIsLoading(false));
33
- }, []);
38
+ }, [duckDb]);
34
39
  return { isMosaicLoading: isLoading, mosaicConnector: connector };
35
40
  }
36
41
  //# sourceMappingURL=use-mosaic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-mosaic.js","sourceRoot":"","sources":["../src/use-mosaic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAG1C,IAAI,SAA0B,CAAC;AAE/B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,SAAS,GAAG,MAAM,WAAW,EAAE,CAAC,iBAAiB,CAC/C,aAAa,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC,EAAE;QACjB,UAAU,EAAE,MAAM,CAAC,IAAI;KACxB,CAAC,CACH,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAmB,CAAC;IAC9D,SAAS,CAAC,GAAG,EAAE;QACb,kBAAkB,EAAE;aACjB,IAAI,CAAC,YAAY,CAAC;aAClB,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAC,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAC,CAAC;AAClE,CAAC","sourcesContent":["import {getDuckDb} from '@sqlrooms/duckdb';\nimport {coordinator, wasmConnector} from '@uwdata/mosaic-core';\nimport {useEffect, useState} from 'react';\n\ntype MosaicConnector = ReturnType<typeof coordinator>['databaseConnector'];\nlet connector: MosaicConnector;\n\n/**\n * Retrieves a Mosaic connector for the DuckDB database.\n *\n * @returns {Promise<MosaicConnector>} The Mosaic connector for the DuckDB database.\n */\nexport async function getMosaicConnector() {\n if (connector) {\n return connector;\n }\n const duckDb = await getDuckDb();\n connector = await coordinator().databaseConnector(\n wasmConnector({\n duckDb: duckDb.db,\n connection: duckDb.conn,\n }),\n );\n return connector;\n}\n\n/**\n * Hook to manage the Mosaic connector.\n *\n * @returns {Object} An object containing the Mosaic connector and a loading state.\n */\nexport function useMosaic() {\n const [isLoading, setIsLoading] = useState(true);\n const [connector, setConnector] = useState<MosaicConnector>();\n useEffect(() => {\n getMosaicConnector()\n .then(setConnector)\n .finally(() => setIsLoading(false));\n }, []);\n return {isMosaicLoading: isLoading, mosaicConnector: connector};\n}\n"]}
1
+ {"version":3,"file":"use-mosaic.js","sourceRoot":"","sources":["../src/use-mosaic.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAG1C,IAAI,eAAgC,CAAC;AAErC,+DAA+D;AAE/D;;;;GAIG;AACH,KAAK,UAAU,kBAAkB,CAAC,MAAuB;IACvD,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,YAAY,mBAAmB,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,eAAe,GAAG,MAAM,WAAW,EAAE,CAAC,iBAAiB,CACrD,aAAa,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;QACtB,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE;KACnC,CAAC,CACH,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAmB,CAAC;IAC9D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE;QACb,kBAAkB,CAAC,MAAM,CAAC;aACvB,IAAI,CAAC,YAAY,CAAC;aAClB,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,EAAC,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAC,CAAC;AAClE,CAAC","sourcesContent":["import {\n DuckDbConnector,\n useDuckDb,\n WasmDuckDbConnector,\n} from '@sqlrooms/duckdb';\nimport {coordinator, wasmConnector} from '@uwdata/mosaic-core';\nimport {useEffect, useState} from 'react';\n\ntype MosaicConnector = ReturnType<typeof coordinator>['databaseConnector'];\nlet mosaicConnector: MosaicConnector;\n\n// TODO: Create MosaicSlice and keep the connector in the store\n\n/**\n * Retrieves a Mosaic connector for the DuckDB database.\n *\n * @returns {Promise<MosaicConnector>} The Mosaic connector for the DuckDB database.\n */\nasync function getMosaicConnector(duckDb: DuckDbConnector) {\n if (mosaicConnector) {\n return mosaicConnector;\n }\n if (!(duckDb instanceof WasmDuckDbConnector)) {\n throw new Error('Only WasmDuckDbConnector is currently supported');\n }\n await duckDb.initialize();\n mosaicConnector = await coordinator().databaseConnector(\n wasmConnector({\n duckDb: duckDb.getDb(),\n connection: duckDb.getConnection(),\n }),\n );\n return mosaicConnector;\n}\n\n/**\n * Hook to manage the Mosaic connector.\n *\n * @returns {Object} An object containing the Mosaic connector and a loading state.\n */\nexport function useMosaic() {\n const [isLoading, setIsLoading] = useState(true);\n const [connector, setConnector] = useState<MosaicConnector>();\n const duckDb = useDuckDb();\n useEffect(() => {\n getMosaicConnector(duckDb)\n .then(setConnector)\n .finally(() => setIsLoading(false));\n }, [duckDb]);\n return {isMosaicLoading: isLoading, mosaicConnector: connector};\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/mosaic",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@ai-sdk/provider": "^1.0.7",
23
- "@sqlrooms/duckdb": "0.8.1",
23
+ "@sqlrooms/duckdb": "0.9.1",
24
24
  "@uwdata/mosaic-core": "^0.12.2",
25
25
  "@uwdata/mosaic-spec": "^0.12.2",
26
26
  "@uwdata/vgplot": "^0.12.2"
@@ -35,5 +35,5 @@
35
35
  "lint": "eslint .",
36
36
  "typedoc": "typedoc"
37
37
  },
38
- "gitHead": "7b5e727b79d675c17b93412c109d1ba1b22699c8"
38
+ "gitHead": "8ffc60d215729cae38631a5037866c193c7520e9"
39
39
  }