@taggor/runtime 0.0.0-reserved.0 → 0.1.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 +50 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/compat/before-compat.d.ts +5 -0
- package/dist/compat/before-compat.d.ts.map +1 -0
- package/dist/compat/before-compat.js +15 -0
- package/dist/compat/before-compat.js.map +1 -0
- package/dist/compat/index.d.ts +90 -0
- package/dist/compat/index.d.ts.map +1 -0
- package/dist/compat/index.js +67 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/scope.d.ts +81 -0
- package/dist/compat/scope.d.ts.map +1 -0
- package/dist/compat/scope.js +107 -0
- package/dist/compat/scope.js.map +1 -0
- package/dist/element/attributes.d.ts +103 -0
- package/dist/element/attributes.d.ts.map +1 -0
- package/dist/element/attributes.js +153 -0
- package/dist/element/attributes.js.map +1 -0
- package/dist/element/component-controller.d.ts +98 -0
- package/dist/element/component-controller.d.ts.map +1 -0
- package/dist/element/component-controller.js +472 -0
- package/dist/element/component-controller.js.map +1 -0
- package/dist/element/contract-gate.d.ts +29 -0
- package/dist/element/contract-gate.d.ts.map +1 -0
- package/dist/element/contract-gate.js +37 -0
- package/dist/element/contract-gate.js.map +1 -0
- package/dist/element/create-component-element.d.ts +93 -0
- package/dist/element/create-component-element.d.ts.map +1 -0
- package/dist/element/create-component-element.js +302 -0
- package/dist/element/create-component-element.js.map +1 -0
- package/dist/element/define-element.d.ts +43 -0
- package/dist/element/define-element.d.ts.map +1 -0
- package/dist/element/define-element.js +61 -0
- package/dist/element/define-element.js.map +1 -0
- package/dist/element/diagnostics.d.ts +35 -0
- package/dist/element/diagnostics.d.ts.map +1 -0
- package/dist/element/diagnostics.js +52 -0
- package/dist/element/diagnostics.js.map +1 -0
- package/dist/element/error-boundary.d.ts +41 -0
- package/dist/element/error-boundary.d.ts.map +1 -0
- package/dist/element/error-boundary.js +36 -0
- package/dist/element/error-boundary.js.map +1 -0
- package/dist/element/error-report.d.ts +9 -0
- package/dist/element/error-report.d.ts.map +1 -0
- package/dist/element/error-report.js +51 -0
- package/dist/element/error-report.js.map +1 -0
- package/dist/element/events.d.ts +69 -0
- package/dist/element/events.d.ts.map +1 -0
- package/dist/element/events.js +115 -0
- package/dist/element/events.js.map +1 -0
- package/dist/element/handler-guard.d.ts +54 -0
- package/dist/element/handler-guard.d.ts.map +1 -0
- package/dist/element/handler-guard.js +162 -0
- package/dist/element/handler-guard.js.map +1 -0
- package/dist/element/index.d.ts +9 -0
- package/dist/element/index.d.ts.map +1 -0
- package/dist/element/index.js +9 -0
- package/dist/element/index.js.map +1 -0
- package/dist/element/props-script.d.ts +37 -0
- package/dist/element/props-script.d.ts.map +1 -0
- package/dist/element/props-script.js +63 -0
- package/dist/element/props-script.js.map +1 -0
- package/dist/element/styles.d.ts +45 -0
- package/dist/element/styles.d.ts.map +1 -0
- package/dist/element/styles.js +66 -0
- package/dist/element/styles.js.map +1 -0
- package/dist/element/types.d.ts +148 -0
- package/dist/element/types.d.ts.map +1 -0
- package/dist/element/types.js +3 -0
- package/dist/element/types.js.map +1 -0
- package/dist/host/api.d.ts +40 -0
- package/dist/host/api.d.ts.map +1 -0
- package/dist/host/api.js +144 -0
- package/dist/host/api.js.map +1 -0
- package/dist/host/barrier.d.ts +27 -0
- package/dist/host/barrier.d.ts.map +1 -0
- package/dist/host/barrier.js +47 -0
- package/dist/host/barrier.js.map +1 -0
- package/dist/host/index.d.ts +11 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +9 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/registry.d.ts +21 -0
- package/dist/host/registry.d.ts.map +1 -0
- package/dist/host/registry.js +29 -0
- package/dist/host/registry.js.map +1 -0
- package/dist/host/types.d.ts +54 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +11 -0
- package/dist/host/types.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/config.d.ts +63 -0
- package/dist/loader/config.d.ts.map +1 -0
- package/dist/loader/config.js +115 -0
- package/dist/loader/config.js.map +1 -0
- package/dist/loader/entry.d.ts +2 -0
- package/dist/loader/entry.d.ts.map +1 -0
- package/dist/loader/entry.js +37 -0
- package/dist/loader/entry.js.map +1 -0
- package/dist/loader/lazy-transport.d.ts +26 -0
- package/dist/loader/lazy-transport.d.ts.map +1 -0
- package/dist/loader/lazy-transport.js +59 -0
- package/dist/loader/lazy-transport.js.map +1 -0
- package/dist/loader/loader-code.d.ts +2 -0
- package/dist/loader/loader-code.js +2 -0
- package/dist/loader/loading.d.ts +24 -0
- package/dist/loader/loading.d.ts.map +1 -0
- package/dist/loader/loading.js +29 -0
- package/dist/loader/loading.js.map +1 -0
- package/dist/loader/page-state.d.ts +66 -0
- package/dist/loader/page-state.d.ts.map +1 -0
- package/dist/loader/page-state.js +73 -0
- package/dist/loader/page-state.js.map +1 -0
- package/dist/loader/resilient-import.d.ts +32 -0
- package/dist/loader/resilient-import.d.ts.map +1 -0
- package/dist/loader/resilient-import.js +42 -0
- package/dist/loader/resilient-import.js.map +1 -0
- package/dist/loader/run.d.ts +45 -0
- package/dist/loader/run.d.ts.map +1 -0
- package/dist/loader/run.js +217 -0
- package/dist/loader/run.js.map +1 -0
- package/dist/loader/script-url.d.ts +50 -0
- package/dist/loader/script-url.d.ts.map +1 -0
- package/dist/loader/script-url.js +71 -0
- package/dist/loader/script-url.js.map +1 -0
- package/dist/loader/script.d.ts +31 -0
- package/dist/loader/script.d.ts.map +1 -0
- package/dist/loader/script.js +40 -0
- package/dist/loader/script.js.map +1 -0
- package/dist/server/render-fragment.d.ts +57 -0
- package/dist/server/render-fragment.d.ts.map +1 -0
- package/dist/server/render-fragment.js +182 -0
- package/dist/server/render-fragment.js.map +1 -0
- package/dist/server/ssr-code.d.ts +4 -0
- package/dist/server/ssr-code.js +3 -0
- package/dist/server/worker.d.ts +37 -0
- package/dist/server/worker.d.ts.map +1 -0
- package/dist/server/worker.js +71 -0
- package/dist/server/worker.js.map +1 -0
- package/package.json +89 -1
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component controller (TAG-302): mounts one component definition into one host element, keeps its
|
|
3
|
+
* props in sync with the attributes, unmounts it, and contains every failure.
|
|
4
|
+
*
|
|
5
|
+
* The Custom Element class (`create-component-element.ts`) only forwards its callbacks here, so the
|
|
6
|
+
* generic `<taggor-component name="…">` host (TAG-320) can drive the same controller. Every entry
|
|
7
|
+
* point catches: a failing component shows its fallback and is reported through the diagnostics
|
|
8
|
+
* port, never thrown at the page (golden rule 2). A failed component stays failed for the life of
|
|
9
|
+
* the element (no retry loop on every attribute change); a new element starts fresh.
|
|
10
|
+
*
|
|
11
|
+
* TAG-303: an attribute its prop type refuses gives the default and one `invalid-attribute`
|
|
12
|
+
* warning (debug mode) per refused text, not one per render.
|
|
13
|
+
*
|
|
14
|
+
* TAG-317: `disconnect` defers the unmount to a microtask and `connect` cancels it, so moving the
|
|
15
|
+
* element (remove + insert in the same task, as SPAs and carousels do) keeps the mounted tree and
|
|
16
|
+
* its state. A real removal unmounts (effect cleanups disconnect the SDK's observers), aborts the
|
|
17
|
+
* mount's `AbortSignal` (`ComponentHost.signal`, which the SDK's data transport hands to `fetch`)
|
|
18
|
+
* and unregisters the handler guard's root.
|
|
19
|
+
*
|
|
20
|
+
* TAG-305: the host's `emit` dispatches a declared event on the host element (`events.ts`
|
|
21
|
+
* validates and copies the detail), only while the component is mounted: after a real removal (or a
|
|
22
|
+
* failure) an `emit` from a timer or a late promise is dropped with an `event-dropped` warning.
|
|
23
|
+
* The host object outlives one mount, so after a remount the component emits again.
|
|
24
|
+
*
|
|
25
|
+
* TAG-304: props also come from JS properties (`el.items = […]`, through accessors the element
|
|
26
|
+
* class defines and `setProperty`) and from a `<script type="application/json" data-props>` child
|
|
27
|
+
* (`props-script.ts`). Precedence, per prop: property > attribute > script > default. A property
|
|
28
|
+
* set before the element was upgraded (an own property shadowing the accessor) is taken over when
|
|
29
|
+
* the controller is created: read, deleted and set through `setProperty` (the "lazy property"
|
|
30
|
+
* pattern). Assigning `undefined` or `null` clears the property, so the attribute (or script, or
|
|
31
|
+
* default) applies again; a refused value gives the default and an `invalid-property` warning
|
|
32
|
+
* without the value. Properties live as long as the element: moving or remounting keeps them.
|
|
33
|
+
* The props the component receives, and what the getters return, are deep-frozen.
|
|
34
|
+
* The script is read once, at the first connect, and again at `DOMContentLoaded` when the document
|
|
35
|
+
* was still loading then (the parser connects an element before parsing its children); changing
|
|
36
|
+
* it later has no effect (set the property instead).
|
|
37
|
+
*
|
|
38
|
+
* TAG-320 (TAG-305 security review): the `<tag>` of the events is the element's own `localName`,
|
|
39
|
+
* the tag its class is really registered under, never the manifest's declared tag, which may
|
|
40
|
+
* belong to another script after a collision.
|
|
41
|
+
*
|
|
42
|
+
* TAG-314: a form field component (`formAssociated` in the manifest) gets the element's
|
|
43
|
+
* `ElementInternals`, attached when the controller is created (in the element's constructor, so
|
|
44
|
+
* no page script can take them first) and handed to the component as `host.internals`. A form reset
|
|
45
|
+
* remounts the component's tree (its state back to the initial one, as `form.reset()` does to an
|
|
46
|
+
* `<input>`); a change of the disabled state (the `disabled` attribute, a disabled `<fieldset>`)
|
|
47
|
+
* renders again, so the component reads `:disabled`. A failed field submits nothing and never blocks
|
|
48
|
+
* the form: its value and validity are cleared. The shadow root delegates focus when the
|
|
49
|
+
* definition says so (`delegatesFocus`, by default a form field).
|
|
50
|
+
*
|
|
51
|
+
* TAG-324: `field` answers the element's form field API (`el.value`, `el.form`, `el.validity`,
|
|
52
|
+
* `el.checkValidity()`…) from those internals; the value is the last one the component submitted,
|
|
53
|
+
* recorded by wrapping the internals' own `setFormValue`.
|
|
54
|
+
* TAG-325: browser-restored text is held on the element's internals and exposed by the SDK as
|
|
55
|
+
* `field.restored`.
|
|
56
|
+
*
|
|
57
|
+
* TAG-214: a connected element is tracked in the live component registry (`deps.live`) with the reader
|
|
58
|
+
* of its `ComponentInfo` (tag, name, version, state, current props), which `window.taggor.get` and
|
|
59
|
+
* `components` return; a real unmount untracks it (a move keeps it).
|
|
60
|
+
*/
|
|
61
|
+
import { h, render } from "preact";
|
|
62
|
+
import { deepFreeze } from "@taggor/contract/zod-free";
|
|
63
|
+
import { propertyValue, readProps, } from "./attributes.js";
|
|
64
|
+
import { ComponentBoundary } from "./error-boundary.js";
|
|
65
|
+
import { emitEvent } from "./events.js";
|
|
66
|
+
import { registerComponentRoot } from "./handler-guard.js";
|
|
67
|
+
import { readScriptProps } from "./props-script.js";
|
|
68
|
+
/**
|
|
69
|
+
* Read once, when the runtime loads (TAG-324 security review): a page that replaces
|
|
70
|
+
* `Reflect.apply` later cannot receive the internals as its `thisArg`. One that poisoned it before
|
|
71
|
+
* the runtime loaded still can (the residual risk of T-62).
|
|
72
|
+
*/
|
|
73
|
+
const { apply } = Reflect;
|
|
74
|
+
/**
|
|
75
|
+
* Creates the controller of one element.
|
|
76
|
+
*
|
|
77
|
+
* Inputs: the host element and `ComponentControllerDeps`. Output: a `ComponentController`. Errors: none;
|
|
78
|
+
* no method ever throws (failures go to `diagnostics.reportError` with their phase). Side effects:
|
|
79
|
+
* takes over the element's own properties named like a bound prop (set before the upgrade:
|
|
80
|
+
* deleted and kept as properties, TAG-304) and, for a form field, attaches the element's
|
|
81
|
+
* `ElementInternals` (TAG-314; none when the browser lacks them or the page took them first);
|
|
82
|
+
* otherwise none until `connect`, which reads the
|
|
83
|
+
* `<script data-props>` child the first time (and listens once for `DOMContentLoaded` while the
|
|
84
|
+
* document is loading), attaches an open shadow root (once), adopts the styles, creates the
|
|
85
|
+
* mount's `AbortController` and renders; `disconnect` queues one microtask (the deferred unmount).
|
|
86
|
+
*/
|
|
87
|
+
export function createComponentController(element, deps) {
|
|
88
|
+
const { definition, bindings, events, styles, diagnostics, fallback, isColor } = deps;
|
|
89
|
+
const { tag, name } = definition.manifest;
|
|
90
|
+
/** The last value given to the internals' `setFormValue` (TAG-324). */
|
|
91
|
+
let formValue = null;
|
|
92
|
+
const internals = deps.formAssociated
|
|
93
|
+
? attachInternals(element, (value) => {
|
|
94
|
+
formValue = value;
|
|
95
|
+
})
|
|
96
|
+
: undefined;
|
|
97
|
+
let root;
|
|
98
|
+
let inlineStyles = [];
|
|
99
|
+
let connected = false;
|
|
100
|
+
let failed = false;
|
|
101
|
+
let unregister;
|
|
102
|
+
/** Aborted on a real unmount; a new one per mount. Kept after the abort, so late reads see it. */
|
|
103
|
+
let mount;
|
|
104
|
+
/** A deferred unmount is queued (`disconnect`); `connect` before it runs cancels it. */
|
|
105
|
+
let unmountQueued = false;
|
|
106
|
+
/** The last refused text warned about, per attribute, so a re-render does not warn again. */
|
|
107
|
+
const warned = new Map();
|
|
108
|
+
/** Props set by property (TAG-304); they win over attributes and the script. */
|
|
109
|
+
const properties = new Map();
|
|
110
|
+
/** Props of the `<script data-props>` child, once read (TAG-304). */
|
|
111
|
+
let scripted;
|
|
112
|
+
const host = Object.freeze({
|
|
113
|
+
element,
|
|
114
|
+
get shadowRoot() {
|
|
115
|
+
// `connect` sets it before the component can render, so the host is never read without it.
|
|
116
|
+
return root;
|
|
117
|
+
},
|
|
118
|
+
emit: (name, detail) => {
|
|
119
|
+
const problem = emitEvent(element, events, element.localName, name, detail, connected && !failed);
|
|
120
|
+
if (problem !== undefined)
|
|
121
|
+
diagnostics.warn({ code: "event-dropped", tag, message: problem });
|
|
122
|
+
},
|
|
123
|
+
get signal() {
|
|
124
|
+
return mount?.signal;
|
|
125
|
+
},
|
|
126
|
+
internals,
|
|
127
|
+
transport: deps.transport,
|
|
128
|
+
});
|
|
129
|
+
const fail = (error, phase, rerender) => {
|
|
130
|
+
const first = !failed;
|
|
131
|
+
failed = true;
|
|
132
|
+
if (first && root !== undefined) {
|
|
133
|
+
try {
|
|
134
|
+
styles.drop(root);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// Dropping styles is cosmetic; the fallback still renders.
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (first) {
|
|
141
|
+
try {
|
|
142
|
+
// A failed field must not block the page's form (golden rule 2): no value, no error.
|
|
143
|
+
internals?.setFormValue(null);
|
|
144
|
+
internals?.setValidity({});
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// Internals the page replaced; nothing more to clear.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
diagnostics.reportError({ tag, name, phase, error });
|
|
151
|
+
// After an unmount (an async handler settling once the element left the page) only report:
|
|
152
|
+
// painting would mount the tree again; a reconnect paints the fallback.
|
|
153
|
+
if (rerender && first && connected)
|
|
154
|
+
paint();
|
|
155
|
+
};
|
|
156
|
+
/** The value is left out of every message: it is page input, possibly long or personal. */
|
|
157
|
+
const refuse = (code, source, prop, problem) => {
|
|
158
|
+
diagnostics.warn({
|
|
159
|
+
code,
|
|
160
|
+
tag,
|
|
161
|
+
message: `${source} of prop "${prop}" was refused (${problem}); using the default`,
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const readScript = () => {
|
|
165
|
+
scripted = readScriptProps(element, bindings, isColor, (prop, problem) => {
|
|
166
|
+
refuse("invalid-props-script", "<script data-props>", prop, problem);
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
const warnAbout = (problems) => {
|
|
170
|
+
for (const binding of bindings) {
|
|
171
|
+
const found = problems.find((problem) => problem.attribute === binding.attribute);
|
|
172
|
+
if (found === undefined) {
|
|
173
|
+
warned.delete(binding.attribute);
|
|
174
|
+
}
|
|
175
|
+
else if (warned.get(binding.attribute) !== found.text) {
|
|
176
|
+
warned.set(binding.attribute, found.text);
|
|
177
|
+
refuse("invalid-attribute", `attribute "${found.attribute}"`, found.prop, found.problem);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const currentProps = () => {
|
|
182
|
+
const { props, problems } = readProps(bindings, (attribute) => element.getAttribute(attribute), isColor);
|
|
183
|
+
warnAbout(problems);
|
|
184
|
+
// Property > attribute > script > default (TAG-304). `merged` already owns every prop, so the
|
|
185
|
+
// assignments below never reach a setter or a frozen member of Object.prototype.
|
|
186
|
+
const merged = { ...props };
|
|
187
|
+
for (const { prop, attribute } of bindings) {
|
|
188
|
+
if (properties.has(prop))
|
|
189
|
+
merged[prop] = properties.get(prop);
|
|
190
|
+
else if (scripted?.has(prop) && element.getAttribute(attribute) === null)
|
|
191
|
+
merged[prop] = scripted.get(prop);
|
|
192
|
+
}
|
|
193
|
+
// Frozen in depth (TAG-304 security review): the getter hands the page these same objects,
|
|
194
|
+
// and a page mutation (`el.items.push(…)`, `el.link.href = "javascript:…"`) would otherwise
|
|
195
|
+
// reach the component on the next render without passing through the contract. This also
|
|
196
|
+
// freezes a declaration's `default` (shared by every instance) before anyone can mutate it.
|
|
197
|
+
return deepFreeze(merged);
|
|
198
|
+
};
|
|
199
|
+
const tree = () => h(ComponentBoundary, {
|
|
200
|
+
failed,
|
|
201
|
+
fallback,
|
|
202
|
+
inlineStyles,
|
|
203
|
+
nonce: styles.nonce,
|
|
204
|
+
onError: (error) => {
|
|
205
|
+
// Called by Preact during a diff: record and report, the boundary re-renders itself.
|
|
206
|
+
fail(error, "render", false);
|
|
207
|
+
},
|
|
208
|
+
}, failed
|
|
209
|
+
? null
|
|
210
|
+
: h(definition.component, {
|
|
211
|
+
host,
|
|
212
|
+
props: currentProps(),
|
|
213
|
+
}));
|
|
214
|
+
/** Renders the current tree; a throw that escapes Preact replaces it with the fallback. */
|
|
215
|
+
function paint() {
|
|
216
|
+
if (root === undefined)
|
|
217
|
+
return;
|
|
218
|
+
try {
|
|
219
|
+
render(tree(), root);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
// Through `fail`, so a form field also drops its value and validity (golden rule 2).
|
|
223
|
+
fail(error, "lifecycle", false);
|
|
224
|
+
showBareFallback(root);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** The fallback without Preact, when Preact itself threw. */
|
|
228
|
+
function showBareFallback(target) {
|
|
229
|
+
try {
|
|
230
|
+
render(null, target);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
// The tree is broken; replaceChildren below still clears it.
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
styles.drop(target);
|
|
237
|
+
target.replaceChildren(...(fallback === "light-dom" ? [target.ownerDocument.createElement("slot")] : []));
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Nothing more can be done without touching the page.
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function attach() {
|
|
244
|
+
const shadow = element.shadowRoot ??
|
|
245
|
+
element.attachShadow({ mode: "open", delegatesFocus: deps.delegatesFocus });
|
|
246
|
+
// SSR (ADR 0066): a server may have put a declarative shadow root in the page
|
|
247
|
+
// (`<template shadowrootmode>`), which the first `render` adopts node by node. It is kept only
|
|
248
|
+
// when the host's `ssr` stamp names this exact published version (`SSR_STAMP_ATTRIBUTE` of
|
|
249
|
+
// server/render-fragment.ts); a root from another version, or with no stamp, is emptied, so a
|
|
250
|
+
// stale fragment is never diffed against a tree it was not rendered from. On a root the
|
|
251
|
+
// runtime just attached this clears nothing.
|
|
252
|
+
if (element.getAttribute("ssr") !== deps.version)
|
|
253
|
+
shadow.textContent = "";
|
|
254
|
+
inlineStyles = styles.adopt(shadow) ? [] : styles.css;
|
|
255
|
+
return shadow;
|
|
256
|
+
}
|
|
257
|
+
/** The real unmount: cleanups run, pending requests are aborted, the root is unregistered. */
|
|
258
|
+
function unmount() {
|
|
259
|
+
if (root === undefined)
|
|
260
|
+
return;
|
|
261
|
+
try {
|
|
262
|
+
mount?.abort();
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// Defensive only: `abort()` itself does not throw. A throwing `abort` listener does not land
|
|
266
|
+
// here either: the browser reports it to the page's `window.onerror`, as for any event
|
|
267
|
+
// listener (a known limit, docs/agentes/runtime.md §3; the SDK never exposes the signal to
|
|
268
|
+
// authors, it only hands it to `fetch`).
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
render(null, root);
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
fail(error, "lifecycle", false);
|
|
275
|
+
}
|
|
276
|
+
unregister?.();
|
|
277
|
+
unregister = undefined;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Adds the element to (or removes it from) the live registry (TAG-214). Accessory: a page that
|
|
281
|
+
* broke `Map.prototype` cannot stop a mount or an unmount (TAG-214 review, A2). `info()` does not
|
|
282
|
+
* need the shadow root, so tracking before `attach` is safe.
|
|
283
|
+
*/
|
|
284
|
+
const track = (add) => {
|
|
285
|
+
try {
|
|
286
|
+
if (add)
|
|
287
|
+
deps.live.set(element, controller.info);
|
|
288
|
+
else
|
|
289
|
+
deps.live.delete(element);
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
// `window.taggor` just does not see this element.
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const controller = {
|
|
296
|
+
connect: () => {
|
|
297
|
+
connected = true;
|
|
298
|
+
// Before the first render (TAG-214 re-review, B1): `emit` works from here on, so an event
|
|
299
|
+
// emitted while rendering or in a mount layout effect must already pass `taggor.on`'s filter.
|
|
300
|
+
track(true);
|
|
301
|
+
try {
|
|
302
|
+
root ??= attach();
|
|
303
|
+
unregister ??= registerComponentRoot(root, (error) => {
|
|
304
|
+
fail(error, "handler", true);
|
|
305
|
+
});
|
|
306
|
+
if (mount === undefined || mount.signal.aborted)
|
|
307
|
+
mount = newMount();
|
|
308
|
+
if (scripted === undefined) {
|
|
309
|
+
readScript();
|
|
310
|
+
const document = element.ownerDocument;
|
|
311
|
+
// Connected by the parser before its children exist: read again once they are parsed.
|
|
312
|
+
if (document.readyState === "loading") {
|
|
313
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
314
|
+
readScript();
|
|
315
|
+
if (connected && !failed)
|
|
316
|
+
paint();
|
|
317
|
+
}, { once: true });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
// No shadow root or no styles: the light DOM simply stays visible.
|
|
323
|
+
fail(error, "lifecycle", false);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
// After a move (unmount cancelled) this re-renders the same tree: Preact keeps its state.
|
|
327
|
+
paint();
|
|
328
|
+
},
|
|
329
|
+
disconnect: () => {
|
|
330
|
+
connected = false;
|
|
331
|
+
if (root === undefined)
|
|
332
|
+
track(false);
|
|
333
|
+
if (root === undefined || unmountQueued)
|
|
334
|
+
return;
|
|
335
|
+
unmountQueued = true;
|
|
336
|
+
// A promise job rather than `queueMicrotask`, which some Custom Elements browsers lack.
|
|
337
|
+
void Promise.resolve().then(() => {
|
|
338
|
+
unmountQueued = false;
|
|
339
|
+
// Reconnected in the same task (a move): keep the tree, its state and its requests.
|
|
340
|
+
if (connected)
|
|
341
|
+
return;
|
|
342
|
+
track(false);
|
|
343
|
+
try {
|
|
344
|
+
unmount();
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
// unmount catches its own steps; this only keeps a bug in it away from the page.
|
|
348
|
+
diagnostics.reportError({ tag, name, phase: "lifecycle", error });
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
},
|
|
352
|
+
attributeChanged: (attribute, previous, next) => {
|
|
353
|
+
if (!connected || failed || previous === next)
|
|
354
|
+
return;
|
|
355
|
+
if (bindings.some((binding) => binding.attribute === attribute))
|
|
356
|
+
paint();
|
|
357
|
+
},
|
|
358
|
+
formReset: () => {
|
|
359
|
+
if (!connected || failed || root === undefined)
|
|
360
|
+
return;
|
|
361
|
+
try {
|
|
362
|
+
render(null, root);
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
fail(error, "lifecycle", false);
|
|
366
|
+
}
|
|
367
|
+
paint();
|
|
368
|
+
},
|
|
369
|
+
r: (state) => {
|
|
370
|
+
if (!internals)
|
|
371
|
+
return;
|
|
372
|
+
// `s` is private to the runtime and SDK; keep the internal slot compact for bundle budgets.
|
|
373
|
+
internals.s = state;
|
|
374
|
+
if (connected && !failed)
|
|
375
|
+
paint();
|
|
376
|
+
},
|
|
377
|
+
formDisabled: () => {
|
|
378
|
+
if (connected && !failed)
|
|
379
|
+
paint();
|
|
380
|
+
},
|
|
381
|
+
failed: () => failed,
|
|
382
|
+
field: (member, call) => {
|
|
383
|
+
if (member === "value")
|
|
384
|
+
return typeof formValue === "string" ? formValue : "";
|
|
385
|
+
if (internals === undefined)
|
|
386
|
+
return call;
|
|
387
|
+
return call
|
|
388
|
+
? internals[member]()
|
|
389
|
+
: internals[member];
|
|
390
|
+
},
|
|
391
|
+
property: (prop) => currentProps()[prop],
|
|
392
|
+
info: () => {
|
|
393
|
+
try {
|
|
394
|
+
return Object.freeze({
|
|
395
|
+
element,
|
|
396
|
+
tag: element.localName,
|
|
397
|
+
name,
|
|
398
|
+
version: deps.version,
|
|
399
|
+
contractVersion: deps.contractVersion,
|
|
400
|
+
state: failed ? "failed" : "mounted",
|
|
401
|
+
props: currentProps(),
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
catch {
|
|
405
|
+
// A page that broke the element's own methods (getAttribute throwing): no info.
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
setProperty: (prop, value) => {
|
|
410
|
+
const binding = bindings.find((candidate) => candidate.prop === prop);
|
|
411
|
+
if (binding === undefined)
|
|
412
|
+
return;
|
|
413
|
+
if (value == null) {
|
|
414
|
+
properties.delete(prop);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
const coerced = propertyValue(binding, value, isColor);
|
|
418
|
+
if (coerced.problem !== undefined)
|
|
419
|
+
refuse("invalid-property", "property", prop, coerced.problem);
|
|
420
|
+
properties.set(prop, coerced.value);
|
|
421
|
+
}
|
|
422
|
+
if (connected && !failed)
|
|
423
|
+
paint();
|
|
424
|
+
},
|
|
425
|
+
};
|
|
426
|
+
// The "lazy property" pattern (TAG-304): `el.items = …` before the bundle defined the element
|
|
427
|
+
// made an own property that shadows the accessor; take it over.
|
|
428
|
+
for (const { prop } of bindings) {
|
|
429
|
+
try {
|
|
430
|
+
if (Object.hasOwn(element, prop)) {
|
|
431
|
+
const value = element[prop];
|
|
432
|
+
if (Reflect.deleteProperty(element, prop))
|
|
433
|
+
controller.setProperty(prop, value);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
// An own getter that throws: the page's property stays as it is.
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return Object.freeze(controller);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* The element's `ElementInternals` (TAG-314), or `undefined` when the browser has no
|
|
444
|
+
* `attachInternals` or it throws (the page attached them first, or the class is not form-associated
|
|
445
|
+
* in this browser). TAG-324: an own `setFormValue` on the internals reports each value
|
|
446
|
+
* the native one accepted to `record` (real internals never give the value back); internals that
|
|
447
|
+
* cannot take it (non-extensible, only from a page that replaced `attachInternals`, or a
|
|
448
|
+
* `setFormValue` getter that throws) count as none.
|
|
449
|
+
*/
|
|
450
|
+
function attachInternals(element, record) {
|
|
451
|
+
try {
|
|
452
|
+
const internals = element.attachInternals();
|
|
453
|
+
const native = Reflect.get(internals, "setFormValue");
|
|
454
|
+
// `defineProperty`, not an assignment: a page that froze `ElementInternals.prototype` makes
|
|
455
|
+
// the assignment throw (the override mistake); an own property is still allowed.
|
|
456
|
+
Object.defineProperty(internals, "setFormValue", {
|
|
457
|
+
value: (...args) => {
|
|
458
|
+
apply(native, internals, args);
|
|
459
|
+
record(args[0]);
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
return internals;
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
return undefined;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/** A fresh abort controller for one mount, or none on a page without `AbortController`. */
|
|
469
|
+
function newMount() {
|
|
470
|
+
return typeof AbortController === "function" ? new AbortController() : undefined;
|
|
471
|
+
}
|
|
472
|
+
//# sourceMappingURL=component-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-controller.js","sourceRoot":"","sources":["../../src/element/component-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAqB,MAAM,2BAA2B,CAAC;AAE1E,OAAO,EACL,aAAa,EACb,SAAS,GAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAWpD;;;;GAIG;AACH,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;AAqF1B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAoB,EACpB,IAA6B;IAE7B,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACtF,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC;IAC1C,uEAAuE;IACvE,IAAI,SAAS,GAAY,IAAI,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc;QACnC,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjC,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC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,KAAK,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,iEAAiE;QACnE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,eAAe,CACtB,OAAoB,EACpB,MAAgC;IAEhC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACtD,4FAA4F;QAC5F,iFAAiF;QACjF,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,cAAc,EAAE;YAC/C,KAAK,EAAE,CAAC,GAAG,IAAkD,EAAE,EAAE;gBAC/D,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;gBAC/B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;SACF,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,2FAA2F;AAC3F,SAAS,QAAQ;IACf,OAAO,OAAO,eAAe,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract version gate of the runtime (TAG-303, ADR 0019): before a component's element is
|
|
3
|
+
* registered, its manifest's `contractVersion` goes through the contract's own
|
|
4
|
+
* `checkContractVersion` with `consumer: "runtime"`. A newer minor mounts with a warning (its
|
|
5
|
+
* additions are unknown declarations, which count as absent or denied); a missing or malformed
|
|
6
|
+
* version, a newer major or an unsupported major is not mounted. It never throws.
|
|
7
|
+
*
|
|
8
|
+
* The visitor's clock never decides that a major's support ended (security review of TAG-207):
|
|
9
|
+
* the runtime reads no date. End of support is the edge's: it stops serving a bundle whose major
|
|
10
|
+
* is past `supportedUntil`, or stamps the day it served it, which the loader passes as `servedOn`.
|
|
11
|
+
* Without a stamp the runtime checks against `NO_CLOCK_DAY`, earlier than any `supportedUntil`.
|
|
12
|
+
*/
|
|
13
|
+
import { type ContractVersionCheck, type ContractVersionPolicy } from "@taggor/contract/zod-free";
|
|
14
|
+
/**
|
|
15
|
+
* The day the runtime checks support against when the edge stamped none: before every
|
|
16
|
+
* `supportedUntil`, so only the edge (by not serving, or by stamping) ends a major's support.
|
|
17
|
+
*/
|
|
18
|
+
export declare const NO_CLOCK_DAY = "0000-01-01";
|
|
19
|
+
/**
|
|
20
|
+
* The runtime's verdict on a component's contract version.
|
|
21
|
+
*
|
|
22
|
+
* Inputs: the raw `contractVersion` (any value; `undefined` when absent), the ISO day the edge
|
|
23
|
+
* served the component (`YYYY-MM-DD`, or `undefined`; anything else is ignored) and the policy
|
|
24
|
+
* (default: this release's). Output: `checkContractVersion`'s `{ usable, version, problem }` for
|
|
25
|
+
* the runtime; `problem` is always a warning. Errors: none, whatever the inputs. Side effects:
|
|
26
|
+
* none; in particular it never reads the clock (`Date`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkComponentContract(contractVersion: unknown, servedOn: string | undefined, policy?: ContractVersionPolicy): ContractVersionCheck;
|
|
29
|
+
//# sourceMappingURL=contract-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-gate.d.ts","sourceRoot":"","sources":["../../src/element/contract-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,OAAO,EACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,GAAE,qBAA+C,GACtD,oBAAoB,CAetB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract version gate of the runtime (TAG-303, ADR 0019): before a component's element is
|
|
3
|
+
* registered, its manifest's `contractVersion` goes through the contract's own
|
|
4
|
+
* `checkContractVersion` with `consumer: "runtime"`. A newer minor mounts with a warning (its
|
|
5
|
+
* additions are unknown declarations, which count as absent or denied); a missing or malformed
|
|
6
|
+
* version, a newer major or an unsupported major is not mounted. It never throws.
|
|
7
|
+
*
|
|
8
|
+
* The visitor's clock never decides that a major's support ended (security review of TAG-207):
|
|
9
|
+
* the runtime reads no date. End of support is the edge's: it stops serving a bundle whose major
|
|
10
|
+
* is past `supportedUntil`, or stamps the day it served it, which the loader passes as `servedOn`.
|
|
11
|
+
* Without a stamp the runtime checks against `NO_CLOCK_DAY`, earlier than any `supportedUntil`.
|
|
12
|
+
*/
|
|
13
|
+
import { CONTRACT_VERSION_POLICY, checkContractVersion, } from "@taggor/contract/zod-free";
|
|
14
|
+
/**
|
|
15
|
+
* The day the runtime checks support against when the edge stamped none: before every
|
|
16
|
+
* `supportedUntil`, so only the edge (by not serving, or by stamping) ends a major's support.
|
|
17
|
+
*/
|
|
18
|
+
export const NO_CLOCK_DAY = "0000-01-01";
|
|
19
|
+
/**
|
|
20
|
+
* The runtime's verdict on a component's contract version.
|
|
21
|
+
*
|
|
22
|
+
* Inputs: the raw `contractVersion` (any value; `undefined` when absent), the ISO day the edge
|
|
23
|
+
* served the component (`YYYY-MM-DD`, or `undefined`; anything else is ignored) and the policy
|
|
24
|
+
* (default: this release's). Output: `checkContractVersion`'s `{ usable, version, problem }` for
|
|
25
|
+
* the runtime; `problem` is always a warning. Errors: none, whatever the inputs. Side effects:
|
|
26
|
+
* none; in particular it never reads the clock (`Date`).
|
|
27
|
+
*/
|
|
28
|
+
export function checkComponentContract(contractVersion, servedOn, policy = CONTRACT_VERSION_POLICY) {
|
|
29
|
+
try {
|
|
30
|
+
return checkContractVersion(contractVersion, { consumer: "runtime", today: servedOn ?? NO_CLOCK_DAY }, policy);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// `servedOn` was not an ISO day (the only way the contract throws): ignore the stamp.
|
|
34
|
+
return checkContractVersion(contractVersion, { consumer: "runtime", today: NO_CLOCK_DAY }, policy);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=contract-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-gate.js","sourceRoot":"","sources":["../../src/element/contract-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAAwB,EACxB,QAA4B,EAC5B,SAAgC,uBAAuB;IAEvD,IAAI,CAAC;QACH,OAAO,oBAAoB,CACzB,eAAe,EACf,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,EACxD,MAAM,CACP,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,sFAAsF;QACtF,OAAO,oBAAoB,CACzB,eAAe,EACf,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAC5C,MAAM,CACP,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type ElementRegistry, GENERIC_TAG } from "./define-element.js";
|
|
2
|
+
import { type FallbackMode, type MountableComponent, type RuntimeDiagnostics } from "./types.js";
|
|
3
|
+
/** Options of `createComponentElement`; every field has a safe default. */
|
|
4
|
+
export interface ComponentElementOptions {
|
|
5
|
+
/** Warnings and caught failures (default: silent; debug mode passes `consoleDiagnostics`). */
|
|
6
|
+
readonly diagnostics?: RuntimeDiagnostics;
|
|
7
|
+
/** What a failed component shows (default `"light-dom"`: the content the page put in the tag). */
|
|
8
|
+
readonly fallback?: FallbackMode;
|
|
9
|
+
/** The registry to define in (default `globalThis.customElements`). */
|
|
10
|
+
readonly registry?: ElementRegistry;
|
|
11
|
+
/** The base class (default `globalThis.HTMLElement`); injectable for tests. */
|
|
12
|
+
readonly baseElement?: typeof HTMLElement;
|
|
13
|
+
/**
|
|
14
|
+
* The published manifest's `contractVersion` (the loader reads it from what the edge serves,
|
|
15
|
+
* TAG-301); when absent, `definition.manifest.contractVersion` is used. Missing in both: the
|
|
16
|
+
* component is not mounted (ADR 0019).
|
|
17
|
+
*/
|
|
18
|
+
readonly contractVersion?: unknown;
|
|
19
|
+
/**
|
|
20
|
+
* The ISO day (`YYYY-MM-DD`) the edge served the component, if it stamps one. The runtime never
|
|
21
|
+
* reads the visitor's clock to end a major's support (`contract-gate.ts`).
|
|
22
|
+
*/
|
|
23
|
+
readonly servedOn?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The page's CSP nonce, put on the `<style>` elements of browsers without constructable
|
|
26
|
+
* stylesheets (TAG-308). The loader reads it from its own script tag (TAG-310); without it, a
|
|
27
|
+
* page whose `style-src` has no `'unsafe-inline'` blocks those styles (adopted sheets are never
|
|
28
|
+
* blocked).
|
|
29
|
+
*/
|
|
30
|
+
readonly styleNonce?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The published version of the component (the loader reads it from the site manifest, TAG-301);
|
|
33
|
+
* only reported by `window.taggor.get` (TAG-214). Anything but a string counts as absent.
|
|
34
|
+
*/
|
|
35
|
+
readonly version?: string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The delivery origin (the loader's runtime URL) the runtime error report is sent to (TAG-318).
|
|
38
|
+
* Passed in, not read from `import.meta`, so the bundle also parses as a classic script (TAG-2522).
|
|
39
|
+
*/
|
|
40
|
+
readonly origin?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The data transport handed to every element as `host.transport` (TAG-709); the loader passes a
|
|
43
|
+
* lazy one for components that declare `data`. Opaque here: the SDK's hooks call it.
|
|
44
|
+
*/
|
|
45
|
+
readonly transport?: unknown;
|
|
46
|
+
/**
|
|
47
|
+
* The props the site gives this component (TAG-613; the `defaults` of its manifest entry, which
|
|
48
|
+
* the loader passes on): each one the prop's type accepts replaces the component's own default,
|
|
49
|
+
* below the page's attribute, property and `<script data-props>`. Anything else is ignored.
|
|
50
|
+
*/
|
|
51
|
+
readonly siteDefaults?: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** The result of `createComponentElement`; it never throws, so every outcome is a value. */
|
|
54
|
+
export type ComponentElementRegistration =
|
|
55
|
+
/** `tag` is now this component's element. */
|
|
56
|
+
{
|
|
57
|
+
readonly status: "defined";
|
|
58
|
+
readonly tag: string;
|
|
59
|
+
readonly element: CustomElementConstructor;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `tag` belongs to another script (or `define` failed); the class was not registered and can
|
|
63
|
+
* back the generic host `genericTag` (TAG-320).
|
|
64
|
+
*/
|
|
65
|
+
| {
|
|
66
|
+
readonly status: "collision" | "define-failed";
|
|
67
|
+
readonly tag: string;
|
|
68
|
+
readonly element: CustomElementConstructor;
|
|
69
|
+
readonly genericTag: typeof GENERIC_TAG;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Nothing was created: not a definition, a contract version this runtime cannot mount
|
|
73
|
+
* (`unsupported-contract`, with a `contract-version` warning), or no Custom Elements.
|
|
74
|
+
*/
|
|
75
|
+
| {
|
|
76
|
+
readonly status: "invalid-definition" | "unsupported-contract" | "unsupported";
|
|
77
|
+
readonly tag: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Creates and registers the Custom Element of a component.
|
|
81
|
+
*
|
|
82
|
+
* Inputs: a definition made by `defineTaggorComponent` (checked by shape: the `taggor.component` brand, a
|
|
83
|
+
* manifest with string `tag` and `name`, a `component` function, a `styles` array) and
|
|
84
|
+
* `ComponentElementOptions`. The contract version is checked first (`checkComponentContract`): a newer
|
|
85
|
+
* minor is mounted with a warning, an unusable version returns `unsupported-contract` without
|
|
86
|
+
* defining anything. Output: a `ComponentElementRegistration`. Errors: never throws; a bad
|
|
87
|
+
* definition or contract version, missing Custom Elements, a taken tag or a failing `define`
|
|
88
|
+
* become a warning and a status. Side effects: `customElements.define` (unless the tag is taken), Preact's
|
|
89
|
+
* `options.vnode` hook on the first call; each element attaches an open shadow root and renders
|
|
90
|
+
* when connected; a connected element is tracked in `liveComponents` (TAG-214).
|
|
91
|
+
*/
|
|
92
|
+
export declare function createComponentElement(definition: MountableComponent, options?: ComponentElementOptions): ComponentElementRegistration;
|
|
93
|
+
//# sourceMappingURL=create-component-element.d.ts.map
|