@t007/dialog 0.0.7 → 0.0.8

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.
@@ -1,8 +1,22 @@
1
1
  "use strict";
2
2
  (() => {
3
+ // ../utils/node_modules/sia-reactor/dist/chunk-DW7Z7YEA.js
4
+ function isDef(val) {
5
+ return "undefined" !== typeof val;
6
+ }
7
+
3
8
  // ../utils/dist/index.js
9
+ function isSym(val) {
10
+ return "symbol" === typeof val;
11
+ }
12
+ function isStr(val) {
13
+ return "string" === typeof val;
14
+ }
15
+ function isFunc(val) {
16
+ return "function" === typeof val;
17
+ }
4
18
  function isSameURL(src1, src2) {
5
- if (typeof src1 !== "string" || typeof src2 !== "string" || !src1 || !src2) return false;
19
+ if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
6
20
  try {
7
21
  const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
8
22
  return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
@@ -27,8 +41,8 @@
27
41
  }
28
42
  var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
29
43
  function loadResource(req, type = "style", { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts = 3, retryKey = false } = {}, w = window) {
30
- w.t007._resourceCache ??= {};
31
- if (req === VIRTUAL_RESOURCE || "symbol" === typeof req) return Promise.resolve();
44
+ w.t007 ??= {}, w.t007._resourceCache ??= {};
45
+ if (req === VIRTUAL_RESOURCE || isSym(req)) return Promise.resolve();
32
46
  const src = req;
33
47
  if (w.t007._resourceCache[src]) return w.t007._resourceCache[src];
34
48
  const existing = type === "script" ? Array.prototype.find.call(w.document.scripts, (s) => isSameURL(s.src, src)) : type === "style" ? Array.prototype.find.call(w.document.styleSheets, (s) => isSameURL(s.href, src)) : null;
@@ -58,7 +72,7 @@
58
72
  while (proto && proto !== Object.prototype) {
59
73
  for (const method of Object.getOwnPropertyNames(proto)) {
60
74
  if (method === "constructor") continue;
61
- if ("function" !== typeof Object.getOwnPropertyDescriptor(proto, method)?.value) continue;
75
+ if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) continue;
62
76
  callback(method, owner);
63
77
  }
64
78
  proto = Object.getPrototypeOf(proto);
@@ -69,7 +83,7 @@
69
83
  owner2[method] = owner2[method].bind(owner2);
70
84
  });
71
85
  }
72
- if (typeof window !== "undefined") {
86
+ if (isDef(window)) {
73
87
  window.t007 ??= {};
74
88
  t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
75
89
  window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
@@ -204,7 +218,7 @@
204
218
  function prompt(question, defaultValue, options) {
205
219
  return new Promise((resolve) => new T007_Prompt_Dialog({ question, defaultValue, resolve, options }));
206
220
  }
207
- if (typeof window !== "undefined") {
221
+ if (isDef(window)) {
208
222
  t007.alert = alert;
209
223
  t007.confirm = confirm;
210
224
  t007.prompt = prompt;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.js
2
- import { bindAllMethods, createEl, loadResource } from "@t007/utils";
2
+ import { isDef, bindAllMethods, createEl, loadResource } from "@t007/utils";
3
3
  var T007_Dialog = class {
4
4
  dialog;
5
5
  confirmBtn;
@@ -123,7 +123,7 @@ function confirm(question, options) {
123
123
  function prompt(question, defaultValue, options) {
124
124
  return new Promise((resolve) => new T007_Prompt_Dialog({ question, defaultValue, resolve, options }));
125
125
  }
126
- if (typeof window !== "undefined") {
126
+ if (isDef(window)) {
127
127
  t007.alert = alert;
128
128
  t007.confirm = confirm;
129
129
  t007.prompt = prompt;
@@ -1,6 +1,20 @@
1
+ // ../utils/node_modules/sia-reactor/dist/chunk-DW7Z7YEA.js
2
+ function isDef(val) {
3
+ return "undefined" !== typeof val;
4
+ }
5
+
1
6
  // ../utils/dist/index.js
7
+ function isSym(val) {
8
+ return "symbol" === typeof val;
9
+ }
10
+ function isStr(val) {
11
+ return "string" === typeof val;
12
+ }
13
+ function isFunc(val) {
14
+ return "function" === typeof val;
15
+ }
2
16
  function isSameURL(src1, src2) {
3
- if (typeof src1 !== "string" || typeof src2 !== "string" || !src1 || !src2) return false;
17
+ if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
4
18
  try {
5
19
  const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
6
20
  return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
@@ -25,8 +39,8 @@ function assignEl(el, props, dataset, styles) {
25
39
  }
26
40
  var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
27
41
  function loadResource(req, type = "style", { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts = 3, retryKey = false } = {}, w = window) {
28
- w.t007._resourceCache ??= {};
29
- if (req === VIRTUAL_RESOURCE || "symbol" === typeof req) return Promise.resolve();
42
+ w.t007 ??= {}, w.t007._resourceCache ??= {};
43
+ if (req === VIRTUAL_RESOURCE || isSym(req)) return Promise.resolve();
30
44
  const src = req;
31
45
  if (w.t007._resourceCache[src]) return w.t007._resourceCache[src];
32
46
  const existing = type === "script" ? Array.prototype.find.call(w.document.scripts, (s) => isSameURL(s.src, src)) : type === "style" ? Array.prototype.find.call(w.document.styleSheets, (s) => isSameURL(s.href, src)) : null;
@@ -56,7 +70,7 @@ function onAllMethods(owner, callback) {
56
70
  while (proto && proto !== Object.prototype) {
57
71
  for (const method of Object.getOwnPropertyNames(proto)) {
58
72
  if (method === "constructor") continue;
59
- if ("function" !== typeof Object.getOwnPropertyDescriptor(proto, method)?.value) continue;
73
+ if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) continue;
60
74
  callback(method, owner);
61
75
  }
62
76
  proto = Object.getPrototypeOf(proto);
@@ -67,7 +81,7 @@ function bindAllMethods(owner) {
67
81
  owner2[method] = owner2[method].bind(owner2);
68
82
  });
69
83
  }
70
- if (typeof window !== "undefined") {
84
+ if (isDef(window)) {
71
85
  window.t007 ??= {};
72
86
  t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
73
87
  window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
@@ -202,7 +216,7 @@ function confirm(question, options) {
202
216
  function prompt(question, defaultValue, options) {
203
217
  return new Promise((resolve) => new T007_Prompt_Dialog({ question, defaultValue, resolve, options }));
204
218
  }
205
- if (typeof window !== "undefined") {
219
+ if (isDef(window)) {
206
220
  t007.alert = alert;
207
221
  t007.confirm = confirm;
208
222
  t007.prompt = prompt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t007/dialog",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "A lightweight, pure JS dialog system.",
5
5
  "author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
6
6
  "license": "MIT",
@@ -57,6 +57,6 @@
57
57
  "accessible"
58
58
  ],
59
59
  "dependencies": {
60
- "@t007/utils": "*"
60
+ "@t007/utils": "^0.0.9"
61
61
  }
62
62
  }