@tbox.cn/app-template-h5 0.1.17 → 0.1.19

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/AGENTS.md CHANGED
@@ -32,6 +32,7 @@ pnpm check:inspector # inspector 接线守卫(随 @tbox.cn/app-sdk-server 分
32
32
  - `@tbox.cn/app-sdk-client`:`configureRuntime`(API base 注入,勿硬编码 host)、`httpGet/httpPost/createService`(HTTP 客户端)、`ErrorBoundary`、`createLogger`、`installGlobalErrorReporting`
33
33
  - `@tbox.cn/app-sdk-server`:`createLogger`
34
34
  - `@tbox.cn/app-sdk-server/platform`:`installInspector`;vite `code-inspect` 插件入口为 `@tbox.cn/app-sdk-client/platform/code-inspect`(页面微调基线,受 `check:inspector` 守卫)
35
+ - `apps/client/vite.config.ts` 在 serve 且非 Vitest 时动态注册同入口的 `previewErrorReporter()`,将开发预览未捕获异常经 HMR 写入应用进程日志;覆盖与限制见 [README.md](README.md#快速开始)。
35
36
  - 不直接 import `@tbox-dev-js/sdk`——平台能力一律经 `@tbox.cn/app-sdk-client` / `@tbox.cn/app-sdk-server` 公开入口。
36
37
 
37
38
  ## 关键入口
package/README.md CHANGED
@@ -11,6 +11,8 @@ pnpm dev
11
11
 
12
12
  开发期浏览器访问 `http://localhost:8000`(单端口:API + 页面 + HMR)。`server` 负责 API、健康检查与生产静态托管,`client` 负责 Web 页面与业务入口。
13
13
 
14
+ Vite 开发预览自动把未捕获 JS 异常、未处理的 Promise rejection 与脚本加载失败经 HMR 转发到应用进程,输出 `[TBOX_PREVIEW_REPORT]` 单行 JSON。不转发普通 `console.*`;生产构建、protected static 页面与 Vitest 不启用。
15
+
14
16
  ## 生成新应用
15
17
 
16
18
  ```sh
@@ -1,6 +1,33 @@
1
+ /* AlibabaSans 字体包:常规、中等、粗体。 */
2
+ @font-face {
3
+ font-family: "AlibabaSans";
4
+ src: url("https://gw.alipayobjects.com/as/g/antui/antui-static/1.0.5/fonts/AlibabaSans102Ver2-Rg.woff")
5
+ format("woff");
6
+ font-weight: 400;
7
+ font-display: swap;
8
+ }
9
+ @font-face {
10
+ font-family: "AlibabaSans";
11
+ src: url("https://gw.alipayobjects.com/as/g/antui/antui-static/1.0.5/fonts/AlibabaSans102Ver2-Md.woff")
12
+ format("woff");
13
+ font-weight: 500;
14
+ font-display: swap;
15
+ }
16
+ @font-face {
17
+ font-family: "AlibabaSans";
18
+ src: url("https://gw.alipayobjects.com/as/g/antui/antui-static/1.0.5/fonts/AlibabaSans102Ver2-Bd.woff")
19
+ format("woff");
20
+ font-weight: 700;
21
+ font-display: swap;
22
+ }
23
+
1
24
  /* 全局样式入口:仅设备无关的基础卫生规则;视觉/布局/端形态由应用自定。 */
2
25
  *, *::before, *::after { box-sizing: border-box; }
3
- body { margin: 0; }
26
+ body {
27
+ margin: 0;
28
+ font-family: "AlibabaSans", PingFang SC, -apple-system, BlinkMacSystemFont,
29
+ Helvetica Neue, Helvetica, sans-serif;
30
+ }
4
31
  button, input, textarea, select { font: inherit; }
5
32
  img, video, canvas { display: block; }
6
33
  img, video { max-width: 100%; height: auto; }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="vitest" />
2
- import { defineConfig } from 'vite';
2
+ import { defineConfig, type Plugin } from 'vite';
3
3
  import react from '@vitejs/plugin-react';
4
4
  import { resolve } from 'node:path';
5
5
  // 平台微调配套 babel plugin(随 @tbox.cn/app-sdk 分发):dev 期给每个 JSX 注入源码位置属性,
@@ -8,18 +8,29 @@ import codeInspectPlugin from '@tbox.cn/app-sdk-client/platform/code-inspect';
8
8
 
9
9
  // dev 期页面由 apps/server dev.ts 的 vite middleware 托管(本文件被其加载);
10
10
  // build 恒走静态产物。无 .tbox-dev.local 探针段(h5 无 dev 装配面,native launch)。
11
- export default defineConfig(({ command }) => ({
12
- plugins: [react({ babel: { plugins: command === 'serve' ? [codeInspectPlugin] : [] } })],
13
- resolve: {
14
- alias: {
15
- '@': resolve(__dirname, 'src'),
11
+ export default defineConfig(async ({ command }) => {
12
+ const devPlugins: Plugin[] = [];
13
+ // 只在开发服务装载异常上报插件;build/vitest 无需解析其 Node 端依赖。
14
+ if (command === 'serve' && !process.env.VITEST) {
15
+ const { previewErrorReporter } = await import('@tbox.cn/app-sdk-server/platform');
16
+ devPlugins.push(previewErrorReporter());
17
+ }
18
+ return {
19
+ plugins: [
20
+ react({ babel: { plugins: command === 'serve' ? [codeInspectPlugin] : [] } }),
21
+ ...devPlugins,
22
+ ],
23
+ resolve: {
24
+ alias: {
25
+ '@': resolve(__dirname, 'src'),
26
+ },
16
27
  },
17
- },
18
- build: {
19
- rollupOptions: { input: { index: resolve(__dirname, 'index.html') } },
20
- },
21
- // 模板出厂零 client 测试文件:随发测试禁钉用户实施面(business/App.tsx 是用户首个改写对象,
22
- // 出厂断言其内容必随应用构建失败——testing/2026-10-20-template-shipped-test-boundary.md);
23
- // 新增客户端测试时移除本旗标。
24
- test: { passWithNoTests: true },
25
- }));
28
+ build: {
29
+ rollupOptions: { input: { index: resolve(__dirname, 'index.html') } },
30
+ },
31
+ // 模板出厂零 client 测试文件:随发测试禁钉用户实施面(business/App.tsx 是用户首个改写对象,
32
+ // 出厂断言其内容必随应用构建失败——testing/2026-10-20-template-shipped-test-boundary.md);
33
+ // 新增客户端测试时移除本旗标。
34
+ test: { passWithNoTests: true },
35
+ };
36
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-template-h5",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "tbox Web 全栈模板(单 workspace:apps/client + apps/server;h5 为家族历史名,不预设端形态),运行时与页面微调经 @tbox.cn/app-sdk。",
5
5
  "type": "module",
6
6
  "engines": {