@fses/workbench-app 0.1.3 → 0.2.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/dist/{Workspace-CvJghuPy.js → Workspace-DMye5DU8.js} +11458 -11325
- package/dist/canvas/api/index.d.ts +7 -0
- package/dist/canvas/api/index.js +4 -0
- package/dist/canvasFacade-B0oy__da.js +1932 -0
- package/dist/cardFactory-CoDF-zsR.js +1392 -0
- package/dist/extensions/index.d.ts +2 -0
- package/dist/extensions/index.js +8 -0
- package/dist/fses-workbench-app.js +89 -86
- package/dist/index-DbH6tMQy.js +837 -0
- package/dist/internal/personal-workbench/lib/workbenchChatReplyBridge.d.ts +24 -0
- package/dist/runtime/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/{useWorkbenchRuntime-Pekhufen.js → useWorkbenchRuntime-XpOzwm56.js} +8752 -11980
- package/dist/workbenchCustomComponentRegistry-6GHzavdM.js +267 -0
- package/package.json +6 -2
- package/dist/index-DXag5A9X.js +0 -1096
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { c as x, a as z } from "./cardFactory-CoDF-zsR.js";
|
|
2
|
+
import { defineComponent as V, computed as A, ref as C, watch as F, onBeforeUnmount as j, openBlock as h, createElementBlock as y, createElementVNode as o, toDisplayString as u, createCommentVNode as W, normalizeClass as T } from "vue";
|
|
3
|
+
const I = "/workbench-card-previews/custom-cards";
|
|
4
|
+
function U(r) {
|
|
5
|
+
return `${r.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "system_card"}.png`;
|
|
6
|
+
}
|
|
7
|
+
function ve(r) {
|
|
8
|
+
const t = x(
|
|
9
|
+
{
|
|
10
|
+
capabilityId: r,
|
|
11
|
+
meta: {
|
|
12
|
+
id: `system-card-preview-${U(r).replace(/\.png$/u, "")}`,
|
|
13
|
+
systemCardPreview: !0
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
[]
|
|
17
|
+
);
|
|
18
|
+
return t.status !== "success" || !t.block || !t.registryEntry ? null : {
|
|
19
|
+
...t.block,
|
|
20
|
+
meta: {
|
|
21
|
+
...t.block.meta,
|
|
22
|
+
rendererKey: t.registryEntry.rendererKey,
|
|
23
|
+
dataShape: t.registryEntry.dataShape
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function he(r) {
|
|
28
|
+
const t = await z(
|
|
29
|
+
{
|
|
30
|
+
capabilityId: r,
|
|
31
|
+
meta: {
|
|
32
|
+
id: `system-card-preview-${U(r).replace(/\.png$/u, "")}`,
|
|
33
|
+
systemCardPreview: !0
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
[]
|
|
37
|
+
);
|
|
38
|
+
return t.status !== "success" || !t.block || !t.registryEntry ? null : {
|
|
39
|
+
...t.block,
|
|
40
|
+
meta: {
|
|
41
|
+
...t.block.meta,
|
|
42
|
+
rendererKey: t.registryEntry.rendererKey,
|
|
43
|
+
dataShape: t.registryEntry.dataShape
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function D(r) {
|
|
48
|
+
const t = r.trim().replace(/^\/+/, "");
|
|
49
|
+
return `${I}/${t}`;
|
|
50
|
+
}
|
|
51
|
+
const G = D("template_weather_card.png"), Y = "@byteluck-fe/workbench-template.WeatherCard", q = "card.fde.templateWeather", ye = [
|
|
52
|
+
{
|
|
53
|
+
capabilityId: q,
|
|
54
|
+
category: "card.fde_custom_cards",
|
|
55
|
+
type: "templateWeather",
|
|
56
|
+
title: "天气组件",
|
|
57
|
+
description: "@byteluck-fe/workbench-template 提供的天气组件,按城市展示实时天气。",
|
|
58
|
+
blockType: "display",
|
|
59
|
+
subType: "fdeCustom",
|
|
60
|
+
rendererKey: "fdeCustomComponent",
|
|
61
|
+
dataShape: "fdeCustomComponent",
|
|
62
|
+
shell: "card",
|
|
63
|
+
styleVariants: ["standard", "compact", "tile"],
|
|
64
|
+
defaultSize: "componentTall",
|
|
65
|
+
handlerClassName: "WorkbenchTemplateWeatherComponentAbility",
|
|
66
|
+
status: "implemented",
|
|
67
|
+
sourceLabel: "npm",
|
|
68
|
+
componentRef: Y,
|
|
69
|
+
packageName: "@byteluck-fe/workbench-template",
|
|
70
|
+
packageVersion: "0.1.1",
|
|
71
|
+
exportName: "WeatherCard",
|
|
72
|
+
previewUrl: G,
|
|
73
|
+
defaultProps: { city: "上海" },
|
|
74
|
+
insertionMode: "registered"
|
|
75
|
+
}
|
|
76
|
+
], J = ["aria-busy"], Q = { class: "weather-card__header" }, X = { class: "weather-card__heading" }, Z = { class: "weather-card__city" }, ee = {
|
|
77
|
+
key: 0,
|
|
78
|
+
class: "weather-card__region"
|
|
79
|
+
}, te = {
|
|
80
|
+
key: 0,
|
|
81
|
+
class: "weather-card__state"
|
|
82
|
+
}, re = {
|
|
83
|
+
key: 2,
|
|
84
|
+
class: "weather-card__body"
|
|
85
|
+
}, ae = { class: "weather-card__temperature" }, ne = { class: "weather-card__summary" }, le = { class: "weather-card__metrics" }, se = { class: "weather-card__metric" }, oe = { class: "weather-card__metric" }, ie = { class: "weather-card__updated" }, ce = /* @__PURE__ */ V({
|
|
86
|
+
__name: "WeatherCard",
|
|
87
|
+
props: {
|
|
88
|
+
city: {}
|
|
89
|
+
},
|
|
90
|
+
setup(r) {
|
|
91
|
+
const t = r, w = A(() => t.city.trim()), f = A(() => {
|
|
92
|
+
var e;
|
|
93
|
+
return ((e = l.value) == null ? void 0 : e.city) ?? (w.value || "未选择城市");
|
|
94
|
+
}), m = C(!1), p = C(""), E = C("empty"), l = C(null);
|
|
95
|
+
let d = null, g = 0;
|
|
96
|
+
F(
|
|
97
|
+
w,
|
|
98
|
+
(e) => {
|
|
99
|
+
N(e);
|
|
100
|
+
},
|
|
101
|
+
{ immediate: !0 }
|
|
102
|
+
), j(() => {
|
|
103
|
+
d == null || d.abort();
|
|
104
|
+
});
|
|
105
|
+
async function N(e) {
|
|
106
|
+
const a = ++g;
|
|
107
|
+
if (d == null || d.abort(), d = null, l.value = null, p.value = "", !e) {
|
|
108
|
+
m.value = !1, E.value = "empty", p.value = "请输入城市名称";
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const n = new AbortController();
|
|
112
|
+
d = n, m.value = !0;
|
|
113
|
+
try {
|
|
114
|
+
const s = await S(e, n.signal), i = await B(s, n.signal);
|
|
115
|
+
if (a !== g)
|
|
116
|
+
return;
|
|
117
|
+
l.value = O(s, i);
|
|
118
|
+
} catch (s) {
|
|
119
|
+
if (n.signal.aborted || a !== g)
|
|
120
|
+
return;
|
|
121
|
+
E.value = "error", p.value = s instanceof Error ? s.message : "天气数据请求失败";
|
|
122
|
+
} finally {
|
|
123
|
+
a === g && (m.value = !1, d === n && (d = null));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function S(e, a) {
|
|
127
|
+
var n;
|
|
128
|
+
const s = new URL("https://geocoding-api.open-meteo.com/v1/search");
|
|
129
|
+
s.searchParams.set("name", e), s.searchParams.set("count", "1"), s.searchParams.set("language", "zh"), s.searchParams.set("format", "json");
|
|
130
|
+
const i = await fetch(s, { signal: a });
|
|
131
|
+
if (!i.ok)
|
|
132
|
+
throw new Error("城市查询失败");
|
|
133
|
+
const v = (n = (await i.json()).results) == null ? void 0 : n[0];
|
|
134
|
+
if (!v)
|
|
135
|
+
throw new Error(`未找到城市:${e}`);
|
|
136
|
+
return v;
|
|
137
|
+
}
|
|
138
|
+
async function B(e, a) {
|
|
139
|
+
const n = new URL("https://api.open-meteo.com/v1/forecast");
|
|
140
|
+
n.searchParams.set("latitude", String(e.latitude)), n.searchParams.set("longitude", String(e.longitude)), n.searchParams.set(
|
|
141
|
+
"current",
|
|
142
|
+
"temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m"
|
|
143
|
+
), n.searchParams.set("daily", "temperature_2m_max,temperature_2m_min"), n.searchParams.set("forecast_days", "1"), n.searchParams.set("timezone", "auto");
|
|
144
|
+
const s = await fetch(n, { signal: a });
|
|
145
|
+
if (!s.ok)
|
|
146
|
+
throw new Error("天气数据请求失败");
|
|
147
|
+
const i = await s.json();
|
|
148
|
+
if (!i.current)
|
|
149
|
+
throw new Error("天气数据暂不可用");
|
|
150
|
+
return i;
|
|
151
|
+
}
|
|
152
|
+
function O(e, a) {
|
|
153
|
+
var n, s, i, v, k, P;
|
|
154
|
+
const c = a.current, b = a.daily, L = [e.admin2, e.admin1, e.country].filter((R, H, M) => !!R && M.indexOf(R) === H).join(" / ");
|
|
155
|
+
return {
|
|
156
|
+
city: e.name,
|
|
157
|
+
region: L,
|
|
158
|
+
condition: $(c == null ? void 0 : c.weather_code),
|
|
159
|
+
temperature: c == null ? void 0 : c.temperature_2m,
|
|
160
|
+
temperatureUnit: ((n = a.current_units) == null ? void 0 : n.temperature_2m) ?? "°C",
|
|
161
|
+
humidity: c == null ? void 0 : c.relative_humidity_2m,
|
|
162
|
+
humidityUnit: ((s = a.current_units) == null ? void 0 : s.relative_humidity_2m) ?? "%",
|
|
163
|
+
windSpeed: c == null ? void 0 : c.wind_speed_10m,
|
|
164
|
+
windSpeedUnit: ((i = a.current_units) == null ? void 0 : i.wind_speed_10m) ?? "km/h",
|
|
165
|
+
high: (v = b == null ? void 0 : b.temperature_2m_max) == null ? void 0 : v[0],
|
|
166
|
+
low: (k = b == null ? void 0 : b.temperature_2m_min) == null ? void 0 : k[0],
|
|
167
|
+
rangeUnit: ((P = a.daily_units) == null ? void 0 : P.temperature_2m_max) ?? "°C",
|
|
168
|
+
updatedAt: K(c == null ? void 0 : c.time)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function $(e) {
|
|
172
|
+
return e === 0 ? { label: "晴", tone: "clear" } : e === 1 || e === 2 ? { label: "多云", tone: "cloudy" } : e === 3 ? { label: "阴", tone: "cloudy" } : e === 45 || e === 48 ? { label: "雾", tone: "fog" } : [51, 53, 55, 56, 57, 61, 63, 65, 66, 67, 80, 81, 82].includes(e ?? -1) ? { label: "降雨", tone: "rain" } : [71, 73, 75, 77, 85, 86].includes(e ?? -1) ? { label: "降雪", tone: "snow" } : [95, 96, 99].includes(e ?? -1) ? { label: "雷阵雨", tone: "storm" } : { label: "未知", tone: "neutral" };
|
|
173
|
+
}
|
|
174
|
+
function K(e) {
|
|
175
|
+
return e ? e.replace("T", " ") : "未知";
|
|
176
|
+
}
|
|
177
|
+
function _(e, a) {
|
|
178
|
+
return typeof e != "number" ? "--" : `${Math.round(e)}${a}`;
|
|
179
|
+
}
|
|
180
|
+
return (e, a) => {
|
|
181
|
+
var n, s;
|
|
182
|
+
return h(), y("section", {
|
|
183
|
+
class: "weather-card",
|
|
184
|
+
"aria-busy": m.value
|
|
185
|
+
}, [
|
|
186
|
+
o("div", Q, [
|
|
187
|
+
o("div", X, [
|
|
188
|
+
a[0] || (a[0] = o("div", { class: "weather-card__label" }, "实时天气", -1)),
|
|
189
|
+
o("h2", Z, u(f.value), 1),
|
|
190
|
+
(n = l.value) != null && n.region ? (h(), y("p", ee, u(l.value.region), 1)) : W("", !0)
|
|
191
|
+
]),
|
|
192
|
+
o("div", {
|
|
193
|
+
class: T(["weather-card__badge", l.value ? `weather-card__badge--${l.value.condition.tone}` : void 0])
|
|
194
|
+
}, u(((s = l.value) == null ? void 0 : s.condition.label) ?? "待更新"), 3)
|
|
195
|
+
]),
|
|
196
|
+
m.value ? (h(), y("div", te, "正在获取天气...")) : p.value ? (h(), y("div", {
|
|
197
|
+
key: 1,
|
|
198
|
+
class: T(["weather-card__state", { "weather-card__state--error": E.value === "error" }])
|
|
199
|
+
}, u(p.value), 3)) : l.value ? (h(), y("div", re, [
|
|
200
|
+
o("div", ae, u(_(l.value.temperature, l.value.temperatureUnit)), 1),
|
|
201
|
+
o("div", ne, [
|
|
202
|
+
o("span", null, "最高 " + u(_(l.value.high, l.value.rangeUnit)), 1),
|
|
203
|
+
o("span", null, "最低 " + u(_(l.value.low, l.value.rangeUnit)), 1)
|
|
204
|
+
]),
|
|
205
|
+
o("div", le, [
|
|
206
|
+
o("div", se, [
|
|
207
|
+
a[1] || (a[1] = o("span", { class: "weather-card__metric-label" }, "湿度", -1)),
|
|
208
|
+
o("strong", null, u(_(l.value.humidity, l.value.humidityUnit)), 1)
|
|
209
|
+
]),
|
|
210
|
+
o("div", oe, [
|
|
211
|
+
a[2] || (a[2] = o("span", { class: "weather-card__metric-label" }, "风速", -1)),
|
|
212
|
+
o("strong", null, u(_(l.value.windSpeed, l.value.windSpeedUnit)), 1)
|
|
213
|
+
])
|
|
214
|
+
]),
|
|
215
|
+
o("p", ie, "更新时间 " + u(l.value.updatedAt), 1)
|
|
216
|
+
])) : W("", !0)
|
|
217
|
+
], 8, J);
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}), ue = [
|
|
221
|
+
{
|
|
222
|
+
packageName: "@byteluck-fe/workbench-template",
|
|
223
|
+
version: "0.1.1",
|
|
224
|
+
componentRef: "@byteluck-fe/workbench-template.WeatherCard",
|
|
225
|
+
componentName: "天气组件",
|
|
226
|
+
exportName: "WeatherCard",
|
|
227
|
+
enabled: !0,
|
|
228
|
+
component: ce,
|
|
229
|
+
validateProps: (r) => typeof r.city == "string" && r.city.trim().length > 0
|
|
230
|
+
}
|
|
231
|
+
// 示例:
|
|
232
|
+
// {
|
|
233
|
+
// packageName: '@fde-components/sales-summary',
|
|
234
|
+
// version: '1.2.0',
|
|
235
|
+
// componentRef: '@fde-components/sales-summary.SalesSummaryCard',
|
|
236
|
+
// componentName: '销售摘要组件',
|
|
237
|
+
// exportName: 'SalesSummaryCard',
|
|
238
|
+
// enabled: true,
|
|
239
|
+
// component: SalesSummaryCard,
|
|
240
|
+
// validateProps: (props) => typeof props.amount === 'number' && typeof props.trend === 'number',
|
|
241
|
+
// },
|
|
242
|
+
], de = new Map(ue.map((r) => [r.componentRef, r]));
|
|
243
|
+
function me(r, t, w) {
|
|
244
|
+
var f;
|
|
245
|
+
return ((f = r.validateProps) == null ? void 0 : f.call(r, t, w)) ?? !0;
|
|
246
|
+
}
|
|
247
|
+
const we = {
|
|
248
|
+
/**
|
|
249
|
+
* 根据 componentRef 查找已安装、已审核并启用的 npm 组件。
|
|
250
|
+
* @param data - FDE 自定义组件卡片数据。
|
|
251
|
+
* @returns 命中的组件登记项;未登记或禁用时返回 null。
|
|
252
|
+
*/
|
|
253
|
+
resolve(r) {
|
|
254
|
+
const t = de.get(r.componentRef);
|
|
255
|
+
return !t || t.enabled === !1 ? null : t;
|
|
256
|
+
},
|
|
257
|
+
validateProps: me
|
|
258
|
+
};
|
|
259
|
+
export {
|
|
260
|
+
ye as W,
|
|
261
|
+
q as a,
|
|
262
|
+
Y as b,
|
|
263
|
+
G as c,
|
|
264
|
+
we as d,
|
|
265
|
+
he as e,
|
|
266
|
+
ve as s
|
|
267
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fses/workbench-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"./extensions": {
|
|
29
29
|
"types": "./dist/extensions/index.d.ts",
|
|
30
|
-
"import": "./dist/
|
|
30
|
+
"import": "./dist/extensions/index.js"
|
|
31
31
|
},
|
|
32
32
|
"./adapters": {
|
|
33
33
|
"types": "./dist/adapters/index.d.ts",
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"types": "./dist/canvas/api/types.d.ts",
|
|
54
54
|
"import": "./dist/fses-workbench-app.js"
|
|
55
55
|
},
|
|
56
|
+
"./canvas/api": {
|
|
57
|
+
"types": "./dist/canvas/api/index.d.ts",
|
|
58
|
+
"import": "./dist/canvas/api/index.js"
|
|
59
|
+
},
|
|
56
60
|
"./canvas/bridge/workbenchCanvasBus": {
|
|
57
61
|
"types": "./dist/canvas/bridge/workbenchCanvasBus.d.ts",
|
|
58
62
|
"import": "./dist/fses-workbench-app.js"
|