@t007/utils 0.0.31 → 0.0.33

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.
@@ -90,15 +90,18 @@ function parseCSSTime(time) {
90
90
  function parseCSSSize(size, el) {
91
91
  return size?.endsWith?.("px") ? parseFloat(size) : remToPx(parseFloat(size), el);
92
92
  }
93
- function isSameURL(src1, src2) {
94
- if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
93
+ function cleanURL(url) {
95
94
  try {
96
- const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
97
- return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
95
+ const u = new URL(url, window.location.href);
96
+ return decodeURIComponent(u.origin + u.pathname);
98
97
  } catch {
99
- return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
98
+ return url.replace(/\\/g, "/").split("?")[0].trim();
100
99
  }
101
100
  }
101
+ function isSameURL(url1, url2) {
102
+ if (!isStr(url1) || !isStr(url2) || !url1 || !url2) return false;
103
+ return cleanURL(url1) === cleanURL(url2);
104
+ }
102
105
 
103
106
  // src/ts/core/fn.ts
104
107
  import { setTimeout as setTimeout2, setInterval, requestAnimationFrame } from "sia-reactor/utils";
@@ -174,6 +177,7 @@ export {
174
177
  pxToRem,
175
178
  parseCSSTime,
176
179
  parseCSSSize,
180
+ cleanURL,
177
181
  isSameURL,
178
182
  limited,
179
183
  mockAsync,
@@ -4,7 +4,7 @@ import {
4
4
  createEl,
5
5
  getActiveEl,
6
6
  isInteractive
7
- } from "./chunk-Y5YJMRXD.js";
7
+ } from "./chunk-4O76EZJ4.js";
8
8
 
9
9
  // src/ts/hooks/vanilla/outsideClick.ts
10
10
  import { NIL, NOOP } from "sia-reactor";
@@ -11,11 +11,11 @@ import {
11
11
  initFocusTrap,
12
12
  initOutsideClick,
13
13
  rippleHandler
14
- } from "../chunk-LBDWVTYF.js";
14
+ } from "../chunk-QJ72EQCJ.js";
15
15
  import {
16
16
  INTERACTIVE_SELECTOR,
17
17
  getActiveEl
18
- } from "../chunk-Y5YJMRXD.js";
18
+ } from "../chunk-4O76EZJ4.js";
19
19
 
20
20
  // src/ts/hooks/react/useScrollAssist.ts
21
21
  import { useEffect, useRef, useCallback } from "react";
@@ -10,12 +10,12 @@ import {
10
10
  removeFocusTrap,
11
11
  removeOutsideClick,
12
12
  rippleHandler
13
- } from "../chunk-LBDWVTYF.js";
13
+ } from "../chunk-QJ72EQCJ.js";
14
14
  import {
15
15
  INTERACTIVE_SELECTOR,
16
16
  createEl,
17
17
  getActiveEl
18
- } from "../chunk-Y5YJMRXD.js";
18
+ } from "../chunk-4O76EZJ4.js";
19
19
 
20
20
  // src/ts/hooks/vanilla/scrollAssist.ts
21
21
  import { NIL } from "sia-reactor";
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ __export(index_exports, {
30
30
  breath: () => breath,
31
31
  clamp: () => import_utils4.clamp,
32
32
  cleanKeyCombo: () => import_utils6.cleanKeyCombo,
33
+ cleanURL: () => cleanURL,
33
34
  createEl: () => import_utils.createEl,
34
35
  deepBreath: () => deepBreath,
35
36
  formatKeyForDisplay: () => import_utils6.formatKeyForDisplay,
@@ -165,15 +166,18 @@ function parseCSSTime(time) {
165
166
  function parseCSSSize(size, el) {
166
167
  return size?.endsWith?.("px") ? parseFloat(size) : remToPx(parseFloat(size), el);
167
168
  }
168
- function isSameURL(src1, src2) {
169
- if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
169
+ function cleanURL(url) {
170
170
  try {
171
- const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
172
- return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
171
+ const u = new URL(url, window.location.href);
172
+ return decodeURIComponent(u.origin + u.pathname);
173
173
  } catch {
174
- return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
174
+ return url.replace(/\\/g, "/").split("?")[0].trim();
175
175
  }
176
176
  }
177
+ function isSameURL(url1, url2) {
178
+ if (!isStr(url1) || !isStr(url2) || !url1 || !url2) return false;
179
+ return cleanURL(url1) === cleanURL(url2);
180
+ }
177
181
 
178
182
  // src/ts/core/fn.ts
179
183
  var import_utils5 = require("sia-reactor/utils");
@@ -234,6 +238,7 @@ if ("undefined" !== typeof window) {
234
238
  breath,
235
239
  clamp,
236
240
  cleanKeyCombo,
241
+ cleanURL,
237
242
  createEl,
238
243
  deepBreath,
239
244
  formatKeyForDisplay,
package/dist/index.d.cts CHANGED
@@ -20,18 +20,18 @@ declare global {
20
20
  interface Window {
21
21
  /** Shared T007 namespace. */
22
22
  t007: T007Namespace;
23
- /** CDN entrypoint for @t007/toast. */
24
- T007_TOAST_JS_SRC?: string;
25
- /** CDN entrypoint for @t007/input. */
26
- T007_INPUT_JS_SRC?: string;
27
- /** CDN entrypoint for @t007/dialog. */
28
- T007_DIALOG_JS_SRC?: string;
29
- /** CDN stylesheet for @t007/toast. */
30
- T007_TOAST_CSS_SRC?: string;
31
- /** CDN stylesheet for @t007/input. */
32
- T007_INPUT_CSS_SRC?: string;
33
- /** CDN stylesheet for @t007/dialog. */
34
- T007_DIALOG_CSS_SRC?: string;
23
+ /** CDN js entrypoint for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
24
+ T007_TOAST_JS_SRC?: string | symbol;
25
+ /** CDN js entrypoint for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
26
+ T007_INPUT_JS_SRC?: string | symbol;
27
+ /** CDN js entrypoint for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
28
+ T007_DIALOG_JS_SRC?: string | symbol;
29
+ /** CDN stylesheet for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
30
+ T007_TOAST_CSS_SRC?: string | symbol;
31
+ /** CDN stylesheet for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
32
+ T007_INPUT_CSS_SRC?: string | symbol;
33
+ /** CDN stylesheet for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
34
+ T007_DIALOG_CSS_SRC?: string | symbol;
35
35
  }
36
36
  /** Shared T007 namespace on the global object. */
37
37
  var t007: T007Namespace;
@@ -77,12 +77,17 @@ declare function parseCSSTime(time: any): number;
77
77
  * @returns The equivalent value in pixels.
78
78
  */
79
79
  declare function parseCSSSize(size: any, el?: HTMLElement): number;
80
+ /** Normalize a URL by decoding it and removing query parameters and hash fragments.
81
+ * @param url The URL string to clean.
82
+ * @returns A normalized URL string for comparison.
83
+ */
84
+ declare function cleanURL(url: string): string;
80
85
  /** Compare two URLs after normalizing origin, pathname, and separators.
81
- * @param src1 First URL or path.
82
- * @param src2 Second URL or path.
86
+ * @param url1 First URL or path.
87
+ * @param url2 Second URL or path.
83
88
  * @returns True when both references point to the same resource.
84
89
  */
85
- declare function isSameURL(src1: unknown, src2: unknown): boolean;
90
+ declare function isSameURL(url1: unknown, url2: unknown): boolean;
86
91
 
87
92
  interface LimitedOptions {
88
93
  /** Storage key used to persist call counts. */
@@ -134,7 +139,7 @@ declare function bindCleanupToSignal<Cb extends () => any>(cleanup: Cb, signal?:
134
139
  /** Exhaustive Selector used for interactive, tabbable UI controls. */
135
140
  declare const INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable='true'],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
136
141
  /** Check whether an event target points to an interactive element. */
137
- declare const isInteractive: (target: EventTarget | null) => target is HTMLElement;
142
+ declare const isInteractive: (target: EventTarget | null) => boolean;
138
143
  /** Resource type accepted by loadResource. */
139
144
  type ResourceType = "style" | "script" | string;
140
145
  /** Options used when loading a script or stylesheet resource. */
@@ -183,4 +188,4 @@ declare function getWindow(el?: any): (Window & typeof globalThis) | undefined;
183
188
  */
184
189
  declare function formatSize(bytes: number, decimals?: number, base?: number): string;
185
190
 
186
- export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
191
+ export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, cleanURL, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
package/dist/index.d.ts CHANGED
@@ -20,18 +20,18 @@ declare global {
20
20
  interface Window {
21
21
  /** Shared T007 namespace. */
22
22
  t007: T007Namespace;
23
- /** CDN entrypoint for @t007/toast. */
24
- T007_TOAST_JS_SRC?: string;
25
- /** CDN entrypoint for @t007/input. */
26
- T007_INPUT_JS_SRC?: string;
27
- /** CDN entrypoint for @t007/dialog. */
28
- T007_DIALOG_JS_SRC?: string;
29
- /** CDN stylesheet for @t007/toast. */
30
- T007_TOAST_CSS_SRC?: string;
31
- /** CDN stylesheet for @t007/input. */
32
- T007_INPUT_CSS_SRC?: string;
33
- /** CDN stylesheet for @t007/dialog. */
34
- T007_DIALOG_CSS_SRC?: string;
23
+ /** CDN js entrypoint for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
24
+ T007_TOAST_JS_SRC?: string | symbol;
25
+ /** CDN js entrypoint for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
26
+ T007_INPUT_JS_SRC?: string | symbol;
27
+ /** CDN js entrypoint for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
28
+ T007_DIALOG_JS_SRC?: string | symbol;
29
+ /** CDN stylesheet for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
30
+ T007_TOAST_CSS_SRC?: string | symbol;
31
+ /** CDN stylesheet for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
32
+ T007_INPUT_CSS_SRC?: string | symbol;
33
+ /** CDN stylesheet for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
34
+ T007_DIALOG_CSS_SRC?: string | symbol;
35
35
  }
36
36
  /** Shared T007 namespace on the global object. */
37
37
  var t007: T007Namespace;
@@ -77,12 +77,17 @@ declare function parseCSSTime(time: any): number;
77
77
  * @returns The equivalent value in pixels.
78
78
  */
79
79
  declare function parseCSSSize(size: any, el?: HTMLElement): number;
80
+ /** Normalize a URL by decoding it and removing query parameters and hash fragments.
81
+ * @param url The URL string to clean.
82
+ * @returns A normalized URL string for comparison.
83
+ */
84
+ declare function cleanURL(url: string): string;
80
85
  /** Compare two URLs after normalizing origin, pathname, and separators.
81
- * @param src1 First URL or path.
82
- * @param src2 Second URL or path.
86
+ * @param url1 First URL or path.
87
+ * @param url2 Second URL or path.
83
88
  * @returns True when both references point to the same resource.
84
89
  */
85
- declare function isSameURL(src1: unknown, src2: unknown): boolean;
90
+ declare function isSameURL(url1: unknown, url2: unknown): boolean;
86
91
 
87
92
  interface LimitedOptions {
88
93
  /** Storage key used to persist call counts. */
@@ -134,7 +139,7 @@ declare function bindCleanupToSignal<Cb extends () => any>(cleanup: Cb, signal?:
134
139
  /** Exhaustive Selector used for interactive, tabbable UI controls. */
135
140
  declare const INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable='true'],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
136
141
  /** Check whether an event target points to an interactive element. */
137
- declare const isInteractive: (target: EventTarget | null) => target is HTMLElement;
142
+ declare const isInteractive: (target: EventTarget | null) => boolean;
138
143
  /** Resource type accepted by loadResource. */
139
144
  type ResourceType = "style" | "script" | string;
140
145
  /** Options used when loading a script or stylesheet resource. */
@@ -183,4 +188,4 @@ declare function getWindow(el?: any): (Window & typeof globalThis) | undefined;
183
188
  */
184
189
  declare function formatSize(bytes: number, decimals?: number, base?: number): string;
185
190
 
186
- export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
191
+ export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, cleanURL, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  breath,
10
10
  clamp,
11
11
  cleanKeyCombo,
12
+ cleanURL,
12
13
  createEl,
13
14
  deepBreath,
14
15
  formatKeyForDisplay,
@@ -49,7 +50,7 @@ import {
49
50
  setTimeout,
50
51
  stringifyKeyEvent,
51
52
  uid
52
- } from "./chunk-Y5YJMRXD.js";
53
+ } from "./chunk-4O76EZJ4.js";
53
54
  export {
54
55
  INTERACTIVE_SELECTOR,
55
56
  NIL,
@@ -61,6 +62,7 @@ export {
61
62
  breath,
62
63
  clamp,
63
64
  cleanKeyCombo,
65
+ cleanURL,
64
66
  createEl,
65
67
  deepBreath,
66
68
  formatKeyForDisplay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t007/utils",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "High-performance utilities for the t007 ecosystem.",
5
5
  "author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
6
6
  "license": "MIT",
@@ -75,7 +75,7 @@
75
75
  "react-dom": "^18.3.1"
76
76
  },
77
77
  "dependencies": {
78
- "sia-reactor": "^0.0.33"
78
+ "sia-reactor": "^0.0.34"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "react": "^18.0.0"