@solid-labs/fab-one-widget 1.0.0 → 1.0.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/{GirthManagerWidget-DF3c7L2P.js → GirthManagerWidget-CwgHrdSO.js} +1608 -1559
- package/dist/{GirthManagerWidget-DF3c7L2P.js.map → GirthManagerWidget-CwgHrdSO.js.map} +1 -1
- package/dist/geo_wasm-CDwm1q1Z.js +1032 -0
- package/dist/geo_wasm-CDwm1q1Z.js.map +1 -0
- package/dist/geo_wasm.d.ts +529 -0
- package/dist/geo_wasm.js +1686 -0
- package/dist/geo_wasm_bg.wasm +0 -0
- package/dist/girth-manager-web-widget/src/GirthManagerWidget.d.ts +2 -2
- package/dist/girth-manager-web-widget/src/web-component.d.ts +10 -7
- package/dist/index.js +1 -1
- package/dist/web-component.js +84 -74
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
|
Binary file
|
|
@@ -5,7 +5,7 @@ export interface GirthManagerWidgetProps {
|
|
|
5
5
|
request: WidgetRequest;
|
|
6
6
|
/** Called when "Continue to Next Step" is clicked with the full response payload */
|
|
7
7
|
onComplete?: (response: WidgetResponse) => void;
|
|
8
|
-
/** Pre-loaded WASM module
|
|
8
|
+
/** Pre-loaded WASM module (optional — auto-loaded from bundle if not set). */
|
|
9
9
|
wasmModule?: WasmModule | null;
|
|
10
10
|
}
|
|
11
|
-
export declare const GirthManagerWidget: ({ request, onComplete, wasmModule }: GirthManagerWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const GirthManagerWidget: ({ request, onComplete, wasmModule: externalWasm }: GirthManagerWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import type { WidgetRequest, WidgetResponse } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
* Custom Element wrapper for Angular integration.
|
|
3
|
+
* Custom Element wrapper for Angular / vanilla JS integration.
|
|
4
|
+
*
|
|
5
|
+
* WASM is loaded automatically from the bundled package — no manual
|
|
6
|
+
* loading required. Just set the `request` property:
|
|
4
7
|
*
|
|
5
8
|
* Usage in Angular:
|
|
6
|
-
* // In the component class:
|
|
7
9
|
* async ngAfterViewInit() {
|
|
8
|
-
* const wasm = await import('geo-wasm');
|
|
9
|
-
* await wasm.default();
|
|
10
|
-
* this.widgetEl.nativeElement.wasmModule = wasm;
|
|
11
10
|
* this.widgetEl.nativeElement.request = { spacing_type: 'BK', scan_url: '...' };
|
|
12
11
|
* }
|
|
13
12
|
*
|
|
14
|
-
* // In the template:
|
|
15
13
|
* <girth-manager-widget #widgetEl (widgetComplete)="onComplete($event)"></girth-manager-widget>
|
|
14
|
+
*
|
|
15
|
+
* To provide your own WASM module (advanced), set `wasmModule` before `request`.
|
|
16
16
|
*/
|
|
17
17
|
declare class GirthManagerWidgetElement extends HTMLElement {
|
|
18
18
|
private _root;
|
|
19
19
|
private _request;
|
|
20
20
|
private _wasmModule;
|
|
21
|
+
private _wasmLoading;
|
|
21
22
|
static get observedAttributes(): string[];
|
|
22
23
|
get request(): WidgetRequest | null;
|
|
23
24
|
set request(value: WidgetRequest | string | null);
|
|
24
|
-
/** Set
|
|
25
|
+
/** Set a pre-loaded WASM module (optional — auto-loaded from bundle if not set). */
|
|
25
26
|
get wasmModule(): unknown;
|
|
26
27
|
set wasmModule(value: unknown);
|
|
28
|
+
/** Auto-load WASM from the bundled package export */
|
|
29
|
+
private _autoLoadWasm;
|
|
27
30
|
connectedCallback(): void;
|
|
28
31
|
disconnectedCallback(): void;
|
|
29
32
|
/**
|
package/dist/index.js
CHANGED
package/dist/web-component.js
CHANGED
|
@@ -1,94 +1,104 @@
|
|
|
1
1
|
import { createElement as i } from "react";
|
|
2
|
-
import { createRoot as
|
|
3
|
-
import { G as o } from "./GirthManagerWidget-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { createRoot as r } from "react-dom/client";
|
|
3
|
+
import { G as o, __tla as __tla_0 } from "./GirthManagerWidget-CwgHrdSO.js";
|
|
4
|
+
let a;
|
|
5
|
+
let __tla = Promise.all([
|
|
6
|
+
(() => {
|
|
7
|
+
try {
|
|
8
|
+
return __tla_0;
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
})()
|
|
12
|
+
]).then(async () => {
|
|
13
|
+
a = class extends HTMLElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this._root = null, this._request = null, this._wasmModule = void 0, this._wasmLoading = false, this._handleComplete = (t) => {
|
|
16
|
+
this.dispatchEvent(new CustomEvent("widgetComplete", {
|
|
9
17
|
detail: t,
|
|
10
18
|
bubbles: true,
|
|
11
19
|
composed: true
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
try {
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static get observedAttributes() {
|
|
24
|
+
return [
|
|
25
|
+
"request"
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
get request() {
|
|
29
|
+
return this._request;
|
|
30
|
+
}
|
|
31
|
+
set request(t) {
|
|
32
|
+
if (typeof t == "string") try {
|
|
25
33
|
this._request = JSON.parse(t);
|
|
26
34
|
} catch {
|
|
27
35
|
console.error("[GirthManagerWidget] Invalid JSON for request attribute:", t);
|
|
28
36
|
return;
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
this._request
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
else this._request = t;
|
|
39
|
+
this._request && !this._wasmModule && this._autoLoadWasm(), this._render();
|
|
40
|
+
}
|
|
41
|
+
get wasmModule() {
|
|
42
|
+
return this._wasmModule;
|
|
43
|
+
}
|
|
44
|
+
set wasmModule(t) {
|
|
45
|
+
this._wasmModule = t, this._render();
|
|
46
|
+
}
|
|
47
|
+
async _autoLoadWasm() {
|
|
48
|
+
if (!(this._wasmModule || this._wasmLoading)) {
|
|
49
|
+
this._wasmLoading = true;
|
|
50
|
+
try {
|
|
51
|
+
const t = await import("./geo_wasm-CDwm1q1Z.js");
|
|
52
|
+
await t.default(), this._wasmModule = t, this._render();
|
|
53
|
+
} catch (t) {
|
|
54
|
+
console.error("[GirthManagerWidget] Failed to auto-load WASM:", t);
|
|
55
|
+
} finally {
|
|
56
|
+
this._wasmLoading = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
const t = this.attachShadow({
|
|
62
|
+
mode: "open"
|
|
63
|
+
}), e = document.createElement("div");
|
|
64
|
+
e.style.width = "100%", e.style.height = "100%", t.appendChild(e), this._root = r(e);
|
|
65
|
+
const s = this.getAttribute("request");
|
|
66
|
+
if (s && !this._request) try {
|
|
67
|
+
this._request = JSON.parse(s);
|
|
48
68
|
} catch {
|
|
49
69
|
console.error("[GirthManagerWidget] Invalid JSON in request attribute");
|
|
50
70
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var _a;
|
|
68
|
-
if (!this._root) return;
|
|
69
|
-
this._root.unmount();
|
|
70
|
-
const t = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("div");
|
|
71
|
-
t && (this._root = s(t)), this._request = null, this._wasmModule = void 0;
|
|
72
|
-
}
|
|
73
|
-
attributeChangedCallback(t, e, r) {
|
|
74
|
-
if (t === "request" && r)
|
|
75
|
-
try {
|
|
76
|
-
this._request = JSON.parse(r), this._render();
|
|
71
|
+
this._request && !this._wasmModule && this._autoLoadWasm(), this._render();
|
|
72
|
+
}
|
|
73
|
+
disconnectedCallback() {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = this._root) == null ? void 0 : _a.unmount(), this._root = null;
|
|
76
|
+
}
|
|
77
|
+
reset() {
|
|
78
|
+
var _a;
|
|
79
|
+
if (!this._root) return;
|
|
80
|
+
this._root.unmount();
|
|
81
|
+
const t = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("div");
|
|
82
|
+
t && (this._root = r(t)), this._request = null;
|
|
83
|
+
}
|
|
84
|
+
attributeChangedCallback(t, e, s) {
|
|
85
|
+
if (t === "request" && s) try {
|
|
86
|
+
this._request = JSON.parse(s), this._render();
|
|
77
87
|
} catch {
|
|
78
88
|
console.error("[GirthManagerWidget] Invalid JSON in request attribute");
|
|
79
89
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
i(o, {
|
|
90
|
+
}
|
|
91
|
+
_render() {
|
|
92
|
+
!this._root || !this._request || this._root.render(i(o, {
|
|
84
93
|
request: this._request,
|
|
85
94
|
onComplete: this._handleComplete,
|
|
86
95
|
wasmModule: this._wasmModule
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
customElements.get("girth-manager-widget") || customElements.define("girth-manager-widget", a);
|
|
100
|
+
});
|
|
92
101
|
export {
|
|
93
|
-
|
|
102
|
+
a as GirthManagerWidgetElement,
|
|
103
|
+
__tla
|
|
94
104
|
};
|
|
@@ -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 integration.\n *\n *
|
|
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,IAsHvB,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,EA5HA,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,IAAI,WAAWA,GAAgB;AAC3B,SAAK,cAAcA,GACnB,KAAK,QAAA;AAAA,EACT;AAAA;AAAA,EAGA,MAAc,gBAAgB;AAC1B,QAAI,OAAK,eAAe,KAAK,eAC7B;AAAA,WAAK,eAAe;AACpB,UAAI;AACA,c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