@t007/utils 0.0.15 → 0.0.16

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 CHANGED
@@ -22,14 +22,14 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  VIRTUAL_RESOURCE: () => VIRTUAL_RESOURCE,
24
24
  assignEl: () => assignEl,
25
- bindAllMethods: () => bindAllMethods,
25
+ bindAllMethods: () => import_utils4.bindAllMethods,
26
26
  bindCleanupToSignal: () => bindCleanupToSignal,
27
27
  breath: () => breath,
28
- clamp: () => clamp,
28
+ clamp: () => import_utils2.clamp,
29
29
  createEl: () => createEl,
30
30
  deepBreath: () => deepBreath,
31
- guardAllMethods: () => guardAllMethods,
32
- guardMethod: () => guardMethod,
31
+ guardAllMethods: () => import_utils4.guardAllMethods,
32
+ guardMethod: () => import_utils4.guardMethod,
33
33
  inBoolArrOpt: () => inBoolArrOpt,
34
34
  initScrollAssist: () => initScrollAssist,
35
35
  initVScrollerator: () => initVScrollerator,
@@ -39,7 +39,7 @@ __export(index_exports, {
39
39
  isFunc: () => isFunc,
40
40
  isIter: () => isIter,
41
41
  isNum: () => isNum,
42
- isObj: () => isObj,
42
+ isObj: () => import_utils.isObj,
43
43
  isPOJO: () => isPOJO,
44
44
  isSameURL: () => isSameURL,
45
45
  isStr: () => isStr,
@@ -47,50 +47,15 @@ __export(index_exports, {
47
47
  limited: () => limited,
48
48
  loadResource: () => loadResource,
49
49
  mockAsync: () => mockAsync,
50
- onAllMethods: () => onAllMethods,
50
+ onAllMethods: () => import_utils4.onAllMethods,
51
51
  removeScrollAssist: () => removeScrollAssist,
52
- requestAnimationFrame: () => requestAnimationFrame2,
53
- setInterval: () => setInterval,
54
- setTimeout: () => setTimeout2,
52
+ requestAnimationFrame: () => import_utils3.requestAnimationFrame,
53
+ setInterval: () => import_utils3.setInterval,
54
+ setTimeout: () => import_utils3.setTimeout,
55
55
  uid: () => uid
56
56
  });
57
57
  module.exports = __toCommonJS(index_exports);
58
58
 
59
- // src/core/obj.ts
60
- function isDef(val) {
61
- return "undefined" !== typeof val;
62
- }
63
- function isSym(val) {
64
- return "symbol" === typeof val;
65
- }
66
- function isBool(val) {
67
- return "boolean" === typeof val;
68
- }
69
- function isNum(val) {
70
- return "number" === typeof val;
71
- }
72
- function isStr(val) {
73
- return "string" === typeof val;
74
- }
75
- function isArr(obj) {
76
- return Array.isArray(obj);
77
- }
78
- function isObj(obj, arraycheck = true) {
79
- return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
80
- }
81
- function isPOJO(obj, crossRealms = false, typecheck = true) {
82
- return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
83
- }
84
- function isIter(obj) {
85
- return obj != null && "function" === typeof obj[Symbol.iterator];
86
- }
87
- function isFunc(val) {
88
- return "function" === typeof val;
89
- }
90
- function inBoolArrOpt(opt, str) {
91
- return opt?.includes?.(str) ?? opt;
92
- }
93
-
94
59
  // src/core/dom.ts
95
60
  function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
96
61
  return assignEl(el, props, dataset, styles), el;
@@ -136,10 +101,41 @@ function loadResource(req, type = "style", { module: module2, media, crossOrigin
136
101
  return w.t007._resourceCache[src];
137
102
  }
138
103
 
139
- // src/core/num.ts
140
- function clamp(min = 0, val, max = Infinity) {
141
- return Math.min(Math.max(val, min), max);
104
+ // src/core/obj.ts
105
+ var import_utils = require("sia-reactor/utils");
106
+ function isDef(val) {
107
+ return "undefined" !== typeof val;
108
+ }
109
+ function isSym(val) {
110
+ return "symbol" === typeof val;
142
111
  }
112
+ function isBool(val) {
113
+ return "boolean" === typeof val;
114
+ }
115
+ function isNum(val) {
116
+ return "number" === typeof val;
117
+ }
118
+ function isStr(val) {
119
+ return "string" === typeof val;
120
+ }
121
+ function isArr(obj) {
122
+ return Array.isArray(obj);
123
+ }
124
+ function isPOJO(obj, crossRealms = false, typecheck = true) {
125
+ return (typecheck ? (0, import_utils.isObj)(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
126
+ }
127
+ function isIter(obj) {
128
+ return obj != null && "function" === typeof obj[Symbol.iterator];
129
+ }
130
+ function isFunc(val) {
131
+ return "function" === typeof val;
132
+ }
133
+ function inBoolArrOpt(opt, str) {
134
+ return opt?.includes?.(str) ?? opt;
135
+ }
136
+
137
+ // src/core/num.ts
138
+ var import_utils2 = require("sia-reactor/utils");
143
139
 
144
140
  // src/core/str.ts
145
141
  function uid(prefix = "") {
@@ -156,26 +152,7 @@ function isSameURL(src1, src2) {
156
152
  }
157
153
 
158
154
  // src/core/fn.ts
159
- function setTimeout2(handler, timeout, ...args) {
160
- const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
161
- if (sig?.aborted) return -1;
162
- const w = args[0] instanceof Window ? args.shift() : window;
163
- if (!sig) return w.setTimeout(handler, timeout, ...args);
164
- const id = w.setTimeout(() => (sig.removeEventListener("abort", kill), isStr(handler) ? new Function(handler) : handler(...args)), timeout), kill = () => w.clearTimeout(id);
165
- return sig.addEventListener("abort", kill, { once: true }), id;
166
- }
167
- function setInterval(handler, timeout, ...args) {
168
- const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
169
- if (sig?.aborted) return -1;
170
- const w = args[0] instanceof Window ? args.shift() : window, id = w.setInterval(handler, timeout, ...args);
171
- return sig?.addEventListener("abort", () => w.clearInterval(id), { once: true }), id;
172
- }
173
- function requestAnimationFrame2(callback, sig, w = window) {
174
- if (sig?.aborted) return -1;
175
- if (!sig) return w.requestAnimationFrame(callback);
176
- const id = w.requestAnimationFrame((t) => (sig.removeEventListener("abort", kill), callback(t))), kill = () => w.cancelAnimationFrame(id);
177
- return sig.addEventListener("abort", kill, { once: true }), id;
178
- }
155
+ var import_utils3 = require("sia-reactor/utils");
179
156
  function limited(FN_KEY, fn, opts = {}) {
180
157
  let count = 0, { key, maxTimes: max = 1 } = isStr(opts) ? { key: opts } : opts;
181
158
  const getReg = () => JSON.parse(localStorage.getItem(FN_KEY) || "{}"), setReg = (r) => localStorage.setItem(FN_KEY, JSON.stringify(r));
@@ -189,7 +166,7 @@ function limited(FN_KEY, fn, opts = {}) {
189
166
  handle.block = () => (count = max, key && ((r) => (r[key] = max, setReg(r)))(getReg()));
190
167
  return handle;
191
168
  }
192
- var mockAsync = (timeout = 250) => new Promise((resolve) => setTimeout2(resolve, timeout));
169
+ var mockAsync = (timeout = 250) => new Promise((resolve) => setTimeout(resolve, timeout));
193
170
  var breath = (w = window) => new Promise((res) => w.requestAnimationFrame(res));
194
171
  var deepBreath = (w = window) => new Promise((res) => w.requestAnimationFrame(() => w.requestAnimationFrame(res)));
195
172
  function bindCleanupToSignal(cleanup, signal) {
@@ -198,38 +175,8 @@ function bindCleanupToSignal(cleanup, signal) {
198
175
  return cleanup;
199
176
  }
200
177
 
201
- // src/mixins/methodist.ts
202
- function onAllMethods(owner, callback, skipNestedOwn = true, nested = false) {
203
- let proto = owner;
204
- while (proto && proto !== Object.prototype) {
205
- for (const method of Object.getOwnPropertyNames(proto)) {
206
- if (method === "constructor") continue;
207
- if (nested && skipNestedOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;
208
- if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
209
- }
210
- proto = Object.getPrototypeOf(proto), nested = true;
211
- }
212
- }
213
- function bindAllMethods(owner) {
214
- onAllMethods(owner, (method, owner2) => {
215
- owner2[method] = owner2[method].bind(owner2);
216
- });
217
- }
218
- function guardAllMethods(owner, guardFn = guardMethod, bound = true) {
219
- onAllMethods(owner, (method, owner2) => {
220
- owner2[method] = guardFn(bound ? owner2[method].bind(owner2) : owner2[method]);
221
- });
222
- }
223
- function guardMethod(fn, onError = (e) => console.error(e)) {
224
- return ((...args) => {
225
- try {
226
- const result = fn(...args);
227
- return result instanceof Promise ? result.catch((e) => onError(e)) : result;
228
- } catch (e) {
229
- onError(e);
230
- }
231
- });
232
- }
178
+ // src/core/methd.ts
179
+ var import_utils4 = require("sia-reactor/utils");
233
180
 
234
181
  // src/quirks/scroll.ts
235
182
  function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, baseRate = 16, lineHeight = 80, margin = 80, car = window } = {}) {
@@ -320,7 +267,7 @@ function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "tmg-video-c
320
267
  var removeScrollAssist = (el) => t007._scrollers.get(el)?.destroy();
321
268
 
322
269
  // src/index.ts
323
- if (isDef(window)) {
270
+ if ("undefined" !== typeof window) {
324
271
  window.t007 ??= {};
325
272
  t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
326
273
  window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ export { bindAllMethods, clamp, guardAllMethods, guardMethod, isObj, onAllMethods, requestAnimationFrame, setInterval, setTimeout } from 'sia-reactor/utils';
2
+
1
3
  interface ScrolleratorOptions {
2
4
  baseSpeed?: number;
3
5
  maxSpeed?: number;
@@ -56,20 +58,15 @@ declare function isBool<T extends boolean = boolean>(val: any): val is T;
56
58
  declare function isNum<T extends number = number>(val: any): val is T;
57
59
  declare function isStr<T extends string = string>(val: any): val is T;
58
60
  declare function isArr<T = unknown>(obj: any): obj is T[];
59
- declare function isObj<T extends object = object>(obj: any, arraycheck?: boolean): obj is T;
61
+
60
62
  declare function isPOJO<T extends object = object>(obj: any, crossRealms?: boolean, typecheck?: boolean): obj is T;
61
63
  declare function isIter<T = unknown>(obj: any): obj is Iterable<T>;
62
64
  declare function isFunc<T extends Function = Function>(val: any): val is T;
63
65
  declare function inBoolArrOpt(opt: any, str: string): boolean;
64
66
 
65
- declare function clamp(min: number | undefined, val: number, max?: number): number;
66
-
67
67
  declare function uid(prefix?: string): string;
68
68
  declare function isSameURL(src1: unknown, src2: unknown): boolean;
69
69
 
70
- declare function setTimeout(handler: TimerHandler, timeout?: number, ...args: any[]): number;
71
- declare function setInterval(handler: TimerHandler, timeout?: number, ...args: any[]): number;
72
- declare function requestAnimationFrame(callback: FrameRequestCallback, sig?: AbortSignal, w?: Window & typeof globalThis): number;
73
70
  interface LimitedOptions {
74
71
  key?: string /** Key for localStorage persistence (if omitted, uses session-only) */;
75
72
  maxTimes?: number /** Max times to call (default: 1) */;
@@ -108,9 +105,4 @@ declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>,
108
105
  declare const VIRTUAL_RESOURCE: unique symbol;
109
106
  declare function loadResource(req: string | symbol, type?: ResourceType, { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts, retryKey }?: LoadResourceOptions, w?: Window & typeof globalThis): Promise<HTMLElement | void>;
110
107
 
111
- declare function onAllMethods(owner: any, callback: (method: string, owner: any) => void, skipNestedOwn?: boolean, nested?: boolean): void;
112
- declare function bindAllMethods(owner: any): void;
113
- declare function guardAllMethods(owner: any, guardFn?: (fn: Function) => Function, bound?: boolean): void;
114
- declare function guardMethod<T extends Function>(fn: T, onError?: (e: any) => void): T;
115
-
116
- export { type Dataset, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindAllMethods, bindCleanupToSignal, breath, clamp, createEl, deepBreath, guardAllMethods, guardMethod, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isObj, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, onAllMethods, removeScrollAssist, requestAnimationFrame, setInterval, setTimeout, uid };
108
+ export { type Dataset, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindCleanupToSignal, breath, createEl, deepBreath, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, removeScrollAssist, uid };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { bindAllMethods, clamp, guardAllMethods, guardMethod, isObj, onAllMethods, requestAnimationFrame, setInterval, setTimeout } from 'sia-reactor/utils';
2
+
1
3
  interface ScrolleratorOptions {
2
4
  baseSpeed?: number;
3
5
  maxSpeed?: number;
@@ -56,20 +58,15 @@ declare function isBool<T extends boolean = boolean>(val: any): val is T;
56
58
  declare function isNum<T extends number = number>(val: any): val is T;
57
59
  declare function isStr<T extends string = string>(val: any): val is T;
58
60
  declare function isArr<T = unknown>(obj: any): obj is T[];
59
- declare function isObj<T extends object = object>(obj: any, arraycheck?: boolean): obj is T;
61
+
60
62
  declare function isPOJO<T extends object = object>(obj: any, crossRealms?: boolean, typecheck?: boolean): obj is T;
61
63
  declare function isIter<T = unknown>(obj: any): obj is Iterable<T>;
62
64
  declare function isFunc<T extends Function = Function>(val: any): val is T;
63
65
  declare function inBoolArrOpt(opt: any, str: string): boolean;
64
66
 
65
- declare function clamp(min: number | undefined, val: number, max?: number): number;
66
-
67
67
  declare function uid(prefix?: string): string;
68
68
  declare function isSameURL(src1: unknown, src2: unknown): boolean;
69
69
 
70
- declare function setTimeout(handler: TimerHandler, timeout?: number, ...args: any[]): number;
71
- declare function setInterval(handler: TimerHandler, timeout?: number, ...args: any[]): number;
72
- declare function requestAnimationFrame(callback: FrameRequestCallback, sig?: AbortSignal, w?: Window & typeof globalThis): number;
73
70
  interface LimitedOptions {
74
71
  key?: string /** Key for localStorage persistence (if omitted, uses session-only) */;
75
72
  maxTimes?: number /** Max times to call (default: 1) */;
@@ -108,9 +105,4 @@ declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>,
108
105
  declare const VIRTUAL_RESOURCE: unique symbol;
109
106
  declare function loadResource(req: string | symbol, type?: ResourceType, { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts, retryKey }?: LoadResourceOptions, w?: Window & typeof globalThis): Promise<HTMLElement | void>;
110
107
 
111
- declare function onAllMethods(owner: any, callback: (method: string, owner: any) => void, skipNestedOwn?: boolean, nested?: boolean): void;
112
- declare function bindAllMethods(owner: any): void;
113
- declare function guardAllMethods(owner: any, guardFn?: (fn: Function) => Function, bound?: boolean): void;
114
- declare function guardMethod<T extends Function>(fn: T, onError?: (e: any) => void): T;
115
-
116
- export { type Dataset, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindAllMethods, bindCleanupToSignal, breath, clamp, createEl, deepBreath, guardAllMethods, guardMethod, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isObj, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, onAllMethods, removeScrollAssist, requestAnimationFrame, setInterval, setTimeout, uid };
108
+ export { type Dataset, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindCleanupToSignal, breath, createEl, deepBreath, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, removeScrollAssist, uid };
package/dist/index.js CHANGED
@@ -1,38 +1,3 @@
1
- // src/core/obj.ts
2
- function isDef(val) {
3
- return "undefined" !== typeof val;
4
- }
5
- function isSym(val) {
6
- return "symbol" === typeof val;
7
- }
8
- function isBool(val) {
9
- return "boolean" === typeof val;
10
- }
11
- function isNum(val) {
12
- return "number" === typeof val;
13
- }
14
- function isStr(val) {
15
- return "string" === typeof val;
16
- }
17
- function isArr(obj) {
18
- return Array.isArray(obj);
19
- }
20
- function isObj(obj, arraycheck = true) {
21
- return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
22
- }
23
- function isPOJO(obj, crossRealms = false, typecheck = true) {
24
- return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
25
- }
26
- function isIter(obj) {
27
- return obj != null && "function" === typeof obj[Symbol.iterator];
28
- }
29
- function isFunc(val) {
30
- return "function" === typeof val;
31
- }
32
- function inBoolArrOpt(opt, str) {
33
- return opt?.includes?.(str) ?? opt;
34
- }
35
-
36
1
  // src/core/dom.ts
37
2
  function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
38
3
  return assignEl(el, props, dataset, styles), el;
@@ -78,10 +43,41 @@ function loadResource(req, type = "style", { module, media, crossOrigin, integri
78
43
  return w.t007._resourceCache[src];
79
44
  }
80
45
 
81
- // src/core/num.ts
82
- function clamp(min = 0, val, max = Infinity) {
83
- return Math.min(Math.max(val, min), max);
46
+ // src/core/obj.ts
47
+ import { isObj } from "sia-reactor/utils";
48
+ function isDef(val) {
49
+ return "undefined" !== typeof val;
50
+ }
51
+ function isSym(val) {
52
+ return "symbol" === typeof val;
84
53
  }
54
+ function isBool(val) {
55
+ return "boolean" === typeof val;
56
+ }
57
+ function isNum(val) {
58
+ return "number" === typeof val;
59
+ }
60
+ function isStr(val) {
61
+ return "string" === typeof val;
62
+ }
63
+ function isArr(obj) {
64
+ return Array.isArray(obj);
65
+ }
66
+ function isPOJO(obj, crossRealms = false, typecheck = true) {
67
+ return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
68
+ }
69
+ function isIter(obj) {
70
+ return obj != null && "function" === typeof obj[Symbol.iterator];
71
+ }
72
+ function isFunc(val) {
73
+ return "function" === typeof val;
74
+ }
75
+ function inBoolArrOpt(opt, str) {
76
+ return opt?.includes?.(str) ?? opt;
77
+ }
78
+
79
+ // src/core/num.ts
80
+ import { clamp } from "sia-reactor/utils";
85
81
 
86
82
  // src/core/str.ts
87
83
  function uid(prefix = "") {
@@ -98,26 +94,7 @@ function isSameURL(src1, src2) {
98
94
  }
99
95
 
100
96
  // src/core/fn.ts
101
- function setTimeout2(handler, timeout, ...args) {
102
- const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
103
- if (sig?.aborted) return -1;
104
- const w = args[0] instanceof Window ? args.shift() : window;
105
- if (!sig) return w.setTimeout(handler, timeout, ...args);
106
- const id = w.setTimeout(() => (sig.removeEventListener("abort", kill), isStr(handler) ? new Function(handler) : handler(...args)), timeout), kill = () => w.clearTimeout(id);
107
- return sig.addEventListener("abort", kill, { once: true }), id;
108
- }
109
- function setInterval(handler, timeout, ...args) {
110
- const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
111
- if (sig?.aborted) return -1;
112
- const w = args[0] instanceof Window ? args.shift() : window, id = w.setInterval(handler, timeout, ...args);
113
- return sig?.addEventListener("abort", () => w.clearInterval(id), { once: true }), id;
114
- }
115
- function requestAnimationFrame2(callback, sig, w = window) {
116
- if (sig?.aborted) return -1;
117
- if (!sig) return w.requestAnimationFrame(callback);
118
- const id = w.requestAnimationFrame((t) => (sig.removeEventListener("abort", kill), callback(t))), kill = () => w.cancelAnimationFrame(id);
119
- return sig.addEventListener("abort", kill, { once: true }), id;
120
- }
97
+ import { setTimeout as setTimeout2, setInterval, requestAnimationFrame as requestAnimationFrame2 } from "sia-reactor/utils";
121
98
  function limited(FN_KEY, fn, opts = {}) {
122
99
  let count = 0, { key, maxTimes: max = 1 } = isStr(opts) ? { key: opts } : opts;
123
100
  const getReg = () => JSON.parse(localStorage.getItem(FN_KEY) || "{}"), setReg = (r) => localStorage.setItem(FN_KEY, JSON.stringify(r));
@@ -131,7 +108,7 @@ function limited(FN_KEY, fn, opts = {}) {
131
108
  handle.block = () => (count = max, key && ((r) => (r[key] = max, setReg(r)))(getReg()));
132
109
  return handle;
133
110
  }
134
- var mockAsync = (timeout = 250) => new Promise((resolve) => setTimeout2(resolve, timeout));
111
+ var mockAsync = (timeout = 250) => new Promise((resolve) => setTimeout(resolve, timeout));
135
112
  var breath = (w = window) => new Promise((res) => w.requestAnimationFrame(res));
136
113
  var deepBreath = (w = window) => new Promise((res) => w.requestAnimationFrame(() => w.requestAnimationFrame(res)));
137
114
  function bindCleanupToSignal(cleanup, signal) {
@@ -140,38 +117,8 @@ function bindCleanupToSignal(cleanup, signal) {
140
117
  return cleanup;
141
118
  }
142
119
 
143
- // src/mixins/methodist.ts
144
- function onAllMethods(owner, callback, skipNestedOwn = true, nested = false) {
145
- let proto = owner;
146
- while (proto && proto !== Object.prototype) {
147
- for (const method of Object.getOwnPropertyNames(proto)) {
148
- if (method === "constructor") continue;
149
- if (nested && skipNestedOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;
150
- if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
151
- }
152
- proto = Object.getPrototypeOf(proto), nested = true;
153
- }
154
- }
155
- function bindAllMethods(owner) {
156
- onAllMethods(owner, (method, owner2) => {
157
- owner2[method] = owner2[method].bind(owner2);
158
- });
159
- }
160
- function guardAllMethods(owner, guardFn = guardMethod, bound = true) {
161
- onAllMethods(owner, (method, owner2) => {
162
- owner2[method] = guardFn(bound ? owner2[method].bind(owner2) : owner2[method]);
163
- });
164
- }
165
- function guardMethod(fn, onError = (e) => console.error(e)) {
166
- return ((...args) => {
167
- try {
168
- const result = fn(...args);
169
- return result instanceof Promise ? result.catch((e) => onError(e)) : result;
170
- } catch (e) {
171
- onError(e);
172
- }
173
- });
174
- }
120
+ // src/core/methd.ts
121
+ import { onAllMethods, bindAllMethods, guardAllMethods, guardMethod } from "sia-reactor/utils";
175
122
 
176
123
  // src/quirks/scroll.ts
177
124
  function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, baseRate = 16, lineHeight = 80, margin = 80, car = window } = {}) {
@@ -262,7 +209,7 @@ function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "tmg-video-c
262
209
  var removeScrollAssist = (el) => t007._scrollers.get(el)?.destroy();
263
210
 
264
211
  // src/index.ts
265
- if (isDef(window)) {
212
+ if ("undefined" !== typeof window) {
266
213
  window.t007 ??= {};
267
214
  t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
268
215
  window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t007/utils",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "High-performance, zero-dependency utility functions for the t007 ecosystem.",
5
5
  "author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
6
6
  "license": "MIT",
@@ -43,5 +43,8 @@
43
43
  "dom-manipulation",
44
44
  "shared-logic",
45
45
  "performance"
46
- ]
46
+ ],
47
+ "dependencies": {
48
+ "sia-reactor": "^0.0.16"
49
+ }
47
50
  }