@opentiny/utils 3.29.0 → 3.30.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.
@@ -18,9 +18,13 @@ export interface DebounceFunction extends Function {
18
18
  /**
19
19
  * 防抖函数 - 将多次触发的函数执行延迟到最后一次触发后的指定时间才执行
20
20
  *
21
+ * 仅允许设置在开始,或者在结尾执行一次的防抖行为,若需要首尾均执行一次,请使用 `debounceBoth` 函数
22
+ *
21
23
  * @param {number} delay - 延迟时间(毫秒)
22
24
  * @param {boolean | Function} atBegin - 如果为布尔值,指定是否在延迟开始前执行;如果为函数,则作为回调函数
23
25
  * @param {Function} [callback] - 需要防抖的回调函数
24
26
  * @returns {DebounceFunction} 返回一个经过防抖处理的函数
25
27
  */
26
28
  export declare function debounce(delay: number, atBegin: boolean | Function, callback?: Function): DebounceFunction;
29
+ /** 防抖函数 - 允许在延迟时间段的首尾均执行一次 */
30
+ export declare function debounceBoth(delay: number, callback: Function): DebounceFunction;
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { fastdom, fastdomAsync, fastdomSandbox } from './fastdom';
24
24
  export { FullscreenApi, sf } from './fullscreen';
25
25
  export { NODE_KEY, getNodeKey, markNodeData, getChildState, Node, TreeStore } from './tree-model';
26
26
  export { afterLeave } from './after-leave';
27
- export { debounce } from './debounce';
27
+ export { debounce, debounceBoth } from './debounce';
28
28
  export { throttle } from './throttle';
29
29
  export { on, off, once, hasClass, addClass, removeClass, getStyle, setStyle, isScroll, getScrollContainer, isInContainer, getDomNode, getScrollTop, stopPropagation, preventDefault, getScrollParent, useScrollParent, isDisplayNone } from './dom';
30
30
  export { init as initEspace, espaceCtrl } from './espace-ctrl';
package/dist/index.es.js CHANGED
@@ -4331,6 +4331,18 @@ function Ks(e, t, s, n) {
4331
4331
  function Zc(e, t, s) {
4332
4332
  return s === void 0 ? Ks(e, t, !1) : Ks(e, s, t !== !1);
4333
4333
  }
4334
+ function Vc(e, t) {
4335
+ let s = null;
4336
+ const n = function(...i) {
4337
+ const r = this, o = function() {
4338
+ s = null, t.apply(r, i);
4339
+ }, a = !s;
4340
+ clearTimeout(s), s = setTimeout(o, e), a && t.apply(r, i);
4341
+ };
4342
+ return n._cancel = function() {
4343
+ s && (clearTimeout(s), s = null);
4344
+ }, n;
4345
+ }
4334
4346
  let ve = null;
4335
4347
  const ja = "ws://localhost", Ys = [27197, 27198, 27199];
4336
4348
  let Ft = 0, Se, Vn = 1e3, Jn = 3e4, Ba = 0, us = {}, Qn;
@@ -4526,15 +4538,15 @@ if (S || !window.WebSocket) {
4526
4538
  Object.prototype.hasOwnProperty.call(k, t) && typeof k[t] == "function" && (k[t] = e);
4527
4539
  }
4528
4540
  let Gs = !1;
4529
- function Vc() {
4541
+ function Jc() {
4530
4542
  return !Gs && !S && (localStorage.setItem("eSpaceCtrl_initialized", 0), k.init({ timeout: 3e3, pollingInterval: 1e3 }), k.ready(() => {
4531
4543
  localStorage.setItem("eSpaceCtrl_initialized", 1);
4532
4544
  }), k.error(() => {
4533
4545
  localStorage.setItem("eSpaceCtrl_initialized", 0);
4534
4546
  }), Gs = !0), k;
4535
4547
  }
4536
- const Jc = k;
4537
- class Qc {
4548
+ const Qc = k;
4549
+ class ef {
4538
4550
  constructor(t, s = {}) {
4539
4551
  if (t && typeof t == "object" ? s = t : t = [], typeof s.key != "string" || !s.key)
4540
4552
  throw new Error("Memorize Initialization error.");
@@ -4821,7 +4833,7 @@ const Va = ["left", "right", "top", "bottom"], ar = ["shift", "offset", "prevent
4821
4833
  t.target.popperVm && t.contentRect.height > 50 && t.target.popperVm.update();
4822
4834
  });
4823
4835
  }) : null;
4824
- class ef {
4836
+ class tf {
4825
4837
  constructor(t, s, n) {
4826
4838
  N(this, "_reference");
4827
4839
  N(this, "_popper");
@@ -5036,13 +5048,13 @@ const he = "__resizeListeners__", rl = (e) => {
5036
5048
  n();
5037
5049
  });
5038
5050
  });
5039
- }, tf = (e, t) => {
5040
- S || (e[he] || (e[he] = [], e.__ro__ = new ai(rl), e.__ro__.observe(e)), e[he].push(t));
5041
5051
  }, sf = (e, t) => {
5052
+ S || (e[he] || (e[he] = [], e.__ro__ = new ai(rl), e.__ro__.observe(e)), e[he].push(t));
5053
+ }, nf = (e, t) => {
5042
5054
  !e || !e[he] || (e[he].splice(e[he].indexOf(t), 1), e[he].length || (e.__ro__.disconnect(), delete e.__ro__));
5043
5055
  };
5044
5056
  let ot;
5045
- function nf() {
5057
+ function rf() {
5046
5058
  if (S)
5047
5059
  return 0;
5048
5060
  if (ot !== void 0)
@@ -5058,7 +5070,7 @@ function nf() {
5058
5070
  const i = n.offsetWidth;
5059
5071
  return t.parentNode.removeChild(t), ot = s - i, ot;
5060
5072
  }
5061
- const rf = (e, t) => {
5073
+ const of = (e, t) => {
5062
5074
  if (S)
5063
5075
  return;
5064
5076
  if (!t) {
@@ -5071,9 +5083,9 @@ const rf = (e, t) => {
5071
5083
  s.push(n), n = n.offsetParent;
5072
5084
  const o = i + s.reduce((u, c) => u + c.offsetTop, 0), a = o + r, l = e.scrollTop, f = l + e.clientHeight;
5073
5085
  o < l ? e.scrollTop = o : a > f && (e.scrollTop = a - e.clientHeight);
5074
- }, en = 10, il = (e, t) => e > t && e > en ? "horizontal" : t > e && t > en ? "vertical" : "", of = (e) => (t) => {
5086
+ }, en = 10, il = (e, t) => e > t && e > en ? "horizontal" : t > e && t > en ? "vertical" : "", af = (e) => (t) => {
5075
5087
  ol(e), e.startX = t.touches[0].clientX, e.startY = t.touches[0].clientY;
5076
- }, af = (e) => (t) => {
5088
+ }, lf = (e) => (t) => {
5077
5089
  const s = t.touches[0];
5078
5090
  e.deltaX = s.clientX - e.startX, e.deltaY = s.clientY - e.startY, e.offsetX = Math.abs(e.deltaX), e.offsetY = Math.abs(e.deltaY), e.direction = e.direction || il(e.offsetX, e.offsetY);
5079
5091
  }, ol = (e) => {
@@ -5106,7 +5118,7 @@ const dr = () => {
5106
5118
  t.type === "mousedown" && (It = !0), t.type === "mouseup" && (It = !1), !(t.type === "mousemove" && !It) && ((t.type === "mousedown" || !at) && (at = t.target), Me = ll(at, "[data-tiny-touch-simulate-container]"), Me && Me.dispatchEvent && fl(e, t), t.type === "mouseup" && (Me = null, at = null));
5107
5119
  }, ul = () => {
5108
5120
  window.addEventListener("mousedown", Lt("touchstart"), !0), window.addEventListener("mousemove", Lt("touchmove"), !0), window.addEventListener("mouseup", Lt("touchend"), !0);
5109
- }, lf = () => {
5121
+ }, cf = () => {
5110
5122
  if (!S) {
5111
5123
  const e = "ontouchstart" in window;
5112
5124
  !tn && !e && (tn = !0, ul());
@@ -5125,7 +5137,7 @@ const dr = () => {
5125
5137
  s.response ? n = s.response.error || s.response : s.responseText ? n = s.responseText : n = `fail to post ${e} ${s.status}`;
5126
5138
  const i = new Error(n);
5127
5139
  return i.status = s.status, i.method = "post", i.url = e, i;
5128
- }, cf = (e) => {
5140
+ }, ff = (e) => {
5129
5141
  if (typeof XMLHttpRequest > "u")
5130
5142
  return;
5131
5143
  const t = new XMLHttpRequest(), s = Mr.filterUrl(e.action);
@@ -5148,7 +5160,7 @@ const dr = () => {
5148
5160
  for (let r in i)
5149
5161
  A.call(i, r) && i[r] !== null && t.setRequestHeader(r, i[r]);
5150
5162
  return t.send(n), t;
5151
- }, ff = { logger: zt };
5163
+ }, uf = { logger: zt };
5152
5164
  export {
5153
5165
  ac as BROWSER_NAME,
5154
5166
  Ye as BigIntDecimal,
@@ -5162,12 +5174,12 @@ export {
5162
5174
  ic as IPTHRESHOLD,
5163
5175
  mo as KEY_CODE,
5164
5176
  lc as MOUSEDELTA,
5165
- Qc as Memorize,
5177
+ ef as Memorize,
5166
5178
  Oe as NODE_KEY,
5167
5179
  Ue as Node,
5168
5180
  we as NumberDecimal,
5169
5181
  nc as POSITION,
5170
- ef as PopperJS,
5182
+ tf as PopperJS,
5171
5183
  $ as PopupManager,
5172
5184
  rc as REFRESH_INTERVAL,
5173
5185
  ai as ResizeObserver,
@@ -5176,10 +5188,10 @@ export {
5176
5188
  cc as VALIDATE_STATE,
5177
5189
  Hc as Validator,
5178
5190
  et as addClass,
5179
- tf as addResizeListener,
5191
+ sf as addResizeListener,
5180
5192
  Gc as afterLeave,
5181
5193
  bl as browserInfo,
5182
- nf as calcScrollWidth,
5194
+ rf as calcScrollWidth,
5183
5195
  Kc as callInterceptor,
5184
5196
  kl as camelize,
5185
5197
  Rl as capitalize,
@@ -5190,14 +5202,15 @@ export {
5190
5202
  Ht as copyField,
5191
5203
  Wc as correctTarget,
5192
5204
  Zc as debounce,
5205
+ Vc as debounceBoth,
5193
5206
  _s as each,
5194
5207
  jc as emitEvent,
5195
- lf as emulate,
5208
+ cf as emulate,
5196
5209
  Cl as equalsDecimal,
5197
5210
  zl as escape,
5198
5211
  Yt as escapeChars,
5199
5212
  gt as escapeHtml,
5200
- Jc as espaceCtrl,
5213
+ Qc as espaceCtrl,
5201
5214
  ke as extend,
5202
5215
  Oc as extractDateFormat,
5203
5216
  Cc as extractTimeFormat,
@@ -5252,7 +5265,7 @@ export {
5252
5265
  A as hasOwn,
5253
5266
  Il as hyphenate,
5254
5267
  wt as indexOf,
5255
- Vc as initEspace,
5268
+ Jc as initEspace,
5256
5269
  Le as isDate,
5257
5270
  jn as isDate1,
5258
5271
  uc as isDateObject,
@@ -5279,7 +5292,7 @@ export {
5279
5292
  po as lastMonth,
5280
5293
  Dl as lessEquals,
5281
5294
  ko as limitTimeRange,
5282
- ff as log,
5295
+ uf as log,
5283
5296
  zt as logger,
5284
5297
  js as markNodeData,
5285
5298
  Ms as merge,
@@ -5310,10 +5323,10 @@ export {
5310
5323
  Fl as recoverNumber,
5311
5324
  kc as remove,
5312
5325
  tt as removeClass,
5313
- sf as removeResizeListener,
5326
+ nf as removeResizeListener,
5314
5327
  ol as resetTouchStatus,
5315
5328
  Tn as roundFixed,
5316
- rf as scrollIntoView,
5329
+ of as scrollIntoView,
5317
5330
  Ai as setDecimalClass,
5318
5331
  As as setObj,
5319
5332
  Pr as setStyle,
@@ -5340,8 +5353,8 @@ export {
5340
5353
  Pc as toObject,
5341
5354
  Kl as toRate,
5342
5355
  dn as toString,
5343
- af as touchMove,
5344
- of as touchStart,
5356
+ lf as touchMove,
5357
+ af as touchStart,
5345
5358
  tc as transformArray,
5346
5359
  Lo as transformPidToChildren,
5347
5360
  Po as transformTreeData,
@@ -5354,7 +5367,7 @@ export {
5354
5367
  Hl as tryToNumber,
5355
5368
  B as typeOf,
5356
5369
  Lc as unique,
5357
- cf as uploadAjax,
5370
+ ff as uploadAjax,
5358
5371
  Al as useScrollParent,
5359
5372
  An as validateNumber,
5360
5373
  Fc as validateRangeInOneMonth,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opentiny/utils",
3
3
  "type": "module",
4
- "version": "3.29.0",
4
+ "version": "3.30.0",
5
5
  "description": "nanoid console xss",
6
6
  "author": "",
7
7
  "license": "ISC",