@lumal/cockpit 0.0.5-beta → 0.0.6-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { i as e, n as t, r as n, t as r, v as i, x as a } from "./resolveComponent-_XUQaM5w.js";
2
- import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createSlots as f, createTextVNode as p, createVNode as m, defineComponent as h, guardReactiveProps as g, inject as _, mergeModels as v, nextTick as y, normalizeClass as b, normalizeProps as x, normalizeStyle as S, onBeforeUnmount as C, openBlock as w, provide as ee, reactive as T, ref as E, renderList as D, renderSlot as O, resolveDynamicComponent as k, shallowReactive as A, shallowRef as j, toDisplayString as M, toValue as N, unref as P, useId as F, useModel as I, useSlots as te, vShow as L, watch as R, watchEffect as z, withCtx as B, withDirectives as V } from "vue";
3
- import { ElButton as H, ElSwitch as ne, ElTooltip as re } from "element-plus";
4
- import { LumalIcon as ie } from "@lumal/icons-vue";
1
+ import { i as e, n as t, r as n, t as r, v as i, x as a } from "./resolveComponent-DK0l5LAa.js";
2
+ import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createSlots as f, createTextVNode as p, createVNode as m, defineComponent as h, guardReactiveProps as g, inject as _, mergeModels as v, nextTick as y, normalizeClass as b, normalizeProps as x, normalizeStyle as S, onBeforeUnmount as C, openBlock as w, provide as ee, reactive as T, ref as E, renderList as D, renderSlot as O, resolveDynamicComponent as k, shallowReactive as A, shallowRef as j, toDisplayString as M, toValue as N, unref as P, useId as F, useModel as I, useSlots as te, useTemplateRef as L, vShow as R, watch as z, watchEffect as B, withCtx as V, withDirectives as ne } from "vue";
3
+ import { ElButton as re, ElSwitch as ie, ElTooltip as ae } from "element-plus";
4
+ import { LumalIcon as H } from "@lumal/icons-vue";
5
5
  //#region src/composables/useCockpit.ts
6
6
  function U(e) {
7
7
  let t = s(() => {
@@ -47,9 +47,9 @@ function K(e) {
47
47
  function o() {
48
48
  !document.hidden && t.value && r("interval");
49
49
  }
50
- return typeof document < "u" && document.addEventListener("visibilitychange", o), R(t, (e) => {
50
+ return typeof document < "u" && document.addEventListener("visibilitychange", o), z(t, (e) => {
51
51
  e ? a() : i();
52
- }, { immediate: !0 }), R(() => N(e.intervalMs), () => {
52
+ }, { immediate: !0 }), z(() => N(e.intervalMs), () => {
53
53
  t.value && a();
54
54
  }), C(() => {
55
55
  i(), typeof document < "u" && document.removeEventListener("visibilitychange", o);
@@ -68,20 +68,20 @@ function J() {
68
68
  }
69
69
  //#endregion
70
70
  //#region src/runtime/LumalCockpitWidgetHost.vue?vue&type=script&setup=true&lang.ts
71
- var Y = [
71
+ var oe = [
72
72
  "data-widget-type",
73
73
  "data-instance-id",
74
74
  "data-cockpit-node-id",
75
75
  "data-cockpit-side"
76
- ], ae = { class: "lumal-cockpit-widget__body" }, oe = {
76
+ ], se = { class: "lumal-cockpit-widget__body" }, ce = {
77
77
  key: 1,
78
78
  class: "lumal-cockpit-widget__missing",
79
79
  role: "status"
80
- }, se = {
80
+ }, le = {
81
81
  key: 1,
82
82
  class: "lumal-cockpit-widget__error",
83
83
  role: "alert"
84
- }, X = /* @__PURE__ */ h({
84
+ }, Y = /* @__PURE__ */ h({
85
85
  __name: "LumalCockpitWidgetHost",
86
86
  props: {
87
87
  layoutId: {},
@@ -100,7 +100,7 @@ var Y = [
100
100
  mode: a.mode,
101
101
  messages: a.messages
102
102
  });
103
- z(() => {
103
+ B(() => {
104
104
  _.cockpitId = a.cockpitId, _.layoutId = n.layoutId, _.instanceId = n.widget.id, _.mode = a.mode, _.messages = a.messages;
105
105
  }), i(_), C(() => {
106
106
  a.messages.clearInstance(n.widget.id);
@@ -117,51 +117,51 @@ var Y = [
117
117
  "data-cockpit-node-id": e.widget.id,
118
118
  "data-cockpit-side": e.side
119
119
  }, [(w(), c(k(y.value), x(g(b.value)), f({
120
- default: B(() => [d("div", ae, [l.value ? (w(), c(t, { key: 1 }, {
121
- error: B(({ retry: t }) => [P(a).slots.error ? (w(), c(k(P(a).slots.error), {
120
+ default: V(() => [d("div", se, [l.value ? (w(), c(t, { key: 1 }, {
121
+ error: V(({ retry: t }) => [P(a).slots.error ? (w(), c(k(P(a).slots.error), {
122
122
  key: 0,
123
123
  retry: t,
124
124
  "instance-id": e.widget.id
125
- }, null, 8, ["retry", "instance-id"])) : (w(), u("div", se, [r[1] ||= d("span", null, "模块加载失败", -1), m(P(H), {
125
+ }, null, 8, ["retry", "instance-id"])) : (w(), u("div", le, [r[1] ||= d("span", null, "模块加载失败", -1), m(P(re), {
126
126
  text: "",
127
127
  type: "primary",
128
128
  onClick: t
129
129
  }, {
130
- default: B(() => [m(P(ie), {
130
+ default: V(() => [m(P(H), {
131
131
  name: "lumal:refresh",
132
132
  size: 14
133
133
  }), r[0] ||= p(" 重试 ", -1)]),
134
134
  _: 1
135
135
  }, 8, ["onClick"])]))]),
136
- default: B(() => [(w(), c(k(h.value), { context: P(_) }, null, 8, ["context"]))]),
136
+ default: V(() => [(w(), c(k(h.value), { context: P(_) }, null, 8, ["context"]))]),
137
137
  _: 1
138
138
  })) : (w(), u(o, { key: 0 }, [P(a).slots["missing-widget"] ? (w(), c(k(P(a).slots["missing-widget"]), {
139
139
  key: 0,
140
140
  type: e.widget.type,
141
141
  "instance-id": e.widget.id
142
- }, null, 8, ["type", "instance-id"])) : (w(), u("div", oe, " 未注册模块:" + M(e.widget.type), 1))], 64))])]),
142
+ }, null, 8, ["type", "instance-id"])) : (w(), u("div", ce, " 未注册模块:" + M(e.widget.type), 1))], 64))])]),
143
143
  _: 2
144
144
  }, [!e.embedded && P(a).slots["widget-title"] ? {
145
145
  name: "title",
146
- fn: B(() => [(w(), c(k(P(a).slots["widget-title"]), {
146
+ fn: V(() => [(w(), c(k(P(a).slots["widget-title"]), {
147
147
  widget: e.widget,
148
148
  title: v.value
149
149
  }, null, 8, ["widget", "title"]))]),
150
150
  key: "0"
151
- } : void 0]), 1040))], 8, Y));
151
+ } : void 0]), 1040))], 8, oe));
152
152
  }
153
- }), ce = ["data-cockpit-node-id", "data-cockpit-side"], le = ["data-cockpit-node-id", "data-cockpit-side"], ue = {
153
+ }), ue = ["data-cockpit-node-id", "data-cockpit-side"], de = ["data-cockpit-node-id", "data-cockpit-side"], fe = {
154
154
  key: 1,
155
155
  class: "lumal-cockpit-container__empty",
156
156
  role: "status"
157
- }, de = {
157
+ }, pe = {
158
158
  key: 0,
159
159
  class: "lumal-cockpit-container__tabpanel"
160
- }, fe = {
160
+ }, me = {
161
161
  key: 1,
162
162
  class: "lumal-cockpit-container__empty",
163
163
  role: "status"
164
- }, Z = /* @__PURE__ */ h({
164
+ }, X = /* @__PURE__ */ h({
165
165
  __name: "LumalCockpitContainer",
166
166
  props: {
167
167
  columns: {},
@@ -179,14 +179,14 @@ var Y = [
179
179
  let e = t.row.activeWidgetId;
180
180
  return t.row.widgets.some((t) => t.id === e) ? e : t.row.widgets[0]?.id;
181
181
  }
182
- return R(() => [t.row.id, t.row.activeWidgetId], () => {
182
+ return z(() => [t.row.id, t.row.activeWidgetId], () => {
183
183
  i.value = h();
184
- }, { immediate: !0 }), R(() => t.row.widgets.map((e) => e.id).join(","), () => {
184
+ }, { immediate: !0 }), z(() => t.row.widgets.map((e) => e.id).join(","), () => {
185
185
  let e = new Set(t.row.widgets.map((e) => e.id));
186
186
  a.forEach((t) => {
187
187
  e.has(t) || a.delete(t);
188
188
  }), t.row.widgets.some((e) => e.id === i.value) || (i.value = h());
189
- }), R(i, (e) => {
189
+ }), z(i, (e) => {
190
190
  e && a.add(e);
191
191
  }, { immediate: !0 }), (t, s) => (w(), u("section", {
192
192
  class: b(["lumal-cockpit-container", { "is-tabs": e.row.mode === "tabs" }]),
@@ -204,7 +204,7 @@ var Y = [
204
204
  "data-cockpit-node": "cell",
205
205
  "data-cockpit-node-id": t.id,
206
206
  "data-cockpit-side": e.side
207
- }, [t.widget ? (w(), c(X, {
207
+ }, [t.widget ? (w(), c(Y, {
208
208
  key: t.widget.id,
209
209
  "layout-id": e.layoutId,
210
210
  side: e.side,
@@ -213,13 +213,13 @@ var Y = [
213
213
  "layout-id",
214
214
  "side",
215
215
  "widget"
216
- ])) : (w(), u("div", ue, " 空模块槽 "))], 8, le))), 128))], 4)) : (w(), u(o, { key: 1 }, [e.row.widgets.length ? (w(), c(k(P(d).cardComponent), {
216
+ ])) : (w(), u("div", fe, " 空模块槽 "))], 8, de))), 128))], 4)) : (w(), u(o, { key: 1 }, [e.row.widgets.length ? (w(), c(k(P(d).cardComponent), {
217
217
  key: 0,
218
218
  "active-tab-id": i.value,
219
219
  "onUpdate:activeTabId": s[0] ||= (e) => i.value = e,
220
220
  tabs: p.value
221
221
  }, f({
222
- default: B(() => [(w(!0), u(o, null, D(e.row.widgets, (t) => (w(), u(o, { key: t.id }, [(P(d).cachePages ? a.has(t.id) : t.id === i.value) ? V((w(), u("div", de, [m(X, {
222
+ default: V(() => [(w(!0), u(o, null, D(e.row.widgets, (t) => (w(), u(o, { key: t.id }, [(P(d).cachePages ? a.has(t.id) : t.id === i.value) ? ne((w(), u("div", pe, [m(Y, {
223
223
  embedded: "",
224
224
  "layout-id": e.layoutId,
225
225
  side: e.side,
@@ -228,29 +228,29 @@ var Y = [
228
228
  "layout-id",
229
229
  "side",
230
230
  "widget"
231
- ])], 512)), [[L, t.id === i.value]]) : l("", !0)], 64))), 128))]),
231
+ ])], 512)), [[R, t.id === i.value]]) : l("", !0)], 64))), 128))]),
232
232
  _: 2
233
233
  }, [P(d).slots["widget-title"] ? {
234
234
  name: "title",
235
- fn: B(({ title: e, widget: t }) => [(w(), c(k(P(d).slots["widget-title"]), {
235
+ fn: V(({ title: e, widget: t }) => [(w(), c(k(P(d).slots["widget-title"]), {
236
236
  widget: t,
237
237
  title: e
238
238
  }, null, 8, ["widget", "title"]))]),
239
239
  key: "0"
240
240
  } : void 0, P(d).slots["widget-title"] ? {
241
241
  name: "tab",
242
- fn: B(({ tab: e }) => [(w(), c(k(P(d).slots["widget-title"]), {
242
+ fn: V(({ tab: e }) => [(w(), c(k(P(d).slots["widget-title"]), {
243
243
  widget: e.widget,
244
244
  title: e.title
245
245
  }, null, 8, ["widget", "title"]))]),
246
246
  key: "1"
247
- } : void 0]), 1064, ["active-tab-id", "tabs"])) : (w(), u("div", fe, " 空 Tab 行 "))], 64))], 14, ce));
247
+ } : void 0]), 1064, ["active-tab-id", "tabs"])) : (w(), u("div", me, " 空 Tab 行 "))], 64))], 14, ue));
248
248
  }
249
- }), pe = [
249
+ }), he = [
250
250
  "data-side",
251
251
  "data-cockpit-node-id",
252
252
  "data-cockpit-side"
253
- ], Q = /* @__PURE__ */ h({
253
+ ], Z = /* @__PURE__ */ h({
254
254
  __name: "LumalCockpitRegion",
255
255
  props: {
256
256
  layoutId: {},
@@ -266,7 +266,7 @@ var Y = [
266
266
  "data-cockpit-node-id": `${e.layoutId}:${e.side}`,
267
267
  "data-cockpit-side": e.side,
268
268
  style: S(r.value)
269
- }, [(w(!0), u(o, null, D(e.region.rows, (t) => (w(), c(Z, {
269
+ }, [(w(!0), u(o, null, D(e.region.rows, (t) => (w(), c(X, {
270
270
  key: t.id,
271
271
  "layout-id": e.layoutId,
272
272
  side: e.side,
@@ -277,9 +277,9 @@ var Y = [
277
277
  "side",
278
278
  "columns",
279
279
  "row"
280
- ]))), 128))], 12, pe));
280
+ ]))), 128))], 12, he));
281
281
  }
282
- }), me = ["data-scale", "data-viewport-mode"], he = { class: "lumal-cockpit-canvas__header" }, ge = { class: "lumal-cockpit-canvas__header-prefix" }, _e = { class: "lumal-cockpit-canvas__title" }, ve = { class: "lumal-cockpit-canvas__header-actions" }, ye = { class: "lumal-cockpit-canvas__body" }, be = { class: "lumal-cockpit-canvas__center" }, xe = { class: "lumal-cockpit-canvas__left" }, Se = { class: "lumal-cockpit-canvas__right" }, Ce = /* @__PURE__ */ h({
282
+ }), ge = ["data-scale", "data-viewport-mode"], _e = { class: "lumal-cockpit-canvas__header" }, ve = { class: "lumal-cockpit-canvas__header-prefix" }, ye = { class: "lumal-cockpit-canvas__title" }, be = { class: "lumal-cockpit-canvas__header-actions" }, xe = { class: "lumal-cockpit-canvas__body" }, Se = { class: "lumal-cockpit-canvas__center" }, Ce = { class: "lumal-cockpit-canvas__left" }, we = { class: "lumal-cockpit-canvas__right" }, Q = /* @__PURE__ */ h({
283
283
  __name: "LumalCockpitCanvas",
284
284
  props: {
285
285
  title: {},
@@ -290,9 +290,10 @@ var Y = [
290
290
  viewportMode: {}
291
291
  },
292
292
  setup(e) {
293
- let t = e, n = E(null), { result: r } = a(n, {
293
+ let t = e, n = L("containerRef"), { result: r } = a(n, {
294
294
  baseWidth: () => t.baseWidth,
295
- baseHeight: () => t.baseHeight
295
+ baseHeight: () => t.baseHeight,
296
+ enabled: () => t.viewportMode === "scale"
296
297
  }), i = s(() => t.viewportMode === "vwvh" ? {
297
298
  width: "100vw",
298
299
  height: "100vh",
@@ -320,55 +321,55 @@ var Y = [
320
321
  }, [d("div", {
321
322
  class: "lumal-cockpit-canvas__stage",
322
323
  style: S(i.value)
323
- }, [d("header", he, [
324
- d("div", ge, [O(t.$slots, "header-prefix")]),
325
- d("div", _e, [O(t.$slots, "header-title", { title: e.title }, () => [d("h1", null, M(e.title), 1)])]),
326
- d("div", ve, [O(t.$slots, "header-actions")])
327
- ]), d("div", ye, [
328
- d("main", be, [O(t.$slots, "center", {
324
+ }, [d("header", _e, [
325
+ d("div", ve, [O(t.$slots, "header-prefix")]),
326
+ d("div", ye, [O(t.$slots, "header-title", { title: e.title }, () => [d("h1", null, M(e.title), 1)])]),
327
+ d("div", be, [O(t.$slots, "header-actions")])
328
+ ]), d("div", xe, [
329
+ d("main", Se, [O(t.$slots, "center", {
329
330
  context: e.centerContext,
330
331
  layout: e.layout
331
332
  }, () => [a[0] ||= d("div", {
332
333
  class: "lumal-cockpit-center__empty",
333
334
  role: "status"
334
335
  }, " 由应用提供中央内容 ", -1)])]),
335
- d("div", xe, [O(t.$slots, "left", {
336
+ d("div", Ce, [O(t.$slots, "left", {
336
337
  layout: e.layout,
337
338
  region: e.layout.left,
338
339
  side: "left"
339
- }, () => [m(Q, {
340
+ }, () => [m(Z, {
340
341
  side: "left",
341
342
  "layout-id": e.layout.id,
342
343
  region: e.layout.left
343
344
  }, null, 8, ["layout-id", "region"])])]),
344
- d("div", Se, [O(t.$slots, "right", {
345
+ d("div", we, [O(t.$slots, "right", {
345
346
  layout: e.layout,
346
347
  region: e.layout.right,
347
348
  side: "right"
348
- }, () => [m(Q, {
349
+ }, () => [m(Z, {
349
350
  side: "right",
350
351
  "layout-id": e.layout.id,
351
352
  region: e.layout.right
352
353
  }, null, 8, ["layout-id", "region"])])])
353
- ])], 4)], 8, me));
354
+ ])], 4)], 8, ge));
354
355
  }
355
- }), we = {
356
+ }), Te = {
356
357
  key: 0,
357
358
  class: "lumal-cockpit-card__header"
358
- }, Te = {
359
+ }, Ee = {
359
360
  class: "lumal-cockpit-card__tablist",
360
361
  role: "tablist",
361
362
  "aria-label": "模块切换"
362
- }, Ee = [
363
+ }, De = [
363
364
  "id",
364
365
  "aria-selected",
365
366
  "tabindex",
366
367
  "onClick",
367
368
  "onKeydown"
368
- ], De = {
369
+ ], Oe = {
369
370
  key: 1,
370
371
  class: "lumal-cockpit-card__header"
371
- }, Oe = { class: "lumal-cockpit-card__title" }, ke = [
372
+ }, ke = { class: "lumal-cockpit-card__title" }, Ae = [
372
373
  "id",
373
374
  "role",
374
375
  "aria-labelledby",
@@ -408,10 +409,10 @@ var Y = [
408
409
  }[e.key], i = n.tabs[r];
409
410
  i && (e.preventDefault(), S(i.id), y(() => a.get(i.id)?.focus()));
410
411
  }
411
- return R(() => [n.activeTabId, n.tabs.map((e) => e.id).join(",")], () => {
412
+ return z(() => [n.activeTabId, n.tabs.map((e) => e.id).join(",")], () => {
412
413
  let e = m.value;
413
414
  c.value && e && e !== n.activeTabId && r("update:activeTabId", e);
414
- }, { immediate: !0 }), (t, n) => (w(), u("section", { class: b(["lumal-cockpit-card", { "is-tabs": c.value }]) }, [c.value ? (w(), u("header", we, [d("div", Te, [(w(!0), u(o, null, D(e.tabs, (e, n) => (w(), u("button", {
415
+ }, { immediate: !0 }), (t, n) => (w(), u("section", { class: b(["lumal-cockpit-card", { "is-tabs": c.value }]) }, [c.value ? (w(), u("header", Te, [d("div", Ee, [(w(!0), u(o, null, D(e.tabs, (e, n) => (w(), u("button", {
415
416
  id: v(n),
416
417
  key: e.id,
417
418
  ref_for: !0,
@@ -427,7 +428,7 @@ var Y = [
427
428
  }, [O(t.$slots, "tab", {
428
429
  tab: e,
429
430
  active: e.id === m.value
430
- }, () => [p(M(e.title), 1)])], 42, Ee))), 128))])])) : g.value || t.$slots.title ? (w(), u("header", De, [d("div", Oe, [O(t.$slots, "title", {
431
+ }, () => [p(M(e.title), 1)])], 42, De))), 128))])])) : g.value || t.$slots.title ? (w(), u("header", Oe, [d("div", ke, [O(t.$slots, "title", {
431
432
  title: g.value,
432
433
  widget: h.value
433
434
  }, () => [p(M(g.value), 1)])])])) : l("", !0), d("div", {
@@ -436,16 +437,16 @@ var Y = [
436
437
  role: c.value ? "tabpanel" : void 0,
437
438
  "aria-labelledby": c.value ? v(Math.max(0, e.tabs.findIndex((e) => e.id === m.value))) : void 0,
438
439
  tabindex: c.value ? 0 : void 0
439
- }, [O(t.$slots, "default", { activeTabId: m.value })], 8, ke)], 2));
440
+ }, [O(t.$slots, "default", { activeTabId: m.value })], 8, Ae)], 2));
440
441
  }
441
- }), Ae = [
442
+ }), je = [
442
443
  "data-mode",
443
444
  "data-cockpit-theme",
444
445
  "data-viewport-mode"
445
- ], je = {
446
+ ], Me = {
446
447
  key: 0,
447
448
  class: "lumal-cockpit__auto-refresh"
448
- }, Me = { class: "lumal-cockpit__auto-refresh-control" }, Ne = /* @__PURE__ */ h({
449
+ }, Ne = { class: "lumal-cockpit__auto-refresh-control" }, Pe = /* @__PURE__ */ h({
449
450
  __name: "LumalCockpit",
450
451
  props: /*@__PURE__*/ v({
451
452
  config: {},
@@ -487,7 +488,7 @@ var Y = [
487
488
  ]),
488
489
  setup(t, { expose: r, emit: i }) {
489
490
  let a = t, c = i, f = I(t, "activeLayoutId"), p = I(t, "themeMode"), h = I(t, "autoRefreshEnabled"), _ = te(), v = j(null), y = j(null), b = "", S = "";
490
- z(() => {
491
+ B(() => {
491
492
  try {
492
493
  let t = JSON.stringify(a.config);
493
494
  if (t === b) {
@@ -504,7 +505,7 @@ var Y = [
504
505
  config: v.value,
505
506
  error: y.value
506
507
  }));
507
- R(() => C.value.error, (e) => {
508
+ z(() => C.value.error, (e) => {
508
509
  e && c("configError", e);
509
510
  }, { immediate: !0 });
510
511
  let T = a.messageBus ?? n(), D = A({
@@ -516,7 +517,7 @@ var Y = [
516
517
  slots: _,
517
518
  cardComponent: a.cardComponent ?? $
518
519
  });
519
- z(() => {
520
+ B(() => {
520
521
  D.cockpitId = v.value?.id ?? a.config.id, D.mode = a.renderMode, D.registry = a.registry, D.cachePages = a.cachePages, D.cardComponent = a.cardComponent ?? $;
521
522
  }), ee(q, D);
522
523
  let k = U({
@@ -532,7 +533,7 @@ var Y = [
532
533
  messages: T
533
534
  };
534
535
  }), N = E(!1);
535
- R([() => a.autoRefresh, h], ([e, t]) => {
536
+ z([() => a.autoRefresh, h], ([e, t]) => {
536
537
  N.value = !!(e && t);
537
538
  }, { immediate: !0 });
538
539
  let F = s(() => {
@@ -543,31 +544,31 @@ var Y = [
543
544
  sourceId: () => v.value?.id ?? a.config.id,
544
545
  intervalMs: () => a.autoRefreshIntervalMs,
545
546
  enabled: N
546
- }), V = E(null);
547
- async function H() {
548
- V.value?.requestFullscreen && await V.value.requestFullscreen();
547
+ }), R = E(null);
548
+ async function ne() {
549
+ R.value?.requestFullscreen && await R.value.requestFullscreen();
549
550
  }
550
- async function ie() {
551
+ async function re() {
551
552
  document.fullscreenElement && await document.exitFullscreen();
552
553
  }
553
- function W() {
554
+ function H() {
554
555
  p.value = p.value === "dark" ? "light" : "dark";
555
556
  }
556
557
  r({
557
- enterFullscreen: H,
558
- exitFullscreen: ie,
558
+ enterFullscreen: ne,
559
+ exitFullscreen: re,
559
560
  messages: T,
560
- toggleTheme: W,
561
+ toggleTheme: H,
561
562
  refreshNow: L
562
563
  });
563
- let G = s(() => !!v.value?.layouts.length);
564
- function J() {
564
+ let W = s(() => !!v.value?.layouts.length);
565
+ function G() {
565
566
  c("configure");
566
567
  }
567
- function Y(e) {
568
+ function J(e) {
568
569
  if (a.renderMode !== "design") return;
569
570
  let t = (e.target instanceof Element ? e.target : null)?.closest("[data-cockpit-node]");
570
- if (!t || !V.value?.contains(t)) return;
571
+ if (!t || !R.value?.contains(t)) return;
571
572
  let n = t.dataset.cockpitNode, r = t.dataset.cockpitNodeId;
572
573
  !n || !r || c("nodeSelect", {
573
574
  kind: n,
@@ -577,19 +578,19 @@ var Y = [
577
578
  }
578
579
  return (e, n) => (w(), u("div", {
579
580
  ref_key: "rootRef",
580
- ref: V,
581
+ ref: R,
581
582
  class: "lumal-cockpit",
582
583
  "data-mode": t.renderMode,
583
584
  "data-cockpit-theme": p.value,
584
585
  "data-viewport-mode": t.viewportMode,
585
- onClickCapture: Y
586
+ onClickCapture: J
586
587
  }, [C.value.error ? O(e.$slots, "error", {
587
588
  key: 0,
588
589
  error: C.value.error
589
590
  }, () => [n[1] ||= d("div", {
590
591
  class: "lumal-cockpit__error",
591
592
  role: "alert"
592
- }, " 配置加载失败 ", -1)]) : G.value ? P(k).activeLayout.value && M.value ? (w(), u(o, { key: 2 }, [m(Ce, {
593
+ }, " 配置加载失败 ", -1)]) : W.value ? P(k).activeLayout.value && M.value ? (w(), u(o, { key: 2 }, [m(Q, {
593
594
  title: v.value.title,
594
595
  "base-width": t.baseWidth,
595
596
  "base-height": t.baseHeight,
@@ -597,10 +598,10 @@ var Y = [
597
598
  layout: P(k).activeLayout.value,
598
599
  "center-context": M.value
599
600
  }, {
600
- "header-prefix": B(() => [O(e.$slots, "header-prefix")]),
601
- "header-title": B((t) => [O(e.$slots, "header-title", x(g(t)))]),
602
- "header-actions": B(() => [t.autoRefresh ? (w(), u("div", je, [m(P(re), { content: h.value ? `关闭自动刷新(每 ${F.value})` : `开启自动刷新(每 ${F.value})` }, {
603
- default: B(() => [d("label", Me, [n[3] ||= d("span", null, "自动刷新", -1), m(P(ne), {
601
+ "header-prefix": V(() => [O(e.$slots, "header-prefix")]),
602
+ "header-title": V((t) => [O(e.$slots, "header-title", x(g(t)))]),
603
+ "header-actions": V(() => [t.autoRefresh ? (w(), u("div", Me, [m(P(ae), { content: h.value ? `关闭自动刷新(每 ${F.value})` : `开启自动刷新(每 ${F.value})` }, {
604
+ default: V(() => [d("label", Ne, [n[3] ||= d("span", null, "自动刷新", -1), m(P(ie), {
604
605
  modelValue: h.value,
605
606
  "onUpdate:modelValue": n[0] ||= (e) => h.value = e,
606
607
  size: "small",
@@ -609,9 +610,9 @@ var Y = [
609
610
  }, null, 8, ["modelValue", "aria-label"])])]),
610
611
  _: 1
611
612
  }, 8, ["content"])])) : l("", !0), O(e.$slots, "header-actions")]),
612
- center: B((t) => [O(e.$slots, "center", x(g(t)))]),
613
- left: B((t) => [O(e.$slots, "left", x(g(t)))]),
614
- right: B((t) => [O(e.$slots, "right", x(g(t)))]),
613
+ center: V((t) => [O(e.$slots, "center", x(g(t)))]),
614
+ left: V((t) => [O(e.$slots, "left", x(g(t)))]),
615
+ right: V((t) => [O(e.$slots, "right", x(g(t)))]),
615
616
  _: 3
616
617
  }, 8, [
617
618
  "title",
@@ -620,20 +621,20 @@ var Y = [
620
621
  "viewport-mode",
621
622
  "layout",
622
623
  "center-context"
623
- ]), O(e.$slots, "configure-trigger", { configure: J })], 64)) : l("", !0) : O(e.$slots, "empty", { key: 1 }, () => [n[2] ||= d("div", {
624
+ ]), O(e.$slots, "configure-trigger", { configure: G })], 64)) : l("", !0) : O(e.$slots, "empty", { key: 1 }, () => [n[2] ||= d("div", {
624
625
  class: "lumal-cockpit__empty",
625
626
  role: "status"
626
- }, " 空驾驶舱 ", -1)])], 40, Ae));
627
+ }, " 空驾驶舱 ", -1)])], 40, je));
627
628
  }
628
629
  });
629
630
  //#endregion
630
631
  //#region src/runtime/index.ts
631
- function Pe(e, t) {
632
+ function Fe(e, t) {
632
633
  let n = e;
633
634
  return n.install = function(n) {
634
635
  n.component(t, e);
635
636
  }, n;
636
637
  }
637
- var Fe = Pe(Ne, "LumalCockpit"), Ie = Pe($, "LumalCockpitCard");
638
+ var Ie = Fe(Pe, "LumalCockpit"), Le = Fe($, "LumalCockpitCard");
638
639
  //#endregion
639
- export { Z as a, J as c, W as d, U as f, Q as i, G as l, Ie as n, X as o, Ce as r, q as s, Fe as t, K as u };
640
+ export { X as a, J as c, W as d, U as f, Z as i, G as l, Le as n, Y as o, Q as r, q as s, Ie as t, K as u };
package/dist/runtime.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./resolveComponent-DXwlDKov.cjs"),t=require("./runtime-Be4SmioJ.cjs");exports.LumalCockpit=t.t,exports.LumalCockpitCanvas=t.r,exports.LumalCockpitCard=t.n,exports.LumalCockpitContainer=t.a,exports.LumalCockpitRegion=t.i,exports.LumalCockpitWidgetHost=t.o,exports.cockpitRuntimeEnvKey=t.s,exports.resolveCockpitComponent=e.t,exports.useCockpitRuntimeEnv=t.c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./resolveComponent-C-IZ1bCO.cjs"),t=require("./runtime-Cpp-LGxT.cjs");exports.LumalCockpit=t.t,exports.LumalCockpitCanvas=t.r,exports.LumalCockpitCard=t.n,exports.LumalCockpitContainer=t.a,exports.LumalCockpitRegion=t.i,exports.LumalCockpitWidgetHost=t.o,exports.cockpitRuntimeEnvKey=t.s,exports.resolveCockpitComponent=e.t,exports.useCockpitRuntimeEnv=t.c;
package/dist/runtime.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./resolveComponent-_XUQaM5w.js";
2
- import { a as t, c as n, i as r, n as i, o as a, r as o, s, t as c } from "./runtime-DTxtlBRg.js";
1
+ import { t as e } from "./resolveComponent-DK0l5LAa.js";
2
+ import { a as t, c as n, i as r, n as i, o as a, r as o, s, t as c } from "./runtime-CwH1dl9E.js";
3
3
  export { c as LumalCockpit, o as LumalCockpitCanvas, i as LumalCockpitCard, t as LumalCockpitContainer, r as LumalCockpitRegion, a as LumalCockpitWidgetHost, s as cockpitRuntimeEnvKey, e as resolveCockpitComponent, n as useCockpitRuntimeEnv };
@@ -23,9 +23,9 @@ export interface UseCanvasScaleOptions {
23
23
  * 监听容器尺寸,实时计算画布缩放。
24
24
  * 使用 requestAnimationFrame 节流 ResizeObserver 回调,避免频繁重排。
25
25
  */
26
- export declare function useCanvasScale(containerRef: Ref<HTMLElement | null>, options: UseCanvasScaleOptions): {
26
+ export declare function useCanvasScale(containerRef: Readonly<Ref<HTMLElement | null>>, options: UseCanvasScaleOptions): {
27
27
  result: import("vue").ShallowRef<CanvasScaleResult, CanvasScaleResult>;
28
- ready: Ref<boolean, boolean>;
28
+ ready: import("vue").ShallowRef<boolean, boolean>;
29
29
  measure: () => void;
30
30
  };
31
31
  //# sourceMappingURL=useCanvasScale.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCanvasScale.d.ts","sourceRoot":"","sources":["../../../src/composables/useCanvasScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAGhD,oDAAoD;AAEpD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,sBAAsB;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,iBAAiB,CAcnB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CACpC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EACrC,OAAO,EAAE,qBAAqB;;;mBAcV,IAAI;EAuDzB"}
1
+ {"version":3,"file":"useCanvasScale.d.ts","sourceRoot":"","sources":["../../../src/composables/useCanvasScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAIhD,oDAAoD;AAEpD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,sBAAsB;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,iBAAiB,CAGnB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CACpC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,EAC/C,OAAO,EAAE,qBAAqB;;;;EAe/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"LumalCockpitCanvas.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/LumalCockpitCanvas.vue"],"names":[],"mappings":"AA+FA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAK9F,kDAAkD;AAElD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,aAAa,EAAE,oBAAoB,CAAA;IACnC,YAAY,EAAE,mBAAmB,CAAA;CAClC,CAAC;AA0JF,QAAA,IAAI,OAAO,IAAU,EAAE,OAAO;;CAAU,EAAE,OAAO,IAAU,EAAE,OAAO;;;CAAU,EAAE,OAAO;;;;CAAU,EAAE,QAAQ;;;;CAAY,CAAE;AACzH,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACpD;IAAE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACnD;IAAE,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACrD;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACzC;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"LumalCockpitCanvas.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/LumalCockpitCanvas.vue"],"names":[],"mappings":"AAgGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAK9F,kDAAkD;AAElD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,aAAa,EAAE,oBAAoB,CAAA;IACnC,YAAY,EAAE,mBAAmB,CAAA;CAClC,CAAC;AA2JF,QAAA,IAAI,OAAO,IAAU,EAAE,OAAO;;CAAU,EAAE,OAAO,IAAU,EAAE,OAAO;;;CAAU,EAAE,OAAO;;;;CAAU,EAAE,QAAQ;;;;CAAY,CAAE;AACzH,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACpD;IAAE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACnD;IAAE,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACrD;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACzC;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1,4 +1,4 @@
1
- import "./resolveComponent-_XUQaM5w.js";
1
+ import "./resolveComponent-DK0l5LAa.js";
2
2
  //#region src/config/validate.ts
3
3
  function e(e, t, n, r, i) {
4
4
  e.has(n) && t.push({
@@ -1 +1 @@
1
- require("./resolveComponent-DXwlDKov.cjs");function e(e,t,n,r,i){e.has(n)&&t.push({level:`error`,message:`${r} 存在重复 id:${n}`,path:i}),e.add(n)}function t(t,n,r,i,a){t.height>0||a.push({level:`error`,message:`行高必须大于 0%。`,path:r}),t.mode===`grid`&&t.cells.length!==n.columns.length&&a.push({level:`error`,message:`普通行的单元格数量必须与列数一致。`,path:r}),t.mode===`tabs`&&t.cells.length&&a.push({level:`error`,message:`Tab 行不能保留普通单元格。`,path:r}),(t.mode===`tabs`?t.widgets:t.cells.flatMap(e=>e.widget?[e.widget]:[])).forEach(t=>{e(i,a,t.id,`模块实例`,[...r,t.id]),t.type.trim()||a.push({level:`error`,message:`模块类型不能为空。`,path:[...r,t.id]})}),t.mode===`tabs`&&t.activeWidgetId&&!t.widgets.some(e=>e.id===t.activeWidgetId)&&a.push({level:`error`,message:`当前 Tab 不存在。`,path:r})}function n(n,r,i,a){n.columns.length||a.push({level:`error`,message:`区域至少需要一列。`,path:r}),n.rows.length||a.push({level:`error`,message:`区域至少需要一行。`,path:r}),n.width>0||a.push({level:`error`,message:`区域宽度必须大于 0 像素。`,path:r});let o=new Set,s=n.columns.reduce((e,t)=>e+t.width,0);n.columns.forEach(t=>{e(o,a,t.id,`列`,[...r,t.id]),t.width>0||a.push({level:`error`,message:`列宽必须大于 0 像素。`,path:[...r,t.id]})}),n.columns.length&&n.width>0&&s!==n.width&&a.push({level:`error`,message:`列宽总和必须等于区域宽度。`,path:r});let c=new Set;n.rows.forEach(o=>{e(c,a,o.id,`行`,[...r,o.id]),t(o,n,[...r,o.id],i,a)});let l=n.rows.reduce((e,t)=>e+t.height,0);Math.abs(l-100)>.01&&a.push({level:`error`,message:`区域行高总和必须为 100%。`,path:r})}function r(t){let r=[];t.schemaVersion!==3&&r.push({level:`error`,message:`配置版本必须为 v3。`}),t.layouts.length||r.push({level:`error`,message:`驾驶舱至少需要一个布局。`});let i=new Set,a=new Set;return t.layouts.forEach(t=>{e(i,r,t.id,`布局`,[t.id]),t.title.trim()||r.push({level:`error`,message:`布局名称不能为空。`,path:[t.id]}),n(t.left,[t.id,`left`],a,r),n(t.right,[t.id,`right`],a,r)}),{valid:!r.some(e=>e.level===`error`),issues:r}}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
1
+ require("./resolveComponent-C-IZ1bCO.cjs");function e(e,t,n,r,i){e.has(n)&&t.push({level:`error`,message:`${r} 存在重复 id:${n}`,path:i}),e.add(n)}function t(t,n,r,i,a){t.height>0||a.push({level:`error`,message:`行高必须大于 0%。`,path:r}),t.mode===`grid`&&t.cells.length!==n.columns.length&&a.push({level:`error`,message:`普通行的单元格数量必须与列数一致。`,path:r}),t.mode===`tabs`&&t.cells.length&&a.push({level:`error`,message:`Tab 行不能保留普通单元格。`,path:r}),(t.mode===`tabs`?t.widgets:t.cells.flatMap(e=>e.widget?[e.widget]:[])).forEach(t=>{e(i,a,t.id,`模块实例`,[...r,t.id]),t.type.trim()||a.push({level:`error`,message:`模块类型不能为空。`,path:[...r,t.id]})}),t.mode===`tabs`&&t.activeWidgetId&&!t.widgets.some(e=>e.id===t.activeWidgetId)&&a.push({level:`error`,message:`当前 Tab 不存在。`,path:r})}function n(n,r,i,a){n.columns.length||a.push({level:`error`,message:`区域至少需要一列。`,path:r}),n.rows.length||a.push({level:`error`,message:`区域至少需要一行。`,path:r}),n.width>0||a.push({level:`error`,message:`区域宽度必须大于 0 像素。`,path:r});let o=new Set,s=n.columns.reduce((e,t)=>e+t.width,0);n.columns.forEach(t=>{e(o,a,t.id,`列`,[...r,t.id]),t.width>0||a.push({level:`error`,message:`列宽必须大于 0 像素。`,path:[...r,t.id]})}),n.columns.length&&n.width>0&&s!==n.width&&a.push({level:`error`,message:`列宽总和必须等于区域宽度。`,path:r});let c=new Set;n.rows.forEach(o=>{e(c,a,o.id,`行`,[...r,o.id]),t(o,n,[...r,o.id],i,a)});let l=n.rows.reduce((e,t)=>e+t.height,0);Math.abs(l-100)>.01&&a.push({level:`error`,message:`区域行高总和必须为 100%。`,path:r})}function r(t){let r=[];t.schemaVersion!==3&&r.push({level:`error`,message:`配置版本必须为 v3。`}),t.layouts.length||r.push({level:`error`,message:`驾驶舱至少需要一个布局。`});let i=new Set,a=new Set;return t.layouts.forEach(t=>{e(i,r,t.id,`布局`,[t.id]),t.title.trim()||r.push({level:`error`,message:`布局名称不能为空。`,path:[t.id]}),n(t.left,[t.id,`left`],a,r),n(t.right,[t.id,`right`],a,r)}),{valid:!r.some(e=>e.level===`error`),issues:r}}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lumal/cockpit",
3
3
  "type": "module",
4
- "version": "0.0.5-beta",
4
+ "version": "0.0.6-beta",
5
5
  "description": "Lumal generic cockpit orchestration framework: layout runtime, component registry, designer and message bus.",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -59,8 +59,9 @@
59
59
  }
60
60
  },
61
61
  "dependencies": {
62
- "@lumal/core": "0.0.5-beta",
63
- "@lumal/icons-vue": "0.0.5-beta",
62
+ "@lumal/core": "0.0.6-beta",
63
+ "@lumal/icons-vue": "0.0.6-beta",
64
+ "@lumal/viewport": "0.0.6-beta",
64
65
  "sortablejs": "^1.15.7"
65
66
  },
66
67
  "devDependencies": {
@@ -1 +0,0 @@
1
- let e=require("vue"),t=require("element-plus"),n=require("@lumal/icons-vue");function r(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,scaledWidth:n,scaledHeight:r,offsetX:0,offsetY:0};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,scaledWidth:a,scaledHeight:o,offsetX:(e-a)/2,offsetY:(t-o)/2}}function i(t,n){let i=(0,e.shallowRef)({scale:1,scaledWidth:n.baseWidth(),scaledHeight:n.baseHeight(),offsetX:0,offsetY:0}),a=(0,e.ref)(!1),o=null,s=0;function c(){let e=t.value;e&&(i.value=r(e.clientWidth,e.clientHeight,n.baseWidth(),n.baseHeight()),a.value=!0)}function l(){if(typeof requestAnimationFrame>`u`){c();return}s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{s=0,c()})}function u(){o?.disconnect(),o=null}function d(){u(),!(n.enabled!==void 0&&!(0,e.toValue)(n.enabled))&&(c(),typeof ResizeObserver<`u`&&t.value&&(o=new ResizeObserver(l),o.observe(t.value)))}return(0,e.watch)([t,n.baseWidth,n.baseHeight,()=>n.enabled===void 0||(0,e.toValue)(n.enabled)],d,{flush:`post`,immediate:!0}),(0,e.onBeforeUnmount)(()=>{s&&typeof cancelAnimationFrame<`u`&&cancelAnimationFrame(s),u()}),{result:i,ready:a,measure:c}}var a=Symbol(`lumal-cockpit-context`);function o(t){(0,e.provide)(a,t)}function s(t=!1){let n=(0,e.inject)(a,null);if(!n&&!t)throw Error(`[cockpit] 未找到驾驶舱渲染上下文,请确认组件在 LumalCockpit 内渲染。`);return n}var c=3,l=320,u=420,d=100,f=0;function p(e=`ck`){f+=1;let t=Date.now().toString(36),n=Math.random().toString(36).slice(2,8);return`${e}-${t}-${f.toString(36)}-${n}`}function m(e,t){return{id:p(`widget`),type:e,title:t}}function h(e=320){return{id:p(`column`),width:e}}function g(e){let t=Math.max(1,e.columns.length),n=Math.max(t,Math.round(e.width)||420);e.width=n;let r=Math.floor(n/t),i=n-r*t;e.columns.forEach(e=>{e.width=r+ +(i>0),i>0&&--i})}function _(){return{id:p(`cell`)}}function v(e,t=`grid`,n=100){return{id:p(`row`),height:n,mode:t,cells:t===`grid`?Array.from({length:Math.max(1,e)},_):[],widgets:[]}}function y(e=1,t=1,n=420){let r=Array.from({length:Math.max(1,e)},()=>h()),i={width:n,columns:r,rows:Array.from({length:Math.max(1,t)},()=>v(r.length,`grid`,100/Math.max(1,t)))};return g(i),i}function b(e=`新布局`){return{id:p(`layout`),title:e,left:y(),right:y()}}function x(e=p(`cockpit`)){let t=b(`布局 1`);return{schemaVersion:3,id:e,title:`驾驶舱`,activeLayoutId:t.id,layouts:[t]}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){return Array.isArray(e)?e:[]}function w(e,t){return typeof e==`string`&&e.trim()?e:t}function T(e,t){let n=typeof e==`number`?e:Number(e);return Number.isFinite(n)&&n>0?n:t}function E(e){if(!(!S(e)||typeof e.type!=`string`||!e.type.trim()))return{id:w(e.id,p(`widget`)),type:e.type,title:typeof e.title==`string`&&e.title.trim()?e.title:void 0}}function D(e){let t=S(e)?e:{};return{id:w(t.id,p(`cell`)),widget:E(t.widget)}}function O(e){let t=C(e).map(e=>{let t=S(e)?e:{};return{id:w(t.id,p(`column`)),width:Math.round(T(t.width,320))}});return t.length?t:[h()]}function k(e,t){let n=S(e)?e:{},r=n.mode===`tabs`?`tabs`:`grid`,i={id:w(n.id,p(`row`)),height:T(n.height,100),mode:r,cells:[],widgets:[]};if(r===`tabs`){i.widgets=C(n.widgets).map(E).filter(e=>!!e);let e=typeof n.activeWidgetId==`string`?n.activeWidgetId:void 0;i.activeWidgetId=i.widgets.some(t=>t.id===e)?e:i.widgets[0]?.id}else{let e=C(n.cells).map(D).slice(0,t);for(;e.length<t;)e.push(_());i.cells=e}return i}function A(e){let t=e.reduce((e,t)=>e+t.height,0);if(t<=0){let t=100/e.length;e.forEach(e=>{e.height=t});return}e.forEach(e=>{e.height=Number((e.height/t*100).toFixed(3))});let n=Number((100-e.reduce((e,t)=>e+t.height,0)).toFixed(3));e[e.length-1]&&(e[e.length-1].height=Number((e[e.length-1].height+n).toFixed(3)))}function j(e){let t=S(e)?e:{},n=O(t.columns),r=n.reduce((e,t)=>e+t.width,0),i=Math.round(T(t.width,r>0?r:420)),a=C(t.rows).map(e=>k(e,n.length));a.length||a.push(v(n.length)),A(a);let o={width:i,columns:n,rows:a};return g(o),o}function M(e){let t=S(e)?e:{},n=b(w(t.title,`未命名布局`));return n.id=w(t.id,n.id),n.left=j(t.left),n.right=j(t.right),n}function N(e){let t=S(e)?e:{},n=C(t.layouts).map(M),r={schemaVersion:3,id:w(t.id,p(`cockpit`)),title:w(t.title,`驾驶舱`),layouts:n.length?n:[b(`布局 1`)]},i=typeof t.activeLayoutId==`string`?t.activeLayoutId:void 0;return r.activeLayoutId=r.layouts.some(e=>e.id===i)?i:r.layouts[0].id,r}function P(e={}){let t=new Map;function n(t,n){let r=e=>{console.error(`[cockpit] 消息订阅处理器异常(topic: ${n})`,e)};try{e.onError?Promise.resolve(e.onError(t,n)).catch(r):r(t)}catch(e){r(e)}}function r(e){let r=t.get(e.topic);if(!r||r.size===0)return;let i=[...r];for(let t of i){let r=e.targetId===void 0,i=t.targetId!==void 0&&t.targetId===e.targetId;if(!(!r&&!i))try{let r=t.handler(e);r&&Promise.resolve(r).catch(t=>n(t,e.topic))}catch(t){n(t,e.topic)}}}function i(e,n,r){let i=t.get(e);i||(i=new Set,t.set(e,i));let a={handler:n,targetId:r?.targetId};return i.add(a),function(){let n=t.get(e);n&&(n.delete(a),n.size===0&&t.delete(e))}}function a(e){for(let[n,r]of t){for(let t of[...r])t.targetId===e&&r.delete(t);r.size===0&&t.delete(n)}}return{publish:r,subscribe:i,clearInstance:a}}var F={class:`lumal-cockpit-error-boundary`},I={class:`lumal-cockpit-error-boundary__fallback`,role:`alert`},L=(0,e.defineComponent)({__name:`CockpitErrorBoundary`,emits:[`error`],setup(r,{emit:i}){let a=i,o=(0,e.ref)(!1),s=(0,e.ref)(null),c=(0,e.ref)(0);(0,e.onErrorCaptured)(e=>(o.value=!0,s.value=e,a(`error`,e),!1));async function l(){o.value=!1,s.value=null,await(0,e.nextTick)(),c.value+=1}return(r,i)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,F,[o.value?(0,e.renderSlot)(r.$slots,`error`,{key:0,error:s.value,retry:l},()=>[(0,e.createElementVNode)(`div`,I,[i[1]||=(0,e.createElementVNode)(`p`,{class:`lumal-cockpit-error-boundary__message`},` 组件渲染失败 `,-1),(0,e.createVNode)((0,e.unref)(t.ElButton),{class:`lumal-cockpit-error-boundary__retry`,onClick:l},{default:(0,e.withCtx)(()=>[(0,e.createVNode)((0,e.unref)(n.LumalIcon),{name:`lumal:refresh`,size:15}),i[0]||=(0,e.createTextVNode)(` 重试 `,-1)]),_:1})])]):(0,e.renderSlot)(r.$slots,`default`,{key:c.value})]))}}),R=new WeakMap;function z(t){if(typeof t==`function`){let n=t,r=R.get(n);if(r)return r;let i=(0,e.defineAsyncComponent)(t);return R.set(n,i),i}return t}Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return s}});