@ag2/weave 0.12.0 → 0.13.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/README.md +15 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/orb-background/OrbBackground.css.d.ts +3 -0
- package/dist/components/orb-background/OrbBackground.d.ts +7 -0
- package/dist/components/orb-background/index.d.ts +2 -0
- package/dist/components/orb-background/orbAppearance.d.ts +2 -0
- package/dist/components/orb-background/orbField.d.ts +1 -0
- package/dist/index.js +372 -31
- package/dist/index.js.map +1 -1
- package/dist/style.css +18 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
The AG2 Space design system. Forked from [folds](https://github.com/cinnyapp/folds) 2.6.2 (Apache-2.0); `@ag2/weave@0.1.0` is folds@2.6.2 under the new name.
|
|
6
6
|
|
|
7
|
+
## Ambient orb background
|
|
8
|
+
|
|
9
|
+
`OrbBackground` renders the Absorb / Calm / Aura field and is the default background
|
|
10
|
+
of `SplashScreen`. Place it inside an element with the exported `OrbBackgroundHost`
|
|
11
|
+
class so its decorative canvas sits behind content and is clipped at the surface edge.
|
|
12
|
+
The parent supplies its background colour through the normal theme tokens.
|
|
13
|
+
|
|
14
|
+
It follows the resolved `color.Background.Container` token, including nested and custom
|
|
15
|
+
themes. An optional `appearance="light" | "dark"` prop lets a framing host override the
|
|
16
|
+
colour intensity. Reduced motion renders a static field; hidden documents pause animation.
|
|
17
|
+
All animation frames, resize observers, and theme listeners are removed on unmount.
|
|
18
|
+
`Starfield` and `StarfieldHost` remain exported for existing consumers.
|
|
19
|
+
|
|
20
|
+
The field is adapted from [matty-morgs/octo-space](https://github.com/matty-morgs/octo-space/blob/7f5536888eaf0068200e1d339318ba2bc57a5e40/onboarding-aura/index.html).
|
|
21
|
+
|
|
7
22
|
<!-- original folds README follows -->
|
|
8
23
|
|
|
9
24
|
# Folds
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare type OrbBackgroundProps = {
|
|
2
|
+
className?: string;
|
|
3
|
+
/** Optional framing-host override; otherwise follows the active surface token. */
|
|
4
|
+
appearance?: "light" | "dark";
|
|
5
|
+
};
|
|
6
|
+
/** Calm, blurred orbs with absorb collisions. Place inside an OrbBackgroundHost surface. */
|
|
7
|
+
export declare const OrbBackground: ({ className, appearance }: OrbBackgroundProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function startOrbField(element: HTMLCanvasElement): () => void;
|
package/dist/index.js
CHANGED
|
@@ -4947,7 +4947,7 @@ const e$x = /* @__PURE__ */ new Map([
|
|
|
4947
4947
|
const e$w = a$T.forwardRef((r2, t2) => /* @__PURE__ */ a$T.createElement(p$5, { ref: t2, ...r2, weights: e$x }));
|
|
4948
4948
|
e$w.displayName = "SunIcon";
|
|
4949
4949
|
const s$4 = e$w;
|
|
4950
|
-
const H = /* @__PURE__ */ new Map([
|
|
4950
|
+
const H$1 = /* @__PURE__ */ new Map([
|
|
4951
4951
|
[
|
|
4952
4952
|
"bold",
|
|
4953
4953
|
/* @__PURE__ */ a$T.createElement(a$T.Fragment, null, /* @__PURE__ */ a$T.createElement("path", { d: "M224,44H32A12,12,0,0,0,20,56V192a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V56A12,12,0,0,0,224,44ZM44,116H76v24H44Zm56,0H212v24H100ZM212,68V92H44V68ZM44,164H76v24H44Zm56,24V164H212v24Z" }))
|
|
@@ -4973,7 +4973,7 @@ const H = /* @__PURE__ */ new Map([
|
|
|
4973
4973
|
/* @__PURE__ */ a$T.createElement(a$T.Fragment, null, /* @__PURE__ */ a$T.createElement("path", { d: "M224,52H32a4,4,0,0,0-4,4V192a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A4,4,0,0,0,224,52ZM36,108H84v40H36Zm56,0H220v40H92ZM220,60v40H36V60ZM36,192V156H84v40H40A4,4,0,0,1,36,192Zm180,4H92V156H220v36A4,4,0,0,1,216,196Z" }))
|
|
4974
4974
|
]
|
|
4975
4975
|
]);
|
|
4976
|
-
const o$a = a$T.forwardRef((a2, r2) => /* @__PURE__ */ a$T.createElement(p$5, { ref: r2, ...a2, weights: H }));
|
|
4976
|
+
const o$a = a$T.forwardRef((a2, r2) => /* @__PURE__ */ a$T.createElement(p$5, { ref: r2, ...a2, weights: H$1 }));
|
|
4977
4977
|
o$a.displayName = "TableIcon";
|
|
4978
4978
|
const n$e = o$a;
|
|
4979
4979
|
const e$v = /* @__PURE__ */ new Map([
|
|
@@ -8251,8 +8251,8 @@ const containRe = /paint|layout|strict|content/;
|
|
|
8251
8251
|
const isNotNone = (value) => !!value && value !== "none";
|
|
8252
8252
|
let isWebKitValue;
|
|
8253
8253
|
function isContainingBlock(elementOrCss) {
|
|
8254
|
-
const
|
|
8255
|
-
return isNotNone(
|
|
8254
|
+
const css2 = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
8255
|
+
return isNotNone(css2.transform) || isNotNone(css2.translate) || isNotNone(css2.scale) || isNotNone(css2.rotate) || isNotNone(css2.perspective) || !isWebKit() && (isNotNone(css2.backdropFilter) || isNotNone(css2.filter)) || willChangeRe.test(css2.willChange || "") || containRe.test(css2.contain || "");
|
|
8256
8256
|
}
|
|
8257
8257
|
function getContainingBlock(element) {
|
|
8258
8258
|
let currentNode = getParentNode(element);
|
|
@@ -8335,9 +8335,9 @@ function getFrameElement(win) {
|
|
|
8335
8335
|
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
8336
8336
|
}
|
|
8337
8337
|
function getCssDimensions(element) {
|
|
8338
|
-
const
|
|
8339
|
-
let width = parseFloat(
|
|
8340
|
-
let height = parseFloat(
|
|
8338
|
+
const css2 = getComputedStyle$1(element);
|
|
8339
|
+
let width = parseFloat(css2.width) || 0;
|
|
8340
|
+
let height = parseFloat(css2.height) || 0;
|
|
8341
8341
|
const hasOffset = isHTMLElement(element);
|
|
8342
8342
|
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
8343
8343
|
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
@@ -8428,9 +8428,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
8428
8428
|
while (currentIFrame && offsetWin !== currentWin) {
|
|
8429
8429
|
const iframeScale = getScale(currentIFrame);
|
|
8430
8430
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
8431
|
-
const
|
|
8432
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(
|
|
8433
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(
|
|
8431
|
+
const css2 = getComputedStyle$1(currentIFrame);
|
|
8432
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css2.paddingLeft)) * iframeScale.x;
|
|
8433
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css2.paddingTop)) * iframeScale.y;
|
|
8434
8434
|
x *= iframeScale.x;
|
|
8435
8435
|
y *= iframeScale.y;
|
|
8436
8436
|
width *= iframeScale.x;
|
|
@@ -10834,11 +10834,11 @@ function makeStyleTag() {
|
|
|
10834
10834
|
}
|
|
10835
10835
|
return tag;
|
|
10836
10836
|
}
|
|
10837
|
-
function injectStyles(tag,
|
|
10837
|
+
function injectStyles(tag, css2) {
|
|
10838
10838
|
if (tag.styleSheet) {
|
|
10839
|
-
tag.styleSheet.cssText =
|
|
10839
|
+
tag.styleSheet.cssText = css2;
|
|
10840
10840
|
} else {
|
|
10841
|
-
tag.appendChild(document.createTextNode(
|
|
10841
|
+
tag.appendChild(document.createTextNode(css2));
|
|
10842
10842
|
}
|
|
10843
10843
|
}
|
|
10844
10844
|
function insertStyleTag(tag) {
|
|
@@ -15493,7 +15493,7 @@ function mountAliveMark(container, opts) {
|
|
|
15493
15493
|
function now() {
|
|
15494
15494
|
return window.performance && performance.now ? performance.now() : Date.now();
|
|
15495
15495
|
}
|
|
15496
|
-
function
|
|
15496
|
+
function rnd2(a2, b) {
|
|
15497
15497
|
return a2 + Math.random() * (b - a2);
|
|
15498
15498
|
}
|
|
15499
15499
|
function setA(el, name, val) {
|
|
@@ -15527,7 +15527,7 @@ function mountAliveMark(container, opts) {
|
|
|
15527
15527
|
if (!sleeping)
|
|
15528
15528
|
doBlink(Math.random() < o2.doubleBlinkChance);
|
|
15529
15529
|
scheduleBlink();
|
|
15530
|
-
},
|
|
15530
|
+
}, rnd2(o2.blinkMin, o2.blinkMax) * 1e3 * mult);
|
|
15531
15531
|
}
|
|
15532
15532
|
function doBlink(dbl) {
|
|
15533
15533
|
var t2 = now();
|
|
@@ -15561,18 +15561,18 @@ function mountAliveMark(container, opts) {
|
|
|
15561
15561
|
clearTimeout(driftT);
|
|
15562
15562
|
driftT = setTimeout(function() {
|
|
15563
15563
|
if (!reduced && !sleeping && !gazing) {
|
|
15564
|
-
tgtX =
|
|
15565
|
-
tgtY =
|
|
15564
|
+
tgtX = rnd2(-o2.driftX, o2.driftX);
|
|
15565
|
+
tgtY = rnd2(-o2.driftY, o2.driftY);
|
|
15566
15566
|
}
|
|
15567
15567
|
scheduleDrift();
|
|
15568
|
-
},
|
|
15568
|
+
}, rnd2(o2.driftMin, o2.driftMax) * 1e3);
|
|
15569
15569
|
}
|
|
15570
15570
|
function frame(t2) {
|
|
15571
15571
|
if (!running)
|
|
15572
15572
|
return;
|
|
15573
15573
|
var dt = last ? Math.min(0.05, (t2 - last) / 1e3) : 0.016;
|
|
15574
15574
|
last = t2;
|
|
15575
|
-
var
|
|
15575
|
+
var ease2 = function(tau) {
|
|
15576
15576
|
return reduced ? 1 : 1 - Math.exp(-dt / tau);
|
|
15577
15577
|
};
|
|
15578
15578
|
if (t2 - rectAt > 250) {
|
|
@@ -15589,7 +15589,7 @@ function mountAliveMark(container, opts) {
|
|
|
15589
15589
|
tgtY = 0;
|
|
15590
15590
|
}
|
|
15591
15591
|
}
|
|
15592
|
-
dreamAmt += ((sleeping ? 1 : 0) - dreamAmt) *
|
|
15592
|
+
dreamAmt += ((sleeping ? 1 : 0) - dreamAmt) * ease2(0.12);
|
|
15593
15593
|
if (dreamAmt < 1e-3)
|
|
15594
15594
|
dreamAmt = 0;
|
|
15595
15595
|
if (dreamAmt > 0.999)
|
|
@@ -15632,8 +15632,8 @@ function mountAliveMark(container, opts) {
|
|
|
15632
15632
|
tgtX = 0;
|
|
15633
15633
|
tgtY = 0;
|
|
15634
15634
|
}
|
|
15635
|
-
curX += (tgtX - curX) *
|
|
15636
|
-
curY += (tgtY - curY) *
|
|
15635
|
+
curX += (tgtX - curX) * ease2(0.18);
|
|
15636
|
+
curY += (tgtY - curY) * ease2(0.18);
|
|
15637
15637
|
setA(look, "transform", "translate(" + curX.toFixed(3) + " " + curY.toFixed(3) + ")");
|
|
15638
15638
|
var sl = lidAt(animL, t2), sr = lidAt(animR, t2);
|
|
15639
15639
|
if (animL && t2 - animL.t0 >= animL.dur)
|
|
@@ -15650,7 +15650,7 @@ function mountAliveMark(container, opts) {
|
|
|
15650
15650
|
"transform",
|
|
15651
15651
|
"translate(" + rx + " " + y + ") scale(1 " + sr.toFixed(3) + ") translate(" + -rx + " " + -y + ")"
|
|
15652
15652
|
);
|
|
15653
|
-
tiltCur += (c2.tilt - tiltCur) *
|
|
15653
|
+
tiltCur += (c2.tilt - tiltCur) * ease2(0.22);
|
|
15654
15654
|
var tstr = pillT(tiltCur.toFixed(3));
|
|
15655
15655
|
setA(swipe, "transform", tstr);
|
|
15656
15656
|
setA(clip, "transform", tstr);
|
|
@@ -15781,6 +15781,353 @@ const StackedAvatar = as(
|
|
|
15781
15781
|
)
|
|
15782
15782
|
);
|
|
15783
15783
|
const ComposeIcon = Icons.Compose;
|
|
15784
|
+
const PAL = {
|
|
15785
|
+
ember: { c: [249, 163, 88], r: [242, 102, 30] },
|
|
15786
|
+
pink: { c: [248, 206, 254], r: [229, 138, 240] },
|
|
15787
|
+
sky: { c: [173, 219, 255], r: [74, 95, 208] },
|
|
15788
|
+
mint: { c: [160, 226, 191], r: [46, 143, 94] },
|
|
15789
|
+
lemon: { c: [240, 227, 69], r: [141, 191, 58] },
|
|
15790
|
+
lilac: { c: [242, 212, 255], r: [154, 166, 255] },
|
|
15791
|
+
forest: { c: [10, 138, 68], r: [4, 90, 44] },
|
|
15792
|
+
cream: { c: [244, 246, 186], r: [201, 161, 74] }
|
|
15793
|
+
};
|
|
15794
|
+
const W = 1200;
|
|
15795
|
+
const H = 800;
|
|
15796
|
+
const TILT = -46.7 * Math.PI / 180;
|
|
15797
|
+
const RATIO = 0.5;
|
|
15798
|
+
const MAXR = 300;
|
|
15799
|
+
const rnd = (a2, b) => a2 + Math.random() * (b - a2);
|
|
15800
|
+
const lerp = (a2, b, t2) => a2 + (b - a2) * t2;
|
|
15801
|
+
const mix = (a2, b, t2) => a2.map((v, i2) => lerp(v, b[i2], t2));
|
|
15802
|
+
const css = (a2) => `rgb(${a2.map(Math.round).join(",")})`;
|
|
15803
|
+
const ease = (t2) => t2 < 0.5 ? 2 * t2 * t2 : 1 - (-2 * t2 + 2) ** 2 / 2;
|
|
15804
|
+
const make = (x, y, vx, vy, r2, name, from) => ({
|
|
15805
|
+
x,
|
|
15806
|
+
y,
|
|
15807
|
+
vx,
|
|
15808
|
+
vy,
|
|
15809
|
+
r: r2,
|
|
15810
|
+
rd: from ? from.rd : r2,
|
|
15811
|
+
name,
|
|
15812
|
+
c0: from ? from.c : PAL[name].c.slice(),
|
|
15813
|
+
r0: from ? from.rr : PAL[name].r.slice(),
|
|
15814
|
+
c: PAL[name].c.slice(),
|
|
15815
|
+
rr: PAL[name].r.slice(),
|
|
15816
|
+
ct: from ? 0 : 1,
|
|
15817
|
+
age: 0,
|
|
15818
|
+
wob: from ? 1 : 0
|
|
15819
|
+
});
|
|
15820
|
+
const cur = (o2) => ({ c: mix(o2.c0, o2.c, ease(o2.ct)), r: mix(o2.r0, o2.rr, ease(o2.ct)) });
|
|
15821
|
+
function startOrbField(element) {
|
|
15822
|
+
const canvas = element;
|
|
15823
|
+
const ctx = canvas.getContext("2d");
|
|
15824
|
+
if (!ctx)
|
|
15825
|
+
return () => void 0;
|
|
15826
|
+
let orbs = [];
|
|
15827
|
+
let target = 3;
|
|
15828
|
+
let targetTime = 0;
|
|
15829
|
+
let spawnTime = 0;
|
|
15830
|
+
let last = performance.now();
|
|
15831
|
+
let raf = 0;
|
|
15832
|
+
const motion2 = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
15833
|
+
const pickName = (exclude = []) => {
|
|
15834
|
+
const taken = /* @__PURE__ */ new Set([...exclude, ...orbs.filter((o2) => !o2.leaving).map((o2) => o2.name)]);
|
|
15835
|
+
let pool = Object.keys(PAL).filter((n2) => !taken.has(n2) && n2 !== "ember");
|
|
15836
|
+
if (!pool.length)
|
|
15837
|
+
pool = Object.keys(PAL).filter((n2) => !exclude.includes(n2) && n2 !== "ember");
|
|
15838
|
+
return pool[Math.floor(Math.random() * pool.length)];
|
|
15839
|
+
};
|
|
15840
|
+
[
|
|
15841
|
+
[0.2, 0.25],
|
|
15842
|
+
[0.82, 0.78],
|
|
15843
|
+
[0.85, 0.2]
|
|
15844
|
+
].forEach(([px, py]) => {
|
|
15845
|
+
const o2 = make(
|
|
15846
|
+
W * px + rnd(-60, 60),
|
|
15847
|
+
H * py + rnd(-50, 50),
|
|
15848
|
+
rnd(-0.6, 0.6),
|
|
15849
|
+
rnd(-0.6, 0.6),
|
|
15850
|
+
rnd(150, 210),
|
|
15851
|
+
pickName()
|
|
15852
|
+
);
|
|
15853
|
+
o2.age = 2;
|
|
15854
|
+
orbs.push(o2);
|
|
15855
|
+
});
|
|
15856
|
+
const spawn = () => {
|
|
15857
|
+
const side = Math.floor(Math.random() * 4);
|
|
15858
|
+
const r2 = rnd(120, 180);
|
|
15859
|
+
const speed = rnd(0.9, 1.7);
|
|
15860
|
+
let x = rnd(80, W - 80);
|
|
15861
|
+
let y = rnd(80, H - 80);
|
|
15862
|
+
if (side === 0)
|
|
15863
|
+
x = -r2;
|
|
15864
|
+
else if (side === 1)
|
|
15865
|
+
x = W + r2;
|
|
15866
|
+
else if (side === 2)
|
|
15867
|
+
y = -r2;
|
|
15868
|
+
else
|
|
15869
|
+
y = H + r2;
|
|
15870
|
+
const tx = rnd(W * 0.25, W * 0.75);
|
|
15871
|
+
const ty = rnd(H * 0.25, H * 0.75);
|
|
15872
|
+
const d = Math.hypot(tx - x, ty - y);
|
|
15873
|
+
orbs.push(make(x, y, (tx - x) / d * speed, (ty - y) / d * speed, r2, pickName()));
|
|
15874
|
+
};
|
|
15875
|
+
const collide = (dt) => {
|
|
15876
|
+
for (let i2 = 0; i2 < orbs.length; i2 += 1) {
|
|
15877
|
+
for (let j = i2 + 1; j < orbs.length; j += 1) {
|
|
15878
|
+
const a2 = orbs[i2];
|
|
15879
|
+
const b = orbs[j];
|
|
15880
|
+
if (a2.age >= 0.8 && b.age >= 0.8) {
|
|
15881
|
+
const dx = b.x - a2.x;
|
|
15882
|
+
const dy = b.y - a2.y;
|
|
15883
|
+
const u = dx * Math.cos(TILT) + dy * Math.sin(TILT);
|
|
15884
|
+
const v = -dx * Math.sin(TILT) + dy * Math.cos(TILT);
|
|
15885
|
+
const R = (a2.rd + b.rd) * 0.92;
|
|
15886
|
+
if (u * u / (R * R) + v * v / (R * R * RATIO * RATIO) < 1) {
|
|
15887
|
+
const big = a2.r >= b.r ? a2 : b;
|
|
15888
|
+
const small = big === a2 ? b : a2;
|
|
15889
|
+
const da = Math.min(small.r * small.r, 14e3 * dt);
|
|
15890
|
+
small.r = Math.sqrt(Math.max(0, small.r * small.r - da));
|
|
15891
|
+
small.rd = Math.min(small.rd, small.r + 6);
|
|
15892
|
+
big.r = Math.sqrt(big.r * big.r + da);
|
|
15893
|
+
const cs = cur(small);
|
|
15894
|
+
const cb = cur(big);
|
|
15895
|
+
const k = Math.min(0.08, da / (big.r * big.r));
|
|
15896
|
+
big.c0 = mix(cb.c, cs.c, k * 3);
|
|
15897
|
+
big.r0 = mix(cb.r, cs.r, k * 3);
|
|
15898
|
+
big.c = mix(big.c, cs.c, k * 3);
|
|
15899
|
+
big.rr = mix(big.rr, cs.r, k * 3);
|
|
15900
|
+
small.x += (big.x - small.x) * 0.05;
|
|
15901
|
+
small.y += (big.y - small.y) * 0.05;
|
|
15902
|
+
if (small.r < 10) {
|
|
15903
|
+
orbs.splice(orbs.indexOf(small), 1);
|
|
15904
|
+
big.wob = 1;
|
|
15905
|
+
const c2 = cur(big);
|
|
15906
|
+
big.name = pickName([big.name]);
|
|
15907
|
+
big.c0 = c2.c;
|
|
15908
|
+
big.r0 = c2.r;
|
|
15909
|
+
big.c = PAL[big.name].c.slice();
|
|
15910
|
+
big.rr = PAL[big.name].r.slice();
|
|
15911
|
+
big.ct = 0;
|
|
15912
|
+
if (big.r > MAXR) {
|
|
15913
|
+
const from = cur(big);
|
|
15914
|
+
orbs.splice(orbs.indexOf(big), 1);
|
|
15915
|
+
for (let n2 = 0; n2 < 2; n2 += 1) {
|
|
15916
|
+
const angle = n2 * Math.PI + rnd(-0.4, 0.4);
|
|
15917
|
+
const speed = rnd(1.4, 2.2);
|
|
15918
|
+
orbs.push(
|
|
15919
|
+
make(
|
|
15920
|
+
big.x,
|
|
15921
|
+
big.y,
|
|
15922
|
+
Math.cos(angle) * speed + big.vx,
|
|
15923
|
+
Math.sin(angle) * speed + big.vy,
|
|
15924
|
+
big.r * 0.42,
|
|
15925
|
+
pickName(),
|
|
15926
|
+
{ rd: big.r * 0.5, c: from.c, rr: from.r }
|
|
15927
|
+
)
|
|
15928
|
+
);
|
|
15929
|
+
}
|
|
15930
|
+
}
|
|
15931
|
+
return;
|
|
15932
|
+
}
|
|
15933
|
+
}
|
|
15934
|
+
}
|
|
15935
|
+
}
|
|
15936
|
+
}
|
|
15937
|
+
};
|
|
15938
|
+
const step = (dt) => {
|
|
15939
|
+
spawnTime += dt;
|
|
15940
|
+
targetTime += dt;
|
|
15941
|
+
if (targetTime > (target === 3 ? 8 : 11)) {
|
|
15942
|
+
targetTime = 0;
|
|
15943
|
+
target = target === 3 ? 2 : 3;
|
|
15944
|
+
if (target === 2 && orbs.length > 2) {
|
|
15945
|
+
const oldest = orbs.filter((o2) => !o2.leaving).sort((a2, b) => b.age - a2.age)[0];
|
|
15946
|
+
if (oldest) {
|
|
15947
|
+
oldest.leaving = true;
|
|
15948
|
+
const d = Math.hypot(oldest.x - W / 2, oldest.y - H / 2) || 1;
|
|
15949
|
+
oldest.lx = (oldest.x - W / 2) / d;
|
|
15950
|
+
oldest.ly = (oldest.y - H / 2) / d;
|
|
15951
|
+
}
|
|
15952
|
+
}
|
|
15953
|
+
}
|
|
15954
|
+
if (spawnTime > 2.4 && orbs.filter((o2) => !o2.leaving).length < target) {
|
|
15955
|
+
spawnTime = 0;
|
|
15956
|
+
spawn();
|
|
15957
|
+
}
|
|
15958
|
+
orbs.forEach((orb) => {
|
|
15959
|
+
const o2 = orb;
|
|
15960
|
+
o2.age += dt;
|
|
15961
|
+
o2.x += o2.vx * dt * 60;
|
|
15962
|
+
o2.y += o2.vy * dt * 60;
|
|
15963
|
+
o2.vx *= 0.999;
|
|
15964
|
+
o2.vy *= 0.999;
|
|
15965
|
+
const k = 0.03 * dt * 60;
|
|
15966
|
+
if (o2.leaving) {
|
|
15967
|
+
o2.vx += (o2.lx ?? 0) * k;
|
|
15968
|
+
o2.vy += (o2.ly ?? 0) * k;
|
|
15969
|
+
} else if (o2.age > 3) {
|
|
15970
|
+
if (o2.x < W * 0.08)
|
|
15971
|
+
o2.vx += k;
|
|
15972
|
+
if (o2.x > W * 0.92)
|
|
15973
|
+
o2.vx -= k;
|
|
15974
|
+
if (o2.y < H * 0.1)
|
|
15975
|
+
o2.vy += k;
|
|
15976
|
+
if (o2.y > H * 0.9)
|
|
15977
|
+
o2.vy -= k;
|
|
15978
|
+
orbs.forEach((q) => {
|
|
15979
|
+
if (q !== o2 && !q.leaving) {
|
|
15980
|
+
const dx = o2.x - q.x;
|
|
15981
|
+
const dy = o2.y - q.y;
|
|
15982
|
+
const d = Math.hypot(dx, dy) || 1;
|
|
15983
|
+
if (d < 420) {
|
|
15984
|
+
o2.vx += dx / d * 6e-3 * dt * 60;
|
|
15985
|
+
o2.vy += dy / d * 6e-3 * dt * 60;
|
|
15986
|
+
}
|
|
15987
|
+
}
|
|
15988
|
+
});
|
|
15989
|
+
}
|
|
15990
|
+
const speed = Math.hypot(o2.vx, o2.vy);
|
|
15991
|
+
const cap = o2.leaving ? 4 : 2.2;
|
|
15992
|
+
if (speed > cap) {
|
|
15993
|
+
o2.vx *= cap / speed;
|
|
15994
|
+
o2.vy *= cap / speed;
|
|
15995
|
+
}
|
|
15996
|
+
o2.rd = lerp(o2.rd, o2.r, 1 - Math.exp(-dt * 5));
|
|
15997
|
+
o2.ct = Math.min(1, o2.ct + dt * 1.4);
|
|
15998
|
+
o2.wob = Math.max(0, o2.wob - dt * 1.1);
|
|
15999
|
+
});
|
|
16000
|
+
collide(dt);
|
|
16001
|
+
orbs = orbs.filter((o2) => {
|
|
16002
|
+
const m2 = o2.leaving ? o2.rd * 1.6 : 400;
|
|
16003
|
+
return o2.x > -m2 && o2.x < W + m2 && o2.y > -m2 && o2.y < H + m2;
|
|
16004
|
+
});
|
|
16005
|
+
};
|
|
16006
|
+
const draw = () => {
|
|
16007
|
+
ctx.clearRect(0, 0, W, H);
|
|
16008
|
+
orbs.forEach((o2) => {
|
|
16009
|
+
const c2 = cur(o2);
|
|
16010
|
+
const w2 = o2.rd * 1.35;
|
|
16011
|
+
const wob = o2.wob > 0 ? Math.sin((1 - o2.wob) * 20) * 0.16 * o2.wob : 0;
|
|
16012
|
+
ctx.save();
|
|
16013
|
+
ctx.translate(o2.x, o2.y);
|
|
16014
|
+
ctx.rotate(TILT);
|
|
16015
|
+
ctx.scale(1 + wob, (1 - wob) * RATIO);
|
|
16016
|
+
const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, w2);
|
|
16017
|
+
gradient.addColorStop(0, css(c2.c));
|
|
16018
|
+
gradient.addColorStop(0.62, css(c2.c));
|
|
16019
|
+
gradient.addColorStop(1, css(c2.r));
|
|
16020
|
+
ctx.fillStyle = gradient;
|
|
16021
|
+
ctx.beginPath();
|
|
16022
|
+
ctx.arc(0, 0, w2, 0, Math.PI * 2);
|
|
16023
|
+
ctx.fill();
|
|
16024
|
+
ctx.restore();
|
|
16025
|
+
});
|
|
16026
|
+
};
|
|
16027
|
+
const resize = () => {
|
|
16028
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
16029
|
+
const width = Math.max(1, canvas.clientWidth);
|
|
16030
|
+
const height = Math.max(1, canvas.clientHeight);
|
|
16031
|
+
canvas.width = Math.round(width * dpr);
|
|
16032
|
+
canvas.height = Math.round(height * dpr);
|
|
16033
|
+
const scale = Math.max(width / W, height / H);
|
|
16034
|
+
ctx.setTransform(
|
|
16035
|
+
dpr * scale,
|
|
16036
|
+
0,
|
|
16037
|
+
0,
|
|
16038
|
+
dpr * scale,
|
|
16039
|
+
dpr * (width - W * scale) / 2,
|
|
16040
|
+
dpr * (height - H * scale) / 2
|
|
16041
|
+
);
|
|
16042
|
+
draw();
|
|
16043
|
+
};
|
|
16044
|
+
const tick = (now) => {
|
|
16045
|
+
step(Math.min(0.05, (now - last) / 1e3));
|
|
16046
|
+
last = now;
|
|
16047
|
+
draw();
|
|
16048
|
+
raf = window.requestAnimationFrame(tick);
|
|
16049
|
+
};
|
|
16050
|
+
const syncMotion = () => {
|
|
16051
|
+
window.cancelAnimationFrame(raf);
|
|
16052
|
+
last = performance.now();
|
|
16053
|
+
if (!motion2.matches && !document.hidden)
|
|
16054
|
+
raf = window.requestAnimationFrame(tick);
|
|
16055
|
+
};
|
|
16056
|
+
resize();
|
|
16057
|
+
syncMotion();
|
|
16058
|
+
const observer = new ResizeObserver(resize);
|
|
16059
|
+
observer.observe(canvas);
|
|
16060
|
+
motion2.addEventListener("change", syncMotion);
|
|
16061
|
+
document.addEventListener("visibilitychange", syncMotion);
|
|
16062
|
+
return () => {
|
|
16063
|
+
window.cancelAnimationFrame(raf);
|
|
16064
|
+
observer.disconnect();
|
|
16065
|
+
motion2.removeEventListener("change", syncMotion);
|
|
16066
|
+
document.removeEventListener("visibilitychange", syncMotion);
|
|
16067
|
+
};
|
|
16068
|
+
}
|
|
16069
|
+
const orbOpacityForSurface = (surface, prefersDark) => {
|
|
16070
|
+
const perceptual = surface.match(/^okl(?:ab|ch)\(\s*([\d.]+)(%?)/);
|
|
16071
|
+
if (perceptual) {
|
|
16072
|
+
const lightness = Number(perceptual[1]) / (perceptual[2] ? 100 : 1);
|
|
16073
|
+
return lightness < 0.6 ? 0.35 : 0.85;
|
|
16074
|
+
}
|
|
16075
|
+
const srgb = surface.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);
|
|
16076
|
+
if (srgb) {
|
|
16077
|
+
const brightness2 = Number(srgb[1]) * 0.2126 + Number(srgb[2]) * 0.7152 + Number(srgb[3]) * 0.0722;
|
|
16078
|
+
return brightness2 < 0.5 ? 0.35 : 0.85;
|
|
16079
|
+
}
|
|
16080
|
+
const channels = surface.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/);
|
|
16081
|
+
if (!channels)
|
|
16082
|
+
return prefersDark ? 0.35 : 0.85;
|
|
16083
|
+
const brightness = Number(channels[1]) * 0.2126 + Number(channels[2]) * 0.7152 + Number(channels[3]) * 0.0722;
|
|
16084
|
+
return brightness < 128 ? 0.35 : 0.85;
|
|
16085
|
+
};
|
|
16086
|
+
const OrbBackground_css_ts_vanilla = "";
|
|
16087
|
+
var OrbBackground$1 = "gde17n1";
|
|
16088
|
+
var OrbBackgroundHost = "gde17n0";
|
|
16089
|
+
const OrbBackground = ({ className, appearance }) => {
|
|
16090
|
+
const ref = useRef(null);
|
|
16091
|
+
useEffect(() => {
|
|
16092
|
+
if (!ref.current)
|
|
16093
|
+
return void 0;
|
|
16094
|
+
return startOrbField(ref.current);
|
|
16095
|
+
}, []);
|
|
16096
|
+
useEffect(() => {
|
|
16097
|
+
var _a;
|
|
16098
|
+
const canvas = ref.current;
|
|
16099
|
+
if (!canvas)
|
|
16100
|
+
return void 0;
|
|
16101
|
+
const scheme = (_a = window.matchMedia) == null ? void 0 : _a.call(window, "(prefers-color-scheme: dark)");
|
|
16102
|
+
const sync = () => {
|
|
16103
|
+
let opacity = orbOpacityForSurface(getComputedStyle(canvas).color, (scheme == null ? void 0 : scheme.matches) ?? false);
|
|
16104
|
+
if (appearance)
|
|
16105
|
+
opacity = appearance === "dark" ? 0.35 : 0.85;
|
|
16106
|
+
canvas.style.opacity = String(opacity);
|
|
16107
|
+
};
|
|
16108
|
+
sync();
|
|
16109
|
+
const observer = new MutationObserver(sync);
|
|
16110
|
+
let ancestor = canvas.parentElement;
|
|
16111
|
+
while (ancestor) {
|
|
16112
|
+
observer.observe(ancestor, { attributes: true, attributeFilter: ["class", "style"] });
|
|
16113
|
+
ancestor = ancestor.parentElement;
|
|
16114
|
+
}
|
|
16115
|
+
scheme == null ? void 0 : scheme.addEventListener("change", sync);
|
|
16116
|
+
return () => {
|
|
16117
|
+
observer.disconnect();
|
|
16118
|
+
scheme == null ? void 0 : scheme.removeEventListener("change", sync);
|
|
16119
|
+
};
|
|
16120
|
+
}, [appearance]);
|
|
16121
|
+
return /* @__PURE__ */ jsx("canvas", { ref, className: classNames(OrbBackground$1, className), "aria-hidden": "true" });
|
|
16122
|
+
};
|
|
16123
|
+
const SplashScreen_css_ts_vanilla = "";
|
|
16124
|
+
var SplashScreen$1 = "wf38060";
|
|
16125
|
+
var SplashScreenFooter = "wf38061";
|
|
16126
|
+
const SplashScreen = ({ children }) => /* @__PURE__ */ jsxs(Box, { className: classNames(SplashScreen$1, OrbBackgroundHost), direction: "Column", children: [
|
|
16127
|
+
/* @__PURE__ */ jsx(OrbBackground, {}),
|
|
16128
|
+
children,
|
|
16129
|
+
/* @__PURE__ */ jsx(Box, { className: SplashScreenFooter, shrink: "No", alignItems: "Center", justifyContent: "Center", children: /* @__PURE__ */ jsx(Text, { size: "H2", align: "Center", children: "AG2 Space" }) })
|
|
16130
|
+
] });
|
|
15784
16131
|
const Starfield_css_ts_vanilla = "";
|
|
15785
16132
|
var Starfield$1 = "_4j0z2c1";
|
|
15786
16133
|
var StarfieldHost = "_4j0z2c0";
|
|
@@ -15888,14 +16235,6 @@ const Starfield = ({ className }) => {
|
|
|
15888
16235
|
}, []);
|
|
15889
16236
|
return /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: classNames(Starfield$1, className), "aria-hidden": true });
|
|
15890
16237
|
};
|
|
15891
|
-
const SplashScreen_css_ts_vanilla = "";
|
|
15892
|
-
var SplashScreen$1 = "wf38060";
|
|
15893
|
-
var SplashScreenFooter = "wf38061";
|
|
15894
|
-
const SplashScreen = ({ children }) => /* @__PURE__ */ jsxs(Box, { className: classNames(SplashScreen$1, StarfieldHost), direction: "Column", children: [
|
|
15895
|
-
/* @__PURE__ */ jsx(Starfield, {}),
|
|
15896
|
-
children,
|
|
15897
|
-
/* @__PURE__ */ jsx(Box, { className: SplashScreenFooter, shrink: "No", alignItems: "Center", justifyContent: "Center", children: /* @__PURE__ */ jsx(Text, { size: "H2", align: "Center", children: "AG2 Space" }) })
|
|
15898
|
-
] });
|
|
15899
16238
|
const style_css_ts_vanilla = "";
|
|
15900
16239
|
var PageCanvas$1 = "_18hg0vg1";
|
|
15901
16240
|
var PageContent$1 = "_18hg0vge _8nex5a1 _8nex5a0";
|
|
@@ -17899,6 +18238,8 @@ export {
|
|
|
17899
18238
|
MenuItem,
|
|
17900
18239
|
Modal,
|
|
17901
18240
|
NavCollapseRow,
|
|
18241
|
+
OrbBackground,
|
|
18242
|
+
OrbBackgroundHost,
|
|
17902
18243
|
Overlay,
|
|
17903
18244
|
OverlayBackdrop,
|
|
17904
18245
|
OverlayCenter,
|