@microsoft/webui-framework 0.0.18 → 0.0.20
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 +130 -70
- package/dist/decorators.d.ts +1 -0
- package/dist/decorators.js +3 -0
- package/dist/element/diff.d.ts +3 -1
- package/dist/element/diff.js +197 -90
- package/dist/element/markers.js +13 -5
- package/dist/element/types.d.ts +18 -10
- package/dist/element/types.js +3 -0
- package/dist/element.d.ts +0 -4
- package/dist/element.js +11 -69
- package/dist/hydration-mismatch.js +3 -2
- package/dist/index.js +1 -1
- package/dist/lifecycle.d.ts +17 -0
- package/dist/lifecycle.js +66 -3
- package/dist/static-host.js +20 -10
- package/dist/streaming-activation.d.ts +2 -0
- package/dist/streaming-activation.js +13 -0
- package/dist/streaming-bootstrap.d.ts +2 -0
- package/dist/streaming-bootstrap.js +48 -0
- package/dist/streaming-cleanup.d.ts +4 -0
- package/dist/streaming-cleanup.js +66 -0
- package/dist/streaming-coordinator.d.ts +7 -0
- package/dist/streaming-coordinator.js +367 -0
- package/dist/streaming-deferred.d.ts +22 -0
- package/dist/streaming-deferred.js +273 -0
- package/dist/streaming-dom.d.ts +32 -0
- package/dist/streaming-dom.js +148 -0
- package/dist/streaming-entry.d.ts +1 -0
- package/dist/streaming-entry.js +2 -0
- package/dist/streaming-install.d.ts +2 -0
- package/dist/streaming-install.js +25 -0
- package/dist/streaming-mode.d.ts +5 -0
- package/dist/streaming-mode.js +14 -0
- package/dist/streaming-protocol.d.ts +32 -0
- package/dist/streaming-protocol.js +27 -0
- package/dist/streaming.d.ts +5 -0
- package/dist/streaming.js +9 -0
- package/dist/template-element.d.ts +28 -9
- package/dist/template-element.js +448 -238
- package/dist/template-events.js +1 -1
- package/dist/template-roots.d.ts +0 -1
- package/dist/template-roots.js +0 -11
- package/dist/template-types.d.ts +7 -1
- package/dist/template.d.ts +2 -0
- package/dist/template.js +46 -19
- package/package.json +9 -3
package/dist/template-events.js
CHANGED
|
@@ -13,7 +13,7 @@ export function templateRegistrationDetail(event) {
|
|
|
13
13
|
const detail = event.detail;
|
|
14
14
|
if (!detail || typeof detail !== 'object')
|
|
15
15
|
return undefined;
|
|
16
|
-
const templates = detail
|
|
16
|
+
const templates = detail.templates;
|
|
17
17
|
const payload = {
|
|
18
18
|
templates: typeof templates === 'object' && templates !== null
|
|
19
19
|
? templates
|
package/dist/template-roots.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TemplateMeta } from './template.js';
|
|
2
2
|
export declare function templateHasRoot(meta: TemplateMeta, root: string): boolean;
|
|
3
3
|
export declare function templateRootForAttribute(meta: TemplateMeta, attrName: string): string | undefined;
|
|
4
|
-
export declare function templateAttributeForRoot(meta: TemplateMeta, root: string): string | undefined;
|
|
5
4
|
export declare function templateNeedsStaticHost(meta: TemplateMeta): boolean;
|
package/dist/template-roots.js
CHANGED
|
@@ -19,17 +19,6 @@ export function templateRootForAttribute(meta, attrName) {
|
|
|
19
19
|
}
|
|
20
20
|
return undefined;
|
|
21
21
|
}
|
|
22
|
-
export function templateAttributeForRoot(meta, root) {
|
|
23
|
-
const roots = meta.tr;
|
|
24
|
-
const attrs = meta.ta;
|
|
25
|
-
if (!roots || !attrs)
|
|
26
|
-
return undefined;
|
|
27
|
-
for (let i = 0; i < roots.length && i < attrs.length; i++) {
|
|
28
|
-
if (roots[i] === root)
|
|
29
|
-
return attrs[i];
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
22
|
export function templateNeedsStaticHost(meta) {
|
|
34
23
|
return !!meta.th;
|
|
35
24
|
}
|
package/dist/template-types.d.ts
CHANGED
|
@@ -17,7 +17,13 @@ export type SerializedCompiledCondition = [fnIndex: number, paths: string[]];
|
|
|
17
17
|
export type TemplateCondition = CompiledCondition | SerializedCompiledCondition;
|
|
18
18
|
export type CompiledConditionalMeta = [condition: TemplateCondition, blockIndex: number, slot: TemplateSlotPath];
|
|
19
19
|
export type CompiledAttrMeta = [name: string, kind: 0, value: string] | [name: string, kind: 1, value: string] | [name: string, kind: 2, condition: TemplateCondition] | [name: string, kind: 3, parts: CompiledAttrPart[]];
|
|
20
|
-
export type CompiledRepeatMeta = [
|
|
20
|
+
export type CompiledRepeatMeta = [
|
|
21
|
+
collection: string,
|
|
22
|
+
itemVar: string,
|
|
23
|
+
blockIndex: number,
|
|
24
|
+
slot: TemplateSlotPath,
|
|
25
|
+
keyPath?: string
|
|
26
|
+
];
|
|
21
27
|
export type CompiledEventArg = ['e'] | ['p', string] | ['s', string] | ['n', number] | ['b', number] | ['z'];
|
|
22
28
|
export type CompiledEventArgs = CompiledEventArg[];
|
|
23
29
|
export type CompiledEventBindingMeta = [
|
package/dist/template.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
state?: Record<string, unknown>;
|
|
7
7
|
templates?: Record<string, TemplateMeta>;
|
|
8
8
|
templateFns?: Record<string, CompiledConditionFn[]>;
|
|
9
|
+
templateHostExclusions?: Set<string>;
|
|
9
10
|
[key: string]: unknown;
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -13,3 +14,4 @@ declare global {
|
|
|
13
14
|
export declare function getTemplate(name: string): TemplateMeta | undefined;
|
|
14
15
|
export declare function getTemplateRegistry(): Record<string, TemplateMeta> | undefined;
|
|
15
16
|
export declare function registerTemplateData(templates: Record<string, TemplateMeta>, templateFns?: Record<string, CompiledConditionFn[]>): void;
|
|
17
|
+
export declare function deferTemplateDefinition(tagName: string, ctor: Function, define: () => void): void;
|
package/dist/template.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import { dispatchTemplatesRegistered } from './template-events.js';
|
|
1
|
+
import { dispatchTemplatesRegistered, templateRegistrationDetail, TEMPLATES_REGISTERED_EVENT, } from './template-events.js';
|
|
2
2
|
const WEBUI_DATA_ID = 'webui-data';
|
|
3
3
|
const normalizedTemplates = new WeakSet();
|
|
4
4
|
let webuiDataLoaded = false;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (!meta) {
|
|
8
|
-
loadWebUIDataBlock();
|
|
9
|
-
meta = window.__webui?.templates?.[name];
|
|
10
|
-
}
|
|
11
|
-
if (meta)
|
|
12
|
-
normalizeTemplate(name, meta);
|
|
13
|
-
return meta;
|
|
14
|
-
}
|
|
15
|
-
export function getTemplateRegistry() {
|
|
16
|
-
loadWebUIDataBlock();
|
|
17
|
-
return window.__webui?.templates;
|
|
18
|
-
}
|
|
19
|
-
export function registerTemplateData(templates, templateFns) {
|
|
5
|
+
const pendingTemplateDefinitions = new Map();
|
|
6
|
+
function acceptTemplateData(templates, templateFns) {
|
|
20
7
|
const w = window;
|
|
21
8
|
if (!w.__webui)
|
|
22
9
|
w.__webui = {};
|
|
@@ -32,16 +19,56 @@ export function registerTemplateData(templates, templateFns) {
|
|
|
32
19
|
}
|
|
33
20
|
}
|
|
34
21
|
const names = Object.keys(templates);
|
|
35
|
-
let hasTemplates = false;
|
|
36
22
|
for (let i = 0; i < names.length; i++) {
|
|
37
23
|
const tag = names[i];
|
|
38
24
|
const meta = templates[tag];
|
|
39
25
|
w.__webui.templates[tag] = meta;
|
|
40
26
|
normalizeTemplate(tag, meta);
|
|
41
|
-
hasTemplates = true;
|
|
42
27
|
}
|
|
43
|
-
|
|
28
|
+
for (let i = 0; i < names.length; i++) {
|
|
29
|
+
const pending = pendingTemplateDefinitions.get(names[i]);
|
|
30
|
+
if (!pending)
|
|
31
|
+
continue;
|
|
32
|
+
pendingTemplateDefinitions.delete(names[i]);
|
|
33
|
+
pending.define();
|
|
34
|
+
}
|
|
35
|
+
return names.length > 0;
|
|
36
|
+
}
|
|
37
|
+
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
|
38
|
+
window.addEventListener(TEMPLATES_REGISTERED_EVENT, (event) => {
|
|
39
|
+
const templates = templateRegistrationDetail(event)?.templates;
|
|
40
|
+
if (templates)
|
|
41
|
+
acceptTemplateData(templates);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function getTemplate(name) {
|
|
45
|
+
let meta = window.__webui?.templates?.[name];
|
|
46
|
+
if (!meta) {
|
|
47
|
+
loadWebUIDataBlock();
|
|
48
|
+
meta = window.__webui?.templates?.[name];
|
|
49
|
+
}
|
|
50
|
+
if (meta)
|
|
51
|
+
normalizeTemplate(name, meta);
|
|
52
|
+
return meta;
|
|
53
|
+
}
|
|
54
|
+
export function getTemplateRegistry() {
|
|
55
|
+
loadWebUIDataBlock();
|
|
56
|
+
return window.__webui?.templates;
|
|
57
|
+
}
|
|
58
|
+
export function registerTemplateData(templates, templateFns) {
|
|
59
|
+
if (acceptTemplateData(templates, templateFns)) {
|
|
44
60
|
dispatchTemplatesRegistered(templates);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function deferTemplateDefinition(tagName, ctor, define) {
|
|
64
|
+
const pending = pendingTemplateDefinitions.get(tagName);
|
|
65
|
+
if (pending) {
|
|
66
|
+
if (pending.ctor === ctor) {
|
|
67
|
+
throw new Error(`[WebUI] <${tagName}> is already pending definition.`);
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`[WebUI] <${tagName}> already has a pending authored definition.`);
|
|
70
|
+
}
|
|
71
|
+
pendingTemplateDefinitions.set(tagName, { ctor, define });
|
|
45
72
|
}
|
|
46
73
|
function loadWebUIDataBlock() {
|
|
47
74
|
if (webuiDataLoaded || window.__webui?.state !== undefined || typeof document === 'undefined')
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/webui-framework",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "WebUI Framework Next — Preact-inspired lightweight Web Component runtime with SSR hydration
|
|
5
|
+
"description": "WebUI Framework Next — Preact-inspired lightweight Web Component runtime with SSR hydration and compiled-template path mapping.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
"types": "./dist/component-asset.d.ts",
|
|
17
17
|
"default": "./dist/component-asset.js"
|
|
18
18
|
}
|
|
19
|
+
},
|
|
20
|
+
"./streaming.js": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/streaming-entry.d.ts",
|
|
23
|
+
"default": "./dist/streaming-entry.js"
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
},
|
|
21
27
|
"files": [
|
|
@@ -25,7 +31,7 @@
|
|
|
25
31
|
"@playwright/test": "^1.61.1",
|
|
26
32
|
"@types/node": "^26.1.0",
|
|
27
33
|
"typescript": "^6.0.3",
|
|
28
|
-
"@microsoft/webui-test-support": "0.0.
|
|
34
|
+
"@microsoft/webui-test-support": "0.0.20"
|
|
29
35
|
},
|
|
30
36
|
"scripts": {
|
|
31
37
|
"build": "tsc",
|