bireactive 0.2.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 +81 -0
- package/dist/animation/anim.d.ts +57 -0
- package/dist/animation/anim.js +318 -0
- package/dist/animation/combinators.d.ts +39 -0
- package/dist/animation/combinators.js +113 -0
- package/dist/animation/easings.d.ts +5 -0
- package/dist/animation/easings.js +5 -0
- package/dist/animation/index.d.ts +3 -0
- package/dist/animation/index.js +3 -0
- package/dist/assert/algebra.d.ts +20 -0
- package/dist/assert/algebra.js +79 -0
- package/dist/assert/claim.d.ts +40 -0
- package/dist/assert/claim.js +129 -0
- package/dist/assert/index.d.ts +7 -0
- package/dist/assert/index.js +19 -0
- package/dist/assert/predicates.d.ts +18 -0
- package/dist/assert/predicates.js +43 -0
- package/dist/assert/record.d.ts +20 -0
- package/dist/assert/record.js +78 -0
- package/dist/assert/scope.d.ts +42 -0
- package/dist/assert/scope.js +233 -0
- package/dist/assert/span.d.ts +37 -0
- package/dist/assert/span.js +68 -0
- package/dist/assert/tree.d.ts +22 -0
- package/dist/assert/tree.js +65 -0
- package/dist/code/code.d.ts +70 -0
- package/dist/code/code.js +361 -0
- package/dist/code/index.d.ts +2 -0
- package/dist/code/index.js +9 -0
- package/dist/code/morph.d.ts +5 -0
- package/dist/code/morph.js +194 -0
- package/dist/code/tokenize.d.ts +8 -0
- package/dist/code/tokenize.js +51 -0
- package/dist/constraints/cluster.d.ts +83 -0
- package/dist/constraints/cluster.js +213 -0
- package/dist/constraints/drivers.d.ts +15 -0
- package/dist/constraints/drivers.js +40 -0
- package/dist/constraints/factories.d.ts +73 -0
- package/dist/constraints/factories.js +248 -0
- package/dist/constraints/index.d.ts +11 -0
- package/dist/constraints/index.js +39 -0
- package/dist/constraints/interaction.d.ts +21 -0
- package/dist/constraints/interaction.js +148 -0
- package/dist/constraints/linalg.d.ts +18 -0
- package/dist/constraints/linalg.js +141 -0
- package/dist/constraints/phases.d.ts +21 -0
- package/dist/constraints/phases.js +60 -0
- package/dist/constraints/physics.d.ts +34 -0
- package/dist/constraints/physics.js +128 -0
- package/dist/constraints/rigid.d.ts +210 -0
- package/dist/constraints/rigid.js +835 -0
- package/dist/constraints/solver.d.ts +107 -0
- package/dist/constraints/solver.js +510 -0
- package/dist/constraints/term.d.ts +50 -0
- package/dist/constraints/term.js +80 -0
- package/dist/constraints/terms.d.ts +80 -0
- package/dist/constraints/terms.js +302 -0
- package/dist/constraints/world.d.ts +31 -0
- package/dist/constraints/world.js +245 -0
- package/dist/core/aggregates.d.ts +64 -0
- package/dist/core/aggregates.js +198 -0
- package/dist/core/anim.d.ts +84 -0
- package/dist/core/anim.js +301 -0
- package/dist/core/index.d.ts +38 -0
- package/dist/core/index.js +38 -0
- package/dist/core/introspect.d.ts +5 -0
- package/dist/core/introspect.js +31 -0
- package/dist/core/lenses/closed-form-policies.d.ts +64 -0
- package/dist/core/lenses/closed-form-policies.js +452 -0
- package/dist/core/lenses/domain-aggregates.d.ts +54 -0
- package/dist/core/lenses/domain-aggregates.js +259 -0
- package/dist/core/lenses/factor-lens.d.ts +42 -0
- package/dist/core/lenses/factor-lens.js +419 -0
- package/dist/core/lenses/index.d.ts +5 -0
- package/dist/core/lenses/index.js +16 -0
- package/dist/core/lenses/memory.d.ts +47 -0
- package/dist/core/lenses/memory.js +102 -0
- package/dist/core/lenses/typed-factor.d.ts +45 -0
- package/dist/core/lenses/typed-factor.js +376 -0
- package/dist/core/network-utils.d.ts +14 -0
- package/dist/core/network-utils.js +62 -0
- package/dist/core/new-primitives.d.ts +33 -0
- package/dist/core/new-primitives.js +113 -0
- package/dist/core/signal.d.ts +254 -0
- package/dist/core/signal.js +1349 -0
- package/dist/core/traits.d.ts +61 -0
- package/dist/core/traits.js +56 -0
- package/dist/core/tree.d.ts +23 -0
- package/dist/core/tree.js +62 -0
- package/dist/core/values/anchor.d.ts +23 -0
- package/dist/core/values/anchor.js +23 -0
- package/dist/core/values/audio.d.ts +33 -0
- package/dist/core/values/audio.js +107 -0
- package/dist/core/values/bool.d.ts +37 -0
- package/dist/core/values/bool.js +75 -0
- package/dist/core/values/box.d.ts +77 -0
- package/dist/core/values/box.js +211 -0
- package/dist/core/values/canvas.d.ts +71 -0
- package/dist/core/values/canvas.js +495 -0
- package/dist/core/values/color.d.ts +49 -0
- package/dist/core/values/color.js +106 -0
- package/dist/core/values/flags.d.ts +18 -0
- package/dist/core/values/flags.js +50 -0
- package/dist/core/values/gpu.d.ts +74 -0
- package/dist/core/values/gpu.js +426 -0
- package/dist/core/values/matrix.d.ts +53 -0
- package/dist/core/values/matrix.js +140 -0
- package/dist/core/values/num.d.ts +62 -0
- package/dist/core/values/num.js +166 -0
- package/dist/core/values/pose.d.ts +31 -0
- package/dist/core/values/pose.js +83 -0
- package/dist/core/values/range.d.ts +83 -0
- package/dist/core/values/range.js +167 -0
- package/dist/core/values/str.d.ts +76 -0
- package/dist/core/values/str.js +346 -0
- package/dist/core/values/template.d.ts +49 -0
- package/dist/core/values/template.js +148 -0
- package/dist/core/values/transform.d.ts +49 -0
- package/dist/core/values/transform.js +115 -0
- package/dist/core/values/tri.d.ts +31 -0
- package/dist/core/values/tri.js +95 -0
- package/dist/core/values/vec.d.ts +72 -0
- package/dist/core/values/vec.js +219 -0
- package/dist/core/writable.d.ts +15 -0
- package/dist/core/writable.js +29 -0
- package/dist/ext/events.d.ts +10 -0
- package/dist/ext/events.js +31 -0
- package/dist/ext/index.d.ts +4 -0
- package/dist/ext/index.js +4 -0
- package/dist/ext/snapshot.d.ts +8 -0
- package/dist/ext/snapshot.js +29 -0
- package/dist/ext/timeline.d.ts +56 -0
- package/dist/ext/timeline.js +94 -0
- package/dist/ext/waapi.d.ts +25 -0
- package/dist/ext/waapi.js +198 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10 -0
- package/dist/propagators/index.d.ts +6 -0
- package/dist/propagators/index.js +6 -0
- package/dist/propagators/layout.d.ts +68 -0
- package/dist/propagators/layout.js +336 -0
- package/dist/propagators/network.d.ts +52 -0
- package/dist/propagators/network.js +185 -0
- package/dist/propagators/propagator.d.ts +12 -0
- package/dist/propagators/propagator.js +16 -0
- package/dist/propagators/range.d.ts +45 -0
- package/dist/propagators/range.js +147 -0
- package/dist/propagators/relations.d.ts +60 -0
- package/dist/propagators/relations.js +343 -0
- package/dist/shapes/annular-sector.d.ts +15 -0
- package/dist/shapes/annular-sector.js +64 -0
- package/dist/shapes/button.d.ts +14 -0
- package/dist/shapes/button.js +31 -0
- package/dist/shapes/choreographers.d.ts +22 -0
- package/dist/shapes/choreographers.js +69 -0
- package/dist/shapes/circle.d.ts +17 -0
- package/dist/shapes/circle.js +57 -0
- package/dist/shapes/clip.d.ts +5 -0
- package/dist/shapes/clip.js +31 -0
- package/dist/shapes/connect.d.ts +16 -0
- package/dist/shapes/connect.js +70 -0
- package/dist/shapes/curve.d.ts +60 -0
- package/dist/shapes/curve.js +285 -0
- package/dist/shapes/dashed.d.ts +16 -0
- package/dist/shapes/dashed.js +142 -0
- package/dist/shapes/debug.d.ts +43 -0
- package/dist/shapes/debug.js +97 -0
- package/dist/shapes/group.d.ts +5 -0
- package/dist/shapes/group.js +10 -0
- package/dist/shapes/handle.d.ts +32 -0
- package/dist/shapes/handle.js +88 -0
- package/dist/shapes/index.d.ts +23 -0
- package/dist/shapes/index.js +23 -0
- package/dist/shapes/interaction.d.ts +32 -0
- package/dist/shapes/interaction.js +187 -0
- package/dist/shapes/label.d.ts +20 -0
- package/dist/shapes/label.js +42 -0
- package/dist/shapes/layout.d.ts +29 -0
- package/dist/shapes/layout.js +74 -0
- package/dist/shapes/line.d.ts +21 -0
- package/dist/shapes/line.js +79 -0
- package/dist/shapes/list.d.ts +18 -0
- package/dist/shapes/list.js +51 -0
- package/dist/shapes/mount.d.ts +7 -0
- package/dist/shapes/mount.js +10 -0
- package/dist/shapes/path.d.ts +77 -0
- package/dist/shapes/path.js +227 -0
- package/dist/shapes/rect.d.ts +30 -0
- package/dist/shapes/rect.js +131 -0
- package/dist/shapes/shape.d.ts +132 -0
- package/dist/shapes/shape.js +306 -0
- package/dist/shapes/text.d.ts +24 -0
- package/dist/shapes/text.js +53 -0
- package/dist/shapes/tokens.d.ts +28 -0
- package/dist/shapes/tokens.js +27 -0
- package/dist/shapes/transitions.d.ts +23 -0
- package/dist/shapes/transitions.js +62 -0
- package/dist/tex/decorations.d.ts +26 -0
- package/dist/tex/decorations.js +116 -0
- package/dist/tex/index.d.ts +5 -0
- package/dist/tex/index.js +5 -0
- package/dist/tex/marker.d.ts +17 -0
- package/dist/tex/marker.js +63 -0
- package/dist/tex/motion.d.ts +43 -0
- package/dist/tex/motion.js +290 -0
- package/dist/tex/parts.d.ts +65 -0
- package/dist/tex/parts.js +149 -0
- package/dist/tex/tex.d.ts +45 -0
- package/dist/tex/tex.js +244 -0
- package/dist/web/attr.d.ts +16 -0
- package/dist/web/attr.js +98 -0
- package/dist/web/diagram.d.ts +49 -0
- package/dist/web/diagram.js +260 -0
- package/dist/web/index.d.ts +6 -0
- package/dist/web/index.js +6 -0
- package/dist/web/md-marker.d.ts +6 -0
- package/dist/web/md-marker.js +39 -0
- package/dist/web/md-tex.d.ts +6 -0
- package/dist/web/md-tex.js +61 -0
- package/dist/web/raf.d.ts +6 -0
- package/dist/web/raf.js +24 -0
- package/dist/web/viewport.d.ts +7 -0
- package/dist/web/viewport.js +13 -0
- package/package.json +87 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Prose-linking element for plain (non-math) text — same wiring as <md-tex sym="...">.
|
|
2
|
+
import { effect } from "../core/index.js";
|
|
3
|
+
import { getMarker as getGlobalMarker, highlightTint, hover } from "../tex/index.js";
|
|
4
|
+
function resolveMarker(id, forId) {
|
|
5
|
+
if (forId) {
|
|
6
|
+
const el = document.getElementById(forId);
|
|
7
|
+
return el?.getMarker?.(id);
|
|
8
|
+
}
|
|
9
|
+
return getGlobalMarker(id);
|
|
10
|
+
}
|
|
11
|
+
export class MdMarker extends HTMLElement {
|
|
12
|
+
#disposers = [];
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
const id = this.getAttribute("sym");
|
|
15
|
+
if (!id)
|
|
16
|
+
return;
|
|
17
|
+
const forId = this.getAttribute("for");
|
|
18
|
+
const m = resolveMarker(id, forId);
|
|
19
|
+
if (!m)
|
|
20
|
+
return;
|
|
21
|
+
this.style.borderRadius = "2px";
|
|
22
|
+
this.style.transition = "background-color 120ms ease-out";
|
|
23
|
+
this.style.cursor = "default";
|
|
24
|
+
this.#disposers.push(hover(this, m), effect(() => {
|
|
25
|
+
this.style.color = m.color.value ?? "";
|
|
26
|
+
}), effect(() => {
|
|
27
|
+
const color = m.color.value;
|
|
28
|
+
this.style.backgroundColor = m.active.value && color ? highlightTint(color) : "";
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
for (const d of this.#disposers)
|
|
33
|
+
d();
|
|
34
|
+
this.#disposers.length = 0;
|
|
35
|
+
}
|
|
36
|
+
static define() {
|
|
37
|
+
customElements.define("md-marker", this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Inline math custom element with optional prose-linking via `for`/`sym`.
|
|
2
|
+
import { effect } from "../core/index.js";
|
|
3
|
+
import { getMarker as getGlobalMarker, highlightTint, hover, renderToMathML, } from "../tex/index.js";
|
|
4
|
+
const SYM_RE = /\\sym\{([^}]+)\}\{([^}]*)\}/g;
|
|
5
|
+
const symClass = (id) => `bireactive-sym-${id.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
6
|
+
function resolveMarker(id, forId) {
|
|
7
|
+
if (forId) {
|
|
8
|
+
const el = document.getElementById(forId);
|
|
9
|
+
return el?.getMarker?.(id);
|
|
10
|
+
}
|
|
11
|
+
return getGlobalMarker(id);
|
|
12
|
+
}
|
|
13
|
+
export class MdTex extends HTMLElement {
|
|
14
|
+
#disposers = [];
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
const singleId = this.getAttribute("sym");
|
|
17
|
+
const forId = this.getAttribute("for");
|
|
18
|
+
const src = this.textContent?.trim() ?? "";
|
|
19
|
+
if (singleId) {
|
|
20
|
+
this.innerHTML = renderToMathML(src);
|
|
21
|
+
const m = resolveMarker(singleId, forId);
|
|
22
|
+
if (m)
|
|
23
|
+
this.#wire(this, m);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Full expression — pre-process \sym{id}{content}
|
|
27
|
+
const symIds = new Map(); // cssClass → registryId
|
|
28
|
+
const processedSrc = src.replace(SYM_RE, (_, id, content) => {
|
|
29
|
+
const cls = symClass(id);
|
|
30
|
+
symIds.set(cls, id);
|
|
31
|
+
return `\\class{${cls}}{${content}}`;
|
|
32
|
+
});
|
|
33
|
+
this.innerHTML = renderToMathML(processedSrc);
|
|
34
|
+
for (const [cls, id] of symIds) {
|
|
35
|
+
const m = resolveMarker(id, forId);
|
|
36
|
+
if (!m)
|
|
37
|
+
continue;
|
|
38
|
+
for (const el of this.querySelectorAll(`.${cls}`))
|
|
39
|
+
this.#wire(el, m);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
#wire(el, m) {
|
|
43
|
+
el.style.borderRadius = "2px";
|
|
44
|
+
el.style.transition = "background-color 120ms ease-out";
|
|
45
|
+
el.style.cursor = "default";
|
|
46
|
+
this.#disposers.push(hover(el, m), effect(() => {
|
|
47
|
+
el.style.color = m.color.value ?? "";
|
|
48
|
+
}), effect(() => {
|
|
49
|
+
const color = m.color.value;
|
|
50
|
+
el.style.backgroundColor = m.active.value && color ? highlightTint(color) : "";
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
for (const d of this.#disposers)
|
|
55
|
+
d();
|
|
56
|
+
this.#disposers.length = 0;
|
|
57
|
+
}
|
|
58
|
+
static define() {
|
|
59
|
+
customElements.define("md-tex", this);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/web/raf.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// requestAnimationFrame adapter for the engine. Lives in `web/`
|
|
2
|
+
// because it depends on the browser; core is renderer-agnostic.
|
|
3
|
+
/** Drive `anim.step(dt)` on every animation frame. Caps `dt` at 32 ms
|
|
4
|
+
* so a backgrounded tab doesn't deliver one giant frame on resume.
|
|
5
|
+
* Returns a disposer. */
|
|
6
|
+
export function attachRaf(anim) {
|
|
7
|
+
if (typeof requestAnimationFrame !== "function")
|
|
8
|
+
return () => { };
|
|
9
|
+
const FRAME_CAP_MS = 32;
|
|
10
|
+
let rafId = 0, last = 0;
|
|
11
|
+
const tick = (now) => {
|
|
12
|
+
rafId = requestAnimationFrame(tick);
|
|
13
|
+
const dt = last ? Math.min(now - last, FRAME_CAP_MS) / 1000 : 0;
|
|
14
|
+
last = now;
|
|
15
|
+
anim.step(dt);
|
|
16
|
+
};
|
|
17
|
+
rafId = requestAnimationFrame(tick);
|
|
18
|
+
return () => {
|
|
19
|
+
if (rafId)
|
|
20
|
+
cancelAnimationFrame(rafId);
|
|
21
|
+
rafId = 0;
|
|
22
|
+
last = 0;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Shared viewport signal — one lazy resize listener, re-emits on resize.
|
|
2
|
+
import { cell } from "../core/index.js";
|
|
3
|
+
let cached;
|
|
4
|
+
export function viewport() {
|
|
5
|
+
if (cached)
|
|
6
|
+
return cached;
|
|
7
|
+
const sig = cell({ w: window.innerWidth, h: window.innerHeight });
|
|
8
|
+
window.addEventListener("resize", () => {
|
|
9
|
+
sig.value = { w: window.innerWidth, h: window.innerHeight };
|
|
10
|
+
});
|
|
11
|
+
cached = sig;
|
|
12
|
+
return sig;
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bireactive",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Bi-directional reactive programming.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"module": "./src/index.ts",
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
|
+
"import": "./src/index.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite --host",
|
|
34
|
+
"site": "vite-node site/build.ts && vite build && vite-node site/build.ts",
|
|
35
|
+
"preview": "vite preview",
|
|
36
|
+
"prebuild": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
37
|
+
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths",
|
|
38
|
+
"test": "vitest --config vitest.config.ts run",
|
|
39
|
+
"test:watch": "vitest --config vitest.config.ts",
|
|
40
|
+
"bench": "node --expose-gc node_modules/.bin/vite-node",
|
|
41
|
+
"typecheck": "tsc --noEmit --pretty",
|
|
42
|
+
"fmt": "biome check --write .",
|
|
43
|
+
"prepublishOnly": "npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"prism-esm": "^1.29.0-fix.6",
|
|
47
|
+
"temml": "^0.13.3"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@biomejs/biome": "2.4.15",
|
|
51
|
+
"@preact/signals-core": "^1.14.2",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"alien-signals": "^3.2.1",
|
|
54
|
+
"fast-check": "^4.8.0",
|
|
55
|
+
"gray-matter": "^4.0.3",
|
|
56
|
+
"marked": "^12.0.0",
|
|
57
|
+
"marked-footnote": "^1.4.0",
|
|
58
|
+
"mitata": "^1.0.34",
|
|
59
|
+
"reactive-framework-test-suite": "^0.0.2",
|
|
60
|
+
"tsc-alias": "^1.8.17",
|
|
61
|
+
"typescript": "^6.0.3",
|
|
62
|
+
"vite": "^7.3.3",
|
|
63
|
+
"vite-node": "^5.3.0",
|
|
64
|
+
"vitest": "^4.1.7"
|
|
65
|
+
},
|
|
66
|
+
"keywords": [
|
|
67
|
+
"bireactive",
|
|
68
|
+
"reactive",
|
|
69
|
+
"signals",
|
|
70
|
+
"svg",
|
|
71
|
+
"animation",
|
|
72
|
+
"diagrams",
|
|
73
|
+
"constraints",
|
|
74
|
+
"propagators"
|
|
75
|
+
],
|
|
76
|
+
"author": "Orion Reed",
|
|
77
|
+
"license": "MIT",
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=20.19"
|
|
80
|
+
},
|
|
81
|
+
"repository": {
|
|
82
|
+
"type": "git",
|
|
83
|
+
"url": "git+https://github.com/OrionReed/bireactive.git"
|
|
84
|
+
},
|
|
85
|
+
"homepage": "https://github.com/OrionReed/bireactive",
|
|
86
|
+
"bugs": "https://github.com/OrionReed/bireactive/issues"
|
|
87
|
+
}
|