@druid-ui/host 1.0.0-next.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/transpile.worker.bc75f4c9.js +69 -0
- package/dist/transpile.worker.bc75f4c9.js.map +1 -0
- package/dist/types/index.d.ts +87 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/ui.js +571 -0
- package/dist/ui.js.map +1 -0
- package/package.json +33 -0
- package/src/file-loader.ts +113 -0
- package/src/host-functions.ts +106 -0
- package/src/index.ts +10 -0
- package/src/routing-strategy.ts +36 -0
- package/src/setup-snabbdom.ts +15 -0
- package/src/transpile.ts +143 -0
- package/src/transpile.worker.ts +33 -0
- package/src/types.ts +18 -0
- package/src/ui.ts +290 -0
- package/src/utils.ts +53 -0
- package/src/vite-env.d.ts +1 -0
- package/src/window.ts +16 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {transpile as $QfSlM$transpile} from "@bytecodealliance/jco";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var $parcel$global = globalThis;
|
|
5
|
+
|
|
6
|
+
var $parcel$modules = {};
|
|
7
|
+
var $parcel$inits = {};
|
|
8
|
+
|
|
9
|
+
var parcelRequire = $parcel$global["parcelRequirea756"];
|
|
10
|
+
|
|
11
|
+
if (parcelRequire == null) {
|
|
12
|
+
parcelRequire = function(id) {
|
|
13
|
+
if (id in $parcel$modules) {
|
|
14
|
+
return $parcel$modules[id].exports;
|
|
15
|
+
}
|
|
16
|
+
if (id in $parcel$inits) {
|
|
17
|
+
var init = $parcel$inits[id];
|
|
18
|
+
delete $parcel$inits[id];
|
|
19
|
+
var module = {id: id, exports: {}};
|
|
20
|
+
$parcel$modules[id] = module;
|
|
21
|
+
init.call(module.exports, module, module.exports);
|
|
22
|
+
return module.exports;
|
|
23
|
+
}
|
|
24
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
25
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
26
|
+
throw err;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
parcelRequire.register = function register(id, init) {
|
|
30
|
+
$parcel$inits[id] = init;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
$parcel$global["parcelRequirea756"] = parcelRequire;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var parcelRegister = parcelRequire.register;
|
|
37
|
+
parcelRegister("ewCzU", function(module, exports) {
|
|
38
|
+
|
|
39
|
+
self.onmessage = async (event)=>{
|
|
40
|
+
const { buffer: buffer, name: name } = event.data;
|
|
41
|
+
try {
|
|
42
|
+
const result = await (0, $QfSlM$transpile)(buffer, {
|
|
43
|
+
name: name,
|
|
44
|
+
instantiation: {
|
|
45
|
+
tag: "async"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// Transfer the file buffers back to the main thread (zero-copy)
|
|
49
|
+
const transferables = result.files.map(([, content])=>content.buffer);
|
|
50
|
+
self.postMessage({
|
|
51
|
+
success: true,
|
|
52
|
+
data: result
|
|
53
|
+
}, {
|
|
54
|
+
transfer: transferables
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
self.postMessage({
|
|
58
|
+
success: false,
|
|
59
|
+
error: error instanceof Error ? error.message : String(error)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
parcelRequire("ewCzU");
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=transpile.worker.bc75f4c9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,KAAK,SAAS,GAAG,OAAO;IACtB,MAAM,UAAE,MAAM,QAAE,IAAI,EAAE,GAAG,MAAM,IAAI;IAEnC,IAAI;QACF,MAAM,SAAU,MAAM,CAAA,GAAA,gBAAQ,EAAE,QAAQ;kBACtC;YACA,eAAe;gBAAE,KAAK;YAAQ;QAChC;QAEA,gEAAgE;QAChE,MAAM,gBAAgB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAK,QAAQ,MAAM;QACtE,KAAK,WAAW,CACd;YAAE,SAAS;YAAM,MAAM;QAAO,GAC9B;YAAE,UAAU;QAAc;IAE9B,EAAE,OAAO,OAAO;QACd,KAAK,WAAW,CAAC;YACf,SAAS;YACT,OAAO,iBAAiB,QAAQ,MAAM,OAAO,GAAG,OAAO;QACzD;IACF;AACF","sources":["packages/host/src/transpile.worker.ts"],"sourcesContent":["import { transpile } from \"@bytecodealliance/jco\";\n\ninterface TranspileRequest {\n buffer: ArrayBuffer;\n name: string;\n}\n\ninterface TranspileResponse {\n files: Array<[string, Uint8Array]>;\n}\n\nself.onmessage = async (event: MessageEvent<TranspileRequest>) => {\n const { buffer, name } = event.data;\n\n try {\n const result = (await transpile(buffer, {\n name,\n instantiation: { tag: \"async\" },\n })) as TranspileResponse;\n\n // Transfer the file buffers back to the main thread (zero-copy)\n const transferables = result.files.map(([, content]) => content.buffer);\n self.postMessage(\n { success: true, data: result },\n { transfer: transferables }\n );\n } catch (error) {\n self.postMessage({\n success: false,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n};\n"],"names":[],"version":3,"file":"transpile.worker.bc75f4c9.js.map"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
interface AuthOptions {
|
|
2
|
+
type: "bearer" | "basic" | "api-key";
|
|
3
|
+
token?: string;
|
|
4
|
+
username?: string;
|
|
5
|
+
password?: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
apiKeyHeader?: string;
|
|
8
|
+
}
|
|
9
|
+
interface FileLoaderOptions {
|
|
10
|
+
auth?: AuthOptions;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
cache?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface HttpResponse {
|
|
15
|
+
buffer: ArrayBuffer;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
contentType: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface FileLoader {
|
|
20
|
+
load(path: string, options?: FileLoaderOptions): Promise<HttpResponse>;
|
|
21
|
+
}
|
|
22
|
+
export class HttpFileLoader {
|
|
23
|
+
constructor(baseUrl?: string, authOptions?: AuthOptions, defaultHeaders?: Record<string, string>);
|
|
24
|
+
protected loadHttp(path: string, options?: FileLoaderOptions): Promise<HttpResponse>;
|
|
25
|
+
load(path: string, options?: FileLoaderOptions): Promise<HttpResponse>;
|
|
26
|
+
}
|
|
27
|
+
export interface RoutingStrategy {
|
|
28
|
+
getCurrentPath(): string;
|
|
29
|
+
navigateTo(path: string): void;
|
|
30
|
+
}
|
|
31
|
+
export class HistoryRoutingStrategy implements RoutingStrategy {
|
|
32
|
+
getCurrentPath(): string;
|
|
33
|
+
navigateTo(path: string): void;
|
|
34
|
+
}
|
|
35
|
+
export class CustomRoutingStrategy implements RoutingStrategy {
|
|
36
|
+
getCurrentPath(): string;
|
|
37
|
+
navigateTo(path: string): void;
|
|
38
|
+
}
|
|
39
|
+
export const createRoutingStrategy: (mode: "history" | "custom") => RoutingStrategy;
|
|
40
|
+
export const loadTranspile: (file: string, fileLoader: FileLoader) => Promise<[string, (filename: string) => Promise<WebAssembly.Module>]>;
|
|
41
|
+
export class Event {
|
|
42
|
+
constructor(_value?: string, _checked?: boolean);
|
|
43
|
+
preventDefault(): void;
|
|
44
|
+
stopPropagation(): void;
|
|
45
|
+
value(): string;
|
|
46
|
+
checked(): boolean;
|
|
47
|
+
}
|
|
48
|
+
export const setCb: (callback: (id: string, result: {
|
|
49
|
+
tag: "ok" | "err";
|
|
50
|
+
val: any;
|
|
51
|
+
}) => void) => void;
|
|
52
|
+
export const PromiseToResult: <T>(promiseFn: (...args: any[]) => Promise<T>) => (...args: any[]) => string;
|
|
53
|
+
export interface Props {
|
|
54
|
+
prop: {
|
|
55
|
+
key: string;
|
|
56
|
+
value: any;
|
|
57
|
+
}[];
|
|
58
|
+
on: string[];
|
|
59
|
+
}
|
|
60
|
+
export function log(msg: string): void;
|
|
61
|
+
export class DruidUI extends HTMLElement {
|
|
62
|
+
connectedCallback(): void;
|
|
63
|
+
disconnectedCallback(): void;
|
|
64
|
+
reloadComponent(): void;
|
|
65
|
+
getWrapper(): HTMLElement;
|
|
66
|
+
set fileloader(loader: HttpFileLoader);
|
|
67
|
+
set extensionObject(obj: object);
|
|
68
|
+
set entrypoint(entrypoint: string);
|
|
69
|
+
set sandbox(sandbox: boolean);
|
|
70
|
+
set routeStrategy(strategy: RoutingStrategy);
|
|
71
|
+
static get observedAttributes(): string[];
|
|
72
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string): void;
|
|
73
|
+
constructor();
|
|
74
|
+
loadEntrypointFromJavaScriptUrl(entrypoint: string): Promise<void>;
|
|
75
|
+
loadEntrypointFromWasmUrl(entrypoint: string, loadCompile?: (file: string) => Promise<WebAssembly.Module>): Promise<void>;
|
|
76
|
+
rerender(): void;
|
|
77
|
+
}
|
|
78
|
+
declare global {
|
|
79
|
+
interface Window {
|
|
80
|
+
"druid-ui": {
|
|
81
|
+
d: (...args: any[]) => any;
|
|
82
|
+
};
|
|
83
|
+
"druid-extension"?: DruidAPI;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;IACj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C;IACb,UAAU,MAAM;QACd,UAAU,EAAE;YACV,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;SAC5B,CAAC;QACF,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"}
|