@tlockney/cdp-kernel 0.12.0 → 0.12.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/browser/kernel.js +9 -1
- package/dist/browser/kernel.js.map +2 -2
- package/dist/browser/mod.d.ts +16 -0
- package/dist/browser/mod.js +16 -0
- package/dist/browser/target.d.ts +2 -2
- package/dist/browser/worker.js +28 -7
- package/dist/browser/worker.js.map +2 -2
- package/dist/package.d.ts +1 -1
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/runtime/browser-worker.mjs +3 -0
- package/runtime/display.mjs +5 -1
- package/runtime/sql.d.mts +14 -0
- package/runtime/sql.mjs +37 -6
package/dist/browser/mod.d.ts
CHANGED
|
@@ -15,6 +15,22 @@ export declare const CHART_MODULES: {
|
|
|
15
15
|
readonly vegaLite: "npm:vega-lite@6";
|
|
16
16
|
readonly linkedom: "npm:linkedom@0.18";
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* What `jupyter.sql` loads, as it writes them: map them in `modules` to
|
|
20
|
+
* copies the page serves, and SQL runs offline. `duckdb` is an ES module
|
|
21
|
+
* that exports what @duckdb/duckdb-wasm does; the others are that
|
|
22
|
+
* package's own dist files, served as they are. A page may map only the
|
|
23
|
+
* `eh` pair (every current browser runs it); a variant left unmapped
|
|
24
|
+
* loads from jsDelivr. Same as runtime/sql.mjs's DUCKDB_WASM and
|
|
25
|
+
* DUCKDB_FILES.
|
|
26
|
+
*/
|
|
27
|
+
export declare const SQL_MODULES: {
|
|
28
|
+
readonly duckdb: "npm:@duckdb/duckdb-wasm@1.29.0";
|
|
29
|
+
readonly ehWasm: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-eh.wasm";
|
|
30
|
+
readonly ehWorker: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-browser-eh.worker.js";
|
|
31
|
+
readonly mvpWasm: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-mvp.wasm";
|
|
32
|
+
readonly mvpWorker: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-browser-mvp.worker.js";
|
|
33
|
+
};
|
|
18
34
|
export interface BrowserKernelOptions extends BrowserTargetOptions {
|
|
19
35
|
/** What strips cells' types; sucrase by default, since esbuild's native binary can't run in a page. */
|
|
20
36
|
typeStrip?: TypeStripperName | TypeStripper;
|
package/dist/browser/mod.js
CHANGED
|
@@ -26,6 +26,22 @@ export const CHART_MODULES = {
|
|
|
26
26
|
vegaLite: "npm:vega-lite@6",
|
|
27
27
|
linkedom: "npm:linkedom@0.18",
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* What `jupyter.sql` loads, as it writes them: map them in `modules` to
|
|
31
|
+
* copies the page serves, and SQL runs offline. `duckdb` is an ES module
|
|
32
|
+
* that exports what @duckdb/duckdb-wasm does; the others are that
|
|
33
|
+
* package's own dist files, served as they are. A page may map only the
|
|
34
|
+
* `eh` pair (every current browser runs it); a variant left unmapped
|
|
35
|
+
* loads from jsDelivr. Same as runtime/sql.mjs's DUCKDB_WASM and
|
|
36
|
+
* DUCKDB_FILES.
|
|
37
|
+
*/
|
|
38
|
+
export const SQL_MODULES = {
|
|
39
|
+
duckdb: "npm:@duckdb/duckdb-wasm@1.29.0",
|
|
40
|
+
ehWasm: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-eh.wasm",
|
|
41
|
+
ehWorker: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-browser-eh.worker.js",
|
|
42
|
+
mvpWasm: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-mvp.wasm",
|
|
43
|
+
mvpWorker: "npm:@duckdb/duckdb-wasm@1.29.0/dist/duckdb-browser-mvp.worker.js",
|
|
44
|
+
};
|
|
29
45
|
export function startBrowserKernel(options) {
|
|
30
46
|
const channels = new PageChannels();
|
|
31
47
|
const log = options.log ?? ((text) => console.debug(`[cdp-kernel] ${text}`));
|
package/dist/browser/target.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export interface BrowserTargetOptions {
|
|
|
26
26
|
* Specifiers, as written, mapped to URLs the page serves (resolved
|
|
27
27
|
* against `base`), which win over `cdn`: a cell's imports and the
|
|
28
28
|
* libraries `jupyter.chart` and `jupyter.sql` import load from there.
|
|
29
|
-
* Mapping `CHART_MODULES` makes charts draw offline
|
|
30
|
-
*
|
|
29
|
+
* Mapping `CHART_MODULES` makes charts draw offline, and mapping
|
|
30
|
+
* `SQL_MODULES` does the same for `jupyter.sql`.
|
|
31
31
|
*/
|
|
32
32
|
modules?: {
|
|
33
33
|
readonly [specifier: string]: string;
|
package/dist/browser/worker.js
CHANGED
|
@@ -797,6 +797,20 @@ function tableBundle(source, options = {}) {
|
|
|
797
797
|
// runtime/sql.mjs
|
|
798
798
|
var NODE_API = "npm:@duckdb/node-api@1.5.6-r.2";
|
|
799
799
|
var DUCKDB_WASM = "npm:@duckdb/duckdb-wasm@1.29.0";
|
|
800
|
+
var DUCKDB_FILES = {
|
|
801
|
+
mvp: { mainModule: `${DUCKDB_WASM}/dist/duckdb-mvp.wasm`, mainWorker: `${DUCKDB_WASM}/dist/duckdb-browser-mvp.worker.js` },
|
|
802
|
+
eh: { mainModule: `${DUCKDB_WASM}/dist/duckdb-eh.wasm`, mainWorker: `${DUCKDB_WASM}/dist/duckdb-browser-eh.worker.js` }
|
|
803
|
+
};
|
|
804
|
+
function duckdbBundles(jsDelivr, mapped) {
|
|
805
|
+
const bundles = { ...jsDelivr };
|
|
806
|
+
if (!mapped) return bundles;
|
|
807
|
+
for (const [variant, files] of Object.entries(DUCKDB_FILES)) {
|
|
808
|
+
const mainModule = mapped(files.mainModule);
|
|
809
|
+
const mainWorker = mapped(files.mainWorker);
|
|
810
|
+
if (mainModule && mainWorker) bundles[variant] = { mainModule, mainWorker, pthreadWorker: null };
|
|
811
|
+
}
|
|
812
|
+
return bundles;
|
|
813
|
+
}
|
|
800
814
|
var $display = /* @__PURE__ */ Symbol.for("Jupyter.display");
|
|
801
815
|
var RAW = /* @__PURE__ */ Symbol("cdpk.sql.raw");
|
|
802
816
|
function jsValue(value, declared) {
|
|
@@ -924,9 +938,9 @@ var DUCK_TYPES = {
|
|
|
924
938
|
object: "JSON",
|
|
925
939
|
duration: "VARCHAR"
|
|
926
940
|
};
|
|
927
|
-
function createSql({ importModule, signal, openEngine }) {
|
|
941
|
+
function createSql({ importModule, mapped, signal, openEngine }) {
|
|
928
942
|
let engine = null;
|
|
929
|
-
const open = () => engine ??= (openEngine ?? (() => defaultEngine(importModule)))().catch((err) => {
|
|
943
|
+
const open = () => engine ??= (openEngine ?? (() => defaultEngine(importModule, mapped)))().catch((err) => {
|
|
930
944
|
engine = null;
|
|
931
945
|
throw err;
|
|
932
946
|
});
|
|
@@ -1024,9 +1038,9 @@ function inWorker() {
|
|
|
1024
1038
|
function hasNativeRuntime() {
|
|
1025
1039
|
return typeof globalThis.Deno?.version?.deno === "string" || typeof globalThis.Bun?.version === "string" || typeof globalThis.process?.versions?.node === "string" && !inWorker();
|
|
1026
1040
|
}
|
|
1027
|
-
async function defaultEngine(importModule) {
|
|
1041
|
+
async function defaultEngine(importModule, mapped) {
|
|
1028
1042
|
if (hasNativeRuntime()) return nativeEngine(importModule);
|
|
1029
|
-
if (inWorker() && typeof Worker === "function") return wasmEngine(importModule);
|
|
1043
|
+
if (inWorker() && typeof Worker === "function") return wasmEngine(importModule, mapped);
|
|
1030
1044
|
throw new Error("jupyter.sql needs Node, Deno, Bun or the browser target; workerd and celld have no DuckDB");
|
|
1031
1045
|
}
|
|
1032
1046
|
async function nativeEngine(importModule) {
|
|
@@ -1054,9 +1068,9 @@ async function nativeEngine(importModule) {
|
|
|
1054
1068
|
}
|
|
1055
1069
|
};
|
|
1056
1070
|
}
|
|
1057
|
-
async function wasmEngine(importModule) {
|
|
1071
|
+
async function wasmEngine(importModule, mapped) {
|
|
1058
1072
|
const duckdb = await importModule(DUCKDB_WASM);
|
|
1059
|
-
const bundle = await duckdb.selectBundle(duckdb.getJsDelivrBundles());
|
|
1073
|
+
const bundle = await duckdb.selectBundle(duckdbBundles(duckdb.getJsDelivrBundles(), mapped));
|
|
1060
1074
|
const loader = URL.createObjectURL(new Blob([`importScripts(${JSON.stringify(bundle.mainWorker)});`], { type: "text/javascript" }));
|
|
1061
1075
|
const worker = new Worker(loader);
|
|
1062
1076
|
const db = new duckdb.AsyncDuckDB(new duckdb.VoidLogger(), worker);
|
|
@@ -1846,7 +1860,11 @@ function createJupyter(host2) {
|
|
|
1846
1860
|
if (typeof load !== "function") return Promise.reject(new Error(`${what}: no module loader in this runtime`));
|
|
1847
1861
|
return load(specifier);
|
|
1848
1862
|
};
|
|
1849
|
-
const sql = createSql({
|
|
1863
|
+
const sql = createSql({
|
|
1864
|
+
importModule: cellImport("jupyter.sql"),
|
|
1865
|
+
mapped: (specifier) => globalThis.__cdpk?.mapped?.(specifier) ?? null,
|
|
1866
|
+
signal: () => current.signal
|
|
1867
|
+
});
|
|
1850
1868
|
const chart = createChart({ importModule: cellImport("jupyter.chart"), summarizeSpec: summarizeChart });
|
|
1851
1869
|
const comms = createComms((msgType, content, metadata, buffers) => host2.send(msgType, content, metadata, buffers));
|
|
1852
1870
|
pager = createTablePager(comms.api);
|
|
@@ -2327,6 +2345,9 @@ function install({ base, cdn: cdnBase, modules: moduleMap, params }) {
|
|
|
2327
2345
|
globalThis.__cdpk = {
|
|
2328
2346
|
import: (specifier, options) => import(resolveSpecifier(specifier, url, cdn, modules)),
|
|
2329
2347
|
meta: { url, resolve: (specifier) => resolveSpecifier(specifier, url, cdn, modules) },
|
|
2348
|
+
// The URL `modules` maps a specifier to, or null: jupyter.sql's DuckDB
|
|
2349
|
+
// files load from the page this way.
|
|
2350
|
+
mapped: (specifier) => modules && Object.hasOwn(modules, specifier) ? new URL(modules[specifier], url).href : null,
|
|
2330
2351
|
// inspect_request (#10): by descriptor, so nothing runs.
|
|
2331
2352
|
describeForInspect: (value, detail) => describeValue(value, { inspect: (v) => inspect(v, { depth: 2 }), detail }),
|
|
2332
2353
|
inspectPath: (path, detail) => inspectPath(path, { inspect: (v) => inspect(v, { depth: 2 }), detail }),
|