@t007/dialog 0.0.7 → 0.0.10
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.global.js +20 -7
- package/dist/index.js +2 -2
- package/dist/standalone.js +20 -7
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -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 (
|
|
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 ||
|
|
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,8 +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 (
|
|
62
|
-
callback(method, owner);
|
|
75
|
+
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
|
|
63
76
|
}
|
|
64
77
|
proto = Object.getPrototypeOf(proto);
|
|
65
78
|
}
|
|
@@ -69,7 +82,7 @@
|
|
|
69
82
|
owner2[method] = owner2[method].bind(owner2);
|
|
70
83
|
});
|
|
71
84
|
}
|
|
72
|
-
if (
|
|
85
|
+
if (isDef(window)) {
|
|
73
86
|
window.t007 ??= {};
|
|
74
87
|
t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
|
|
75
88
|
window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
|
|
@@ -204,7 +217,7 @@
|
|
|
204
217
|
function prompt(question, defaultValue, options) {
|
|
205
218
|
return new Promise((resolve) => new T007_Prompt_Dialog({ question, defaultValue, resolve, options }));
|
|
206
219
|
}
|
|
207
|
-
if (
|
|
220
|
+
if (isDef(window)) {
|
|
208
221
|
t007.alert = alert;
|
|
209
222
|
t007.confirm = confirm;
|
|
210
223
|
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 (
|
|
126
|
+
if (isDef(window)) {
|
|
127
127
|
t007.alert = alert;
|
|
128
128
|
t007.confirm = confirm;
|
|
129
129
|
t007.prompt = prompt;
|
package/dist/standalone.js
CHANGED
|
@@ -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 (
|
|
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 ||
|
|
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,8 +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 (
|
|
60
|
-
callback(method, owner);
|
|
73
|
+
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
|
|
61
74
|
}
|
|
62
75
|
proto = Object.getPrototypeOf(proto);
|
|
63
76
|
}
|
|
@@ -67,7 +80,7 @@ function bindAllMethods(owner) {
|
|
|
67
80
|
owner2[method] = owner2[method].bind(owner2);
|
|
68
81
|
});
|
|
69
82
|
}
|
|
70
|
-
if (
|
|
83
|
+
if (isDef(window)) {
|
|
71
84
|
window.t007 ??= {};
|
|
72
85
|
t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
|
|
73
86
|
window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
|
|
@@ -202,7 +215,7 @@ function confirm(question, options) {
|
|
|
202
215
|
function prompt(question, defaultValue, options) {
|
|
203
216
|
return new Promise((resolve) => new T007_Prompt_Dialog({ question, defaultValue, resolve, options }));
|
|
204
217
|
}
|
|
205
|
-
if (
|
|
218
|
+
if (isDef(window)) {
|
|
206
219
|
t007.alert = alert;
|
|
207
220
|
t007.confirm = confirm;
|
|
208
221
|
t007.prompt = prompt;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/dialog",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
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.11"
|
|
61
61
|
}
|
|
62
62
|
}
|