@base-web-kits/base-tools-web 0.8.11 → 0.8.13

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.
@@ -0,0 +1,586 @@
1
+ "use strict";
2
+ var baseToolsWeb = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/web/index.ts
22
+ var web_exports = {};
23
+ __export(web_exports, {
24
+ copyBlob: () => copyBlob,
25
+ copyHtml: () => copyHtml,
26
+ copyImage: () => copyImage,
27
+ copyNode: () => copyNode,
28
+ copyRtf: () => copyRtf,
29
+ copyTable: () => copyTable,
30
+ copyText: () => copyText,
31
+ copyUrl: () => copyUrl,
32
+ download: () => download,
33
+ getBrowserName: () => getBrowserName,
34
+ getBrowserVersion: () => getBrowserVersion,
35
+ getCookie: () => getCookie,
36
+ getDevicePixelRatio: () => getDevicePixelRatio,
37
+ getDispositionFileName: () => getDispositionFileName,
38
+ getLocalStorage: () => getLocalStorage,
39
+ getOS: () => getOS,
40
+ getUA: () => getUA,
41
+ getWindowHeight: () => getWindowHeight,
42
+ getWindowScrollLeft: () => getWindowScrollLeft,
43
+ getWindowScrollTop: () => getWindowScrollTop,
44
+ getWindowWidth: () => getWindowWidth,
45
+ hasCss: () => hasCss,
46
+ hasJs: () => hasJs,
47
+ isAndroid: () => isAndroid,
48
+ isChrome: () => isChrome,
49
+ isIOS: () => isIOS,
50
+ isInViewport: () => isInViewport,
51
+ isMobile: () => isMobile,
52
+ isPC: () => isPC,
53
+ isTablet: () => isTablet,
54
+ isTouchSupported: () => isTouchSupported,
55
+ isWeChat: () => isWeChat,
56
+ loadCss: () => loadCss,
57
+ loadJs: () => loadJs,
58
+ lockBodyScroll: () => lockBodyScroll,
59
+ parseAxiosBlob: () => parseAxiosBlob,
60
+ preloadImage: () => preloadImage,
61
+ removeCookie: () => removeCookie,
62
+ removeLocalStorage: () => removeLocalStorage,
63
+ setCookie: () => setCookie,
64
+ setLocalStorage: () => setLocalStorage,
65
+ unlockBodyScroll: () => unlockBodyScroll,
66
+ windowScrollTo: () => windowScrollTo
67
+ });
68
+
69
+ // src/web/clipboard/index.ts
70
+ async function copyText(text) {
71
+ if (typeof text !== "string") text = String(text ?? "");
72
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
73
+ try {
74
+ await navigator.clipboard.writeText(text);
75
+ return;
76
+ } catch (e) {
77
+ }
78
+ }
79
+ return new Promise((resolve, reject) => {
80
+ try {
81
+ const textarea = document.createElement("textarea");
82
+ textarea.value = text;
83
+ textarea.setAttribute("readonly", "");
84
+ textarea.style.position = "fixed";
85
+ textarea.style.top = "0";
86
+ textarea.style.right = "-9999px";
87
+ textarea.style.opacity = "0";
88
+ textarea.style.pointerEvents = "none";
89
+ document.body.appendChild(textarea);
90
+ textarea.focus();
91
+ textarea.select();
92
+ textarea.setSelectionRange(0, textarea.value.length);
93
+ const ok = document.execCommand("copy");
94
+ document.body.removeChild(textarea);
95
+ if (ok) {
96
+ resolve();
97
+ } else {
98
+ reject(new Error("Copy failed: clipboard unavailable"));
99
+ }
100
+ } catch (e) {
101
+ reject(e);
102
+ }
103
+ });
104
+ }
105
+ async function copyHtml(html) {
106
+ const s = String(html ?? "");
107
+ if (canWriteClipboard()) {
108
+ const plain = htmlToText(s);
109
+ await writeClipboard({
110
+ "text/html": new Blob([s], { type: "text/html" }),
111
+ "text/plain": new Blob([plain], { type: "text/plain" })
112
+ });
113
+ return;
114
+ }
115
+ return execCopyFromHtml(s);
116
+ }
117
+ async function copyNode(node) {
118
+ if (canWriteClipboard()) {
119
+ const { html: html2, text } = nodeToHtmlText(node);
120
+ await writeClipboard({
121
+ "text/html": new Blob([html2], { type: "text/html" }),
122
+ "text/plain": new Blob([text], { type: "text/plain" })
123
+ });
124
+ return;
125
+ }
126
+ const { html } = nodeToHtmlText(node);
127
+ return execCopyFromHtml(html);
128
+ }
129
+ async function copyImage(image) {
130
+ const blob = await toImageBlob(image);
131
+ if (!blob) throw new Error("Unsupported image source");
132
+ if (canWriteClipboard()) {
133
+ const type = blob.type || "image/png";
134
+ await writeClipboard({ [type]: blob });
135
+ return;
136
+ }
137
+ throw new Error("Clipboard image write not supported");
138
+ }
139
+ async function copyUrl(url) {
140
+ const s = String(url ?? "");
141
+ if (canWriteClipboard()) {
142
+ await writeClipboard({
143
+ "text/uri-list": new Blob([s], { type: "text/uri-list" }),
144
+ "text/plain": new Blob([s], { type: "text/plain" })
145
+ });
146
+ return;
147
+ }
148
+ await copyText(s);
149
+ }
150
+ async function copyBlob(blob) {
151
+ if (canWriteClipboard()) {
152
+ const type = blob.type || "application/octet-stream";
153
+ await writeClipboard({ [type]: blob });
154
+ return;
155
+ }
156
+ throw new Error("Clipboard blob write not supported");
157
+ }
158
+ async function copyRtf(rtf) {
159
+ const s = String(rtf ?? "");
160
+ if (canWriteClipboard()) {
161
+ const plain = s.replace(/\\par[\s]?/g, "\n").replace(/\{[^}]*\}/g, "").replace(/\\[a-zA-Z]+[0-9'-]*/g, "").replace(/\r?\n/g, "\n").trim();
162
+ await writeClipboard({
163
+ "text/rtf": new Blob([s], { type: "text/rtf" }),
164
+ "text/plain": new Blob([plain], { type: "text/plain" })
165
+ });
166
+ return;
167
+ }
168
+ await copyText(s);
169
+ }
170
+ async function copyTable(rows) {
171
+ const data = Array.isArray(rows) ? rows : [];
172
+ const escapeHtml = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
173
+ const html = (() => {
174
+ const trs = data.map((r) => `<tr>${r.map((c) => `<td>${escapeHtml(String(c))}</td>`).join("")}</tr>`).join("");
175
+ return `<table>${trs}</table>`;
176
+ })();
177
+ const tsv = data.map((r) => r.map((c) => String(c)).join(" ")).join("\n");
178
+ const csv = data.map(
179
+ (r) => r.map((c) => {
180
+ const s = String(c);
181
+ const needQuote = /[",\n]/.test(s);
182
+ const escaped = s.replace(/"/g, '""');
183
+ return needQuote ? `"${escaped}"` : escaped;
184
+ }).join(",")
185
+ ).join("\n");
186
+ if (canWriteClipboard()) {
187
+ await writeClipboard({
188
+ "text/html": new Blob([html], { type: "text/html" }),
189
+ "text/tab-separated-values": new Blob([tsv], { type: "text/tab-separated-values" }),
190
+ "text/csv": new Blob([csv], { type: "text/csv" }),
191
+ "text/plain": new Blob([tsv], { type: "text/plain" })
192
+ });
193
+ return;
194
+ }
195
+ await copyText(tsv);
196
+ }
197
+ async function toImageBlob(image) {
198
+ if (image instanceof Blob) return image;
199
+ if (image instanceof HTMLCanvasElement)
200
+ return await new Promise((resolve, reject) => {
201
+ image.toBlob(
202
+ (b) => b ? resolve(b) : reject(new Error("Canvas toBlob failed")),
203
+ "image/png"
204
+ );
205
+ });
206
+ const isBitmap = typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap;
207
+ if (isBitmap) {
208
+ const cnv = document.createElement("canvas");
209
+ cnv.width = image.width;
210
+ cnv.height = image.height;
211
+ const ctx = cnv.getContext("2d");
212
+ ctx?.drawImage(image, 0, 0);
213
+ return await new Promise((resolve, reject) => {
214
+ cnv.toBlob((b) => b ? resolve(b) : reject(new Error("Canvas toBlob failed")), "image/png");
215
+ });
216
+ }
217
+ return null;
218
+ }
219
+ function canWriteClipboard() {
220
+ return !!(navigator.clipboard && typeof navigator.clipboard.write === "function" && typeof ClipboardItem !== "undefined");
221
+ }
222
+ async function writeClipboard(items) {
223
+ await navigator.clipboard.write([new ClipboardItem(items)]);
224
+ }
225
+ function htmlToText(html) {
226
+ const div = document.createElement("div");
227
+ div.innerHTML = html;
228
+ return div.textContent || "";
229
+ }
230
+ function nodeToHtmlText(node) {
231
+ const container = document.createElement("div");
232
+ container.appendChild(node.cloneNode(true));
233
+ const html = node instanceof Element ? node.outerHTML ?? container.innerHTML : container.innerHTML;
234
+ const text = container.textContent || "";
235
+ return { html, text };
236
+ }
237
+ function execCopyFromHtml(html) {
238
+ return new Promise((resolve, reject) => {
239
+ try {
240
+ const div = document.createElement("div");
241
+ div.contentEditable = "true";
242
+ div.style.position = "fixed";
243
+ div.style.top = "0";
244
+ div.style.right = "-9999px";
245
+ div.style.opacity = "0";
246
+ div.style.pointerEvents = "none";
247
+ div.innerHTML = html;
248
+ document.body.appendChild(div);
249
+ const selection = window.getSelection();
250
+ const range = document.createRange();
251
+ range.selectNodeContents(div);
252
+ selection?.removeAllRanges();
253
+ selection?.addRange(range);
254
+ const ok = document.execCommand("copy");
255
+ document.body.removeChild(div);
256
+ selection?.removeAllRanges();
257
+ if (ok) {
258
+ resolve();
259
+ } else {
260
+ reject(new Error("Copy failed: clipboard unavailable"));
261
+ }
262
+ } catch (e) {
263
+ reject(e);
264
+ }
265
+ });
266
+ }
267
+
268
+ // src/web/cookie/index.ts
269
+ function setCookie(name, value, days) {
270
+ const date = /* @__PURE__ */ new Date();
271
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
272
+ const expires = `expires=${date.toUTCString()}; path=/`;
273
+ document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}`;
274
+ }
275
+ function getCookie(name) {
276
+ const value = `; ${document.cookie}`;
277
+ const parts = value.split(`; ${name}=`);
278
+ if (parts.length === 2) {
279
+ const v = parts.pop()?.split(";").shift();
280
+ return v ? decodeURIComponent(v) : null;
281
+ }
282
+ return null;
283
+ }
284
+ function removeCookie(name) {
285
+ document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
286
+ }
287
+
288
+ // src/web/load/index.ts
289
+ async function download(url, fileName = "") {
290
+ if (!url) return;
291
+ let blobUrl = "";
292
+ let needRevoke = false;
293
+ try {
294
+ if (url instanceof Blob) {
295
+ blobUrl = URL.createObjectURL(url);
296
+ needRevoke = true;
297
+ } else if (url.includes(";base64,")) {
298
+ blobUrl = url;
299
+ } else {
300
+ if (fileName) {
301
+ const res = await fetch(url);
302
+ if (!res.ok) throw new Error(`fetch error ${res.status}\uFF1A${url}`);
303
+ const blob = await res.blob();
304
+ blobUrl = URL.createObjectURL(blob);
305
+ needRevoke = true;
306
+ } else {
307
+ blobUrl = url;
308
+ }
309
+ }
310
+ const a = document.createElement("a");
311
+ a.href = blobUrl;
312
+ a.download = fileName;
313
+ document.body.appendChild(a);
314
+ a.click();
315
+ document.body.removeChild(a);
316
+ } finally {
317
+ if (needRevoke) {
318
+ setTimeout(() => URL.revokeObjectURL(blobUrl), 100);
319
+ }
320
+ }
321
+ }
322
+ async function parseAxiosBlob(res) {
323
+ const { data, headers, status, statusText, config } = res;
324
+ if (status < 200 || status >= 300) throw new Error(`${status}\uFF0C${statusText}\uFF1A${config.url}`);
325
+ if (data.type.includes("application/json")) {
326
+ const txt = await data.text();
327
+ throw JSON.parse(txt);
328
+ }
329
+ const fileName = getDispositionFileName(headers["content-disposition"]);
330
+ return { blob: data, fileName };
331
+ }
332
+ function getDispositionFileName(disposition) {
333
+ if (!disposition) return "";
334
+ const rfc5987 = /filename\*\s*=\s*([^']*)''([^;]*)/i.exec(disposition);
335
+ if (rfc5987?.[2]) {
336
+ try {
337
+ return decodeURIComponent(rfc5987[2].trim()).replace(/[\r\n]+/g, "");
338
+ } catch {
339
+ return rfc5987[2].trim().replace(/[\r\n]+/g, "");
340
+ }
341
+ }
342
+ const old = /filename\s*=\s*(?:"([^"]*)"|([^";]*))(?=;|$)/i.exec(disposition);
343
+ if (old) return (old[1] ?? old[2]).trim().replace(/[\r\n]+/g, "");
344
+ return "";
345
+ }
346
+ async function loadJs(src, attrs) {
347
+ return new Promise((resolve, reject) => {
348
+ if (hasJs(src)) return resolve();
349
+ const script = document.createElement("script");
350
+ script.type = "text/javascript";
351
+ script.src = src;
352
+ if (attrs) {
353
+ const keys = Object.keys(attrs);
354
+ keys.forEach((key) => {
355
+ const v = attrs[key];
356
+ if (v === null || v === void 0 || v === false) return;
357
+ script.setAttribute(key, typeof v === "boolean" ? "" : v);
358
+ });
359
+ }
360
+ script.onload = () => resolve();
361
+ script.onerror = (e) => reject(e);
362
+ document.head.appendChild(script);
363
+ });
364
+ }
365
+ function hasJs(src) {
366
+ const target = new URL(src, document.baseURI).href;
367
+ const jsList = Array.from(document.querySelectorAll("script[src]"));
368
+ return jsList.some((e) => {
369
+ const src2 = e.getAttribute("src");
370
+ return src2 && new URL(src2, document.baseURI).href === target;
371
+ });
372
+ }
373
+ async function loadCss(href, attrs) {
374
+ return new Promise((resolve, reject) => {
375
+ if (hasCss(href)) return resolve();
376
+ const link = document.createElement("link");
377
+ link.rel = "stylesheet";
378
+ link.href = href;
379
+ if (attrs) {
380
+ const keys = Object.keys(attrs);
381
+ keys.forEach((key) => {
382
+ const v = attrs[key];
383
+ if (v === null || v === void 0) return;
384
+ link.setAttribute(key, String(v));
385
+ });
386
+ }
387
+ link.onload = () => resolve();
388
+ link.onerror = (e) => reject(e);
389
+ document.head.appendChild(link);
390
+ });
391
+ }
392
+ function hasCss(href) {
393
+ const target = new URL(href, document.baseURI).href;
394
+ const list = Array.from(document.querySelectorAll('link[rel="stylesheet"][href]'));
395
+ return list.some((e) => {
396
+ const h = e.getAttribute("href");
397
+ return h && new URL(h, document.baseURI).href === target;
398
+ });
399
+ }
400
+ function preloadImage(src) {
401
+ return new Promise((resolve, reject) => {
402
+ const img = new Image();
403
+ img.onload = () => resolve(img);
404
+ img.onerror = (e) => reject(e);
405
+ img.src = src;
406
+ });
407
+ }
408
+
409
+ // src/web/storage/index.ts
410
+ var WK = {
411
+ val: "__l_val",
412
+ exp: "__l_exp",
413
+ wrap: "__l_wrap"
414
+ };
415
+ function setLocalStorage(key, value, days) {
416
+ if (value === void 0 || value === null) {
417
+ removeLocalStorage(key);
418
+ return;
419
+ }
420
+ let toStore = value;
421
+ if (typeof days === "number" && days > 0) {
422
+ const ms = days * 24 * 60 * 60 * 1e3;
423
+ toStore = {
424
+ [WK.wrap]: true,
425
+ [WK.val]: value,
426
+ [WK.exp]: Date.now() + ms
427
+ };
428
+ }
429
+ localStorage.setItem(key, JSON.stringify(toStore));
430
+ }
431
+ function getLocalStorage(key) {
432
+ const raw = localStorage.getItem(key);
433
+ if (raw === null) return null;
434
+ try {
435
+ const parsed = JSON.parse(raw);
436
+ if (parsed && typeof parsed === "object" && WK.wrap in parsed && WK.exp in parsed) {
437
+ if (Date.now() > parsed[WK.exp]) {
438
+ removeLocalStorage(key);
439
+ return null;
440
+ }
441
+ return parsed[WK.val];
442
+ }
443
+ return parsed;
444
+ } catch {
445
+ return raw;
446
+ }
447
+ }
448
+ function removeLocalStorage(key) {
449
+ localStorage.removeItem(key);
450
+ }
451
+
452
+ // src/web/dom/index.ts
453
+ function getWindowWidth() {
454
+ return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
455
+ }
456
+ function getWindowHeight() {
457
+ return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
458
+ }
459
+ function getWindowScrollTop() {
460
+ const doc = document.documentElement;
461
+ const body = document.body;
462
+ return window.pageYOffset || doc.scrollTop || body.scrollTop || 0;
463
+ }
464
+ function getWindowScrollLeft() {
465
+ const doc = document.documentElement;
466
+ const body = document.body;
467
+ return window.pageXOffset || doc.scrollLeft || body.scrollLeft || 0;
468
+ }
469
+ function windowScrollTo(top, behavior = "smooth") {
470
+ if ("scrollBehavior" in document.documentElement.style) {
471
+ window.scrollTo({ top, behavior });
472
+ } else {
473
+ window.scrollTo(0, top);
474
+ }
475
+ }
476
+ function isInViewport(el, offset = 0) {
477
+ const rect = el.getBoundingClientRect();
478
+ const width = getWindowWidth();
479
+ const height = getWindowHeight();
480
+ return rect.bottom >= -offset && rect.right >= -offset && rect.top <= height + offset && rect.left <= width + offset;
481
+ }
482
+ function lockBodyScroll() {
483
+ const body = document.body;
484
+ if (body.dataset.scrollLock === "true") return;
485
+ const y = Math.round(window.scrollY || window.pageYOffset || 0);
486
+ body.dataset.scrollLock = "true";
487
+ body.dataset.scrollLockY = String(y);
488
+ body.style.position = "fixed";
489
+ body.style.top = `-${y}px`;
490
+ body.style.left = "0";
491
+ body.style.right = "0";
492
+ body.style.width = "100%";
493
+ }
494
+ function unlockBodyScroll() {
495
+ const body = document.body;
496
+ if (body.dataset.scrollLock !== "true") return;
497
+ const y = Number(body.dataset.scrollLockY || 0);
498
+ body.style.position = "";
499
+ body.style.top = "";
500
+ body.style.left = "";
501
+ body.style.right = "";
502
+ body.style.width = "";
503
+ delete body.dataset.scrollLock;
504
+ delete body.dataset.scrollLockY;
505
+ window.scrollTo(0, y);
506
+ }
507
+
508
+ // src/web/device/index.ts
509
+ function getUA() {
510
+ if (typeof navigator === "undefined") return "";
511
+ return (navigator.userAgent || "").toLowerCase();
512
+ }
513
+ function isMobile() {
514
+ const ua = getUA();
515
+ return /android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile/i.test(ua);
516
+ }
517
+ function isTablet() {
518
+ const ua = getUA();
519
+ return /ipad|android(?!.*mobile)|tablet/i.test(ua) && !/mobile/i.test(ua);
520
+ }
521
+ function isPC() {
522
+ return !isMobile() && !isTablet();
523
+ }
524
+ function isIOS() {
525
+ const ua = getUA();
526
+ return /iphone|ipad|ipod/i.test(ua);
527
+ }
528
+ function isAndroid() {
529
+ const ua = getUA();
530
+ return /android/i.test(ua);
531
+ }
532
+ function isWeChat() {
533
+ const ua = getUA();
534
+ return /micromessenger/i.test(ua);
535
+ }
536
+ function isChrome() {
537
+ const ua = getUA();
538
+ return /chrome\//i.test(ua) && !/edg\//i.test(ua) && !/opr\//i.test(ua) && !/whale\//i.test(ua);
539
+ }
540
+ function isTouchSupported() {
541
+ if (typeof window === "undefined") return false;
542
+ return "ontouchstart" in window || navigator.maxTouchPoints > 0;
543
+ }
544
+ function getDevicePixelRatio() {
545
+ if (typeof window === "undefined") return 1;
546
+ return window.devicePixelRatio || 1;
547
+ }
548
+ function getBrowserName() {
549
+ const ua = getUA();
550
+ if (/chrome\//i.test(ua)) return "chrome";
551
+ if (/safari\//i.test(ua)) return "safari";
552
+ if (/firefox\//i.test(ua)) return "firefox";
553
+ if (/opr\//i.test(ua)) return "opera";
554
+ if (/edg\//i.test(ua)) return "edge";
555
+ if (/msie|trident/i.test(ua)) return "ie";
556
+ return null;
557
+ }
558
+ function getBrowserVersion() {
559
+ const ua = getUA();
560
+ const versionPatterns = [
561
+ /(?:edg|edge)\/([0-9.]+)/i,
562
+ /(?:opr|opera)\/([0-9.]+)/i,
563
+ /chrome\/([0-9.]+)/i,
564
+ /firefox\/([0-9.]+)/i,
565
+ /version\/([0-9.]+).*safari/i,
566
+ /(?:msie |rv:)([0-9.]+)/i
567
+ ];
568
+ for (const pattern of versionPatterns) {
569
+ const matches = ua.match(pattern);
570
+ if (matches && matches[1]) {
571
+ return matches[1];
572
+ }
573
+ }
574
+ return null;
575
+ }
576
+ function getOS() {
577
+ const ua = getUA();
578
+ if (/windows/i.test(ua)) return "windows";
579
+ if (/mac os/i.test(ua)) return "macos";
580
+ if (/linux/i.test(ua)) return "linux";
581
+ if (/iphone|ipad|ipod/i.test(ua)) return "ios";
582
+ if (/android/i.test(ua)) return "android";
583
+ return "unknown";
584
+ }
585
+ return __toCommonJS(web_exports);
586
+ })();
@@ -0,0 +1,586 @@
1
+ "use strict";
2
+ var baseToolsWeb = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/web/index.ts
22
+ var web_exports = {};
23
+ __export(web_exports, {
24
+ copyBlob: () => copyBlob,
25
+ copyHtml: () => copyHtml,
26
+ copyImage: () => copyImage,
27
+ copyNode: () => copyNode,
28
+ copyRtf: () => copyRtf,
29
+ copyTable: () => copyTable,
30
+ copyText: () => copyText,
31
+ copyUrl: () => copyUrl,
32
+ download: () => download,
33
+ getBrowserName: () => getBrowserName,
34
+ getBrowserVersion: () => getBrowserVersion,
35
+ getCookie: () => getCookie,
36
+ getDevicePixelRatio: () => getDevicePixelRatio,
37
+ getDispositionFileName: () => getDispositionFileName,
38
+ getLocalStorage: () => getLocalStorage,
39
+ getOS: () => getOS,
40
+ getUA: () => getUA,
41
+ getWindowHeight: () => getWindowHeight,
42
+ getWindowScrollLeft: () => getWindowScrollLeft,
43
+ getWindowScrollTop: () => getWindowScrollTop,
44
+ getWindowWidth: () => getWindowWidth,
45
+ hasCss: () => hasCss,
46
+ hasJs: () => hasJs,
47
+ isAndroid: () => isAndroid,
48
+ isChrome: () => isChrome,
49
+ isIOS: () => isIOS,
50
+ isInViewport: () => isInViewport,
51
+ isMobile: () => isMobile,
52
+ isPC: () => isPC,
53
+ isTablet: () => isTablet,
54
+ isTouchSupported: () => isTouchSupported,
55
+ isWeChat: () => isWeChat,
56
+ loadCss: () => loadCss,
57
+ loadJs: () => loadJs,
58
+ lockBodyScroll: () => lockBodyScroll,
59
+ parseAxiosBlob: () => parseAxiosBlob,
60
+ preloadImage: () => preloadImage,
61
+ removeCookie: () => removeCookie,
62
+ removeLocalStorage: () => removeLocalStorage,
63
+ setCookie: () => setCookie,
64
+ setLocalStorage: () => setLocalStorage,
65
+ unlockBodyScroll: () => unlockBodyScroll,
66
+ windowScrollTo: () => windowScrollTo
67
+ });
68
+
69
+ // src/web/clipboard/index.ts
70
+ async function copyText(text) {
71
+ if (typeof text !== "string") text = String(text ?? "");
72
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
73
+ try {
74
+ await navigator.clipboard.writeText(text);
75
+ return;
76
+ } catch (e) {
77
+ }
78
+ }
79
+ return new Promise((resolve, reject) => {
80
+ try {
81
+ const textarea = document.createElement("textarea");
82
+ textarea.value = text;
83
+ textarea.setAttribute("readonly", "");
84
+ textarea.style.position = "fixed";
85
+ textarea.style.top = "0";
86
+ textarea.style.right = "-9999px";
87
+ textarea.style.opacity = "0";
88
+ textarea.style.pointerEvents = "none";
89
+ document.body.appendChild(textarea);
90
+ textarea.focus();
91
+ textarea.select();
92
+ textarea.setSelectionRange(0, textarea.value.length);
93
+ const ok = document.execCommand("copy");
94
+ document.body.removeChild(textarea);
95
+ if (ok) {
96
+ resolve();
97
+ } else {
98
+ reject(new Error("Copy failed: clipboard unavailable"));
99
+ }
100
+ } catch (e) {
101
+ reject(e);
102
+ }
103
+ });
104
+ }
105
+ async function copyHtml(html) {
106
+ const s = String(html ?? "");
107
+ if (canWriteClipboard()) {
108
+ const plain = htmlToText(s);
109
+ await writeClipboard({
110
+ "text/html": new Blob([s], { type: "text/html" }),
111
+ "text/plain": new Blob([plain], { type: "text/plain" })
112
+ });
113
+ return;
114
+ }
115
+ return execCopyFromHtml(s);
116
+ }
117
+ async function copyNode(node) {
118
+ if (canWriteClipboard()) {
119
+ const { html: html2, text } = nodeToHtmlText(node);
120
+ await writeClipboard({
121
+ "text/html": new Blob([html2], { type: "text/html" }),
122
+ "text/plain": new Blob([text], { type: "text/plain" })
123
+ });
124
+ return;
125
+ }
126
+ const { html } = nodeToHtmlText(node);
127
+ return execCopyFromHtml(html);
128
+ }
129
+ async function copyImage(image) {
130
+ const blob = await toImageBlob(image);
131
+ if (!blob) throw new Error("Unsupported image source");
132
+ if (canWriteClipboard()) {
133
+ const type = blob.type || "image/png";
134
+ await writeClipboard({ [type]: blob });
135
+ return;
136
+ }
137
+ throw new Error("Clipboard image write not supported");
138
+ }
139
+ async function copyUrl(url) {
140
+ const s = String(url ?? "");
141
+ if (canWriteClipboard()) {
142
+ await writeClipboard({
143
+ "text/uri-list": new Blob([s], { type: "text/uri-list" }),
144
+ "text/plain": new Blob([s], { type: "text/plain" })
145
+ });
146
+ return;
147
+ }
148
+ await copyText(s);
149
+ }
150
+ async function copyBlob(blob) {
151
+ if (canWriteClipboard()) {
152
+ const type = blob.type || "application/octet-stream";
153
+ await writeClipboard({ [type]: blob });
154
+ return;
155
+ }
156
+ throw new Error("Clipboard blob write not supported");
157
+ }
158
+ async function copyRtf(rtf) {
159
+ const s = String(rtf ?? "");
160
+ if (canWriteClipboard()) {
161
+ const plain = s.replace(/\\par[\s]?/g, "\n").replace(/\{[^}]*\}/g, "").replace(/\\[a-zA-Z]+[0-9'-]*/g, "").replace(/\r?\n/g, "\n").trim();
162
+ await writeClipboard({
163
+ "text/rtf": new Blob([s], { type: "text/rtf" }),
164
+ "text/plain": new Blob([plain], { type: "text/plain" })
165
+ });
166
+ return;
167
+ }
168
+ await copyText(s);
169
+ }
170
+ async function copyTable(rows) {
171
+ const data = Array.isArray(rows) ? rows : [];
172
+ const escapeHtml = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
173
+ const html = (() => {
174
+ const trs = data.map((r) => `<tr>${r.map((c) => `<td>${escapeHtml(String(c))}</td>`).join("")}</tr>`).join("");
175
+ return `<table>${trs}</table>`;
176
+ })();
177
+ const tsv = data.map((r) => r.map((c) => String(c)).join(" ")).join("\n");
178
+ const csv = data.map(
179
+ (r) => r.map((c) => {
180
+ const s = String(c);
181
+ const needQuote = /[",\n]/.test(s);
182
+ const escaped = s.replace(/"/g, '""');
183
+ return needQuote ? `"${escaped}"` : escaped;
184
+ }).join(",")
185
+ ).join("\n");
186
+ if (canWriteClipboard()) {
187
+ await writeClipboard({
188
+ "text/html": new Blob([html], { type: "text/html" }),
189
+ "text/tab-separated-values": new Blob([tsv], { type: "text/tab-separated-values" }),
190
+ "text/csv": new Blob([csv], { type: "text/csv" }),
191
+ "text/plain": new Blob([tsv], { type: "text/plain" })
192
+ });
193
+ return;
194
+ }
195
+ await copyText(tsv);
196
+ }
197
+ async function toImageBlob(image) {
198
+ if (image instanceof Blob) return image;
199
+ if (image instanceof HTMLCanvasElement)
200
+ return await new Promise((resolve, reject) => {
201
+ image.toBlob(
202
+ (b) => b ? resolve(b) : reject(new Error("Canvas toBlob failed")),
203
+ "image/png"
204
+ );
205
+ });
206
+ const isBitmap = typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap;
207
+ if (isBitmap) {
208
+ const cnv = document.createElement("canvas");
209
+ cnv.width = image.width;
210
+ cnv.height = image.height;
211
+ const ctx = cnv.getContext("2d");
212
+ ctx?.drawImage(image, 0, 0);
213
+ return await new Promise((resolve, reject) => {
214
+ cnv.toBlob((b) => b ? resolve(b) : reject(new Error("Canvas toBlob failed")), "image/png");
215
+ });
216
+ }
217
+ return null;
218
+ }
219
+ function canWriteClipboard() {
220
+ return !!(navigator.clipboard && typeof navigator.clipboard.write === "function" && typeof ClipboardItem !== "undefined");
221
+ }
222
+ async function writeClipboard(items) {
223
+ await navigator.clipboard.write([new ClipboardItem(items)]);
224
+ }
225
+ function htmlToText(html) {
226
+ const div = document.createElement("div");
227
+ div.innerHTML = html;
228
+ return div.textContent || "";
229
+ }
230
+ function nodeToHtmlText(node) {
231
+ const container = document.createElement("div");
232
+ container.appendChild(node.cloneNode(true));
233
+ const html = node instanceof Element ? node.outerHTML ?? container.innerHTML : container.innerHTML;
234
+ const text = container.textContent || "";
235
+ return { html, text };
236
+ }
237
+ function execCopyFromHtml(html) {
238
+ return new Promise((resolve, reject) => {
239
+ try {
240
+ const div = document.createElement("div");
241
+ div.contentEditable = "true";
242
+ div.style.position = "fixed";
243
+ div.style.top = "0";
244
+ div.style.right = "-9999px";
245
+ div.style.opacity = "0";
246
+ div.style.pointerEvents = "none";
247
+ div.innerHTML = html;
248
+ document.body.appendChild(div);
249
+ const selection = window.getSelection();
250
+ const range = document.createRange();
251
+ range.selectNodeContents(div);
252
+ selection?.removeAllRanges();
253
+ selection?.addRange(range);
254
+ const ok = document.execCommand("copy");
255
+ document.body.removeChild(div);
256
+ selection?.removeAllRanges();
257
+ if (ok) {
258
+ resolve();
259
+ } else {
260
+ reject(new Error("Copy failed: clipboard unavailable"));
261
+ }
262
+ } catch (e) {
263
+ reject(e);
264
+ }
265
+ });
266
+ }
267
+
268
+ // src/web/cookie/index.ts
269
+ function setCookie(name, value, days) {
270
+ const date = /* @__PURE__ */ new Date();
271
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
272
+ const expires = `expires=${date.toUTCString()}; path=/`;
273
+ document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}`;
274
+ }
275
+ function getCookie(name) {
276
+ const value = `; ${document.cookie}`;
277
+ const parts = value.split(`; ${name}=`);
278
+ if (parts.length === 2) {
279
+ const v = parts.pop()?.split(";").shift();
280
+ return v ? decodeURIComponent(v) : null;
281
+ }
282
+ return null;
283
+ }
284
+ function removeCookie(name) {
285
+ document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
286
+ }
287
+
288
+ // src/web/load/index.ts
289
+ async function download(url, fileName = "") {
290
+ if (!url) return;
291
+ let blobUrl = "";
292
+ let needRevoke = false;
293
+ try {
294
+ if (url instanceof Blob) {
295
+ blobUrl = URL.createObjectURL(url);
296
+ needRevoke = true;
297
+ } else if (url.includes(";base64,")) {
298
+ blobUrl = url;
299
+ } else {
300
+ if (fileName) {
301
+ const res = await fetch(url);
302
+ if (!res.ok) throw new Error(`fetch error ${res.status}\uFF1A${url}`);
303
+ const blob = await res.blob();
304
+ blobUrl = URL.createObjectURL(blob);
305
+ needRevoke = true;
306
+ } else {
307
+ blobUrl = url;
308
+ }
309
+ }
310
+ const a = document.createElement("a");
311
+ a.href = blobUrl;
312
+ a.download = fileName;
313
+ document.body.appendChild(a);
314
+ a.click();
315
+ document.body.removeChild(a);
316
+ } finally {
317
+ if (needRevoke) {
318
+ setTimeout(() => URL.revokeObjectURL(blobUrl), 100);
319
+ }
320
+ }
321
+ }
322
+ async function parseAxiosBlob(res) {
323
+ const { data, headers, status, statusText, config } = res;
324
+ if (status < 200 || status >= 300) throw new Error(`${status}\uFF0C${statusText}\uFF1A${config.url}`);
325
+ if (data.type.includes("application/json")) {
326
+ const txt = await data.text();
327
+ throw JSON.parse(txt);
328
+ }
329
+ const fileName = getDispositionFileName(headers["content-disposition"]);
330
+ return { blob: data, fileName };
331
+ }
332
+ function getDispositionFileName(disposition) {
333
+ if (!disposition) return "";
334
+ const rfc5987 = /filename\*\s*=\s*([^']*)''([^;]*)/i.exec(disposition);
335
+ if (rfc5987?.[2]) {
336
+ try {
337
+ return decodeURIComponent(rfc5987[2].trim()).replace(/[\r\n]+/g, "");
338
+ } catch {
339
+ return rfc5987[2].trim().replace(/[\r\n]+/g, "");
340
+ }
341
+ }
342
+ const old = /filename\s*=\s*(?:"([^"]*)"|([^";]*))(?=;|$)/i.exec(disposition);
343
+ if (old) return (old[1] ?? old[2]).trim().replace(/[\r\n]+/g, "");
344
+ return "";
345
+ }
346
+ async function loadJs(src, attrs) {
347
+ return new Promise((resolve, reject) => {
348
+ if (hasJs(src)) return resolve();
349
+ const script = document.createElement("script");
350
+ script.type = "text/javascript";
351
+ script.src = src;
352
+ if (attrs) {
353
+ const keys = Object.keys(attrs);
354
+ keys.forEach((key) => {
355
+ const v = attrs[key];
356
+ if (v === null || v === void 0 || v === false) return;
357
+ script.setAttribute(key, typeof v === "boolean" ? "" : v);
358
+ });
359
+ }
360
+ script.onload = () => resolve();
361
+ script.onerror = (e) => reject(e);
362
+ document.head.appendChild(script);
363
+ });
364
+ }
365
+ function hasJs(src) {
366
+ const target = new URL(src, document.baseURI).href;
367
+ const jsList = Array.from(document.querySelectorAll("script[src]"));
368
+ return jsList.some((e) => {
369
+ const src2 = e.getAttribute("src");
370
+ return src2 && new URL(src2, document.baseURI).href === target;
371
+ });
372
+ }
373
+ async function loadCss(href, attrs) {
374
+ return new Promise((resolve, reject) => {
375
+ if (hasCss(href)) return resolve();
376
+ const link = document.createElement("link");
377
+ link.rel = "stylesheet";
378
+ link.href = href;
379
+ if (attrs) {
380
+ const keys = Object.keys(attrs);
381
+ keys.forEach((key) => {
382
+ const v = attrs[key];
383
+ if (v === null || v === void 0) return;
384
+ link.setAttribute(key, String(v));
385
+ });
386
+ }
387
+ link.onload = () => resolve();
388
+ link.onerror = (e) => reject(e);
389
+ document.head.appendChild(link);
390
+ });
391
+ }
392
+ function hasCss(href) {
393
+ const target = new URL(href, document.baseURI).href;
394
+ const list = Array.from(document.querySelectorAll('link[rel="stylesheet"][href]'));
395
+ return list.some((e) => {
396
+ const h = e.getAttribute("href");
397
+ return h && new URL(h, document.baseURI).href === target;
398
+ });
399
+ }
400
+ function preloadImage(src) {
401
+ return new Promise((resolve, reject) => {
402
+ const img = new Image();
403
+ img.onload = () => resolve(img);
404
+ img.onerror = (e) => reject(e);
405
+ img.src = src;
406
+ });
407
+ }
408
+
409
+ // src/web/storage/index.ts
410
+ var WK = {
411
+ val: "__l_val",
412
+ exp: "__l_exp",
413
+ wrap: "__l_wrap"
414
+ };
415
+ function setLocalStorage(key, value, days) {
416
+ if (value === void 0 || value === null) {
417
+ removeLocalStorage(key);
418
+ return;
419
+ }
420
+ let toStore = value;
421
+ if (typeof days === "number" && days > 0) {
422
+ const ms = days * 24 * 60 * 60 * 1e3;
423
+ toStore = {
424
+ [WK.wrap]: true,
425
+ [WK.val]: value,
426
+ [WK.exp]: Date.now() + ms
427
+ };
428
+ }
429
+ localStorage.setItem(key, JSON.stringify(toStore));
430
+ }
431
+ function getLocalStorage(key) {
432
+ const raw = localStorage.getItem(key);
433
+ if (raw === null) return null;
434
+ try {
435
+ const parsed = JSON.parse(raw);
436
+ if (parsed && typeof parsed === "object" && WK.wrap in parsed && WK.exp in parsed) {
437
+ if (Date.now() > parsed[WK.exp]) {
438
+ removeLocalStorage(key);
439
+ return null;
440
+ }
441
+ return parsed[WK.val];
442
+ }
443
+ return parsed;
444
+ } catch {
445
+ return raw;
446
+ }
447
+ }
448
+ function removeLocalStorage(key) {
449
+ localStorage.removeItem(key);
450
+ }
451
+
452
+ // src/web/dom/index.ts
453
+ function getWindowWidth() {
454
+ return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
455
+ }
456
+ function getWindowHeight() {
457
+ return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
458
+ }
459
+ function getWindowScrollTop() {
460
+ const doc = document.documentElement;
461
+ const body = document.body;
462
+ return window.pageYOffset || doc.scrollTop || body.scrollTop || 0;
463
+ }
464
+ function getWindowScrollLeft() {
465
+ const doc = document.documentElement;
466
+ const body = document.body;
467
+ return window.pageXOffset || doc.scrollLeft || body.scrollLeft || 0;
468
+ }
469
+ function windowScrollTo(top, behavior = "smooth") {
470
+ if ("scrollBehavior" in document.documentElement.style) {
471
+ window.scrollTo({ top, behavior });
472
+ } else {
473
+ window.scrollTo(0, top);
474
+ }
475
+ }
476
+ function isInViewport(el, offset = 0) {
477
+ const rect = el.getBoundingClientRect();
478
+ const width = getWindowWidth();
479
+ const height = getWindowHeight();
480
+ return rect.bottom >= -offset && rect.right >= -offset && rect.top <= height + offset && rect.left <= width + offset;
481
+ }
482
+ function lockBodyScroll() {
483
+ const body = document.body;
484
+ if (body.dataset.scrollLock === "true") return;
485
+ const y = Math.round(window.scrollY || window.pageYOffset || 0);
486
+ body.dataset.scrollLock = "true";
487
+ body.dataset.scrollLockY = String(y);
488
+ body.style.position = "fixed";
489
+ body.style.top = `-${y}px`;
490
+ body.style.left = "0";
491
+ body.style.right = "0";
492
+ body.style.width = "100%";
493
+ }
494
+ function unlockBodyScroll() {
495
+ const body = document.body;
496
+ if (body.dataset.scrollLock !== "true") return;
497
+ const y = Number(body.dataset.scrollLockY || 0);
498
+ body.style.position = "";
499
+ body.style.top = "";
500
+ body.style.left = "";
501
+ body.style.right = "";
502
+ body.style.width = "";
503
+ delete body.dataset.scrollLock;
504
+ delete body.dataset.scrollLockY;
505
+ window.scrollTo(0, y);
506
+ }
507
+
508
+ // src/web/device/index.ts
509
+ function getUA() {
510
+ if (typeof navigator === "undefined") return "";
511
+ return (navigator.userAgent || "").toLowerCase();
512
+ }
513
+ function isMobile() {
514
+ const ua = getUA();
515
+ return /android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile/i.test(ua);
516
+ }
517
+ function isTablet() {
518
+ const ua = getUA();
519
+ return /ipad|android(?!.*mobile)|tablet/i.test(ua) && !/mobile/i.test(ua);
520
+ }
521
+ function isPC() {
522
+ return !isMobile() && !isTablet();
523
+ }
524
+ function isIOS() {
525
+ const ua = getUA();
526
+ return /iphone|ipad|ipod/i.test(ua);
527
+ }
528
+ function isAndroid() {
529
+ const ua = getUA();
530
+ return /android/i.test(ua);
531
+ }
532
+ function isWeChat() {
533
+ const ua = getUA();
534
+ return /micromessenger/i.test(ua);
535
+ }
536
+ function isChrome() {
537
+ const ua = getUA();
538
+ return /chrome\//i.test(ua) && !/edg\//i.test(ua) && !/opr\//i.test(ua) && !/whale\//i.test(ua);
539
+ }
540
+ function isTouchSupported() {
541
+ if (typeof window === "undefined") return false;
542
+ return "ontouchstart" in window || navigator.maxTouchPoints > 0;
543
+ }
544
+ function getDevicePixelRatio() {
545
+ if (typeof window === "undefined") return 1;
546
+ return window.devicePixelRatio || 1;
547
+ }
548
+ function getBrowserName() {
549
+ const ua = getUA();
550
+ if (/chrome\//i.test(ua)) return "chrome";
551
+ if (/safari\//i.test(ua)) return "safari";
552
+ if (/firefox\//i.test(ua)) return "firefox";
553
+ if (/opr\//i.test(ua)) return "opera";
554
+ if (/edg\//i.test(ua)) return "edge";
555
+ if (/msie|trident/i.test(ua)) return "ie";
556
+ return null;
557
+ }
558
+ function getBrowserVersion() {
559
+ const ua = getUA();
560
+ const versionPatterns = [
561
+ /(?:edg|edge)\/([0-9.]+)/i,
562
+ /(?:opr|opera)\/([0-9.]+)/i,
563
+ /chrome\/([0-9.]+)/i,
564
+ /firefox\/([0-9.]+)/i,
565
+ /version\/([0-9.]+).*safari/i,
566
+ /(?:msie |rv:)([0-9.]+)/i
567
+ ];
568
+ for (const pattern of versionPatterns) {
569
+ const matches = ua.match(pattern);
570
+ if (matches && matches[1]) {
571
+ return matches[1];
572
+ }
573
+ }
574
+ return null;
575
+ }
576
+ function getOS() {
577
+ const ua = getUA();
578
+ if (/windows/i.test(ua)) return "windows";
579
+ if (/mac os/i.test(ua)) return "macos";
580
+ if (/linux/i.test(ua)) return "linux";
581
+ if (/iphone|ipad|ipod/i.test(ua)) return "ios";
582
+ if (/android/i.test(ua)) return "android";
583
+ return "unknown";
584
+ }
585
+ return __toCommonJS(web_exports);
586
+ })();
package/package.json CHANGED
@@ -1,55 +1,36 @@
1
- {
2
- "name": "@base-web-kits/base-tools-web",
3
- "version": "0.8.11",
4
- "sideEffects": false,
5
- "description": "Independent Web utilities package built from src/web.",
6
- "keywords": [
7
- "base-tools",
8
- "web",
9
- "utilities",
10
- "thin-wrapper"
11
- ],
12
- "license": "MIT",
13
- "main": "./index.cjs",
14
- "module": "./index.js",
15
- "types": "./index.d.ts",
16
- "exports": {
17
- ".": {
18
- "types": "./index.d.ts",
19
- "import": "./index.js",
20
- "require": "./index.cjs",
21
- "default": "./index.js"
22
- },
23
- "./index": {
24
- "types": "./index.d.ts",
25
- "import": "./index.js",
26
- "require": "./index.cjs",
27
- "default": "./index.js"
28
- },
29
- "./index.js": {
30
- "types": "./index.d.ts",
31
- "import": "./index.js",
32
- "require": "./index.cjs",
33
- "default": "./index.js"
34
- },
35
- "./package.json": "./package.json"
36
- },
37
- "typesVersions": {
38
- "*": {
39
- "index": [
40
- "./index.d.ts"
41
- ]
42
- }
43
- },
44
- "files": [
45
- "dist",
46
- "README.md",
47
- "index.d.ts",
48
- "index.js",
49
- "index.cjs"
50
- ],
51
- "dependencies": {},
52
- "publishConfig": {
53
- "registry": "https://registry.npmjs.org"
54
- }
55
- }
1
+ {
2
+ "name": "@base-web-kits/base-tools-web",
3
+ "version": "0.8.13",
4
+ "sideEffects": false,
5
+ "description": "Independent Web utilities package built from src/web.",
6
+ "keywords": [
7
+ "base-tools",
8
+ "web",
9
+ "utilities",
10
+ "thin-wrapper"
11
+ ],
12
+ "license": "MIT",
13
+ "main": "./index.cjs",
14
+ "module": "./index.js",
15
+ "types": "./index.d.ts",
16
+ "typesVersions": {
17
+ "*": {
18
+ "index": [
19
+ "./index.d.ts"
20
+ ]
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "index.d.ts",
27
+ "index.js",
28
+ "index.cjs",
29
+ "base-tools-web.umd.global.js",
30
+ "base-tools-web.umd.global.js.map"
31
+ ],
32
+ "dependencies": {},
33
+ "publishConfig": {
34
+ "registry": "https://registry.npmjs.org"
35
+ }
36
+ }