@componentonce/dom 0.1.0-beta.0
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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/examples/plain-card.ts +25 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @componentonce/dom
|
|
2
|
+
|
|
3
|
+
Trusted ordinary DOM adapter for ComponentOnce.
|
|
4
|
+
|
|
5
|
+
A DOM component receives three independent typed channels: persisted props, host-owned context, and per-render payload. Its implementation mounts into a host-owned Element and returns explicit update and destroy lifecycle methods.
|
|
6
|
+
|
|
7
|
+
Typed mounts do not revalidate values unless explicitly requested. Use mountDomComponentBoundary when loading raw props or payload from storage or transport.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ComponentOnceCapability, type ComponentOnceCapabilityCompatibility, type ComponentOnceDefinition, type ComponentOnceManifest, type ComponentOnceValidator } from "@componentonce/core";
|
|
2
|
+
/** Typed values passed to a DOM component instance. */
|
|
3
|
+
export interface ComponentOnceDomRenderInput<TProps, THostContext, TPayload> {
|
|
4
|
+
readonly props: TProps;
|
|
5
|
+
readonly context: THostContext;
|
|
6
|
+
readonly payload: TPayload;
|
|
7
|
+
}
|
|
8
|
+
/** Live DOM instance returned by one component mount. */
|
|
9
|
+
export interface ComponentOnceDomMountHandle<TProps, THostContext, TPayload> {
|
|
10
|
+
/** Replace the application values shown by this mounted instance. */
|
|
11
|
+
update(input: ComponentOnceDomRenderInput<TProps, THostContext, TPayload>): void;
|
|
12
|
+
/** Release listeners/resources and stop owning the target contents. */
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
/** Trusted DOM implementation registered with ComponentOnce. */
|
|
16
|
+
export interface ComponentOnceDomImplementation<TProps, THostContext, TPayload> {
|
|
17
|
+
/** Mount into one host-owned target and return its explicit lifecycle handle. */
|
|
18
|
+
mount(target: Element, input: ComponentOnceDomRenderInput<TProps, THostContext, TPayload>): ComponentOnceDomMountHandle<TProps, THostContext, TPayload>;
|
|
19
|
+
}
|
|
20
|
+
/** Core definition specialized to an ordinary DOM implementation. */
|
|
21
|
+
export type ComponentOnceDomDefinition<TProps, THostContext, TPayload> = ComponentOnceDefinition<ComponentOnceDomImplementation<TProps, THostContext, TPayload>, TProps, THostContext, TPayload>;
|
|
22
|
+
/** Input used to define one typed DOM component. */
|
|
23
|
+
export interface DefineDomComponentInput<TProps, THostContext, TPayload> {
|
|
24
|
+
readonly manifest: ComponentOnceManifest;
|
|
25
|
+
readonly implementation: ComponentOnceDomImplementation<TProps, THostContext, TPayload>;
|
|
26
|
+
readonly validateProps?: ComponentOnceValidator<TProps>;
|
|
27
|
+
readonly validatePayload?: ComponentOnceValidator<TPayload>;
|
|
28
|
+
}
|
|
29
|
+
/** Selects typed values that a host explicitly wants to revalidate before mount. */
|
|
30
|
+
export interface ComponentOnceDomValidationRequest {
|
|
31
|
+
readonly props?: boolean;
|
|
32
|
+
readonly payload?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Input for mounting an already typed DOM definition. */
|
|
35
|
+
export interface ComponentOnceDomMountInput<TProps, THostContext, TPayload> extends ComponentOnceDomRenderInput<TProps, THostContext, TPayload> {
|
|
36
|
+
readonly definition: ComponentOnceDomDefinition<TProps, THostContext, TPayload>;
|
|
37
|
+
readonly target: Element;
|
|
38
|
+
readonly validation?: boolean | ComponentOnceDomValidationRequest;
|
|
39
|
+
readonly hostCapabilities?: readonly ComponentOnceCapability[];
|
|
40
|
+
readonly capabilityCompatibility?: ComponentOnceCapabilityCompatibility;
|
|
41
|
+
}
|
|
42
|
+
/** Unknown values received from an untyped host/storage boundary. */
|
|
43
|
+
export interface ComponentOnceDomBoundaryInput<THostContext> {
|
|
44
|
+
readonly props: unknown;
|
|
45
|
+
readonly context: THostContext;
|
|
46
|
+
readonly payload: unknown;
|
|
47
|
+
}
|
|
48
|
+
/** Raw values plus target/definition needed for one validated mount. */
|
|
49
|
+
export interface ComponentOnceDomBoundaryMountInput<TProps, THostContext, TPayload> extends ComponentOnceDomBoundaryInput<THostContext> {
|
|
50
|
+
readonly definition: ComponentOnceDomDefinition<TProps, THostContext, TPayload>;
|
|
51
|
+
readonly target: Element;
|
|
52
|
+
readonly hostCapabilities?: readonly ComponentOnceCapability[];
|
|
53
|
+
readonly capabilityCompatibility?: ComponentOnceCapabilityCompatibility;
|
|
54
|
+
}
|
|
55
|
+
/** DOM definition field that may provide a boundary validator. */
|
|
56
|
+
export type ComponentOnceDomValidationField = "props" | "payload";
|
|
57
|
+
/** Thrown when a raw boundary needs a validator that the definition did not provide. */
|
|
58
|
+
export declare class ComponentOnceDomValidatorMissingError extends Error {
|
|
59
|
+
readonly field: ComponentOnceDomValidationField;
|
|
60
|
+
readonly manifest: ComponentOnceManifest;
|
|
61
|
+
constructor(field: ComponentOnceDomValidationField, manifest: ComponentOnceManifest);
|
|
62
|
+
}
|
|
63
|
+
/** Define one trusted typed DOM implementation. */
|
|
64
|
+
export declare function defineDomComponent<TProps, THostContext, TPayload>(input: DefineDomComponentInput<TProps, THostContext, TPayload>): ComponentOnceDomDefinition<TProps, THostContext, TPayload>;
|
|
65
|
+
/** Mount one typed DOM definition after compatibility and optional validation checks. */
|
|
66
|
+
export declare function mountDomComponent<TProps, THostContext, TPayload>(input: ComponentOnceDomMountInput<TProps, THostContext, TPayload>): ComponentOnceDomMountHandle<TProps, THostContext, TPayload>;
|
|
67
|
+
/** Validate unknown persisted props and payload once at a DOM host boundary. */
|
|
68
|
+
export declare function validateDomComponentBoundary<TProps, THostContext, TPayload>(definition: ComponentOnceDomDefinition<TProps, THostContext, TPayload>, input: ComponentOnceDomBoundaryInput<THostContext>): ComponentOnceDomRenderInput<TProps, THostContext, TPayload>;
|
|
69
|
+
/** Validate one raw boundary then mount without a second validation pass. */
|
|
70
|
+
export declare function mountDomComponentBoundary<TProps, THostContext, TPayload>(input: ComponentOnceDomBoundaryMountInput<TProps, THostContext, TPayload>): ComponentOnceDomMountHandle<TProps, THostContext, TPayload>;
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,oCAAoC,EACzC,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7D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { assertComponentOnceCompatible, } from "@componentonce/core";
|
|
2
|
+
/** Thrown when a raw boundary needs a validator that the definition did not provide. */
|
|
3
|
+
export class ComponentOnceDomValidatorMissingError extends Error {
|
|
4
|
+
field;
|
|
5
|
+
manifest;
|
|
6
|
+
constructor(field, manifest) {
|
|
7
|
+
super("Component \"" + manifest.id + "\" version \"" + manifest.version +
|
|
8
|
+
"\" has no " + field + " validator.");
|
|
9
|
+
this.name = new.target.name;
|
|
10
|
+
this.field = field;
|
|
11
|
+
this.manifest = manifest;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Define one trusted typed DOM implementation. */
|
|
15
|
+
export function defineDomComponent(input) {
|
|
16
|
+
return {
|
|
17
|
+
manifest: input.manifest,
|
|
18
|
+
implementation: input.implementation,
|
|
19
|
+
...(input.validateProps === undefined ? {} : { validateProps: input.validateProps }),
|
|
20
|
+
...(input.validatePayload === undefined ? {} : { validatePayload: input.validatePayload }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Mount one typed DOM definition after compatibility and optional validation checks. */
|
|
24
|
+
export function mountDomComponent(input) {
|
|
25
|
+
assertComponentOnceCompatible(input.definition.manifest, input.hostCapabilities ?? [], input.capabilityCompatibility);
|
|
26
|
+
const validation = normalizeValidation(input.validation);
|
|
27
|
+
const props = validation.props
|
|
28
|
+
? validateField(input.definition, "props", input.props)
|
|
29
|
+
: input.props;
|
|
30
|
+
const payload = validation.payload
|
|
31
|
+
? validateField(input.definition, "payload", input.payload)
|
|
32
|
+
: input.payload;
|
|
33
|
+
return input.definition.implementation.mount(input.target, {
|
|
34
|
+
props,
|
|
35
|
+
context: input.context,
|
|
36
|
+
payload,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Validate unknown persisted props and payload once at a DOM host boundary. */
|
|
40
|
+
export function validateDomComponentBoundary(definition, input) {
|
|
41
|
+
return {
|
|
42
|
+
props: validateField(definition, "props", input.props),
|
|
43
|
+
context: input.context,
|
|
44
|
+
payload: validateField(definition, "payload", input.payload),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Validate one raw boundary then mount without a second validation pass. */
|
|
48
|
+
export function mountDomComponentBoundary(input) {
|
|
49
|
+
const validated = validateDomComponentBoundary(input.definition, input);
|
|
50
|
+
return mountDomComponent({
|
|
51
|
+
definition: input.definition,
|
|
52
|
+
target: input.target,
|
|
53
|
+
...validated,
|
|
54
|
+
...(input.hostCapabilities === undefined
|
|
55
|
+
? {}
|
|
56
|
+
: { hostCapabilities: input.hostCapabilities }),
|
|
57
|
+
...(input.capabilityCompatibility === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: { capabilityCompatibility: input.capabilityCompatibility }),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function normalizeValidation(validation) {
|
|
63
|
+
if (validation === true)
|
|
64
|
+
return { props: true, payload: true };
|
|
65
|
+
if (validation === false || validation === undefined)
|
|
66
|
+
return { props: false, payload: false };
|
|
67
|
+
return { props: validation.props ?? false, payload: validation.payload ?? false };
|
|
68
|
+
}
|
|
69
|
+
function validateField(definition, field, value) {
|
|
70
|
+
const validator = field === "props" ? definition.validateProps : definition.validatePayload;
|
|
71
|
+
if (validator === undefined) {
|
|
72
|
+
throw new ComponentOnceDomValidatorMissingError(field, definition.manifest);
|
|
73
|
+
}
|
|
74
|
+
return validator(value);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAM9B,MAAM,qBAAqB,CAAC;AA8E7B,wFAAwF;AACxF,MAAM,OAAO,qCAAsC,SAAQ,KAAK;IAC9C,KAAK,CAAkC;IACvC,QAAQ,CAAwB;IAEhD,YAAmB,KAAsC,EAAE,QAA+B;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E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/D,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9F,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC;AACpF,CAAC;AAYD,SAAS,aAAa,CACpB,UAAsE,EACtE,KAAsC,EACtC,KAAc;IAEd,MAAM,SAAS,GAAG,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;IAC5F,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,qCAAqC,CAAC,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineDomComponent } from "@componentonce/dom";
|
|
2
|
+
|
|
3
|
+
export const plainCard = defineDomComponent<
|
|
4
|
+
{ readonly title: string },
|
|
5
|
+
{ readonly format: (value: string) => string },
|
|
6
|
+
{ readonly count: number }
|
|
7
|
+
>({
|
|
8
|
+
manifest: {
|
|
9
|
+
id: "example/plain-card",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
requirements: [{ name: "browser-dom", version: "1" }],
|
|
12
|
+
},
|
|
13
|
+
implementation: {
|
|
14
|
+
mount(target, input) {
|
|
15
|
+
const render = (next: typeof input) => {
|
|
16
|
+
target.textContent = next.context.format(next.props.title) + " (" + next.payload.count + ")";
|
|
17
|
+
};
|
|
18
|
+
render(input);
|
|
19
|
+
return {
|
|
20
|
+
update(next) { render(next); },
|
|
21
|
+
destroy() { target.replaceChildren(); },
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@componentonce/dom",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"examples",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@componentonce/core": "0.1.0-beta.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^4.0.5"
|
|
22
|
+
},
|
|
23
|
+
"description": "DOM adapter for trusted ComponentOnce components with explicit mount, update, and destroy lifecycle.",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"tag": "beta"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"precheck": "pnpm --filter @componentonce/core build",
|
|
31
|
+
"check": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
32
|
+
"pretest": "pnpm --filter @componentonce/core build",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"prebuild": "pnpm --filter @componentonce/core build",
|
|
35
|
+
"build": "tsc -p tsconfig.json"
|
|
36
|
+
}
|
|
37
|
+
}
|