@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/index.cjs
CHANGED
|
@@ -1,607 +1,38 @@
|
|
|
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/index.ts
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
Captcha: () => Captcha,
|
|
26
|
+
SliderCaptcha: () => SliderCaptcha,
|
|
27
|
+
analyzeSliderTrail: () => analyzeSliderTrail,
|
|
28
|
+
collectCaptchaDeviceSignals: () => collectCaptchaDeviceSignals
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
var import_vobs2 = require("@vobs/vobs");
|
|
603
32
|
|
|
604
33
|
// packages/captcha/src/slider.ts
|
|
34
|
+
var import_vobs = require("@vobs/vobs");
|
|
35
|
+
var import_reactivity = require("@vobs/reactivity");
|
|
605
36
|
var sessionId = createSessionId();
|
|
606
37
|
function collectCaptchaDeviceSignals() {
|
|
607
38
|
if (typeof navigator === "undefined" || typeof window === "undefined") {
|
|
@@ -640,10 +71,10 @@ function collectCaptchaDeviceSignals() {
|
|
|
640
71
|
__name(collectCaptchaDeviceSignals, "collectCaptchaDeviceSignals");
|
|
641
72
|
function SliderCaptcha(props = {}) {
|
|
642
73
|
const positions = /* @__PURE__ */ new Map();
|
|
643
|
-
const successDismissed = state(false);
|
|
74
|
+
const successDismissed = (0, import_vobs.state)(false);
|
|
644
75
|
let successTimer;
|
|
645
76
|
let waitingForDismiss = false;
|
|
646
|
-
effect(() => {
|
|
77
|
+
(0, import_vobs.effect)(() => {
|
|
647
78
|
const currentStatus = readValue(props, "status", "idle");
|
|
648
79
|
if (currentStatus !== "verified") {
|
|
649
80
|
waitingForDismiss = false;
|
|
@@ -663,7 +94,7 @@ function SliderCaptcha(props = {}) {
|
|
|
663
94
|
props.onSuccessDismiss?.();
|
|
664
95
|
}, duration);
|
|
665
96
|
});
|
|
666
|
-
onDispose(() => {
|
|
97
|
+
(0, import_reactivity.onDispose)(() => {
|
|
667
98
|
if (successTimer !== void 0) clearTimeout(successTimer);
|
|
668
99
|
positions.clear();
|
|
669
100
|
});
|
|
@@ -764,92 +195,92 @@ function createSliderChallenge(context, props, initialPosition, onPositionChange
|
|
|
764
195
|
const challenge = context.challenge;
|
|
765
196
|
const payload = challenge.payload;
|
|
766
197
|
const interactionDisabled = context.disabled || context.status === "error" || context.status === "expired" || context.status === "verified";
|
|
767
|
-
const wrapper = createElement("div");
|
|
768
|
-
const visual = createElement("div");
|
|
769
|
-
const target = createElement("div");
|
|
770
|
-
const targetImage = createElement("div");
|
|
771
|
-
const piece = createElement("div");
|
|
772
|
-
const pieceImage = createElement("div");
|
|
773
|
-
const track = createElement("div");
|
|
774
|
-
const trackPrompt = createElement("span");
|
|
775
|
-
const handle = createElement("button");
|
|
776
|
-
const handleText = createText(context.status === "verified" ? "\u221A" : readValue(props, "dragLabel", ">"));
|
|
198
|
+
const wrapper = (0, import_vobs.createElement)("div");
|
|
199
|
+
const visual = (0, import_vobs.createElement)("div");
|
|
200
|
+
const target = (0, import_vobs.createElement)("div");
|
|
201
|
+
const targetImage = (0, import_vobs.createElement)("div");
|
|
202
|
+
const piece = (0, import_vobs.createElement)("div");
|
|
203
|
+
const pieceImage = (0, import_vobs.createElement)("div");
|
|
204
|
+
const track = (0, import_vobs.createElement)("div");
|
|
205
|
+
const trackPrompt = (0, import_vobs.createElement)("span");
|
|
206
|
+
const handle = (0, import_vobs.createElement)("button");
|
|
207
|
+
const handleText = (0, import_vobs.createText)(context.status === "verified" ? "\u221A" : readValue(props, "dragLabel", ">"));
|
|
777
208
|
const trail = [];
|
|
778
209
|
const startX = clamp(payload.startX ?? 0, 0, Math.max(0, payload.width - payload.pieceWidth));
|
|
779
210
|
const maxPosition = Math.max(0, payload.width - payload.pieceWidth - startX);
|
|
780
|
-
const position = state(clamp(initialPosition, 0, maxPosition));
|
|
781
|
-
const dragging = state(false);
|
|
211
|
+
const position = (0, import_vobs.state)(clamp(initialPosition, 0, maxPosition));
|
|
212
|
+
const dragging = (0, import_vobs.state)(false);
|
|
782
213
|
const handleWidth = 50;
|
|
783
214
|
let startClientX = 0;
|
|
784
215
|
let startPosition = 0;
|
|
785
216
|
let lastRecordedAt = 0;
|
|
786
217
|
let startedAt = 0;
|
|
787
|
-
setAttribute(wrapper, "class", "vobs-slider-captcha__challenge");
|
|
788
|
-
setAttribute(visual, "class", "vobs-slider-captcha__visual");
|
|
789
|
-
setAttribute(target, "class", `vobs-slider-captcha__target vobs-slider-captcha__target--${payload.shape ?? "puzzle"}`);
|
|
790
|
-
setAttribute(targetImage, "class", "vobs-slider-captcha__image");
|
|
791
|
-
setAttribute(piece, "class", `vobs-slider-captcha__piece vobs-slider-captcha__piece--${payload.shape ?? "puzzle"}`);
|
|
792
|
-
setAttribute(pieceImage, "class", "vobs-slider-captcha__image");
|
|
793
|
-
setAttribute(track, "class", "vobs-slider-captcha__track");
|
|
794
|
-
setAttribute(trackPrompt, "class", "vobs-slider-captcha__track-prompt");
|
|
795
|
-
setAttribute(handle, "class", `vobs-slider-captcha__handle${context.status === "verified" ? " vobs-slider-captcha__handle--verified" : ""}`);
|
|
796
|
-
setAttribute(handle, "type", "button");
|
|
797
|
-
setAttribute(handle, "role", "slider");
|
|
798
|
-
setAttribute(handle, "aria-label", context.status === "verified" ? "\u9A8C\u8BC1\u901A\u8FC7" : readValue(props, "dragLabel", ">"));
|
|
799
|
-
insertBefore(trackPrompt, createText("\u5411\u53F3\u62D6\u52A8\u6ED1\u5757\u5B8C\u6210\u62FC\u56FE"), null);
|
|
800
|
-
insertBefore(handle, handleText, null);
|
|
218
|
+
(0, import_vobs.setAttribute)(wrapper, "class", "vobs-slider-captcha__challenge");
|
|
219
|
+
(0, import_vobs.setAttribute)(visual, "class", "vobs-slider-captcha__visual");
|
|
220
|
+
(0, import_vobs.setAttribute)(target, "class", `vobs-slider-captcha__target vobs-slider-captcha__target--${payload.shape ?? "puzzle"}`);
|
|
221
|
+
(0, import_vobs.setAttribute)(targetImage, "class", "vobs-slider-captcha__image");
|
|
222
|
+
(0, import_vobs.setAttribute)(piece, "class", `vobs-slider-captcha__piece vobs-slider-captcha__piece--${payload.shape ?? "puzzle"}`);
|
|
223
|
+
(0, import_vobs.setAttribute)(pieceImage, "class", "vobs-slider-captcha__image");
|
|
224
|
+
(0, import_vobs.setAttribute)(track, "class", "vobs-slider-captcha__track");
|
|
225
|
+
(0, import_vobs.setAttribute)(trackPrompt, "class", "vobs-slider-captcha__track-prompt");
|
|
226
|
+
(0, import_vobs.setAttribute)(handle, "class", `vobs-slider-captcha__handle${context.status === "verified" ? " vobs-slider-captcha__handle--verified" : ""}`);
|
|
227
|
+
(0, import_vobs.setAttribute)(handle, "type", "button");
|
|
228
|
+
(0, import_vobs.setAttribute)(handle, "role", "slider");
|
|
229
|
+
(0, import_vobs.setAttribute)(handle, "aria-label", context.status === "verified" ? "\u9A8C\u8BC1\u901A\u8FC7" : readValue(props, "dragLabel", ">"));
|
|
230
|
+
(0, import_vobs.insertBefore)(trackPrompt, (0, import_vobs.createText)("\u5411\u53F3\u62D6\u52A8\u6ED1\u5757\u5B8C\u6210\u62FC\u56FE"), null);
|
|
231
|
+
(0, import_vobs.insertBefore)(handle, handleText, null);
|
|
801
232
|
const visualImageStyle = payload.image ? `background-image: url(${quoteCssUrl(payload.image)}); background-size: ${payload.width}px ${payload.height}px;` : "";
|
|
802
233
|
const imageAt = /* @__PURE__ */ __name((x, y) => payload.image ? `${visualImageStyle} background-position: -${x}px -${y}px;` : "", "imageAt");
|
|
803
|
-
setAttribute(visual, "style", `width: ${payload.width}px; height: ${payload.height}px; ${visualImageStyle}`);
|
|
234
|
+
(0, import_vobs.setAttribute)(visual, "style", `width: ${payload.width}px; height: ${payload.height}px; ${visualImageStyle}`);
|
|
804
235
|
const targetRotation = rotationStyle(payload.rotation);
|
|
805
|
-
setAttribute(target, "style", `left: ${payload.targetX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
806
|
-
setAttribute(targetImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
807
|
-
setAttribute(pieceImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
808
|
-
setAttribute(piece, "style", `top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
809
|
-
setAttribute(track, "style", `width: ${payload.width}px`);
|
|
810
|
-
insertBefore(target, targetImage, null);
|
|
236
|
+
(0, import_vobs.setAttribute)(target, "style", `left: ${payload.targetX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
237
|
+
(0, import_vobs.setAttribute)(targetImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
238
|
+
(0, import_vobs.setAttribute)(pieceImage, "style", `${counterRotationStyle(payload.rotation)} ${imageAt(payload.targetX, payload.targetY)}`);
|
|
239
|
+
(0, import_vobs.setAttribute)(piece, "style", `top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
240
|
+
(0, import_vobs.setAttribute)(track, "style", `width: ${payload.width}px`);
|
|
241
|
+
(0, import_vobs.insertBefore)(target, targetImage, null);
|
|
811
242
|
const decoys = readDecoys(payload);
|
|
812
243
|
const decoyNodes = decoys.map((decoyData) => {
|
|
813
|
-
const decoy = createElement("div");
|
|
814
|
-
const decoyImage = createElement("div");
|
|
815
|
-
setAttribute(decoy, "class", `vobs-slider-captcha__decoy vobs-slider-captcha__decoy--${payload.shape ?? "puzzle"}`);
|
|
816
|
-
setAttribute(decoyImage, "class", "vobs-slider-captcha__image");
|
|
817
|
-
setAttribute(decoy, "style", `left: ${decoyData.x}px; top: ${decoyData.y}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${rotationStyle(decoyData.rotation)}`);
|
|
818
|
-
setAttribute(decoyImage, "style", `${counterRotationStyle(decoyData.rotation)} ${imageAt(decoyData.x, decoyData.y)}`);
|
|
819
|
-
insertBefore(decoy, decoyImage, null);
|
|
244
|
+
const decoy = (0, import_vobs.createElement)("div");
|
|
245
|
+
const decoyImage = (0, import_vobs.createElement)("div");
|
|
246
|
+
(0, import_vobs.setAttribute)(decoy, "class", `vobs-slider-captcha__decoy vobs-slider-captcha__decoy--${payload.shape ?? "puzzle"}`);
|
|
247
|
+
(0, import_vobs.setAttribute)(decoyImage, "class", "vobs-slider-captcha__image");
|
|
248
|
+
(0, import_vobs.setAttribute)(decoy, "style", `left: ${decoyData.x}px; top: ${decoyData.y}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${rotationStyle(decoyData.rotation)}`);
|
|
249
|
+
(0, import_vobs.setAttribute)(decoyImage, "style", `${counterRotationStyle(decoyData.rotation)} ${imageAt(decoyData.x, decoyData.y)}`);
|
|
250
|
+
(0, import_vobs.insertBefore)(decoy, decoyImage, null);
|
|
820
251
|
return decoy;
|
|
821
252
|
});
|
|
822
|
-
insertBefore(piece, pieceImage, null);
|
|
823
|
-
insertBefore(visual, target, null);
|
|
824
|
-
for (const decoy of decoyNodes) insertBefore(visual, decoy, null);
|
|
825
|
-
insertBefore(visual, piece, null);
|
|
253
|
+
(0, import_vobs.insertBefore)(piece, pieceImage, null);
|
|
254
|
+
(0, import_vobs.insertBefore)(visual, target, null);
|
|
255
|
+
for (const decoy of decoyNodes) (0, import_vobs.insertBefore)(visual, decoy, null);
|
|
256
|
+
(0, import_vobs.insertBefore)(visual, piece, null);
|
|
826
257
|
if (context.status === "error" || context.status === "loading") {
|
|
827
|
-
const notice = createElement("p");
|
|
258
|
+
const notice = (0, import_vobs.createElement)("p");
|
|
828
259
|
const isError = context.status === "error";
|
|
829
|
-
setAttribute(notice, "class", isError ? "vobs-slider-captcha__error" : "vobs-slider-captcha__notice");
|
|
830
|
-
setAttribute(notice, "role", isError ? "alert" : "status");
|
|
831
|
-
insertBefore(notice, createText(isError ? readErrorMessage(props) : readValue(props, "loadingLabel", "Refreshing captcha\u2026")), null);
|
|
832
|
-
insertBefore(visual, notice, null);
|
|
833
|
-
}
|
|
834
|
-
insertBefore(track, trackPrompt, null);
|
|
835
|
-
insertBefore(track, handle, null);
|
|
836
|
-
insertBefore(wrapper, visual, null);
|
|
837
|
-
insertBefore(wrapper, track, null);
|
|
838
|
-
effect(() => {
|
|
260
|
+
(0, import_vobs.setAttribute)(notice, "class", isError ? "vobs-slider-captcha__error" : "vobs-slider-captcha__notice");
|
|
261
|
+
(0, import_vobs.setAttribute)(notice, "role", isError ? "alert" : "status");
|
|
262
|
+
(0, import_vobs.insertBefore)(notice, (0, import_vobs.createText)(isError ? readErrorMessage(props) : readValue(props, "loadingLabel", "Refreshing captcha\u2026")), null);
|
|
263
|
+
(0, import_vobs.insertBefore)(visual, notice, null);
|
|
264
|
+
}
|
|
265
|
+
(0, import_vobs.insertBefore)(track, trackPrompt, null);
|
|
266
|
+
(0, import_vobs.insertBefore)(track, handle, null);
|
|
267
|
+
(0, import_vobs.insertBefore)(wrapper, visual, null);
|
|
268
|
+
(0, import_vobs.insertBefore)(wrapper, track, null);
|
|
269
|
+
(0, import_vobs.effect)(() => {
|
|
839
270
|
const value = position.value;
|
|
840
271
|
const pieceX = startX + value;
|
|
841
272
|
onPositionChange(value);
|
|
842
|
-
setAttribute(track, "data-has-moved", String(value > 0));
|
|
843
|
-
setAttribute(piece, "style", `left: ${pieceX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
844
|
-
setAttribute(handle, "style", `left: calc(${value / Math.max(1, maxPosition) * 100}% - ${value / Math.max(1, maxPosition) * handleWidth}px)`);
|
|
845
|
-
setAttribute(handle, "aria-valuemin", "0");
|
|
846
|
-
setAttribute(handle, "aria-valuemax", String(maxPosition));
|
|
847
|
-
setAttribute(handle, "aria-valuenow", String(Math.round(value)));
|
|
848
|
-
setProperty(handle, "disabled", interactionDisabled);
|
|
849
|
-
setAttribute(wrapper, "data-dragging", String(dragging.value));
|
|
273
|
+
(0, import_vobs.setAttribute)(track, "data-has-moved", String(value > 0));
|
|
274
|
+
(0, import_vobs.setAttribute)(piece, "style", `left: ${pieceX}px; top: ${payload.targetY}px; width: ${payload.pieceWidth}px; height: ${payload.pieceHeight}px; ${targetRotation}`);
|
|
275
|
+
(0, import_vobs.setAttribute)(handle, "style", `left: calc(${value / Math.max(1, maxPosition) * 100}% - ${value / Math.max(1, maxPosition) * handleWidth}px)`);
|
|
276
|
+
(0, import_vobs.setAttribute)(handle, "aria-valuemin", "0");
|
|
277
|
+
(0, import_vobs.setAttribute)(handle, "aria-valuemax", String(maxPosition));
|
|
278
|
+
(0, import_vobs.setAttribute)(handle, "aria-valuenow", String(Math.round(value)));
|
|
279
|
+
(0, import_vobs.setProperty)(handle, "disabled", interactionDisabled);
|
|
280
|
+
(0, import_vobs.setAttribute)(wrapper, "data-dragging", String(dragging.value));
|
|
850
281
|
});
|
|
851
282
|
for (const source of [piece, handle]) {
|
|
852
|
-
addEventListener(source, "pointerdown", (event) => {
|
|
283
|
+
(0, import_vobs.addEventListener)(source, "pointerdown", (event) => {
|
|
853
284
|
if (interactionDisabled) return;
|
|
854
285
|
const pointer = event;
|
|
855
286
|
if (pointer.button !== void 0 && pointer.button !== 0) return;
|
|
@@ -863,26 +294,26 @@ function createSliderChallenge(context, props, initialPosition, onPositionChange
|
|
|
863
294
|
const capture = source;
|
|
864
295
|
capture.setPointerCapture?.(pointer.pointerId);
|
|
865
296
|
});
|
|
866
|
-
addEventListener(source, "pointermove", (event) => {
|
|
297
|
+
(0, import_vobs.addEventListener)(source, "pointermove", (event) => {
|
|
867
298
|
if (!dragging.value || interactionDisabled) return;
|
|
868
299
|
const pointer = event;
|
|
869
300
|
const scale = getVisualScale(visual, payload.width);
|
|
870
301
|
position.value = clamp(startPosition + (pointer.clientX - startClientX) / scale, 0, maxPosition);
|
|
871
302
|
recordPoint(pointer);
|
|
872
303
|
});
|
|
873
|
-
addEventListener(source, "pointerup", (event) => {
|
|
304
|
+
(0, import_vobs.addEventListener)(source, "pointerup", (event) => {
|
|
874
305
|
if (!dragging.value) return;
|
|
875
306
|
recordPoint(event, true);
|
|
876
307
|
dragging.value = false;
|
|
877
308
|
submit();
|
|
878
309
|
});
|
|
879
|
-
addEventListener(source, "pointercancel", () => {
|
|
310
|
+
(0, import_vobs.addEventListener)(source, "pointercancel", () => {
|
|
880
311
|
dragging.value = false;
|
|
881
312
|
position.value = 0;
|
|
882
313
|
trail.length = 0;
|
|
883
314
|
});
|
|
884
315
|
}
|
|
885
|
-
addEventListener(handle, "keydown", (event) => {
|
|
316
|
+
(0, import_vobs.addEventListener)(handle, "keydown", (event) => {
|
|
886
317
|
if (interactionDisabled) return;
|
|
887
318
|
const keyboard = event;
|
|
888
319
|
if (keyboard.key === "ArrowLeft" || keyboard.key === "ArrowRight") {
|
|
@@ -895,7 +326,7 @@ function createSliderChallenge(context, props, initialPosition, onPositionChange
|
|
|
895
326
|
keyboard.preventDefault();
|
|
896
327
|
}
|
|
897
328
|
});
|
|
898
|
-
onDispose(() => {
|
|
329
|
+
(0, import_reactivity.onDispose)(() => {
|
|
899
330
|
trail.length = 0;
|
|
900
331
|
});
|
|
901
332
|
function recordPoint(pointer, force = false) {
|
|
@@ -1055,41 +486,41 @@ __name(createSessionId, "createSessionId");
|
|
|
1055
486
|
|
|
1056
487
|
// packages/captcha/src/index.ts
|
|
1057
488
|
function Captcha(props = {}) {
|
|
1058
|
-
const root = createElement("section");
|
|
1059
|
-
const challengeHost = createElement("div");
|
|
1060
|
-
const messageHost = createElement("div");
|
|
1061
|
-
const actions = createElement("div");
|
|
1062
|
-
const header = createElement("div");
|
|
1063
|
-
const headerText = createText("");
|
|
1064
|
-
setAttribute(header, "class", "vobs-captcha__header");
|
|
1065
|
-
setAttribute(challengeHost, "class", "vobs-captcha__challenge");
|
|
1066
|
-
setAttribute(messageHost, "class", "vobs-captcha__message-host");
|
|
1067
|
-
setAttribute(actions, "class", "vobs-captcha__actions");
|
|
1068
|
-
insertBefore(root, header, null);
|
|
1069
|
-
insertBefore(root, challengeHost, null);
|
|
1070
|
-
insertBefore(root, messageHost, null);
|
|
1071
|
-
insertBefore(root, actions, null);
|
|
1072
|
-
insertDynamic(header, null, () => {
|
|
489
|
+
const root = (0, import_vobs2.createElement)("section");
|
|
490
|
+
const challengeHost = (0, import_vobs2.createElement)("div");
|
|
491
|
+
const messageHost = (0, import_vobs2.createElement)("div");
|
|
492
|
+
const actions = (0, import_vobs2.createElement)("div");
|
|
493
|
+
const header = (0, import_vobs2.createElement)("div");
|
|
494
|
+
const headerText = (0, import_vobs2.createText)("");
|
|
495
|
+
(0, import_vobs2.setAttribute)(header, "class", "vobs-captcha__header");
|
|
496
|
+
(0, import_vobs2.setAttribute)(challengeHost, "class", "vobs-captcha__challenge");
|
|
497
|
+
(0, import_vobs2.setAttribute)(messageHost, "class", "vobs-captcha__message-host");
|
|
498
|
+
(0, import_vobs2.setAttribute)(actions, "class", "vobs-captcha__actions");
|
|
499
|
+
(0, import_vobs2.insertBefore)(root, header, null);
|
|
500
|
+
(0, import_vobs2.insertBefore)(root, challengeHost, null);
|
|
501
|
+
(0, import_vobs2.insertBefore)(root, messageHost, null);
|
|
502
|
+
(0, import_vobs2.insertBefore)(root, actions, null);
|
|
503
|
+
(0, import_vobs2.insertDynamic)(header, null, () => {
|
|
1073
504
|
const label = readString2(props, "label");
|
|
1074
505
|
if (!label) return null;
|
|
1075
506
|
setText(headerText, label);
|
|
1076
507
|
return headerText;
|
|
1077
508
|
});
|
|
1078
|
-
effect(() => {
|
|
509
|
+
(0, import_vobs2.effect)(() => {
|
|
1079
510
|
const status = readValue2(props, "status", "idle");
|
|
1080
|
-
setAttribute(root, "class", classNames2("vobs-captcha", readString2(props, "class"), readString2(props, "className")));
|
|
1081
|
-
setAttribute(root, "data-status", status);
|
|
511
|
+
(0, import_vobs2.setAttribute)(root, "class", classNames2("vobs-captcha", readString2(props, "class"), readString2(props, "className")));
|
|
512
|
+
(0, import_vobs2.setAttribute)(root, "data-status", status);
|
|
1082
513
|
setOptionalAttribute(root, "id", readString2(props, "id"));
|
|
1083
514
|
setOptionalAttribute(root, "title", readString2(props, "title"));
|
|
1084
515
|
setOptionalAttribute(root, "role", readString2(props, "role"));
|
|
1085
|
-
setAttribute(root, "aria-busy", String(status === "loading" || status === "verifying"));
|
|
1086
|
-
if (readValue2(props, "disabled", false) || status === "loading" || status === "verifying") setAttribute(root, "aria-disabled", "true");
|
|
516
|
+
(0, import_vobs2.setAttribute)(root, "aria-busy", String(status === "loading" || status === "verifying"));
|
|
517
|
+
if (readValue2(props, "disabled", false) || status === "loading" || status === "verifying") (0, import_vobs2.setAttribute)(root, "aria-disabled", "true");
|
|
1087
518
|
else root.removeAttribute("aria-disabled");
|
|
1088
519
|
bindDataAndAriaAttributes(root, props);
|
|
1089
520
|
});
|
|
1090
|
-
insertDynamic(challengeHost, null, () => renderChallenge(props));
|
|
1091
|
-
insertDynamic(messageHost, null, () => renderMessage(props));
|
|
1092
|
-
insertDynamic(actions, null, () => renderActions(props));
|
|
521
|
+
(0, import_vobs2.insertDynamic)(challengeHost, null, () => renderChallenge(props));
|
|
522
|
+
(0, import_vobs2.insertDynamic)(messageHost, null, () => renderMessage(props));
|
|
523
|
+
(0, import_vobs2.insertDynamic)(actions, null, () => renderActions(props));
|
|
1093
524
|
return root;
|
|
1094
525
|
function renderChallenge(input) {
|
|
1095
526
|
const status = readValue2(input, "status", "idle");
|
|
@@ -1120,22 +551,24 @@ function Captcha(props = {}) {
|
|
|
1120
551
|
}
|
|
1121
552
|
}) ?? createMessage(readValue2(input, "emptyLabel", "Captcha is not ready."));
|
|
1122
553
|
}
|
|
554
|
+
__name(renderChallenge, "renderChallenge");
|
|
1123
555
|
function renderMessage(input) {
|
|
1124
556
|
const status = readValue2(input, "status", "idle");
|
|
1125
557
|
if (readValue2(input, "messagePlacement", "challenge") !== "footer") return null;
|
|
1126
558
|
if (status !== "error") return null;
|
|
1127
559
|
return createMessage(readError(input) || readValue2(input, "errorLabel", "Captcha verification failed."));
|
|
1128
560
|
}
|
|
561
|
+
__name(renderMessage, "renderMessage");
|
|
1129
562
|
function renderActions(input) {
|
|
1130
563
|
const status = readValue2(input, "status", "idle");
|
|
1131
564
|
const disabled = readValue2(input, "disabled", false) || status === "loading" || status === "verifying";
|
|
1132
565
|
const retry = readCallback(input, "onRetry", void 0);
|
|
1133
566
|
const cancel = readCallback(input, "onCancel", void 0);
|
|
1134
567
|
if (!retry && !cancel) return null;
|
|
1135
|
-
return createFragment((parent, anchor) => {
|
|
568
|
+
return (0, import_vobs2.createFragment)((parent, anchor) => {
|
|
1136
569
|
const canRetry = status === "idle" || status === "expired" || status === "error" || status === "loading" && readValue2(input, "showRetryWhileLoading", false) || readValue2(input, "showRetry", false) && status !== "loading" && status !== "verifying";
|
|
1137
570
|
if (retry && canRetry) {
|
|
1138
|
-
insertBefore(parent, createActionButton(
|
|
571
|
+
(0, import_vobs2.insertBefore)(parent, createActionButton(
|
|
1139
572
|
readValue2(input, "retryLabel", "Retry"),
|
|
1140
573
|
readCallback(input, "retryIcon", void 0),
|
|
1141
574
|
retry,
|
|
@@ -1145,7 +578,7 @@ function Captcha(props = {}) {
|
|
|
1145
578
|
}
|
|
1146
579
|
const canCancel = status === "loading" || status === "verifying" || readValue2(input, "showCancel", false);
|
|
1147
580
|
if (cancel && canCancel) {
|
|
1148
|
-
insertBefore(parent, createActionButton(
|
|
581
|
+
(0, import_vobs2.insertBefore)(parent, createActionButton(
|
|
1149
582
|
readValue2(input, "cancelLabel", "Cancel"),
|
|
1150
583
|
void 0,
|
|
1151
584
|
cancel,
|
|
@@ -1155,29 +588,32 @@ function Captcha(props = {}) {
|
|
|
1155
588
|
}
|
|
1156
589
|
});
|
|
1157
590
|
}
|
|
591
|
+
__name(renderActions, "renderActions");
|
|
1158
592
|
function createActionButton(label, icon, handler, disabled, variant) {
|
|
1159
|
-
const button = createElement("button");
|
|
1160
|
-
setAttribute(button, "class", `vobs-captcha__action ${variant}`);
|
|
1161
|
-
setAttribute(button, "type", "button");
|
|
1162
|
-
setAttribute(button, "aria-label", label);
|
|
1163
|
-
setProperty(button, "disabled", disabled);
|
|
593
|
+
const button = (0, import_vobs2.createElement)("button");
|
|
594
|
+
(0, import_vobs2.setAttribute)(button, "class", `vobs-captcha__action ${variant}`);
|
|
595
|
+
(0, import_vobs2.setAttribute)(button, "type", "button");
|
|
596
|
+
(0, import_vobs2.setAttribute)(button, "aria-label", label);
|
|
597
|
+
(0, import_vobs2.setProperty)(button, "disabled", disabled);
|
|
1164
598
|
if (icon !== void 0) {
|
|
1165
|
-
const iconHost = createElement("span");
|
|
1166
|
-
setAttribute(iconHost, "class", "vobs-captcha__action-icon");
|
|
599
|
+
const iconHost = (0, import_vobs2.createElement)("span");
|
|
600
|
+
(0, import_vobs2.setAttribute)(iconHost, "class", "vobs-captcha__action-icon");
|
|
1167
601
|
const value = typeof icon === "function" ? icon() : icon;
|
|
1168
|
-
if (value !== null && value !== void 0) insertBefore(iconHost, value, null);
|
|
1169
|
-
insertBefore(button, iconHost, null);
|
|
602
|
+
if (value !== null && value !== void 0) (0, import_vobs2.insertBefore)(iconHost, value, null);
|
|
603
|
+
(0, import_vobs2.insertBefore)(button, iconHost, null);
|
|
1170
604
|
}
|
|
1171
|
-
insertBefore(button, createText(label), null);
|
|
1172
|
-
addEventListener(button, "click", handler);
|
|
605
|
+
(0, import_vobs2.insertBefore)(button, (0, import_vobs2.createText)(label), null);
|
|
606
|
+
(0, import_vobs2.addEventListener)(button, "click", handler);
|
|
1173
607
|
return button;
|
|
1174
608
|
}
|
|
609
|
+
__name(createActionButton, "createActionButton");
|
|
1175
610
|
function createMessage(message) {
|
|
1176
|
-
const node = createElement("p");
|
|
1177
|
-
setAttribute(node, "class", "vobs-captcha__message");
|
|
1178
|
-
insertBefore(node, createText(message), null);
|
|
611
|
+
const node = (0, import_vobs2.createElement)("p");
|
|
612
|
+
(0, import_vobs2.setAttribute)(node, "class", "vobs-captcha__message");
|
|
613
|
+
(0, import_vobs2.insertBefore)(node, (0, import_vobs2.createText)(message), null);
|
|
1179
614
|
return node;
|
|
1180
615
|
}
|
|
616
|
+
__name(createMessage, "createMessage");
|
|
1181
617
|
}
|
|
1182
618
|
__name(Captcha, "Captcha");
|
|
1183
619
|
function setText(node, value) {
|
|
@@ -1214,7 +650,7 @@ function readError(props) {
|
|
|
1214
650
|
}
|
|
1215
651
|
__name(readError, "readError");
|
|
1216
652
|
function setOptionalAttribute(node, name, value) {
|
|
1217
|
-
if (value) setAttribute(node, name, value);
|
|
653
|
+
if (value) (0, import_vobs2.setAttribute)(node, name, value);
|
|
1218
654
|
else node.removeAttribute(name);
|
|
1219
655
|
}
|
|
1220
656
|
__name(setOptionalAttribute, "setOptionalAttribute");
|
|
@@ -1223,7 +659,7 @@ function bindDataAndAriaAttributes(node, props) {
|
|
|
1223
659
|
if (!name.startsWith("aria-") && !name.startsWith("data-")) continue;
|
|
1224
660
|
const value = readValue2(props, name, void 0);
|
|
1225
661
|
if (value === void 0 || value === null || value === false) node.removeAttribute(name);
|
|
1226
|
-
else setAttribute(node, name, String(value));
|
|
662
|
+
else (0, import_vobs2.setAttribute)(node, name, String(value));
|
|
1227
663
|
}
|
|
1228
664
|
}
|
|
1229
665
|
__name(bindDataAndAriaAttributes, "bindDataAndAriaAttributes");
|
|
@@ -1231,10 +667,11 @@ function isSignal2(value) {
|
|
|
1231
667
|
return value !== null && typeof value === "object" && "value" in value && typeof value.dispose === "function";
|
|
1232
668
|
}
|
|
1233
669
|
__name(isSignal2, "isSignal");
|
|
1234
|
-
|
|
1235
|
-
exports
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
670
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
671
|
+
0 && (module.exports = {
|
|
672
|
+
Captcha,
|
|
673
|
+
SliderCaptcha,
|
|
674
|
+
analyzeSliderTrail,
|
|
675
|
+
collectCaptchaDeviceSignals
|
|
676
|
+
});
|
|
1240
677
|
//# sourceMappingURL=index.cjs.map
|