@huoshan12345/jqueryx 0.0.2

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.
Files changed (40) hide show
  1. package/LICENSE.TXT +21 -0
  2. package/README.md +390 -0
  3. package/dist/extensions/index.d.ts +16 -0
  4. package/dist/extensions/index.d.ts.map +1 -0
  5. package/dist/extensions/jquery.attr.d.ts +30 -0
  6. package/dist/extensions/jquery.attr.d.ts.map +1 -0
  7. package/dist/extensions/jquery.collection.d.ts +22 -0
  8. package/dist/extensions/jquery.collection.d.ts.map +1 -0
  9. package/dist/extensions/jquery.css.d.ts +42 -0
  10. package/dist/extensions/jquery.css.d.ts.map +1 -0
  11. package/dist/extensions/jquery.enumeration.d.ts +12 -0
  12. package/dist/extensions/jquery.enumeration.d.ts.map +1 -0
  13. package/dist/extensions/jquery.events.d.ts +36 -0
  14. package/dist/extensions/jquery.events.d.ts.map +1 -0
  15. package/dist/extensions/jquery.factory.d.ts +20 -0
  16. package/dist/extensions/jquery.factory.d.ts.map +1 -0
  17. package/dist/extensions/jquery.init.d.ts +2 -0
  18. package/dist/extensions/jquery.init.d.ts.map +1 -0
  19. package/dist/extensions/jquery.observe.d.ts +13 -0
  20. package/dist/extensions/jquery.observe.d.ts.map +1 -0
  21. package/dist/extensions/jquery.replace.d.ts +15 -0
  22. package/dist/extensions/jquery.replace.d.ts.map +1 -0
  23. package/dist/extensions/jquery.scroll.d.ts +8 -0
  24. package/dist/extensions/jquery.scroll.d.ts.map +1 -0
  25. package/dist/extensions/jquery.text-nodes.d.ts +17 -0
  26. package/dist/extensions/jquery.text-nodes.d.ts.map +1 -0
  27. package/dist/extensions/jquery.text.d.ts +27 -0
  28. package/dist/extensions/jquery.text.d.ts.map +1 -0
  29. package/dist/extensions/jquery.traversal.d.ts +20 -0
  30. package/dist/extensions/jquery.traversal.d.ts.map +1 -0
  31. package/dist/extensions/jquery.urls.d.ts +9 -0
  32. package/dist/extensions/jquery.urls.d.ts.map +1 -0
  33. package/dist/extensions/jquery.wait.d.ts +12 -0
  34. package/dist/extensions/jquery.wait.d.ts.map +1 -0
  35. package/dist/index.d.ts +5 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +524 -0
  38. package/dist/types/lib.d.ts +65 -0
  39. package/dist/types/lib.d.ts.map +1 -0
  40. package/package.json +63 -0
package/dist/index.js ADDED
@@ -0,0 +1,524 @@
1
+ import e from "jquery";
2
+ import "builtinx/dom";
3
+ import { Enumerable as t } from "linqx";
4
+ import { MutationObserverOptions as n, Stack as r } from "builtinx";
5
+ //#endregion
6
+ //#region src/extensions/jquery.enumeration.ts
7
+ globalThis.$ = e, globalThis.jQuery = e, $.fn.isNot = function(e) {
8
+ return this.is(e) === !1;
9
+ }, $.fn.throwIfEmpty = function() {
10
+ return this.isEmpty() && Error.throw("The set is empty"), this;
11
+ }, $.fn.isEmpty = function() {
12
+ return this.length === 0;
13
+ }, $.fn.isNotEmpty = function() {
14
+ return this.length !== 0;
15
+ }, $.fn.ifEmpty = function(e) {
16
+ return this.isEmpty() ? $(e) : this;
17
+ }, $.fn.where = function(e) {
18
+ return this.filter((t, n) => e(n, t) === !0);
19
+ }, $.fn.tap = function(e) {
20
+ return e(this), this;
21
+ }, $.fn.tapIf = function(e, t) {
22
+ return e(this) && t(this), this;
23
+ }, $.fn.entries = function* () {
24
+ let e = 0;
25
+ for (let t of this) yield [e, t], e++;
26
+ };
27
+ function* i(e) {
28
+ for (let t of e) yield t;
29
+ }
30
+ //#endregion
31
+ //#region src/extensions/jquery.factory.ts
32
+ $.fn.asEnumerable = function() {
33
+ return t.from(() => i(this));
34
+ }, $.fn.enumerate = function() {
35
+ return this.asEnumerable().select((e) => $(e));
36
+ }, $.isJQuery = function(e) {
37
+ return e instanceof $;
38
+ };
39
+ var a = Object.getOwnPropertyDescriptor(Element.prototype, "tagName").get;
40
+ $.isElement = function(e) {
41
+ if (typeof e != "object" || !e) return !1;
42
+ try {
43
+ return a.call(e), !0;
44
+ } catch {
45
+ return !1;
46
+ }
47
+ };
48
+ var o = Object.getOwnPropertyDescriptor(Node.prototype, "nodeType").get;
49
+ $.isNode = function(e) {
50
+ if (typeof e != "object" || !e) return !1;
51
+ try {
52
+ return o.call(e), !0;
53
+ } catch {
54
+ return !1;
55
+ }
56
+ };
57
+ function s(e) {
58
+ if (e == null) return $();
59
+ if (typeof e == "string") return $(e);
60
+ if ($.isJQuery(e)) return e;
61
+ if ($.isNode(e)) return $(e);
62
+ if (Array.isArrayLike(e) === !1) {
63
+ let t = BuiltinX.Type.get(e);
64
+ throw console.log(t, e), TypeError("Not an array-like object: " + t);
65
+ }
66
+ let t = $();
67
+ for (let n = 0; n < e.length; n++) {
68
+ let r = e[n];
69
+ if (typeof r == "string") t = t.add($(r));
70
+ else if ($.isJQuery(r)) t = t.add(r);
71
+ else if ($.isNode(r)) t = t.add($(r));
72
+ else {
73
+ let e = BuiltinX.Type.get(r);
74
+ throw console.log(e, r), TypeError("Not an acceptable item type: " + e);
75
+ }
76
+ }
77
+ return t;
78
+ }
79
+ //#endregion
80
+ //#region src/extensions/jquery.text-nodes.ts
81
+ $.from = s, $.fn.ancestor = function(e, t = !1, n = !1) {
82
+ let r = $();
83
+ return this.each((e, a) => {
84
+ let o = i(a, t, n);
85
+ r = r.add(o.toArray());
86
+ }), r;
87
+ function i(t, n, r) {
88
+ let i = $(t), a = r ? i : i.parent(), o = $();
89
+ for (; a.isNotEmpty() && !(a.is(e) && (o = a, n === !1));) a = a.parent();
90
+ return o;
91
+ }
92
+ }, $.fn.search = function(e, t = !0) {
93
+ let n = this.find(e);
94
+ return n.isEmpty() && t && (n = this.find("iframe").contents().find(e)), n;
95
+ }, $.search = function(e, t = !0) {
96
+ let n = $(e);
97
+ return n.isEmpty() && t && (n = $("iframe").contents().find(e)), n;
98
+ }, $.fn.textNodes = function(e, t = []) {
99
+ let n = new r();
100
+ for (let e of this.asEnumerable().reverse()) n.push(e);
101
+ let i = /* @__PURE__ */ new Set(), a = [];
102
+ for (; n.isNotEmpty();) {
103
+ let r = n.pop();
104
+ if (i.has(r)) continue;
105
+ if (i.add(r), r.nodeType === Node.TEXT_NODE) {
106
+ a.push(r);
107
+ continue;
108
+ }
109
+ let o = $(r);
110
+ if (!(r.nodeType === Node.ELEMENT_NODE && (e && !o.is(e) || t.some((e) => o.is(e))))) for (let e of o.contents().asEnumerable().reverse()) (e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE) && n.push(e);
111
+ }
112
+ return $.from(a);
113
+ };
114
+ //#endregion
115
+ //#region src/extensions/jquery.text.ts
116
+ function c(e) {
117
+ if (e == null) return this.textNodes().asEnumerable().select((e) => e.nodeValue ?? "").joinWith("");
118
+ for (let t of this.enumerate()) {
119
+ let n = t.textNodes();
120
+ if (n.isEmpty()) {
121
+ let n = t[0], r = $.isElement(n) && n.namespaceURI === "http://www.w3.org/1999/xhtml" && n.localName === "template" ? n.content : n;
122
+ if (r.nodeType === Node.ELEMENT_NODE || r.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
123
+ let t = r.ownerDocument.createTextNode(e);
124
+ r.insertBefore(t, r.firstChild);
125
+ }
126
+ continue;
127
+ }
128
+ for (let { item: t, isFirst: r } of n.asEnumerable().position()) r ? t.nodeValue = e : t.remove();
129
+ }
130
+ return this;
131
+ }
132
+ $.fn.textContent = c;
133
+ function l(e) {
134
+ if (e == null) {
135
+ let e = [];
136
+ for (let t of this) e.push(BuiltinX.Node.ownText(t));
137
+ return e.join("");
138
+ }
139
+ for (let t of this) {
140
+ if (t.nodeType === Node.TEXT_NODE) {
141
+ t.nodeValue = e;
142
+ continue;
143
+ }
144
+ if (t.nodeType !== Node.ELEMENT_NODE && t.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) continue;
145
+ let n = [], r = !1;
146
+ for (let i of t.childNodes) i.nodeType === Node.TEXT_NODE && (r ? n.push(i) : (i.nodeValue = e, r = !0));
147
+ for (let e of n) e.remove();
148
+ if (r === !1) {
149
+ let n = document.createTextNode(e);
150
+ t.insertBefore(n, t.firstChild);
151
+ }
152
+ }
153
+ return this;
154
+ }
155
+ //#endregion
156
+ //#region src/extensions/jquery.replace.ts
157
+ $.fn.ownText = l, $.fn.collapseBrs = function() {
158
+ return this.each((e, t) => {
159
+ BuiltinX.Element.collapseBrs(t);
160
+ }), this;
161
+ }, $.fn.isNewLineTextNode = function() {
162
+ return this.isNotEmpty() && this.asEnumerable().all((e) => BuiltinX.Node.isNewLineTextNode(e));
163
+ }, $.fn.trimLeadingBrs = function() {
164
+ return this.each((e, t) => {
165
+ BuiltinX.Element.trimLeadingBrs(t);
166
+ }), this;
167
+ }, $.fn.replaceBy = function(e) {
168
+ let t = this.toArray(), n = new Set(t), r = /* @__PURE__ */ new Set(), i = [...t.entries()].filter(([, e]) => {
169
+ if (r.has(e)) return !1;
170
+ r.add(e);
171
+ for (let t = e.parentElement; t; t = t.parentElement) if (n.has(t)) return !1;
172
+ return !0;
173
+ }), a = new Set(i.map(([, e]) => e)), o = /* @__PURE__ */ new Set(), s = [];
174
+ for (let [t, n] of i) {
175
+ let r = [];
176
+ for (let i of e($(n), t)) {
177
+ let e = o.has(i) || !Object.is(i, n) && a.has(i) ? $(i).clone(!0, !0)[0] : i;
178
+ r.push(e), o.add(e);
179
+ }
180
+ let i = n.parentNode;
181
+ if (i) {
182
+ let e = n.ownerDocument.createComment("");
183
+ i.insertBefore(e, n);
184
+ try {
185
+ for (let t of r) i.insertBefore(t, e);
186
+ r.some((e) => Object.is(e, n)) || $(n).remove();
187
+ } finally {
188
+ e.remove();
189
+ }
190
+ }
191
+ s.push(...r);
192
+ }
193
+ return $(s);
194
+ };
195
+ //#endregion
196
+ //#region src/extensions/jquery.attr.ts
197
+ function u(e) {
198
+ return e == null ? this.attr("title") : this.attr("title", e);
199
+ }
200
+ $.fn.title = u, $.fn.requiredTitle = function() {
201
+ return this.attr("title") || Error.throw("The element does not have title.");
202
+ }, $.fn.targetBlank = function(e = !0) {
203
+ return (e ? this.filter((e, t) => t.getAttribute("target") != "_blank") : this).attr("target", "_blank"), this;
204
+ };
205
+ function d(e) {
206
+ return e == null ? this.attr("href") : this.attr("href", e.toString());
207
+ }
208
+ $.fn.href = d, $.fn.requiredHref = function() {
209
+ return this.attr("href") || Error.throw("The element does not have href.");
210
+ }, $.fn.voidHref = function() {
211
+ return this.href("javascript:;");
212
+ }, $.fn.hasUrlHref = function() {
213
+ let e = this.attr("href");
214
+ return !!e && !e.startsWith("javascript:");
215
+ }, $.fn.disable = function() {
216
+ return this.prop("disabled", !0);
217
+ }, $.fn.enable = function() {
218
+ return this.prop("disabled", !1);
219
+ }, $.fn.checked = function() {
220
+ return this.is(":checked");
221
+ }, $.fn.pointer = function() {
222
+ return this.css("cursor", "pointer");
223
+ }, $.fn.underline = function() {
224
+ return this.css("text-decoration", "underline");
225
+ }, $.fn.flex = function() {
226
+ return this.css("display", "flex");
227
+ }, $.fn.inlineFlex = function() {
228
+ return this.css("display", "inline-flex");
229
+ }, $.fn.flexWrap = function(e = "wrap") {
230
+ return this.css("flex-wrap", e);
231
+ }, $.fn.inlineBlock = function() {
232
+ return this.css("display", "inline-block");
233
+ }, $.fn.cssImportant = function(e, t) {
234
+ if (typeof t != "string") throw TypeError("cssImportant requires a CSS string value with explicit units where needed.");
235
+ return this.each((n, r) => r.style.setProperty(e, t, "important"));
236
+ }, $.fn.cssIfNotEmpty = function(e, t) {
237
+ return t && this.css(e, t), this;
238
+ }, $.fn.addClassIfNotEmpty = function(e) {
239
+ return e?.length && this.addClass(e), this;
240
+ }, $.fn.padding = function(e) {
241
+ return this.css("padding", e);
242
+ };
243
+ function f(e, t) {
244
+ return e == null ? this.css("color") : t ? this.cssImportant("color", e) : this.css("color", e);
245
+ }
246
+ $.fn.color = f;
247
+ var p = /^rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*(?:,\s*(\d*\.?\d+)\s*)?\)$/i;
248
+ function m(e = !1) {
249
+ let t = this.color()?.trim().match(p);
250
+ if (!t) return;
251
+ let n = t.slice(1, 4).map(Number), r = t[4] === void 0 ? 1 : Number(t[4]);
252
+ if (n.some((e) => e > 255) || r > 1) return;
253
+ r < 1 && n.push(r * 255);
254
+ let i = "#" + n.map((e) => Math.round(e).toString(16).padStart(2, "0")).join("");
255
+ return e ? i.toUpperCase() : i;
256
+ }
257
+ $.fn.colorHex = m;
258
+ function h(e) {
259
+ return e == null ? this.is(":visible") : e ? this.show() : this.hide();
260
+ }
261
+ //#endregion
262
+ //#region src/extensions/jquery.scroll.ts
263
+ $.fn.visible = h, $.scrollToNode = function(e, t) {
264
+ let n;
265
+ if ($.isElement(e)) n = e;
266
+ else if (typeof e == "string") n = $(e).get(0);
267
+ else if (e instanceof jQuery) n = e.get(0);
268
+ else throw TypeError("Expected an element, selector, or JQuery collection.");
269
+ n && n.scrollIntoView({
270
+ block: "start",
271
+ inline: "nearest",
272
+ ...t
273
+ });
274
+ };
275
+ //#endregion
276
+ //#region src/types/lib.ts
277
+ var g = class {
278
+ constructor(e) {
279
+ this.preventDefault = !0, this.stopPropagation = !1, this.stopImmediatePropagation = !1, this.disableWhileProcessing = !0, Object.assign(this, e);
280
+ }
281
+ }, _ = /* @__PURE__ */ new WeakMap();
282
+ function v(e) {
283
+ let t = _.get(e);
284
+ if (t) {
285
+ t.count++;
286
+ return;
287
+ }
288
+ _.set(e, {
289
+ count: 1,
290
+ pointerEvents: e.style.getPropertyValue("pointer-events"),
291
+ priority: e.style.getPropertyPriority("pointer-events")
292
+ }), e.style.setProperty("pointer-events", "none", "important");
293
+ }
294
+ function y(e) {
295
+ let t = _.get(e);
296
+ t && (t.count--, !(t.count > 0) && (_.delete(e), t.pointerEvents ? e.style.setProperty("pointer-events", t.pointerEvents, t.priority) : e.style.removeProperty("pointer-events")));
297
+ }
298
+ async function b(e, t) {
299
+ try {
300
+ await e();
301
+ } catch (e) {
302
+ if (!t?.onError) {
303
+ console.error(e);
304
+ return;
305
+ }
306
+ try {
307
+ await t.onError(e);
308
+ } catch (e) {
309
+ console.error(e);
310
+ }
311
+ }
312
+ }
313
+ $.fn.onClick = function(e, t) {
314
+ let n = new g(t), r = /* @__PURE__ */ new WeakSet();
315
+ return this.on("click", (t) => {
316
+ n.preventDefault && t.preventDefault(), n.stopPropagation && t.stopPropagation(), n.stopImmediatePropagation && t.stopImmediatePropagation();
317
+ let i = t.currentTarget;
318
+ if (n.disableWhileProcessing) {
319
+ if (r.has(i)) return;
320
+ r.add(i), v(i);
321
+ }
322
+ b(async () => {
323
+ try {
324
+ await e(t.target, t.originalEvent);
325
+ } finally {
326
+ n.disableWhileProcessing && (r.delete(i), y(i));
327
+ }
328
+ }, n);
329
+ });
330
+ }, $.fn.onClickGotoHref = function(e) {
331
+ for (let t of this.enumerate()) if (!t.isNot("a")) {
332
+ e && t.targetBlank();
333
+ for (let e of t) e.addEventListener("click", (e) => e.stopPropagation(), !0);
334
+ t.off("click").attr("onclick", null).removeAttr("onclick");
335
+ }
336
+ return this;
337
+ };
338
+ function x(e, t, n, r) {
339
+ return e.on("keydown", (e) => {
340
+ (r === void 0 || e.key === r) && (e.stopImmediatePropagation(), b(() => t(e.target, e.key), n));
341
+ });
342
+ }
343
+ //#endregion
344
+ //#region src/extensions/jquery.wait.ts
345
+ $.fn.onKeyDown = function(e, t) {
346
+ return x(this, e, t);
347
+ }, $.fn.onEnterDown = function(e, t) {
348
+ return x(this, (t) => e(t), t, "Enter");
349
+ }, $.fn.triggerClick = function() {
350
+ return this.each((e, t) => t.click());
351
+ }, $.fn.triggerChange = function() {
352
+ return this.trigger("change");
353
+ }, $.fn.dispatchEvent = function(e) {
354
+ return this.each((t, n) => {
355
+ n.dispatchEvent(e);
356
+ });
357
+ }, $.fn.observe = function(e, t) {
358
+ let r = this, i = /* @__PURE__ */ new Set(), a = !1, o = { disconnect() {
359
+ a = !0;
360
+ for (let e of i) e.disconnect();
361
+ i.clear();
362
+ } };
363
+ function s(e) {
364
+ return (t, n, r) => {
365
+ a || (i.add(n), e?.(t, n, r));
366
+ };
367
+ }
368
+ try {
369
+ for (let a of r) {
370
+ let o = {
371
+ ...n.default,
372
+ ...t
373
+ }, c = Node.prototype.observe.call(a, s((t, n) => {
374
+ e(t, n, r);
375
+ }), {
376
+ ...t,
377
+ beforeCallback: s(o.beforeCallback),
378
+ afterCallback: s(o.afterCallback),
379
+ onSkipped: s(o.onSkipped)
380
+ });
381
+ i.add(c);
382
+ }
383
+ } catch (e) {
384
+ throw o.disconnect(), e;
385
+ }
386
+ return o;
387
+ }, $.waitForNodes = function(e, t = {}) {
388
+ return new Promise((n, r) => {
389
+ let { signal: i, timeoutMs: a = 3e4, pollIntervalMs: o = 100, includeIframes: s = !1 } = t, c = performance.now(), l = c, u, d = !1;
390
+ function f() {
391
+ u !== void 0 && clearTimeout(u), i?.removeEventListener("abort", m);
392
+ }
393
+ function p(e) {
394
+ d || (d = !0, f(), r(e));
395
+ }
396
+ function m() {
397
+ p(i.reason);
398
+ }
399
+ function h() {
400
+ p(new DOMException(`No nodes matched '${e}' within ${a} ms.`, "TimeoutError"));
401
+ }
402
+ function g() {
403
+ if (!d) try {
404
+ let t = /* @__PURE__ */ new Set([document]), r = /* @__PURE__ */ new Set();
405
+ for (let n of t) {
406
+ for (let t of n.querySelectorAll(e)) r.add(t);
407
+ if (s) for (let e of n.querySelectorAll("iframe")) {
408
+ let n = S(e);
409
+ n && t.add(n);
410
+ }
411
+ }
412
+ if (d) return;
413
+ if (r.size > 0) {
414
+ d = !0, f(), n($([...r]));
415
+ return;
416
+ }
417
+ } catch (e) {
418
+ p(e);
419
+ }
420
+ }
421
+ function _() {
422
+ if (d) return;
423
+ let e = performance.now(), t = a - (e - c);
424
+ if (t <= 0) {
425
+ h();
426
+ return;
427
+ }
428
+ let n = Math.min(Math.max(0, l - e), t, 2147483647);
429
+ u = setTimeout(() => {
430
+ if (u = void 0, performance.now() - c >= a) {
431
+ h();
432
+ return;
433
+ }
434
+ performance.now() >= l && (g(), l = performance.now() + o), _();
435
+ }, n);
436
+ }
437
+ try {
438
+ if (i?.aborted) {
439
+ m();
440
+ return;
441
+ }
442
+ if (!Number.isFinite(a) || a < 0) throw RangeError("timeoutMs must be a finite non-negative number.");
443
+ if (!Number.isFinite(o) || o <= 0) throw RangeError("pollIntervalMs must be a finite positive number.");
444
+ if (typeof e != "string" || e.trim() === "") throw TypeError("selector must be a non-empty selector string.");
445
+ i?.addEventListener("abort", m, { once: !0 }), g(), l = performance.now() + o, _();
446
+ } catch (e) {
447
+ p(e);
448
+ }
449
+ });
450
+ };
451
+ function S(e) {
452
+ try {
453
+ return e.contentDocument;
454
+ } catch (e) {
455
+ if (e && typeof e == "object" && "name" in e && e.name === "SecurityError") return null;
456
+ throw e;
457
+ }
458
+ }
459
+ //#endregion
460
+ //#region src/extensions/jquery.urls.ts
461
+ var C = /^(?:https?:|\/\/)/i;
462
+ $.fn.refineUrls = function(e, t, n) {
463
+ let { pathRewrite: r, addImageFallbackLinks: i } = typeof n == "function" ? { pathRewrite: n } : n ?? {}, a = this, o = [];
464
+ for (let n of a) {
465
+ let i = $(n), a;
466
+ switch (n.tagName) {
467
+ case "A":
468
+ a = "href";
469
+ break;
470
+ case "IMG":
471
+ a = "src", o.push(i);
472
+ break;
473
+ default:
474
+ console.styled("unsupported tag: ", {
475
+ text: n.tagName,
476
+ color: "blue"
477
+ });
478
+ continue;
479
+ }
480
+ let s = i.attr(a)?.trim();
481
+ if (!s || C.test(s) === !1) continue;
482
+ let c;
483
+ try {
484
+ c = new URL(s, n.baseURI);
485
+ } catch {
486
+ console.log("invalid url: ", s);
487
+ continue;
488
+ }
489
+ if (c.protocol !== "http:" && c.protocol !== "https:" || c.host === t.host || e.matchesAny(c.host) === !1) continue;
490
+ r && (c.pathname = r(c.pathname)), c.protocol = t.protocol, c.hostname = t.hostname, c.port = t.port;
491
+ let l = c.toString();
492
+ i.attr(a, l);
493
+ for (let e of i.textNodes()) {
494
+ let t = e.nodeValue;
495
+ if (!t) continue;
496
+ let n = t.replaceAll(s, () => l);
497
+ t !== n && (e.nodeValue = n);
498
+ }
499
+ }
500
+ for (let e of o) T(e[0], i === !0);
501
+ return this;
502
+ };
503
+ var w = /* @__PURE__ */ new WeakMap();
504
+ function T(e, t) {
505
+ let n = e.getAttribute("src"), r = w.get(e);
506
+ if (!t || !n) {
507
+ r && (e.removeEventListener("load", r.updateVisibility), e.removeEventListener("error", r.updateVisibility), r.link.remove(), w.delete(e));
508
+ return;
509
+ }
510
+ if (!r) {
511
+ let t = e.ownerDocument.createElement("a");
512
+ t.rel = "noreferrer", t.target = "_blank";
513
+ let n = () => {
514
+ t.style.display = e.complete && e.naturalHeight > 0 ? "none" : "block";
515
+ };
516
+ r = {
517
+ link: t,
518
+ updateVisibility: n
519
+ }, w.set(e, r), e.addEventListener("load", n), e.addEventListener("error", n);
520
+ }
521
+ r.link.setAttribute("href", n), r.link.textContent = n, e.nextSibling !== r.link && e.after(r.link), r.updateVisibility();
522
+ }
523
+ //#endregion
524
+ export { g as ClickOptions };
@@ -0,0 +1,65 @@
1
+ import type { Awaitable, HTMLNode } from 'builtinx';
2
+ /** Convenience alias for a jQuery collection of builtinx HTMLNode values. */
3
+ export type JQueryNode = JQuery<HTMLNode>;
4
+ /** Receives one observer delivery and the original collection passed to observe. */
5
+ export type JQueryMutationCallback<TElement = HTMLElement> = (mutations: MutationRecord[], observer: MutationObserver, jQuery: JQuery<TElement>) => void;
6
+ /** Owns all observers created by one JQuery.observe call. */
7
+ export interface JQueryObservation {
8
+ /** Stops all observers and suppresses pending callbacks. Safe to call repeatedly. */
9
+ disconnect(): void;
10
+ }
11
+ /** Polling, timeout, cancellation and iframe options for $.waitForNodes. */
12
+ export interface WaitForNodesOptions {
13
+ /** Finite non-negative milliseconds. Defaults to 30,000; zero checks only once. */
14
+ timeoutMs?: number;
15
+ /** Finite positive milliseconds between queries. Defaults to 100. */
16
+ pollIntervalMs?: number;
17
+ /** Cancels the wait with signal.reason, including if already aborted. */
18
+ signal?: AbortSignal;
19
+ /** Discovers accessible iframe documents on every query. Defaults to false. */
20
+ includeIframes?: boolean;
21
+ }
22
+ /** URL path transformation and image fallback behavior for refineUrls. */
23
+ export interface RefineUrlsOptions {
24
+ /** Transforms the pathname of each matching external URL before changing its origin. */
25
+ pathRewrite?: (path: string) => string;
26
+ /**
27
+ * Adds/reuses a fallback link for every selected image with a src, even if its URL
28
+ * is not rewritten. Defaults to false, which removes links previously managed here.
29
+ */
30
+ addImageFallbackLinks?: boolean;
31
+ }
32
+ /** Error reporting shared by async click and keyboard handlers. */
33
+ export interface EventHandlerOptions {
34
+ /**
35
+ * Handles synchronous throws and asynchronous rejections. Defaults to console.error.
36
+ * If this callback throws or rejects, its error is also reported to console.error.
37
+ */
38
+ onError?: (error: unknown) => Awaitable<unknown>;
39
+ }
40
+ /** Resolved onClick settings. Every construction creates independent defaults. */
41
+ export declare class ClickOptions implements EventHandlerOptions {
42
+ /** Cancels the default action before invoking the handler; defaults to true. */
43
+ preventDefault: boolean;
44
+ /** Stops bubbling to ancestors; defaults to false. */
45
+ stopPropagation: boolean;
46
+ /** Also stops subsequent listeners on the same element; defaults to false. */
47
+ stopImmediatePropagation: boolean;
48
+ /** Skips reentrant calls per binding and element until the handler settles. */
49
+ disableWhileProcessing: boolean;
50
+ onError?: EventHandlerOptions['onError'];
51
+ /** Copies supplied overrides onto the defaults without mutating init. */
52
+ constructor(init?: Partial<ClickOptions>);
53
+ }
54
+ /** Text presentation data for consumers; jqueryx does not render or apply this interface itself. */
55
+ export interface JQueryTextInfo {
56
+ /** Text or number to present. */
57
+ text: string | number;
58
+ /** Optional CSS color. */
59
+ color?: string;
60
+ /** Optional class names. */
61
+ classNames?: string[];
62
+ /** Optional consumer-invoked action on a collection. */
63
+ action?: (e: JQuery) => void;
64
+ }
65
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/types/lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpD,6EAA6E;AAC7E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1C,oFAAoF;AACpF,MAAM,MAAM,sBAAsB,CAAC,QAAQ,GAAG,WAAW,IAAI,CAC3D,SAAS,EAAE,cAAc,EAAE,EAC3B,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,KACrB,IAAI,CAAC;AAEV,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB;IAClC,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,wFAAwF;IACxF,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,mEAAmE;AACnE,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC;CAClD;AAED,kFAAkF;AAClF,qBAAa,YAAa,YAAW,mBAAmB;IACtD,gFAAgF;IAChF,cAAc,EAAE,OAAO,CAAQ;IAC/B,sDAAsD;IACtD,eAAe,EAAE,OAAO,CAAS;IACjC,8EAA8E;IAC9E,wBAAwB,EAAE,OAAO,CAAS;IAC1C,+EAA+E;IAC/E,sBAAsB,EAAE,OAAO,CAAQ;IACvC,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAEzC,yEAAyE;IACzE,YAAmB,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAE9C;CACF;AAED,oGAAoG;AACpG,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,wDAAwD;IACxD,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@huoshan12345/jqueryx",
3
+ "author": "huoshan12345",
4
+ "version": "0.0.2",
5
+ "description": "Extensions for JavaScript built-ins and web platform objects",
6
+ "homepage": "https://github.com/huoshan12345/jqueryx#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/huoshan12345/jqueryx.git"
10
+ },
11
+ "type": "module",
12
+ "main": "dist/index.js",
13
+ "types": "dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "prepack": "pinst --disable",
27
+ "postpack": "pinst --enable",
28
+ "_preinstall": "npx only-allow pnpm",
29
+ "clean": "shx rm -rf dist/** && shx rm -f *.tgz",
30
+ "dev": "run-s type-check:watch",
31
+ "build": "run-s clean && run-s build:ts && run-s build:dts",
32
+ "build:ts": "run-s type-check && vite build",
33
+ "build:dts": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "type-check": "tsc --noEmit",
37
+ "type-check:watch": "tsc --noEmit --watch",
38
+ "ncu": "npx npm-check-updates -u",
39
+ "p": "run-s build && pnpm pack"
40
+ },
41
+ "devDependencies": {
42
+ "@phiberber/pinst": "^3.0.1",
43
+ "@types/node": "^26.4.1",
44
+ "builtinx": "^0.3.3",
45
+ "jquery": "^4.0.0",
46
+ "linqx": "^0.3.4",
47
+ "npm-run-all2": "^9.0.3",
48
+ "shx": "^0.4.0",
49
+ "tsc-alias": "^1.9.4",
50
+ "typescript": "^7.0.2",
51
+ "vite": "^8.2.2",
52
+ "vitest": "^4.1.1",
53
+ "vitest-canvas-mock": "^1.2.0"
54
+ },
55
+ "dependencies": {
56
+ "@types/jquery": "^4.0.1"
57
+ },
58
+ "peerDependencies": {
59
+ "builtinx": "^0.3.3",
60
+ "jquery": "^4.0.0",
61
+ "linqx": "^0.3.4"
62
+ }
63
+ }