@vobs/captcha 1.2.1 → 1.3.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/dist/index.cjs +154 -717
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -637
- package/dist/index.js.map +1 -1
- package/dist/slider.cjs +152 -716
- package/dist/slider.cjs.map +1 -1
- package/dist/slider.js +100 -667
- package/dist/slider.js.map +1 -1
- package/package.json +2 -2
package/dist/slider.cjs
CHANGED
|
@@ -1,643 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __VOBS_CJS_FILE_URL = require("url").pathToFileURL(__filename).href;
|
|
2
|
+
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var signalNames = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
function hasDebugHooks() {
|
|
10
|
-
return activeDebugHooks !== null;
|
|
11
|
-
}
|
|
12
|
-
__name(hasDebugHooks, "hasDebugHooks");
|
|
13
|
-
function setSignalDebugName(signal, name) {
|
|
14
|
-
signalNames.set(signal, name);
|
|
15
|
-
invokeDebug("signalNamed", signal, name);
|
|
16
|
-
}
|
|
17
|
-
__name(setSignalDebugName, "setSignalDebugName");
|
|
18
|
-
function invokeDebug(name, ...args) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
__name(invokeDebug, "invokeDebug");
|
|
22
|
-
|
|
23
|
-
// packages/reactivity/src/owner.ts
|
|
24
|
-
var currentOwner = null;
|
|
25
|
-
var nextOwnerId = 1;
|
|
26
|
-
var ownerNames = /* @__PURE__ */ new WeakMap();
|
|
27
|
-
function createOwner() {
|
|
28
|
-
const parent = currentOwner;
|
|
29
|
-
let disposed = parent?.disposed ?? false;
|
|
30
|
-
const children = [];
|
|
31
|
-
const cleanups = [];
|
|
32
|
-
const errorHandlers = /* @__PURE__ */ new Set();
|
|
33
|
-
const owner = {
|
|
34
|
-
id: `owner-${nextOwnerId++}`,
|
|
35
|
-
parent,
|
|
36
|
-
children,
|
|
37
|
-
depth: (parent?.depth ?? -1) + 1,
|
|
38
|
-
get disposed() {
|
|
39
|
-
return disposed;
|
|
40
|
-
},
|
|
41
|
-
run(fn) {
|
|
42
|
-
if (disposed) throw new Error("Vobs: \u5DF2\u9500\u6BC1\u7684 Owner \u4E0D\u80FD\u7EE7\u7EED\u8FD0\u884C");
|
|
43
|
-
const previous = currentOwner;
|
|
44
|
-
currentOwner = owner;
|
|
45
|
-
try {
|
|
46
|
-
return fn();
|
|
47
|
-
} finally {
|
|
48
|
-
currentOwner = previous;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
addCleanup(cleanup) {
|
|
52
|
-
if (disposed) {
|
|
53
|
-
cleanup();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
cleanups.push(cleanup);
|
|
57
|
-
},
|
|
58
|
-
onDispose(cleanup) {
|
|
59
|
-
owner.addCleanup(cleanup);
|
|
60
|
-
},
|
|
61
|
-
onError(handler) {
|
|
62
|
-
errorHandlers.add(handler);
|
|
63
|
-
const remove = /* @__PURE__ */ __name(() => errorHandlers.delete(handler), "remove");
|
|
64
|
-
owner.addCleanup(remove);
|
|
65
|
-
return remove;
|
|
66
|
-
},
|
|
67
|
-
handleError(error) {
|
|
68
|
-
for (const handler of [...errorHandlers].reverse()) {
|
|
69
|
-
try {
|
|
70
|
-
handler(error);
|
|
71
|
-
return true;
|
|
72
|
-
} catch (handlerError) {
|
|
73
|
-
return parent?.handleError(handlerError) ?? false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return parent?.handleError(error) ?? false;
|
|
77
|
-
},
|
|
78
|
-
dispose() {
|
|
79
|
-
if (disposed) return;
|
|
80
|
-
disposed = true;
|
|
81
|
-
for (const child of [...children]) child.dispose();
|
|
82
|
-
children.length = 0;
|
|
83
|
-
let firstError;
|
|
84
|
-
for (let index = cleanups.length - 1; index >= 0; index--) {
|
|
85
|
-
try {
|
|
86
|
-
cleanups[index]();
|
|
87
|
-
} catch (error) {
|
|
88
|
-
firstError ?? (firstError = error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
cleanups.length = 0;
|
|
92
|
-
if (parent) {
|
|
93
|
-
const index = parent.children.indexOf(owner);
|
|
94
|
-
if (index >= 0) parent.children.splice(index, 1);
|
|
95
|
-
}
|
|
96
|
-
if (firstError) throw firstError;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
if (parent && !parent.disposed) parent.children.push(owner);
|
|
100
|
-
return owner;
|
|
101
|
-
}
|
|
102
|
-
__name(createOwner, "createOwner");
|
|
103
|
-
function setOwnerDebugName(owner, name) {
|
|
104
|
-
ownerNames.set(owner, name);
|
|
105
|
-
}
|
|
106
|
-
__name(setOwnerDebugName, "setOwnerDebugName");
|
|
107
|
-
function getCurrentOwner() {
|
|
108
|
-
return currentOwner;
|
|
109
|
-
}
|
|
110
|
-
__name(getCurrentOwner, "getCurrentOwner");
|
|
111
|
-
function onDispose(cleanup) {
|
|
112
|
-
const owner = getCurrentOwner();
|
|
113
|
-
if (!owner) throw new Error("Vobs: onDispose \u5FC5\u987B\u5728 Owner \u4F5C\u7528\u57DF\u5185\u8C03\u7528");
|
|
114
|
-
owner.onDispose(cleanup);
|
|
115
|
-
}
|
|
116
|
-
__name(onDispose, "onDispose");
|
|
117
|
-
|
|
118
|
-
// packages/reactivity/src/signal.ts
|
|
119
|
-
var currentSubscriber = null;
|
|
120
|
-
function getCurrentSubscriber() {
|
|
121
|
-
return currentSubscriber;
|
|
122
|
-
}
|
|
123
|
-
__name(getCurrentSubscriber, "getCurrentSubscriber");
|
|
124
|
-
function setCurrentSubscriber(subscriber) {
|
|
125
|
-
currentSubscriber = subscriber;
|
|
126
|
-
}
|
|
127
|
-
__name(setCurrentSubscriber, "setCurrentSubscriber");
|
|
128
|
-
function trackDependency(dependency) {
|
|
129
|
-
if (!currentSubscriber || currentSubscriber.disposed) return;
|
|
130
|
-
!currentSubscriber.dependencies.has(dependency);
|
|
131
|
-
currentSubscriber.dependencies.add(dependency);
|
|
132
|
-
}
|
|
133
|
-
__name(trackDependency, "trackDependency");
|
|
134
|
-
function state(initialValue, debugName) {
|
|
135
|
-
let value = initialValue;
|
|
136
|
-
let disposed = false;
|
|
137
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
138
|
-
const signalInstance = {
|
|
139
|
-
get value() {
|
|
140
|
-
const subscriber = getCurrentSubscriber();
|
|
141
|
-
if (subscriber && !subscriber.disposed) {
|
|
142
|
-
subscribers.add(subscriber);
|
|
143
|
-
trackDependency(signalInstance);
|
|
144
|
-
}
|
|
145
|
-
return value;
|
|
146
|
-
},
|
|
147
|
-
set value(nextValue) {
|
|
148
|
-
if (disposed || Object.is(value, nextValue)) return;
|
|
149
|
-
value = nextValue;
|
|
150
|
-
for (const subscriber of [...subscribers]) subscriber.notify();
|
|
151
|
-
},
|
|
152
|
-
unsubscribe(subscriber) {
|
|
153
|
-
subscribers.delete(subscriber);
|
|
154
|
-
},
|
|
155
|
-
// 与 `.value =` 赋值同一条路径:判等短路、debug hook、notify 全部一致。
|
|
156
|
-
// 以闭包实现,可安全地作为回调直接传递(无 this 绑定问题)。
|
|
157
|
-
set(next) {
|
|
158
|
-
signalInstance.value = next;
|
|
159
|
-
},
|
|
160
|
-
dispose() {
|
|
161
|
-
if (disposed) return;
|
|
162
|
-
disposed = true;
|
|
163
|
-
subscribers.clear();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const owner = getCurrentOwner();
|
|
167
|
-
owner?.addCleanup(signalInstance.dispose);
|
|
168
|
-
if (debugName?.trim()) setSignalDebugName(signalInstance, debugName.trim());
|
|
169
|
-
return signalInstance;
|
|
170
|
-
}
|
|
171
|
-
__name(state, "state");
|
|
172
|
-
|
|
173
|
-
// packages/reactivity/src/scheduler.ts
|
|
174
|
-
var _Scheduler = class _Scheduler {
|
|
175
|
-
constructor() {
|
|
176
|
-
this.dirtyEffects = /* @__PURE__ */ new Set();
|
|
177
|
-
this.lowPriorityEffects = /* @__PURE__ */ new Set();
|
|
178
|
-
// flush 不可重入(flushing 标志保证),缓冲数组可在轮次间安全复用,避免每轮分配。
|
|
179
|
-
this.normalBuffer = [];
|
|
180
|
-
this.lowBuffer = [];
|
|
181
|
-
this.flushing = false;
|
|
182
|
-
this.scheduled = false;
|
|
183
|
-
this.batchDepth = 0;
|
|
184
|
-
}
|
|
185
|
-
schedule(effect2) {
|
|
186
|
-
if (effect2.disposed) return;
|
|
187
|
-
this.dirtyEffects.add(effect2);
|
|
188
|
-
this.lowPriorityEffects.delete(effect2);
|
|
189
|
-
this.ensureScheduled();
|
|
190
|
-
}
|
|
191
|
-
/** Queue an effect behind normal updates while preserving deterministic order. */
|
|
192
|
-
scheduleLow(effect2) {
|
|
193
|
-
if (effect2.disposed) return;
|
|
194
|
-
if (!this.dirtyEffects.has(effect2)) this.lowPriorityEffects.add(effect2);
|
|
195
|
-
this.ensureScheduled();
|
|
196
|
-
}
|
|
197
|
-
ensureScheduled() {
|
|
198
|
-
if (this.batchDepth === 0 && !this.flushing && !this.scheduled) {
|
|
199
|
-
this.scheduled = true;
|
|
200
|
-
queueMicrotask(() => {
|
|
201
|
-
this.scheduled = false;
|
|
202
|
-
this.flush();
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
remove(effect2) {
|
|
207
|
-
this.dirtyEffects.delete(effect2);
|
|
208
|
-
this.lowPriorityEffects.delete(effect2);
|
|
209
|
-
}
|
|
210
|
-
batch(fn) {
|
|
211
|
-
this.batchDepth++;
|
|
212
|
-
try {
|
|
213
|
-
return fn();
|
|
214
|
-
} finally {
|
|
215
|
-
this.batchDepth--;
|
|
216
|
-
if (this.batchDepth === 0) this.flush();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
flush() {
|
|
220
|
-
if (this.flushing || this.batchDepth > 0) return;
|
|
221
|
-
this.flushing = true;
|
|
222
|
-
let rounds = 0;
|
|
223
|
-
let firstError;
|
|
224
|
-
let hasError = false;
|
|
225
|
-
try {
|
|
226
|
-
while (this.dirtyEffects.size > 0 || this.lowPriorityEffects.size > 0) {
|
|
227
|
-
if (++rounds > 100) {
|
|
228
|
-
this.dirtyEffects.clear();
|
|
229
|
-
this.lowPriorityEffects.clear();
|
|
230
|
-
throw new Error("Vobs: \u54CD\u5E94\u5F0F\u66F4\u65B0\u8D85\u8FC7 100 \u8F6E\uFF0C\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56");
|
|
231
|
-
}
|
|
232
|
-
this.collectRunnable(this.dirtyEffects, this.normalBuffer);
|
|
233
|
-
this.collectRunnable(this.lowPriorityEffects, this.lowBuffer);
|
|
234
|
-
sortEffects(this.normalBuffer);
|
|
235
|
-
sortEffects(this.lowBuffer);
|
|
236
|
-
for (const effect2 of this.normalBuffer) {
|
|
237
|
-
try {
|
|
238
|
-
effect2.run();
|
|
239
|
-
} catch (error) {
|
|
240
|
-
if (!hasError) {
|
|
241
|
-
firstError = error;
|
|
242
|
-
hasError = true;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
for (const effect2 of this.lowBuffer) {
|
|
247
|
-
try {
|
|
248
|
-
effect2.run();
|
|
249
|
-
} catch (error) {
|
|
250
|
-
if (!hasError) {
|
|
251
|
-
firstError = error;
|
|
252
|
-
hasError = true;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
this.normalBuffer.length = 0;
|
|
257
|
-
this.lowBuffer.length = 0;
|
|
258
|
-
}
|
|
259
|
-
} finally {
|
|
260
|
-
this.normalBuffer.length = 0;
|
|
261
|
-
this.lowBuffer.length = 0;
|
|
262
|
-
this.flushing = false;
|
|
263
|
-
}
|
|
264
|
-
if (hasError) throw firstError;
|
|
265
|
-
}
|
|
266
|
-
/** 收集未 disposed 的 effect 并清空源集合;run() 期间新调度的 effect 留给下一轮。 */
|
|
267
|
-
collectRunnable(source, target) {
|
|
268
|
-
for (const effect2 of source) {
|
|
269
|
-
if (!effect2.disposed) target.push(effect2);
|
|
270
|
-
}
|
|
271
|
-
source.clear();
|
|
272
|
-
}
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
273
11
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
__name(sortEffects, "sortEffects");
|
|
282
|
-
var scheduler = new Scheduler();
|
|
283
|
-
|
|
284
|
-
// packages/reactivity/src/effect.ts
|
|
285
|
-
var nextEffectOrder = 1;
|
|
286
|
-
function cleanupDependencies(subscriber) {
|
|
287
|
-
for (const dependency of subscriber.dependencies) {
|
|
288
|
-
dependency.unsubscribe(subscriber);
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
289
17
|
}
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function effect(callback) {
|
|
294
|
-
const owner = getCurrentOwner();
|
|
295
|
-
let cleanup;
|
|
296
|
-
let dirty = true;
|
|
297
|
-
let disposed = false;
|
|
298
|
-
const eff = {
|
|
299
|
-
order: nextEffectOrder++,
|
|
300
|
-
depth: owner?.depth ?? 0,
|
|
301
|
-
dependencies: /* @__PURE__ */ new Set(),
|
|
302
|
-
get disposed() {
|
|
303
|
-
return disposed;
|
|
304
|
-
},
|
|
305
|
-
notify() {
|
|
306
|
-
if (disposed || dirty) return;
|
|
307
|
-
dirty = true;
|
|
308
|
-
scheduler.schedule(eff);
|
|
309
|
-
},
|
|
310
|
-
run() {
|
|
311
|
-
if (disposed || !dirty) return;
|
|
312
|
-
dirty = false;
|
|
313
|
-
const previousCleanup = cleanup;
|
|
314
|
-
cleanup = void 0;
|
|
315
|
-
let cleanupError;
|
|
316
|
-
if (previousCleanup) {
|
|
317
|
-
try {
|
|
318
|
-
previousCleanup();
|
|
319
|
-
} catch (error) {
|
|
320
|
-
const handled2 = owner?.handleError(error) ?? false;
|
|
321
|
-
if (!handled2) cleanupError = error;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
cleanupDependencies(eff);
|
|
325
|
-
const previous = getCurrentSubscriber();
|
|
326
|
-
setCurrentSubscriber(eff);
|
|
327
|
-
let thrown;
|
|
328
|
-
let handled = false;
|
|
329
|
-
try {
|
|
330
|
-
const result = owner ? owner.run(callback) : callback();
|
|
331
|
-
cleanup = typeof result === "function" ? result : void 0;
|
|
332
|
-
} catch (error) {
|
|
333
|
-
thrown = error;
|
|
334
|
-
handled = owner?.handleError(error) ?? false;
|
|
335
|
-
if (!handled) throw error;
|
|
336
|
-
} finally {
|
|
337
|
-
setCurrentSubscriber(previous);
|
|
338
|
-
}
|
|
339
|
-
if (cleanupError && !thrown) throw cleanupError;
|
|
340
|
-
},
|
|
341
|
-
scheduleLow() {
|
|
342
|
-
if (disposed || dirty) return;
|
|
343
|
-
dirty = true;
|
|
344
|
-
scheduler.scheduleLow(eff);
|
|
345
|
-
},
|
|
346
|
-
dispose() {
|
|
347
|
-
if (disposed) return;
|
|
348
|
-
disposed = true;
|
|
349
|
-
dirty = false;
|
|
350
|
-
scheduler.remove(eff);
|
|
351
|
-
const previousCleanup = cleanup;
|
|
352
|
-
cleanup = void 0;
|
|
353
|
-
let cleanupError;
|
|
354
|
-
if (previousCleanup) {
|
|
355
|
-
try {
|
|
356
|
-
previousCleanup();
|
|
357
|
-
} catch (error) {
|
|
358
|
-
const handled = owner?.handleError(error) ?? false;
|
|
359
|
-
if (!handled) cleanupError = error;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
cleanupDependencies(eff);
|
|
363
|
-
if (cleanupError) throw cleanupError;
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
owner?.addCleanup(eff.dispose);
|
|
367
|
-
eff.run();
|
|
368
|
-
return eff;
|
|
369
|
-
}
|
|
370
|
-
__name(effect, "effect");
|
|
371
|
-
|
|
372
|
-
// packages/runtime/src/debug.ts
|
|
373
|
-
var activeRuntimeDebugHooks = null;
|
|
374
|
-
function getRuntimeDebugHooks() {
|
|
375
|
-
return activeRuntimeDebugHooks;
|
|
376
|
-
}
|
|
377
|
-
__name(getRuntimeDebugHooks, "getRuntimeDebugHooks");
|
|
378
|
-
function invokeRuntimeDebug(name, ...args) {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
__name(invokeRuntimeDebug, "invokeRuntimeDebug");
|
|
382
|
-
function readDebugValue(read) {
|
|
383
|
-
try {
|
|
384
|
-
return read();
|
|
385
|
-
} catch {
|
|
386
|
-
return "[Uninspectable]";
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
__name(readDebugValue, "readDebugValue");
|
|
390
|
-
function describeDebugNode(node) {
|
|
391
|
-
if (!node || typeof node !== "object") return "node";
|
|
392
|
-
const value = node;
|
|
393
|
-
const name = typeof value.tagName === "string" ? value.tagName.toLowerCase() : typeof value.nodeName === "string" ? value.nodeName.toLowerCase() : "node";
|
|
394
|
-
const id = typeof value.id === "string" && value.id ? `#${value.id}` : "";
|
|
395
|
-
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().split(/\s+/).filter(Boolean).join(".")}` : "";
|
|
396
|
-
return `${name}${id}${className}`;
|
|
397
|
-
}
|
|
398
|
-
__name(describeDebugNode, "describeDebugNode");
|
|
399
|
-
|
|
400
|
-
// packages/runtime/src/hmr.ts
|
|
401
|
-
var globalTarget = globalThis;
|
|
402
|
-
var hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: /* @__PURE__ */ new Map() };
|
|
403
|
-
globalTarget.__VOBS_HMR__ = hmrGlobal;
|
|
404
|
-
function markHmrInstanceMounted(node, parent) {
|
|
405
|
-
const instance = hmrInstances.get(node);
|
|
406
|
-
if (instance) instance.parent = parent;
|
|
407
|
-
}
|
|
408
|
-
__name(markHmrInstanceMounted, "markHmrInstanceMounted");
|
|
409
|
-
var hmrInstances = /* @__PURE__ */ new WeakMap();
|
|
410
|
-
var nodeOwners = /* @__PURE__ */ new WeakMap();
|
|
411
|
-
var eventBindings = /* @__PURE__ */ new WeakMap();
|
|
412
|
-
function getRenderer() {
|
|
413
|
-
{
|
|
414
|
-
throw new Error("\u6E32\u67D3\u5668\u672A\u521D\u59CB\u5316");
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
__name(getRenderer, "getRenderer");
|
|
418
|
-
function createText(content) {
|
|
419
|
-
return getRenderer().createText(content);
|
|
420
|
-
}
|
|
421
|
-
__name(createText, "createText");
|
|
422
|
-
function createElement(tag) {
|
|
423
|
-
return getRenderer().createElement(tag);
|
|
424
|
-
}
|
|
425
|
-
__name(createElement, "createElement");
|
|
426
|
-
function createComment(content) {
|
|
427
|
-
return getRenderer().createComment(content);
|
|
428
|
-
}
|
|
429
|
-
__name(createComment, "createComment");
|
|
430
|
-
function insertBefore(parent, child, anchor) {
|
|
431
|
-
if (isVobsFragment(child)) {
|
|
432
|
-
child.mount(parent, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
getRenderer().insertBefore(parent, child, isVobsFragment(anchor) ? anchor.start : anchor);
|
|
436
|
-
markHmrInstanceMounted(child, parent);
|
|
437
|
-
}
|
|
438
|
-
__name(insertBefore, "insertBefore");
|
|
439
|
-
function removeChild(parent, child) {
|
|
440
|
-
disposeNodeOwner(child);
|
|
441
|
-
if (isVobsFragment(child)) {
|
|
442
|
-
child.unmount(parent);
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
getRenderer().removeChild(parent, child);
|
|
446
|
-
}
|
|
447
|
-
__name(removeChild, "removeChild");
|
|
448
|
-
function setProperty(node, key, value) {
|
|
449
|
-
getRenderer().setProperty(node, key, value);
|
|
450
|
-
}
|
|
451
|
-
__name(setProperty, "setProperty");
|
|
452
|
-
function setAttribute(node, key, value) {
|
|
453
|
-
getRenderer().setAttribute(node, key, value);
|
|
454
|
-
}
|
|
455
|
-
__name(setAttribute, "setAttribute");
|
|
456
|
-
function addEventListener(node, event, handler) {
|
|
457
|
-
const renderer = getRenderer();
|
|
458
|
-
const owner = getCurrentOwner();
|
|
459
|
-
let bindings = eventBindings.get(node);
|
|
460
|
-
if (!bindings) {
|
|
461
|
-
bindings = /* @__PURE__ */ new Map();
|
|
462
|
-
eventBindings.set(node, bindings);
|
|
463
|
-
}
|
|
464
|
-
const previous = bindings.get(event);
|
|
465
|
-
if (previous && previous.original === handler && previous.owner === owner) return;
|
|
466
|
-
if (previous) renderer.removeEventListener(node, event, previous.handler);
|
|
467
|
-
const listener = owner ? (reason) => {
|
|
468
|
-
try {
|
|
469
|
-
owner.run(() => handler(reason));
|
|
470
|
-
} catch (error) {
|
|
471
|
-
const handled = owner.handleError(error);
|
|
472
|
-
invokeRuntimeDebug("error", {
|
|
473
|
-
error,
|
|
474
|
-
owner,
|
|
475
|
-
phase: "event",
|
|
476
|
-
handled,
|
|
477
|
-
recovery: handled ? "handled" : "propagated"
|
|
478
|
-
});
|
|
479
|
-
if (!handled) throw error;
|
|
480
|
-
}
|
|
481
|
-
} : handler;
|
|
482
|
-
const binding = { handler: listener, owner, original: handler };
|
|
483
|
-
bindings.set(event, binding);
|
|
484
|
-
renderer.addEventListener(node, event, listener);
|
|
485
|
-
owner?.onDispose(() => {
|
|
486
|
-
if (bindings?.get(event) !== binding) return;
|
|
487
|
-
bindings.delete(event);
|
|
488
|
-
renderer.removeEventListener(node, event, listener);
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
__name(addEventListener, "addEventListener");
|
|
492
|
-
function createBlock(factory) {
|
|
493
|
-
const owner = createOwner();
|
|
494
|
-
setOwnerDebugName(owner, "dynamic");
|
|
495
|
-
let node;
|
|
496
|
-
try {
|
|
497
|
-
node = owner.run(factory);
|
|
498
|
-
} catch (error) {
|
|
499
|
-
owner.dispose();
|
|
500
|
-
throw error;
|
|
501
|
-
}
|
|
502
|
-
if (!node) {
|
|
503
|
-
owner.dispose();
|
|
504
|
-
return null;
|
|
505
|
-
}
|
|
506
|
-
associateNodeOwner(node, owner);
|
|
507
|
-
return node;
|
|
508
|
-
}
|
|
509
|
-
__name(createBlock, "createBlock");
|
|
510
|
-
function associateNodeOwner(node, owner) {
|
|
511
|
-
nodeOwners.set(node, owner);
|
|
512
|
-
}
|
|
513
|
-
__name(associateNodeOwner, "associateNodeOwner");
|
|
514
|
-
function disposeNodeOwner(node) {
|
|
515
|
-
const owner = nodeOwners.get(node);
|
|
516
|
-
if (!owner) return;
|
|
517
|
-
nodeOwners.delete(node);
|
|
518
|
-
owner.dispose();
|
|
519
|
-
}
|
|
520
|
-
__name(disposeNodeOwner, "disposeNodeOwner");
|
|
521
|
-
|
|
522
|
-
// packages/runtime/src/fragment.ts
|
|
523
|
-
function createFragment(factory) {
|
|
524
|
-
const start = createComment("vobs:fragment:start");
|
|
525
|
-
const end = createComment("vobs:fragment:end");
|
|
526
|
-
let parent = null;
|
|
527
|
-
let initialized = false;
|
|
528
|
-
const owner = getCurrentOwner();
|
|
529
|
-
const fragment = {
|
|
530
|
-
kind: "vobs-fragment",
|
|
531
|
-
start,
|
|
532
|
-
end,
|
|
533
|
-
mount(nextParent, anchor) {
|
|
534
|
-
if (parent && parent !== nextParent) {
|
|
535
|
-
throw new Error("Vobs Fragment: \u4E0D\u80FD\u8DE8\u7236\u8282\u70B9\u79FB\u52A8 Fragment");
|
|
536
|
-
}
|
|
537
|
-
if (initialized) {
|
|
538
|
-
moveRange(nextParent, start, end, anchor);
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
const renderer = getRenderer();
|
|
542
|
-
renderer.insertBefore(nextParent, start, anchor);
|
|
543
|
-
renderer.insertBefore(nextParent, end, anchor);
|
|
544
|
-
parent = nextParent;
|
|
545
|
-
initialized = true;
|
|
546
|
-
if (owner) owner.run(() => factory(nextParent, end));
|
|
547
|
-
else factory(nextParent, end);
|
|
548
|
-
},
|
|
549
|
-
unmount(nextParent) {
|
|
550
|
-
if (!initialized || parent !== nextParent) {
|
|
551
|
-
throw new Error("Vobs Fragment: Fragment \u4E0D\u5C5E\u4E8E\u6307\u5B9A\u7236\u8282\u70B9");
|
|
552
|
-
}
|
|
553
|
-
const renderer = getRenderer();
|
|
554
|
-
let current = renderer.nextSibling(start);
|
|
555
|
-
while (current && current !== end) {
|
|
556
|
-
const next = renderer.nextSibling(current);
|
|
557
|
-
renderer.removeChild(nextParent, current);
|
|
558
|
-
current = next;
|
|
559
|
-
}
|
|
560
|
-
renderer.removeChild(nextParent, start);
|
|
561
|
-
renderer.removeChild(nextParent, end);
|
|
562
|
-
parent = null;
|
|
563
|
-
initialized = false;
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
return fragment;
|
|
567
|
-
}
|
|
568
|
-
__name(createFragment, "createFragment");
|
|
569
|
-
function isVobsFragment(value) {
|
|
570
|
-
return Boolean(value) && typeof value === "object" && value.kind === "vobs-fragment";
|
|
571
|
-
}
|
|
572
|
-
__name(isVobsFragment, "isVobsFragment");
|
|
573
|
-
function moveRange(parent, start, end, anchor) {
|
|
574
|
-
const renderer = getRenderer();
|
|
575
|
-
const nodes = [start];
|
|
576
|
-
let current = renderer.nextSibling(start);
|
|
577
|
-
while (current) {
|
|
578
|
-
nodes.push(current);
|
|
579
|
-
if (current === end) break;
|
|
580
|
-
current = renderer.nextSibling(current);
|
|
581
|
-
}
|
|
582
|
-
if (nodes[nodes.length - 1] !== end) {
|
|
583
|
-
throw new Error("Vobs Fragment: \u627E\u4E0D\u5230\u7ED3\u675F\u951A\u70B9");
|
|
584
|
-
}
|
|
585
|
-
for (const node of nodes) renderer.insertBefore(parent, node, anchor);
|
|
586
|
-
}
|
|
587
|
-
__name(moveRange, "moveRange");
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
588
21
|
|
|
589
|
-
// packages/
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
if (current) insertBefore(parent, current, marker);
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
__name(insertDynamic, "insertDynamic");
|
|
22
|
+
// packages/captcha/src/slider.ts
|
|
23
|
+
var slider_exports = {};
|
|
24
|
+
__export(slider_exports, {
|
|
25
|
+
SliderCaptcha: () => SliderCaptcha,
|
|
26
|
+
analyzeSliderTrail: () => analyzeSliderTrail,
|
|
27
|
+
collectCaptchaDeviceSignals: () => collectCaptchaDeviceSignals
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(slider_exports);
|
|
30
|
+
var import_vobs2 = require("@vobs/vobs");
|
|
31
|
+
var import_reactivity = require("@vobs/reactivity");
|
|
603
32
|
|
|
604
33
|
// packages/captcha/src/index.ts
|
|
34
|
+
var import_vobs = require("@vobs/vobs");
|
|
605
35
|
function Captcha(props = {}) {
|
|
606
|
-
const root = createElement("section");
|
|
607
|
-
const challengeHost = createElement("div");
|
|
608
|
-
const messageHost = createElement("div");
|
|
609
|
-
const actions = createElement("div");
|
|
610
|
-
const header = createElement("div");
|
|
611
|
-
const headerText = createText("");
|
|
612
|
-
setAttribute(header, "class", "vobs-captcha__header");
|
|
613
|
-
setAttribute(challengeHost, "class", "vobs-captcha__challenge");
|
|
614
|
-
setAttribute(messageHost, "class", "vobs-captcha__message-host");
|
|
615
|
-
setAttribute(actions, "class", "vobs-captcha__actions");
|
|
616
|
-
insertBefore(root, header, null);
|
|
617
|
-
insertBefore(root, challengeHost, null);
|
|
618
|
-
insertBefore(root, messageHost, null);
|
|
619
|
-
insertBefore(root, actions, null);
|
|
620
|
-
insertDynamic(header, null, () => {
|
|
36
|
+
const root = (0, import_vobs.createElement)("section");
|
|
37
|
+
const challengeHost = (0, import_vobs.createElement)("div");
|
|
38
|
+
const messageHost = (0, import_vobs.createElement)("div");
|
|
39
|
+
const actions = (0, import_vobs.createElement)("div");
|
|
40
|
+
const header = (0, import_vobs.createElement)("div");
|
|
41
|
+
const headerText = (0, import_vobs.createText)("");
|
|
42
|
+
(0, import_vobs.setAttribute)(header, "class", "vobs-captcha__header");
|
|
43
|
+
(0, import_vobs.setAttribute)(challengeHost, "class", "vobs-captcha__challenge");
|
|
44
|
+
(0, import_vobs.setAttribute)(messageHost, "class", "vobs-captcha__message-host");
|
|
45
|
+
(0, import_vobs.setAttribute)(actions, "class", "vobs-captcha__actions");
|
|
46
|
+
(0, import_vobs.insertBefore)(root, header, null);
|
|
47
|
+
(0, import_vobs.insertBefore)(root, challengeHost, null);
|
|
48
|
+
(0, import_vobs.insertBefore)(root, messageHost, null);
|
|
49
|
+
(0, import_vobs.insertBefore)(root, actions, null);
|
|
50
|
+
(0, import_vobs.insertDynamic)(header, null, () => {
|
|
621
51
|
const label = readString(props, "label");
|
|
622
52
|
if (!label) return null;
|
|
623
53
|
setText(headerText, label);
|
|
624
54
|
return headerText;
|
|
625
55
|
});
|
|
626
|
-
effect(() => {
|
|
56
|
+
(0, import_vobs.effect)(() => {
|
|
627
57
|
const status = readValue(props, "status", "idle");
|
|
628
|
-
setAttribute(root, "class", classNames("vobs-captcha", readString(props, "class"), readString(props, "className")));
|
|
629
|
-
setAttribute(root, "data-status", status);
|
|
58
|
+
(0, import_vobs.setAttribute)(root, "class", classNames("vobs-captcha", readString(props, "class"), readString(props, "className")));
|
|
59
|
+
(0, import_vobs.setAttribute)(root, "data-status", status);
|
|
630
60
|
setOptionalAttribute(root, "id", readString(props, "id"));
|
|
631
61
|
setOptionalAttribute(root, "title", readString(props, "title"));
|
|
632
62
|
setOptionalAttribute(root, "role", readString(props, "role"));
|
|
633
|
-
setAttribute(root, "aria-busy", String(status === "loading" || status === "verifying"));
|
|
634
|
-
if (readValue(props, "disabled", false) || status === "loading" || status === "verifying") setAttribute(root, "aria-disabled", "true");
|
|
63
|
+
(0, import_vobs.setAttribute)(root, "aria-busy", String(status === "loading" || status === "verifying"));
|
|
64
|
+
if (readValue(props, "disabled", false) || status === "loading" || status === "verifying") (0, import_vobs.setAttribute)(root, "aria-disabled", "true");
|
|
635
65
|
else root.removeAttribute("aria-disabled");
|
|
636
66
|
bindDataAndAriaAttributes(root, props);
|
|
637
67
|
});
|
|
638
|
-
insertDynamic(challengeHost, null, () => renderChallenge(props));
|
|
639
|
-
insertDynamic(messageHost, null, () => renderMessage(props));
|
|
640
|
-
insertDynamic(actions, null, () => renderActions(props));
|
|
68
|
+
(0, import_vobs.insertDynamic)(challengeHost, null, () => renderChallenge(props));
|
|
69
|
+
(0, import_vobs.insertDynamic)(messageHost, null, () => renderMessage(props));
|
|
70
|
+
(0, import_vobs.insertDynamic)(actions, null, () => renderActions(props));
|
|
641
71
|
return root;
|
|
642
72
|
function renderChallenge(input) {
|
|
643
73
|
const status = readValue(input, "status", "idle");
|
|
@@ -668,22 +98,24 @@ function Captcha(props = {}) {
|
|
|
668
98
|
}
|
|
669
99
|
}) ?? createMessage(readValue(input, "emptyLabel", "Captcha is not ready."));
|
|
670
100
|
}
|
|
101
|
+
__name(renderChallenge, "renderChallenge");
|
|
671
102
|
function renderMessage(input) {
|
|
672
103
|
const status = readValue(input, "status", "idle");
|
|
673
104
|
if (readValue(input, "messagePlacement", "challenge") !== "footer") return null;
|
|
674
105
|
if (status !== "error") return null;
|
|
675
106
|
return createMessage(readError(input) || readValue(input, "errorLabel", "Captcha verification failed."));
|
|
676
107
|
}
|
|
108
|
+
__name(renderMessage, "renderMessage");
|
|
677
109
|
function renderActions(input) {
|
|
678
110
|
const status = readValue(input, "status", "idle");
|
|
679
111
|
const disabled = readValue(input, "disabled", false) || status === "loading" || status === "verifying";
|
|
680
112
|
const retry = readCallback(input, "onRetry", void 0);
|
|
681
113
|
const cancel = readCallback(input, "onCancel", void 0);
|
|
682
114
|
if (!retry && !cancel) return null;
|
|
683
|
-
return createFragment((parent, anchor) => {
|
|
115
|
+
return (0, import_vobs.createFragment)((parent, anchor) => {
|
|
684
116
|
const canRetry = status === "idle" || status === "expired" || status === "error" || status === "loading" && readValue(input, "showRetryWhileLoading", false) || readValue(input, "showRetry", false) && status !== "loading" && status !== "verifying";
|
|
685
117
|
if (retry && canRetry) {
|
|
686
|
-
insertBefore(parent, createActionButton(
|
|
118
|
+
(0, import_vobs.insertBefore)(parent, createActionButton(
|
|
687
119
|
readValue(input, "retryLabel", "Retry"),
|
|
688
120
|
readCallback(input, "retryIcon", void 0),
|
|
689
121
|
retry,
|
|
@@ -693,7 +125,7 @@ function Captcha(props = {}) {
|
|
|
693
125
|
}
|
|
694
126
|
const canCancel = status === "loading" || status === "verifying" || readValue(input, "showCancel", false);
|
|
695
127
|
if (cancel && canCancel) {
|
|
696
|
-
insertBefore(parent, createActionButton(
|
|
128
|
+
(0, import_vobs.insertBefore)(parent, createActionButton(
|
|
697
129
|
readValue(input, "cancelLabel", "Cancel"),
|
|
698
130
|
void 0,
|
|
699
131
|
cancel,
|
|
@@ -703,29 +135,32 @@ function Captcha(props = {}) {
|
|
|
703
135
|
}
|
|
704
136
|
});
|
|
705
137
|
}
|
|
138
|
+
__name(renderActions, "renderActions");
|
|
706
139
|
function createActionButton(label, icon, handler, disabled, variant) {
|
|
707
|
-
const button = createElement("button");
|
|
708
|
-
setAttribute(button, "class", `vobs-captcha__action ${variant}`);
|
|
709
|
-
setAttribute(button, "type", "button");
|
|
710
|
-
setAttribute(button, "aria-label", label);
|
|
711
|
-
setProperty(button, "disabled", disabled);
|
|
140
|
+
const button = (0, import_vobs.createElement)("button");
|
|
141
|
+
(0, import_vobs.setAttribute)(button, "class", `vobs-captcha__action ${variant}`);
|
|
142
|
+
(0, import_vobs.setAttribute)(button, "type", "button");
|
|
143
|
+
(0, import_vobs.setAttribute)(button, "aria-label", label);
|
|
144
|
+
(0, import_vobs.setProperty)(button, "disabled", disabled);
|
|
712
145
|
if (icon !== void 0) {
|
|
713
|
-
const iconHost = createElement("span");
|
|
714
|
-
setAttribute(iconHost, "class", "vobs-captcha__action-icon");
|
|
146
|
+
const iconHost = (0, import_vobs.createElement)("span");
|
|
147
|
+
(0, import_vobs.setAttribute)(iconHost, "class", "vobs-captcha__action-icon");
|
|
715
148
|
const value = typeof icon === "function" ? icon() : icon;
|
|
716
|
-
if (value !== null && value !== void 0) insertBefore(iconHost, value, null);
|
|
717
|
-
insertBefore(button, iconHost, null);
|
|
149
|
+
if (value !== null && value !== void 0) (0, import_vobs.insertBefore)(iconHost, value, null);
|
|
150
|
+
(0, import_vobs.insertBefore)(button, iconHost, null);
|
|
718
151
|
}
|
|
719
|
-
insertBefore(button, createText(label), null);
|
|
720
|
-
addEventListener(button, "click", handler);
|
|
152
|
+
(0, import_vobs.insertBefore)(button, (0, import_vobs.createText)(label), null);
|
|
153
|
+
(0, import_vobs.addEventListener)(button, "click", handler);
|
|
721
154
|
return button;
|
|
722
155
|
}
|
|
156
|
+
__name(createActionButton, "createActionButton");
|
|
723
157
|
function createMessage(message) {
|
|
724
|
-
const node = createElement("p");
|
|
725
|
-
setAttribute(node, "class", "vobs-captcha__message");
|
|
726
|
-
insertBefore(node, createText(message), null);
|
|
158
|
+
const node = (0, import_vobs.createElement)("p");
|
|
159
|
+
(0, import_vobs.setAttribute)(node, "class", "vobs-captcha__message");
|
|
160
|
+
(0, import_vobs.insertBefore)(node, (0, import_vobs.createText)(message), null);
|
|
727
161
|
return node;
|
|
728
162
|
}
|
|
163
|
+
__name(createMessage, "createMessage");
|
|
729
164
|
}
|
|
730
165
|
__name(Captcha, "Captcha");
|
|
731
166
|
function setText(node, value) {
|
|
@@ -762,7 +197,7 @@ function readError(props) {
|
|
|
762
197
|
}
|
|
763
198
|
__name(readError, "readError");
|
|
764
199
|
function setOptionalAttribute(node, name, value) {
|
|
765
|
-
if (value) setAttribute(node, name, value);
|
|
200
|
+
if (value) (0, import_vobs.setAttribute)(node, name, value);
|
|
766
201
|
else node.removeAttribute(name);
|
|
767
202
|
}
|
|
768
203
|
__name(setOptionalAttribute, "setOptionalAttribute");
|
|
@@ -771,7 +206,7 @@ function bindDataAndAriaAttributes(node, props) {
|
|
|
771
206
|
if (!name.startsWith("aria-") && !name.startsWith("data-")) continue;
|
|
772
207
|
const value = readValue(props, name, void 0);
|
|
773
208
|
if (value === void 0 || value === null || value === false) node.removeAttribute(name);
|
|
774
|
-
else setAttribute(node, name, String(value));
|
|
209
|
+
else (0, import_vobs.setAttribute)(node, name, String(value));
|
|
775
210
|
}
|
|
776
211
|
}
|
|
777
212
|
__name(bindDataAndAriaAttributes, "bindDataAndAriaAttributes");
|
|
@@ -819,10 +254,10 @@ function collectCaptchaDeviceSignals() {
|
|
|
819
254
|
__name(collectCaptchaDeviceSignals, "collectCaptchaDeviceSignals");
|
|
820
255
|
function SliderCaptcha(props = {}) {
|
|
821
256
|
const positions = /* @__PURE__ */ new Map();
|
|
822
|
-
const successDismissed = state(false);
|
|
257
|
+
const successDismissed = (0, import_vobs2.state)(false);
|
|
823
258
|
let successTimer;
|
|
824
259
|
let waitingForDismiss = false;
|
|
825
|
-
effect(() => {
|
|
260
|
+
(0, import_vobs2.effect)(() => {
|
|
826
261
|
const currentStatus = readValue2(props, "status", "idle");
|
|
827
262
|
if (currentStatus !== "verified") {
|
|
828
263
|
waitingForDismiss = false;
|
|
@@ -842,7 +277,7 @@ function SliderCaptcha(props = {}) {
|
|
|
842
277
|
props.onSuccessDismiss?.();
|
|
843
278
|
}, duration);
|
|
844
279
|
});
|
|
845
|
-
onDispose(() => {
|
|
280
|
+
(0, import_reactivity.onDispose)(() => {
|
|
846
281
|
if (successTimer !== void 0) clearTimeout(successTimer);
|
|
847
282
|
positions.clear();
|
|
848
283
|
});
|
|
@@ -943,92 +378,92 @@ function createSliderChallenge(context, props, initialPosition, onPositionChange
|
|
|
943
378
|
const challenge = context.challenge;
|
|
944
379
|
const payload = challenge.payload;
|
|
945
380
|
const interactionDisabled = context.disabled || context.status === "error" || context.status === "expired" || context.status === "verified";
|
|
946
|
-
const wrapper = createElement("div");
|
|
947
|
-
const visual = createElement("div");
|
|
948
|
-
const target = createElement("div");
|
|
949
|
-
const targetImage = createElement("div");
|
|
950
|
-
const piece = createElement("div");
|
|
951
|
-
const pieceImage = createElement("div");
|
|
952
|
-
const track = createElement("div");
|
|
953
|
-
const trackPrompt = createElement("span");
|
|
954
|
-
const handle = createElement("button");
|
|
955
|
-
const handleText = createText(context.status === "verified" ? "\u221A" : readValue2(props, "dragLabel", ">"));
|
|
381
|
+
const wrapper = (0, import_vobs2.createElement)("div");
|
|
382
|
+
const visual = (0, import_vobs2.createElement)("div");
|
|
383
|
+
const target = (0, import_vobs2.createElement)("div");
|
|
384
|
+
const targetImage = (0, import_vobs2.createElement)("div");
|
|
385
|
+
const piece = (0, import_vobs2.createElement)("div");
|
|
386
|
+
const pieceImage = (0, import_vobs2.createElement)("div");
|
|
387
|
+
const track = (0, import_vobs2.createElement)("div");
|
|
388
|
+
const trackPrompt = (0, import_vobs2.createElement)("span");
|
|
389
|
+
const handle = (0, import_vobs2.createElement)("button");
|
|
390
|
+
const handleText = (0, import_vobs2.createText)(context.status === "verified" ? "\u221A" : readValue2(props, "dragLabel", ">"));
|
|
956
391
|
const trail = [];
|
|
957
392
|
const startX = clamp(payload.startX ?? 0, 0, Math.max(0, payload.width - payload.pieceWidth));
|
|
958
393
|
const maxPosition = Math.max(0, payload.width - payload.pieceWidth - startX);
|
|
959
|
-
const position = state(clamp(initialPosition, 0, maxPosition));
|
|
960
|
-
const dragging = state(false);
|
|
394
|
+
const position = (0, import_vobs2.state)(clamp(initialPosition, 0, maxPosition));
|
|
395
|
+
const dragging = (0, import_vobs2.state)(false);
|
|
961
396
|
const handleWidth = 50;
|
|
962
397
|
let startClientX = 0;
|
|
963
398
|
let startPosition = 0;
|
|
964
399
|
let lastRecordedAt = 0;
|
|
965
400
|
let startedAt = 0;
|
|
966
|
-
setAttribute(wrapper, "class", "vobs-slider-captcha__challenge");
|
|
967
|
-
setAttribute(visual, "class", "vobs-slider-captcha__visual");
|
|
968
|
-
setAttribute(target, "class", `vobs-slider-captcha__target vobs-slider-captcha__target--${payload.shape ?? "puzzle"}`);
|
|
969
|
-
setAttribute(targetImage, "class", "vobs-slider-captcha__image");
|
|
970
|
-
setAttribute(piece, "class", `vobs-slider-captcha__piece vobs-slider-captcha__piece--${payload.shape ?? "puzzle"}`);
|
|
971
|
-
setAttribute(pieceImage, "class", "vobs-slider-captcha__image");
|
|
972
|
-
setAttribute(track, "class", "vobs-slider-captcha__track");
|
|
973
|
-
setAttribute(trackPrompt, "class", "vobs-slider-captcha__track-prompt");
|
|
974
|
-
setAttribute(handle, "class", `vobs-slider-captcha__handle${context.status === "verified" ? " vobs-slider-captcha__handle--verified" : ""}`);
|
|
975
|
-
setAttribute(handle, "type", "button");
|
|
976
|
-
setAttribute(handle, "role", "slider");
|
|
977
|
-
setAttribute(handle, "aria-label", context.status === "verified" ? "\u9A8C\u8BC1\u901A\u8FC7" : readValue2(props, "dragLabel", ">"));
|
|
978
|
-
insertBefore(trackPrompt, createText("\u5411\u53F3\u62D6\u52A8\u6ED1\u5757\u5B8C\u6210\u62FC\u56FE"), null);
|
|
979
|
-
insertBefore(handle, handleText, null);
|
|
401
|
+
(0, import_vobs2.setAttribute)(wrapper, "class", "vobs-slider-captcha__challenge");
|
|
402
|
+
(0, import_vobs2.setAttribute)(visual, "class", "vobs-slider-captcha__visual");
|
|
403
|
+
(0, import_vobs2.setAttribute)(target, "class", `vobs-slider-captcha__target vobs-slider-captcha__target--${payload.shape ?? "puzzle"}`);
|
|
404
|
+
(0, import_vobs2.setAttribute)(targetImage, "class", "vobs-slider-captcha__image");
|
|
405
|
+
(0, import_vobs2.setAttribute)(piece, "class", `vobs-slider-captcha__piece vobs-slider-captcha__piece--${payload.shape ?? "puzzle"}`);
|
|
406
|
+
(0, import_vobs2.setAttribute)(pieceImage, "class", "vobs-slider-captcha__image");
|
|
407
|
+
(0, import_vobs2.setAttribute)(track, "class", "vobs-slider-captcha__track");
|
|
408
|
+
(0, import_vobs2.setAttribute)(trackPrompt, "class", "vobs-slider-captcha__track-prompt");
|
|
409
|
+
(0, import_vobs2.setAttribute)(handle, "class", `vobs-slider-captcha__handle${context.status === "verified" ? " vobs-slider-captcha__handle--verified" : ""}`);
|
|
410
|
+
(0, import_vobs2.setAttribute)(handle, "type", "button");
|
|
411
|
+
(0, import_vobs2.setAttribute)(handle, "role", "slider");
|
|
412
|
+
(0, import_vobs2.setAttribute)(handle, "aria-label", context.status === "verified" ? "\u9A8C\u8BC1\u901A\u8FC7" : readValue2(props, "dragLabel", ">"));
|
|
413
|
+
(0, import_vobs2.insertBefore)(trackPrompt, (0, import_vobs2.createText)("\u5411\u53F3\u62D6\u52A8\u6ED1\u5757\u5B8C\u6210\u62FC\u56FE"), null);
|
|
414
|
+
(0, import_vobs2.insertBefore)(handle, handleText, null);
|
|
980
415
|
const visualImageStyle = payload.image ? `background-image: url(${quoteCssUrl(payload.image)}); background-size: ${payload.width}px ${payload.height}px;` : "";
|
|
981
416
|
const imageAt = /* @__PURE__ */ __name((x, y) => payload.image ? `${visualImageStyle} background-position: -${x}px -${y}px;` : "", "imageAt");
|
|
982
|
-
setAttribute(visual, "style", `width: ${payload.width}px; height: ${payload.height}px; ${visualImageStyle}`);
|
|
417
|
+
(0, import_vobs2.setAttribute)(visual, "style", `width: ${payload.width}px; height: ${payload.height}px; ${visualImageStyle}`);
|
|
983
418
|
const targetRotation = rotationStyle(payload.rotation);
|
|
984
|
-
setAttribute(target, "style", `left: ${payload.targetX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
985
|
-
setAttribute(targetImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
986
|
-
setAttribute(pieceImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
987
|
-
setAttribute(piece, "style", `top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
988
|
-
setAttribute(track, "style", `width: ${payload.width}px`);
|
|
989
|
-
insertBefore(target, targetImage, null);
|
|
419
|
+
(0, import_vobs2.setAttribute)(target, "style", `left: ${payload.targetX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
420
|
+
(0, import_vobs2.setAttribute)(targetImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
421
|
+
(0, import_vobs2.setAttribute)(pieceImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
422
|
+
(0, import_vobs2.setAttribute)(piece, "style", `top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
423
|
+
(0, import_vobs2.setAttribute)(track, "style", `width: ${payload.width}px`);
|
|
424
|
+
(0, import_vobs2.insertBefore)(target, targetImage, null);
|
|
990
425
|
const decoys = readDecoys(payload);
|
|
991
426
|
const decoyNodes = decoys.map((decoyData) => {
|
|
992
|
-
const decoy = createElement("div");
|
|
993
|
-
const decoyImage = createElement("div");
|
|
994
|
-
setAttribute(decoy, "class", `vobs-slider-captcha__decoy vobs-slider-captcha__decoy--${payload.shape ?? "puzzle"}`);
|
|
995
|
-
setAttribute(decoyImage, "class", "vobs-slider-captcha__image");
|
|
996
|
-
setAttribute(decoy, "style", `left: ${decoyData.x}px; top: ${decoyData.y}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${rotationStyle(decoyData.rotation)}`);
|
|
997
|
-
setAttribute(decoyImage, "style", `${counterRotationStyle(decoyData.rotation)} ${imageAt(decoyData.x, decoyData.y)}`);
|
|
998
|
-
insertBefore(decoy, decoyImage, null);
|
|
427
|
+
const decoy = (0, import_vobs2.createElement)("div");
|
|
428
|
+
const decoyImage = (0, import_vobs2.createElement)("div");
|
|
429
|
+
(0, import_vobs2.setAttribute)(decoy, "class", `vobs-slider-captcha__decoy vobs-slider-captcha__decoy--${payload.shape ?? "puzzle"}`);
|
|
430
|
+
(0, import_vobs2.setAttribute)(decoyImage, "class", "vobs-slider-captcha__image");
|
|
431
|
+
(0, import_vobs2.setAttribute)(decoy, "style", `left: ${decoyData.x}px; top: ${decoyData.y}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${rotationStyle(decoyData.rotation)}`);
|
|
432
|
+
(0, import_vobs2.setAttribute)(decoyImage, "style", `${counterRotationStyle(decoyData.rotation)} ${imageAt(decoyData.x, decoyData.y)}`);
|
|
433
|
+
(0, import_vobs2.insertBefore)(decoy, decoyImage, null);
|
|
999
434
|
return decoy;
|
|
1000
435
|
});
|
|
1001
|
-
insertBefore(piece, pieceImage, null);
|
|
1002
|
-
insertBefore(visual, target, null);
|
|
1003
|
-
for (const decoy of decoyNodes) insertBefore(visual, decoy, null);
|
|
1004
|
-
insertBefore(visual, piece, null);
|
|
436
|
+
(0, import_vobs2.insertBefore)(piece, pieceImage, null);
|
|
437
|
+
(0, import_vobs2.insertBefore)(visual, target, null);
|
|
438
|
+
for (const decoy of decoyNodes) (0, import_vobs2.insertBefore)(visual, decoy, null);
|
|
439
|
+
(0, import_vobs2.insertBefore)(visual, piece, null);
|
|
1005
440
|
if (context.status === "error" || context.status === "loading") {
|
|
1006
|
-
const notice = createElement("p");
|
|
441
|
+
const notice = (0, import_vobs2.createElement)("p");
|
|
1007
442
|
const isError = context.status === "error";
|
|
1008
|
-
setAttribute(notice, "class", isError ? "vobs-slider-captcha__error" : "vobs-slider-captcha__notice");
|
|
1009
|
-
setAttribute(notice, "role", isError ? "alert" : "status");
|
|
1010
|
-
insertBefore(notice, createText(isError ? readErrorMessage(props) : readValue2(props, "loadingLabel", "Refreshing captcha\u2026")), null);
|
|
1011
|
-
insertBefore(visual, notice, null);
|
|
1012
|
-
}
|
|
1013
|
-
insertBefore(track, trackPrompt, null);
|
|
1014
|
-
insertBefore(track, handle, null);
|
|
1015
|
-
insertBefore(wrapper, visual, null);
|
|
1016
|
-
insertBefore(wrapper, track, null);
|
|
1017
|
-
effect(() => {
|
|
443
|
+
(0, import_vobs2.setAttribute)(notice, "class", isError ? "vobs-slider-captcha__error" : "vobs-slider-captcha__notice");
|
|
444
|
+
(0, import_vobs2.setAttribute)(notice, "role", isError ? "alert" : "status");
|
|
445
|
+
(0, import_vobs2.insertBefore)(notice, (0, import_vobs2.createText)(isError ? readErrorMessage(props) : readValue2(props, "loadingLabel", "Refreshing captcha\u2026")), null);
|
|
446
|
+
(0, import_vobs2.insertBefore)(visual, notice, null);
|
|
447
|
+
}
|
|
448
|
+
(0, import_vobs2.insertBefore)(track, trackPrompt, null);
|
|
449
|
+
(0, import_vobs2.insertBefore)(track, handle, null);
|
|
450
|
+
(0, import_vobs2.insertBefore)(wrapper, visual, null);
|
|
451
|
+
(0, import_vobs2.insertBefore)(wrapper, track, null);
|
|
452
|
+
(0, import_vobs2.effect)(() => {
|
|
1018
453
|
const value = position.value;
|
|
1019
454
|
const pieceX = startX + value;
|
|
1020
455
|
onPositionChange(value);
|
|
1021
|
-
setAttribute(track, "data-has-moved", String(value > 0));
|
|
1022
|
-
setAttribute(piece, "style", `left: ${pieceX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
1023
|
-
setAttribute(handle, "style", `left: calc(${value / Math.max(1, maxPosition) * 100}% - ${value / Math.max(1, maxPosition) * handleWidth}px)`);
|
|
1024
|
-
setAttribute(handle, "aria-valuemin", "0");
|
|
1025
|
-
setAttribute(handle, "aria-valuemax", String(maxPosition));
|
|
1026
|
-
setAttribute(handle, "aria-valuenow", String(Math.round(value)));
|
|
1027
|
-
setProperty(handle, "disabled", interactionDisabled);
|
|
1028
|
-
setAttribute(wrapper, "data-dragging", String(dragging.value));
|
|
456
|
+
(0, import_vobs2.setAttribute)(track, "data-has-moved", String(value > 0));
|
|
457
|
+
(0, import_vobs2.setAttribute)(piece, "style", `left: ${pieceX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
458
|
+
(0, import_vobs2.setAttribute)(handle, "style", `left: calc(${value / Math.max(1, maxPosition) * 100}% - ${value / Math.max(1, maxPosition) * handleWidth}px)`);
|
|
459
|
+
(0, import_vobs2.setAttribute)(handle, "aria-valuemin", "0");
|
|
460
|
+
(0, import_vobs2.setAttribute)(handle, "aria-valuemax", String(maxPosition));
|
|
461
|
+
(0, import_vobs2.setAttribute)(handle, "aria-valuenow", String(Math.round(value)));
|
|
462
|
+
(0, import_vobs2.setProperty)(handle, "disabled", interactionDisabled);
|
|
463
|
+
(0, import_vobs2.setAttribute)(wrapper, "data-dragging", String(dragging.value));
|
|
1029
464
|
});
|
|
1030
465
|
for (const source of [piece, handle]) {
|
|
1031
|
-
addEventListener(source, "pointerdown", (event) => {
|
|
466
|
+
(0, import_vobs2.addEventListener)(source, "pointerdown", (event) => {
|
|
1032
467
|
if (interactionDisabled) return;
|
|
1033
468
|
const pointer = event;
|
|
1034
469
|
if (pointer.button !== void 0 && pointer.button !== 0) return;
|
|
@@ -1042,26 +477,26 @@ function createSliderChallenge(context, props, initialPosition, onPositionChange
|
|
|
1042
477
|
const capture = source;
|
|
1043
478
|
capture.setPointerCapture?.(pointer.pointerId);
|
|
1044
479
|
});
|
|
1045
|
-
addEventListener(source, "pointermove", (event) => {
|
|
480
|
+
(0, import_vobs2.addEventListener)(source, "pointermove", (event) => {
|
|
1046
481
|
if (!dragging.value || interactionDisabled) return;
|
|
1047
482
|
const pointer = event;
|
|
1048
483
|
const scale = getVisualScale(visual, payload.width);
|
|
1049
484
|
position.value = clamp(startPosition + (pointer.clientX - startClientX) / scale, 0, maxPosition);
|
|
1050
485
|
recordPoint(pointer);
|
|
1051
486
|
});
|
|
1052
|
-
addEventListener(source, "pointerup", (event) => {
|
|
487
|
+
(0, import_vobs2.addEventListener)(source, "pointerup", (event) => {
|
|
1053
488
|
if (!dragging.value) return;
|
|
1054
489
|
recordPoint(event, true);
|
|
1055
490
|
dragging.value = false;
|
|
1056
491
|
submit();
|
|
1057
492
|
});
|
|
1058
|
-
addEventListener(source, "pointercancel", () => {
|
|
493
|
+
(0, import_vobs2.addEventListener)(source, "pointercancel", () => {
|
|
1059
494
|
dragging.value = false;
|
|
1060
495
|
position.value = 0;
|
|
1061
496
|
trail.length = 0;
|
|
1062
497
|
});
|
|
1063
498
|
}
|
|
1064
|
-
addEventListener(handle, "keydown", (event) => {
|
|
499
|
+
(0, import_vobs2.addEventListener)(handle, "keydown", (event) => {
|
|
1065
500
|
if (interactionDisabled) return;
|
|
1066
501
|
const keyboard = event;
|
|
1067
502
|
if (keyboard.key === "ArrowLeft" || keyboard.key === "ArrowRight") {
|
|
@@ -1074,7 +509,7 @@ function createSliderChallenge(context, props, initialPosition, onPositionChange
|
|
|
1074
509
|
keyboard.preventDefault();
|
|
1075
510
|
}
|
|
1076
511
|
});
|
|
1077
|
-
onDispose(() => {
|
|
512
|
+
(0, import_reactivity.onDispose)(() => {
|
|
1078
513
|
trail.length = 0;
|
|
1079
514
|
});
|
|
1080
515
|
function recordPoint(pointer, force = false) {
|
|
@@ -1231,9 +666,10 @@ function createSessionId() {
|
|
|
1231
666
|
return `captcha-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1232
667
|
}
|
|
1233
668
|
__name(createSessionId, "createSessionId");
|
|
1234
|
-
|
|
1235
|
-
exports
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
669
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
670
|
+
0 && (module.exports = {
|
|
671
|
+
SliderCaptcha,
|
|
672
|
+
analyzeSliderTrail,
|
|
673
|
+
collectCaptchaDeviceSignals
|
|
674
|
+
});
|
|
1239
675
|
//# sourceMappingURL=slider.cjs.map
|