craft-library 0.8.0 → 0.9.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 +35 -3
- package/dist/card-load.js +1 -1
- package/dist/card-mount.js +1 -1
- package/dist/card.cdn.js +1 -1
- package/dist/card.js +1 -1
- package/dist/cdn.js +3 -3
- package/dist/craft.js +632 -5
- package/dist/elements.js +34 -4
- package/dist/glassnav.js +1 -1
- package/dist/index.js +21 -2
- package/dist/joinha.js +1 -1
- package/dist/like.js +1 -1
- package/dist/magnet.js +1 -1
- package/dist/orb.js +381 -0
- package/dist/panorama-assets.js +2 -2
- package/dist/panorama-mount.js +1 -1
- package/dist/panorama.js +1 -1
- package/dist/piggy-load.js +1 -1
- package/dist/piggy-mount.js +1 -1
- package/dist/piggy.cdn.js +1 -1
- package/dist/piggy.js +1 -1
- package/dist/pin-load.js +1 -1
- package/dist/pin-mount.js +1 -1
- package/dist/pin.cdn.js +1 -1
- package/dist/pin.js +1 -1
- package/dist/sign.js +1 -1
- package/dist/style.js +1 -1
- package/dist/thinking.js +1 -1
- package/dist/tokens-load.js +1 -1
- package/dist/tokens-mount.js +1 -1
- package/dist/tokens.cdn.js +1 -1
- package/dist/tokens.js +1 -1
- package/package.json +7 -3
package/dist/craft.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Sara Lobo Library · liquid glass nav bar, bursting heart, magnetic icon, iridescent card, glass piggy bank, magic sphere, sweep, panorama, map pin, token wheel, thumbs reaction · <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin>, <token-wheel>, <thumbs-reaction> · https://saralobolibrary.com · MIT */
|
|
1
|
+
/*! Sara Lobo Library · liquid glass nav bar, bursting heart, magnetic icon, iridescent card, glass piggy bank, magic sphere, sweep, panorama, map pin, token wheel, thumbs reaction, fold orb · <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin>, <token-wheel>, <thumbs-reaction>, <fold-orb> · https://saralobolibrary.com · MIT */
|
|
2
2
|
(() => {
|
|
3
3
|
// dist/style.js
|
|
4
4
|
var done = /* @__PURE__ */ new Set();
|
|
@@ -2972,7 +2972,7 @@ void main() {
|
|
|
2972
2972
|
show();
|
|
2973
2973
|
}
|
|
2974
2974
|
set(o.value);
|
|
2975
|
-
var
|
|
2975
|
+
var api7 = {
|
|
2976
2976
|
set,
|
|
2977
2977
|
// the reaction again, as a tap would play it (from rest, so it can be shown on a loop)
|
|
2978
2978
|
play: function(v) {
|
|
@@ -2995,7 +2995,7 @@ void main() {
|
|
|
2995
2995
|
root.__joinha = null;
|
|
2996
2996
|
}
|
|
2997
2997
|
};
|
|
2998
|
-
return root.__joinha =
|
|
2998
|
+
return root.__joinha = api7;
|
|
2999
2999
|
}
|
|
3000
3000
|
function scan() {
|
|
3001
3001
|
Array.prototype.forEach.call(document.querySelectorAll(".joinha"), function(r) {
|
|
@@ -3025,6 +3025,601 @@ void main() {
|
|
|
3025
3025
|
} };
|
|
3026
3026
|
}
|
|
3027
3027
|
|
|
3028
|
+
// dist/orb.js
|
|
3029
|
+
var CSS7 = "/* Orb \xB7 Sara Lobo Library\n orb.js draws the orb and its ground on a canvas that fills the element. Give the element a size (it is a block,\n 100% wide; the height is yours to set, or --orb-height). */\n\n.orb {\n position: relative;\n display: block;\n width: 100%;\n height: var(--orb-height, 420px);\n overflow: hidden;\n}\n.orb-canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n}\n";
|
|
3030
|
+
var api6;
|
|
3031
|
+
function engine6() {
|
|
3032
|
+
if (api6) return api6;
|
|
3033
|
+
const window2 = {};
|
|
3034
|
+
(function() {
|
|
3035
|
+
"use strict";
|
|
3036
|
+
var TONES = {
|
|
3037
|
+
steel: { top: [0.215, 0.22, 0.232], bot: [0.062, 0.064, 0.07], floor: [0.13, 0.135, 0.145], shadow: 0, vig: 0.32, ink: 0, disp: 0.65, halo: 0.75, orb: [0.84, 0.86, 0.9], rim: [1, 1, 1], haloC: [0.42, 0.43, 0.47] },
|
|
3038
|
+
mist: { top: [0.948, 0.95, 0.958], bot: [0.795, 0.8, 0.815], floor: [0.05, 0.05, 0.055], shadow: 0.17, vig: 0.12, ink: 1, disp: 1, halo: 0, orb: [0.66, 0.7, 0.78], rim: [1, 1, 1], haloC: [0, 0, 0] },
|
|
3039
|
+
blue: { top: [8e-3, 0.016, 0.046], bot: [3e-3, 6e-3, 0.018], floor: [0.03, 0.14, 0.58], shadow: 0, vig: 0, ink: 0, disp: 1, halo: 1, orb: [0.46, 0.64, 1], rim: [0.5, 0.74, 1], haloC: [0.1, 0.3, 1] }
|
|
3040
|
+
};
|
|
3041
|
+
var STATES = { idle: 1, typing: 1, listening: 1, thinking: 1, speaking: 1 };
|
|
3042
|
+
var VS2 = "attribute vec2 p;void main(){gl_Position=vec4(p,0.0,1.0);}";
|
|
3043
|
+
var FS2 = [
|
|
3044
|
+
"precision highp float;",
|
|
3045
|
+
"uniform vec2 uRes,uC;uniform float uR;",
|
|
3046
|
+
"uniform vec3 uTop,uBot,uFloor;uniform float uShadow,uVig;",
|
|
3047
|
+
"uniform float uT,uAttend,uLevel,uPulse,uBlur,uPhase,uFill,uSpeak,uInk,uDispK,uHaloK;",
|
|
3048
|
+
"uniform vec3 uBands,uGaze,uLight,uOrbCol,uRimCol,uHaloCol;uniform mat3 uRot;",
|
|
3049
|
+
"float sq(float x){return x*x;}",
|
|
3050
|
+
"float hash12(vec2 p){vec3 p3=fract(vec3(p.xyx)*.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}",
|
|
3051
|
+
// the ground: a vertical gradient, a soft floor light, a vignette and, on light grounds, a contact shadow
|
|
3052
|
+
"vec3 ground(vec2 f){vec2 uv=f/uRes;vec3 c=mix(uBot,uTop,smoothstep(0.0,0.85,uv.y));float bx=uv.x-0.5;",
|
|
3053
|
+
" c+=uFloor*exp(-sq(uv.y/0.2))*(0.55+0.45*exp(-sq(bx/0.45)));c*=1.0-uVig*sq(bx*1.5);",
|
|
3054
|
+
" vec2 q=(f-uC)/uR;c*=1.0-uShadow*exp(-sq((q.y+1.5)/0.17)-sq(q.x/0.72));return c;}",
|
|
3055
|
+
"vec3 tm(vec3 x){return 1.0-exp(-max(x,0.0)*1.1);}",
|
|
3056
|
+
"float Fp(float f,float S){return sign(f)*(1.0-exp(-S*abs(f)))/S;}",
|
|
3057
|
+
"mat2 rot(float a){float c=cos(a),s=sin(a);return mat2(c,-s,s,c);}",
|
|
3058
|
+
// the two folds: the sphere's skin turned into itself, twisted along an axis
|
|
3059
|
+
"float sheetA(vec3 q){vec2 xz=rot(2.3*q.y+uPhase)*q.xz;vec3 r=vec3(xz.x,q.y,xz.y);",
|
|
3060
|
+
" float rr=0.80+0.05*sin(3.0*r.y+uT*0.4)+0.06*uBands.x*uLevel;",
|
|
3061
|
+
" return length(r-vec3(0.46+0.14*sin(2.2*q.y+0.6),0.0,0.0))-rr+uLevel*0.035*sin(11.0*r.y-8.0*uT)*(0.4+uBands.y);}",
|
|
3062
|
+
"float sheetB(vec3 q){vec2 yz=rot(-2.0*q.x-0.7*uPhase+2.2)*q.yz;vec3 r=vec3(q.x,yz.x,yz.y);",
|
|
3063
|
+
" return length(r-vec3(-0.52,0.12+0.12*sin(2.0*q.x+1.4),0.0))-(0.76+0.04*sin(2.4*r.z+uT*0.3))+uLevel*0.03*sin(9.0*r.x+7.0*uT)*(0.4+uBands.z);}",
|
|
3064
|
+
"void main(){",
|
|
3065
|
+
" vec2 f=gl_FragCoord.xy;vec3 bg=ground(f);vec3 col=bg,light=vec3(0.0);vec2 p=(f-uC)/uR;",
|
|
3066
|
+
" if(dot(p,p)<9.0){",
|
|
3067
|
+
" const float K=0.3535534;vec3 ro=vec3(0.0,0.0,3.0),rd=normalize(vec3(p*K,-1.0));",
|
|
3068
|
+
" float rad=1.0+0.028*uLevel;float b=dot(ro,rd),c=dot(ro,ro)-rad*rad,h=b*b-c;",
|
|
3069
|
+
" float dmin=sqrt(max(dot(ro,ro)-b*b,0.0)),e=max(dmin-rad,0.0);",
|
|
3070
|
+
" light+=uHaloCol*uHaloK*(0.16*exp(-e*14.0)+0.06*exp(-e*3.2))*(0.6+0.9*uFill+0.8*uLevel+0.5*uAttend);",
|
|
3071
|
+
// the silhouette is blended over ~1.6 device pixels: never a stair-stepped cut
|
|
3072
|
+
" float ps=tan(asin(rad/3.0))/K,pl=length(p);float cov=smoothstep(ps+0.8/uR,ps-0.8/uR,pl);",
|
|
3073
|
+
" if(cov>0.0){",
|
|
3074
|
+
" float sh=sqrt(max(h,0.0)),t0=-b-sh,t1=-b+sh;vec3 n0=normalize(ro+rd*t0);",
|
|
3075
|
+
" float cosv=max(dot(n0,-rd),0.0),fres=1.0-cosv;float gl=max(dot(n0,uGaze),0.0),ll=max(dot(n0,uLight),0.0);",
|
|
3076
|
+
" float dl=max(ps-pl,0.0)/ps;float lip=0.55+0.45*smoothstep(0.0,0.016,dl);",
|
|
3077
|
+
" vec3 band=vec3(exp(-dl/0.030),exp(-dl/0.037),exp(-dl/0.046))*lip;",
|
|
3078
|
+
// march the folds; each step integrates the sheet glow exactly for a linear field, one offset per colour channel
|
|
3079
|
+
" const int N=44;float dt=(t1-t0)/float(N);float S=mix(56.0,11.0,uBlur),dsp=(0.016+0.085*uBlur)*uDispK;",
|
|
3080
|
+
" vec3 x=ro+rd*t0,q=uRot*x;float fa=sheetA(q),fb=sheetB(q);",
|
|
3081
|
+
" vec3 FA=vec3(Fp(fa+dsp,S),Fp(fa,S),Fp(fa-dsp,S)),FB=vec3(Fp(fb+dsp,S),Fp(fb,S),Fp(fb-dsp,S));",
|
|
3082
|
+
" float pfa=fa,pfb=fb;vec3 acc=vec3(0.0);",
|
|
3083
|
+
" for(int i=1;i<=N;i++){",
|
|
3084
|
+
" x=ro+rd*(t0+float(i)*dt);q=uRot*x;fa=sheetA(q);fb=sheetB(q);",
|
|
3085
|
+
" vec3 nFA=vec3(Fp(fa+dsp,S),Fp(fa,S),Fp(fa-dsp,S)),nFB=vec3(Fp(fb+dsp,S),Fp(fb,S),Fp(fb-dsp,S));",
|
|
3086
|
+
" float da=fa-pfa,db=fb-pfb;",
|
|
3087
|
+
" vec3 ia=abs(da)>1e-4?(nFA-FA)/da:exp(-S*abs(vec3(fa+dsp,fa,fa-dsp)));",
|
|
3088
|
+
" vec3 ib=abs(db)>1e-4?(nFB-FB)/db:exp(-S*abs(vec3(fb+dsp,fb,fb-dsp)));",
|
|
3089
|
+
" vec3 xn=x/rad;float lit=0.3+1.3*smoothstep(-0.3,1.0,dot(xn,uLight))+0.6*uAttend*smoothstep(0.0,1.0,dot(xn,uGaze));",
|
|
3090
|
+
" float ga=1.0-min(abs(da)/dt,1.0),gb=1.0-min(abs(db)/dt,1.0);",
|
|
3091
|
+
" float wa=mix(0.035,1.0,ga*ga*mix(1.0,0.3,uBlur)+uBlur*0.7),wb=mix(0.035,1.0,gb*gb*mix(1.0,0.3,uBlur)+uBlur*0.7);",
|
|
3092
|
+
" acc+=(ia*wa+0.75*ib*wb)*lit;FA=nFA;FB=nFB;pfa=fa;pfb=fb;",
|
|
3093
|
+
" }",
|
|
3094
|
+
" acc*=dt*S*0.11*(1.0+0.8*uLevel+0.35*uSpeak);float thick=t1-t0;",
|
|
3095
|
+
" if(uInk<0.5){",
|
|
3096
|
+
// a dark ground: the ball emits light
|
|
3097
|
+
" float rimW=0.14+3.2*ll*ll*ll+1.3*uAttend*gl*gl+1.4*uPulse*gl+0.9*uLevel;",
|
|
3098
|
+
" vec3 inner=(0.72*band+0.28*vec3(pow(fres,4.0),pow(fres,3.4),pow(fres,2.9)))*uRimCol*rimW*1.9;",
|
|
3099
|
+
" inner+=uOrbCol*0.09*pow(ll,3.0)*(0.3+0.7*fres);inner+=acc*uOrbCol+acc*acc*vec3(0.30,0.32,0.36);",
|
|
3100
|
+
" inner+=uOrbCol*thick*0.08*uFill;light+=inner*cov;col=bg*mix(1.0,exp(-thick*0.9),cov);",
|
|
3101
|
+
" }else{",
|
|
3102
|
+
// a light ground: clear glass refracting the ground, darker toward its edge, folds read as ink, a white crescent
|
|
3103
|
+
" float k=0.55*fres+0.10;vec2 off=-n0.xy*uR*k;float dk=0.05*uDispK;",
|
|
3104
|
+
" vec3 tr=vec3(ground(f+off*(1.0-dk)).r,ground(f+off).g,ground(f+off*(1.0+dk)).b);",
|
|
3105
|
+
" tr*=mix(vec3(1.0),uOrbCol,clamp(thick*0.32,0.0,0.6));tr=mix(tr,vec3(0.96),uFill*0.5*smoothstep(0.0,1.2,thick));",
|
|
3106
|
+
" tr*=1.0-0.45*band;tr*=1.0-clamp(acc*(0.40+0.3*uLevel),0.0,0.85);",
|
|
3107
|
+
" float spec=(0.6*band.g+0.4*pow(fres,3.0))*pow(ll,3.0)*(1.0+1.5*uAttend*gl*gl+uPulse*gl)*smoothstep(0.004,0.02,dl);",
|
|
3108
|
+
" tr+=vec3(1.0)*spec*0.95;tr+=clamp(acc*acc*0.05,0.0,0.5);col=mix(bg,tr,cov);",
|
|
3109
|
+
" }",
|
|
3110
|
+
" }",
|
|
3111
|
+
" }",
|
|
3112
|
+
" gl_FragColor=vec4(col+tm(light)+(hash12(f)-0.5)*(1.5/255.0),1.0);",
|
|
3113
|
+
"}"
|
|
3114
|
+
].join("\n");
|
|
3115
|
+
function Spring(x, k, zeta) {
|
|
3116
|
+
this.x = x;
|
|
3117
|
+
this.v = 0;
|
|
3118
|
+
this.target = x;
|
|
3119
|
+
this.k = k;
|
|
3120
|
+
this.c = 2 * zeta * Math.sqrt(k);
|
|
3121
|
+
}
|
|
3122
|
+
Spring.prototype.step = function(dt) {
|
|
3123
|
+
var n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
|
|
3124
|
+
for (var i = 0; i < n; i++) {
|
|
3125
|
+
this.v += (-this.k * (this.x - this.target) - this.c * this.v) * h;
|
|
3126
|
+
this.x += this.v * h;
|
|
3127
|
+
}
|
|
3128
|
+
return this.x;
|
|
3129
|
+
};
|
|
3130
|
+
function damp2(x, t, l, dt) {
|
|
3131
|
+
return x + (t - x) * (1 - Math.exp(-l * dt));
|
|
3132
|
+
}
|
|
3133
|
+
function clamp2(x, a, b) {
|
|
3134
|
+
return Math.min(b, Math.max(a, x));
|
|
3135
|
+
}
|
|
3136
|
+
function smooth(a, b, x) {
|
|
3137
|
+
var t = clamp2((x - a) / (b - a), 0, 1);
|
|
3138
|
+
return t * t * (3 - 2 * t);
|
|
3139
|
+
}
|
|
3140
|
+
function hash1(n) {
|
|
3141
|
+
var s = Math.sin(n * 127.1 + 311.7) * 43758.5453;
|
|
3142
|
+
return s - Math.floor(s);
|
|
3143
|
+
}
|
|
3144
|
+
function vnoise(x) {
|
|
3145
|
+
var i = Math.floor(x), f = x - i, u = f * f * (3 - 2 * f);
|
|
3146
|
+
return hash1(i) * (1 - u) + hash1(i + 1) * u;
|
|
3147
|
+
}
|
|
3148
|
+
function norm(v) {
|
|
3149
|
+
var n = Math.hypot(v[0], v[1], v[2]) || 1;
|
|
3150
|
+
v[0] /= n;
|
|
3151
|
+
v[1] /= n;
|
|
3152
|
+
v[2] /= n;
|
|
3153
|
+
return v;
|
|
3154
|
+
}
|
|
3155
|
+
function frameTo(g, out) {
|
|
3156
|
+
var z = [0, 0, 1], d = g[2];
|
|
3157
|
+
if (d > 0.99999) {
|
|
3158
|
+
out.set([1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
3159
|
+
return;
|
|
3160
|
+
}
|
|
3161
|
+
var ax = [-g[1], g[0], 0];
|
|
3162
|
+
norm(ax);
|
|
3163
|
+
var a = Math.acos(clamp2(d, -1, 1)), c = Math.cos(-a), s = Math.sin(-a), t = 1 - c, x = ax[0], y = ax[1], w = ax[2];
|
|
3164
|
+
out[0] = t * x * x + c;
|
|
3165
|
+
out[3] = t * x * y - s * w;
|
|
3166
|
+
out[6] = t * x * w + s * y;
|
|
3167
|
+
out[1] = t * x * y + s * w;
|
|
3168
|
+
out[4] = t * y * y + c;
|
|
3169
|
+
out[7] = t * y * w - s * x;
|
|
3170
|
+
out[2] = t * x * w - s * y;
|
|
3171
|
+
out[5] = t * y * w + s * x;
|
|
3172
|
+
out[8] = t * w * w + c;
|
|
3173
|
+
}
|
|
3174
|
+
function simVoice(t, ai, bands) {
|
|
3175
|
+
var rate = ai ? 3.4 : 4.2;
|
|
3176
|
+
var syl = Math.pow(Math.abs(Math.sin(Math.PI * rate * t + 2.6 * vnoise(t * 0.8 + (ai ? 40 : 0)))), ai ? 1.3 : 1.8);
|
|
3177
|
+
var gate = ai ? smooth(0.18, 0.4, vnoise(t * 0.55 + 7)) : smooth(0.32, 0.52, vnoise(t * 0.7 + 11));
|
|
3178
|
+
var lv = syl * gate * (0.5 + 0.5 * vnoise(t * 2.1 + 5));
|
|
3179
|
+
bands[0] = lv * (0.75 + 0.5 * vnoise(t * 6.5 + 1));
|
|
3180
|
+
bands[1] = lv * (0.45 + 0.5 * vnoise(t * 6.5 + 9));
|
|
3181
|
+
bands[2] = lv * (0.2 + 0.4 * vnoise(t * 6.5 + 17));
|
|
3182
|
+
return lv;
|
|
3183
|
+
}
|
|
3184
|
+
var reduceMQ = typeof matchMedia === "function" ? matchMedia("(prefers-reduced-motion: reduce)") : null;
|
|
3185
|
+
var measureCtx = null;
|
|
3186
|
+
function orb(host, o) {
|
|
3187
|
+
o = o || {};
|
|
3188
|
+
var tone = TONES[o.tone] ? o.tone : "steel", state = STATES[o.state] ? o.state : "idle";
|
|
3189
|
+
host.classList.add("orb");
|
|
3190
|
+
if (!host.hasAttribute("role")) host.setAttribute("role", "img");
|
|
3191
|
+
if (!host.hasAttribute("aria-label")) host.setAttribute("aria-label", o.label || "AI assistant");
|
|
3192
|
+
var canvas = document.createElement("canvas");
|
|
3193
|
+
canvas.className = "orb-canvas";
|
|
3194
|
+
canvas.setAttribute("aria-hidden", "true");
|
|
3195
|
+
host.appendChild(canvas);
|
|
3196
|
+
var gl = canvas.getContext("webgl", { antialias: false, alpha: false, depth: false, stencil: false, premultipliedAlpha: false, powerPreference: "high-performance" });
|
|
3197
|
+
var noop = function() {
|
|
3198
|
+
return api7;
|
|
3199
|
+
};
|
|
3200
|
+
var api7 = { set: noop, tone: noop, level: noop, pulse: noop, lookAt: noop, follow: noop, destroy: function() {
|
|
3201
|
+
canvas.remove();
|
|
3202
|
+
} };
|
|
3203
|
+
if (!gl) {
|
|
3204
|
+
host.classList.add("orb-nogl");
|
|
3205
|
+
return api7;
|
|
3206
|
+
}
|
|
3207
|
+
function sh(type, src) {
|
|
3208
|
+
var s = gl.createShader(type);
|
|
3209
|
+
gl.shaderSource(s, src);
|
|
3210
|
+
gl.compileShader(s);
|
|
3211
|
+
return s;
|
|
3212
|
+
}
|
|
3213
|
+
var prog = gl.createProgram();
|
|
3214
|
+
gl.attachShader(prog, sh(gl.VERTEX_SHADER, VS2));
|
|
3215
|
+
gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FS2));
|
|
3216
|
+
gl.bindAttribLocation(prog, 0, "p");
|
|
3217
|
+
gl.linkProgram(prog);
|
|
3218
|
+
if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {
|
|
3219
|
+
host.classList.add("orb-nogl");
|
|
3220
|
+
return api7;
|
|
3221
|
+
}
|
|
3222
|
+
gl.useProgram(prog);
|
|
3223
|
+
var buf = gl.createBuffer();
|
|
3224
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
|
3225
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
|
|
3226
|
+
gl.enableVertexAttribArray(0);
|
|
3227
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
|
3228
|
+
var U = {};
|
|
3229
|
+
[
|
|
3230
|
+
"uRes",
|
|
3231
|
+
"uC",
|
|
3232
|
+
"uR",
|
|
3233
|
+
"uTop",
|
|
3234
|
+
"uBot",
|
|
3235
|
+
"uFloor",
|
|
3236
|
+
"uShadow",
|
|
3237
|
+
"uVig",
|
|
3238
|
+
"uT",
|
|
3239
|
+
"uAttend",
|
|
3240
|
+
"uLevel",
|
|
3241
|
+
"uPulse",
|
|
3242
|
+
"uBlur",
|
|
3243
|
+
"uPhase",
|
|
3244
|
+
"uFill",
|
|
3245
|
+
"uSpeak",
|
|
3246
|
+
"uInk",
|
|
3247
|
+
"uDispK",
|
|
3248
|
+
"uHaloK",
|
|
3249
|
+
"uBands",
|
|
3250
|
+
"uGaze",
|
|
3251
|
+
"uLight",
|
|
3252
|
+
"uOrbCol",
|
|
3253
|
+
"uRimCol",
|
|
3254
|
+
"uHaloCol",
|
|
3255
|
+
"uRot"
|
|
3256
|
+
].forEach(function(n) {
|
|
3257
|
+
U[n] = gl.getUniformLocation(prog, n);
|
|
3258
|
+
});
|
|
3259
|
+
var W = 0, H = 0, dpr = 1, cx = 0, cy = 0, R = 1;
|
|
3260
|
+
var t = 0, prev = 0, raf = 0, onScreen = true, dead = false;
|
|
3261
|
+
var gx = new Spring(0, 26, 1), gy = new Spring(0, 26, 1), gz = new Spring(1, 26, 1);
|
|
3262
|
+
var attend = new Spring(0, 46, 1), pulseS = new Spring(0, 150, 1), think = new Spring(0, 22, 1), speak = new Spring(0, 34, 1);
|
|
3263
|
+
var blur = new Spring(0.3, 24, 1), fill = new Spring(0, 22, 1);
|
|
3264
|
+
var phase = 0, pvel = 0.14, kick = 0, lastKey = -99, level = 0, bands = [0, 0, 0], rawB = [0, 0, 0];
|
|
3265
|
+
var gaze = [0, 0, 1], light = norm([0.62, 0.55, 0.35]), lightT = [0, 0, 0], rotM = new Float32Array(9);
|
|
3266
|
+
var cur = JSON.parse(JSON.stringify(TONES[tone])), want = TONES[tone];
|
|
3267
|
+
var extLevel = null, followEl = null, focused = false, look = null;
|
|
3268
|
+
var caret = { x: 0, y: 0 }, sim = { x: -1.7, next: 0.45, pause: 0 };
|
|
3269
|
+
var mic = { on: false, an: null, ctx: null, stream: null, td: null, fd: null, asked: false };
|
|
3270
|
+
var SPEED = { idle: 0.14, typing: 0.2, listening: 0.32, thinking: 1.15, speaking: 0.42 };
|
|
3271
|
+
function size() {
|
|
3272
|
+
var r = host.getBoundingClientRect();
|
|
3273
|
+
dpr = Math.min(typeof devicePixelRatio === "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, 2);
|
|
3274
|
+
W = Math.max(1, Math.round(r.width * dpr));
|
|
3275
|
+
H = Math.max(1, Math.round(r.height * dpr));
|
|
3276
|
+
if (canvas.width !== W || canvas.height !== H) {
|
|
3277
|
+
canvas.width = W;
|
|
3278
|
+
canvas.height = H;
|
|
3279
|
+
}
|
|
3280
|
+
cx = r.width / 2;
|
|
3281
|
+
cy = r.height * 0.46;
|
|
3282
|
+
R = Math.max(8, Math.min(r.width, r.height) * 0.3);
|
|
3283
|
+
}
|
|
3284
|
+
var ro = typeof ResizeObserver === "function" ? new ResizeObserver(size) : null;
|
|
3285
|
+
if (ro) ro.observe(host);
|
|
3286
|
+
else addEventListener("resize", size);
|
|
3287
|
+
var io = typeof IntersectionObserver === "function" ? new IntersectionObserver(function(es) {
|
|
3288
|
+
onScreen = es[0].isIntersecting;
|
|
3289
|
+
}, { rootMargin: "80px" }) : null;
|
|
3290
|
+
if (io) io.observe(host);
|
|
3291
|
+
size();
|
|
3292
|
+
function key() {
|
|
3293
|
+
pulseS.v += 15;
|
|
3294
|
+
kick += 0.55;
|
|
3295
|
+
lastKey = t;
|
|
3296
|
+
}
|
|
3297
|
+
function mode() {
|
|
3298
|
+
return followEl && focused ? "typing" : state;
|
|
3299
|
+
}
|
|
3300
|
+
function readCaret() {
|
|
3301
|
+
if (!followEl) return;
|
|
3302
|
+
var r = host.getBoundingClientRect(), fr = followEl.getBoundingClientRect(), cs = getComputedStyle(followEl);
|
|
3303
|
+
measureCtx = measureCtx || document.createElement("canvas").getContext("2d");
|
|
3304
|
+
measureCtx.font = cs.fontWeight + " " + cs.fontSize + " " + cs.fontFamily;
|
|
3305
|
+
var v = followEl.value || "", at = followEl.selectionStart == null ? v.length : followEl.selectionStart;
|
|
3306
|
+
var w = measureCtx.measureText(v.slice(0, at)).width - (followEl.scrollLeft || 0) + (parseFloat(cs.paddingLeft) || 0);
|
|
3307
|
+
caret.x = fr.left - r.left + clamp2(w, 0, fr.width);
|
|
3308
|
+
caret.y = fr.top - r.top + fr.height / 2;
|
|
3309
|
+
}
|
|
3310
|
+
function onInput() {
|
|
3311
|
+
readCaret();
|
|
3312
|
+
key();
|
|
3313
|
+
}
|
|
3314
|
+
function onFocus() {
|
|
3315
|
+
focused = true;
|
|
3316
|
+
readCaret();
|
|
3317
|
+
}
|
|
3318
|
+
function onBlur() {
|
|
3319
|
+
focused = false;
|
|
3320
|
+
}
|
|
3321
|
+
function startMic() {
|
|
3322
|
+
if (mic.asked || !navigator.mediaDevices) return;
|
|
3323
|
+
mic.asked = true;
|
|
3324
|
+
navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true, noiseSuppression: true } }).then(function(s) {
|
|
3325
|
+
if (dead) {
|
|
3326
|
+
s.getTracks().forEach(function(k) {
|
|
3327
|
+
k.stop();
|
|
3328
|
+
});
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
var C = new (typeof AudioContext === "function" ? AudioContext : webkitAudioContext)(), an = C.createAnalyser();
|
|
3332
|
+
an.fftSize = 1024;
|
|
3333
|
+
an.smoothingTimeConstant = 0.5;
|
|
3334
|
+
C.createMediaStreamSource(s).connect(an);
|
|
3335
|
+
mic.on = true;
|
|
3336
|
+
mic.ctx = C;
|
|
3337
|
+
mic.an = an;
|
|
3338
|
+
mic.stream = s;
|
|
3339
|
+
mic.td = new Float32Array(an.fftSize);
|
|
3340
|
+
mic.fd = new Uint8Array(an.frequencyBinCount);
|
|
3341
|
+
}).catch(function() {
|
|
3342
|
+
});
|
|
3343
|
+
}
|
|
3344
|
+
function stopMic() {
|
|
3345
|
+
if (mic.stream) mic.stream.getTracks().forEach(function(k) {
|
|
3346
|
+
k.stop();
|
|
3347
|
+
});
|
|
3348
|
+
if (mic.ctx) mic.ctx.close();
|
|
3349
|
+
mic.on = false;
|
|
3350
|
+
mic.asked = false;
|
|
3351
|
+
mic.stream = mic.ctx = mic.an = null;
|
|
3352
|
+
}
|
|
3353
|
+
function readMic(b) {
|
|
3354
|
+
mic.an.getFloatTimeDomainData(mic.td);
|
|
3355
|
+
var s = 0, i;
|
|
3356
|
+
for (i = 0; i < mic.td.length; i++) s += mic.td[i] * mic.td[i];
|
|
3357
|
+
var db = 20 * Math.log10(Math.sqrt(s / mic.td.length) + 1e-7);
|
|
3358
|
+
mic.an.getByteFrequencyData(mic.fd);
|
|
3359
|
+
var hz = mic.ctx.sampleRate / mic.an.fftSize, band = function(lo, hi) {
|
|
3360
|
+
var a = 0, n = 0;
|
|
3361
|
+
for (var k = Math.floor(lo / hz); k <= Math.ceil(hi / hz); k++) {
|
|
3362
|
+
a += mic.fd[k] || 0;
|
|
3363
|
+
n++;
|
|
3364
|
+
}
|
|
3365
|
+
return clamp2((a / n / 255 - 0.28) / 0.5, 0, 1);
|
|
3366
|
+
};
|
|
3367
|
+
b[0] = band(90, 300);
|
|
3368
|
+
b[1] = band(300, 2e3);
|
|
3369
|
+
b[2] = band(2e3, 6500);
|
|
3370
|
+
return clamp2((db + 54) / 34, 0, 1);
|
|
3371
|
+
}
|
|
3372
|
+
function step(dt) {
|
|
3373
|
+
t += dt;
|
|
3374
|
+
var m = mode(), reduce = reduceMQ && reduceMQ.matches, sw = reduce ? 0 : 1;
|
|
3375
|
+
var tx = 0, ty = 0, tz = 1, att = 0;
|
|
3376
|
+
if (m === "typing") {
|
|
3377
|
+
if (followEl && focused) readCaret();
|
|
3378
|
+
else {
|
|
3379
|
+
if (t >= sim.next) {
|
|
3380
|
+
if (sim.x >= 1.7) {
|
|
3381
|
+
sim.x = -1.7;
|
|
3382
|
+
sim.next = t + 1.1;
|
|
3383
|
+
} else {
|
|
3384
|
+
sim.x += 0.11 + 0.06 * hash1(t * 9.1);
|
|
3385
|
+
key();
|
|
3386
|
+
sim.next = t + 0.07 + 0.095 * hash1(t * 3.7) + (hash1(t * 5.3) > 0.82 ? 0.11 : 0);
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
caret.x = cx + sim.x * R;
|
|
3390
|
+
caret.y = cy + 3.1 * R;
|
|
3391
|
+
}
|
|
3392
|
+
att = t - lastKey < 1.3 ? 1 : 0.55;
|
|
3393
|
+
tx = (caret.x - cx) / R;
|
|
3394
|
+
ty = -(caret.y - cy) / R;
|
|
3395
|
+
tz = 1.7;
|
|
3396
|
+
} else if (look) {
|
|
3397
|
+
tx = (look[0] - cx) / R;
|
|
3398
|
+
ty = -(look[1] - cy) / R;
|
|
3399
|
+
tz = 1.7;
|
|
3400
|
+
} else if (m === "listening") ty = -0.08;
|
|
3401
|
+
else if (m === "thinking") {
|
|
3402
|
+
tx = 0.34 * Math.cos(t * 0.75);
|
|
3403
|
+
ty = 0.24 * Math.sin(t * 0.97);
|
|
3404
|
+
} else if (m === "speaking") ty = 0.04;
|
|
3405
|
+
else {
|
|
3406
|
+
tx = sw * 0.14 * Math.sin(t / 4.3);
|
|
3407
|
+
ty = sw * 0.09 * Math.sin(t / 5.7 + 1);
|
|
3408
|
+
}
|
|
3409
|
+
var n = Math.hypot(tx, ty, tz) || 1;
|
|
3410
|
+
gx.target = tx / n;
|
|
3411
|
+
gy.target = ty / n;
|
|
3412
|
+
gz.target = tz / n;
|
|
3413
|
+
gx.step(dt);
|
|
3414
|
+
gy.step(dt);
|
|
3415
|
+
gz.step(dt);
|
|
3416
|
+
gaze[0] = gx.x;
|
|
3417
|
+
gaze[1] = gy.x;
|
|
3418
|
+
gaze[2] = gz.x;
|
|
3419
|
+
norm(gaze);
|
|
3420
|
+
attend.target = att;
|
|
3421
|
+
attend.step(dt);
|
|
3422
|
+
pulseS.step(dt);
|
|
3423
|
+
think.target = m === "thinking" ? 1 : 0;
|
|
3424
|
+
think.step(dt);
|
|
3425
|
+
speak.target = m === "speaking" ? 1 : 0;
|
|
3426
|
+
speak.step(dt);
|
|
3427
|
+
var lv = 0;
|
|
3428
|
+
rawB[0] = rawB[1] = rawB[2] = 0;
|
|
3429
|
+
if (m === "listening" || m === "speaking") {
|
|
3430
|
+
if (extLevel != null) {
|
|
3431
|
+
lv = clamp2(extLevel, 0, 1);
|
|
3432
|
+
rawB[0] = lv * 0.9;
|
|
3433
|
+
rawB[1] = lv * 0.6;
|
|
3434
|
+
rawB[2] = lv * 0.3;
|
|
3435
|
+
} else if (m === "listening" && mic.on) lv = readMic(rawB);
|
|
3436
|
+
else lv = simVoice(t, m === "speaking", rawB);
|
|
3437
|
+
}
|
|
3438
|
+
level = damp2(level, lv, lv > level ? 28 : 6, dt);
|
|
3439
|
+
for (var i = 0; i < 3; i++) bands[i] = damp2(bands[i], rawB[i], rawB[i] > bands[i] ? 24 : 7, dt);
|
|
3440
|
+
kick = damp2(kick, 0, 2.2, dt);
|
|
3441
|
+
pvel = damp2(pvel, (reduce ? 0.3 : 1) * SPEED[m] + kick, 5, dt);
|
|
3442
|
+
phase += pvel * dt;
|
|
3443
|
+
blur.target = m === "thinking" ? 1 : m === "typing" ? 0 : m === "listening" ? 0.12 : m === "speaking" ? 0.18 : 0.3;
|
|
3444
|
+
blur.step(dt);
|
|
3445
|
+
fill.target = m === "thinking" ? 1 : m === "speaking" ? 0.12 : 0;
|
|
3446
|
+
fill.step(dt);
|
|
3447
|
+
var k = 1 - Math.exp(-5 * dt);
|
|
3448
|
+
for (var key2 in cur) {
|
|
3449
|
+
if (Array.isArray(cur[key2])) for (var j = 0; j < 3; j++) cur[key2][j] += (want[key2][j] - cur[key2][j]) * k;
|
|
3450
|
+
else cur[key2] += (want[key2] - cur[key2]) * k;
|
|
3451
|
+
}
|
|
3452
|
+
var lx = cur.ink > 0.5 ? -0.55 : 0.62;
|
|
3453
|
+
if (m === "thinking") {
|
|
3454
|
+
lightT[0] = Math.cos(t * 0.9);
|
|
3455
|
+
lightT[1] = Math.sin(t * 0.9);
|
|
3456
|
+
lightT[2] = 0.3;
|
|
3457
|
+
} else {
|
|
3458
|
+
lightT[0] = lx + sw * 0.22 * Math.sin(t / 6.1);
|
|
3459
|
+
lightT[1] = 0.58 + sw * 0.18 * Math.sin(t / 7.3 + 2);
|
|
3460
|
+
lightT[2] = 0.38;
|
|
3461
|
+
}
|
|
3462
|
+
norm(lightT);
|
|
3463
|
+
var a = 0.85 * attend.x;
|
|
3464
|
+
for (i = 0; i < 3; i++) lightT[i] += (gaze[i] - lightT[i]) * a;
|
|
3465
|
+
norm(lightT);
|
|
3466
|
+
var kl = 1 - Math.exp(-2.6 * dt);
|
|
3467
|
+
for (i = 0; i < 3; i++) light[i] += (lightT[i] - light[i]) * kl;
|
|
3468
|
+
norm(light);
|
|
3469
|
+
}
|
|
3470
|
+
function draw() {
|
|
3471
|
+
gl.viewport(0, 0, W, H);
|
|
3472
|
+
gl.uniform2f(U.uRes, W, H);
|
|
3473
|
+
gl.uniform2f(U.uC, cx * dpr, H - cy * dpr);
|
|
3474
|
+
gl.uniform1f(U.uR, R * dpr);
|
|
3475
|
+
gl.uniform3fv(U.uTop, cur.top);
|
|
3476
|
+
gl.uniform3fv(U.uBot, cur.bot);
|
|
3477
|
+
gl.uniform3fv(U.uFloor, cur.floor);
|
|
3478
|
+
gl.uniform1f(U.uShadow, cur.shadow);
|
|
3479
|
+
gl.uniform1f(U.uVig, cur.vig);
|
|
3480
|
+
gl.uniform1f(U.uInk, cur.ink);
|
|
3481
|
+
gl.uniform1f(U.uDispK, cur.disp);
|
|
3482
|
+
gl.uniform1f(U.uHaloK, cur.halo);
|
|
3483
|
+
gl.uniform3fv(U.uOrbCol, cur.orb);
|
|
3484
|
+
gl.uniform3fv(U.uRimCol, cur.rim);
|
|
3485
|
+
gl.uniform3fv(U.uHaloCol, cur.haloC);
|
|
3486
|
+
gl.uniform1f(U.uT, t);
|
|
3487
|
+
gl.uniform1f(U.uAttend, attend.x);
|
|
3488
|
+
gl.uniform1f(U.uLevel, level);
|
|
3489
|
+
gl.uniform1f(U.uPulse, clamp2(pulseS.x, 0, 1.2));
|
|
3490
|
+
gl.uniform1f(U.uBlur, blur.x);
|
|
3491
|
+
gl.uniform1f(U.uPhase, phase);
|
|
3492
|
+
gl.uniform1f(U.uFill, fill.x);
|
|
3493
|
+
gl.uniform1f(U.uSpeak, speak.x);
|
|
3494
|
+
gl.uniform3f(U.uBands, bands[0], bands[1], bands[2]);
|
|
3495
|
+
gl.uniform3fv(U.uGaze, gaze);
|
|
3496
|
+
gl.uniform3fv(U.uLight, light);
|
|
3497
|
+
frameTo(gaze, rotM);
|
|
3498
|
+
gl.uniformMatrix3fv(U.uRot, false, rotM);
|
|
3499
|
+
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
|
3500
|
+
}
|
|
3501
|
+
function frame(now) {
|
|
3502
|
+
if (dead) return;
|
|
3503
|
+
raf = requestAnimationFrame(frame);
|
|
3504
|
+
var dt = prev ? Math.min(1 / 30, Math.max(0, (now - prev) / 1e3)) : 0;
|
|
3505
|
+
prev = now;
|
|
3506
|
+
if (!onScreen || document.hidden) return;
|
|
3507
|
+
step(dt);
|
|
3508
|
+
draw();
|
|
3509
|
+
}
|
|
3510
|
+
step(0);
|
|
3511
|
+
draw();
|
|
3512
|
+
raf = requestAnimationFrame(frame);
|
|
3513
|
+
api7 = {
|
|
3514
|
+
set: function(s) {
|
|
3515
|
+
if (STATES[s]) {
|
|
3516
|
+
state = s;
|
|
3517
|
+
if (s === "listening" && o.mic) startMic();
|
|
3518
|
+
if (s !== "listening") stopMic();
|
|
3519
|
+
}
|
|
3520
|
+
return api7;
|
|
3521
|
+
},
|
|
3522
|
+
tone: function(n) {
|
|
3523
|
+
if (TONES[n]) {
|
|
3524
|
+
tone = n;
|
|
3525
|
+
want = TONES[n];
|
|
3526
|
+
}
|
|
3527
|
+
return api7;
|
|
3528
|
+
},
|
|
3529
|
+
level: function(v) {
|
|
3530
|
+
extLevel = v == null ? null : +v;
|
|
3531
|
+
return api7;
|
|
3532
|
+
},
|
|
3533
|
+
pulse: function() {
|
|
3534
|
+
key();
|
|
3535
|
+
return api7;
|
|
3536
|
+
},
|
|
3537
|
+
lookAt: function(x, y) {
|
|
3538
|
+
if (x == null) {
|
|
3539
|
+
look = null;
|
|
3540
|
+
return api7;
|
|
3541
|
+
}
|
|
3542
|
+
var r = host.getBoundingClientRect();
|
|
3543
|
+
look = [x - r.left, y - r.top];
|
|
3544
|
+
return api7;
|
|
3545
|
+
},
|
|
3546
|
+
follow: function(el) {
|
|
3547
|
+
if (followEl) {
|
|
3548
|
+
followEl.removeEventListener("input", onInput);
|
|
3549
|
+
followEl.removeEventListener("focus", onFocus);
|
|
3550
|
+
followEl.removeEventListener("blur", onBlur);
|
|
3551
|
+
followEl.removeEventListener("keyup", readCaret);
|
|
3552
|
+
followEl.removeEventListener("click", readCaret);
|
|
3553
|
+
}
|
|
3554
|
+
followEl = el || null;
|
|
3555
|
+
focused = !!(followEl && document.activeElement === followEl);
|
|
3556
|
+
if (followEl) {
|
|
3557
|
+
followEl.addEventListener("input", onInput);
|
|
3558
|
+
followEl.addEventListener("focus", onFocus);
|
|
3559
|
+
followEl.addEventListener("blur", onBlur);
|
|
3560
|
+
followEl.addEventListener("keyup", readCaret);
|
|
3561
|
+
followEl.addEventListener("click", readCaret);
|
|
3562
|
+
}
|
|
3563
|
+
return api7;
|
|
3564
|
+
},
|
|
3565
|
+
get state() {
|
|
3566
|
+
return state;
|
|
3567
|
+
},
|
|
3568
|
+
get toneName() {
|
|
3569
|
+
return tone;
|
|
3570
|
+
},
|
|
3571
|
+
destroy: function() {
|
|
3572
|
+
dead = true;
|
|
3573
|
+
cancelAnimationFrame(raf);
|
|
3574
|
+
api7.follow(null);
|
|
3575
|
+
stopMic();
|
|
3576
|
+
if (ro) ro.disconnect();
|
|
3577
|
+
else removeEventListener("resize", size);
|
|
3578
|
+
if (io) io.disconnect();
|
|
3579
|
+
var lose = gl.getExtension("WEBGL_lose_context");
|
|
3580
|
+
if (lose) lose.loseContext();
|
|
3581
|
+
canvas.remove();
|
|
3582
|
+
host.classList.remove("orb");
|
|
3583
|
+
}
|
|
3584
|
+
};
|
|
3585
|
+
if (o.follow) api7.follow(typeof o.follow === "string" ? document.querySelector(o.follow) : o.follow);
|
|
3586
|
+
if (o.level != null) api7.level(o.level);
|
|
3587
|
+
api7.set(state);
|
|
3588
|
+
return api7;
|
|
3589
|
+
}
|
|
3590
|
+
orb.tones = Object.keys(TONES);
|
|
3591
|
+
orb.states = Object.keys(STATES);
|
|
3592
|
+
window2.orb = orb;
|
|
3593
|
+
})();
|
|
3594
|
+
return api6 = window2;
|
|
3595
|
+
}
|
|
3596
|
+
function mountFoldOrb(host, o = {}) {
|
|
3597
|
+
css("craft-orb", CSS7);
|
|
3598
|
+
const E = engine6();
|
|
3599
|
+
host.innerHTML = '<div class="orb"></div>';
|
|
3600
|
+
const el = host.firstChild;
|
|
3601
|
+
const tall = (h) => {
|
|
3602
|
+
if (h != null && h !== "") el.style.setProperty("--orb-height", typeof h === "number" || /^\d+(\.\d+)?$/.test(h) ? h + "px" : String(h));
|
|
3603
|
+
};
|
|
3604
|
+
const field = (f) => typeof f === "string" ? document.querySelector(f) : f && "current" in f ? f.current : f;
|
|
3605
|
+
tall(o.height);
|
|
3606
|
+
const m = E.orb(el, { tone: o.tone, state: o.state, follow: field(o.follow), level: o.level, mic: o.mic, label: o.label });
|
|
3607
|
+
return {
|
|
3608
|
+
element: el,
|
|
3609
|
+
set: (s) => m.set(s),
|
|
3610
|
+
tone: (t) => m.tone(t),
|
|
3611
|
+
level: (v) => m.level(v),
|
|
3612
|
+
pulse: () => m.pulse(),
|
|
3613
|
+
lookAt: (x, y) => m.lookAt(x, y),
|
|
3614
|
+
follow: (f) => m.follow(field(f)),
|
|
3615
|
+
height: tall,
|
|
3616
|
+
destroy() {
|
|
3617
|
+
m.destroy();
|
|
3618
|
+
host.innerHTML = "";
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
}
|
|
3622
|
+
|
|
3028
3623
|
// dist/sign.js
|
|
3029
3624
|
function sign() {
|
|
3030
3625
|
if (typeof window === "undefined" || typeof document === "undefined" || window.__craftLibrarySigned) return;
|
|
@@ -3044,7 +3639,7 @@ void main() {
|
|
|
3044
3639
|
customElements.define(name, class extends HTMLElement {
|
|
3045
3640
|
connectedCallback() {
|
|
3046
3641
|
if (this.piece) return;
|
|
3047
|
-
css("craft-hosts", "like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}");
|
|
3642
|
+
css("craft-hosts", "like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}fold-orb{display:block}");
|
|
3048
3643
|
this.piece = mount(this, options(this));
|
|
3049
3644
|
}
|
|
3050
3645
|
});
|
|
@@ -3170,7 +3765,39 @@ void main() {
|
|
|
3170
3765
|
label: el.getAttribute("label") || void 0,
|
|
3171
3766
|
onChange: (value) => send(el, "change", { value })
|
|
3172
3767
|
}));
|
|
3768
|
+
define("fold-orb", (el, o) => {
|
|
3769
|
+
const m = mountFoldOrb(el, o), num = (v) => v == null || v === "" ? null : +v;
|
|
3770
|
+
const sel = el.getAttribute("follow");
|
|
3771
|
+
if (sel && !o.follow) {
|
|
3772
|
+
const f = () => m.follow(document.querySelector(sel));
|
|
3773
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", f, { once: true });
|
|
3774
|
+
else f();
|
|
3775
|
+
}
|
|
3776
|
+
el.pulse = m.pulse;
|
|
3777
|
+
el.lookAt = m.lookAt;
|
|
3778
|
+
el.follow = m.follow;
|
|
3779
|
+
Object.defineProperty(el, "state", { configurable: true, get: () => el.getAttribute("state") || "idle", set: (v) => el.setAttribute("state", v) });
|
|
3780
|
+
Object.defineProperty(el, "tone", { configurable: true, get: () => el.getAttribute("tone") || "steel", set: (v) => el.setAttribute("tone", v) });
|
|
3781
|
+
Object.defineProperty(el, "level", { configurable: true, get: () => num(el.getAttribute("level")), set: (v) => {
|
|
3782
|
+
if (v == null) el.removeAttribute("level");
|
|
3783
|
+
else el.setAttribute("level", v);
|
|
3784
|
+
} });
|
|
3785
|
+
new MutationObserver((list) => list.forEach((r) => {
|
|
3786
|
+
if (r.attributeName === "state") m.set(el.getAttribute("state") || "idle");
|
|
3787
|
+
else if (r.attributeName === "tone") m.tone(el.getAttribute("tone") || "steel");
|
|
3788
|
+
else if (r.attributeName === "level") m.level(num(el.getAttribute("level")));
|
|
3789
|
+
else if (r.attributeName === "height") m.height(el.getAttribute("height"));
|
|
3790
|
+
})).observe(el, { attributes: true, attributeFilter: ["state", "tone", "level", "height"] });
|
|
3791
|
+
return m;
|
|
3792
|
+
}, (el) => ({
|
|
3793
|
+
tone: el.getAttribute("tone") || void 0,
|
|
3794
|
+
state: el.getAttribute("state") || void 0,
|
|
3795
|
+
height: el.getAttribute("height") || void 0,
|
|
3796
|
+
level: el.hasAttribute("level") && el.getAttribute("level") !== "" ? +el.getAttribute("level") : void 0,
|
|
3797
|
+
mic: el.hasAttribute("mic") && el.getAttribute("mic") !== "false",
|
|
3798
|
+
label: el.getAttribute("label") || void 0
|
|
3799
|
+
}));
|
|
3173
3800
|
|
|
3174
3801
|
// dist/cdn.js
|
|
3175
|
-
window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction };
|
|
3802
|
+
window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb };
|
|
3176
3803
|
})();
|