@casoon/opengrid 0.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.
@@ -0,0 +1,31 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const export_csv: (a: number, b: number, c: any, d: number) => [number, number, number, number];
5
+ export const export_json: (a: number, b: number, c: number) => [number, number, number, number];
6
+ export const get_pivot: (a: any, b: any) => [number, number, number];
7
+ export const get_query: (a: any) => any;
8
+ export const get_view: (a: any) => any;
9
+ export const register: () => [number, number];
10
+ export const set_choices: (a: any, b: any) => void;
11
+ export const set_columns: (a: any, b: any) => void;
12
+ export const set_formats: (a: any, b: any) => void;
13
+ export const set_provider: (a: any, b: any) => void;
14
+ export const set_texts: (a: any, b: any) => void;
15
+ export const set_view: (a: any, b: any) => void;
16
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_f19f0f38d6ea5adb___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_: (a: number, b: number, c: any, d: number, e: number, f: number, g: number, h: number, i: number) => void;
17
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___wasm_bindgen_66404d18cc2edcc2___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_66404d18cc2edcc2___JsError___true_: (a: number, b: number, c: any) => [number, number];
18
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_f19f0f38d6ea5adb___features__gen_HtmlElement__HtmlElement______true_: (a: number, b: number, c: any) => void;
19
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_f19f0f38d6ea5adb___features__gen_HtmlElement__HtmlElement______true__3: (a: number, b: number, c: any) => void;
20
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_f19f0f38d6ea5adb___features__gen_HtmlElement__HtmlElement______true__4: (a: number, b: number, c: any) => void;
21
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___u32______true_: (a: number, b: number, c: number) => void;
22
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke_______true_: (a: number, b: number) => void;
23
+ export const __wbindgen_malloc: (a: number, b: number) => number;
24
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
25
+ export const __externref_table_alloc: () => number;
26
+ export const __wbindgen_externrefs: WebAssembly.Table;
27
+ export const __wbindgen_exn_store: (a: number) => void;
28
+ export const __wbindgen_destroy_closure: (a: number, b: number) => void;
29
+ export const __externref_table_dealloc: (a: number) => void;
30
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
31
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,22 @@
1
+
2
+ const ids = new WeakMap();
3
+ let next = 1;
4
+ let registry = null;
5
+
6
+ export function __opengrid_watch_with(release) {
7
+ registry = new FinalizationRegistry(release);
8
+ }
9
+
10
+ export function __opengrid_known_id(host) {
11
+ return ids.get(host) ?? 0;
12
+ }
13
+
14
+ export function __opengrid_host_id(host) {
15
+ let id = ids.get(host);
16
+ if (id === undefined) {
17
+ id = next++;
18
+ ids.set(host, id);
19
+ registry.register(host, id);
20
+ }
21
+ return id;
22
+ }
@@ -0,0 +1,25 @@
1
+
2
+ const OPENGRID_LIFECYCLE = Symbol("opengrid.lifecycle");
3
+
4
+ export function __opengrid_define_element(name, observed, connected, disconnected, attributeChanged) {
5
+ const hooks = { connected, disconnected, attributeChanged };
6
+ class OpengridElement extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this[OPENGRID_LIFECYCLE] = hooks;
10
+ }
11
+ connectedCallback() {
12
+ hooks.connected(this);
13
+ }
14
+ disconnectedCallback() {
15
+ hooks.disconnected(this);
16
+ }
17
+ attributeChangedCallback(attribute, oldValue, newValue) {
18
+ hooks.attributeChanged(this, attribute, oldValue, newValue);
19
+ }
20
+ }
21
+ if (observed.length > 0) {
22
+ Object.defineProperty(OpengridElement, "observedAttributes", { value: observed });
23
+ }
24
+ customElements.define(name, OpengridElement);
25
+ }
package/worker.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * opengrid engine worker (plan point 19,
3
+ * plan/spezifikation/04-local-engine.md §Worker).
4
+ *
5
+ * A **module worker** that owns exactly one WASM `Engine`. The main thread
6
+ * keeps the DOM, events and rendering; this worker runs ingest, filter, sort,
7
+ * group and aggregate, so a large query never blocks the UI. No pool, no
8
+ * SharedArrayBuffer (V1, §Multithreading erst später).
9
+ *
10
+ * Message protocol (all replies carry the request `id` so they can be matched):
11
+ *
12
+ * init { type:"init", id, moduleUrl, wasmUrl } -> { type:"ready", id }
13
+ * load { type:"load", id, name, bytes, schema }
14
+ * -> { type:"loaded", id }
15
+ * query { type:"query", id, query } -> { id, result }
16
+ *
17
+ * Any request that throws answers `{ id, type:"error", message }`. The `bytes`
18
+ * of `load` arrive as a transferable `ArrayBuffer`; the response strings are the
19
+ * wire JSON of the engine (E6/E13), so nothing engine-specific is serialised
20
+ * here.
21
+ */
22
+
23
+ /** The single engine instance, created on `init` and reused for every query. */
24
+ let engine;
25
+
26
+ self.onmessage = async ({ data }) => {
27
+ try {
28
+ switch (data.type) {
29
+ case "init": {
30
+ // wasm-bindgen `--target web`: the default export initialises the
31
+ // module; the named `Engine` class is created afterwards.
32
+ const module = await import(data.moduleUrl);
33
+ await module.default(data.wasmUrl);
34
+ engine = new module.Engine();
35
+ self.postMessage({ type: "ready", id: data.id });
36
+ break;
37
+ }
38
+ case "load": {
39
+ engine.load_csv(data.name, new Uint8Array(data.bytes), data.schema);
40
+ self.postMessage({ type: "loaded", id: data.id });
41
+ break;
42
+ }
43
+ case "query": {
44
+ self.postMessage({ id: data.id, result: engine.execute(data.query) });
45
+ break;
46
+ }
47
+ default:
48
+ throw new Error(`unknown message type ${data.type}`);
49
+ }
50
+ } catch (error) {
51
+ // The error path is a message, not a crash: the provider rejects the
52
+ // matching promise and the page decides what to show.
53
+ self.postMessage({
54
+ id: data.id,
55
+ type: "error",
56
+ message: error?.message ?? String(error),
57
+ });
58
+ }
59
+ };