@24city/web-console 0.3.4 → 0.3.6

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.
@@ -42,10 +42,11 @@ export declare const ALLOWED_FONT_SIZES: readonly number[];
42
42
  /** 允许出现在 @media 里的宽度(px)。 */
43
43
  export declare const ALLOWED_BREAKPOINTS: readonly number[];
44
44
  /**
45
- * 检查样式里写死的字号和断点是否落在设计阶梯上,逐处报告(带行号):
45
+ * 检查样式里写死的字号和断点是否落在设计阶梯上,斜体是否只来自本包,逐处报告(带行号):
46
46
  * - `font-size: Npx` 的 N 必须是字号阶梯或展示尺寸里的值(引用 `var(--app-font-size-*)`、`inherit`、`em` 等不受限);
47
- * - `@media` 里 `min-width` / `max-width` 的像素值必须是断点之一。
48
- * 新产品 `expect(checkDesignScale({ sourceRoot })).toEqual([])`;存量产品可以先断言数量不超过现状,只减不增。
47
+ * - `@media` 里 `min-width` / `max-width` 的像素值必须是断点之一;
48
+ * - 不写 `font-style: italic` / `oblique`:重点功能的斜体标题用 `FeatureTitle`,编号用 `FeatureIndex`。
49
+ * 新产品 `expect(checkDesignScale({ sourceRoot })).toEqual([])`;存量产品可以按 `rule` 分别断言数量不超过现状,只减不增。
49
50
  */
50
51
  export declare const checkDesignScale: ({ sourceRoot, exclude }: UiGuardOptions) => UiGuardViolation[];
51
52
  /**
@@ -1,9 +1,9 @@
1
- import { readFileSync as f, readdirSync as L, statSync as _ } from "node:fs";
2
- import { relative as y, join as v } from "node:path";
3
- import { D as x, F as N, B as O } from "../chunks/scale-smFifpMm.js";
4
- const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
1
+ import { readFileSync as m, readdirSync as I, statSync as L } from "node:fs";
2
+ import { relative as A, join as _ } from "node:path";
3
+ import { D as v, F as N, B as O } from "../chunks/scale-smFifpMm.js";
4
+ const C = { "@douyinfe/semi-ui": "2.104.0" }, T = {
5
5
  peerDependencies: C
6
- }, R = /<(button|input|select|textarea|option|label|form|table|thead|tbody|tr|td|th|details|summary|dialog|img|a|ul|ol|li|dl|dt|dd|h[1-6]|p)(\s|>|\/)/, T = [
6
+ }, D = /<(button|input|select|textarea|option|label|form|table|thead|tbody|tr|td|th|details|summary|dialog|img|a|ul|ol|li|dl|dt|dd|h[1-6]|p)(\s|>|\/)/, F = [
7
7
  "lucide-react",
8
8
  "@nuwa/customer-ui",
9
9
  "@nuwa/customer-shell",
@@ -15,28 +15,28 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
15
15
  ".arco-",
16
16
  "@douyinfe/semi-ui/dist/css",
17
17
  "theme-mode"
18
- ], w = ["--semi-", "--app-"], F = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, P = /\b(?:rgba?|hsla?)\((?!\s*var\()/, k = new RegExp(`(?:^|[\\s{;'"])(${w.map((s) => s.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), W = /<IconSpin\b([^>]*)>/g, j = (s) => {
18
+ ], R = ["--semi-", "--app-"], w = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, P = /\b(?:rgba?|hsla?)\((?!\s*var\()/, k = new RegExp(`(?:^|[\\s{;'"])(${R.map((s) => s.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), W = /<IconSpin\b([^>]*)>/g, j = (s) => {
19
19
  for (const i of s.matchAll(W))
20
20
  if (!/(?:^|\s)spin(?=[\s=/]|$)/.test(i[1])) return i[0];
21
21
  return null;
22
- }, h = (s) => L(s).flatMap((i) => {
23
- const e = v(s, i);
24
- return _(e).isDirectory() ? h(e) : [e];
25
- }), S = (s) => /\.test\.(ts|tsx)$/.test(s) || s.startsWith("test/") || s.endsWith(".d.ts"), X = ({ sourceRoot: s, exclude: i = S }) => {
26
- const e = [], r = h(s).map((o) => ({ path: o, file: y(s, o) })).filter(({ file: o }) => !i(o));
22
+ }, h = (s) => I(s).flatMap((i) => {
23
+ const e = _(s, i);
24
+ return L(e).isDirectory() ? h(e) : [e];
25
+ }), S = (s) => /\.test\.(ts|tsx)$/.test(s) || s.startsWith("test/") || s.endsWith(".d.ts"), U = ({ sourceRoot: s, exclude: i = S }) => {
26
+ const e = [], r = h(s).map((o) => ({ path: o, file: A(s, o) })).filter(({ file: o }) => !i(o));
27
27
  for (const { path: o, file: t } of r) {
28
28
  const n = t.endsWith(".tsx");
29
29
  if (!/\.(tsx?|css)$/.test(t)) continue;
30
- const c = f(o, "utf8");
30
+ const c = m(o, "utf8");
31
31
  if (n) {
32
- const m = c.match(R);
33
- m && e.push({ file: t, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${m[0].trim()}` }), /className="/.test(c) && e.push({ file: t, rule: "class-string", detail: "className 应引用 CSS Module,不写工具类字符串" });
32
+ const f = c.match(D);
33
+ f && e.push({ file: t, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${f[0].trim()}` }), /className="/.test(c) && e.push({ file: t, rule: "class-string", detail: "className 应引用 CSS Module,不写工具类字符串" });
34
34
  const g = j(c);
35
35
  g && e.push({ file: t, rule: "static-spinner", detail: `${g} 不会转:Semi 的 IconSpin 要加 spin` });
36
36
  }
37
- for (const m of T)
38
- c.includes(m) && e.push({ file: t, rule: "forbidden-import", detail: `不应引用 ${m}` });
39
- const a = c.match(F);
37
+ for (const f of F)
38
+ c.includes(f) && e.push({ file: t, rule: "forbidden-import", detail: `不应引用 ${f}` });
39
+ const a = c.match(w);
40
40
  a && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${a[0]}` });
41
41
  const u = c.match(P);
42
42
  u && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${u[0]}` });
@@ -44,20 +44,20 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
44
44
  E && e.push({ file: t, rule: "reserved-variable", detail: `不得声明主题变量 ${E[1]}…,品牌主色只能通过 runtime-config 的 brand.primaryColor 设置` });
45
45
  }
46
46
  return e;
47
- }, M = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], z = D.peerDependencies, d = z["@douyinfe/semi-ui"], q = (s) => {
47
+ }, M = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], z = T.peerDependencies, p = z["@douyinfe/semi-ui"], X = (s) => {
48
48
  var r, o;
49
- const i = JSON.parse(f(s, "utf8")), e = [];
49
+ const i = JSON.parse(m(s, "utf8")), e = [];
50
50
  for (const t of M) {
51
51
  const n = ((r = i.dependencies) == null ? void 0 : r[t]) ?? ((o = i.devDependencies) == null ? void 0 : o[t]);
52
- !(t === "@douyinfe/semi-ui" || n !== void 0) || n === d || e.push({
52
+ !(t === "@douyinfe/semi-ui" || n !== void 0) || n === p || e.push({
53
53
  file: "package.json",
54
54
  rule: "semi-version",
55
- detail: n ? `${t} 必须精确声明为 ${d},现在是 ${n}` : `必须声明 ${t} ${d}`
55
+ detail: n ? `${t} 必须精确声明为 ${p},现在是 ${n}` : `必须声明 ${t} ${p}`
56
56
  });
57
57
  }
58
58
  return e;
59
59
  }, G = (s) => {
60
- const i = f(s, "utf8").replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, ""), e = /import\s*\{[^}]*\bsemiCssLayer\b[^}]*\}\s*from\s*['"]@24city\/web-console\/vite['"]/.test(i), r = /\bsemiCssLayer\s*\(\s*\)/.test(i);
60
+ const i = m(s, "utf8").replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, ""), e = /import\s*\{[^}]*\bsemiCssLayer\b[^}]*\}\s*from\s*['"]@24city\/web-console\/vite['"]/.test(i), r = /\bsemiCssLayer\s*\(\s*\)/.test(i);
61
61
  return e && r ? [] : [
62
62
  {
63
63
  file: "vite.config.ts",
@@ -65,32 +65,39 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
65
65
  detail: "plugins 里要加 semiCssLayer()(import { semiCssLayer } from '@24city/web-console/vite'),把 Semi 的样式放进 semi 层"
66
66
  }
67
67
  ];
68
- }, A = [...Object.values(N), ...x], b = Object.values(O), $ = (s) => s.replace(/\/\*[\s\S]*?\*\//g, (i) => i.replace(/[^\n]/g, " ")), p = (s, i) => s.slice(0, i).split(`
69
- `).length, I = (s, i) => h(s).map((e) => ({ path: e, file: y(s, e) })).filter(({ file: e }) => e.endsWith(".css") && !i(e)), H = ({ sourceRoot: s, exclude: i = S }) => {
68
+ }, b = [...Object.values(N), ...v], y = Object.values(O), $ = (s) => s.replace(/\/\*[\s\S]*?\*\//g, (i) => i.replace(/[^\n]/g, " ")), d = (s, i) => s.slice(0, i).split(`
69
+ `).length, x = (s, i) => h(s).map((e) => ({ path: e, file: A(s, e) })).filter(({ file: e }) => e.endsWith(".css") && !i(e)), H = ({ sourceRoot: s, exclude: i = S }) => {
70
70
  const e = [];
71
- for (const { path: r, file: o } of I(s, i)) {
72
- const t = $(f(r, "utf8"));
71
+ for (const { path: r, file: o } of x(s, i)) {
72
+ const t = $(m(r, "utf8"));
73
73
  for (const n of t.matchAll(/font-size\s*:\s*(\d+(?:\.\d+)?)px/g))
74
- A.includes(Number(n[1])) || e.push({
74
+ b.includes(Number(n[1])) || e.push({
75
75
  file: o,
76
- line: p(t, n.index),
76
+ line: d(t, n.index),
77
77
  rule: "font-size-scale",
78
- detail: `font-size: ${n[1]}px 不在字号阶梯上(${[...A].sort((l, c) => l - c).join("、")})`
78
+ detail: `font-size: ${n[1]}px 不在字号阶梯上(${[...b].sort((l, c) => l - c).join("、")})`
79
79
  });
80
80
  for (const n of t.matchAll(/@media[^{]*/g))
81
81
  for (const l of n[0].matchAll(/(min|max)-width\s*:\s*(\d+(?:\.\d+)?)px/g))
82
- b.includes(Number(l[2])) || e.push({
82
+ y.includes(Number(l[2])) || e.push({
83
83
  file: o,
84
- line: p(t, n.index),
84
+ line: d(t, n.index),
85
85
  rule: "breakpoint",
86
- detail: `@media 的 ${l[1]}-width: ${l[2]}px 不是规定的断点(${b.join("、")})`
86
+ detail: `@media 的 ${l[1]}-width: ${l[2]}px 不是规定的断点(${y.join("、")})`
87
87
  });
88
+ for (const n of t.matchAll(/font-style\s*:\s*(italic|oblique)\b/g))
89
+ e.push({
90
+ file: o,
91
+ line: d(t, n.index),
92
+ rule: "font-style",
93
+ detail: `font-style: ${n[1]} 不写在产品样式里:重点功能的斜体标题用 FeatureTitle,编号用 FeatureIndex(@24city/web-console/page)`
94
+ });
88
95
  }
89
96
  return e;
90
97
  }, B = /(?:^|[\s>+~])(?::global\(\s*)?\.(semi-[A-Za-z0-9-]+)/, V = /:not\((?:[^()]|\([^()]*\))*\)/g, J = ({ sourceRoot: s, exclude: i = S }) => {
91
98
  const e = [];
92
- for (const { path: r, file: o } of I(s, i)) {
93
- const t = $(f(r, "utf8"));
99
+ for (const { path: r, file: o } of x(s, i)) {
100
+ const t = $(m(r, "utf8"));
94
101
  for (const n of t.matchAll(/([^{}]+)\{/g)) {
95
102
  const l = n[1];
96
103
  if (l.trimStart().startsWith("@")) continue;
@@ -99,7 +106,7 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
99
106
  const u = a.replace(V, "").trim().match(B);
100
107
  u && e.push({
101
108
  file: o,
102
- line: p(t, n.index + c + (a.length - a.trimStart().length)),
109
+ line: d(t, n.index + c + (a.length - a.trimStart().length)),
103
110
  rule: "semi-internals",
104
111
  detail: `选择器 ${a.trim()} 伸进了 Semi 组件内部(.${u[1]})`
105
112
  }), c += a.length + 1;
@@ -109,16 +116,16 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
109
116
  return e;
110
117
  };
111
118
  export {
112
- b as ALLOWED_BREAKPOINTS,
113
- A as ALLOWED_FONT_SIZES,
114
- d as EXPECTED_SEMI_VERSION,
115
- T as FORBIDDEN_SNIPPETS,
116
- R as RAW_ELEMENT_PATTERN,
117
- w as RESERVED_VARIABLE_PREFIXES,
119
+ y as ALLOWED_BREAKPOINTS,
120
+ b as ALLOWED_FONT_SIZES,
121
+ p as EXPECTED_SEMI_VERSION,
122
+ F as FORBIDDEN_SNIPPETS,
123
+ D as RAW_ELEMENT_PATTERN,
124
+ R as RESERVED_VARIABLE_PREFIXES,
118
125
  M as SEMI_PACKAGES,
119
126
  H as checkDesignScale,
120
127
  G as checkSemiCssLayer,
121
128
  J as checkSemiInternals,
122
- q as checkSemiVersion,
123
- X as checkUiLibraryUsage
129
+ X as checkSemiVersion,
130
+ U as checkUiLibraryUsage
124
131
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24city/web-console",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "24.city 产品用户端的界面底座:Semi Design 主题与设计变量、控制台外壳、账号与会员界面、列表与数据组件、界面规范与守卫",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,65 +0,0 @@
1
- import { jsx as n, jsxs as u, Fragment as z } from "react/jsx-runtime";
2
- import { Button as p, Typography as F } from "@douyinfe/semi-ui";
3
- import { useNavigate as O } from "react-router";
4
- import { b as S } from "./context-CaVim6ZO.js";
5
- import { F as f, e as g } from "./page-YBG0dEN1.js";
6
- import { useId as j, cloneElement as E, forwardRef as L } from "react";
7
- const Q = () => {
8
- const { config: i } = S(), r = O();
9
- return /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
10
- g,
11
- {
12
- status: "not-found",
13
- title: "页面不存在",
14
- description: "请检查地址,或返回产品首页继续。",
15
- extra: /* @__PURE__ */ n(p, { theme: "solid", type: "primary", onClick: () => r(i.routes.publicHome), children: "返回首页" })
16
- }
17
- ) });
18
- }, P = "_srOnly_1mfs8_2", R = {
19
- srOnly: P
20
- }, U = ({ label: i, children: r }) => {
21
- const t = j();
22
- return /* @__PURE__ */ u(z, { children: [
23
- /* @__PURE__ */ n("span", { id: t, className: R.srOnly, children: i }),
24
- E(r, { "aria-labelledby": t })
25
- ] });
26
- }, V = () => /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n("div", { role: "alert", children: /* @__PURE__ */ n(
27
- g,
28
- {
29
- status: "error",
30
- title: "应用配置暂时无法加载",
31
- description: "启动检查未通过。请检查运行时配置和网络连接后重新加载。",
32
- extra: /* @__PURE__ */ n(p, { theme: "solid", type: "primary", onClick: () => window.location.reload(), children: "重新加载" })
33
- }
34
- ) }) }), B = "_link_1mzr6_2", C = "_danger_1mzr6_28", I = "_warning_1mzr6_33", H = "_icon_1mzr6_38", s = {
35
- link: B,
36
- danger: C,
37
- warning: I,
38
- icon: H
39
- }, W = L(function({ href: r, target: t, rel: c, download: _, onClick: a, onKeyDown: l, icon: d, status: m, disabled: o = !1, className: y, style: h, role: k, tabIndex: x, children: w, ...N }, b) {
40
- const T = [s.link, m === "danger" ? s.danger : m === "warning" ? s.warning : "", y ?? ""].filter(Boolean).join(" "), v = {
41
- ...N,
42
- ref: b,
43
- href: r,
44
- target: t,
45
- rel: t === "_blank" ? c ?? "noreferrer" : c,
46
- download: _,
47
- onClick: o ? void 0 : a,
48
- onKeyDown: (e) => {
49
- l == null || l(e), !(e.defaultPrevented || r || o || !a) && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), a(e));
50
- },
51
- role: k ?? (r ? void 0 : "button"),
52
- tabIndex: x ?? (r || o ? void 0 : 0),
53
- "aria-disabled": o || void 0
54
- };
55
- return /* @__PURE__ */ u(F.Text, { link: v, disabled: o, className: T, style: h, children: [
56
- d ? /* @__PURE__ */ n("span", { className: s.icon, children: d }) : null,
57
- w
58
- ] });
59
- });
60
- export {
61
- Q as N,
62
- U as S,
63
- W as T,
64
- V as a
65
- };