@solid-labs/fab-one-widget 1.0.3 → 1.0.5
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/{GirthManagerWidget-CwgHrdSO.js → GirthManagerWidget-DKpok3Ke.js} +433 -410
- package/dist/{GirthManagerWidget-CwgHrdSO.js.map → GirthManagerWidget-DKpok3Ke.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/web-component.js +17 -10
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
package/dist/web-component.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createElement as
|
|
2
|
-
import { createRoot as
|
|
3
|
-
import { G as
|
|
4
|
-
let
|
|
1
|
+
import { createElement as a } from "react";
|
|
2
|
+
import { createRoot as i } from "react-dom/client";
|
|
3
|
+
import { G as n, __tla as __tla_0 } from "./GirthManagerWidget-DKpok3Ke.js";
|
|
4
|
+
let h;
|
|
5
5
|
let __tla = Promise.all([
|
|
6
6
|
(() => {
|
|
7
7
|
try {
|
|
@@ -10,7 +10,7 @@ let __tla = Promise.all([
|
|
|
10
10
|
}
|
|
11
11
|
})()
|
|
12
12
|
]).then(async () => {
|
|
13
|
-
|
|
13
|
+
h = class extends HTMLElement {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments), this._root = null, this._request = null, this._wasmModule = void 0, this._wasmLoading = false, this._handleComplete = (t) => {
|
|
16
16
|
this.dispatchEvent(new CustomEvent("widgetComplete", {
|
|
@@ -61,7 +61,14 @@ let __tla = Promise.all([
|
|
|
61
61
|
const t = this.attachShadow({
|
|
62
62
|
mode: "open"
|
|
63
63
|
}), e = document.createElement("div");
|
|
64
|
-
e.style.width = "100%", e.style.height = "100%", t.appendChild(e), this._root =
|
|
64
|
+
e.style.width = "100%", e.style.height = "100%", t.appendChild(e), this._root = i(e);
|
|
65
|
+
for (const r of [
|
|
66
|
+
"request",
|
|
67
|
+
"wasmModule"
|
|
68
|
+
]) if (Object.prototype.hasOwnProperty.call(this, r)) {
|
|
69
|
+
const o = this[r];
|
|
70
|
+
delete this[r], this[r] = o;
|
|
71
|
+
}
|
|
65
72
|
const s = this.getAttribute("request");
|
|
66
73
|
if (s && !this._request) try {
|
|
67
74
|
this._request = JSON.parse(s);
|
|
@@ -79,7 +86,7 @@ let __tla = Promise.all([
|
|
|
79
86
|
if (!this._root) return;
|
|
80
87
|
this._root.unmount();
|
|
81
88
|
const t = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("div");
|
|
82
|
-
t && (this._root =
|
|
89
|
+
t && (this._root = i(t)), this._request = null;
|
|
83
90
|
}
|
|
84
91
|
attributeChangedCallback(t, e, s) {
|
|
85
92
|
if (t === "request" && s) try {
|
|
@@ -89,16 +96,16 @@ let __tla = Promise.all([
|
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
_render() {
|
|
92
|
-
!this._root || !this._request || this._root.render(
|
|
99
|
+
!this._root || !this._request || this._root.render(a(n, {
|
|
93
100
|
request: this._request,
|
|
94
101
|
onComplete: this._handleComplete,
|
|
95
102
|
wasmModule: this._wasmModule
|
|
96
103
|
}));
|
|
97
104
|
}
|
|
98
105
|
};
|
|
99
|
-
customElements.get("girth-manager-widget") || customElements.define("girth-manager-widget",
|
|
106
|
+
customElements.get("girth-manager-widget") || customElements.define("girth-manager-widget", h);
|
|
100
107
|
});
|
|
101
108
|
export {
|
|
102
|
-
|
|
109
|
+
h as GirthManagerWidgetElement,
|
|
103
110
|
__tla
|
|
104
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-component.js","sources":["../src/web-component.ts"],"sourcesContent":["import { createElement } from \"react\"\nimport { createRoot, type Root } from \"react-dom/client\"\nimport { GirthManagerWidget } from \"./GirthManagerWidget\"\nimport type { WidgetRequest, WidgetResponse } from \"./types\"\n\n/**\n * Custom Element wrapper for Angular / vanilla JS integration.\n *\n * WASM is loaded automatically from the bundled package — no manual\n * loading required. Just set the `request` property:\n *\n * Usage in Angular:\n * async ngAfterViewInit() {\n * this.widgetEl.nativeElement.request = { spacing_type: 'BK', scan_url: '...' };\n * }\n *\n * <girth-manager-widget #widgetEl (widgetComplete)=\"onComplete($event)\"></girth-manager-widget>\n *\n * To provide your own WASM module (advanced), set `wasmModule` before `request`.\n */\nclass GirthManagerWidgetElement extends HTMLElement {\n private _root: Root | null = null\n private _request: WidgetRequest | null = null\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _wasmModule: any = undefined\n private _wasmLoading = false\n\n static get observedAttributes() {\n return [\"request\"]\n }\n\n get request(): WidgetRequest | null {\n return this._request\n }\n\n set request(value: WidgetRequest | string | null) {\n if (typeof value === \"string\") {\n try {\n this._request = JSON.parse(value)\n } catch {\n console.error(\"[GirthManagerWidget] Invalid JSON for request attribute:\", value)\n return\n }\n } else {\n this._request = value\n }\n // Auto-load WASM from bundle if not externally provided\n if (this._request && !this._wasmModule) {\n this._autoLoadWasm()\n }\n this._render()\n }\n\n /** Set a pre-loaded WASM module (optional — auto-loaded from bundle if not set). */\n get wasmModule() {\n return this._wasmModule\n }\n\n set wasmModule(value: unknown) {\n this._wasmModule = value\n this._render()\n }\n\n /** Auto-load WASM from the bundled package export */\n private async _autoLoadWasm() {\n if (this._wasmModule || this._wasmLoading) return\n this._wasmLoading = true\n try {\n const wasm = await import(\"geo-wasm\")\n await wasm.default()\n this._wasmModule = wasm\n this._render()\n } catch (err) {\n console.error(\"[GirthManagerWidget] Failed to auto-load WASM:\", err)\n } finally {\n this._wasmLoading = false\n }\n }\n\n connectedCallback() {\n const shadow = this.attachShadow({ mode: \"open\" })\n const container = document.createElement(\"div\")\n container.style.width = \"100%\"\n container.style.height = \"100%\"\n shadow.appendChild(container)\n this._root = createRoot(container)\n\n // Parse request from attribute if set before connection\n const attrValue = this.getAttribute(\"request\")\n if (attrValue && !this._request) {\n try {\n this._request = JSON.parse(attrValue)\n } catch {\n console.error(\"[GirthManagerWidget] Invalid JSON in request attribute\")\n }\n }\n\n // Auto-load WASM from bundle if not externally provided\n if (this._request && !this._wasmModule) {\n this._autoLoadWasm()\n }\n\n this._render()\n }\n\n disconnectedCallback() {\n this._root?.unmount()\n this._root = null\n }\n\n /**\n * Reset the widget to its initial state without removing it from the DOM.\n * Unmounts and re-mounts the React tree, clearing all internal state\n * (Zustand store, WASM memory, landmarks, measurements).\n *\n * Usage in Angular:\n * this.widgetEl.nativeElement.reset();\n * this.widgetEl.nativeElement.request = { ... }; // re-initialize\n */\n reset() {\n if (!this._root) return\n // Unmount the current React tree (clears all component state)\n this._root.unmount()\n // Re-create the root on the same container\n const container = this.shadowRoot?.querySelector(\"div\")\n if (container) {\n this._root = createRoot(container)\n }\n this._request = null\n // Keep _wasmModule — it's reusable across resets\n }\n\n attributeChangedCallback(name: string, _oldValue: string, newValue: string) {\n if (name === \"request\" && newValue) {\n try {\n this._request = JSON.parse(newValue)\n this._render()\n } catch {\n console.error(\"[GirthManagerWidget] Invalid JSON in request attribute\")\n }\n }\n }\n\n private _handleComplete = (response: WidgetResponse) => {\n this.dispatchEvent(\n new CustomEvent(\"widgetComplete\", {\n detail: response,\n bubbles: true,\n composed: true,\n })\n )\n }\n\n private _render() {\n if (!this._root || !this._request) return\n\n this._root.render(\n createElement(GirthManagerWidget, {\n request: this._request,\n onComplete: this._handleComplete,\n wasmModule: this._wasmModule,\n })\n )\n }\n}\n\n// Register the custom element\nif (!customElements.get(\"girth-manager-widget\")) {\n customElements.define(\"girth-manager-widget\", GirthManagerWidgetElement)\n}\n\nexport { GirthManagerWidgetElement }\nexport type { WidgetRequest, WidgetResponse }\n"],"names":["GirthManagerWidgetElement","response","value","wasm","err","shadow","container","createRoot","attrValue","name","_oldValue","newValue","createElement","GirthManagerWidget"],"mappings":";;;AAoBA,MAAMA,UAAkC,YAAY;AAAA,EAApD,cAAA;AAAA,UAAA,GAAA,SAAA,GACI,KAAQ,QAAqB,MAC7B,KAAQ,WAAiC,MAEzC,KAAQ,cAAmB,QAC3B,KAAQ,eAAe,
|
|
1
|
+
{"version":3,"file":"web-component.js","sources":["../src/web-component.ts"],"sourcesContent":["import { createElement } from \"react\"\nimport { createRoot, type Root } from \"react-dom/client\"\nimport { GirthManagerWidget } from \"./GirthManagerWidget\"\nimport type { WidgetRequest, WidgetResponse } from \"./types\"\n\n/**\n * Custom Element wrapper for Angular / vanilla JS integration.\n *\n * WASM is loaded automatically from the bundled package — no manual\n * loading required. Just set the `request` property:\n *\n * Usage in Angular:\n * async ngAfterViewInit() {\n * this.widgetEl.nativeElement.request = { spacing_type: 'BK', scan_url: '...' };\n * }\n *\n * <girth-manager-widget #widgetEl (widgetComplete)=\"onComplete($event)\"></girth-manager-widget>\n *\n * To provide your own WASM module (advanced), set `wasmModule` before `request`.\n */\nclass GirthManagerWidgetElement extends HTMLElement {\n private _root: Root | null = null\n private _request: WidgetRequest | null = null\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _wasmModule: any = undefined\n private _wasmLoading = false\n\n static get observedAttributes() {\n return [\"request\"]\n }\n\n get request(): WidgetRequest | null {\n return this._request\n }\n\n set request(value: WidgetRequest | string | null) {\n if (typeof value === \"string\") {\n try {\n this._request = JSON.parse(value)\n } catch {\n console.error(\"[GirthManagerWidget] Invalid JSON for request attribute:\", value)\n return\n }\n } else {\n this._request = value\n }\n // Auto-load WASM from bundle if not externally provided\n if (this._request && !this._wasmModule) {\n this._autoLoadWasm()\n }\n this._render()\n }\n\n /** Set a pre-loaded WASM module (optional — auto-loaded from bundle if not set). */\n get wasmModule() {\n return this._wasmModule\n }\n\n set wasmModule(value: unknown) {\n this._wasmModule = value\n this._render()\n }\n\n /** Auto-load WASM from the bundled package export */\n private async _autoLoadWasm() {\n if (this._wasmModule || this._wasmLoading) return\n this._wasmLoading = true\n try {\n const wasm = await import(\"geo-wasm\")\n await wasm.default()\n this._wasmModule = wasm\n this._render()\n } catch (err) {\n console.error(\"[GirthManagerWidget] Failed to auto-load WASM:\", err)\n } finally {\n this._wasmLoading = false\n }\n }\n\n connectedCallback() {\n const shadow = this.attachShadow({ mode: \"open\" })\n const container = document.createElement(\"div\")\n container.style.width = \"100%\"\n container.style.height = \"100%\"\n shadow.appendChild(container)\n this._root = createRoot(container)\n\n // Recover properties set before custom element upgrade.\n // When the element is created in HTML before customElements.define() runs,\n // property assignments (el.request = {...}) become own-properties on the\n // HTMLElement instance and bypass the class setters. We must pick them up.\n for (const prop of [\"request\", \"wasmModule\"] as const) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = (this as any)[prop]\n delete (this as any)[prop] // remove own-property so setter is reachable\n ;(this as any)[prop] = value // re-assign through the class setter\n }\n }\n\n // Parse request from attribute if set before connection\n const attrValue = this.getAttribute(\"request\")\n if (attrValue && !this._request) {\n try {\n this._request = JSON.parse(attrValue)\n } catch {\n console.error(\"[GirthManagerWidget] Invalid JSON in request attribute\")\n }\n }\n\n // Auto-load WASM from bundle if not externally provided\n if (this._request && !this._wasmModule) {\n this._autoLoadWasm()\n }\n\n this._render()\n }\n\n disconnectedCallback() {\n this._root?.unmount()\n this._root = null\n }\n\n /**\n * Reset the widget to its initial state without removing it from the DOM.\n * Unmounts and re-mounts the React tree, clearing all internal state\n * (Zustand store, WASM memory, landmarks, measurements).\n *\n * Usage in Angular:\n * this.widgetEl.nativeElement.reset();\n * this.widgetEl.nativeElement.request = { ... }; // re-initialize\n */\n reset() {\n if (!this._root) return\n // Unmount the current React tree (clears all component state)\n this._root.unmount()\n // Re-create the root on the same container\n const container = this.shadowRoot?.querySelector(\"div\")\n if (container) {\n this._root = createRoot(container)\n }\n this._request = null\n // Keep _wasmModule — it's reusable across resets\n }\n\n attributeChangedCallback(name: string, _oldValue: string, newValue: string) {\n if (name === \"request\" && newValue) {\n try {\n this._request = JSON.parse(newValue)\n this._render()\n } catch {\n console.error(\"[GirthManagerWidget] Invalid JSON in request attribute\")\n }\n }\n }\n\n private _handleComplete = (response: WidgetResponse) => {\n this.dispatchEvent(\n new CustomEvent(\"widgetComplete\", {\n detail: response,\n bubbles: true,\n composed: true,\n })\n )\n }\n\n private _render() {\n if (!this._root || !this._request) return\n\n this._root.render(\n createElement(GirthManagerWidget, {\n request: this._request,\n onComplete: this._handleComplete,\n wasmModule: this._wasmModule,\n })\n )\n }\n}\n\n// Register the custom element\nif (!customElements.get(\"girth-manager-widget\")) {\n customElements.define(\"girth-manager-widget\", GirthManagerWidgetElement)\n}\n\nexport { GirthManagerWidgetElement }\nexport type { WidgetRequest, WidgetResponse }\n"],"names":["GirthManagerWidgetElement","response","value","wasm","err","shadow","container","createRoot","prop","attrValue","name","_oldValue","newValue","createElement","GirthManagerWidget"],"mappings":";;;AAoBA,MAAMA,UAAkC,YAAY;AAAA,EAApD,cAAA;AAAA,UAAA,GAAA,SAAA,GACI,KAAQ,QAAqB,MAC7B,KAAQ,WAAiC,MAEzC,KAAQ,cAAmB,QAC3B,KAAQ,eAAe,IAkIvB,KAAQ,kBAAkB,CAACC,MAA6B;AACpD,WAAK;AAAA,QACD,IAAI,YAAY,kBAAkB;AAAA,UAC9B,QAAQA;AAAA,UACR,SAAS;AAAA,UACT,UAAU;AAAA,QAAA,CACb;AAAA,MAAA;AAAA,IAET;AAAA,EAAA;AAAA,EAxIA,WAAW,qBAAqB;AAC5B,WAAO,CAAC,SAAS;AAAA,EACrB;AAAA,EAEA,IAAI,UAAgC;AAChC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,QAAQC,GAAsC;AAC9C,QAAI,OAAOA,KAAU;AACjB,UAAI;AACA,aAAK,WAAW,KAAK,MAAMA,CAAK;AAAA,MACpC,QAAQ;AACJ,gBAAQ,MAAM,4DAA4DA,CAAK;AAC/E;AAAA,MACJ;AAAA;AAEA,WAAK,WAAWA;AAGpB,IAAI,KAAK,YAAY,CAAC,KAAK,eACvB,KAAK,cAAA,GAET,KAAK,QAAA;AAAA,EACT;AAAA;AAAA,EAGA,IAAI,aAAa;AACb,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IA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