@exponential-at/ui-element 0.0.0-stage → 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 +201 -0
- package/NOTICE +54 -0
- package/README.md +212 -2
- package/dist/chunks/index-yte5bftp.js +898 -0
- package/dist/chunks/index-yte5bftp.js.map +15 -0
- package/dist/define.js +44 -0
- package/dist/define.js.map +10 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +9 -0
- package/dist/standalone.js +466 -0
- package/dist/standalone.js.map +1 -0
- package/dist/types/define.d.ts +1 -0
- package/dist/types/element.d.ts +91 -0
- package/dist/types/events.d.ts +71 -0
- package/dist/types/extensions.d.ts +39 -0
- package/dist/types/icons.d.ts +7 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/standalone.d.ts +2 -0
- package/dist/types/transport.d.ts +34 -0
- package/package.json +52 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Dennis Strähhuber
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Exponential
|
|
2
|
+
Copyright 2026 Dennis Strähhuber
|
|
3
|
+
|
|
4
|
+
This product includes software developed as part of the Exponential project,
|
|
5
|
+
licensed under the Apache License, Version 2.0 (see LICENSE at the repo root).
|
|
6
|
+
|
|
7
|
+
Third-party code vendored into this repository keeps its own NOTICE, next to
|
|
8
|
+
the vendored source:
|
|
9
|
+
|
|
10
|
+
apps/desktop/crates/ui/NOTICE
|
|
11
|
+
apps/desktop/crates/gpui-markdown-editor/NOTICE
|
|
12
|
+
|
|
13
|
+
This file records the attributions that travel with a distributed artifact.
|
|
14
|
+
It is not the per-client dependency inventory; that is generated separately.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
================================================================================
|
|
18
|
+
Feedback widget
|
|
19
|
+
================================================================================
|
|
20
|
+
|
|
21
|
+
The feedback widget (packages/widget, emitted to
|
|
22
|
+
apps/web/public/widget/v1/loader.js and widget.js) is served cross-origin to
|
|
23
|
+
third-party websites, so its bundle redistributes the software below. Both
|
|
24
|
+
emitted files carry a short banner naming these packages and pointing here.
|
|
25
|
+
|
|
26
|
+
preact
|
|
27
|
+
Copyright (c) 2015-present Jason Miller
|
|
28
|
+
https://github.com/preactjs/preact
|
|
29
|
+
MIT License
|
|
30
|
+
|
|
31
|
+
@zumer/snapdom
|
|
32
|
+
Copyright (c) 2025 ZumerLab
|
|
33
|
+
https://github.com/zumerlab/snapdom
|
|
34
|
+
MIT License
|
|
35
|
+
|
|
36
|
+
Both are made available under the following terms:
|
|
37
|
+
|
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
39
|
+
copy of this software and associated documentation files (the "Software"),
|
|
40
|
+
to deal in the Software without restriction, including without limitation
|
|
41
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
42
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
43
|
+
Software is furnished to do so, subject to the following conditions:
|
|
44
|
+
|
|
45
|
+
The above copyright notice and this permission notice shall be included in
|
|
46
|
+
all copies or substantial portions of the Software.
|
|
47
|
+
|
|
48
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
49
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
50
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
51
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
52
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
53
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
54
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,213 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@exponential-at/ui-element`: Exponential UI as a custom element
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`<exponential-surface>` paints an A2UI surface in the core catalog
|
|
4
|
+
(`@exponential-at/ui`) in any page, with no framework (FEED-130). It does not
|
|
5
|
+
have a painter of its own. It mounts the Solid renderer
|
|
6
|
+
(`@exponential-at/ui-solid`) inside itself, so you get one painter with two
|
|
7
|
+
entry points. The element uses light DOM and is `display: contents` through
|
|
8
|
+
one shared zero-specificity rule `define()` installs (`:where(exponential-surface){display:contents}`,
|
|
9
|
+
so any rule of yours wins), so the surface's `.xui-surface` root is THE box,
|
|
10
|
+
in the same place React's div would be. Elements attached in one task mount
|
|
11
|
+
together: the first at once, the rest in a microtask inside one batch.
|
|
12
|
+
|
|
13
|
+
## The invariant
|
|
14
|
+
|
|
15
|
+
For every surface, the element paints exactly what the React renderer
|
|
16
|
+
paints: the same elements, attributes, `<style data-xui-style>` sheets,
|
|
17
|
+
layers and runtime themes. `src/parity.test.ts` compares the element's
|
|
18
|
+
`.xui-surface` subtree against `@exponential-at/ui-react` in jsdom, using
|
|
19
|
+
the Solid package's `serializeDom` and `renderReact`.
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script type="module">
|
|
23
|
+
import "@exponential-at/ui-element/define" // or the self-contained ./standalone bundle
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<exponential-surface theme="orange" mode="system" src="/ui/stream" post="/ui/events"></exponential-surface>
|
|
27
|
+
|
|
28
|
+
<script type="module">
|
|
29
|
+
const el = document.querySelector("exponential-surface")
|
|
30
|
+
el.addEventListener("xui-action", (e) => e.detail.waitUntil(fetch("/save", { method: "POST", body: JSON.stringify(e.detail.context) })))
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Without a server, call `apply()` to feed it A2UI v0.9 messages:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const el = document.createElement("exponential-surface")
|
|
38
|
+
document.body.append(el)
|
|
39
|
+
el.apply({ createSurface: { surfaceId: "main", catalogId } })
|
|
40
|
+
el.apply({ updateComponents: { surfaceId: "main", components } })
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
| attribute / property | what |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `theme` | A built-in id (attribute). The property also takes a theme JSON or a `ResolvedTheme`; an object is not reflected. An unusable theme never throws: the default theme paints and `xui-theme-issues` fires. |
|
|
48
|
+
| `mode` | `light`, `dark` or `system` (the default, followed live) |
|
|
49
|
+
| `density`, `contrast` | `compact`, `default` or `comfortable`; `normal`, `high` or `system` |
|
|
50
|
+
| `locale`, `time-zone` (`timeZone`) | BCP 47 locale (default `en-US`) and IANA time zone (default the platform's) |
|
|
51
|
+
| `direction` | `ltr` or `rtl` (default: the locale's direction) |
|
|
52
|
+
| `width`, `height` | A numeric string means px; any other string is a CSS length. An explicit `height` is the viewport for height conditions. |
|
|
53
|
+
| `surface-id` (`surfaceId`) | The surface id (default `main`): the `xui-s-<id>` class, the store `apply()` makes, and the host surface it paints |
|
|
54
|
+
| `src`, `post`, `transport` | The host API (see below) |
|
|
55
|
+
| `surface` | A `createSurface` store (it takes priority over the other sources) |
|
|
56
|
+
| `root`, `templates`, `data` | Fixture mode: a normalized tree, its lifted templates, and a data model |
|
|
57
|
+
| `host` | An `ExponentialHost` to use instead of `src` |
|
|
58
|
+
| `plugin` | A `HostPlugin`: icons, `Markdown`, URL and media policies, `optionSource`, `mediaRequest`, `mediaStreamUrl`, `resolveUrl`, `functions`, and the callbacks |
|
|
59
|
+
| `extensions`, `strings`, `states`, `measure`, `viewportHeight` | The same as the Solid props |
|
|
60
|
+
|
|
61
|
+
String properties reflect to their attributes. Setting a property to
|
|
62
|
+
`null` removes its attribute. Properties set before the element is attached
|
|
63
|
+
(or before it is upgraded) still apply.
|
|
64
|
+
|
|
65
|
+
Read-only properties:
|
|
66
|
+
|
|
67
|
+
- `handle`: the `SurfaceHandle`, or `null` until the first paint.
|
|
68
|
+
- `issues`: the active store's reduce issues.
|
|
69
|
+
- `status`: the transport status; `statusDetail`: its detail (an error, or why the URL policy refused `src`/`post`).
|
|
70
|
+
- `surfaceState`: the `SurfaceState` being painted.
|
|
71
|
+
|
|
72
|
+
Methods:
|
|
73
|
+
|
|
74
|
+
- `apply(message)` sends the message to the `surface` property, else to the host (`receive`), else to a store created on first use.
|
|
75
|
+
- `setData(pointer, value)` writes the active store. In fixture mode it sets a new `data`.
|
|
76
|
+
- `reset()` resets the active store.
|
|
77
|
+
- `run(command)`, `focus(id)`, `announce(text, live?)`, `scrollIntoView(id)` and `scrollToIndex(id, index, align?)` go through the handle. Before the first paint they return `false` or do nothing. Called without a string id, `focus()` and `scrollIntoView()` keep their usual `HTMLElement` meaning.
|
|
78
|
+
|
|
79
|
+
Detaching the element disposes the painted DOM. Re-attaching it paints
|
|
80
|
+
again, and every property survives. Attaching also clears any children the
|
|
81
|
+
author put inside the element.
|
|
82
|
+
|
|
83
|
+
## Events
|
|
84
|
+
|
|
85
|
+
Every event is a `CustomEvent` that bubbles and is composed. When there is
|
|
86
|
+
a matching `plugin` callback, both the callback and the event fire. Where a
|
|
87
|
+
promise is involved, the results are joined: the control stays pending until
|
|
88
|
+
all of them settle.
|
|
89
|
+
|
|
90
|
+
| event | detail |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `xui-action` | `SurfaceActionEvent` + `waitUntil(promise)`. A Button stays pending (`aria-busy="true"` and `disabled` at once; `data-pending="true"` after `PENDING_DELAY_MS`) until the promise settles. |
|
|
93
|
+
| `xui-input` | `SurfaceInputEvent` + `waitUntil`. The revision is acknowledged when the promise settles. |
|
|
94
|
+
| `xui-function-call` | `{ call, respond(value) }`. The first `respond` wins. With no response, the plugin's `onFunctionCall` result is used. |
|
|
95
|
+
| `xui-open-url` | `{ url }`, after the URL policy passed it. Cancelable: if not cancelled, it goes to `plugin.openUrl`, else `window.open(url, "_blank", "noopener,noreferrer")`. |
|
|
96
|
+
| `xui-upload` | `{ files, target: { nodeId, name }, waitUntil }` |
|
|
97
|
+
| `xui-paint-error` | `{ error }` |
|
|
98
|
+
| `xui-theme-issues` | `{ issues }` |
|
|
99
|
+
| `xui-unknown` | `{ node }` |
|
|
100
|
+
| `xui-status` | `{ status, detail? }` |
|
|
101
|
+
| `xui-ready` | `{ handle }`. Fires once per mount, in a microtask after the handle arrives, so listeners added right after `appendChild` still get it. |
|
|
102
|
+
|
|
103
|
+
`HTMLElementEventMap` and `HTMLElementTagNameMap` are augmented, so
|
|
104
|
+
`addEventListener("xui-action", …)` and `document.createElement("exponential-surface")`
|
|
105
|
+
are typed.
|
|
106
|
+
|
|
107
|
+
## The host API
|
|
108
|
+
|
|
109
|
+
When `src` is set and no `host` property is given, the element builds
|
|
110
|
+
`new ExponentialHost({ transport })` with one of these transports:
|
|
111
|
+
|
|
112
|
+
- `WebSocketTransport` when `src` is a `ws:`/`wss:` URL or `transport="ws"`.
|
|
113
|
+
- `SseTransport` when `transport="sse"`.
|
|
114
|
+
- `JsonlStreamTransport` otherwise.
|
|
115
|
+
|
|
116
|
+
Client messages are POSTed to `post` (default `src`). The element connects
|
|
117
|
+
the host it built when attached, closes it when detached, and rebuilds it
|
|
118
|
+
when `src`, `post` or `transport` change. A host surface paints nothing
|
|
119
|
+
until the host has a surface with `surface-id`. Actions, functions, URLs and
|
|
120
|
+
media route through the host (`hostPlugin`). `xui-open-url` still fires
|
|
121
|
+
before the host opens a URL.
|
|
122
|
+
|
|
123
|
+
A `host` property belongs to the page. The element connects it only if it
|
|
124
|
+
has a transport and has never connected (`status === "closed"`), and it
|
|
125
|
+
never closes it.
|
|
126
|
+
|
|
127
|
+
`src` and `post` pass the page's URL policy (`plugin.urls`, the one every
|
|
128
|
+
href passes) BEFORE a transport is built (`decideTransport`): a private,
|
|
129
|
+
loopback or link-local host (`10.0.0.5`, `localhost`, `*.local`,
|
|
130
|
+
`169.254.169.254`, `::1`, decimal and IPv4-mapped literals) is denied unless
|
|
131
|
+
`plugin.urls.allowPrivate` opts it in (the page's own private origin is, so
|
|
132
|
+
a dev server on localhost streams from itself); a `hosts` allowlist holds;
|
|
133
|
+
`schemes: ["https"]` means https + wss only; `javascript:`, `file:`, `data:`
|
|
134
|
+
never connect. A `ws:`/`wss:` url is decided as its http(s) twin. A denied
|
|
135
|
+
`src` or `post` builds no host and fetches nothing: `status` is `closed`,
|
|
136
|
+
`statusDetail` says why (`src denied by the URL policy (private)`) and
|
|
137
|
+
`xui-status` fires once. The standalone bundle carries the same filter.
|
|
138
|
+
|
|
139
|
+
## Extensions
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
import { defineElementExtension } from "@exponential-at/ui-element"
|
|
143
|
+
|
|
144
|
+
el.extensions = [defineElementExtension({
|
|
145
|
+
catalog, // defineExtension(...) or its JSON
|
|
146
|
+
components: {
|
|
147
|
+
Gauge: (ctx) => {
|
|
148
|
+
const div = document.createElement("div")
|
|
149
|
+
ctx.applyRootProps(div) // class, data-xui-id, data-xui-c, data-r-*, aria, dir, style
|
|
150
|
+
div.textContent = `${ctx.props.value}`
|
|
151
|
+
div.append(...ctx.children()) // ctx.slot("header") for a slot
|
|
152
|
+
div.onclick = () => ctx.emit("press")
|
|
153
|
+
return div
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
})]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
A painter is a plain function: `ElementPaintContext` goes in, and one DOM
|
|
160
|
+
element comes out. It runs again when the node, props, theme, mode or root
|
|
161
|
+
attributes change, and the new element replaces the old one. The painted
|
|
162
|
+
children and slots are the same nodes on every re-paint. `registerExtension(ext)`
|
|
163
|
+
registers one for every surface on the page. A `components` key that names a
|
|
164
|
+
core native overrides its painter. A host built from `src` learns the
|
|
165
|
+
catalogs of `el.extensions` when it is built: set the extensions before the
|
|
166
|
+
element attaches (or before `src`).
|
|
167
|
+
|
|
168
|
+
## Icons for framework-less hosts
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
el.plugin = { icons: iconsFromSvg((name) => sprite[name]) } // SVG markup strings
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Each markup string becomes an icon component, created once per distinct
|
|
175
|
+
string. A name with no markup falls back to the renderer's own Lucide
|
|
176
|
+
glyphs. The wrapper sets on the `<svg>` root what lucide-react's root
|
|
177
|
+
carries for the props it receives:
|
|
178
|
+
|
|
179
|
+
- `width`/`height` = `width` ?? `size` ?? 24.
|
|
180
|
+
- `class` = the markup's own classes + the painter's.
|
|
181
|
+
- `aria-hidden="true"`, unless an aria-*/role/title prop is passed.
|
|
182
|
+
- `stroke` = `color`, `stroke-width` = `strokeWidth`.
|
|
183
|
+
- Every other string or number attribute as given (`data-icon`…).
|
|
184
|
+
|
|
185
|
+
The markup is trusted, but `<script>`, `foreignObject`, `on*` attributes
|
|
186
|
+
and `javascript:` links are stripped anyway.
|
|
187
|
+
|
|
188
|
+
## Entries
|
|
189
|
+
|
|
190
|
+
| entry | what |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `@exponential-at/ui-element` | No side effects: the class, `TAG`, `define(tag?)`, the helpers, and re-exports of `createSurface`, `registerExtension` and `defineSolidExtension` |
|
|
193
|
+
| `@exponential-at/ui-element/define` | Calls `define()` on import (idempotent; a tag taken by another class throws; another tag gets its own subclass) |
|
|
194
|
+
| `@exponential-at/ui-element/standalone` | The same, bundled self-contained (Solid and the renderer inlined) into one ES module |
|
|
195
|
+
|
|
196
|
+
## Layout
|
|
197
|
+
|
|
198
|
+
| path | what |
|
|
199
|
+
|---|---|
|
|
200
|
+
| `src/element.ts` | `ExponentialSurfaceElement`: the signals, attributes and properties, the source order, the merged plugin, mounting |
|
|
201
|
+
| `src/events.ts` | Event names, detail types, the global augmentations, the `waitUntil` join |
|
|
202
|
+
| `src/transport.ts` | `src`/`post`/`transport` → an `ExponentialHost` |
|
|
203
|
+
| `src/extensions.ts` | `defineElementExtension`, `registerExtension`, `applyRootProps` |
|
|
204
|
+
| `src/icons.ts` | `iconsFromSvg`, `svgIcon` |
|
|
205
|
+
| `src/index.ts`, `define.ts`, `standalone.ts` | The entries |
|
|
206
|
+
| `src/*.test.ts` | jsdom suites: element, events, transport, extensions, DOM parity with React |
|
|
207
|
+
|
|
208
|
+
## Commands
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
bun run --filter @exponential-at/ui-element typecheck
|
|
212
|
+
bun run --filter @exponential-at/ui-element test
|
|
213
|
+
```
|