@opentiny/next-sdk 0.4.0 → 0.4.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/agent/AgentModelProvider.ts +78 -81
- package/agent/type.ts +6 -9
- package/agent/utils/getAISDKTools.ts +0 -1
- package/agent/utils/getBuiltinMcpTools.ts +7 -7
- package/core.ts +0 -3
- package/dist/SimulatorMask-BHVXyogh-iNUb4dyF.js +361 -0
- package/dist/agent/type.d.ts +4 -12
- package/dist/agent/utils/getBuiltinMcpTools.d.ts +3 -3
- package/dist/core.d.ts +0 -1
- package/dist/core.js +16 -17
- package/dist/index-CXK8CcKq.js +6076 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +57 -4969
- package/dist/{initialize-builtin-WebMCP-HgObT902.js → initialize-builtin-WebMCP-rALfqS-o.js} +1166 -1056
- package/dist/page-tools/a11y/build.d.ts +11 -0
- package/dist/page-tools/a11y/constants.d.ts +9 -0
- package/dist/page-tools/a11y/search.d.ts +17 -0
- package/dist/page-tools/a11y/types.d.ts +104 -0
- package/dist/page-tools/a11y/utils.d.ts +34 -0
- package/dist/page-tools/a11y/vnode.d.ts +37 -0
- package/dist/page-tools/a11y-tree.d.ts +8 -99
- package/dist/page-tools/constants.d.ts +22 -0
- package/dist/page-tools/context.d.ts +28 -0
- package/dist/page-tools/handlers/browserState.d.ts +8 -0
- package/dist/page-tools/handlers/click.d.ts +8 -0
- package/dist/page-tools/handlers/executeJavascript.d.ts +8 -0
- package/dist/page-tools/handlers/fill.d.ts +8 -0
- package/dist/page-tools/handlers/scroll.d.ts +8 -0
- package/dist/page-tools/handlers/searchTree.d.ts +8 -0
- package/dist/page-tools/handlers/select.d.ts +8 -0
- package/dist/page-tools/page-agent-highlight/index.d.ts +9 -0
- package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +14 -0
- package/dist/page-tools/page-agent-mask/checkDarkMode.d.ts +5 -0
- package/dist/page-tools/page-agent-tool.d.ts +3 -8
- package/dist/page-tools/schema.d.ts +43 -0
- package/dist/page-tools/utils/dom.d.ts +6 -0
- package/dist/page-tools/utils/scroll.d.ts +15 -0
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.js +744 -0
- package/dist/utils/builtinProxy.d.ts +1 -1
- package/index.ts +0 -5
- package/package.json +6 -17
- package/page-tools/a11y/build.ts +70 -0
- package/page-tools/a11y/constants.ts +110 -0
- package/page-tools/a11y/search.ts +129 -0
- package/page-tools/a11y/types.ts +108 -0
- package/page-tools/a11y/utils.ts +266 -0
- package/page-tools/a11y/vnode.ts +229 -0
- package/page-tools/a11y-tree.ts +8 -527
- package/page-tools/bridge.ts +1 -1
- package/page-tools/constants.ts +72 -0
- package/page-tools/context.ts +13 -0
- package/page-tools/handlers/browserState.ts +12 -0
- package/page-tools/handlers/click.ts +26 -0
- package/page-tools/handlers/executeJavascript.ts +22 -0
- package/page-tools/handlers/fill.ts +60 -0
- package/page-tools/handlers/scroll.ts +66 -0
- package/page-tools/handlers/searchTree.ts +30 -0
- package/page-tools/handlers/select.ts +34 -0
- package/page-tools/page-agent-highlight/index.ts +198 -0
- package/page-tools/page-agent-mask/SimulatorMask.module.css +14 -0
- package/page-tools/page-agent-mask/SimulatorMask.ts +279 -0
- package/page-tools/page-agent-mask/checkDarkMode.ts +181 -0
- package/page-tools/page-agent-mask/cursor-border.svg +3 -0
- package/page-tools/page-agent-mask/cursor-fill.svg +5 -0
- package/page-tools/page-agent-mask/cursor.module.css +70 -0
- package/page-tools/page-agent-prompt.md +34 -18
- package/page-tools/page-agent-tool.ts +104 -152
- package/page-tools/schema.ts +51 -0
- package/page-tools/utils/dom.ts +155 -0
- package/page-tools/utils/scroll.ts +58 -0
- package/runtime.ts +13 -0
- package/utils/builtinProxy.ts +45 -13
- package/vite.config.runtime.ts +22 -0
- package/vite.config.ts +52 -8
- package/McpSdk.ts +0 -14
- package/WebAgent.ts +0 -5
- package/WebMcp.ts +0 -26
- package/Zod.ts +0 -1
- package/dist/McpSdk.d.ts +0 -14
- package/dist/SimulatorMask-BHVXyogh-BFEGpD5S.js +0 -1048
- package/dist/SimulatorMask-BHVXyogh-CCYbrb84.js +0 -801
- package/dist/WebAgent.d.ts +0 -5
- package/dist/WebMcp.d.ts +0 -23
- package/dist/Zod.d.ts +0 -1
- package/dist/index.es.dev.js +0 -59017
- package/dist/index.es.js +0 -46795
- package/dist/index.umd.dev.js +0 -60355
- package/dist/index.umd.js +0 -1248
- package/dist/mcpsdk@1.25.3.dev.js +0 -22780
- package/dist/mcpsdk@1.25.3.es.dev.js +0 -22778
- package/dist/mcpsdk@1.25.3.es.js +0 -16960
- package/dist/mcpsdk@1.25.3.js +0 -48
- package/dist/transport/ExtensionClientTransport.d.ts +0 -24
- package/dist/transport/ExtensionContentServerTransport.d.ts +0 -39
- package/dist/transport/ExtensionPageServerTransport.d.ts +0 -36
- package/dist/transport/messages.d.ts +0 -9
- package/dist/vite.config.mcpSdk.d.ts +0 -2
- package/dist/vite.config.webAgent.d.ts +0 -2
- package/dist/vite.config.webMcp.d.ts +0 -2
- package/dist/vite.config.webMcpFull.d.ts +0 -2
- package/dist/vite.config.zod.d.ts +0 -2
- package/dist/webagent.dev.js +0 -49360
- package/dist/webagent.es.dev.js +0 -49071
- package/dist/webagent.es.js +0 -39219
- package/dist/webagent.js +0 -642
- package/dist/webmcp-full.dev.js +0 -31336
- package/dist/webmcp-full.es.dev.js +0 -30283
- package/dist/webmcp-full.es.js +0 -22889
- package/dist/webmcp-full.js +0 -645
- package/dist/webmcp.dev.js +0 -9572
- package/dist/webmcp.es.dev.js +0 -8518
- package/dist/webmcp.es.js +0 -6727
- package/dist/webmcp.js +0 -602
- package/dist/zod@3.25.76.dev.js +0 -4037
- package/dist/zod@3.25.76.es.dev.js +0 -4033
- package/dist/zod@3.25.76.es.js +0 -2945
- package/dist/zod@3.25.76.js +0 -1
- package/transport/ExtensionClientTransport.ts +0 -100
- package/transport/ExtensionContentServerTransport.ts +0 -162
- package/transport/ExtensionPageServerTransport.ts +0 -149
- package/transport/messages.ts +0 -63
- package/vite-build-tsc.ts +0 -63
- package/vite-env.d.ts +0 -10
- package/vite.config.mcpSdk.ts +0 -28
- package/vite.config.webAgent.ts +0 -19
- package/vite.config.webMcp.ts +0 -40
- package/vite.config.webMcpFull.ts +0 -19
- package/vite.config.zod.ts +0 -23
- /package/dist/{vite-build-tsc.d.ts → vite.config.runtime.d.ts} +0 -0
|
@@ -1,801 +0,0 @@
|
|
|
1
|
-
function N(r, t, o, n) {
|
|
2
|
-
const e = Math.max(1, Math.min(r, t)), i = Math.min(o, 20), y = Math.min(i + n, e), l = Math.min(y, Math.floor(r / 2)), h = Math.min(y, Math.floor(t / 2)), s = (M) => M / r * 2 - 1, d = (M) => M / t * 2 - 1, E = 0, k = r, A = 0, b = t, _ = l, x = r - l, P = h, C = t - h, c = s(E), a = s(k), R = d(A), T = d(b), I = s(_), B = s(x), u = d(P), f = d(C), g = 0, F = 0, p = 1, G = 1, U = l / r, S = 1 - l / r, m = h / t, w = 1 - h / t, z = new Float32Array([
|
|
3
|
-
// Top strip
|
|
4
|
-
c,
|
|
5
|
-
R,
|
|
6
|
-
a,
|
|
7
|
-
R,
|
|
8
|
-
c,
|
|
9
|
-
u,
|
|
10
|
-
c,
|
|
11
|
-
u,
|
|
12
|
-
a,
|
|
13
|
-
R,
|
|
14
|
-
a,
|
|
15
|
-
u,
|
|
16
|
-
// Bottom strip
|
|
17
|
-
c,
|
|
18
|
-
f,
|
|
19
|
-
a,
|
|
20
|
-
f,
|
|
21
|
-
c,
|
|
22
|
-
T,
|
|
23
|
-
c,
|
|
24
|
-
T,
|
|
25
|
-
a,
|
|
26
|
-
f,
|
|
27
|
-
a,
|
|
28
|
-
T,
|
|
29
|
-
// Left strip
|
|
30
|
-
c,
|
|
31
|
-
u,
|
|
32
|
-
I,
|
|
33
|
-
u,
|
|
34
|
-
c,
|
|
35
|
-
f,
|
|
36
|
-
c,
|
|
37
|
-
f,
|
|
38
|
-
I,
|
|
39
|
-
u,
|
|
40
|
-
I,
|
|
41
|
-
f,
|
|
42
|
-
// Right strip
|
|
43
|
-
B,
|
|
44
|
-
u,
|
|
45
|
-
a,
|
|
46
|
-
u,
|
|
47
|
-
B,
|
|
48
|
-
f,
|
|
49
|
-
B,
|
|
50
|
-
f,
|
|
51
|
-
a,
|
|
52
|
-
u,
|
|
53
|
-
a,
|
|
54
|
-
f
|
|
55
|
-
]), Q = new Float32Array([
|
|
56
|
-
// Top strip
|
|
57
|
-
g,
|
|
58
|
-
F,
|
|
59
|
-
p,
|
|
60
|
-
F,
|
|
61
|
-
g,
|
|
62
|
-
m,
|
|
63
|
-
g,
|
|
64
|
-
m,
|
|
65
|
-
p,
|
|
66
|
-
F,
|
|
67
|
-
p,
|
|
68
|
-
m,
|
|
69
|
-
// Bottom strip
|
|
70
|
-
g,
|
|
71
|
-
w,
|
|
72
|
-
p,
|
|
73
|
-
w,
|
|
74
|
-
g,
|
|
75
|
-
G,
|
|
76
|
-
g,
|
|
77
|
-
G,
|
|
78
|
-
p,
|
|
79
|
-
w,
|
|
80
|
-
p,
|
|
81
|
-
G,
|
|
82
|
-
// Left strip
|
|
83
|
-
g,
|
|
84
|
-
m,
|
|
85
|
-
U,
|
|
86
|
-
m,
|
|
87
|
-
g,
|
|
88
|
-
w,
|
|
89
|
-
g,
|
|
90
|
-
w,
|
|
91
|
-
U,
|
|
92
|
-
m,
|
|
93
|
-
U,
|
|
94
|
-
w,
|
|
95
|
-
// Right strip
|
|
96
|
-
S,
|
|
97
|
-
m,
|
|
98
|
-
p,
|
|
99
|
-
m,
|
|
100
|
-
S,
|
|
101
|
-
w,
|
|
102
|
-
S,
|
|
103
|
-
w,
|
|
104
|
-
p,
|
|
105
|
-
m,
|
|
106
|
-
p,
|
|
107
|
-
w
|
|
108
|
-
]);
|
|
109
|
-
return { positions: z, uvs: Q };
|
|
110
|
-
}
|
|
111
|
-
function V(r, t, o) {
|
|
112
|
-
const n = r.createShader(t);
|
|
113
|
-
if (!n) throw new Error("Failed to create shader");
|
|
114
|
-
if (r.shaderSource(n, o), r.compileShader(n), !r.getShaderParameter(n, r.COMPILE_STATUS)) {
|
|
115
|
-
const e = r.getShaderInfoLog(n) || "Unknown shader error";
|
|
116
|
-
throw r.deleteShader(n), new Error(e);
|
|
117
|
-
}
|
|
118
|
-
return n;
|
|
119
|
-
}
|
|
120
|
-
function Y(r, t, o) {
|
|
121
|
-
const n = V(r, r.VERTEX_SHADER, t), e = V(r, r.FRAGMENT_SHADER, o), i = r.createProgram();
|
|
122
|
-
if (!i) throw new Error("Failed to create program");
|
|
123
|
-
if (r.attachShader(i, n), r.attachShader(i, e), r.linkProgram(i), !r.getProgramParameter(i, r.LINK_STATUS)) {
|
|
124
|
-
const v = r.getProgramInfoLog(i) || "Unknown link error";
|
|
125
|
-
throw r.deleteProgram(i), r.deleteShader(n), r.deleteShader(e), new Error(v);
|
|
126
|
-
}
|
|
127
|
-
return r.deleteShader(n), r.deleteShader(e), i;
|
|
128
|
-
}
|
|
129
|
-
const X = `#version 300 es
|
|
130
|
-
precision lowp float;
|
|
131
|
-
in vec2 vUV;
|
|
132
|
-
out vec4 outColor;
|
|
133
|
-
uniform vec2 uResolution;
|
|
134
|
-
uniform float uTime;
|
|
135
|
-
uniform float uBorderWidth;
|
|
136
|
-
uniform float uGlowWidth;
|
|
137
|
-
uniform float uBorderRadius;
|
|
138
|
-
uniform vec3 uColors[4];
|
|
139
|
-
uniform float uGlowExponent;
|
|
140
|
-
uniform float uGlowFactor;
|
|
141
|
-
const float PI = 3.14159265359;
|
|
142
|
-
const float TWO_PI = 2.0 * PI;
|
|
143
|
-
const float HALF_PI = 0.5 * PI;
|
|
144
|
-
const vec4 startPositions = vec4(0.0, PI, HALF_PI, 1.5 * PI);
|
|
145
|
-
const vec4 speeds = vec4(-1.9, -1.9, -1.5, 2.1);
|
|
146
|
-
const vec4 innerRadius = vec4(PI * 0.8, PI * 0.7, PI * 0.3, PI * 0.1);
|
|
147
|
-
const vec4 outerRadius = vec4(PI * 1.2, PI * 0.9, PI * 0.6, PI * 0.4);
|
|
148
|
-
float random(vec2 st) {
|
|
149
|
-
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
|
|
150
|
-
}
|
|
151
|
-
vec2 random2(vec2 st) {
|
|
152
|
-
return vec2(random(st), random(st + 1.0));
|
|
153
|
-
}
|
|
154
|
-
float aaStep(float edge, float d) {
|
|
155
|
-
float width = fwidth(d);
|
|
156
|
-
return smoothstep(edge - width * 0.5, edge + width * 0.5, d);
|
|
157
|
-
}
|
|
158
|
-
float aaFract(float x) {
|
|
159
|
-
float f = fract(x);
|
|
160
|
-
float w = fwidth(x);
|
|
161
|
-
float smooth_f = f * (1.0 - smoothstep(1.0 - w, 1.0, f));
|
|
162
|
-
return smooth_f;
|
|
163
|
-
}
|
|
164
|
-
float sdRoundedBox(in vec2 p, in vec2 b, in float r) {
|
|
165
|
-
vec2 q = abs(p) - b + r;
|
|
166
|
-
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
|
|
167
|
-
}
|
|
168
|
-
float getInnerGlow(vec2 p, vec2 b, float radius) {
|
|
169
|
-
float dist_x = b.x - abs(p.x);
|
|
170
|
-
float dist_y = b.y - abs(p.y);
|
|
171
|
-
float glow_x = smoothstep(radius, 0.0, dist_x);
|
|
172
|
-
float glow_y = smoothstep(radius, 0.0, dist_y);
|
|
173
|
-
return 1.0 - (1.0 - glow_x) * (1.0 - glow_y);
|
|
174
|
-
}
|
|
175
|
-
float getVignette(vec2 uv) {
|
|
176
|
-
vec2 vignetteUv = uv;
|
|
177
|
-
vignetteUv = vignetteUv * (1.0 - vignetteUv);
|
|
178
|
-
float vignette = vignetteUv.x * vignetteUv.y * 25.0;
|
|
179
|
-
vignette = pow(vignette, 0.16);
|
|
180
|
-
vignette = 1.0 - vignette;
|
|
181
|
-
return vignette;
|
|
182
|
-
}
|
|
183
|
-
float uvToAngle(vec2 uv) {
|
|
184
|
-
vec2 center = vec2(0.5);
|
|
185
|
-
vec2 dir = uv - center;
|
|
186
|
-
return atan(dir.y, dir.x) + PI;
|
|
187
|
-
}
|
|
188
|
-
void main() {
|
|
189
|
-
vec2 uv = vUV;
|
|
190
|
-
vec2 pos = uv * uResolution;
|
|
191
|
-
vec2 centeredPos = pos - uResolution * 0.5;
|
|
192
|
-
vec2 size = uResolution - uBorderWidth;
|
|
193
|
-
vec2 halfSize = size * 0.5;
|
|
194
|
-
float dBorderBox = sdRoundedBox(centeredPos, halfSize, uBorderRadius);
|
|
195
|
-
float border = aaStep(0.0, dBorderBox);
|
|
196
|
-
float glow = getInnerGlow(centeredPos, halfSize, uGlowWidth);
|
|
197
|
-
float vignette = getVignette(uv);
|
|
198
|
-
glow *= vignette;
|
|
199
|
-
float posAngle = uvToAngle(uv);
|
|
200
|
-
vec4 lightCenter = mod(startPositions + speeds * uTime, TWO_PI);
|
|
201
|
-
vec4 angleDist = abs(posAngle - lightCenter);
|
|
202
|
-
vec4 disToLight = min(angleDist, TWO_PI - angleDist) / TWO_PI;
|
|
203
|
-
float intensityBorder[4];
|
|
204
|
-
intensityBorder[0] = 1.0;
|
|
205
|
-
intensityBorder[1] = smoothstep(0.4, 0.0, disToLight.y);
|
|
206
|
-
intensityBorder[2] = smoothstep(0.4, 0.0, disToLight.z);
|
|
207
|
-
intensityBorder[3] = smoothstep(0.2, 0.0, disToLight.w) * 0.5;
|
|
208
|
-
vec3 borderColor = vec3(0.0);
|
|
209
|
-
for(int i = 0; i < 4; i++) {
|
|
210
|
-
borderColor = mix(borderColor, uColors[i], intensityBorder[i]);
|
|
211
|
-
}
|
|
212
|
-
borderColor *= 1.1;
|
|
213
|
-
borderColor = clamp(borderColor, 0.0, 1.0);
|
|
214
|
-
float intensityGlow[4];
|
|
215
|
-
intensityGlow[0] = smoothstep(0.9, 0.0, disToLight.x);
|
|
216
|
-
intensityGlow[1] = smoothstep(0.7, 0.0, disToLight.y);
|
|
217
|
-
intensityGlow[2] = smoothstep(0.4, 0.0, disToLight.z);
|
|
218
|
-
intensityGlow[3] = smoothstep(0.1, 0.0, disToLight.w) * 0.7;
|
|
219
|
-
vec4 breath = smoothstep(0.0, 1.0, sin(uTime * 1.0 + startPositions * PI) * 0.2 + 0.8);
|
|
220
|
-
vec3 glowColor = vec3(0.0);
|
|
221
|
-
glowColor += uColors[0] * intensityGlow[0] * breath.x;
|
|
222
|
-
glowColor += uColors[1] * intensityGlow[1] * breath.y;
|
|
223
|
-
glowColor += uColors[2] * intensityGlow[2] * breath.z;
|
|
224
|
-
glowColor += uColors[3] * intensityGlow[3] * breath.w * glow;
|
|
225
|
-
glow = pow(glow, uGlowExponent);
|
|
226
|
-
glow *= random(pos + uTime) * 0.1 + 1.0;
|
|
227
|
-
glowColor *= glow * uGlowFactor;
|
|
228
|
-
glowColor = clamp(glowColor, 0.0, 1.0);
|
|
229
|
-
vec3 color = mix(glowColor, borderColor + glowColor * 0.2, border);
|
|
230
|
-
float alpha = mix(glow, 1.0, border);
|
|
231
|
-
outColor = vec4(color, alpha);
|
|
232
|
-
}`, $ = `#version 300 es
|
|
233
|
-
in vec2 aPosition;
|
|
234
|
-
in vec2 aUV;
|
|
235
|
-
out vec2 vUV;
|
|
236
|
-
void main() {
|
|
237
|
-
vUV = aUV;
|
|
238
|
-
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
239
|
-
}`;
|
|
240
|
-
const q = [
|
|
241
|
-
"rgb(57, 182, 255)",
|
|
242
|
-
"rgb(189, 69, 251)",
|
|
243
|
-
"rgb(255, 87, 51)",
|
|
244
|
-
"rgb(255, 214, 0)"
|
|
245
|
-
];
|
|
246
|
-
function j(r) {
|
|
247
|
-
const t = r.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
248
|
-
if (!t)
|
|
249
|
-
throw new Error(`Invalid color format: ${r}`);
|
|
250
|
-
const [, o, n, e] = t;
|
|
251
|
-
return [parseInt(o) / 255, parseInt(n) / 255, parseInt(e) / 255];
|
|
252
|
-
}
|
|
253
|
-
class H {
|
|
254
|
-
element;
|
|
255
|
-
canvas;
|
|
256
|
-
options;
|
|
257
|
-
running = !1;
|
|
258
|
-
disposed = !1;
|
|
259
|
-
startTime = 0;
|
|
260
|
-
lastTime = 0;
|
|
261
|
-
rafId = null;
|
|
262
|
-
glr;
|
|
263
|
-
observer;
|
|
264
|
-
constructor(t = {}) {
|
|
265
|
-
this.options = {
|
|
266
|
-
width: t.width ?? 600,
|
|
267
|
-
height: t.height ?? 600,
|
|
268
|
-
ratio: t.ratio ?? window.devicePixelRatio ?? 1,
|
|
269
|
-
borderWidth: t.borderWidth ?? 8,
|
|
270
|
-
glowWidth: t.glowWidth ?? 200,
|
|
271
|
-
borderRadius: t.borderRadius ?? 8,
|
|
272
|
-
mode: t.mode ?? "light",
|
|
273
|
-
...t
|
|
274
|
-
}, this.canvas = document.createElement("canvas"), this.options.classNames && (this.canvas.className = this.options.classNames), this.options.styles && Object.assign(this.canvas.style, this.options.styles), this.canvas.style.display = "block", this.canvas.style.transformOrigin = "center", this.canvas.style.pointerEvents = "none", this.element = this.canvas, this.setupGL(), this.options.skipGreeting || this.greet();
|
|
275
|
-
}
|
|
276
|
-
start() {
|
|
277
|
-
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
278
|
-
if (this.running) return;
|
|
279
|
-
if (!this.glr) {
|
|
280
|
-
console.error("WebGL resources are not initialized.");
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
this.running = !0, this.startTime = performance.now(), this.resize(this.options.width ?? 600, this.options.height ?? 600, this.options.ratio), this.glr.gl.viewport(0, 0, this.canvas.width, this.canvas.height), this.glr.gl.useProgram(this.glr.program), this.glr.gl.uniform2f(this.glr.uResolution, this.canvas.width, this.canvas.height), this.checkGLError(this.glr.gl, "start: after initial setup");
|
|
284
|
-
const t = () => {
|
|
285
|
-
if (!this.running || !this.glr) return;
|
|
286
|
-
this.rafId = requestAnimationFrame(t);
|
|
287
|
-
const o = performance.now();
|
|
288
|
-
if (o - this.lastTime < 1e3 / 32) return;
|
|
289
|
-
this.lastTime = o;
|
|
290
|
-
const e = (o - this.startTime) * 1e-3;
|
|
291
|
-
this.render(e);
|
|
292
|
-
};
|
|
293
|
-
this.rafId = requestAnimationFrame(t);
|
|
294
|
-
}
|
|
295
|
-
pause() {
|
|
296
|
-
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
297
|
-
this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
|
|
298
|
-
}
|
|
299
|
-
dispose() {
|
|
300
|
-
if (this.disposed) return;
|
|
301
|
-
this.disposed = !0, this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
|
|
302
|
-
const { gl: t, vao: o, positionBuffer: n, uvBuffer: e, program: i } = this.glr;
|
|
303
|
-
o && t.deleteVertexArray(o), n && t.deleteBuffer(n), e && t.deleteBuffer(e), t.deleteProgram(i), this.observer && this.observer.disconnect(), this.canvas.remove();
|
|
304
|
-
}
|
|
305
|
-
resize(t, o, n) {
|
|
306
|
-
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
307
|
-
if (this.options.width = t, this.options.height = o, n && (this.options.ratio = n), !this.running) return;
|
|
308
|
-
const { gl: e, program: i, vao: v, positionBuffer: y, uvBuffer: l, uResolution: h } = this.glr, s = n ?? this.options.ratio ?? window.devicePixelRatio ?? 1, d = Math.max(1, Math.floor(t * s)), E = Math.max(1, Math.floor(o * s));
|
|
309
|
-
this.canvas.style.width = `${t}px`, this.canvas.style.height = `${o}px`, (this.canvas.width !== d || this.canvas.height !== E) && (this.canvas.width = d, this.canvas.height = E), e.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(e, "resize: after viewport setup");
|
|
310
|
-
const { positions: k, uvs: A } = N(
|
|
311
|
-
this.canvas.width,
|
|
312
|
-
this.canvas.height,
|
|
313
|
-
this.options.borderWidth * s,
|
|
314
|
-
this.options.glowWidth * s
|
|
315
|
-
);
|
|
316
|
-
e.bindVertexArray(v), e.bindBuffer(e.ARRAY_BUFFER, y), e.bufferData(e.ARRAY_BUFFER, k, e.STATIC_DRAW);
|
|
317
|
-
const b = e.getAttribLocation(i, "aPosition");
|
|
318
|
-
e.enableVertexAttribArray(b), e.vertexAttribPointer(b, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "resize: after position buffer update"), e.bindBuffer(e.ARRAY_BUFFER, l), e.bufferData(e.ARRAY_BUFFER, A, e.STATIC_DRAW);
|
|
319
|
-
const _ = e.getAttribLocation(i, "aUV");
|
|
320
|
-
e.enableVertexAttribArray(_), e.vertexAttribPointer(_, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "resize: after UV buffer update"), e.useProgram(i), e.uniform2f(h, this.canvas.width, this.canvas.height), e.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * s), e.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * s), e.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * s), this.checkGLError(e, "resize: after uniform updates");
|
|
321
|
-
const x = performance.now();
|
|
322
|
-
this.lastTime = x;
|
|
323
|
-
const P = (x - this.startTime) * 1e-3;
|
|
324
|
-
this.render(P);
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Automatically resizes the canvas to match the dimensions of the given element.
|
|
328
|
-
* @note using ResizeObserver
|
|
329
|
-
*/
|
|
330
|
-
autoResize(t) {
|
|
331
|
-
this.observer && this.observer.disconnect(), this.observer = new ResizeObserver(() => {
|
|
332
|
-
const o = t.getBoundingClientRect();
|
|
333
|
-
this.resize(o.width, o.height);
|
|
334
|
-
}), this.observer.observe(t);
|
|
335
|
-
}
|
|
336
|
-
fadeIn() {
|
|
337
|
-
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
338
|
-
return new Promise((t, o) => {
|
|
339
|
-
const n = this.canvas.animate(
|
|
340
|
-
[
|
|
341
|
-
{ opacity: 0, transform: "scale(1.2)" },
|
|
342
|
-
{ opacity: 1, transform: "scale(1)" }
|
|
343
|
-
],
|
|
344
|
-
{ duration: 300, easing: "ease-out", fill: "forwards" }
|
|
345
|
-
);
|
|
346
|
-
n.onfinish = () => t(), n.oncancel = () => o("canceled");
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
fadeOut() {
|
|
350
|
-
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
351
|
-
return new Promise((t, o) => {
|
|
352
|
-
const n = this.canvas.animate(
|
|
353
|
-
[
|
|
354
|
-
{ opacity: 1, transform: "scale(1)" },
|
|
355
|
-
{ opacity: 0, transform: "scale(1.2)" }
|
|
356
|
-
],
|
|
357
|
-
{ duration: 300, easing: "ease-in", fill: "forwards" }
|
|
358
|
-
);
|
|
359
|
-
n.onfinish = () => t(), n.oncancel = () => o("canceled");
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
checkGLError(t, o) {
|
|
363
|
-
let n = t.getError();
|
|
364
|
-
if (n !== t.NO_ERROR) {
|
|
365
|
-
for (console.group(`🔴 WebGL Error in ${o}`); n !== t.NO_ERROR; ) {
|
|
366
|
-
const e = this.getGLErrorName(t, n);
|
|
367
|
-
console.error(`${e} (0x${n.toString(16)})`), n = t.getError();
|
|
368
|
-
}
|
|
369
|
-
console.groupEnd();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
getGLErrorName(t, o) {
|
|
373
|
-
switch (o) {
|
|
374
|
-
case t.INVALID_ENUM:
|
|
375
|
-
return "INVALID_ENUM";
|
|
376
|
-
case t.INVALID_VALUE:
|
|
377
|
-
return "INVALID_VALUE";
|
|
378
|
-
case t.INVALID_OPERATION:
|
|
379
|
-
return "INVALID_OPERATION";
|
|
380
|
-
case t.INVALID_FRAMEBUFFER_OPERATION:
|
|
381
|
-
return "INVALID_FRAMEBUFFER_OPERATION";
|
|
382
|
-
case t.OUT_OF_MEMORY:
|
|
383
|
-
return "OUT_OF_MEMORY";
|
|
384
|
-
case t.CONTEXT_LOST_WEBGL:
|
|
385
|
-
return "CONTEXT_LOST_WEBGL";
|
|
386
|
-
default:
|
|
387
|
-
return "UNKNOWN_ERROR";
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
setupGL() {
|
|
391
|
-
const t = this.canvas.getContext("webgl2", { antialias: !1, alpha: !0 });
|
|
392
|
-
if (!t)
|
|
393
|
-
throw new Error("WebGL2 is required but not available.");
|
|
394
|
-
const o = Y(t, $, X);
|
|
395
|
-
this.checkGLError(t, "setupGL: after createProgram");
|
|
396
|
-
const n = t.createVertexArray();
|
|
397
|
-
t.bindVertexArray(n), this.checkGLError(t, "setupGL: after VAO creation");
|
|
398
|
-
const e = this.canvas.width || 2, i = this.canvas.height || 2, { positions: v, uvs: y } = N(
|
|
399
|
-
e,
|
|
400
|
-
i,
|
|
401
|
-
this.options.borderWidth,
|
|
402
|
-
this.options.glowWidth
|
|
403
|
-
), l = t.createBuffer();
|
|
404
|
-
t.bindBuffer(t.ARRAY_BUFFER, l), t.bufferData(t.ARRAY_BUFFER, v, t.STATIC_DRAW);
|
|
405
|
-
const h = t.getAttribLocation(o, "aPosition");
|
|
406
|
-
t.enableVertexAttribArray(h), t.vertexAttribPointer(h, 2, t.FLOAT, !1, 0, 0), this.checkGLError(t, "setupGL: after position buffer setup");
|
|
407
|
-
const s = t.createBuffer();
|
|
408
|
-
t.bindBuffer(t.ARRAY_BUFFER, s), t.bufferData(t.ARRAY_BUFFER, y, t.STATIC_DRAW);
|
|
409
|
-
const d = t.getAttribLocation(o, "aUV");
|
|
410
|
-
t.enableVertexAttribArray(d), t.vertexAttribPointer(d, 2, t.FLOAT, !1, 0, 0), this.checkGLError(t, "setupGL: after UV buffer setup");
|
|
411
|
-
const E = t.getUniformLocation(o, "uResolution"), k = t.getUniformLocation(o, "uTime"), A = t.getUniformLocation(o, "uBorderWidth"), b = t.getUniformLocation(o, "uGlowWidth"), _ = t.getUniformLocation(o, "uBorderRadius"), x = t.getUniformLocation(o, "uColors"), P = t.getUniformLocation(o, "uGlowExponent"), C = t.getUniformLocation(o, "uGlowFactor");
|
|
412
|
-
t.useProgram(o), t.uniform1f(A, this.options.borderWidth), t.uniform1f(b, this.options.glowWidth), t.uniform1f(_, this.options.borderRadius), this.options.mode === "dark" ? (t.uniform1f(P, 2), t.uniform1f(C, 1.8)) : (t.uniform1f(P, 1), t.uniform1f(C, 1));
|
|
413
|
-
const c = (this.options.colors || q).map(j);
|
|
414
|
-
for (let a = 0; a < c.length; a++)
|
|
415
|
-
t.uniform3f(t.getUniformLocation(o, `uColors[${a}]`), ...c[a]);
|
|
416
|
-
this.checkGLError(t, "setupGL: after uniform setup"), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), this.glr = {
|
|
417
|
-
gl: t,
|
|
418
|
-
program: o,
|
|
419
|
-
vao: n,
|
|
420
|
-
positionBuffer: l,
|
|
421
|
-
uvBuffer: s,
|
|
422
|
-
uResolution: E,
|
|
423
|
-
uTime: k,
|
|
424
|
-
uBorderWidth: A,
|
|
425
|
-
uGlowWidth: b,
|
|
426
|
-
uBorderRadius: _,
|
|
427
|
-
uColors: x
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
render(t) {
|
|
431
|
-
if (!this.glr) return;
|
|
432
|
-
const { gl: o, program: n, vao: e, uTime: i } = this.glr;
|
|
433
|
-
o.useProgram(n), o.bindVertexArray(e), o.uniform1f(i, t), o.disable(o.DEPTH_TEST), o.disable(o.CULL_FACE), o.disable(o.BLEND), o.clearColor(0, 0, 0, 0), o.clear(o.COLOR_BUFFER_BIT), o.drawArrays(o.TRIANGLES, 0, 24), this.checkGLError(o, "render: after draw call"), o.bindVertexArray(null);
|
|
434
|
-
}
|
|
435
|
-
greet() {
|
|
436
|
-
console.log(
|
|
437
|
-
"%c🌈 ai-motion 0.4.8 🌈",
|
|
438
|
-
"background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;"
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
(function() {
|
|
443
|
-
try {
|
|
444
|
-
if (typeof document < "u") {
|
|
445
|
-
var r = document.createElement("style");
|
|
446
|
-
r.appendChild(document.createTextNode(`._wrapper_1ooyb_1 {
|
|
447
|
-
position: fixed;
|
|
448
|
-
inset: 0;
|
|
449
|
-
z-index: 2147483641; /* 确保在所有元素之上,除了 panel */
|
|
450
|
-
cursor: wait;
|
|
451
|
-
overflow: hidden;
|
|
452
|
-
|
|
453
|
-
display: none;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
._wrapper_1ooyb_1._visible_1ooyb_11 {
|
|
457
|
-
display: block;
|
|
458
|
-
}
|
|
459
|
-
/* AI 光标样式 */
|
|
460
|
-
._cursor_1dgwb_2 {
|
|
461
|
-
position: absolute;
|
|
462
|
-
width: var(--cursor-size, 75px);
|
|
463
|
-
height: var(--cursor-size, 75px);
|
|
464
|
-
pointer-events: none;
|
|
465
|
-
z-index: 10000;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
._cursorBorder_1dgwb_10 {
|
|
469
|
-
position: absolute;
|
|
470
|
-
width: 100%;
|
|
471
|
-
height: 100%;
|
|
472
|
-
background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));
|
|
473
|
-
mask-image: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");
|
|
474
|
-
mask-size: 100% 100%;
|
|
475
|
-
mask-repeat: no-repeat;
|
|
476
|
-
|
|
477
|
-
transform-origin: center;
|
|
478
|
-
transform: rotate(-135deg) scale(1.2);
|
|
479
|
-
margin-left: -10px;
|
|
480
|
-
margin-top: -18px;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
._cursorFilling_1dgwb_25 {
|
|
484
|
-
position: absolute;
|
|
485
|
-
width: 100%;
|
|
486
|
-
height: 100%;
|
|
487
|
-
background: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");
|
|
488
|
-
background-size: 100% 100%;
|
|
489
|
-
background-repeat: no-repeat;
|
|
490
|
-
|
|
491
|
-
transform-origin: center;
|
|
492
|
-
transform: rotate(-135deg) scale(1.2);
|
|
493
|
-
margin-left: -10px;
|
|
494
|
-
margin-top: -18px;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
._cursorRipple_1dgwb_39 {
|
|
498
|
-
position: absolute;
|
|
499
|
-
width: 100%;
|
|
500
|
-
height: 100%;
|
|
501
|
-
pointer-events: none;
|
|
502
|
-
margin-left: -50%;
|
|
503
|
-
margin-top: -50%;
|
|
504
|
-
|
|
505
|
-
&::after {
|
|
506
|
-
content: '';
|
|
507
|
-
opacity: 0;
|
|
508
|
-
position: absolute;
|
|
509
|
-
inset: 0;
|
|
510
|
-
border: 4px solid rgba(57, 182, 255, 1);
|
|
511
|
-
border-radius: 50%;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39::after {
|
|
516
|
-
animation: _cursor-ripple_1dgwb_1 300ms ease-out forwards;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
@keyframes _cursor-ripple_1dgwb_1 {
|
|
520
|
-
0% {
|
|
521
|
-
transform: scale(0);
|
|
522
|
-
opacity: 1;
|
|
523
|
-
}
|
|
524
|
-
100% {
|
|
525
|
-
transform: scale(2);
|
|
526
|
-
opacity: 0;
|
|
527
|
-
}
|
|
528
|
-
}`)), document.head.appendChild(r);
|
|
529
|
-
}
|
|
530
|
-
} catch (t) {
|
|
531
|
-
console.error("vite-plugin-css-injected-by-js", t);
|
|
532
|
-
}
|
|
533
|
-
})();
|
|
534
|
-
(function() {
|
|
535
|
-
try {
|
|
536
|
-
if (typeof document < "u") {
|
|
537
|
-
var r = document.createElement("style");
|
|
538
|
-
r.appendChild(document.createTextNode(`._wrapper_1ooyb_1 {
|
|
539
|
-
position: fixed;
|
|
540
|
-
inset: 0;
|
|
541
|
-
z-index: 2147483641; /* 确保在所有元素之上,除了 panel */
|
|
542
|
-
cursor: wait;
|
|
543
|
-
overflow: hidden;
|
|
544
|
-
|
|
545
|
-
display: none;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
._wrapper_1ooyb_1._visible_1ooyb_11 {
|
|
549
|
-
display: block;
|
|
550
|
-
}
|
|
551
|
-
/* AI 光标样式 */
|
|
552
|
-
._cursor_1dgwb_2 {
|
|
553
|
-
position: absolute;
|
|
554
|
-
width: var(--cursor-size, 75px);
|
|
555
|
-
height: var(--cursor-size, 75px);
|
|
556
|
-
pointer-events: none;
|
|
557
|
-
z-index: 10000;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
._cursorBorder_1dgwb_10 {
|
|
561
|
-
position: absolute;
|
|
562
|
-
width: 100%;
|
|
563
|
-
height: 100%;
|
|
564
|
-
background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));
|
|
565
|
-
mask-image: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");
|
|
566
|
-
mask-size: 100% 100%;
|
|
567
|
-
mask-repeat: no-repeat;
|
|
568
|
-
|
|
569
|
-
transform-origin: center;
|
|
570
|
-
transform: rotate(-135deg) scale(1.2);
|
|
571
|
-
margin-left: -10px;
|
|
572
|
-
margin-top: -18px;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
._cursorFilling_1dgwb_25 {
|
|
576
|
-
position: absolute;
|
|
577
|
-
width: 100%;
|
|
578
|
-
height: 100%;
|
|
579
|
-
background: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");
|
|
580
|
-
background-size: 100% 100%;
|
|
581
|
-
background-repeat: no-repeat;
|
|
582
|
-
|
|
583
|
-
transform-origin: center;
|
|
584
|
-
transform: rotate(-135deg) scale(1.2);
|
|
585
|
-
margin-left: -10px;
|
|
586
|
-
margin-top: -18px;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
._cursorRipple_1dgwb_39 {
|
|
590
|
-
position: absolute;
|
|
591
|
-
width: 100%;
|
|
592
|
-
height: 100%;
|
|
593
|
-
pointer-events: none;
|
|
594
|
-
margin-left: -50%;
|
|
595
|
-
margin-top: -50%;
|
|
596
|
-
|
|
597
|
-
&::after {
|
|
598
|
-
content: '';
|
|
599
|
-
opacity: 0;
|
|
600
|
-
position: absolute;
|
|
601
|
-
inset: 0;
|
|
602
|
-
border: 4px solid rgba(57, 182, 255, 1);
|
|
603
|
-
border-radius: 50%;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39::after {
|
|
608
|
-
animation: _cursor-ripple_1dgwb_1 300ms ease-out forwards;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
@keyframes _cursor-ripple_1dgwb_1 {
|
|
612
|
-
0% {
|
|
613
|
-
transform: scale(0);
|
|
614
|
-
opacity: 1;
|
|
615
|
-
}
|
|
616
|
-
100% {
|
|
617
|
-
transform: scale(2);
|
|
618
|
-
opacity: 0;
|
|
619
|
-
}
|
|
620
|
-
}`)), document.head.appendChild(r);
|
|
621
|
-
}
|
|
622
|
-
} catch (t) {
|
|
623
|
-
console.error("vite-plugin-css-injected-by-js", t);
|
|
624
|
-
}
|
|
625
|
-
})();
|
|
626
|
-
function Z() {
|
|
627
|
-
try {
|
|
628
|
-
return !!(K() || J() || tt() || et() || rt() || ot());
|
|
629
|
-
} catch (r) {
|
|
630
|
-
return console.warn("Error determining if page is dark:", r), !1;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
function K() {
|
|
634
|
-
const r = [
|
|
635
|
-
"dark",
|
|
636
|
-
"dark-mode",
|
|
637
|
-
"theme-dark",
|
|
638
|
-
"night",
|
|
639
|
-
"night-mode"
|
|
640
|
-
], t = document.documentElement, o = document.body || document.documentElement;
|
|
641
|
-
for (const n of r) if (t.classList.contains(n) || o?.classList.contains(n)) return !0;
|
|
642
|
-
return !1;
|
|
643
|
-
}
|
|
644
|
-
function J() {
|
|
645
|
-
const r = document.documentElement, t = document.body || document.documentElement;
|
|
646
|
-
for (const o of [
|
|
647
|
-
"data-theme",
|
|
648
|
-
"data-color-mode",
|
|
649
|
-
"data-bs-theme",
|
|
650
|
-
"data-mui-color-scheme"
|
|
651
|
-
]) {
|
|
652
|
-
const n = t?.getAttribute(o), e = r.getAttribute(o);
|
|
653
|
-
if (n?.toLowerCase() === "dark" || e?.toLowerCase() === "dark") return !0;
|
|
654
|
-
}
|
|
655
|
-
return !1;
|
|
656
|
-
}
|
|
657
|
-
function tt() {
|
|
658
|
-
const r = document.querySelector('meta[name="color-scheme"]')?.content.toLowerCase();
|
|
659
|
-
if (r === "dark" || r === "only dark") return !0;
|
|
660
|
-
const t = window.getComputedStyle(document.documentElement).getPropertyValue("color-scheme").trim().toLowerCase();
|
|
661
|
-
return t === "dark" || t === "only dark";
|
|
662
|
-
}
|
|
663
|
-
function et() {
|
|
664
|
-
const r = window.getComputedStyle(document.documentElement), t = window.getComputedStyle(document.body || document.documentElement), o = r.backgroundColor, n = t.backgroundColor;
|
|
665
|
-
return O(n) ? !0 : n === "transparent" || n.startsWith("rgba(0, 0, 0, 0)") ? O(o) : !1;
|
|
666
|
-
}
|
|
667
|
-
function ot() {
|
|
668
|
-
const t = W(window.getComputedStyle(document.body || document.documentElement).color);
|
|
669
|
-
return t !== null && t > 200;
|
|
670
|
-
}
|
|
671
|
-
function rt() {
|
|
672
|
-
const { innerWidth: r, innerHeight: t } = window, o = r * t * 0.5;
|
|
673
|
-
for (const n of [
|
|
674
|
-
"#app",
|
|
675
|
-
"#root",
|
|
676
|
-
"#__next"
|
|
677
|
-
]) {
|
|
678
|
-
const e = document.querySelector(n);
|
|
679
|
-
if (!e) continue;
|
|
680
|
-
const i = e.getBoundingClientRect();
|
|
681
|
-
if (!(i.width * i.height < o) && O(window.getComputedStyle(e).backgroundColor))
|
|
682
|
-
return !0;
|
|
683
|
-
}
|
|
684
|
-
return !1;
|
|
685
|
-
}
|
|
686
|
-
function nt(r) {
|
|
687
|
-
const t = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(r);
|
|
688
|
-
return t ? {
|
|
689
|
-
r: parseInt(t[1]),
|
|
690
|
-
g: parseInt(t[2]),
|
|
691
|
-
b: parseInt(t[3])
|
|
692
|
-
} : null;
|
|
693
|
-
}
|
|
694
|
-
function W(r) {
|
|
695
|
-
if (!r || r === "transparent" || r.startsWith("rgba(0, 0, 0, 0)")) return null;
|
|
696
|
-
const t = nt(r);
|
|
697
|
-
return t ? 0.299 * t.r + 0.587 * t.g + 0.114 * t.b : null;
|
|
698
|
-
}
|
|
699
|
-
function O(r, t = 128) {
|
|
700
|
-
const o = W(r);
|
|
701
|
-
return o !== null && o < t;
|
|
702
|
-
}
|
|
703
|
-
var D = {
|
|
704
|
-
wrapper: "_wrapper_1ooyb_1",
|
|
705
|
-
visible: "_visible_1ooyb_11"
|
|
706
|
-
}, L = {
|
|
707
|
-
cursor: "_cursor_1dgwb_2",
|
|
708
|
-
cursorBorder: "_cursorBorder_1dgwb_10",
|
|
709
|
-
cursorFilling: "_cursorFilling_1dgwb_25",
|
|
710
|
-
cursorRipple: "_cursorRipple_1dgwb_39",
|
|
711
|
-
clicking: "_clicking_1dgwb_57"
|
|
712
|
-
}, it = class extends EventTarget {
|
|
713
|
-
shown = !1;
|
|
714
|
-
wrapper = document.createElement("div");
|
|
715
|
-
motion = null;
|
|
716
|
-
#r = !1;
|
|
717
|
-
#t = document.createElement("div");
|
|
718
|
-
#e = 0;
|
|
719
|
-
#o = 0;
|
|
720
|
-
#n = 0;
|
|
721
|
-
#i = 0;
|
|
722
|
-
constructor() {
|
|
723
|
-
super(), this.wrapper.id = "page-agent-runtime_simulator-mask", this.wrapper.className = D.wrapper, this.wrapper.setAttribute("data-browser-use-ignore", "true"), this.wrapper.setAttribute("data-page-agent-ignore", "true");
|
|
724
|
-
try {
|
|
725
|
-
const e = new H({
|
|
726
|
-
mode: Z() ? "dark" : "light",
|
|
727
|
-
styles: {
|
|
728
|
-
position: "absolute",
|
|
729
|
-
inset: "0"
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
this.motion = e, this.wrapper.appendChild(e.element), e.autoResize(this.wrapper);
|
|
733
|
-
} catch (e) {
|
|
734
|
-
console.warn("[SimulatorMask] Motion overlay unavailable:", e);
|
|
735
|
-
}
|
|
736
|
-
this.wrapper.addEventListener("click", (e) => {
|
|
737
|
-
e.stopPropagation(), e.preventDefault();
|
|
738
|
-
}), this.wrapper.addEventListener("mousedown", (e) => {
|
|
739
|
-
e.stopPropagation(), e.preventDefault();
|
|
740
|
-
}), this.wrapper.addEventListener("mouseup", (e) => {
|
|
741
|
-
e.stopPropagation(), e.preventDefault();
|
|
742
|
-
}), this.wrapper.addEventListener("mousemove", (e) => {
|
|
743
|
-
e.stopPropagation(), e.preventDefault();
|
|
744
|
-
}), this.wrapper.addEventListener("wheel", (e) => {
|
|
745
|
-
e.stopPropagation(), e.preventDefault();
|
|
746
|
-
}), this.wrapper.addEventListener("keydown", (e) => {
|
|
747
|
-
e.stopPropagation(), e.preventDefault();
|
|
748
|
-
}), this.wrapper.addEventListener("keyup", (e) => {
|
|
749
|
-
e.stopPropagation(), e.preventDefault();
|
|
750
|
-
}), this.#a(), document.body.appendChild(this.wrapper), this.#s();
|
|
751
|
-
const r = (e) => {
|
|
752
|
-
const { x: i, y: v } = e.detail;
|
|
753
|
-
this.setCursorPosition(i, v);
|
|
754
|
-
}, t = () => {
|
|
755
|
-
this.triggerClickAnimation();
|
|
756
|
-
}, o = () => {
|
|
757
|
-
this.wrapper.style.pointerEvents = "none";
|
|
758
|
-
}, n = () => {
|
|
759
|
-
this.wrapper.style.pointerEvents = "auto";
|
|
760
|
-
};
|
|
761
|
-
window.addEventListener("PageAgent::MovePointerTo", r), window.addEventListener("PageAgent::ClickPointer", t), window.addEventListener("PageAgent::EnablePassThrough", o), window.addEventListener("PageAgent::DisablePassThrough", n), this.addEventListener("dispose", () => {
|
|
762
|
-
window.removeEventListener("PageAgent::MovePointerTo", r), window.removeEventListener("PageAgent::ClickPointer", t), window.removeEventListener("PageAgent::EnablePassThrough", o), window.removeEventListener("PageAgent::DisablePassThrough", n);
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
#a() {
|
|
766
|
-
this.#t.className = L.cursor;
|
|
767
|
-
const r = document.createElement("div");
|
|
768
|
-
r.className = L.cursorRipple, this.#t.appendChild(r);
|
|
769
|
-
const t = document.createElement("div");
|
|
770
|
-
t.className = L.cursorFilling, this.#t.appendChild(t);
|
|
771
|
-
const o = document.createElement("div");
|
|
772
|
-
o.className = L.cursorBorder, this.#t.appendChild(o), this.wrapper.appendChild(this.#t);
|
|
773
|
-
}
|
|
774
|
-
#s() {
|
|
775
|
-
if (this.#r) return;
|
|
776
|
-
const r = this.#e + (this.#n - this.#e) * 0.2, t = this.#o + (this.#i - this.#o) * 0.2, o = Math.abs(r - this.#n);
|
|
777
|
-
o > 0 && (o < 2 ? this.#e = this.#n : this.#e = r, this.#t.style.left = `${this.#e}px`);
|
|
778
|
-
const n = Math.abs(t - this.#i);
|
|
779
|
-
n > 0 && (n < 2 ? this.#o = this.#i : this.#o = t, this.#t.style.top = `${this.#o}px`), requestAnimationFrame(() => this.#s());
|
|
780
|
-
}
|
|
781
|
-
setCursorPosition(r, t) {
|
|
782
|
-
this.#r || (this.#n = r, this.#i = t);
|
|
783
|
-
}
|
|
784
|
-
triggerClickAnimation() {
|
|
785
|
-
this.#r || (this.#t.classList.remove(L.clicking), this.#t.offsetHeight, this.#t.classList.add(L.clicking));
|
|
786
|
-
}
|
|
787
|
-
show() {
|
|
788
|
-
this.shown || this.#r || (this.shown = !0, this.motion?.start(), this.motion?.fadeIn(), this.wrapper.classList.add(D.visible), this.#e = window.innerWidth / 2, this.#o = window.innerHeight / 2, this.#n = this.#e, this.#i = this.#o, this.#t.style.left = `${this.#e}px`, this.#t.style.top = `${this.#o}px`);
|
|
789
|
-
}
|
|
790
|
-
hide() {
|
|
791
|
-
!this.shown || this.#r || (this.shown = !1, this.motion?.fadeOut(), this.motion?.pause(), this.#t.classList.remove(L.clicking), setTimeout(() => {
|
|
792
|
-
this.wrapper.classList.remove(D.visible);
|
|
793
|
-
}, 800));
|
|
794
|
-
}
|
|
795
|
-
dispose() {
|
|
796
|
-
this.#r = !0, this.motion?.dispose(), this.wrapper.remove(), this.dispatchEvent(new Event("dispose"));
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
export {
|
|
800
|
-
it as SimulatorMask
|
|
801
|
-
};
|