@druid-ui/host 1.0.10 → 1.0.12
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/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui.js +7 -5
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/host-functions.ts +1 -1
- package/src/ui.ts +11 -5
- package/src/window.ts +0 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;IACE,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;IACE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;IACE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACxE;AAED;gBAOI,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,WAAW,EACzB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;cAOzB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC;IA+DlB,IA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G,MAAM,GAAG,EAAE,wDAiBvB,CAAC;AChCF;IACE,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;IACpC,EAAE,EAAE,MAAM,EAAE,CAAC;CACd;AAGD,oBAAoB,GAAG,EAAE,MAAM,QAG9B;AAED,oBAAqB,SAAQ,WAAW;IAe/B,iBAAiB;IASjB,oBAAoB;IAIpB,eAAe;IAqCf,UAAU,IAAI,WAAW;IAGhC,IAAI,UAAU,CAAC,MAAM,EAAE,cAAc,EAGpC;IAED,IAAI,eAAe,CAAC,GAAG,EAAE,MAAM,EAE9B;IACD,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAGhC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAG3B;IAED,IAAI,aAAa,CAAC,QAAQ,EAAE,eAAe,EAG1C;IAED,MAAM,KAAK,kBAAkB,aAE5B;IAED,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM;;IA4FZ,+BAA+B,CAAC,UAAU,EAAE,MAAM;IAwDlD,yBAAyB,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,MAAM,CAAC;IAa7D,QAAQ;CA+DT;AC5VD,QAAQ,MAAM,CAAC;IACb,UAAU,MAAM;QACd,iBAAiB,CAAC,EAAE,QAAQ,CAAC;KAC9B;CACF","sources":["packages/host/src/src/file-loader.ts","packages/host/src/src/setup-snabbdom.ts","packages/host/src/src/routing-strategy.ts","packages/host/src/src/transpile.ts","packages/host/src/src/types.ts","packages/host/src/src/host-functions.ts","packages/host/src/src/utils.ts","packages/host/src/src/ui.ts","packages/host/src/src/window.ts","packages/host/src/src/index.ts","packages/host/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"// Re-export everything for easy access\nexport * from \"./ui\";\nexport * from \"./types\";\nexport * from \"./file-loader\";\nexport * from \"./routing-strategy\";\nexport * from \"./transpile\";\nexport * from \"./utils\";\n\n// Global Window augmentation (side-effect import for declaration output)\nimport \"./window\";\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/ui.js
CHANGED
|
@@ -263,7 +263,7 @@ function $0e97ad6bdcaa9a3e$export$2bfbd9808f953be9(element, props, children) {
|
|
|
263
263
|
return id;
|
|
264
264
|
}
|
|
265
265
|
function $0e97ad6bdcaa9a3e$export$f570cabd7d9ab9b(msg) {
|
|
266
|
-
console.
|
|
266
|
+
console.log("UI LOG:", msg);
|
|
267
267
|
}
|
|
268
268
|
function $0e97ad6bdcaa9a3e$export$431694b633b87558(id, emitEvent, navigate) {
|
|
269
269
|
const node = $0e97ad6bdcaa9a3e$var$nodes.get(id);
|
|
@@ -504,9 +504,6 @@ class $7ecf692fb720ca8d$export$6874335aa33ac2fe extends HTMLElement {
|
|
|
504
504
|
// Capture the generation at the start of this load
|
|
505
505
|
const loadGeneration = this.reloadGeneration;
|
|
506
506
|
console.debug(`[loadEntrypointFromJavaScriptUrl] Starting load for generation ${loadGeneration}`);
|
|
507
|
-
window["druid-ui"] = {
|
|
508
|
-
d: (0, $0e97ad6bdcaa9a3e$export$2bfbd9808f953be9)
|
|
509
|
-
};
|
|
510
507
|
window["druid-extension"] = this.getExtensionObject();
|
|
511
508
|
// Force no-cache to get fresh content
|
|
512
509
|
const response = await this.loader.load(entrypoint, {
|
|
@@ -532,7 +529,12 @@ class $7ecf692fb720ca8d$export$6874335aa33ac2fe extends HTMLElement {
|
|
|
532
529
|
this.rootComponent = t;
|
|
533
530
|
// Reset VNode right before rendering new module to ensure hooks fire
|
|
534
531
|
// This must be done here (not in reloadComponent) to avoid race conditions
|
|
535
|
-
// with pending rerenders from previous module
|
|
532
|
+
// with pending rerenders from previous module.
|
|
533
|
+
// After the first render, snabbdom's patch() replaces mountEl in the DOM
|
|
534
|
+
// with the VNode element, leaving mountEl detached. We must restore it
|
|
535
|
+
// so the next patch(mountEl, dom) can insert the new element.
|
|
536
|
+
if (this.currentVNode?.elm?.parentNode) this.currentVNode.elm.parentNode.replaceChild(this.mountEl, this.currentVNode.elm);
|
|
537
|
+
this.mountEl.innerHTML = "";
|
|
536
538
|
this.currentVNode = null;
|
|
537
539
|
console.debug(`[loadEntrypointFromJavaScriptUrl] Rendering generation ${loadGeneration}`);
|
|
538
540
|
this.rerender();
|
package/dist/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA,uCAAuC;;;;;;;;AEyBhC,MAAM;IAMX,YACE,OAAgB,EAChB,WAAyB,EACzB,cAAuC,CACvC;QACA,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,cAAc,GAAG;IACxB;IAEA,MAAgB,SACd,IAAY,EACZ,OAA2B,EACJ;QACvB,MAAM,UAAkC;YACtC,GAAG,IAAI,CAAC,cAAc;YACtB,GAAG,SAAS,OAAO;QACrB;QAEA,mFAAmF;QACnF,MAAM,YAAY,SAAS,QAAQ,IAAI,CAAC,WAAW;QAEnD,6BAA6B;QAC7B,IAAI,WACF,OAAQ,UAAU,IAAI;YACpB,KAAK;gBACH,IAAI,UAAU,KAAK,EACjB,OAAO,CAAC,gBAAgB,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,EAAE;gBAExD;YACF,KAAK;gBACH,IAAI,UAAU,QAAQ,IAAI,UAAU,QAAQ,EAAE;oBAC5C,MAAM,cAAc,KAClB,GAAG,UAAU,QAAQ,CAAC,CAAC,EAAE,UAAU,QAAQ,EAAE;oBAE/C,OAAO,CAAC,gBAAgB,GAAG,CAAC,MAAM,EAAE,aAAa;gBACnD;gBACA;YACF,KAAK;gBACH,IAAI,UAAU,MAAM,EAAE;oBACpB,MAAM,aAAa,UAAU,YAAY,IAAI;oBAC7C,OAAO,CAAC,WAAW,GAAG,UAA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,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,YAAY,YAAY,GAAG;YACjC,QAAQ,KAAK,CACX,CAAC,oBAAoB,EAAE,AAAC,CAAA,YAAY,WAAW,EAAG,OAAO,CAAC,GAAG,GAAG,CAAC;QAErE;IACF;AACF;AAEA,eAAe,MAAM,CAAC,YAAY;;;;;;;;AQ7VlC,mDAAmD;AACnD,2EAA2E;;","sources":["packages/host/src/index.ts","packages/host/src/ui.ts","packages/host/src/file-loader.ts","packages/host/src/setup-snabbdom.ts","packages/host/src/routing-strategy.ts","packages/host/src/transpile.ts","packages/host/src/host-functions.ts","packages/host/src/types.ts","packages/host/src/utils.ts","packages/host/src/window.ts"],"sourcesContent":["// Re-export everything for easy access\nexport * from \"./ui\";\nexport * from \"./types\";\nexport * from \"./file-loader\";\nexport * from \"./routing-strategy\";\nexport * from \"./transpile\";\nexport * from \"./utils\";\n\n// Global Window augmentation (side-effect import for declaration output)\nimport \"./window\";\n","import { HttpFileLoader } from \"./file-loader\";\nimport { patch } from \"./setup-snabbdom\";\nimport { type VNode } from \"snabbdom\";\nimport {\n HistoryRoutingStrategy,\n type RoutingStrategy,\n} from \"./routing-strategy\";\nimport { loadTranspile } from \"./transpile\";\nimport {\n clearNodes,\n createDomFromIdRec,\n dfunc,\n logfunc,\n setHook,\n} from \"./host-functions\";\nimport { Event } from \"./types\";\nimport { setCb } from \"./utils\";\n\nexport interface Props {\n prop: { key: string; value: any }[];\n on: string[]; // [eventType, fnid]\n}\n\n// Dev-time log function exposed for components importing from \"druid:ui/ui\".\nexport function log(msg: string) {\n // Reuse internal logfunc for consistent labeling.\n logfunc(msg);\n}\n\nexport class DruidUI extends HTMLElement {\n private shadow: ShadowRoot;\n private wrapperEl: HTMLElement;\n private mountEl: HTMLElement;\n private profile: boolean = false;\n private currentVNode: VNode | null = null;\n private _routeStrategy: RoutingStrategy = new HistoryRoutingStrategy();\n private loader = new HttpFileLoader();\n private _sandbox: boolean = true;\n private _extensionObject: object = {};\n private _entrypoint?: string;\n private rootComponent: any;\n private _connected: boolean = false;\n private reloadGeneration: number = 0;\n\n public connectedCallback() {\n this._connected = true;\n if (this.rootComponent) {\n this.rerender();\n return;\n }\n this.reloadComponent();\n }\n\n public disconnectedCallback() {\n this._connected = false;\n }\n\n public reloadComponent() {\n if (!this._connected) {\n console.warn(\"Component not connected, skipping reload.\");\n return;\n }\n const entrypoint = this._entrypoint;\n if (!entrypoint) {\n console.warn(\"No entrypoint attribute set.\");\n return;\n }\n if (!this.loader) {\n console.warn(\"No file loader set.\");\n return;\n }\n\n // Increment generation to invalidate all pending operations from previous load\n this.reloadGeneration++;\n console.debug(\n `[reloadComponent] Starting reload, generation: ${this.reloadGeneration}`,\n );\n\n // Clear nodes map to ensure fresh state\n clearNodes();\n\n if (this._sandbox) {\n loadTranspile(entrypoint, this.loader)\n .then(([moduleUrl, compile]) => {\n this.loadEntrypointFromWasmUrl(moduleUrl, compile);\n })\n .catch((e) => {\n console.error(\"Failed to load and transpile entrypoint:\", e);\n });\n } else {\n this.loadEntrypointFromJavaScriptUrl(entrypoint);\n }\n }\n\n public getWrapper(): HTMLElement {\n return this.wrapperEl;\n }\n set fileloader(loader: HttpFileLoader) {\n this.loader = loader;\n this.reloadComponent();\n }\n\n set extensionObject(obj: object) {\n this._extensionObject = obj;\n }\n set entrypoint(entrypoint: string) {\n this._entrypoint = entrypoint;\n this.reloadComponent();\n }\n\n set sandbox(sandbox: boolean) {\n this._sandbox = sandbox;\n this.reloadComponent();\n }\n\n set routeStrategy(strategy: RoutingStrategy) {\n this._routeStrategy = strategy;\n this.rerender();\n }\n\n static get observedAttributes() {\n return [\"entrypoint\", \"path\", \"profile\", \"css\", \"style\", \"no-sandbox\"];\n }\n\n attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string,\n ) {\n switch (name) {\n case \"no-sandbox\":\n this._sandbox = newValue !== \"true\";\n break;\n case \"entrypoint\":\n this.entrypoint = newValue;\n break;\n case \"path\":\n if (oldValue) {\n this.rerender();\n }\n break;\n case \"profile\":\n this.profile = newValue === \"true\";\n break;\n case \"style\":\n const htmlString = newValue;\n const styleEl = document.createElement(\"style\");\n styleEl.textContent = htmlString.trim();\n\n // Insert style after all link elements\n const lastLink = Array.from(\n this.shadow.querySelectorAll('link[rel=\"stylesheet\"]'),\n ).pop();\n //clear previous style elements\n const existingStyles = this.shadow.querySelectorAll(\"style\");\n existingStyles.forEach((style) => style.remove());\n\n if (lastLink) {\n this.shadow.insertBefore(styleEl, lastLink.nextSibling);\n } else {\n this.shadow.insertBefore(\n styleEl,\n this.shadowRoot?.firstChild || null,\n );\n }\n break;\n case \"css\":\n const css = newValue.split(\",\");\n //clear previous css links\n const existingLinks = this.shadow.querySelectorAll(\n 'link[rel=\"stylesheet\"]',\n );\n existingLinks.forEach((link) => link.remove());\n\n for (const comp of css) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = comp;\n this.shadow.insertBefore(link, this.shadowRoot?.firstChild || null);\n }\n break;\n }\n }\n\n constructor() {\n super();\n this.shadow = this.attachShadow({ mode: \"open\" });\n\n this.wrapperEl = document.createElement(\"div\");\n this.wrapperEl.classList.add(\"druid-wrapper\");\n this.mountEl = document.createElement(\"div\");\n this.mountEl.classList.add(\"druid-mount\");\n this.mountEl.innerText = \"Transpiling...\";\n\n this.wrapperEl.appendChild(this.mountEl);\n this.shadow.appendChild(this.wrapperEl);\n }\n\n private getExtensionObject() {\n return {\n \"druid:ui/ui\": {\n d: (element: string, props: Props, children: string[]) => {\n return dfunc(element, props, children);\n },\n log: (msg: string) => {\n logfunc(msg);\n },\n rerender: () => {\n setTimeout(() => this.rerender(), 0);\n },\n setHook: setHook,\n },\n \"druid:ui/utils\": {\n Event: Event,\n },\n ...this._extensionObject,\n };\n }\n\n async loadEntrypointFromJavaScriptUrl(entrypoint: string) {\n // Capture the generation at the start of this load\n const loadGeneration = this.reloadGeneration;\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Starting load for generation ${loadGeneration}`,\n );\n\n window[\"druid-ui\"] = {\n d: dfunc,\n };\n\n window[\"druid-extension\"] = this.getExtensionObject();\n\n // Force no-cache to get fresh content\n const response = await this.loader.load(entrypoint, { cache: false });\n const bundleContent = response.buffer;\n\n // Create blob URL to avoid Vite's /public restrictions\n const blob = new Blob([bundleContent], { type: \"application/javascript\" });\n const moduleUrl = URL.createObjectURL(blob);\n const t = await import(/* @vite-ignore */ moduleUrl);\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Module loaded for generation ${loadGeneration}, current generation: ${this.reloadGeneration}`,\n );\n\n setCb(t.component.asyncComplete);\n\n // Only proceed if no newer reload has been triggered\n if (this.reloadGeneration !== loadGeneration) {\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Aborting stale load (generation ${loadGeneration}, current: ${this.reloadGeneration})`,\n );\n URL.revokeObjectURL(moduleUrl);\n return;\n }\n\n this.rootComponent = t;\n\n // Reset VNode right before rendering new module to ensure hooks fire\n // This must be done here (not in reloadComponent) to avoid race conditions\n // with pending rerenders from previous module\n this.currentVNode = null;\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Rendering generation ${loadGeneration}`,\n );\n\n this.rerender();\n URL.revokeObjectURL(moduleUrl);\n }\n\n async loadEntrypointFromWasmUrl(\n entrypoint: string,\n loadCompile?: (file: string) => Promise<WebAssembly.Module>,\n ) {\n const t = await import(/* @vite-ignore */ entrypoint!);\n\n URL.revokeObjectURL(entrypoint);\n\n const i = await t.instantiate(loadCompile, this.getExtensionObject());\n setCb(i.component.asyncComplete);\n\n this.rootComponent = i;\n this.rerender();\n }\n\n rerender() {\n if (!this.rootComponent) {\n console.warn(\"Root component not initialized yet.\");\n return;\n }\n let renderStart;\n if (this.profile) {\n // Start profiling\n renderStart = performance.now();\n }\n\n const rootId = this.rootComponent.component.init({\n path: this._routeStrategy.getCurrentPath(),\n });\n\n if (this.profile) {\n const initEnd = performance.now();\n console.debug(\n `Init completed in ${(initEnd - renderStart!).toFixed(2)} ms`,\n );\n }\n\n this.mountEl.innerHTML = \"\";\n const dom = createDomFromIdRec(\n rootId,\n (nodeId, eventType, e) => {\n this.rootComponent.component.emit(nodeId, eventType, e);\n // Capture the current generation\n const generation = this.reloadGeneration;\n setTimeout(() => {\n // Only rerender if we're still in the same generation (no reload happened)\n if (this.reloadGeneration === generation) {\n this.rerender();\n } else {\n console.debug(\n `[setTimeout] Skipping stale rerender (generation ${generation}, current: ${this.reloadGeneration})`,\n );\n }\n }, 0);\n },\n (href: string) => {\n this._routeStrategy.navigateTo(href);\n this.rerender();\n },\n );\n\n if (dom instanceof String) {\n console.warn(\"Root DOM is a string, cannot render:\", dom);\n return;\n }\n if (this.currentVNode) {\n patch(this.currentVNode, dom);\n } else {\n patch(this.mountEl, dom);\n }\n this.currentVNode = dom;\n if (this.profile) {\n const renderEnd = performance.now();\n console.debug(\n `Render completed in ${(renderEnd - renderStart!).toFixed(2)} ms`,\n );\n }\n }\n}\n\ncustomElements.define(\"druid-ui\", DruidUI);\n","interface AuthOptions {\n type: \"bearer\" | \"basic\" | \"api-key\";\n token?: string;\n username?: string;\n password?: string;\n apiKey?: string;\n apiKeyHeader?: string;\n}\n\ninterface FileLoaderOptions {\n auth?: AuthOptions;\n headers?: Record<string, string>;\n cache?: boolean;\n}\n\ninterface HttpResponse {\n buffer: ArrayBuffer;\n headers: Record<string, string>;\n contentType: string | null;\n}\n\nexport interface FileLoader {\n load(path: string, options?: FileLoaderOptions): Promise<HttpResponse>;\n}\n\nexport class HttpFileLoader {\n private authOptions?: AuthOptions | undefined;\n private defaultHeaders?: Record<string, string> | undefined;\n\n private baseUrl?: string | undefined;\n\n constructor(\n baseUrl?: string,\n authOptions?: AuthOptions,\n defaultHeaders?: Record<string, string>\n ) {\n this.baseUrl = baseUrl;\n this.authOptions = authOptions;\n this.defaultHeaders = defaultHeaders;\n }\n\n protected async loadHttp(\n path: string,\n options?: FileLoaderOptions\n ): Promise<HttpResponse> {\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n ...options?.headers,\n };\n\n // Use instance auth options if no options provided, or merge with provided options\n const authToUse = options?.auth || this.authOptions;\n\n // Add authentication headers\n if (authToUse) {\n switch (authToUse.type) {\n case \"bearer\":\n if (authToUse.token) {\n headers[\"Authorization\"] = `Bearer ${authToUse.token}`;\n }\n break;\n case \"basic\":\n if (authToUse.username && authToUse.password) {\n const credentials = btoa(\n `${authToUse.username}:${authToUse.password}`\n );\n headers[\"Authorization\"] = `Basic ${credentials}`;\n }\n break;\n case \"api-key\":\n if (authToUse.apiKey) {\n const headerName = authToUse.apiKeyHeader || \"X-API-Key\";\n headers[headerName] = authToUse.apiKey;\n }\n break;\n }\n }\n\n const res = await fetch(path, {\n headers,\n cache: options?.cache === false ? \"no-store\" : \"default\",\n });\n\n if (!res.ok) {\n throw new Error(`Failed to load file: ${path}, status: ${res.status}`);\n }\n\n // Extract all fetch-specific data\n const text = await res.arrayBuffer();\n\n const responseHeaders: Record<string, string> = {};\n // Handle both real Headers object and mocked headers\n if (res.headers && typeof res.headers.forEach === \"function\") {\n res.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n }\n\n const contentType = res.headers.get(\"Content-Type\");\n\n return {\n buffer: text,\n headers: responseHeaders,\n contentType,\n };\n }\n\n async load(path: string, options?: FileLoaderOptions) {\n const filePath = this.baseUrl ? `${this.baseUrl}/${path}` : path;\n const response = await this.loadHttp(filePath, options);\n return response;\n }\n}\n","import {\n init,\n classModule,\n propsModule,\n styleModule,\n eventListenersModule,\n} from \"snabbdom\";\n\nexport const patch = init([\n // Init patch function with chosen modules\n classModule, // makes it easy to toggle classes\n propsModule, // for setting properties on DOM elements\n styleModule, // handles styling on elements with support for animations\n eventListenersModule, // attaches event listeners\n]);\n","export interface RoutingStrategy {\n getCurrentPath(): string;\n navigateTo(path: string): void;\n}\n\nexport class HistoryRoutingStrategy implements RoutingStrategy {\n getCurrentPath(): string {\n return window.location.pathname;\n }\n\n navigateTo(path: string): void {\n window.history.pushState({}, \"\", path);\n }\n}\n\nexport class CustomRoutingStrategy implements RoutingStrategy {\n private currentPath: string = \"/\";\n\n getCurrentPath(): string {\n return this.currentPath;\n }\n\n navigateTo(path: string): void {\n this.currentPath = path;\n }\n}\n\nexport const createRoutingStrategy = (\n mode: \"history\" | \"custom\"\n): RoutingStrategy => {\n if (mode === \"custom\") {\n return new CustomRoutingStrategy();\n } else {\n return new HistoryRoutingStrategy();\n }\n};\n","import type { FileLoader } from \"./file-loader\";\n\ninterface TranspileResult {\n files: Array<[string, Uint8Array]>;\n}\n\ninterface CacheEntry {\n jsUrl: string;\n fileUrls: Record<string, string>;\n}\n\nconst CACHE_KEY_PREFIX = \"transpile_cache_\";\n\n// Helper functions for localStorage caching\nconst getCachedEntry = (file: string): CacheEntry | null => {\n try {\n const cached = localStorage.getItem(CACHE_KEY_PREFIX + file);\n if (cached) {\n return JSON.parse(cached);\n }\n } catch (e) {\n console.warn(\"Failed to read from cache:\", e);\n }\n return null;\n};\n\nconst setCachedEntry = (file: string, entry: CacheEntry): void => {\n try {\n localStorage.setItem(CACHE_KEY_PREFIX + file, JSON.stringify(entry));\n } catch (e) {\n console.warn(\"Failed to write to cache:\", e);\n }\n};\n\nconst transpileInWorker = async (\n buffer: ArrayBuffer,\n name: string,\n): Promise<TranspileResult> => {\n return new Promise((resolve, reject) => {\n const worker = new Worker(\n new URL(\"./transpile.worker.ts\", import.meta.url),\n { type: \"module\" },\n );\n\n worker.onmessage = (event: MessageEvent) => {\n worker.terminate();\n if (event.data.success) {\n resolve(event.data.data);\n } else {\n reject(new Error(event.data.error));\n }\n };\n\n worker.onerror = (error) => {\n worker.terminate();\n reject(error);\n };\n\n // Transfer the buffer ownership to the worker (zero-copy)\n worker.postMessage({ buffer, name }, [buffer]);\n });\n};\n\nexport const loadTranspile = async (\n file: string,\n fileLoader: FileLoader,\n): Promise<[string, (filename: string) => Promise<WebAssembly.Module>]> => {\n // Check cache first\n const cached = getCachedEntry(file);\n if (cached) {\n // Verify URLs are still valid\n try {\n await fetch(cached.jsUrl, { method: \"HEAD\" });\n return [\n cached.jsUrl,\n async (filename: string) => {\n const url = cached.fileUrls[filename];\n if (!url) {\n throw new Error(`File ${filename} not found in transpiled output.`);\n }\n const wasmResponse = await fetch(url);\n const wasmBuffer = await wasmResponse.arrayBuffer();\n return await WebAssembly.compile(wasmBuffer);\n },\n ];\n } catch (e) {\n // Cache is stale, proceed with transpilation\n console.warn(\"Cached URLs are stale, re-transpiling\");\n }\n }\n\n const response = await fileLoader.load(file);\n if (!response) {\n throw new Error(`Failed to load file: ${file}`);\n }\n const files: Record<string, string> = {};\n const t = await transpileInWorker(response.buffer, \"test\");\n\n for (const file of t.files) {\n const [f, content] = file as [string, Uint8Array];\n\n let blob: Blob | null = null;\n if (f.endsWith(\".js\")) {\n blob = new Blob([new Uint8Array(content)], {\n type: \"application/javascript\",\n });\n } else if (f.endsWith(\".wasm\")) {\n blob = new Blob([new Uint8Array(content)], {\n type: \"application/wasm\",\n });\n }\n if (blob) {\n const url = URL.createObjectURL(blob);\n files[f] = url;\n }\n }\n const jsFileEntry = Object.entries(files).find(([filename]) =>\n filename.endsWith(\".js\"),\n );\n if (!jsFileEntry) {\n throw new Error(\"No JavaScript file found in transpiled output.\");\n }\n\n // Cache the result\n const cacheEntry: CacheEntry = {\n jsUrl: jsFileEntry[1],\n fileUrls: files,\n };\n setCachedEntry(file, cacheEntry);\n\n return [\n jsFileEntry[1],\n async (filename: string) => {\n const url = files[filename];\n if (!url) {\n throw new Error(`File ${filename} not found in transpiled output.`);\n }\n const wasmResponse = await fetch(url);\n const wasmBuffer = await wasmResponse.arrayBuffer();\n return await WebAssembly.compile(wasmBuffer);\n },\n ];\n};\n","import type { Props } from \"druid:ui/ui\";\nimport { h, type VNode, type VNodeChildren, type VNodeData } from \"snabbdom\";\nimport { Event } from \"./types\";\n\nconst nodes = new Map<\n string,\n {\n element: string;\n props?: Props;\n children?: Array<string>;\n hooks?: string[];\n }\n>();\n\nexport function clearNodes() {\n console.debug(`[clearNodes] Clearing ${nodes.size} nodes`);\n nodes.clear();\n}\n\nexport function setHook(id: string, callback: string) {\n console.debug(`[setHook] Setting \"${callback}\" hook on node ${id}`);\n const node = nodes.get(id);\n if (node) {\n node.hooks = node.hooks || [];\n node.hooks.push(callback);\n }\n}\n\nexport function dfunc(element: string, props: Props, children: string[]) {\n const id = crypto.randomUUID();\n console.debug(`[dfunc] Creating node: element=\"${element}\", id=${id}`);\n\n nodes.set(id, { element, props, children });\n return id;\n}\n\nexport function logfunc(msg: string) {\n console.debug(\"UI LOG:\", msg);\n}\n\nexport function createDomFromIdRec(\n id: string,\n emitEvent: (id: string, eventType: string, event: Event) => void,\n navigate?: (href: string) => void,\n): VNode | String {\n const node = nodes.get(id);\n //it is a bit strange to do it like that, in theory we want to better distinguish between text nodes and element nodes\n if (!node) {\n console.debug(`[createDomFromIdRec] Text node: \"${id}\"`);\n return id;\n }\n\n const data: VNodeData = {};\n\n // Set properties\n if (node.props) {\n data.props = {};\n for (const prop of node.props.prop) {\n data.props[prop.key] = prop.value;\n }\n data.on = {};\n for (const eventType of node.props.on) {\n data.on[eventType] = (e) => {\n console.debug(`[event] \"${eventType}\" on node ${id}`);\n emitEvent(\n id,\n eventType,\n new Event(e?.currentTarget?.value, e?.currentTarget?.checked),\n );\n };\n }\n const href = data.props[\"href\"];\n if (href && !data.on[\"click\"]) {\n if (navigate) {\n data.on.click = (e) => {\n e.preventDefault();\n navigate(href);\n };\n }\n }\n }\n\n // Set hooks (outside props check so hooks work even without props)\n if (node.hooks && node.hooks.length > 0) {\n console.debug(\n `[createDomFromIdRec] Node ${id} has ${\n node.hooks.length\n } hooks: ${node.hooks.join(\", \")}`,\n );\n data.hook = {};\n for (const hookName of node.hooks) {\n data.hook[hookName as keyof typeof data.hook] = () => {\n console.debug(`[hook] \"${hookName}\" fired for node ${id}`);\n emitEvent(id, hookName, new Event());\n };\n }\n }\n const ch: VNodeChildren = [];\n if (node.children) {\n for (const childId of node.children) {\n const childEl = createDomFromIdRec(childId, emitEvent, navigate);\n ch.push(childEl);\n }\n }\n\n return h(node.element, data, ch);\n}\n","export class Event {\n private _value: string;\n private _checked: boolean;\n\n constructor(_value: string = \"\", _checked: boolean = false) {\n this._value = _value;\n this._checked = _checked;\n }\n\n preventDefault() {}\n stopPropagation() {}\n value() {\n return this._value;\n }\n checked() {\n return this._checked;\n }\n}\n","type Callback = (id: string, result: { tag: \"ok\" | \"err\"; val: any }) => void;\n\nlet cb: Callback | undefined;\n\nconst pending: Array<{ id: string; result: Parameters<Callback>[1] }> = [];\n\nconst dispatch = (id: string, result: Parameters<Callback>[1]) => {\n if (cb) {\n cb(id, result);\n return;\n }\n\n pending.push({ id, result });\n};\nexport const setCb = (\n callback: (id: string, result: { tag: \"ok\" | \"err\"; val: any }) => void,\n) => {\n cb = callback;\n\n if (pending.length === 0) {\n return;\n }\n\n // Flush any results that arrived before the callback was registered.\n while (pending.length > 0) {\n const { id, result } = pending.shift()!;\n cb(id, result);\n }\n};\n\nexport const PromiseToResult = <T>(\n promiseFn: (...args: any[]) => Promise<T>,\n) => {\n return (...args: any[]) => {\n const id = crypto.randomUUID();\n promiseFn(...args)\n .then((result) => {\n dispatch(id, {\n tag: \"ok\",\n val: result,\n });\n })\n .catch((error) => {\n dispatch(id, {\n tag: \"err\",\n val: error instanceof Error ? error.message : String(error),\n });\n });\n return id;\n };\n};\n","// Augment the Window interface to include 'druid'.\n// We define a lightweight shape for better intellisense; extend as needed.\n\ntype DruidAPI = Record<string, any>;\n\ndeclare global {\n interface Window {\n \"druid-ui\": {\n d: (...args: any[]) => any;\n };\n \"druid-extension\"?: DruidAPI;\n }\n}\n\n// Mark this file as a module so global augmentation is always applied reliably.\nexport {};\n"],"names":[],"version":3,"file":"ui.js.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA,uCAAuC;;;;;;;;AEyBhC,MAAM;IAMX,YACE,OAAgB,EAChB,WAAyB,EACzB,cAAuC,CACvC;QACA,IAAI,CAAC,OAAO,GAAG;QACf,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ts","packages/host/src/setup-snabbdom.ts","packages/host/src/routing-strategy.ts","packages/host/src/transpile.ts","packages/host/src/host-functions.ts","packages/host/src/types.ts","packages/host/src/utils.ts","packages/host/src/window.ts"],"sourcesContent":["// Re-export everything for easy access\nexport * from \"./ui\";\nexport * from \"./types\";\nexport * from \"./file-loader\";\nexport * from \"./routing-strategy\";\nexport * from \"./transpile\";\nexport * from \"./utils\";\n\n// Global Window augmentation (side-effect import for declaration output)\nimport \"./window\";\n","import { HttpFileLoader } from \"./file-loader\";\nimport { patch } from \"./setup-snabbdom\";\nimport { type VNode } from \"snabbdom\";\nimport {\n HistoryRoutingStrategy,\n type RoutingStrategy,\n} from \"./routing-strategy\";\nimport { loadTranspile } from \"./transpile\";\nimport {\n clearNodes,\n createDomFromIdRec,\n dfunc,\n logfunc,\n setHook,\n} from \"./host-functions\";\nimport { Event } from \"./types\";\nimport { setCb } from \"./utils\";\n\nexport interface Props {\n prop: { key: string; value: any }[];\n on: string[]; // [eventType, fnid]\n}\n\n// Dev-time log function exposed for components importing from \"druid:ui/ui\".\nexport function log(msg: string) {\n // Reuse internal logfunc for consistent labeling.\n logfunc(msg);\n}\n\nexport class DruidUI extends HTMLElement {\n private shadow: ShadowRoot;\n private wrapperEl: HTMLElement;\n private mountEl: HTMLElement;\n private profile: boolean = false;\n private currentVNode: VNode | null = null;\n private _routeStrategy: RoutingStrategy = new HistoryRoutingStrategy();\n private loader = new HttpFileLoader();\n private _sandbox: boolean = true;\n private _extensionObject: object = {};\n private _entrypoint?: string;\n private rootComponent: any;\n private _connected: boolean = false;\n private reloadGeneration: number = 0;\n\n public connectedCallback() {\n this._connected = true;\n if (this.rootComponent) {\n this.rerender();\n return;\n }\n this.reloadComponent();\n }\n\n public disconnectedCallback() {\n this._connected = false;\n }\n\n public reloadComponent() {\n if (!this._connected) {\n console.warn(\"Component not connected, skipping reload.\");\n return;\n }\n const entrypoint = this._entrypoint;\n if (!entrypoint) {\n console.warn(\"No entrypoint attribute set.\");\n return;\n }\n if (!this.loader) {\n console.warn(\"No file loader set.\");\n return;\n }\n\n // Increment generation to invalidate all pending operations from previous load\n this.reloadGeneration++;\n console.debug(\n `[reloadComponent] Starting reload, generation: ${this.reloadGeneration}`,\n );\n\n // Clear nodes map to ensure fresh state\n clearNodes();\n\n if (this._sandbox) {\n loadTranspile(entrypoint, this.loader)\n .then(([moduleUrl, compile]) => {\n this.loadEntrypointFromWasmUrl(moduleUrl, compile);\n })\n .catch((e) => {\n console.error(\"Failed to load and transpile entrypoint:\", e);\n });\n } else {\n this.loadEntrypointFromJavaScriptUrl(entrypoint);\n }\n }\n\n public getWrapper(): HTMLElement {\n return this.wrapperEl;\n }\n set fileloader(loader: HttpFileLoader) {\n this.loader = loader;\n this.reloadComponent();\n }\n\n set extensionObject(obj: object) {\n this._extensionObject = obj;\n }\n set entrypoint(entrypoint: string) {\n this._entrypoint = entrypoint;\n this.reloadComponent();\n }\n\n set sandbox(sandbox: boolean) {\n this._sandbox = sandbox;\n this.reloadComponent();\n }\n\n set routeStrategy(strategy: RoutingStrategy) {\n this._routeStrategy = strategy;\n this.rerender();\n }\n\n static get observedAttributes() {\n return [\"entrypoint\", \"path\", \"profile\", \"css\", \"style\", \"no-sandbox\"];\n }\n\n attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string,\n ) {\n switch (name) {\n case \"no-sandbox\":\n this._sandbox = newValue !== \"true\";\n break;\n case \"entrypoint\":\n this.entrypoint = newValue;\n break;\n case \"path\":\n if (oldValue) {\n this.rerender();\n }\n break;\n case \"profile\":\n this.profile = newValue === \"true\";\n break;\n case \"style\":\n const htmlString = newValue;\n const styleEl = document.createElement(\"style\");\n styleEl.textContent = htmlString.trim();\n\n // Insert style after all link elements\n const lastLink = Array.from(\n this.shadow.querySelectorAll('link[rel=\"stylesheet\"]'),\n ).pop();\n //clear previous style elements\n const existingStyles = this.shadow.querySelectorAll(\"style\");\n existingStyles.forEach((style) => style.remove());\n\n if (lastLink) {\n this.shadow.insertBefore(styleEl, lastLink.nextSibling);\n } else {\n this.shadow.insertBefore(\n styleEl,\n this.shadowRoot?.firstChild || null,\n );\n }\n break;\n case \"css\":\n const css = newValue.split(\",\");\n //clear previous css links\n const existingLinks = this.shadow.querySelectorAll(\n 'link[rel=\"stylesheet\"]',\n );\n existingLinks.forEach((link) => link.remove());\n\n for (const comp of css) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = comp;\n this.shadow.insertBefore(link, this.shadowRoot?.firstChild || null);\n }\n break;\n }\n }\n\n constructor() {\n super();\n this.shadow = this.attachShadow({ mode: \"open\" });\n\n this.wrapperEl = document.createElement(\"div\");\n this.wrapperEl.classList.add(\"druid-wrapper\");\n this.mountEl = document.createElement(\"div\");\n this.mountEl.classList.add(\"druid-mount\");\n this.mountEl.innerText = \"Transpiling...\";\n\n this.wrapperEl.appendChild(this.mountEl);\n this.shadow.appendChild(this.wrapperEl);\n }\n\n private getExtensionObject() {\n return {\n \"druid:ui/ui\": {\n d: (element: string, props: Props, children: string[]) => {\n return dfunc(element, props, children);\n },\n log: (msg: string) => {\n logfunc(msg);\n },\n rerender: () => {\n setTimeout(() => this.rerender(), 0);\n },\n setHook: setHook,\n },\n \"druid:ui/utils\": {\n Event: Event,\n },\n ...this._extensionObject,\n };\n }\n\n async loadEntrypointFromJavaScriptUrl(entrypoint: string) {\n // Capture the generation at the start of this load\n const loadGeneration = this.reloadGeneration;\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Starting load for generation ${loadGeneration}`,\n );\n\n window[\"druid-extension\"] = this.getExtensionObject();\n\n // Force no-cache to get fresh content\n const response = await this.loader.load(entrypoint, { cache: false });\n const bundleContent = response.buffer;\n\n // Create blob URL to avoid Vite's /public restrictions\n const blob = new Blob([bundleContent], { type: \"application/javascript\" });\n const moduleUrl = URL.createObjectURL(blob);\n const t = await import(/* @vite-ignore */ moduleUrl);\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Module loaded for generation ${loadGeneration}, current generation: ${this.reloadGeneration}`,\n );\n\n setCb(t.component.asyncComplete);\n\n // Only proceed if no newer reload has been triggered\n if (this.reloadGeneration !== loadGeneration) {\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Aborting stale load (generation ${loadGeneration}, current: ${this.reloadGeneration})`,\n );\n URL.revokeObjectURL(moduleUrl);\n return;\n }\n\n this.rootComponent = t;\n\n // Reset VNode right before rendering new module to ensure hooks fire\n // This must be done here (not in reloadComponent) to avoid race conditions\n // with pending rerenders from previous module.\n // After the first render, snabbdom's patch() replaces mountEl in the DOM\n // with the VNode element, leaving mountEl detached. We must restore it\n // so the next patch(mountEl, dom) can insert the new element.\n if (this.currentVNode?.elm?.parentNode) {\n this.currentVNode.elm.parentNode.replaceChild(\n this.mountEl,\n this.currentVNode.elm as Node,\n );\n }\n this.mountEl.innerHTML = \"\";\n this.currentVNode = null;\n console.debug(\n `[loadEntrypointFromJavaScriptUrl] Rendering generation ${loadGeneration}`,\n );\n\n this.rerender();\n URL.revokeObjectURL(moduleUrl);\n }\n\n async loadEntrypointFromWasmUrl(\n entrypoint: string,\n loadCompile?: (file: string) => Promise<WebAssembly.Module>,\n ) {\n const t = await import(/* @vite-ignore */ entrypoint!);\n\n URL.revokeObjectURL(entrypoint);\n\n const i = await t.instantiate(loadCompile, this.getExtensionObject());\n setCb(i.component.asyncComplete);\n\n this.rootComponent = i;\n this.rerender();\n }\n\n rerender() {\n if (!this.rootComponent) {\n console.warn(\"Root component not initialized yet.\");\n return;\n }\n let renderStart;\n if (this.profile) {\n // Start profiling\n renderStart = performance.now();\n }\n\n const rootId = this.rootComponent.component.init({\n path: this._routeStrategy.getCurrentPath(),\n });\n\n if (this.profile) {\n const initEnd = performance.now();\n console.debug(\n `Init completed in ${(initEnd - renderStart!).toFixed(2)} ms`,\n );\n }\n\n this.mountEl.innerHTML = \"\";\n const dom = createDomFromIdRec(\n rootId,\n (nodeId, eventType, e) => {\n this.rootComponent.component.emit(nodeId, eventType, e);\n // Capture the current generation\n const generation = this.reloadGeneration;\n setTimeout(() => {\n // Only rerender if we're still in the same generation (no reload happened)\n if (this.reloadGeneration === generation) {\n this.rerender();\n } else {\n console.debug(\n `[setTimeout] Skipping stale rerender (generation ${generation}, current: ${this.reloadGeneration})`,\n );\n }\n }, 0);\n },\n (href: string) => {\n this._routeStrategy.navigateTo(href);\n this.rerender();\n },\n );\n\n if (dom instanceof String) {\n console.warn(\"Root DOM is a string, cannot render:\", dom);\n return;\n }\n if (this.currentVNode) {\n patch(this.currentVNode, dom);\n } else {\n patch(this.mountEl, dom);\n }\n this.currentVNode = dom;\n if (this.profile) {\n const renderEnd = performance.now();\n console.debug(\n `Render completed in ${(renderEnd - renderStart!).toFixed(2)} ms`,\n );\n }\n }\n}\n\ncustomElements.define(\"druid-ui\", DruidUI);\n","interface AuthOptions {\n type: \"bearer\" | \"basic\" | \"api-key\";\n token?: string;\n username?: string;\n password?: string;\n apiKey?: string;\n apiKeyHeader?: string;\n}\n\ninterface FileLoaderOptions {\n auth?: AuthOptions;\n headers?: Record<string, string>;\n cache?: boolean;\n}\n\ninterface HttpResponse {\n buffer: ArrayBuffer;\n headers: Record<string, string>;\n contentType: string | null;\n}\n\nexport interface FileLoader {\n load(path: string, options?: FileLoaderOptions): Promise<HttpResponse>;\n}\n\nexport class HttpFileLoader {\n private authOptions?: AuthOptions | undefined;\n private defaultHeaders?: Record<string, string> | undefined;\n\n private baseUrl?: string | undefined;\n\n constructor(\n baseUrl?: string,\n authOptions?: AuthOptions,\n defaultHeaders?: Record<string, string>\n ) {\n this.baseUrl = baseUrl;\n this.authOptions = authOptions;\n this.defaultHeaders = defaultHeaders;\n }\n\n protected async loadHttp(\n path: string,\n options?: FileLoaderOptions\n ): Promise<HttpResponse> {\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n ...options?.headers,\n };\n\n // Use instance auth options if no options provided, or merge with provided options\n const authToUse = options?.auth || this.authOptions;\n\n // Add authentication headers\n if (authToUse) {\n switch (authToUse.type) {\n case \"bearer\":\n if (authToUse.token) {\n headers[\"Authorization\"] = `Bearer ${authToUse.token}`;\n }\n break;\n case \"basic\":\n if (authToUse.username && authToUse.password) {\n const credentials = btoa(\n `${authToUse.username}:${authToUse.password}`\n );\n headers[\"Authorization\"] = `Basic ${credentials}`;\n }\n break;\n case \"api-key\":\n if (authToUse.apiKey) {\n const headerName = authToUse.apiKeyHeader || \"X-API-Key\";\n headers[headerName] = authToUse.apiKey;\n }\n break;\n }\n }\n\n const res = await fetch(path, {\n headers,\n cache: options?.cache === false ? \"no-store\" : \"default\",\n });\n\n if (!res.ok) {\n throw new Error(`Failed to load file: ${path}, status: ${res.status}`);\n }\n\n // Extract all fetch-specific data\n const text = await res.arrayBuffer();\n\n const responseHeaders: Record<string, string> = {};\n // Handle both real Headers object and mocked headers\n if (res.headers && typeof res.headers.forEach === \"function\") {\n res.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n }\n\n const contentType = res.headers.get(\"Content-Type\");\n\n return {\n buffer: text,\n headers: responseHeaders,\n contentType,\n };\n }\n\n async load(path: string, options?: FileLoaderOptions) {\n const filePath = this.baseUrl ? `${this.baseUrl}/${path}` : path;\n const response = await this.loadHttp(filePath, options);\n return response;\n }\n}\n","import {\n init,\n classModule,\n propsModule,\n styleModule,\n eventListenersModule,\n} from \"snabbdom\";\n\nexport const patch = init([\n // Init patch function with chosen modules\n classModule, // makes it easy to toggle classes\n propsModule, // for setting properties on DOM elements\n styleModule, // handles styling on elements with support for animations\n eventListenersModule, // attaches event listeners\n]);\n","export interface RoutingStrategy {\n getCurrentPath(): string;\n navigateTo(path: string): void;\n}\n\nexport class HistoryRoutingStrategy implements RoutingStrategy {\n getCurrentPath(): string {\n return window.location.pathname;\n }\n\n navigateTo(path: string): void {\n window.history.pushState({}, \"\", path);\n }\n}\n\nexport class CustomRoutingStrategy implements RoutingStrategy {\n private currentPath: string = \"/\";\n\n getCurrentPath(): string {\n return this.currentPath;\n }\n\n navigateTo(path: string): void {\n this.currentPath = path;\n }\n}\n\nexport const createRoutingStrategy = (\n mode: \"history\" | \"custom\"\n): RoutingStrategy => {\n if (mode === \"custom\") {\n return new CustomRoutingStrategy();\n } else {\n return new HistoryRoutingStrategy();\n }\n};\n","import type { FileLoader } from \"./file-loader\";\n\ninterface TranspileResult {\n files: Array<[string, Uint8Array]>;\n}\n\ninterface CacheEntry {\n jsUrl: string;\n fileUrls: Record<string, string>;\n}\n\nconst CACHE_KEY_PREFIX = \"transpile_cache_\";\n\n// Helper functions for localStorage caching\nconst getCachedEntry = (file: string): CacheEntry | null => {\n try {\n const cached = localStorage.getItem(CACHE_KEY_PREFIX + file);\n if (cached) {\n return JSON.parse(cached);\n }\n } catch (e) {\n console.warn(\"Failed to read from cache:\", e);\n }\n return null;\n};\n\nconst setCachedEntry = (file: string, entry: CacheEntry): void => {\n try {\n localStorage.setItem(CACHE_KEY_PREFIX + file, JSON.stringify(entry));\n } catch (e) {\n console.warn(\"Failed to write to cache:\", e);\n }\n};\n\nconst transpileInWorker = async (\n buffer: ArrayBuffer,\n name: string,\n): Promise<TranspileResult> => {\n return new Promise((resolve, reject) => {\n const worker = new Worker(\n new URL(\"./transpile.worker.ts\", import.meta.url),\n { type: \"module\" },\n );\n\n worker.onmessage = (event: MessageEvent) => {\n worker.terminate();\n if (event.data.success) {\n resolve(event.data.data);\n } else {\n reject(new Error(event.data.error));\n }\n };\n\n worker.onerror = (error) => {\n worker.terminate();\n reject(error);\n };\n\n // Transfer the buffer ownership to the worker (zero-copy)\n worker.postMessage({ buffer, name }, [buffer]);\n });\n};\n\nexport const loadTranspile = async (\n file: string,\n fileLoader: FileLoader,\n): Promise<[string, (filename: string) => Promise<WebAssembly.Module>]> => {\n // Check cache first\n const cached = getCachedEntry(file);\n if (cached) {\n // Verify URLs are still valid\n try {\n await fetch(cached.jsUrl, { method: \"HEAD\" });\n return [\n cached.jsUrl,\n async (filename: string) => {\n const url = cached.fileUrls[filename];\n if (!url) {\n throw new Error(`File ${filename} not found in transpiled output.`);\n }\n const wasmResponse = await fetch(url);\n const wasmBuffer = await wasmResponse.arrayBuffer();\n return await WebAssembly.compile(wasmBuffer);\n },\n ];\n } catch (e) {\n // Cache is stale, proceed with transpilation\n console.warn(\"Cached URLs are stale, re-transpiling\");\n }\n }\n\n const response = await fileLoader.load(file);\n if (!response) {\n throw new Error(`Failed to load file: ${file}`);\n }\n const files: Record<string, string> = {};\n const t = await transpileInWorker(response.buffer, \"test\");\n\n for (const file of t.files) {\n const [f, content] = file as [string, Uint8Array];\n\n let blob: Blob | null = null;\n if (f.endsWith(\".js\")) {\n blob = new Blob([new Uint8Array(content)], {\n type: \"application/javascript\",\n });\n } else if (f.endsWith(\".wasm\")) {\n blob = new Blob([new Uint8Array(content)], {\n type: \"application/wasm\",\n });\n }\n if (blob) {\n const url = URL.createObjectURL(blob);\n files[f] = url;\n }\n }\n const jsFileEntry = Object.entries(files).find(([filename]) =>\n filename.endsWith(\".js\"),\n );\n if (!jsFileEntry) {\n throw new Error(\"No JavaScript file found in transpiled output.\");\n }\n\n // Cache the result\n const cacheEntry: CacheEntry = {\n jsUrl: jsFileEntry[1],\n fileUrls: files,\n };\n setCachedEntry(file, cacheEntry);\n\n return [\n jsFileEntry[1],\n async (filename: string) => {\n const url = files[filename];\n if (!url) {\n throw new Error(`File ${filename} not found in transpiled output.`);\n }\n const wasmResponse = await fetch(url);\n const wasmBuffer = await wasmResponse.arrayBuffer();\n return await WebAssembly.compile(wasmBuffer);\n },\n ];\n};\n","import type { Props } from \"druid:ui/ui\";\nimport { h, type VNode, type VNodeChildren, type VNodeData } from \"snabbdom\";\nimport { Event } from \"./types\";\n\nconst nodes = new Map<\n string,\n {\n element: string;\n props?: Props;\n children?: Array<string>;\n hooks?: string[];\n }\n>();\n\nexport function clearNodes() {\n console.debug(`[clearNodes] Clearing ${nodes.size} nodes`);\n nodes.clear();\n}\n\nexport function setHook(id: string, callback: string) {\n console.debug(`[setHook] Setting \"${callback}\" hook on node ${id}`);\n const node = nodes.get(id);\n if (node) {\n node.hooks = node.hooks || [];\n node.hooks.push(callback);\n }\n}\n\nexport function dfunc(element: string, props: Props, children: string[]) {\n const id = crypto.randomUUID();\n console.debug(`[dfunc] Creating node: element=\"${element}\", id=${id}`);\n\n nodes.set(id, { element, props, children });\n return id;\n}\n\nexport function logfunc(msg: string) {\n console.log(\"UI LOG:\", msg);\n}\n\nexport function createDomFromIdRec(\n id: string,\n emitEvent: (id: string, eventType: string, event: Event) => void,\n navigate?: (href: string) => void,\n): VNode | String {\n const node = nodes.get(id);\n //it is a bit strange to do it like that, in theory we want to better distinguish between text nodes and element nodes\n if (!node) {\n console.debug(`[createDomFromIdRec] Text node: \"${id}\"`);\n return id;\n }\n\n const data: VNodeData = {};\n\n // Set properties\n if (node.props) {\n data.props = {};\n for (const prop of node.props.prop) {\n data.props[prop.key] = prop.value;\n }\n data.on = {};\n for (const eventType of node.props.on) {\n data.on[eventType] = (e) => {\n console.debug(`[event] \"${eventType}\" on node ${id}`);\n emitEvent(\n id,\n eventType,\n new Event(e?.currentTarget?.value, e?.currentTarget?.checked),\n );\n };\n }\n const href = data.props[\"href\"];\n if (href && !data.on[\"click\"]) {\n if (navigate) {\n data.on.click = (e) => {\n e.preventDefault();\n navigate(href);\n };\n }\n }\n }\n\n // Set hooks (outside props check so hooks work even without props)\n if (node.hooks && node.hooks.length > 0) {\n console.debug(\n `[createDomFromIdRec] Node ${id} has ${\n node.hooks.length\n } hooks: ${node.hooks.join(\", \")}`,\n );\n data.hook = {};\n for (const hookName of node.hooks) {\n data.hook[hookName as keyof typeof data.hook] = () => {\n console.debug(`[hook] \"${hookName}\" fired for node ${id}`);\n emitEvent(id, hookName, new Event());\n };\n }\n }\n const ch: VNodeChildren = [];\n if (node.children) {\n for (const childId of node.children) {\n const childEl = createDomFromIdRec(childId, emitEvent, navigate);\n ch.push(childEl);\n }\n }\n\n return h(node.element, data, ch);\n}\n","export class Event {\n private _value: string;\n private _checked: boolean;\n\n constructor(_value: string = \"\", _checked: boolean = false) {\n this._value = _value;\n this._checked = _checked;\n }\n\n preventDefault() {}\n stopPropagation() {}\n value() {\n return this._value;\n }\n checked() {\n return this._checked;\n }\n}\n","type Callback = (id: string, result: { tag: \"ok\" | \"err\"; val: any }) => void;\n\nlet cb: Callback | undefined;\n\nconst pending: Array<{ id: string; result: Parameters<Callback>[1] }> = [];\n\nconst dispatch = (id: string, result: Parameters<Callback>[1]) => {\n if (cb) {\n cb(id, result);\n return;\n }\n\n pending.push({ id, result });\n};\nexport const setCb = (\n callback: (id: string, result: { tag: \"ok\" | \"err\"; val: any }) => void,\n) => {\n cb = callback;\n\n if (pending.length === 0) {\n return;\n }\n\n // Flush any results that arrived before the callback was registered.\n while (pending.length > 0) {\n const { id, result } = pending.shift()!;\n cb(id, result);\n }\n};\n\nexport const PromiseToResult = <T>(\n promiseFn: (...args: any[]) => Promise<T>,\n) => {\n return (...args: any[]) => {\n const id = crypto.randomUUID();\n promiseFn(...args)\n .then((result) => {\n dispatch(id, {\n tag: \"ok\",\n val: result,\n });\n })\n .catch((error) => {\n dispatch(id, {\n tag: \"err\",\n val: error instanceof Error ? error.message : String(error),\n });\n });\n return id;\n };\n};\n","// Augment the Window interface to include 'druid'.\n// We define a lightweight shape for better intellisense; extend as needed.\n\ntype DruidAPI = Record<string, any>;\n\ndeclare global {\n interface Window {\n \"druid-extension\"?: DruidAPI;\n }\n}\n\n// Mark this file as a module so global augmentation is always applied reliably.\nexport {};\n"],"names":[],"version":3,"file":"ui.js.map"}
|
package/package.json
CHANGED
package/src/host-functions.ts
CHANGED
package/src/ui.ts
CHANGED
|
@@ -224,10 +224,6 @@ export class DruidUI extends HTMLElement {
|
|
|
224
224
|
`[loadEntrypointFromJavaScriptUrl] Starting load for generation ${loadGeneration}`,
|
|
225
225
|
);
|
|
226
226
|
|
|
227
|
-
window["druid-ui"] = {
|
|
228
|
-
d: dfunc,
|
|
229
|
-
};
|
|
230
|
-
|
|
231
227
|
window["druid-extension"] = this.getExtensionObject();
|
|
232
228
|
|
|
233
229
|
// Force no-cache to get fresh content
|
|
@@ -257,7 +253,17 @@ export class DruidUI extends HTMLElement {
|
|
|
257
253
|
|
|
258
254
|
// Reset VNode right before rendering new module to ensure hooks fire
|
|
259
255
|
// This must be done here (not in reloadComponent) to avoid race conditions
|
|
260
|
-
// with pending rerenders from previous module
|
|
256
|
+
// with pending rerenders from previous module.
|
|
257
|
+
// After the first render, snabbdom's patch() replaces mountEl in the DOM
|
|
258
|
+
// with the VNode element, leaving mountEl detached. We must restore it
|
|
259
|
+
// so the next patch(mountEl, dom) can insert the new element.
|
|
260
|
+
if (this.currentVNode?.elm?.parentNode) {
|
|
261
|
+
this.currentVNode.elm.parentNode.replaceChild(
|
|
262
|
+
this.mountEl,
|
|
263
|
+
this.currentVNode.elm as Node,
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
this.mountEl.innerHTML = "";
|
|
261
267
|
this.currentVNode = null;
|
|
262
268
|
console.debug(
|
|
263
269
|
`[loadEntrypointFromJavaScriptUrl] Rendering generation ${loadGeneration}`,
|