@microsoft/webui 0.0.20 → 0.0.21
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/README.md +14 -3
- package/bin/webui +0 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -129
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -10,7 +10,11 @@ High-performance server-side rendering framework. Compiles HTML templates into a
|
|
|
10
10
|
npm install @microsoft/webui
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The package automatically installs the correct platform-specific native binary
|
|
13
|
+
The package automatically installs the correct platform-specific native binary
|
|
14
|
+
for your OS and architecture (Windows, macOS, Linux - x64 and arm64). The Node
|
|
15
|
+
API requires that native addon and surfaces loading errors directly. It never
|
|
16
|
+
falls back to a subprocess. Use the `webui` CLI explicitly for filesystem
|
|
17
|
+
builds.
|
|
14
18
|
|
|
15
19
|
## Quick start
|
|
16
20
|
|
|
@@ -36,23 +40,30 @@ Compiles an application directory of HTML templates into a binary protocol.
|
|
|
36
40
|
const result = build({
|
|
37
41
|
appDir: "./src", // Path to the template directory
|
|
38
42
|
entry: "index.html", // Entry file (default: "index.html")
|
|
39
|
-
css: "link", // CSS strategy: "link" or "
|
|
43
|
+
css: "link", // CSS strategy: "link", "style", or "module"
|
|
40
44
|
plugin: "webui", // Parser plugin name
|
|
41
45
|
components: [], // Additional component sources
|
|
42
46
|
componentAssetRoots: ["settings-dialog"], // Static .webui.js asset roots
|
|
47
|
+
metafile: true, // Return an esbuild-compatible asset graph
|
|
43
48
|
cssFileNameTemplate: "[name]-[hash].[ext]", // CSS/component asset filename template
|
|
44
49
|
cssPublicBase: "https://cdn.example.com/assets", // Optional CDN/public href base
|
|
45
50
|
theme: "./themes/brand.json", // Optional design-token theme validation
|
|
46
|
-
outDir: "./dist", // Output directory for CLI fallback
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
// result.protocol - Buffer containing the compiled protocol
|
|
50
54
|
// result.cssFiles - Array of [filename, content, ...] pairs
|
|
51
55
|
// result.componentAssetFiles - Array of [filename, ESM content, ...] pairs
|
|
56
|
+
// result.metafile - Optional esbuild-compatible graph JSON
|
|
52
57
|
// result.warnings - Array of non-fatal build advisory diagnostics
|
|
53
58
|
// result.stats - { durationMs, fragmentCount, componentCount, cssFileCount, protocolSizeBytes, tokenCount }
|
|
54
59
|
```
|
|
55
60
|
|
|
61
|
+
Static component assets use a root/chunk graph. Entry-reachable dependencies
|
|
62
|
+
remain external, dependencies used by one root stay inline, and dependencies
|
|
63
|
+
with an identical multi-root consumer set are emitted once as dynamic chunks.
|
|
64
|
+
Asset-only records are omitted from `result.protocol`. Component assets cannot
|
|
65
|
+
be combined with `<route>`.
|
|
66
|
+
|
|
56
67
|
When `theme` is provided, every required CSS token must exist in the theme
|
|
57
68
|
after local and ancestor custom-property definitions are excluded. A `var()`
|
|
58
69
|
usage with a literal fallback (e.g. `var(--brand, #000)`) is exempt. Missing
|
package/bin/webui
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -12,12 +12,12 @@ export interface BuildOptions {
|
|
|
12
12
|
components?: string[];
|
|
13
13
|
/** Root component tags emitted as static `.webui.js` ESM assets. */
|
|
14
14
|
componentAssetRoots?: string[];
|
|
15
|
+
/** Generate and return an esbuild-compatible component asset metafile. */
|
|
16
|
+
metafile?: boolean;
|
|
15
17
|
/** Emitted asset filename template for Link-mode CSS and component assets. Tokens: [name], [hash], [ext]. */
|
|
16
18
|
cssFileNameTemplate?: string;
|
|
17
19
|
/** Optional base URL/path prefix for Link-mode CSS hrefs. */
|
|
18
20
|
cssPublicBase?: string;
|
|
19
|
-
/** Output directory (used by CLI fallback for build-to-disk). */
|
|
20
|
-
outDir?: string;
|
|
21
21
|
/** Design token theme: a JSON file path or npm package name. */
|
|
22
22
|
theme?: string;
|
|
23
23
|
/** Projection manifest file paths, merged in order. */
|
|
@@ -51,6 +51,8 @@ export interface BuildResult {
|
|
|
51
51
|
cssFiles: string[];
|
|
52
52
|
/** Static component asset files as alternating [filename, content, ...]. */
|
|
53
53
|
componentAssetFiles: string[];
|
|
54
|
+
/** Esbuild-compatible component asset metafile JSON when requested. */
|
|
55
|
+
metafile?: string;
|
|
54
56
|
/** Non-fatal build advisories as plain diagnostic strings. */
|
|
55
57
|
warnings: string[];
|
|
56
58
|
/** Build statistics. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClC,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6GAA6G;IAC7G,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,2EAA2E;IAC3E,yBAAyB,CAAC,EAAE,KAAK,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC,C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,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI9B,mDAAmD;IACnD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAI1C,gEAAgE;IAChE,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,IAAI,GAAE,YAAsB,GAC3B,MAAM;IAIT,wEAAwE;IACxE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAIxD,6DAA6D;IAC7D,MAAM,CAAC,KAAK,GAAE,MAAM,GAAG,MAAW,GAAG,MAAM;CAG5C;AAMD,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAQpD"}
|
package/dist/index.js
CHANGED
|
@@ -1,132 +1,57 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
-
import {
|
|
5
|
-
import fs from "node:fs";
|
|
6
|
-
import nodePath from "node:path";
|
|
7
|
-
import { resolve, platformKey } from "./platform.js";
|
|
4
|
+
import { packageName, platformKey, resolve } from "./platform.js";
|
|
8
5
|
const require = createRequire(import.meta.url);
|
|
9
|
-
let addon
|
|
10
|
-
let fallbackWarned = false;
|
|
6
|
+
let addon;
|
|
11
7
|
function loadAddon() {
|
|
12
8
|
if (addon)
|
|
13
9
|
return addon;
|
|
14
10
|
const addonPath = resolve("addon");
|
|
15
|
-
if (addonPath) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
process.dlopen(m, addonPath);
|
|
24
|
-
addon = m.exports;
|
|
25
|
-
}
|
|
26
|
-
return addon;
|
|
11
|
+
if (!addonPath) {
|
|
12
|
+
throw new Error(`[webui] Native addon not found for ${platformKey()}. ${addonInstallHelp()} ` +
|
|
13
|
+
'The Node API does not fall back to the CLI; invoke "webui" explicitly for filesystem builds.');
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
// .node files load via require(), native libs (.dylib/.so/.dll) via dlopen
|
|
17
|
+
if (addonPath.endsWith(".node")) {
|
|
18
|
+
addon = require(addonPath);
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
else {
|
|
21
|
+
const m = { exports: {} };
|
|
22
|
+
process.dlopen(m, addonPath);
|
|
23
|
+
addon = m.exports;
|
|
30
24
|
}
|
|
31
25
|
}
|
|
32
|
-
|
|
26
|
+
catch (cause) {
|
|
27
|
+
throw new Error(`[webui] Failed to load native addon at ${addonPath}. ${addonInstallHelp()}`, { cause });
|
|
28
|
+
}
|
|
29
|
+
return addon;
|
|
33
30
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
function addonInstallHelp() {
|
|
32
|
+
try {
|
|
33
|
+
return `Reinstall ${packageName()} or set WEBUI_ADDON_PATH to a compatible addon.`;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const platformError = error instanceof Error ? error.message : String(error);
|
|
37
|
+
return `${platformError} Set WEBUI_ADDON_PATH to a compatible addon.`;
|
|
38
|
+
}
|
|
41
39
|
}
|
|
42
40
|
// ── Build API ────────────────────────────────────────────────────────
|
|
43
41
|
/** Build a WebUI application from an app directory. */
|
|
44
42
|
export function build(options) {
|
|
45
43
|
const native = loadAddon();
|
|
46
|
-
if (native
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const binPath = resolve("bin");
|
|
58
|
-
if (!binPath) {
|
|
59
|
-
throw new Error("[webui] Cannot build: no native addon or CLI binary available.");
|
|
60
|
-
}
|
|
61
|
-
const args = ["build", options.appDir ?? "."];
|
|
62
|
-
if (options.entry)
|
|
63
|
-
args.push("--entry", options.entry);
|
|
64
|
-
if (options.css)
|
|
65
|
-
args.push("--css", options.css);
|
|
66
|
-
if (options.plugin)
|
|
67
|
-
args.push("--plugin", options.plugin);
|
|
68
|
-
if (options.components) {
|
|
69
|
-
for (const c of options.components) {
|
|
70
|
-
args.push("--components", c);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (options.projectionManifests) {
|
|
74
|
-
for (const manifest of options.projectionManifests) {
|
|
75
|
-
args.push("--projection-manifest", manifest);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (options.projectionManifestObjects &&
|
|
79
|
-
options.projectionManifestObjects.length > 0) {
|
|
80
|
-
throw new Error("[webui] Inline projection manifest objects require the native addon; write the manifest and pass projectionManifests when using the CLI fallback.");
|
|
81
|
-
}
|
|
82
|
-
if (options.componentAssetRoots && options.componentAssetRoots.length > 0) {
|
|
83
|
-
args.push("--emit-component-assets", options.componentAssetRoots.join(","));
|
|
84
|
-
}
|
|
85
|
-
if (options.cssFileNameTemplate) {
|
|
86
|
-
args.push("--css-file-name-template", options.cssFileNameTemplate);
|
|
87
|
-
}
|
|
88
|
-
if (options.cssPublicBase) {
|
|
89
|
-
args.push("--css-public-base", options.cssPublicBase);
|
|
90
|
-
}
|
|
91
|
-
if (options.theme)
|
|
92
|
-
args.push("--theme", options.theme);
|
|
93
|
-
if (options.outDir)
|
|
94
|
-
args.push("--out", options.outDir);
|
|
95
|
-
execFileSync(binPath, args, { stdio: "inherit" });
|
|
96
|
-
// CLI fallback does not return in-memory protocol.
|
|
97
|
-
if (options.outDir) {
|
|
98
|
-
const protocol = fs.readFileSync(nodePath.join(options.outDir, "protocol.bin"));
|
|
99
|
-
return {
|
|
100
|
-
protocol,
|
|
101
|
-
cssFiles: [],
|
|
102
|
-
componentAssetFiles: readComponentAssetFiles(options.outDir),
|
|
103
|
-
warnings: [],
|
|
104
|
-
stats: emptyStats(),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
protocol: Buffer.alloc(0),
|
|
109
|
-
cssFiles: [],
|
|
110
|
-
componentAssetFiles: [],
|
|
111
|
-
warnings: [],
|
|
112
|
-
stats: emptyStats(),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function readComponentAssetFiles(outDir) {
|
|
116
|
-
const files = [];
|
|
117
|
-
const entries = fs.readdirSync(outDir, { withFileTypes: true });
|
|
118
|
-
for (let i = 0; i < entries.length; i++) {
|
|
119
|
-
const entry = entries[i];
|
|
120
|
-
if (!entry.isFile())
|
|
121
|
-
continue;
|
|
122
|
-
const name = entry.name;
|
|
123
|
-
const path = nodePath.join(outDir, name);
|
|
124
|
-
const content = fs.readFileSync(path, "utf8");
|
|
125
|
-
if (!content.startsWith("const asset=") || !content.includes("webui-component-asset"))
|
|
126
|
-
continue;
|
|
127
|
-
files.push(name, content);
|
|
128
|
-
}
|
|
129
|
-
return files;
|
|
44
|
+
if (typeof native.build !== "function") {
|
|
45
|
+
throw new Error(`[webui] Native addon is incompatible: build() is required. ${addonInstallHelp()}`);
|
|
46
|
+
}
|
|
47
|
+
const { projectionManifestObjects, ...nativeOptions } = options;
|
|
48
|
+
return native.build({
|
|
49
|
+
...nativeOptions,
|
|
50
|
+
projectionManifestObjects: projectionManifestObjects?.map(({ path, manifest }) => ({
|
|
51
|
+
path,
|
|
52
|
+
json: JSON.stringify(manifest),
|
|
53
|
+
})),
|
|
54
|
+
});
|
|
130
55
|
}
|
|
131
56
|
// ── Runtime protocol API ─────────────────────────────────────────────
|
|
132
57
|
/**
|
|
@@ -138,11 +63,9 @@ function readComponentAssetFiles(outDir) {
|
|
|
138
63
|
export class Protocol {
|
|
139
64
|
#native;
|
|
140
65
|
constructor(protocolData, options) {
|
|
141
|
-
const
|
|
142
|
-
const NativeProtocol = native?.Protocol;
|
|
66
|
+
const NativeProtocol = loadAddon().Protocol;
|
|
143
67
|
if (!NativeProtocol) {
|
|
144
|
-
|
|
145
|
-
throw new Error("[webui] Native addon is incompatible: Protocol is required.");
|
|
68
|
+
throw new Error(`[webui] Native addon is incompatible: Protocol is required. ${addonInstallHelp()}`);
|
|
146
69
|
}
|
|
147
70
|
this.#native = new NativeProtocol(protocolData, options?.plugin);
|
|
148
71
|
}
|
|
@@ -257,20 +180,10 @@ function toStateJson(state) {
|
|
|
257
180
|
/** Inspect protocol bytes and return JSON representation. */
|
|
258
181
|
export function inspect(protocolData) {
|
|
259
182
|
const native = loadAddon();
|
|
260
|
-
if (native
|
|
261
|
-
|
|
183
|
+
if (typeof native.inspect !== "function") {
|
|
184
|
+
throw new Error(`[webui] Native addon is incompatible: inspect() is required. ${addonInstallHelp()}`);
|
|
262
185
|
}
|
|
263
|
-
|
|
186
|
+
return native.inspect(protocolData);
|
|
264
187
|
}
|
|
265
188
|
// ── Helpers ──────────────────────────────────────────────────────────
|
|
266
|
-
function emptyStats() {
|
|
267
|
-
return {
|
|
268
|
-
durationMs: 0,
|
|
269
|
-
fragmentCount: 0,
|
|
270
|
-
componentCount: 0,
|
|
271
|
-
cssFileCount: 0,
|
|
272
|
-
protocolSizeBytes: 0,
|
|
273
|
-
tokenCount: 0,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
189
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,E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jD,CAAC;CACF;AAED,SAAS,WAAW,CAAC,KAAsB;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,OAAO,CAAC,YAAoB;IAC1C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,gEAAgE,gBAAgB,EAAE,EAAE,CACrF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;AAED,wEAAwE"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@microsoft/webui",
|
|
3
3
|
"description": "WebUI — high-performance server-side rendering framework. Build-time protocol compiler and streaming renderer.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.21",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"optionalDependencies": {
|
|
46
|
-
"@microsoft/webui-darwin-arm64": "0.0.
|
|
47
|
-
"@microsoft/webui-
|
|
48
|
-
"@microsoft/webui-linux-arm64": "0.0.
|
|
49
|
-
"@microsoft/webui-
|
|
50
|
-
"@microsoft/webui-win32-
|
|
51
|
-
"@microsoft/webui-win32-
|
|
46
|
+
"@microsoft/webui-darwin-arm64": "0.0.21",
|
|
47
|
+
"@microsoft/webui-linux-x64": "0.0.21",
|
|
48
|
+
"@microsoft/webui-linux-arm64": "0.0.21",
|
|
49
|
+
"@microsoft/webui-darwin-x64": "0.0.21",
|
|
50
|
+
"@microsoft/webui-win32-arm64": "0.0.21",
|
|
51
|
+
"@microsoft/webui-win32-x64": "0.0.21"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"esbuild": "^0.28.1",
|
|
@@ -71,6 +71,6 @@
|
|
|
71
71
|
"build": "tsc",
|
|
72
72
|
"postbuild": "node dist/install.js",
|
|
73
73
|
"postinstall": "node --input-type=module -e \"try{await import('./dist/install.js')}catch{}\"",
|
|
74
|
-
"test": "tsc --project tsconfig.test.json && node --test dist/test/integration.test.js dist/test/
|
|
74
|
+
"test": "tsc --project tsconfig.test.json && node --test dist/test/integration.test.js dist/test/native-addon-loading.test.js dist/test/projection-conformance.test.js dist/test/projection-compiler.test.js dist/test/projection-esbuild.test.js dist/test/projection-peers.test.js"
|
|
75
75
|
}
|
|
76
76
|
}
|