@lark-apaas/coding-templates 0.1.43-alpha.25 → 0.1.43-alpha.26

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.
Files changed (89) hide show
  1. package/meta.json +2 -8
  2. package/package.json +1 -1
  3. package/template-apex/package.json +2 -2
  4. package/template-apex/tsconfig.app.json +1 -2
  5. package/template-html/_gitignore +2 -0
  6. package/template-html/index.html +20 -19
  7. package/template-html/package.json +2 -17
  8. package/template-html/routes.json +1 -0
  9. package/template-html/scripts/build.sh +16 -28
  10. package/template-vite-react/README.md +10 -10
  11. package/template-vite-react/{src → client/src}/hooks/use-mobile.ts +3 -4
  12. package/template-vite-react/{src → client/src}/index.tsx +2 -9
  13. package/template-vite-react/components.json +1 -1
  14. package/template-vite-react/package.json +13 -8
  15. package/template-vite-react/scripts/build.sh +3 -15
  16. package/template-vite-react/tsconfig.app.json +2 -3
  17. package/template-vite-react/tsconfig.json +1 -1
  18. package/template-vite-react/vite.config.ts +2 -1
  19. package/template-html/.spark_project +0 -17
  20. package/template-html/scripts/mock-health.cjs +0 -32
  21. package/template-html/src/main.js +0 -38
  22. package/template-html/src/styles.css +0 -1
  23. package/template-html/vite.config.ts +0 -70
  24. package/template-vite-react/.spark/meta.json +0 -8
  25. package/template-vite-react/.spark_project +0 -12
  26. package/template-vite-react/_npmrc +0 -1
  27. package/template-vite-react/scripts/dev.mjs +0 -125
  28. /package/template-vite-react/{index.html → client/index.html} +0 -0
  29. /package/template-vite-react/{public → client/public}/favicon.svg +0 -0
  30. /package/template-vite-react/{public → client/public}/icons.svg +0 -0
  31. /package/template-vite-react/{src → client/src}/app.tsx +0 -0
  32. /package/template-vite-react/{src → client/src}/components/layout.tsx +0 -0
  33. /package/template-vite-react/{src → client/src}/components/ui/accordion.tsx +0 -0
  34. /package/template-vite-react/{src → client/src}/components/ui/alert-dialog.tsx +0 -0
  35. /package/template-vite-react/{src → client/src}/components/ui/alert.tsx +0 -0
  36. /package/template-vite-react/{src → client/src}/components/ui/aspect-ratio.tsx +0 -0
  37. /package/template-vite-react/{src → client/src}/components/ui/avatar.tsx +0 -0
  38. /package/template-vite-react/{src → client/src}/components/ui/badge.tsx +0 -0
  39. /package/template-vite-react/{src → client/src}/components/ui/breadcrumb.tsx +0 -0
  40. /package/template-vite-react/{src → client/src}/components/ui/button-group.tsx +0 -0
  41. /package/template-vite-react/{src → client/src}/components/ui/button.tsx +0 -0
  42. /package/template-vite-react/{src → client/src}/components/ui/calendar.tsx +0 -0
  43. /package/template-vite-react/{src → client/src}/components/ui/card.tsx +0 -0
  44. /package/template-vite-react/{src → client/src}/components/ui/carousel.tsx +0 -0
  45. /package/template-vite-react/{src → client/src}/components/ui/chart.tsx +0 -0
  46. /package/template-vite-react/{src → client/src}/components/ui/checkbox.tsx +0 -0
  47. /package/template-vite-react/{src → client/src}/components/ui/collapsible.tsx +0 -0
  48. /package/template-vite-react/{src → client/src}/components/ui/command.tsx +0 -0
  49. /package/template-vite-react/{src → client/src}/components/ui/context-menu.tsx +0 -0
  50. /package/template-vite-react/{src → client/src}/components/ui/dialog.tsx +0 -0
  51. /package/template-vite-react/{src → client/src}/components/ui/drawer.tsx +0 -0
  52. /package/template-vite-react/{src → client/src}/components/ui/dropdown-menu.tsx +0 -0
  53. /package/template-vite-react/{src → client/src}/components/ui/empty.tsx +0 -0
  54. /package/template-vite-react/{src → client/src}/components/ui/field.tsx +0 -0
  55. /package/template-vite-react/{src → client/src}/components/ui/form.tsx +0 -0
  56. /package/template-vite-react/{src → client/src}/components/ui/hover-card.tsx +0 -0
  57. /package/template-vite-react/{src → client/src}/components/ui/image.tsx +0 -0
  58. /package/template-vite-react/{src → client/src}/components/ui/input-group.tsx +0 -0
  59. /package/template-vite-react/{src → client/src}/components/ui/input-otp.tsx +0 -0
  60. /package/template-vite-react/{src → client/src}/components/ui/input.tsx +0 -0
  61. /package/template-vite-react/{src → client/src}/components/ui/item.tsx +0 -0
  62. /package/template-vite-react/{src → client/src}/components/ui/kbd.tsx +0 -0
  63. /package/template-vite-react/{src → client/src}/components/ui/label.tsx +0 -0
  64. /package/template-vite-react/{src → client/src}/components/ui/menubar.tsx +0 -0
  65. /package/template-vite-react/{src → client/src}/components/ui/native-select.tsx +0 -0
  66. /package/template-vite-react/{src → client/src}/components/ui/navigation-menu.tsx +0 -0
  67. /package/template-vite-react/{src → client/src}/components/ui/pagination.tsx +0 -0
  68. /package/template-vite-react/{src → client/src}/components/ui/popover.tsx +0 -0
  69. /package/template-vite-react/{src → client/src}/components/ui/progress.tsx +0 -0
  70. /package/template-vite-react/{src → client/src}/components/ui/radio-group.tsx +0 -0
  71. /package/template-vite-react/{src → client/src}/components/ui/resizable.tsx +0 -0
  72. /package/template-vite-react/{src → client/src}/components/ui/scroll-area.tsx +0 -0
  73. /package/template-vite-react/{src → client/src}/components/ui/select.tsx +0 -0
  74. /package/template-vite-react/{src → client/src}/components/ui/separator.tsx +0 -0
  75. /package/template-vite-react/{src → client/src}/components/ui/sheet.tsx +0 -0
  76. /package/template-vite-react/{src → client/src}/components/ui/sidebar.tsx +0 -0
  77. /package/template-vite-react/{src → client/src}/components/ui/skeleton.tsx +0 -0
  78. /package/template-vite-react/{src → client/src}/components/ui/slider.tsx +0 -0
  79. /package/template-vite-react/{src → client/src}/components/ui/sonner.tsx +0 -0
  80. /package/template-vite-react/{src → client/src}/components/ui/spinner.tsx +0 -0
  81. /package/template-vite-react/{src → client/src}/components/ui/switch.tsx +0 -0
  82. /package/template-vite-react/{src → client/src}/components/ui/table.tsx +0 -0
  83. /package/template-vite-react/{src → client/src}/components/ui/tabs.tsx +0 -0
  84. /package/template-vite-react/{src → client/src}/components/ui/textarea.tsx +0 -0
  85. /package/template-vite-react/{src → client/src}/components/ui/toggle-group.tsx +0 -0
  86. /package/template-vite-react/{src → client/src}/components/ui/toggle.tsx +0 -0
  87. /package/template-vite-react/{src → client/src}/components/ui/tooltip.tsx +0 -0
  88. /package/template-vite-react/{src → client/src}/index.css +0 -0
  89. /package/template-vite-react/{src → client/src}/pages/NotFoundPage/NotFoundPage.tsx +0 -0
package/meta.json CHANGED
@@ -1,16 +1,10 @@
1
1
  {
2
2
  "templates": [
3
- {
4
- "name": "vite-react",
5
- "dir": "template-vite-react",
6
- "description": "Vite + React 19 + shadcn — jsPage 主推(HMR / Inspector / Capability / OpenTel)",
7
- "features": ["typescript", "vite", "hmr", "tailwind", "shadcn-ui", "inspector", "capability", "observable"]
8
- },
9
3
  {
10
4
  "name": "html",
11
5
  "dir": "template-html",
12
- "description": "纯 HTML — Vite dev + HMR + Tailwind v4 + Capability / OpenTel",
13
- "features": ["vite", "hmr", "tailwind", "capability", "observable"]
6
+ "description": "纯 HTML — 零依赖,原型验证",
7
+ "features": ["tailwind-cdn", "dark-mode"]
14
8
  },
15
9
  {
16
10
  "name": "nextjs-static",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/coding-templates",
3
- "version": "0.1.43-alpha.25",
3
+ "version": "0.1.43-alpha.26",
4
4
  "description": "OpenClaw project templates for mclaw CLI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -71,9 +71,9 @@
71
71
  "react-day-picker": "^9.14.0",
72
72
  "react-dom": "^19.2.4",
73
73
  "react-hook-form": "^7.72.0",
74
- "react-resizable-panels": "^4.7.6",
74
+ "react-resizable-panels": "^3.0.6",
75
75
  "react-router-dom": "^7.13.2",
76
- "recharts": "^3.8.0",
76
+ "recharts": "^2.15.4",
77
77
  "sonner": "^2.0.7",
78
78
  "tailwind-merge": "^3.5.0",
79
79
  "tailwindcss": "^4.2.2",
@@ -8,6 +8,5 @@
8
8
  "@shared/*": ["./shared/*"]
9
9
  }
10
10
  },
11
- "include": ["client/src", "shared"],
12
- "exclude": ["client/src/components/ui"]
11
+ "include": ["client/src", "shared"]
13
12
  }
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ node_modules
@@ -1,22 +1,23 @@
1
1
  <!doctype html>
2
2
  <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>应用标题</title>
7
- <link
8
- href="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/feisuda.svg"
9
- rel="shortcut icon"
10
- />
11
- </head>
12
- <body class="bg-gray-50">
13
- <!-- 画布布局容器:业务页面内容放这里 -->
14
- <main id="canvas" class="mx-auto max-w-7xl p-6">
15
- <h1 class="text-2xl font-semibold">Hello HTML 模板</h1>
16
- <p class="mt-2 text-gray-600">编辑 <code>index.html</code> 开始你的应用。</p>
17
- </main>
18
-
19
- <!-- 入口模块:装载平台 SDK(capability / observable / ...) + 样式 -->
20
- <script type="module" src="/src/main.js"></script>
21
- </body>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>应用标题</title>
7
+ <link href="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/feisuda.svg" rel="shortcut icon"/>
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script>
10
+ // 可选:Tailwind 运行时配置
11
+ tailwind.config = {};
12
+ </script>
13
+ <style>
14
+ /* 必要的自定义样式(如画布容器尺寸、预览区边框等) */
15
+ </style>
16
+ </head>
17
+ <body class="bg-gray-50">
18
+ <!-- 画布布局容器 -->
19
+ <main id="canvas" class="mx-auto max-w-7xl p-6">
20
+ <!-- 页面内容(由 generate_design 生成的 HTML 片段插入此处) -->
21
+ </main>
22
+ </body>
22
23
  </html>
@@ -5,24 +5,9 @@
5
5
  "mclaw": {
6
6
  "stack": "html",
7
7
  "stackVersion": "0.1.0",
8
- "features": [
9
- "client"
10
- ]
8
+ "features": ["client"]
11
9
  },
12
10
  "scripts": {
13
- "dev": "concurrently -k -n vite,health 'vite --port 8001 --host 0.0.0.0' 'node scripts/mock-health.cjs'",
14
- "build": "bash scripts/build.sh",
15
- "lint": "echo 'no lint for plain HTML'"
16
- },
17
- "dependencies": {
18
- "@lark-apaas/client-toolkit-lite": "1.1.7-alpha.6",
19
- "@lark-apaas/observable-web": "^1.0.6"
20
- },
21
- "devDependencies": {
22
- "@lark-apaas/coding-vite-preset": "1.0.7-alpha.2",
23
- "@tailwindcss/vite": "^4.0.0",
24
- "concurrently": "^9",
25
- "tailwindcss": "^4.0.0",
26
- "vite": "^8"
11
+ "build": "bash scripts/build.sh"
27
12
  }
28
13
  }
@@ -0,0 +1 @@
1
+ { "version": 1, "type": "html", "fallback": "index.html" }
@@ -3,41 +3,29 @@ set -e
3
3
 
4
4
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5
5
  OUTPUT="$ROOT/dist/output"
6
- OUTPUT_RESOURCE="$ROOT/dist/output_resource"
7
6
  OUTPUT_STATIC="$ROOT/dist/output_static"
7
+ STATIC_PREFIX="${MCLAW_STATIC_PREFIX:-}"
8
8
 
9
- # 映射平台环境变量到 preset 期望的变量名(同 template-vite-react)
10
- export CLIENT_BASE_PATH="${MCLAW_APP_ID:+/app/$MCLAW_APP_ID}"
11
- export ASSETS_CDN_PATH="${MCLAW_CDN_DOMAIN:-/}"
12
- export NODE_ENV="${NODE_ENV:-production}"
13
-
9
+ # 清理
14
10
  rm -rf "$ROOT/dist"
15
-
16
- # 1. Vite 构建 → dist/client/
17
- npx vite build --outDir "$ROOT/dist/client" --emptyOutDir
18
-
19
- # 2. HTML → dist/output/
20
11
  mkdir -p "$OUTPUT"
21
- find "$ROOT/dist/client" -maxdepth 1 -name '*.html' -exec cp {} "$OUTPUT/" \;
22
12
 
23
- # 生成 routes.json(运行态 PageServer 按 type 区分渲染策略)
24
- echo '{ "version": 1, "type": "html", "fallback": "index.html" }' > "$OUTPUT/routes.json"
13
+ # 1. 所有 .html 文件按目录结构复制到 dist/output/,并替换 $STATIC$ 为实际静态资源路径
14
+ cd "$ROOT"
15
+ find . -name '*.html' -not -path './dist/*' -not -path './node_modules/*' | while read -r file; do
16
+ dir=$(dirname "$file")
17
+ mkdir -p "$OUTPUT/$dir"
18
+ sed "s|\\\$STATIC\\\$|${STATIC_PREFIX}|g" "$file" > "$OUTPUT/$file"
19
+ done
25
20
 
26
- # 3. assets/ → dist/output_resource/(JS/CSS/字体上传到 CDN)
27
- if [ -d "$ROOT/dist/client/assets" ]; then
28
- mkdir -p "$OUTPUT_RESOURCE"
29
- cp -r "$ROOT/dist/client/assets" "$OUTPUT_RESOURCE/"
30
- fi
21
+ # 2. routes.json → dist/output/
22
+ cp "$ROOT/routes.json" "$OUTPUT/routes.json"
31
23
 
32
- # 4. 私有静态资源 → dist/output_static/(排除代码文件)
33
- if [ -d "$ROOT/shared/static" ]; then
34
- mkdir -p "$OUTPUT_STATIC"
35
- rsync -a --exclude='*.ts' --exclude='*.tsx' --exclude='*.js' --exclude='*.jsx' "$ROOT/shared/static/" "$OUTPUT_STATIC/"
24
+ # 3. static/ → dist/output_static/(如果存在)
25
+ if [ -d "$ROOT/static" ]; then
26
+ cp -r "$ROOT/static" "$OUTPUT_STATIC"
36
27
  fi
37
28
 
38
- rm -rf "$ROOT/dist/client"
39
-
40
29
  echo "Build complete"
41
- echo " HTML → dist/output/"
42
- [ -d "$OUTPUT_RESOURCE" ] && echo " Resource → dist/output_resource/" || true
43
- [ -d "$OUTPUT_STATIC" ] && echo " Static → dist/output_static/" || true
30
+ echo " HTML → dist/output/"
31
+ [ -d "$OUTPUT_STATIC" ] && echo " Static → dist/output_static/" || true
@@ -15,7 +15,7 @@
15
15
  ## 目录结构
16
16
 
17
17
  ```
18
- src/
18
+ client/src/
19
19
  ├── index.tsx # 入口(勿修改)
20
20
  ├── app.tsx # 路由配置(仅在 <Routes> 内增删 <Route>)
21
21
  ├── index.css # 全局样式 + 主题变量
@@ -51,8 +51,8 @@ shared/
51
51
 
52
52
  | 文件 | 原因 |
53
53
  |------|------|
54
- | `src/index.tsx` | Provider 层级 + 样式引入,由模板管理 |
55
- | `src/components/ui/*` | shadcn/ui 内置组件,版本锁定 |
54
+ | `client/src/index.tsx` | Provider 层级 + 样式引入,由模板管理 |
55
+ | `client/src/components/ui/*` | shadcn/ui 内置组件,版本锁定 |
56
56
 
57
57
  ---
58
58
 
@@ -60,10 +60,10 @@ shared/
60
60
 
61
61
  | 内容类型 | 放置位置 |
62
62
  |---------|---------|
63
- | 新页面 | `src/pages/<PageName>/PageName.tsx` |
64
- | 页面专属组件 | `src/pages/<PageName>/components/` |
65
- | 自定义 Hooks | `src/hooks/` |
66
- | 工具函数 | `src/lib/` |
63
+ | 新页面 | `client/src/pages/<PageName>/PageName.tsx` |
64
+ | 页面专属组件 | `client/src/pages/<PageName>/components/` |
65
+ | 自定义 Hooks | `client/src/hooks/` |
66
+ | 工具函数 | `client/src/lib/` |
67
67
  | 静态数据文件 | `shared/static/data/` |
68
68
  | 静态图片 | `shared/static/images/` |
69
69
 
@@ -72,7 +72,7 @@ shared/
72
72
  ## 导入路径
73
73
 
74
74
  ```typescript
75
- // @/ 别名 → src/
75
+ // @/ 别名 → client/src/
76
76
  import { cn } from "@/lib/utils";
77
77
  import { useIsMobile } from "@/hooks/use-mobile";
78
78
 
@@ -85,14 +85,14 @@ import configData from "@shared/static/config.json";
85
85
 
86
86
  ## 路由配置
87
87
 
88
- - 新增页面需在 `src/app.tsx` 的 `<Routes>` 内注册 `<Route>`
88
+ - 新增页面需在 `client/src/app.tsx` 的 `<Routes>` 内注册 `<Route>`
89
89
  - `BrowserRouter` 已在 `index.tsx` 中配置,`app.tsx` 中**禁止**再包裹 Router
90
90
 
91
91
  ---
92
92
 
93
93
  ## 主题变量
94
94
 
95
- 主题色定义在 `src/index.css`,通过 `:root` CSS 变量 + `@theme inline` 注册到 Tailwind。
95
+ 主题色定义在 `client/src/index.css`,通过 `:root` CSS 变量 + `@theme inline` 注册到 Tailwind。
96
96
 
97
97
  | 用途 | Tailwind 类 | CSS 变量 |
98
98
  |------|------------|----------|
@@ -3,9 +3,7 @@ import * as React from "react"
3
3
  const MOBILE_BREAKPOINT = 768
4
4
 
5
5
  export function useIsMobile() {
6
- const [isMobile, setIsMobile] = React.useState<boolean>(() =>
7
- typeof window !== "undefined" && window.innerWidth < MOBILE_BREAKPOINT,
8
- )
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
9
7
 
10
8
  React.useEffect(() => {
11
9
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
@@ -13,8 +11,9 @@ export function useIsMobile() {
13
11
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
14
12
  }
15
13
  mql.addEventListener("change", onChange)
14
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
16
15
  return () => mql.removeEventListener("change", onChange)
17
16
  }, [])
18
17
 
19
- return isMobile
18
+ return !!isMobile
20
19
  }
@@ -1,8 +1,7 @@
1
1
  import { StrictMode } from "react";
2
2
  import { createRoot } from "react-dom/client";
3
3
  import { BrowserRouter } from "react-router-dom";
4
- import { ErrorBoundary } from "react-error-boundary";
5
- import { AppContainer, ErrorRender } from "@lark-apaas/client-toolkit-lite";
4
+ import { AppContainer } from "@lark-apaas/client-toolkit-lite";
6
5
  import App from "./app";
7
6
  import "./index.css";
8
7
 
@@ -10,13 +9,7 @@ createRoot(document.getElementById("root")!).render(
10
9
  <StrictMode>
11
10
  <BrowserRouter basename={process.env.CLIENT_BASE_PATH || "/"}>
12
11
  <AppContainer>
13
- <ErrorBoundary
14
- fallbackRender={({ error, resetErrorBoundary }) => (
15
- <ErrorRender error={error} resetErrorBoundary={resetErrorBoundary} />
16
- )}
17
- >
18
- <App />
19
- </ErrorBoundary>
12
+ <App />
20
13
  </AppContainer>
21
14
  </BrowserRouter>
22
15
  </StrictMode>,
@@ -5,7 +5,7 @@
5
5
  "tsx": true,
6
6
  "tailwind": {
7
7
  "config": "",
8
- "css": "src/index.css",
8
+ "css": "client/src/index.css",
9
9
  "baseColor": "neutral",
10
10
  "cssVariables": true,
11
11
  "prefix": ""
@@ -1,13 +1,19 @@
1
1
  {
2
- "name": "miaoda-vite-react-app",
2
+ "name": "{{projectName}}",
3
3
  "version": "0.1.0",
4
4
  "private": true,
5
+ "mclaw": {
6
+ "stack": "vite-react",
7
+ "stackVersion": "0.1.0",
8
+ "features": [
9
+ "client"
10
+ ]
11
+ },
5
12
  "scripts": {
6
- "dev": "node scripts/dev.mjs",
7
13
  "build": "bash scripts/build.sh",
8
14
  "typecheck": "tsc -p tsconfig.app.json",
9
15
  "lint": "concurrently npm:typecheck npm:lint:eslint",
10
- "lint:eslint": "eslint src"
16
+ "lint:eslint": "eslint client/src"
11
17
  },
12
18
  "dependencies": {
13
19
  "@hookform/resolvers": "^5.2.2",
@@ -37,7 +43,7 @@
37
43
  "@radix-ui/react-toggle": "^1.1.9",
38
44
  "@radix-ui/react-toggle-group": "^1.1.10",
39
45
  "@radix-ui/react-tooltip": "^1.1.18",
40
- "@lark-apaas/client-toolkit-lite": "1.1.7-alpha.23",
46
+ "@lark-apaas/client-toolkit-lite": "^1.1.0",
41
47
  "@formkit/auto-animate": "^0.9.0",
42
48
  "@gsap/react": "^2.1.2",
43
49
  "framer-motion": "^12.38.0",
@@ -55,11 +61,10 @@
55
61
  "react": "^19.2.4",
56
62
  "react-day-picker": "^9.14.0",
57
63
  "react-dom": "^19.2.4",
58
- "react-error-boundary": "^6.0.0",
59
64
  "react-hook-form": "^7.72.0",
60
- "react-resizable-panels": "^4.7.6",
65
+ "react-resizable-panels": "^3.0.6",
61
66
  "react-router-dom": "^7.13.2",
62
- "recharts": "^3.8.0",
67
+ "recharts": "^2.15.4",
63
68
  "sonner": "^2.0.7",
64
69
  "tailwind-merge": "^3.5.0",
65
70
  "tailwindcss": "^4.2.2",
@@ -73,7 +78,7 @@
73
78
  "@types/react": "^19",
74
79
  "@types/react-dom": "^19",
75
80
  "@lark-apaas/coding-presets": "^1.0.0",
76
- "@lark-apaas/coding-vite-preset": "1.0.7-alpha.21",
81
+ "@lark-apaas/coding-vite-preset": "^1.0.0",
77
82
  "concurrently": "^9",
78
83
  "eslint": "^9",
79
84
  "eslint-plugin-react-hooks": "^7",
@@ -36,22 +36,10 @@ if [ -d "$ROOT/shared/static" ]; then
36
36
  rsync -a --exclude='*.ts' --exclude='*.tsx' --exclude='*.js' --exclude='*.jsx' "$ROOT/shared/static/" "$OUTPUT_STATIC/"
37
37
  fi
38
38
 
39
- # 5. capability 配置 → dist/output_capabilities/(老路径优先)
40
- if [ -d "$ROOT/server/capabilities" ]; then
41
- CAPS_SRC="$ROOT/server/capabilities"
42
- elif [ -d "$ROOT/shared/capabilities" ]; then
43
- CAPS_SRC="$ROOT/shared/capabilities"
44
- fi
45
- if [ -n "${CAPS_SRC:-}" ]; then
46
- mkdir -p "$ROOT/dist/output_capabilities"
47
- cp -r "$CAPS_SRC/." "$ROOT/dist/output_capabilities/"
48
- fi
49
-
50
39
  # 清理中间产物
51
40
  rm -rf "$ROOT/dist/client"
52
41
 
53
42
  echo "Build complete"
54
- echo " HTML → dist/output/"
55
- [ -d "$OUTPUT_RESOURCE" ] && echo " Resource → dist/output_resource/" || true
56
- [ -d "$OUTPUT_STATIC" ] && echo " Static → dist/output_static/" || true
57
- [ -d "$ROOT/dist/output_capabilities" ] && echo " Capabilities → dist/output_capabilities/" || true
43
+ echo " HTML → dist/output/"
44
+ [ -d "$OUTPUT_RESOURCE" ] && echo " Resource → dist/output_resource/" || true
45
+ [ -d "$OUTPUT_STATIC" ] && echo " Static → dist/output_static/" || true
@@ -4,10 +4,9 @@
4
4
  "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5
5
  "baseUrl": ".",
6
6
  "paths": {
7
- "@/*": ["./src/*"],
7
+ "@/*": ["./client/src/*"],
8
8
  "@shared/*": ["./shared/*"]
9
9
  }
10
10
  },
11
- "include": ["src", "shared"],
12
- "exclude": ["src/components/ui"]
11
+ "include": ["client/src", "shared"]
13
12
  }
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
4
  "paths": {
5
- "@/*": ["./src/*"],
5
+ "@/*": ["./client/src/*"],
6
6
  "@shared/*": ["./shared/*"]
7
7
  }
8
8
  },
@@ -2,9 +2,10 @@ import path from 'path'
2
2
  import { defineConfig } from '@lark-apaas/coding-vite-preset'
3
3
 
4
4
  export default defineConfig({
5
+ root: path.resolve(__dirname, 'client'),
5
6
  resolve: {
6
7
  alias: {
7
- '@': path.resolve(__dirname, 'src'),
8
+ '@': path.resolve(__dirname, 'client/src'),
8
9
  '@shared': path.resolve(__dirname, 'shared'),
9
10
  },
10
11
  },
@@ -1,17 +0,0 @@
1
- run = ["npm", "run", "dev"]
2
- lint = ["npm", "run", "lint"]
3
- hidden = [".config", ".git", "scripts", "node_modules", "dist", ".spark", ".agent", ".agents", "tmp", ".spark_project", ".playwright-cli"]
4
-
5
- [deployment]
6
- build = ["npm", "run", "build"]
7
-
8
- [files]
9
- [files.restrict]
10
- pathPatterns = ["package.json", ".spark_project", ".spark/meta.json", ".gitignore"]
11
- [files.hidden]
12
- pathPatterns = [".config", ".git", "scripts", "node_modules", "dist", ".spark", ".agent", ".agents", "tmp", ".spark_project", ".playwright-cli"]
13
-
14
- [sandbox]
15
- # 临时兼容老沙箱硬编码探测的 3000 / 8001 端口。
16
- # 8001 由 vite dev server 真实占据;3000 由 scripts/mock-health.cjs 占位。
17
- healthCheck = [8001, 3000]
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * 沙箱预览态健康检查兜底:在 3000 端口起 HTTP listener。
4
- *
5
- * 老沙箱硬编码探测 3000 + 8001 判定"应用启动了"。jsPage 没有真实 Node server,
6
- * 8001 由 Vite dev server 真正占(预览流量也走 8001),3000 没有任何业务进程,
7
- * 只能 mock 一个 listener 让健康检查过。
8
- *
9
- * 等沙箱链路切到新协议(读 .spark_project [sandbox].healthCheck)后可删除。
10
- */
11
- const http = require('node:http');
12
-
13
- const PORTS = [3000];
14
-
15
- for (const port of PORTS) {
16
- const server = http.createServer((_req, res) => {
17
- res.writeHead(200, { 'content-type': 'text/plain' });
18
- res.end('ok');
19
- });
20
- server.on('error', (err) => {
21
- console.error(`[mock-health] :${port} listen error:`, err.message);
22
- if (err.code === 'EADDRINUSE') {
23
- // 端口已被占说明业务已起来,mock 退场即可
24
- console.warn(`[mock-health] :${port} 已被占用,跳过 mock`);
25
- return;
26
- }
27
- process.exitCode = 1;
28
- });
29
- server.listen(port, '0.0.0.0', () => {
30
- console.log(`[mock-health] listening on :${port}`);
31
- });
32
- }
@@ -1,38 +0,0 @@
1
- // 极薄入口:装平台 SDK。
2
- // 业务代码写在 index.html 的 <script> 里,或者再 import './your-app.js'。
3
-
4
- import './styles.css';
5
-
6
- // 1) capability — 调插件能力
7
- import { capabilityClient } from '@lark-apaas/client-toolkit-lite';
8
- // 暴露到 window 让 index.html 内联 <script> 也能用
9
- window.capability = capabilityClient;
10
-
11
- // 2) observable — OpenTelemetry traces/logs/metrics
12
- // lite 里的 initObservable() 绑了 React useEffect,纯 HTML 用不了;inline 一份等效逻辑。
13
- import { observable, AppEnv } from '@lark-apaas/observable-web';
14
- try {
15
- const appId = window.appId;
16
- const isNewPath =
17
- typeof window.location !== 'undefined' &&
18
- /^\/app\/[^/]/.test(window.location.pathname);
19
- observable.start({
20
- serviceName: 'app',
21
- env: process.env.NODE_ENV === 'development' ? AppEnv.Dev : AppEnv.Prod,
22
- collectorUrl: isNewPath
23
- ? {
24
- log: `/app/${appId}/__runtime__/api/v1/observability/logs/collect`,
25
- trace: `/app/${appId}/__runtime__/api/v1/observability/traces/collect`,
26
- metric: `/app/${appId}/__runtime__/api/v1/observability/metrics/collect`,
27
- time: `/app/${appId}/__runtime__/api/v1/observability/current_server_timestamp`,
28
- }
29
- : {
30
- log: `/spark/app/${appId}/runtime/api/v1/observability/logs/collect`,
31
- trace: `/spark/app/${appId}/runtime/api/v1/observability/traces/collect`,
32
- metric: `/spark/app/${appId}/runtime/api/v1/observability/metrics/collect`,
33
- time: `/spark/api/v1/observability/app/${appId}/current_server_timestamp`,
34
- },
35
- });
36
- } catch (error) {
37
- console.error('Failed to start WebObservableSdk:', error);
38
- }
@@ -1 +0,0 @@
1
- @import "tailwindcss";
@@ -1,70 +0,0 @@
1
- import path from 'path'
2
- import type { IncomingMessage, ServerResponse } from 'http'
3
- import { defineConfig } from '@lark-apaas/coding-vite-preset'
4
- import type { Plugin, ViteDevServer } from 'vite'
5
-
6
- /**
7
- * dev 模式 base-path normalize 中间件(同 template-vite-react)
8
- *
9
- * 沙箱预览网关把流量原样转给 vite(保留 /app/:appId 前缀)。但浏览器首次访问的
10
- * URL 是 `/app/app_xxx?sso_token=...`(pathname 缺末尾 /)。
11
- *
12
- * vite 8 的 baseMiddleware 对"缺末尾 /"的请求不再像 vite 5 那样自动 301,
13
- * 而是直接返回 404 警告页 "The server is configured with a public base URL..."。
14
- *
15
- * 这里做 internal rewrite(不发 301,避免跟沙箱网关形成 round-trip 死循环):
16
- * pathname === base 去尾 / → 改写 req.url 加上尾 /,下游继续 strip → SPA fallback。
17
- *
18
- * 必须 stack.unshift 而非 server.middlewares.use,否则排到内置 baseMiddleware
19
- * 之后失效。
20
- *
21
- * TODO: coding-vite-preset 新版本已含同等逻辑,待依赖普及后可删此 plugin。
22
- */
23
- const baseNormalizePlugin: Plugin = {
24
- name: 'base-path-normalize',
25
- configureServer(server: ViteDevServer) {
26
- const base = (process.env.CLIENT_BASE_PATH || '').replace(/\/+$/, '')
27
- if (!base) return
28
- const stack = (
29
- server.middlewares as unknown as {
30
- stack: Array<{ route: string; handle: unknown }>
31
- }
32
- ).stack
33
- if (!Array.isArray(stack)) return
34
- stack.unshift({
35
- route: '',
36
- handle: (req: IncomingMessage, _res: ServerResponse, next: () => void) => {
37
- const url = req.url || ''
38
- const qIdx = url.indexOf('?')
39
- const pathname = qIdx >= 0 ? url.slice(0, qIdx) : url
40
- const search = qIdx >= 0 ? url.slice(qIdx) : ''
41
- if (pathname === base) {
42
- req.url = base + '/' + search
43
- }
44
- next()
45
- },
46
- })
47
- },
48
- }
49
-
50
- export default defineConfig({
51
- // 模板根目录就是 index.html 所在位置(跟 vite-react 不同,没有 client/ 子目录)
52
- root: path.resolve(__dirname),
53
- resolve: {
54
- alias: {
55
- '@shared': path.resolve(__dirname, 'shared'),
56
- },
57
- },
58
- build: {
59
- // coding-vite-preset 默认把 entry 设为 client/index.html(vite-react 用的布局),
60
- // HTML 模板没有 client/ 子目录,override 成根目录的 index.html。
61
- rollupOptions: {
62
- input: path.resolve(__dirname, 'index.html'),
63
- },
64
- },
65
- // 同步告诉 Vite dev 优化器 entry 在哪,避免"failed to resolve rolldownOptions.input"警告。
66
- optimizeDeps: {
67
- entries: [path.resolve(__dirname, 'index.html')],
68
- },
69
- plugins: [baseNormalizePlugin],
70
- })
@@ -1,8 +0,0 @@
1
- {
2
- "appId": "app_xxxxxxxxxxxxxx",
3
- "template": "vite-react",
4
- "version": "0.1.0",
5
- "archType": 2,
6
- "features": ["client"],
7
- "appUrl": "https://bytedance.aiforce.cloud/app/app_xxxxxxxxxxxxxx"
8
- }
@@ -1,12 +0,0 @@
1
- run = ["npm", "run", "dev"]
2
- lint = ["npm", "run", "lint"]
3
- hidden = [".config", ".git", "scripts", "node_modules", "dist", ".spark", ".agent", ".agents", "tmp", ".spark_project", ".playwright-cli"]
4
-
5
- [deployment]
6
- build = ["npm", "run", "build"]
7
-
8
- [files]
9
- [files.restrict]
10
- pathPatterns = ["package.json", ".spark_project", ".spark/meta.json", ".gitignore"]
11
- [files.hidden]
12
- pathPatterns = [".config", ".git", "scripts", "node_modules", "dist", ".spark", ".agent", ".agents", "tmp", ".spark_project", ".playwright-cli"]
@@ -1 +0,0 @@
1
- registry=https://registry.npmmirror.com/
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Dev launcher: 启动 vite dev server,把 stdout/stderr 加时间戳前缀
4
- * 写到 logs/<name>.std.log + 当前 stdout;负责子进程组管理与端口孤儿清理。
5
- */
6
-
7
- import fs from 'node:fs';
8
- import path from 'node:path';
9
- import readline from 'node:readline';
10
- import { spawn, execSync } from 'node:child_process';
11
- import { fileURLToPath } from 'node:url';
12
-
13
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
- const ROOT = path.resolve(__dirname, '..');
15
- process.chdir(ROOT);
16
-
17
- const LOG_DIR = process.env.LOG_DIR || 'logs';
18
- const CLIENT_DEV_PORT = process.env.CLIENT_DEV_PORT || '8001';
19
-
20
- fs.mkdirSync(LOG_DIR, { recursive: true });
21
-
22
- function timestamp() {
23
- const now = new Date();
24
- const pad = (n) => String(n).padStart(2, '0');
25
- return (
26
- `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ` +
27
- `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
28
- );
29
- }
30
-
31
- function log(msg) {
32
- const line = `[${timestamp()}] [dev] ${msg}\n`;
33
- try { process.stdout.write(line); } catch {}
34
- }
35
-
36
- /** 清理端口占用:lsof -ti:<port> | kill -9 */
37
- function killOrphansByPort(port) {
38
- try {
39
- const out = execSync(`lsof -ti:${port}`, { stdio: ['ignore', 'pipe', 'ignore'] })
40
- .toString()
41
- .trim();
42
- if (!out) return [];
43
- const pids = out.split('\n').filter(Boolean);
44
- for (const pid of pids) {
45
- try {
46
- process.kill(Number(pid), 'SIGKILL');
47
- log(`killed orphan pid=${pid} on :${port}`);
48
- } catch {}
49
- }
50
- return pids;
51
- } catch {
52
- return [];
53
- }
54
- }
55
-
56
- const managed = [];
57
-
58
- function startProcess({ name, command, args, logFileName }) {
59
- const logFd = logFileName
60
- ? fs.openSync(path.join(LOG_DIR, logFileName), 'a')
61
- : null;
62
-
63
- const child = spawn(command, args, {
64
- stdio: ['ignore', 'pipe', 'pipe'],
65
- shell: false,
66
- cwd: ROOT,
67
- env: process.env,
68
- detached: true,
69
- });
70
-
71
- const pipeLines = (stream) => {
72
- const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
73
- rl.on('line', (line) => {
74
- const msg = `[${timestamp()}] [${name}] ${line}\n`;
75
- try { process.stdout.write(msg); } catch {}
76
- if (logFd != null) {
77
- try { fs.writeSync(logFd, msg); } catch {}
78
- }
79
- });
80
- };
81
- pipeLines(child.stdout);
82
- pipeLines(child.stderr);
83
-
84
- managed.push({ name, child });
85
- return child;
86
- }
87
-
88
- killOrphansByPort(CLIENT_DEV_PORT);
89
-
90
- startProcess({
91
- name: 'client',
92
- command: 'npx',
93
- args: ['vite', '--port', CLIENT_DEV_PORT, '--host', '0.0.0.0'],
94
- logFileName: 'client.std.log',
95
- });
96
-
97
- let stopping = false;
98
- function cleanup(signal) {
99
- if (stopping) return;
100
- stopping = true;
101
- log(`cleanup triggered by ${signal}`);
102
-
103
- for (const { child } of managed) {
104
- if (!child.pid) continue;
105
- try { process.kill(-child.pid, signal || 'SIGTERM'); } catch {}
106
- }
107
- setTimeout(() => {
108
- for (const { child } of managed) {
109
- if (!child.pid) continue;
110
- try { process.kill(-child.pid, 'SIGKILL'); } catch {}
111
- }
112
- killOrphansByPort(CLIENT_DEV_PORT);
113
- process.exit(0);
114
- }, 2000);
115
- }
116
-
117
- process.on('SIGINT', () => cleanup('SIGTERM'));
118
- process.on('SIGTERM', () => cleanup('SIGTERM'));
119
- // pkill 杀父 npm 后会收 SIGHUP(controlling tty 关闭);
120
- // Node 默认直接退出不跑 handler,注册 handler 触发 cleanup
121
- process.on('SIGHUP', () => cleanup('SIGTERM'));
122
-
123
- Promise.race(
124
- managed.map(({ child }) => new Promise((r) => child.on('exit', r))),
125
- ).then(() => cleanup('SIGTERM'));
File without changes