@fundamental-engine/elements 0.5.1
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 +120 -0
- package/custom-elements.json +2832 -0
- package/dist/base.d.ts +9 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +12 -0
- package/dist/base.js.map +1 -0
- package/dist/cell-force.d.ts +10 -0
- package/dist/cell-force.d.ts.map +1 -0
- package/dist/cell-force.js +38 -0
- package/dist/cell-force.js.map +1 -0
- package/dist/field-cell.d.ts +62 -0
- package/dist/field-cell.d.ts.map +1 -0
- package/dist/field-cell.js +220 -0
- package/dist/field-cell.js.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +476 -0
- package/dist/index.js.map +1 -0
- package/dist/mount.d.ts +8 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +7 -0
- package/dist/mount.js.map +1 -0
- package/dist/platform-runtime.d.ts +92 -0
- package/dist/platform-runtime.d.ts.map +1 -0
- package/dist/platform-runtime.js +244 -0
- package/dist/platform-runtime.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zach Shallbetter
|
|
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,120 @@
|
|
|
1
|
+
# @fundamental-engine/elements
|
|
2
|
+
|
|
3
|
+
**The web-component keystone for [`@fundamental-engine/core`](../core).** "Every element is a body" is a
|
|
4
|
+
web-components-shaped idea: drop one tag, mark up your bodies, and the field runs in any framework or
|
|
5
|
+
plain HTML, unchanged. Semantic HTML stays the source of meaning; the field is a behavior +
|
|
6
|
+
visualization layer on top.
|
|
7
|
+
|
|
8
|
+
→ Live manual, Lab, and gallery at **[fundamental-engine.com](https://fundamental-engine.com)**.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm i @fundamental-engine/elements
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Use
|
|
17
|
+
|
|
18
|
+
Import the package once to register the elements, then mark up the field and your bodies:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script type="module">
|
|
22
|
+
import '@fundamental-engine/elements';
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<field-root accent="#4da3ff"></field-root>
|
|
26
|
+
|
|
27
|
+
<a data-body="attract" data-strength="0.9" data-range="320" data-feedback>pull me</a>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`<field-root>` mounts a fixed, full-viewport canvas behind your page and runs the engine on it. The
|
|
31
|
+
field reacts to every `[data-body]` element on the page (the *field-reacts* law). It is decorative, so
|
|
32
|
+
it is marked `aria-hidden` automatically. It is also registered as `<field-field>`.
|
|
33
|
+
|
|
34
|
+
## Marking bodies — the `data-body` vocabulary
|
|
35
|
+
|
|
36
|
+
Any element becomes a *body* by carrying `data-body`. The common attributes:
|
|
37
|
+
|
|
38
|
+
| Attribute | Meaning |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `data-body="attract"` | the force token (`attract`, `gravity`, `charge`, `sink`, …) |
|
|
41
|
+
| `data-strength` | how hard it bends the field |
|
|
42
|
+
| `data-range` | radius of influence, in px |
|
|
43
|
+
| `data-feedback` | opt in to receiving `--field-*` variables back on the element |
|
|
44
|
+
| `data-absorb` / `data-max` | for `sink` bodies: accretion load and capacity |
|
|
45
|
+
|
|
46
|
+
Bodies that opt in with `data-feedback` get `--field-*` CSS custom properties written back onto them
|
|
47
|
+
each frame — style with them (`var(--field-density)`, etc.) to make content react to the field.
|
|
48
|
+
|
|
49
|
+
## `<field-root>` attributes
|
|
50
|
+
|
|
51
|
+
`accent` · `density` · `waves` · `render` (`dots` / `trails` / `links` / `streamlines` / `metaballs` /
|
|
52
|
+
`voronoi`) · `palette` (`ours` / `heatmap` / `infrared` / `spectrum`) · `mass` · `attention` ·
|
|
53
|
+
`causality`. The engine ships 16 render modes in all (including `field-lines`, `heatmap`, and the
|
|
54
|
+
diagnostics); the others are reached through `setRender()` / the core, not this attribute.
|
|
55
|
+
|
|
56
|
+
## Methods — the `FieldHandle`, proxied onto the element
|
|
57
|
+
|
|
58
|
+
Every `FieldHandle` method is available directly on the element:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const field = document.querySelector('field-root');
|
|
62
|
+
field.scan(); // after adding [data-body] elements
|
|
63
|
+
field.setFormation('wells');
|
|
64
|
+
field.setAttention(true);
|
|
65
|
+
field.setRender('streamlines');
|
|
66
|
+
field.setOverlay('field-lines'); // a second canvas in front of content
|
|
67
|
+
field.flowTo(x, y); // a movable flow focus the field bends toward
|
|
68
|
+
field.burst(x, y); // a one-off impulse
|
|
69
|
+
field.destroy(); // stop the loop, remove the canvas
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
| Method | Use |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `scan()` / `rescan()` | re-read `[data-body]` elements after the DOM changes |
|
|
75
|
+
| `setAccent(hex)` · `setPalette(p)` | recolor live |
|
|
76
|
+
| `setFormation(name)` | arrange particles into a named formation |
|
|
77
|
+
| `setRender(mode)` · `setOverlay(mode)` | underlay (behind content) / overlay (in front) |
|
|
78
|
+
| `setAttention(on)` · `setCausality(on)` · `setHeatmap(on)` | toggle diagnostics |
|
|
79
|
+
| `burst(x, y, hex?)` · `flowTo(x, y)` · `clearFlow()` | impulses and a movable focus |
|
|
80
|
+
| `threads(list)` | draw relationship threads between bodies |
|
|
81
|
+
|
|
82
|
+
### Imperative mount
|
|
83
|
+
|
|
84
|
+
For a canvas you do not want declared in markup, `mountField(opts)` creates one, starts the engine, and
|
|
85
|
+
returns the handle (its `destroy()` also removes the canvas).
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import { mountField } from '@fundamental-engine/elements';
|
|
89
|
+
const field = mountField({ render: 'trails', accent: '#2dd4bf' });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Local cells
|
|
93
|
+
|
|
94
|
+
`<field-cell>` is a self-contained, container-sized field surface for embedded demos (one force or
|
|
95
|
+
formation inside a frame), separate from the page-wide `<field-root>`. It runs a deliberately
|
|
96
|
+
simplified in-frame model, not the canonical engine math.
|
|
97
|
+
|
|
98
|
+
## Framework use
|
|
99
|
+
|
|
100
|
+
The custom elements work unchanged in React, Vue, Svelte, Solid, Angular, or plain HTML — register once
|
|
101
|
+
(`import '@fundamental-engine/elements'`) and write `<field-root>` in your markup. In React, prefer
|
|
102
|
+
[`@fundamental-engine/react`](../react) for typed props and a `FieldHandle` ref; reach for the element directly
|
|
103
|
+
when you want one field across a whole page regardless of framework.
|
|
104
|
+
|
|
105
|
+
## Recipes & data binding
|
|
106
|
+
|
|
107
|
+
To apply a named recipe over your markup (or bind data to it) rather than wire bodies by hand, use
|
|
108
|
+
`applyRecipe()` / `bindData()` from [`@fundamental-engine/platform`](../platform); browse all 64 recipes at
|
|
109
|
+
[`/docs/gallery`](https://fundamental-engine.com/docs/gallery). The starter app in
|
|
110
|
+
[`apps/starter`](../../apps/starter) shows the declarative element, `applyRecipe`, and `bindData`
|
|
111
|
+
together.
|
|
112
|
+
|
|
113
|
+
## Related
|
|
114
|
+
|
|
115
|
+
[`@fundamental-engine/core`](../core) · [`@fundamental-engine/platform`](../platform) · [`@fundamental-engine/react`](../react) ·
|
|
116
|
+
[`@fundamental-engine/vanilla`](../vanilla) · the [documentation map](../../docs/README.md).
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT © Zach Shallbetter
|