@maiyunnet/kebab 9.3.5 → 9.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.
package/doc/kebab-rag.md CHANGED
@@ -1360,7 +1360,7 @@ index/variables/VER.md
1360
1360
 
1361
1361
  # Variable: VER
1362
1362
 
1363
- > `const` **VER**: `"9.3.5"` = `'9.3.5'`
1363
+ > `const` **VER**: `"9.3.6"` = `'9.3.6'`
1364
1364
 
1365
1365
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1366
1366
 
@@ -3258,7 +3258,7 @@ lib/core/functions/clone.md
3258
3258
 
3259
3259
  > **clone**\<`T`\>(`obj`): `T`
3260
3260
 
3261
- Defined in: [lib/core.ts:1048](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1048)
3261
+ Defined in: [lib/core.ts:1060](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1060)
3262
3262
 
3263
3263
  完整的克隆一份数组/对象
3264
3264
 
@@ -3322,7 +3322,7 @@ lib/core/functions/debug.md
3322
3322
 
3323
3323
  > **debug**(`message?`, ...`optionalParams`): `void`
3324
3324
 
3325
- Defined in: [lib/core.ts:1082](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1082)
3325
+ Defined in: [lib/core.ts:1094](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1094)
3326
3326
 
3327
3327
  打印调试信息,线上环境不会打印
3328
3328
 
@@ -3357,7 +3357,7 @@ lib/core/functions/display.md
3357
3357
 
3358
3358
  > **display**(`message?`, ...`optionalParams`): `void`
3359
3359
 
3360
- Defined in: [lib/core.ts:1095](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1095)
3360
+ Defined in: [lib/core.ts:1107](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1107)
3361
3361
 
3362
3362
  向控制台直接显示内容,一般情况下禁止使用
3363
3363
 
@@ -3462,7 +3462,7 @@ lib/core/functions/getLog.md
3462
3462
 
3463
3463
  > **getLog**(`opt`): `Promise`\<`false` \| `string`[][] \| `null`\>
3464
3464
 
3465
- Defined in: [lib/core.ts:955](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L955)
3465
+ Defined in: [lib/core.ts:967](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L967)
3466
3466
 
3467
3467
  获取日志内容为一个数组
3468
3468
 
@@ -3568,7 +3568,7 @@ lib/core/functions/loadEnv.md
3568
3568
 
3569
3569
  > **loadEnv**(`dir`): `Promise`\<`void`\>
3570
3570
 
3571
- Defined in: [lib/core.ts:1147](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1147)
3571
+ Defined in: [lib/core.ts:1159](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1159)
3572
3572
 
3573
3573
  加载 .env 文件到 process.env,若文件不存在则跳过
3574
3574
 
@@ -3597,7 +3597,7 @@ lib/core/functions/log.md
3597
3597
 
3598
3598
  > **log**(`opt`, `msg`, `fend?`): `void`
3599
3599
 
3600
- Defined in: [lib/core.ts:849](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L849)
3600
+ Defined in: [lib/core.ts:861](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L861)
3601
3601
 
3602
3602
  写入文件日志
3603
3603
 
@@ -3638,7 +3638,7 @@ lib/core/functions/ls.md
3638
3638
 
3639
3639
  > **ls**(`opt`): `Promise`\<`object`[]\>
3640
3640
 
3641
- Defined in: [lib/core.ts:1009](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1009)
3641
+ Defined in: [lib/core.ts:1021](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1021)
3642
3642
 
3643
3643
  获取目录内文件/文件夹列表
3644
3644
 
@@ -3964,7 +3964,7 @@ lib/core/functions/removeGlobal.md
3964
3964
 
3965
3965
  > **removeGlobal**(`key`, `hosts?`): `Promise`\<`string`[]\>
3966
3966
 
3967
- Defined in: [lib/core.ts:730](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L730)
3967
+ Defined in: [lib/core.ts:736](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L736)
3968
3968
 
3969
3969
  移除某个跨线程/跨内网服务器全局变量
3970
3970
 
@@ -3999,7 +3999,7 @@ lib/core/functions/resolveEnvVars.md
3999
3999
 
4000
4000
  > **resolveEnvVars**(`obj`): `void`
4001
4001
 
4002
- Defined in: [lib/core.ts:1177](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1177)
4002
+ Defined in: [lib/core.ts:1189](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1189)
4003
4003
 
4004
4004
  将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
4005
4005
 
@@ -4028,7 +4028,7 @@ lib/core/functions/sendNpm.md
4028
4028
 
4029
4029
  > **sendNpm**(`path`, `hosts?`): `Promise`\<`string`[]\>
4030
4030
 
4031
- Defined in: [lib/core.ts:646](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L646)
4031
+ Defined in: [lib/core.ts:649](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L649)
4032
4032
 
4033
4033
  向本机或局域网 RPC 发送 npm install 操作
4034
4034
 
@@ -4104,7 +4104,7 @@ lib/core/functions/sendProject.md
4104
4104
 
4105
4105
  > **sendProject**(`path`, `key`, `value`, `hosts?`): `Promise`\<`string`[]\>
4106
4106
 
4107
- Defined in: [lib/core.ts:796](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L796)
4107
+ Defined in: [lib/core.ts:805](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L805)
4108
4108
 
4109
4109
  向本机或局域网 RPC 发送项目配置更新操作
4110
4110
 
@@ -4254,7 +4254,7 @@ lib/core/functions/setGlobal.md
4254
4254
 
4255
4255
  > **setGlobal**(`key`, `data`, `hosts?`): `Promise`\<`string`[]\>
4256
4256
 
4257
- Defined in: [lib/core.ts:689](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L689)
4257
+ Defined in: [lib/core.ts:695](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L695)
4258
4258
 
4259
4259
  设置跨线程/指定的局域网主机的全局变量
4260
4260
 
@@ -4353,7 +4353,7 @@ lib/core/functions/updateCode.md
4353
4353
 
4354
4354
  > **updateCode**(`sourcePath`, `path`, `hosts?`, `config?`, `strict?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4355
4355
 
4356
- Defined in: [lib/core.ts:742](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L742)
4356
+ Defined in: [lib/core.ts:748](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L748)
4357
4357
 
4358
4358
  上传并覆盖代码文件,config.json、kebab.json、.js.map、.ts, .gitignore 不会被覆盖和新创建
4359
4359
 
@@ -4406,7 +4406,7 @@ lib/core/functions/writeEventStreamHead.md
4406
4406
 
4407
4407
  > **writeEventStreamHead**(`res`): `void`
4408
4408
 
4409
- Defined in: [lib/core.ts:1117](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1117)
4409
+ Defined in: [lib/core.ts:1129](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1129)
4410
4410
 
4411
4411
  ## Parameters
4412
4412
 
@@ -4431,7 +4431,7 @@ lib/core/functions/writeHead.md
4431
4431
 
4432
4432
  > **writeHead**(`res`, `statusCode`, `headers?`): `void`
4433
4433
 
4434
- Defined in: [lib/core.ts:1106](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1106)
4434
+ Defined in: [lib/core.ts:1118](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1118)
4435
4435
 
4436
4436
  让 res 发送头部(前提是头部没有被发送才能调用本方法
4437
4437
 
@@ -4472,7 +4472,7 @@ lib/core/functions/write.md
4472
4472
 
4473
4473
  > **write**(`res`, `data`): `void`
4474
4474
 
4475
- Defined in: [lib/core.ts:1129](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1129)
4475
+ Defined in: [lib/core.ts:1141](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1141)
4476
4476
 
4477
4477
  向 res 发送数据
4478
4478
 
@@ -4642,7 +4642,7 @@ lib/core/interfaces/ILogOptions.md
4642
4642
 
4643
4643
  # Interface: ILogOptions
4644
4644
 
4645
- Defined in: [lib/core.ts:832](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L832)
4645
+ Defined in: [lib/core.ts:844](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L844)
4646
4646
 
4647
4647
  log 设置的选项
4648
4648
 
@@ -4652,7 +4652,7 @@ log 设置的选项
4652
4652
 
4653
4653
  > `optional` **cookie?**: `Record`\<`string`, `string`\>
4654
4654
 
4655
- Defined in: [lib/core.ts:838](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L838)
4655
+ Defined in: [lib/core.ts:850](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L850)
4656
4656
 
4657
4657
  ***
4658
4658
 
@@ -4660,7 +4660,7 @@ Defined in: [lib/core.ts:838](https://github.com/maiyunnet/kebab/blob/master/lib
4660
4660
 
4661
4661
  > `optional` **get?**: `Record`\<`string`, `any`\>
4662
4662
 
4663
- Defined in: [lib/core.ts:837](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L837)
4663
+ Defined in: [lib/core.ts:849](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L849)
4664
4664
 
4665
4665
  ***
4666
4666
 
@@ -4668,7 +4668,7 @@ Defined in: [lib/core.ts:837](https://github.com/maiyunnet/kebab/blob/master/lib
4668
4668
 
4669
4669
  > `optional` **headers?**: `IncomingHttpHeaders`
4670
4670
 
4671
- Defined in: [lib/core.ts:840](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L840)
4671
+ Defined in: [lib/core.ts:852](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L852)
4672
4672
 
4673
4673
  ***
4674
4674
 
@@ -4676,7 +4676,7 @@ Defined in: [lib/core.ts:840](https://github.com/maiyunnet/kebab/blob/master/lib
4676
4676
 
4677
4677
  > `optional` **hostname?**: `string`
4678
4678
 
4679
- Defined in: [lib/core.ts:835](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L835)
4679
+ Defined in: [lib/core.ts:847](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L847)
4680
4680
 
4681
4681
  ***
4682
4682
 
@@ -4684,7 +4684,7 @@ Defined in: [lib/core.ts:835](https://github.com/maiyunnet/kebab/blob/master/lib
4684
4684
 
4685
4685
  > `optional` **path?**: `string`
4686
4686
 
4687
- Defined in: [lib/core.ts:833](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L833)
4687
+ Defined in: [lib/core.ts:845](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L845)
4688
4688
 
4689
4689
  ***
4690
4690
 
@@ -4692,7 +4692,7 @@ Defined in: [lib/core.ts:833](https://github.com/maiyunnet/kebab/blob/master/lib
4692
4692
 
4693
4693
  > `optional` **req?**: `IncomingMessage` \| `Http2ServerRequest` \| `null`
4694
4694
 
4695
- Defined in: [lib/core.ts:836](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L836)
4695
+ Defined in: [lib/core.ts:848](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L848)
4696
4696
 
4697
4697
  ***
4698
4698
 
@@ -4700,7 +4700,7 @@ Defined in: [lib/core.ts:836](https://github.com/maiyunnet/kebab/blob/master/lib
4700
4700
 
4701
4701
  > `optional` **session?**: `Record`\<`string`, `any`\>
4702
4702
 
4703
- Defined in: [lib/core.ts:839](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L839)
4703
+ Defined in: [lib/core.ts:851](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L851)
4704
4704
 
4705
4705
  ***
4706
4706
 
@@ -4708,7 +4708,7 @@ Defined in: [lib/core.ts:839](https://github.com/maiyunnet/kebab/blob/master/lib
4708
4708
 
4709
4709
  > `optional` **urlFull?**: `string`
4710
4710
 
4711
- Defined in: [lib/core.ts:834](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L834)
4711
+ Defined in: [lib/core.ts:846](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L846)
4712
4712
 
4713
4713
  lib/core/type-aliases/TPm2Action.md
4714
4714
  ---
@@ -4797,7 +4797,7 @@ lib/core/variables/global.md
4797
4797
 
4798
4798
  > `const` **global**: `Record`\<`string`, `any`\> = `{}`
4799
4799
 
4800
- Defined in: [lib/core.ts:681](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L681)
4800
+ Defined in: [lib/core.ts:687](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L687)
4801
4801
 
4802
4802
  跨进程全局变量
4803
4803
 
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.3.5";
8
+ export declare const VER = "9.3.6";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.3.5';
9
+ export const VER = '9.3.6';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/core.js CHANGED
@@ -532,7 +532,10 @@ export async function sendPm2(name, action = 'restart', hosts) {
532
532
  if (hosts === 'config') {
533
533
  hosts = globalConfig.hosts;
534
534
  }
535
- hosts ??= ['127.0.0.1'];
535
+ // --- 未传或 config 展开后为空数组,均回退到本机 ---
536
+ if (!hosts?.length) {
537
+ hosts = ['127.0.0.1'];
538
+ }
536
539
  // --- 局域网模式 ---
537
540
  const time = lTime.stamp();
538
541
  /** --- 返回成功的 host --- */
@@ -569,7 +572,10 @@ export async function sendNpm(path, hosts) {
569
572
  if (hosts === 'config') {
570
573
  hosts = globalConfig.hosts;
571
574
  }
572
- hosts ??= ['127.0.0.1'];
575
+ // --- 未传或 config 展开后为空数组,均回退到本机 ---
576
+ if (!hosts?.length) {
577
+ hosts = ['127.0.0.1'];
578
+ }
573
579
  // --- 局域网模式 ---
574
580
  const time = lTime.stamp();
575
581
  /** --- 返回成功的 host --- */
@@ -659,7 +665,10 @@ export async function updateCode(sourcePath, path, hosts, config = true, strict
659
665
  if (hosts === 'config') {
660
666
  hosts = globalConfig.hosts;
661
667
  }
662
- hosts ??= ['127.0.0.1'];
668
+ // --- 未传或 config 展开后为空数组,均回退到本机 ---
669
+ if (!hosts?.length) {
670
+ hosts = ['127.0.0.1'];
671
+ }
663
672
  /** --- 返回成功的 host --- */
664
673
  const rtn = {};
665
674
  for (const host of hosts) {
@@ -703,7 +712,10 @@ export async function sendProject(path, key, value, hosts) {
703
712
  if (hosts === 'config') {
704
713
  hosts = globalConfig.hosts;
705
714
  }
706
- hosts ??= ['127.0.0.1'];
715
+ // --- 未传或 config 展开后为空数组,均回退到本机 ---
716
+ if (!hosts?.length) {
717
+ hosts = ['127.0.0.1'];
718
+ }
707
719
  // --- 局域网模式 ---
708
720
  const time = lTime.stamp();
709
721
  /** --- 返回成功的 host --- */
@@ -31,7 +31,7 @@ export declare class Response {
31
31
  /**
32
32
  * --- 获取响应读取流对象 ---
33
33
  */
34
- getStream(): zlib.BrotliDecompress | zlib.Gunzip | zlib.Inflate | (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | null;
34
+ getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress | null;
35
35
  /**
36
36
  * --- 获取原生响应读取流对象 ---
37
37
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.3.5",
3
+ "version": "9.3.6",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -19,9 +19,9 @@
19
19
  * 如需打包为 .bundle.js,执行:node ./source/main build
20
20
  *
21
21
  * 【Tailwind CSS 构建】
22
- * bundle 模式下不再加载 CDN,需提前构建 CSS 产物。
23
- * 执行 node ./source/main build 时会自动构建同名 .css,无需单独执行。
24
- * 框架通过 _urlStc _staticVer 自动拼接正确的带版本号 URL。
22
+ * 需提前执行 node ./source/main build -d source/www/example/stc 生成 CSS 产物。
23
+ * 框架通过 _staticPath _staticVer 自动拼接带版本号 URL;
24
+ * import map、props JSON、水合脚本均由框架自动注入 HTML,组件无需手动处理。
25
25
  */
26
26
  interface IUser {
27
27
  'id': string;
@@ -42,17 +42,11 @@ interface IProps {
42
42
  '_staticVer': string;
43
43
  /** --- 框架注入:BrowserRouter 的 basename,如 /test/react-router-page --- */
44
44
  '_routerBase'?: string;
45
- /** --- 框架注入:import map JSON 字符串 --- */
46
- '_importMapJson'?: string;
47
- /** --- 框架注入:水合脚本 --- */
48
- '_hydrateScript'?: string;
49
- /** --- 框架注入:fullProps 序列化 JSON --- */
50
- '_propsJson'?: string;
51
45
  }
52
46
  /**
53
47
  * --- Kebab React BrowserRouter 全页面演示 ---
54
48
  * 框架负责用 StaticRouter(服务端)/ BrowserRouter(客户端)包裹本组件,
55
49
  * 组件内部只需使用 Routes/Route/Link 等,无需自行包裹 Router。
56
50
  */
57
- export default function ReactRouterPage({ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, _importMapJson, _hydrateScript, _propsJson, }: IProps): import("react/jsx-runtime").JSX.Element;
51
+ export default function ReactRouterPage({ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, }: IProps): import("react/jsx-runtime").JSX.Element;
58
52
  export {};
@@ -20,9 +20,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  * 如需打包为 .bundle.js,执行:node ./source/main build
21
21
  *
22
22
  * 【Tailwind CSS 构建】
23
- * bundle 模式下不再加载 CDN,需提前构建 CSS 产物。
24
- * 执行 node ./source/main build 时会自动构建同名 .css,无需单独执行。
25
- * 框架通过 _urlStc _staticVer 自动拼接正确的带版本号 URL。
23
+ * 需提前执行 node ./source/main build -d source/www/example/stc 生成 CSS 产物。
24
+ * 框架通过 _staticPath _staticVer 自动拼接带版本号 URL;
25
+ * import map、props JSON、水合脚本均由框架自动注入 HTML,组件无需手动处理。
26
26
  */
27
27
  import { useState, useEffect } from 'react';
28
28
  import { Routes, Route, Link, NavLink, useParams, useNavigate, useLocation, Outlet } from 'react-router-dom';
@@ -135,8 +135,6 @@ function PageNotFound() {
135
135
  * 框架负责用 StaticRouter(服务端)/ BrowserRouter(客户端)包裹本组件,
136
136
  * 组件内部只需使用 Routes/Route/Link 等,无需自行包裹 Router。
137
137
  */
138
- export default function ReactRouterPage({ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, _importMapJson, _hydrateScript, _propsJson, }) {
139
- return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("title", { suppressHydrationWarning: true, children: title }), _importMapJson
140
- ? _jsx("script", { src: "https://cdn.tailwindcss.com" })
141
- : _jsx("link", { rel: "stylesheet", href: `${_urlStc}view/react-router-page.css?v=${_staticVer}` }), _importMapJson && (_jsx("script", { type: "importmap", dangerouslySetInnerHTML: { '__html': _importMapJson } }))] }), _jsxs("body", { className: "bg-slate-50 min-h-screen", children: [_jsxs("div", { className: "max-w-2xl mx-auto px-4 py-10 space-y-6", children: [_jsxs("div", { className: "flex items-start justify-between", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold text-slate-900", children: "Kebab React Router" }), _jsxs("p", { className: "text-slate-500 mt-1 text-sm", children: [_jsx("code", { className: "bg-slate-100 px-1.5 py-0.5 rounded font-mono text-xs", children: "router: 'browser'" }), "\u00A0mode \u2014 URL synced with routes"] })] }), _jsx("a", { href: `${_urlBase}`, className: "text-xs text-slate-400 hover:text-slate-600 transition-colors mt-1", children: "Back to Index" })] }), _jsx("div", { className: "bg-white rounded-xl shadow-sm border border-slate-200 px-4 py-3", children: _jsx(NavBar, {}) }), _jsx("div", { className: "bg-white rounded-xl shadow-sm border border-slate-200 p-6", children: _jsxs(Routes, { children: [_jsx(Route, { path: "/", element: _jsx(PageHome, { serverTime: serverTime, node: node }) }), _jsx(Route, { path: "/about", element: _jsx(PageAbout, {}) }), _jsx(Route, { path: "/user", element: _jsx(PageUsers, { users: users, urlBase: _urlBase }) }), _jsx(Route, { path: "/user/:id", element: _jsx(PageUserDetail, { user: user, urlBase: _urlBase }), children: _jsx(Route, { path: "profile", element: _jsx(PageUserProfile, {}) }) }), _jsx(Route, { path: "*", element: _jsx(PageNotFound, {}) })] }) }), _jsxs(Card, { className: "text-xs text-slate-500 space-y-1.5", children: [_jsx("p", { className: "font-semibold text-slate-700 text-sm", children: "How It Works" }), _jsxs("p", { children: ["\u2022 Server: framework wraps with ", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "StaticRouter" }), " to SSR the matching route"] }), _jsxs("p", { children: ["\u2022 Client: hydration script wraps with ", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "BrowserRouter" }), " for URL-synced navigation"] }), _jsxs("p", { children: ["\u2022 Data: one backend method (", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "_getRouteData" }), ") serves both SSR props and SPA API"] }), _jsxs("p", { children: ["\u2022 Deep links like ", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "/test/react-router-page/user/42" }), " work out of the box"] })] })] }), _propsJson && (_jsx("script", { id: "__kebab_props__", type: "application/json", suppressHydrationWarning: true, dangerouslySetInnerHTML: { '__html': _propsJson } })), _hydrateScript && (_jsx("script", { type: "module", suppressHydrationWarning: true, dangerouslySetInnerHTML: { '__html': _hydrateScript } }))] })] }));
138
+ export default function ReactRouterPage({ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, }) {
139
+ return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("title", { suppressHydrationWarning: true, children: title }), _jsx("link", { rel: "stylesheet", href: `${_urlStc}view/react-router-page.css?v=${_staticVer}` })] }), _jsx("body", { className: "bg-slate-50 min-h-screen", children: _jsxs("div", { className: "max-w-2xl mx-auto px-4 py-10 space-y-6", children: [_jsxs("div", { className: "flex items-start justify-between", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold text-slate-900", children: "Kebab React Router" }), _jsxs("p", { className: "text-slate-500 mt-1 text-sm", children: [_jsx("code", { className: "bg-slate-100 px-1.5 py-0.5 rounded font-mono text-xs", children: "router: 'browser'" }), "\u00A0mode \u2014 URL synced with routes"] })] }), _jsx("a", { href: `${_urlBase}`, className: "text-xs text-slate-400 hover:text-slate-600 transition-colors mt-1", children: "Back to Index" })] }), _jsx("div", { className: "bg-white rounded-xl shadow-sm border border-slate-200 px-4 py-3", children: _jsx(NavBar, {}) }), _jsx("div", { className: "bg-white rounded-xl shadow-sm border border-slate-200 p-6", children: _jsxs(Routes, { children: [_jsx(Route, { path: "/", element: _jsx(PageHome, { serverTime: serverTime, node: node }) }), _jsx(Route, { path: "/about", element: _jsx(PageAbout, {}) }), _jsx(Route, { path: "/user", element: _jsx(PageUsers, { users: users, urlBase: _urlBase }) }), _jsx(Route, { path: "/user/:id", element: _jsx(PageUserDetail, { user: user, urlBase: _urlBase }), children: _jsx(Route, { path: "profile", element: _jsx(PageUserProfile, {}) }) }), _jsx(Route, { path: "*", element: _jsx(PageNotFound, {}) })] }) }), _jsxs(Card, { className: "text-xs text-slate-500 space-y-1.5", children: [_jsx("p", { className: "font-semibold text-slate-700 text-sm", children: "How It Works" }), _jsxs("p", { children: ["\u2022 Server: framework wraps with ", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "StaticRouter" }), " to SSR the matching route"] }), _jsxs("p", { children: ["\u2022 Client: hydration script wraps with ", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "BrowserRouter" }), " for URL-synced navigation"] }), _jsxs("p", { children: ["\u2022 Data: one backend method (", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "_getRouteData" }), ") serves both SSR props and SPA API"] }), _jsxs("p", { children: ["\u2022 Deep links like ", _jsx("code", { className: "bg-slate-100 px-1 rounded", children: "/test/react-router-page/user/42" }), " work out of the box"] })] })] }) })] }));
142
140
  }
@@ -19,9 +19,9 @@
19
19
  * 如需打包为 .bundle.js,执行:node ./source/main build
20
20
  *
21
21
  * 【Tailwind CSS 构建】
22
- * bundle 模式下不再加载 CDN,需提前构建 CSS 产物。
23
- * 执行 node ./source/main build 时会自动构建同名 .css,无需单独执行。
24
- * 框架通过 _urlStc _staticVer 自动拼接正确的带版本号 URL。
22
+ * 需提前执行 node ./source/main build -d source/www/example/stc 生成 CSS 产物。
23
+ * 框架通过 _staticPath _staticVer 自动拼接带版本号 URL;
24
+ * import map、props JSON、水合脚本均由框架自动注入 HTML,组件无需手动处理。
25
25
  */
26
26
 
27
27
  import { useState, useEffect } from 'react';
@@ -49,12 +49,6 @@ interface IProps {
49
49
  '_staticVer': string;
50
50
  /** --- 框架注入:BrowserRouter 的 basename,如 /test/react-router-page --- */
51
51
  '_routerBase'?: string;
52
- /** --- 框架注入:import map JSON 字符串 --- */
53
- '_importMapJson'?: string;
54
- /** --- 框架注入:水合脚本 --- */
55
- '_hydrateScript'?: string;
56
- /** --- 框架注入:fullProps 序列化 JSON --- */
57
- '_propsJson'?: string;
58
52
  }
59
53
 
60
54
  // --- 基础控件 ---
@@ -334,7 +328,7 @@ function PageNotFound() {
334
328
  * 组件内部只需使用 Routes/Route/Link 等,无需自行包裹 Router。
335
329
  */
336
330
  export default function ReactRouterPage({
337
- title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, _importMapJson, _hydrateScript, _propsJson,
331
+ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer,
338
332
  }: IProps) {
339
333
  return (
340
334
  <html lang="en">
@@ -343,14 +337,9 @@ export default function ReactRouterPage({
343
337
  <meta name="viewport" content="width=device-width, initial-scale=1" />
344
338
  {/* eslint-disable-next-line @typescript-eslint/naming-convention */}
345
339
  <title suppressHydrationWarning>{title}</title>
346
- {/* --- CSS:dev 模式(无 bundle)用 Tailwind CDN;bundle 模式加载本地构建产物 --- */}
347
- {_importMapJson
348
- ? <script src="https://cdn.tailwindcss.com" />
349
- : <link rel="stylesheet" href={`${_urlStc}view/react-router-page.css?v=${_staticVer}`} />}
350
- {/* --- import map:让浏览器识别 bare import,esm.sh 自动解析依赖 --- */}
351
- {_importMapJson && (
352
- <script type="importmap" dangerouslySetInnerHTML={{ '__html': _importMapJson }} />
353
- )}
340
+ {/* --- import map 由框架自动注入在此标签前,无需手动添加 --- */}
341
+ {/* --- dev: 需先执行 node ./source/main build -d source/www/example/stc 生成 CSS --- */}
342
+ <link rel="stylesheet" href={`${_urlStc}view/react-router-page.css?v=${_staticVer}`} />
354
343
  </head>
355
344
  <body className="bg-slate-50 min-h-screen">
356
345
  <div className="max-w-2xl mx-auto px-4 py-10 space-y-6">
@@ -403,23 +392,7 @@ export default function ReactRouterPage({
403
392
  </Card>
404
393
  </div>
405
394
 
406
- {/* --- 框架注入:props JSON,供客户端水合读取 --- */}
407
- {_propsJson && (
408
- <script
409
- id="__kebab_props__"
410
- type="application/json"
411
- suppressHydrationWarning
412
- dangerouslySetInnerHTML={{ '__html': _propsJson }}
413
- />
414
- )}
415
- {/* --- 框架注入:水合脚本 --- */}
416
- {_hydrateScript && (
417
- <script
418
- type="module"
419
- suppressHydrationWarning
420
- dangerouslySetInnerHTML={{ '__html': _hydrateScript }}
421
- />
422
- )}
395
+ {/* --- props JSON + 水合脚本由框架自动注入在此标签前,无需手动添加 --- */}
423
396
  </body>
424
397
  </html>
425
398
  );