x-next 1.12.0 → 1.14.0
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/AI_CODING.md +6 -5
- package/AI_USAGE/catalog.md +106 -105
- package/AI_USAGE/components/alert-api.md +48 -0
- package/AI_USAGE/components/alert.md +222 -3
- package/AI_USAGE/components/bar-chart-api.md +177 -0
- package/AI_USAGE/components/bar-chart.md +297 -3
- package/AI_USAGE/components/boxicons.md +147 -0
- package/AI_USAGE/components/button-api.md +144 -0
- package/AI_USAGE/components/button.md +447 -3
- package/AI_USAGE/components/charts.md +81 -0
- package/AI_USAGE/components/checkbox-api.md +145 -0
- package/AI_USAGE/components/checkbox.md +365 -3
- package/AI_USAGE/components/color-picker-api.md +52 -0
- package/AI_USAGE/components/color-picker.md +211 -3
- package/AI_USAGE/components/config-provider-api.md +38 -0
- package/AI_USAGE/components/config-provider.md +250 -3
- package/AI_USAGE/components/date-picker-api.md +1114 -0
- package/AI_USAGE/components/date-picker.md +378 -3
- package/AI_USAGE/components/dialog-api.md +142 -0
- package/AI_USAGE/components/dialog.md +284 -3
- package/AI_USAGE/components/draggable-api.md +146 -0
- package/AI_USAGE/components/draggable.md +259 -0
- package/AI_USAGE/components/drawer-api.md +78 -0
- package/AI_USAGE/components/drawer.md +227 -0
- package/AI_USAGE/components/dropdown-api.md +529 -0
- package/AI_USAGE/components/dropdown.md +392 -3
- package/AI_USAGE/components/empty-api.md +36 -0
- package/AI_USAGE/components/empty.md +227 -3
- package/AI_USAGE/components/finicon.md +88 -0
- package/AI_USAGE/components/form-api.md +524 -0
- package/AI_USAGE/components/form.md +454 -0
- package/AI_USAGE/components/grid-api.md +527 -0
- package/AI_USAGE/components/grid.md +224 -0
- package/AI_USAGE/components/heatmap-api.md +122 -0
- package/AI_USAGE/components/heatmap.md +220 -0
- package/AI_USAGE/components/icon-api.md +4707 -0
- package/AI_USAGE/components/icon.md +257 -0
- package/AI_USAGE/components/image-api.md +440 -0
- package/AI_USAGE/components/image.md +465 -0
- package/AI_USAGE/components/input-api.md +184 -0
- package/AI_USAGE/components/input-number-api.md +66 -0
- package/AI_USAGE/components/input-number.md +294 -0
- package/AI_USAGE/components/input-tag-api.md +114 -0
- package/AI_USAGE/components/input-tag.md +482 -0
- package/AI_USAGE/components/input.md +293 -3
- package/AI_USAGE/components/layout-api.md +147 -0
- package/AI_USAGE/components/layout.md +230 -0
- package/AI_USAGE/components/line-chart-api.md +197 -0
- package/AI_USAGE/components/line-chart.md +279 -3
- package/AI_USAGE/components/link-api.md +42 -0
- package/AI_USAGE/components/link.md +197 -0
- package/AI_USAGE/components/menu-api.md +516 -0
- package/AI_USAGE/components/menu.md +268 -0
- package/AI_USAGE/components/message-api.md +215 -0
- package/AI_USAGE/components/message-box-api.md +108 -0
- package/AI_USAGE/components/message-box.md +268 -3
- package/AI_USAGE/components/message.md +231 -3
- package/AI_USAGE/components/network-api.md +91 -0
- package/AI_USAGE/components/network.md +378 -0
- package/AI_USAGE/components/notification-api.md +236 -0
- package/AI_USAGE/components/notification.md +275 -3
- package/AI_USAGE/components/pagination-api.md +62 -0
- package/AI_USAGE/components/pagination.md +386 -5
- package/AI_USAGE/components/pie-chart-api.md +109 -0
- package/AI_USAGE/components/pie-chart.md +245 -3
- package/AI_USAGE/components/popconfirm-api.md +75 -0
- package/AI_USAGE/components/popconfirm.md +231 -3
- package/AI_USAGE/components/popover-api.md +75 -0
- package/AI_USAGE/components/popover.md +208 -3
- package/AI_USAGE/components/popup-api.md +75 -0
- package/AI_USAGE/components/popup.md +52 -0
- package/AI_USAGE/components/progress-api.md +44 -0
- package/AI_USAGE/components/progress.md +248 -3
- package/AI_USAGE/components/radio-api.md +165 -0
- package/AI_USAGE/components/radio.md +259 -3
- package/AI_USAGE/components/rate-api.md +54 -0
- package/AI_USAGE/components/rate.md +233 -3
- package/AI_USAGE/components/resize-box-api.md +56 -0
- package/AI_USAGE/components/resize-box.md +231 -0
- package/AI_USAGE/components/scrollbar-api.md +77 -0
- package/AI_USAGE/components/scrollbar.md +218 -0
- package/AI_USAGE/components/select-api.md +758 -0
- package/AI_USAGE/components/select.md +640 -3
- package/AI_USAGE/components/skeleton-api.md +85 -0
- package/AI_USAGE/components/skeleton.md +150 -0
- package/AI_USAGE/components/slider-api.md +51 -0
- package/AI_USAGE/components/slider.md +233 -3
- package/AI_USAGE/components/space-api.md +38 -0
- package/AI_USAGE/components/space.md +145 -0
- package/AI_USAGE/components/spin-api.md +43 -0
- package/AI_USAGE/components/spin.md +205 -0
- package/AI_USAGE/components/steps-api.md +111 -0
- package/AI_USAGE/components/steps.md +201 -3
- package/AI_USAGE/components/switch-api.md +58 -0
- package/AI_USAGE/components/switch.md +290 -3
- package/AI_USAGE/components/table-api.md +2919 -0
- package/AI_USAGE/components/table.md +1414 -0
- package/AI_USAGE/components/tabs-api.md +135 -0
- package/AI_USAGE/components/tabs.md +308 -3
- package/AI_USAGE/components/tag-api.md +124 -0
- package/AI_USAGE/components/tag.md +292 -0
- package/AI_USAGE/components/textarea-api.md +55 -0
- package/AI_USAGE/components/textarea.md +326 -3
- package/AI_USAGE/components/time-picker-api.md +137 -0
- package/AI_USAGE/components/time-picker.md +271 -3
- package/AI_USAGE/components/time-range-selector-api.md +44 -0
- package/AI_USAGE/components/time-range-selector.md +355 -0
- package/AI_USAGE/components/timeline-api.md +93 -0
- package/AI_USAGE/components/timeline.md +312 -0
- package/AI_USAGE/components/tooltip-api.md +77 -0
- package/AI_USAGE/components/tooltip.md +182 -0
- package/AI_USAGE/components/trend-chart-api.md +119 -0
- package/AI_USAGE/components/trend-chart.md +335 -0
- package/AI_USAGE/components/trigger-api.md +124 -0
- package/AI_USAGE/components/trigger.md +185 -0
- package/AI_USAGE/components/upload-api.md +200 -0
- package/AI_USAGE/components/upload.md +711 -3
- package/AI_USAGE/components/watermark-api.md +87 -0
- package/AI_USAGE/components/watermark.md +200 -0
- package/AI_USAGE/core.md +1 -1
- package/AI_USAGE/index.md +35 -7
- package/AI_USAGE/recipes/form-on-demand.md +1 -1
- package/AI_USAGE.md +33657 -7
- package/CHANGELOG.md +40 -0
- package/dist/_utils/inherit-component-type.d.ts +11 -0
- package/dist/components/date-picker/index.d.ts +420 -5
- package/dist/components/form-input/index.d.ts +617 -2
- package/dist/components/layout/index.d.ts +689 -1
- package/dist/components/menu/index.d.ts +786 -1
- package/dist/components/network/Network.vue.d.ts +7 -3
- package/dist/components/network/index.d.ts +10 -2
- package/dist/components/network/props.d.ts +5 -0
- package/dist/components/network/utils.d.ts +3 -3
- package/dist/components/pagination/page-item-ellipsis.vue.d.ts +4 -1
- package/dist/components/pagination/page-item-step.vue.d.ts +101 -130
- package/dist/components/pagination/page-item.vue.d.ts +1 -0
- package/dist/components/pagination/page-jumper.vue.d.ts +1 -1
- package/dist/components/pagination/page-options.vue.d.ts +6 -4
- package/dist/components/pagination/utils.d.ts +3 -0
- package/dist/components/time-range-selector/index.d.ts +6 -6
- package/dist/es/_container/resize-observer-v2.js +1 -1
- package/dist/es/_container/resize-observer.js +1 -1
- package/dist/es/_hooks/use-resize-observer.js +1 -1
- package/dist/es/_styles/palette-aliases.js +4 -4
- package/dist/es/_utils/inherit-component-type.js +6 -0
- package/dist/es/_virtual/advancedFormat.js +1 -1
- package/dist/es/_virtual/customParseFormat.js +1 -1
- package/dist/es/_virtual/dayjs.min.js +1 -1
- package/dist/es/_virtual/isBetween.js +1 -1
- package/dist/es/_virtual/quarterOfYear.js +1 -1
- package/dist/es/_virtual/weekOfYear.js +1 -1
- package/dist/es/_virtual/weekYear.js +1 -1
- package/dist/es/_virtual/zh-cn.js +1 -1
- package/dist/es/components/button/Button.js +53 -42
- package/dist/es/components/date-picker/index.js +18 -17
- package/dist/es/components/draggable/useDraggable.js +1 -1
- package/dist/es/components/form/Form.vue2.js +1 -1
- package/dist/es/components/form/FormItem.vue2.js +1 -1
- package/dist/es/components/form-input/index.js +12 -11
- package/dist/es/components/form-input-number/InputNumber.js +1 -1
- package/dist/es/components/form-slider/Slider.vue2.js +1 -1
- package/dist/es/components/form-slider/slider-ticks.vue2.js +1 -1
- package/dist/es/components/form-slider/utils.js +1 -1
- package/dist/es/components/layout/index.js +10 -9
- package/dist/es/components/menu/MenuItem.js +1 -1
- package/dist/es/components/menu/hooks/use-level.js +5 -5
- package/dist/es/components/menu/index.js +13 -10
- package/dist/es/components/menu/overflow-wrap.js +1 -1
- package/dist/es/components/network/Network.vue.js +17 -12
- package/dist/es/components/network/Network.vue2.js +78 -70
- package/dist/es/components/network/utils.js +112 -71
- package/dist/es/components/pagination/Pagination.js +132 -123
- package/dist/es/components/pagination/page-item-ellipsis.vue.js +10 -10
- package/dist/es/components/pagination/page-item-ellipsis.vue2.js +24 -19
- package/dist/es/components/pagination/page-item-step.vue.js +14 -11
- package/dist/es/components/pagination/page-item-step.vue2.js +20 -22
- package/dist/es/components/pagination/page-item.vue.js +10 -9
- package/dist/es/components/pagination/page-item.vue2.js +24 -19
- package/dist/es/components/pagination/page-jumper.vue2.js +23 -23
- package/dist/es/components/pagination/page-options.vue.js +15 -10
- package/dist/es/components/pagination/page-options.vue2.js +21 -17
- package/dist/es/components/pagination/utils.js +4 -2
- package/dist/es/components/progress/circle.vue2.js +1 -1
- package/dist/es/components/progress/line.vue2.js +1 -1
- package/dist/es/components/progress/steps.vue2.js +1 -1
- package/dist/es/components/rate/Rate.js +1 -1
- package/dist/es/components/virtual-list-v2/virtual-list-item.js +1 -1
- package/dist/es/locale/en-US.js +2 -0
- package/dist/es/locale/zh-CN.js +2 -0
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/dayjs.min.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/locale/zh-cn.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/advancedFormat.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/customParseFormat.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/isBetween.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/quarterOfYear.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/weekOfYear.js +1 -1
- package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/dayjs@1.11.21/node_modules/dayjs/plugin/weekYear.js +1 -1
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/locale/interface.d.ts +3 -0
- package/dist/style/base.css +1 -1
- package/dist/style/button.css +1 -1
- package/dist/style/form-select.css +1 -1
- package/dist/style/network.css +1 -1
- package/dist/style/pagination.css +1 -1
- package/dist/style/table.css +1 -1
- package/dist/style.css +1 -1
- package/package.json +10 -5
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/index.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/is.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/locale/en-US.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/array.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/base.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/boolean.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/custom.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/number.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/object.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/string.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/rules/type.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/b-validate@1.5.3/node_modules/b-validate/es/util.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/compute-scroll-into-view@3.1.1/node_modules/compute-scroll-into-view/dist/index.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/number-precision@1.6.0/node_modules/number-precision/build/index.es.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/scroll-into-view-if-needed@3.1.0/node_modules/scroll-into-view-if-needed/dist/index.js +0 -0
- /package/dist/es/{Users/xuyu/Code/x-next/node_modules → node_modules}/.pnpm/sortablejs@1.15.7/node_modules/sortablejs/modular/sortable.esm.js +0 -0
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { useLocale as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { getClassNameMixin as
|
|
4
|
-
import { Network as
|
|
5
|
-
const
|
|
1
|
+
import { useLocale as I } from "../../locale/index.js";
|
|
2
|
+
import { defineComponent as D, shallowRef as R, ref as p, computed as n, watch as $, onMounted as j, onUnmounted as B } from "vue";
|
|
3
|
+
import { getClassNameMixin as F } from "../../_utils/config.js";
|
|
4
|
+
import { Network as Q } from "./utils.js";
|
|
5
|
+
const M = {
|
|
6
6
|
online: !0,
|
|
7
7
|
quality: "unknown",
|
|
8
8
|
source: "manual",
|
|
9
9
|
reason: "initial",
|
|
10
10
|
lastCheckedAt: 0
|
|
11
|
-
},
|
|
11
|
+
}, W = {
|
|
12
12
|
unknown: "network.checking",
|
|
13
13
|
good: "network.good",
|
|
14
14
|
medium: "network.fair",
|
|
15
15
|
poor: "network.poor",
|
|
16
16
|
offline: "network.offline"
|
|
17
|
-
},
|
|
17
|
+
}, T = ["unknown", "good", "medium", "poor", "offline"], A = ["mini", "small", "medium", "large"], J = D({
|
|
18
18
|
name: "Network",
|
|
19
|
+
slots: Object,
|
|
19
20
|
props: {
|
|
20
21
|
size: {
|
|
21
22
|
type: String,
|
|
22
|
-
default: "medium"
|
|
23
|
+
default: "medium",
|
|
24
|
+
validator: (o) => A.includes(o)
|
|
23
25
|
},
|
|
24
26
|
/**
|
|
25
27
|
* @zh 兼容旧版强/弱信号颜色配置
|
|
@@ -40,7 +42,7 @@ const C = {
|
|
|
40
42
|
*/
|
|
41
43
|
status: {
|
|
42
44
|
type: String,
|
|
43
|
-
validator: (
|
|
45
|
+
validator: (o) => T.includes(o)
|
|
44
46
|
},
|
|
45
47
|
/**
|
|
46
48
|
* @zh 主动探测 URL,需要支持 CORS。
|
|
@@ -85,94 +87,100 @@ const C = {
|
|
|
85
87
|
}
|
|
86
88
|
},
|
|
87
89
|
emits: {
|
|
88
|
-
change: (
|
|
89
|
-
online: (
|
|
90
|
-
offline: (
|
|
91
|
-
probe: (
|
|
90
|
+
change: (o) => !0,
|
|
91
|
+
online: (o) => !0,
|
|
92
|
+
offline: (o) => !0,
|
|
93
|
+
probe: (o) => !0
|
|
92
94
|
},
|
|
93
|
-
setup(
|
|
94
|
-
const
|
|
95
|
-
|
|
95
|
+
setup(o, { emit: c, expose: L }) {
|
|
96
|
+
const l = F("network"), r = R(), i = p(M);
|
|
97
|
+
let d = !1;
|
|
98
|
+
const a = n(
|
|
99
|
+
() => o.status == null ? void 0 : T.includes(o.status) ? o.status : "unknown"
|
|
100
|
+
), f = n(() => A.includes(o.size) ? o.size : "medium"), v = n(() => f.value === "small" || f.value === "mini" ? 3 : f.value === "medium" ? 4 : 5), m = (e) => ({
|
|
101
|
+
...M,
|
|
96
102
|
online: e !== "offline",
|
|
97
103
|
quality: e,
|
|
98
104
|
source: "manual",
|
|
99
105
|
lastCheckedAt: Date.now()
|
|
100
|
-
}), u = n(() =>
|
|
101
|
-
() =>
|
|
102
|
-
),
|
|
103
|
-
const [
|
|
106
|
+
}), u = n(() => a.value !== void 0 ? m(a.value) : i.value), { t: S } = I(), k = n(() => S(W[u.value.quality])), N = n(
|
|
107
|
+
() => o.ariaLabel || S("network.ariaLabel", { status: k.value })
|
|
108
|
+
), _ = (e, t = "--") => e === void 0 ? t : e <= 0 ? "0K/s" : e >= 1024 * 1024 ? `${(e / 1024 / 1024).toFixed(1)}M/s` : `${Math.max(1, Math.round(e / 1024))}K/s`, q = n(() => _(u.value.downloadSpeed)), w = n(() => o.showMetrics), E = (e) => {
|
|
109
|
+
const [t, C] = o.signalStrengthColor, g = {
|
|
104
110
|
unknown: "var(--x-network-color-unknown)",
|
|
105
|
-
good:
|
|
106
|
-
medium:
|
|
107
|
-
poor:
|
|
111
|
+
good: t || "var(--x-network-color-good)",
|
|
112
|
+
medium: o.statusColors.medium || "var(--x-network-color-medium)",
|
|
113
|
+
poor: C || "var(--x-network-color-poor)",
|
|
108
114
|
offline: "var(--x-network-color-offline)"
|
|
109
115
|
};
|
|
110
|
-
return
|
|
111
|
-
},
|
|
112
|
-
const e =
|
|
113
|
-
return Array.from({ length:
|
|
114
|
-
const
|
|
116
|
+
return o.statusColors[e] || g[e];
|
|
117
|
+
}, z = (e) => e === "good" ? v.value : e === "medium" ? Math.max(2, Math.ceil(v.value * 0.6)) : e === "poor" ? Math.max(1, Math.ceil(v.value * 0.4)) : 0, K = n(() => {
|
|
118
|
+
const e = z(u.value.quality), t = E(u.value.quality);
|
|
119
|
+
return Array.from({ length: v.value }, (C, g) => {
|
|
120
|
+
const x = g < e;
|
|
115
121
|
return {
|
|
116
|
-
active:
|
|
117
|
-
color:
|
|
122
|
+
active: x,
|
|
123
|
+
color: x || e === 0 ? t : "var(--x-network-color-inactive)"
|
|
118
124
|
};
|
|
119
125
|
});
|
|
120
|
-
}),
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
i.value = e, (!
|
|
124
|
-
},
|
|
125
|
-
var
|
|
126
|
-
if ((
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
}), O = (e, t) => e.online === t.online && e.quality === t.quality && e.source === t.source && e.reason === t.reason && e.latency === t.latency && e.downloadSpeed === t.downloadSpeed && e.speedSource === t.speedSource && e.downlink === t.downlink && e.rtt === t.rtt && e.effectiveType === t.effectiveType, s = p(void 0), U = (e) => {
|
|
127
|
+
if (!d || a.value !== void 0) return;
|
|
128
|
+
const t = s.value ?? i.value;
|
|
129
|
+
i.value = e, (!s.value || !O(s.value, e)) && (s.value = e, c("change", e)), e.source === "probe" && c("probe", e), t.quality !== "offline" && e.quality === "offline" && c("offline", e), t.quality === "offline" && e.quality !== "offline" && c("online", e);
|
|
130
|
+
}, h = (e = !1) => {
|
|
131
|
+
var t;
|
|
132
|
+
if ((t = r.value) == null || t.destroy(), r.value = void 0, e && (s.value = void 0), !!d) {
|
|
133
|
+
if (a.value !== void 0) {
|
|
134
|
+
i.value = m(a.value);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
r.value = new Q(U, {
|
|
138
|
+
ping: o.ping,
|
|
139
|
+
interval: o.interval,
|
|
140
|
+
timeout: o.timeout
|
|
141
|
+
}), s.value || (i.value = r.value.getSnapshot());
|
|
129
142
|
}
|
|
130
|
-
|
|
131
|
-
ping: t.ping,
|
|
132
|
-
interval: t.interval,
|
|
133
|
-
timeout: t.timeout
|
|
134
|
-
}), i.value = r.value.getSnapshot();
|
|
135
|
-
}, S = async () => {
|
|
143
|
+
}, y = async () => {
|
|
136
144
|
var e;
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
return
|
|
145
|
+
if (a.value !== void 0) {
|
|
146
|
+
const t = m(a.value);
|
|
147
|
+
return d && c("change", t), t;
|
|
140
148
|
}
|
|
141
149
|
return await ((e = r.value) == null ? void 0 : e.refresh()) ?? i.value;
|
|
142
150
|
};
|
|
143
|
-
|
|
144
|
-
() => [
|
|
145
|
-
() => {
|
|
146
|
-
|
|
151
|
+
$(
|
|
152
|
+
() => [o.status, o.ping, o.interval, o.timeout],
|
|
153
|
+
(e, t) => {
|
|
154
|
+
h(e[0] !== t[0]);
|
|
147
155
|
}
|
|
148
|
-
),
|
|
149
|
-
|
|
150
|
-
}),
|
|
156
|
+
), j(() => {
|
|
157
|
+
d = !0, h();
|
|
158
|
+
}), B(() => {
|
|
151
159
|
var e;
|
|
152
|
-
(e = r.value) == null || e.destroy(), r.value = void 0;
|
|
153
|
-
}),
|
|
160
|
+
d = !1, (e = r.value) == null || e.destroy(), r.value = void 0;
|
|
161
|
+
}), L({ refresh: y });
|
|
154
162
|
const b = n(() => [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
l.block,
|
|
164
|
+
l.modifier(f.value),
|
|
165
|
+
l.modifier(`status-${u.value.quality}`),
|
|
158
166
|
{
|
|
159
|
-
[
|
|
160
|
-
[
|
|
167
|
+
[l.is("with-text")]: w.value,
|
|
168
|
+
[l.is("with-metrics")]: w.value
|
|
161
169
|
}
|
|
162
170
|
]);
|
|
163
171
|
return {
|
|
164
|
-
className:
|
|
172
|
+
className: l,
|
|
165
173
|
cls: b,
|
|
166
|
-
lineItems:
|
|
174
|
+
lineItems: K,
|
|
167
175
|
mergedStatus: u,
|
|
168
|
-
statusText:
|
|
169
|
-
mergedAriaLabel:
|
|
170
|
-
formattedDownloadSpeed:
|
|
171
|
-
mergedShowMetrics:
|
|
172
|
-
refresh:
|
|
176
|
+
statusText: k,
|
|
177
|
+
mergedAriaLabel: N,
|
|
178
|
+
formattedDownloadSpeed: q,
|
|
179
|
+
mergedShowMetrics: w,
|
|
180
|
+
refresh: y
|
|
173
181
|
};
|
|
174
182
|
}
|
|
175
183
|
});
|
|
176
184
|
export {
|
|
177
|
-
|
|
185
|
+
J as default
|
|
178
186
|
};
|
|
@@ -1,162 +1,203 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (t, e, n) =>
|
|
4
|
-
const
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var N = (t, e, n) => e in t ? M(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var o = (t, e, n) => N(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
const k = {
|
|
5
5
|
online: !0,
|
|
6
6
|
quality: "unknown",
|
|
7
7
|
source: "manual",
|
|
8
8
|
reason: "initial",
|
|
9
9
|
lastCheckedAt: 0
|
|
10
|
-
},
|
|
10
|
+
}, g = () => Date.now(), l = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), L = () => {
|
|
11
11
|
if (!(typeof navigator > "u"))
|
|
12
12
|
return navigator.connection;
|
|
13
|
-
},
|
|
13
|
+
}, c = () => typeof navigator < "u" && navigator.onLine === !1, w = (t) => typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0, E = (t) => typeof t == "number" && Number.isFinite(t) && t > 0 ? Math.min(2147483647, Math.max(1, t)) : void 0, p = /* @__PURE__ */ new WeakMap(), R = (t, e) => {
|
|
14
|
+
if (t.addEventListener && t.removeEventListener)
|
|
15
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
16
|
+
let n = p.get(t);
|
|
17
|
+
if (!n || t.onchange !== n.dispatch) {
|
|
18
|
+
const i = t.onchange, s = /* @__PURE__ */ new Set();
|
|
19
|
+
n = {
|
|
20
|
+
previous: i,
|
|
21
|
+
listeners: s,
|
|
22
|
+
dispatch(f) {
|
|
23
|
+
try {
|
|
24
|
+
i == null || i.call(t, f);
|
|
25
|
+
} finally {
|
|
26
|
+
for (const u of [...s]) u();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, p.set(t, n), t.onchange = n.dispatch;
|
|
30
|
+
}
|
|
31
|
+
const r = n;
|
|
32
|
+
return r.listeners.add(e), () => {
|
|
33
|
+
r.listeners.delete(e), !r.listeners.size && (t.onchange === r.dispatch && (t.onchange = r.previous ?? null), p.get(t) === r && p.delete(t));
|
|
34
|
+
};
|
|
35
|
+
}, P = (t) => {
|
|
14
36
|
const { effectiveType: e } = t;
|
|
15
37
|
if (e === "slow-2g" || e === "2g") return "poor";
|
|
16
38
|
if (e === "3g") return "medium";
|
|
17
39
|
if (e === "4g") return "good";
|
|
18
|
-
const
|
|
19
|
-
if (!(
|
|
20
|
-
return n > 2 &&
|
|
21
|
-
},
|
|
40
|
+
const n = w(t.downlink), r = w(t.rtt);
|
|
41
|
+
if (!(n === void 0 || r === void 0))
|
|
42
|
+
return n > 2 && r <= 100 ? "good" : n > 1 && r <= 300 ? "medium" : "poor";
|
|
43
|
+
}, D = (t) => t < 500 ? "good" : t < 1500 ? "medium" : "poor", y = (t, e) => ({
|
|
22
44
|
online: !1,
|
|
23
45
|
quality: "offline",
|
|
24
46
|
source: t,
|
|
25
47
|
reason: e,
|
|
26
|
-
lastCheckedAt:
|
|
27
|
-
}),
|
|
48
|
+
lastCheckedAt: g()
|
|
49
|
+
}), d = (t) => {
|
|
28
50
|
if (typeof navigator > "u")
|
|
29
51
|
return {
|
|
30
52
|
online: !0,
|
|
31
53
|
quality: "unknown",
|
|
32
54
|
source: "navigator",
|
|
33
55
|
reason: "unsupported",
|
|
34
|
-
lastCheckedAt:
|
|
56
|
+
lastCheckedAt: g()
|
|
35
57
|
};
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
38
|
-
const e =
|
|
58
|
+
if (c())
|
|
59
|
+
return y("navigator", "browser-offline");
|
|
60
|
+
const e = L();
|
|
39
61
|
return e ? {
|
|
40
62
|
online: !0,
|
|
41
|
-
quality:
|
|
42
|
-
downlink: e.downlink,
|
|
43
|
-
rtt: e.rtt,
|
|
63
|
+
quality: P(e) ?? "unknown",
|
|
64
|
+
downlink: w(e.downlink),
|
|
65
|
+
rtt: w(e.rtt),
|
|
44
66
|
effectiveType: e.effectiveType,
|
|
45
67
|
source: "connection",
|
|
46
68
|
reason: t,
|
|
47
|
-
lastCheckedAt:
|
|
69
|
+
lastCheckedAt: g()
|
|
48
70
|
} : {
|
|
49
71
|
online: !0,
|
|
50
72
|
quality: "good",
|
|
51
73
|
source: "navigator",
|
|
52
74
|
reason: t,
|
|
53
|
-
lastCheckedAt:
|
|
75
|
+
lastCheckedAt: g()
|
|
54
76
|
};
|
|
55
77
|
};
|
|
56
|
-
class
|
|
78
|
+
class F {
|
|
57
79
|
constructor(e, n = {}) {
|
|
58
80
|
o(this, "callback");
|
|
59
81
|
o(this, "options");
|
|
60
82
|
o(this, "timer");
|
|
61
83
|
o(this, "initialTimer");
|
|
62
|
-
o(this, "
|
|
63
|
-
/** 不支持 addEventListener 时保存 connection.onchange 的原处理器,销毁时归还 */
|
|
64
|
-
o(this, "previousConnectionOnChange");
|
|
84
|
+
o(this, "unsubscribeConnection");
|
|
65
85
|
o(this, "controller");
|
|
86
|
+
o(this, "cancelProbe");
|
|
66
87
|
o(this, "destroyed", !1);
|
|
67
88
|
o(this, "pendingRefresh");
|
|
68
89
|
o(this, "sequence", 0);
|
|
69
90
|
o(this, "handleWindowChange", () => {
|
|
70
|
-
this.
|
|
91
|
+
this.refreshAfterBrowserChange(c() ? "browser-offline" : void 0);
|
|
71
92
|
});
|
|
72
93
|
o(this, "handleConnectionChange", () => {
|
|
73
|
-
this.
|
|
94
|
+
this.refreshAfterBrowserChange("connection-change");
|
|
74
95
|
});
|
|
75
96
|
this.callback = e, this.options = n, this.boot();
|
|
76
97
|
}
|
|
77
98
|
checkNetworkQuality() {
|
|
78
|
-
return
|
|
99
|
+
return d().quality;
|
|
79
100
|
}
|
|
80
101
|
getSnapshot() {
|
|
81
|
-
return typeof window > "u" || typeof navigator > "u" ?
|
|
102
|
+
return typeof window > "u" || typeof navigator > "u" ? k : d();
|
|
82
103
|
}
|
|
83
104
|
async refresh(e) {
|
|
105
|
+
if (this.destroyed) return this.getSnapshot();
|
|
84
106
|
if (this.pendingRefresh) return this.pendingRefresh;
|
|
85
|
-
const n = ++this.sequence
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
107
|
+
const n = ++this.sequence, r = this.resolveStatus(e).then((i) => (!this.destroyed && n === this.sequence && this.emitCallback(i), i)).finally(() => {
|
|
108
|
+
this.pendingRefresh === r && (this.pendingRefresh = void 0);
|
|
109
|
+
});
|
|
110
|
+
return this.pendingRefresh = r, r;
|
|
111
|
+
}
|
|
112
|
+
refreshAfterBrowserChange(e) {
|
|
113
|
+
var n;
|
|
114
|
+
this.destroyed || (this.sequence += 1, (n = this.cancelProbe) == null || n.call(this), this.pendingRefresh = void 0, this.refresh(e));
|
|
89
115
|
}
|
|
90
116
|
async resolveStatus(e) {
|
|
91
|
-
return typeof window > "u" || typeof navigator > "u" ?
|
|
117
|
+
return typeof window > "u" || typeof navigator > "u" ? k : c() ? y("navigator", "browser-offline") : this.options.ping ? this.pingNetworkQuality(this.options.ping, this.options.timeout) : d(e);
|
|
92
118
|
}
|
|
93
119
|
async pingNetworkQuality(e, n = 5e3) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
const r = l(), i = typeof AbortController < "u" ? new AbortController() : void 0;
|
|
121
|
+
this.controller = i;
|
|
122
|
+
let s = !1, f = !1, u, b;
|
|
123
|
+
const A = new Promise((m, a) => {
|
|
124
|
+
u = () => {
|
|
125
|
+
f = !0, a(new Error("Network probe cancelled")), i == null || i.abort();
|
|
126
|
+
}, b = setTimeout(() => {
|
|
127
|
+
s = !0, a(new Error("Network probe timeout")), i == null || i.abort();
|
|
128
|
+
}, E(n) ?? 5e3);
|
|
129
|
+
});
|
|
130
|
+
this.cancelProbe = u;
|
|
100
131
|
try {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
const { response: m, headerLatency: a, buffer: v, duration: T } = await Promise.race([
|
|
133
|
+
(async () => {
|
|
134
|
+
const C = await fetch(e, {
|
|
135
|
+
cache: "no-cache",
|
|
136
|
+
method: "GET",
|
|
137
|
+
mode: "cors",
|
|
138
|
+
signal: i == null ? void 0 : i.signal
|
|
139
|
+
}), q = Math.round(l() - r), S = await C.arrayBuffer();
|
|
140
|
+
return { response: C, headerLatency: q, buffer: S, duration: l() - r };
|
|
141
|
+
})(),
|
|
142
|
+
A
|
|
143
|
+
]);
|
|
144
|
+
if (c()) return y("navigator", "browser-offline");
|
|
145
|
+
const h = v.byteLength > 0 && T > 0 ? v.byteLength / T * 1e3 : void 0;
|
|
146
|
+
return m.ok ? {
|
|
147
|
+
...d(),
|
|
148
|
+
quality: D(a),
|
|
110
149
|
latency: a,
|
|
111
|
-
downloadSpeed:
|
|
112
|
-
speedSource:
|
|
150
|
+
downloadSpeed: h,
|
|
151
|
+
speedSource: h ? "probe" : void 0,
|
|
113
152
|
source: "probe"
|
|
114
153
|
} : {
|
|
115
|
-
...
|
|
154
|
+
...d("http-error"),
|
|
116
155
|
quality: "poor",
|
|
117
156
|
latency: a,
|
|
118
|
-
downloadSpeed:
|
|
119
|
-
speedSource:
|
|
157
|
+
downloadSpeed: h,
|
|
158
|
+
speedSource: h ? "probe" : void 0,
|
|
120
159
|
source: "probe",
|
|
121
160
|
reason: "http-error"
|
|
122
161
|
};
|
|
123
|
-
} catch
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
...c(a ? "probe-timeout" : "probe-error"),
|
|
162
|
+
} catch {
|
|
163
|
+
return c() ? y("navigator", "browser-offline") : f ? this.getSnapshot() : {
|
|
164
|
+
...d(s ? "probe-timeout" : "probe-error"),
|
|
127
165
|
quality: "poor",
|
|
128
|
-
latency: Math.round(
|
|
166
|
+
latency: Math.round(l() - r),
|
|
129
167
|
source: "probe",
|
|
130
|
-
reason:
|
|
168
|
+
reason: s ? "probe-timeout" : "probe-error"
|
|
131
169
|
};
|
|
132
170
|
} finally {
|
|
133
|
-
|
|
171
|
+
clearTimeout(b), this.cancelProbe === u && (this.cancelProbe = void 0), this.controller === i && (this.controller = void 0);
|
|
134
172
|
}
|
|
135
173
|
}
|
|
136
174
|
boot() {
|
|
137
175
|
if (typeof window > "u" || typeof navigator > "u")
|
|
138
176
|
return;
|
|
139
177
|
window.addEventListener("online", this.handleWindowChange), window.addEventListener("offline", this.handleWindowChange);
|
|
140
|
-
const e =
|
|
141
|
-
e && (this.
|
|
142
|
-
typeof this.previousConnectionOnChange == "function" && this.previousConnectionOnChange.call(e, n), this.handleConnectionChange();
|
|
143
|
-
})), this.initialTimer = setTimeout(() => {
|
|
178
|
+
const e = L();
|
|
179
|
+
e && (this.unsubscribeConnection = R(e, this.handleConnectionChange)), this.initialTimer = setTimeout(() => {
|
|
144
180
|
this.refresh();
|
|
145
181
|
}, 0), this.scheduleNextRefresh();
|
|
146
182
|
}
|
|
147
183
|
scheduleNextRefresh() {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
184
|
+
const e = E(this.options.interval);
|
|
185
|
+
e === void 0 || this.destroyed || (this.timer = setTimeout(async () => {
|
|
186
|
+
try {
|
|
187
|
+
await this.refresh();
|
|
188
|
+
} finally {
|
|
189
|
+
this.scheduleNextRefresh();
|
|
190
|
+
}
|
|
191
|
+
}, e));
|
|
151
192
|
}
|
|
152
193
|
emitCallback(e) {
|
|
153
194
|
this.callback(e);
|
|
154
195
|
}
|
|
155
196
|
destroy() {
|
|
156
|
-
var e;
|
|
157
|
-
this.destroyed = !0, this.sequence += 1, (e = this.
|
|
197
|
+
var e, n, r;
|
|
198
|
+
this.destroyed || (this.destroyed = !0, this.sequence += 1, (e = this.cancelProbe) == null || e.call(this), this.cancelProbe = void 0, (n = this.controller) == null || n.abort(), this.controller = void 0, this.initialTimer !== void 0 && (clearTimeout(this.initialTimer), this.initialTimer = void 0), this.timer !== void 0 && (clearTimeout(this.timer), this.timer = void 0), typeof window < "u" && (window.removeEventListener("online", this.handleWindowChange), window.removeEventListener("offline", this.handleWindowChange)), (r = this.unsubscribeConnection) == null || r.call(this), this.unsubscribeConnection = void 0);
|
|
158
199
|
}
|
|
159
200
|
}
|
|
160
201
|
export {
|
|
161
|
-
|
|
202
|
+
F as Network
|
|
162
203
|
};
|