Commit bc376f43 by liimin

feat: api-core SHA1/多transport 扩展 + JS 产物;mp lane 基建(名字真源+sync+护栏)

- api-core:新增 sha1/crypto、createSha1Signer(secret 前后包裹+全签+大写,与原生
  mp sign.js 字节级一致)、createWxSender/UniSender/FetchSender/AutoSender、
  GatewayStrategy.fixedParams(dispatcher 签名前并入);tsup 出 CJS+ESM+dts
  供原生小程序构建 npm 消费(miniprogram 字段指 dist/index.cjs)
- mp lane 基建:apps/mp/manifest.json 名字唯一真源(usedcar/sales/store/points,
  含 source gitlab 仓与 backend 家族提示);scripts/sync-mp-apps.mjs 消费端
  (--prune 清旧 lane;dir 含连字符时派生 camelCase 标识符修非法命名 bug);
  4 个 lane 脚手架(createWxSender+createSha1Signer+fixedParams)
- typescript-config/mini-program.json + eslint mp() 预设;check-boundaries 双 lane
  护栏(mp 禁引 platform-core/web-*/wujie)
- 根 eslint ignores:apps/mp/**/*.js(原生 mp 代码归 devtool 管,工具链只查 src/)、
  temp/**(已 gitignore 的暂存目录此前被 lint:all 误扫,顺手修复)
1 parent 644bd133
import { mp } from '@uj/eslint-config';
// 小程序 lane:禁止引用 web/host 独占运行时(见 @uj/eslint-config 的 mp 预设)。
export default mp();
{
"name": "@uj/mp-example",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "eslint ."
},
"dependencies": {
"@uj/api-core": "workspace:*"
},
"devDependencies": {
"@uj/contracts": "workspace:*",
"@uj/eslint-config": "workspace:*",
"@uj/typescript-config": "workspace:*",
"typescript": "catalog:"
}
}
import {
createRpcDispatcher,
createWxSender,
createSha1Signer,
registerGateway,
type GatewayStrategy,
type GatewayCredential,
type NormalizedEnvelope,
type RpcCall,
} from '@uj/api-core';
/**
* 原生小程序接入示例(apps/mp lane 的样板)。
*
* 与 web 子应用共用同一套 @uj/api-core 契约,差异只在 transport 一个参数:
* - web 子应用:createHostSender(requestViaHost()) 把请求交回主壳 axios;
* - 原生小程序:createWxSender() 直接用 wx.request(不经由主壳,不破坏请求层边界)。
*
* 签名用 api-core 内置 SHA1 预设:原生小程序 RPC 网关走 SHA1(secret 前后包裹、
* appKey/format/method/v + params 全签),与 web points 子应用的 MD5 网关是两套不同算法。
*
* 注意:本文件在微信运行时被 import 时才会执行 createWxSender();
* 类型检查 / lint 不会执行这段代码,因此无需担心 Node 环境下 wx 缺失。
*/
export const demoGateway: GatewayStrategy = {
id: 'demo-backend',
// 落点随接入项目而变:scrm 系为 rop-scrm-<dir>/router,dj 系为 rop-dj-<dir>/router。
router: 'rop-scrm-demo/router',
tokenHeader: 'token',
// 原生小程序签名:SHA1 预设;换算法(HMAC / MD5)只改这一行。
signer: createSha1Signer({ id: 'demo-sha1' }),
// 网关级常量参数:并进签名与请求体(会话态 sessionId 等业务参数在调用时再传)。
fixedParams: { locale: 'zh_CN', source: 'dj-wechat' },
// 把对方信封归一成主壳拦截器认得的 { data } / { code, message }。
normalize(body: unknown): NormalizedEnvelope {
if (!body || typeof body !== 'object') return { data: body };
const env = body as Record<string, unknown>;
const code = env['code'];
if (String(code) === '0') return { data: env['data'] };
return {
code: Number(code) || 500,
message: typeof env['message'] === 'string' ? env['message'] : '请求失败',
};
},
};
registerGateway(demoGateway);
/** 运行时凭据:真实项目从配置中心 / 编译变量注入,本层不留密钥字面量。 */
const credentials = new Map<string, GatewayCredential>([
['demo-backend', { origin: 'https://demo.example.com', appKey: 'app-key', secret: 'app-secret', version: '1.0', format: 'json' }],
]);
const dispatch = createRpcDispatcher({
// 原生小程序 transport:wx.request(非 wujie 环境,可自行发请求)。
sender: createWxSender(),
resolveCredential: (id) => {
const c = credentials.get(id);
if (!c) throw new Error(`未配置网关 ${id} 的凭据`);
return c;
},
resolveToken: () => '',
timeout: 30000,
});
/** 业务侧调用:只说方法名和参数,不关心对方怎么加签 / 怎么发。 */
export function callDemo<T = unknown>(method: string, params: Record<string, unknown>): Promise<T> {
const call: RpcCall = { gateway: 'demo-backend', method, params, signed: true };
return dispatch(call) as Promise<T>;
}
{
"extends": "../../../packages/typescript-config/mini-program.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@uj/api-core": ["../../../packages/api-core/src/index.ts"],
"@uj/contracts": ["../../../packages/contracts/src/index.ts"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts"]
}
{
"note": "【mp lane 名字唯一真源】这里定义所有原生小程序 lane 的目录名与元信息。dir 同时决定目录名 apps/mp/<dir> 与包名 @uj/mp-<dir>。名字已定稿(2026-11-06 超人拍板),后续若需改名改本文件的 dir / displayName / appId / backend / source 字段,再跑 `pnpm mp:sync` 即可重建脚手架(`--prune` 清旧目录)。`source` 字段记录该 lane 真实代码来自哪个 GitLab 仓库,供物理迁入时对照;`backend` 为后端家族提示,精确的 scrm/dj project 码在物理迁移真实请求层时再落定。",
"apps": [
{
"dir": "usedcar",
"displayName": "二手车 / 车精品小程序",
"appId": "wx_usedcar_PLACEHOLDER",
"backend": "saas_plus 家族(dj-car-boutique-work-wechat);双后端 scrm + dj,project 码待物理迁移时确认",
"source": "dj-car-boutique-work-wechat"
},
{
"dir": "sales",
"displayName": "车生活小程序(SCRM)",
"appId": "wx_sales_PLACEHOLDER",
"backend": "glsx SCRM(miniprogram-scrm-carlife,已依赖 glsx-common-sdk)",
"source": "miniprogram-scrm-carlife"
},
{
"dir": "store",
"displayName": "门店助手小程序",
"appId": "wx_store_PLACEHOLDER",
"backend": "saas_plus 家族(store-assistant-assemble);双后端 scrm + dj(djSecretKey)",
"source": "store-assistant-assemble"
},
{
"dir": "points",
"displayName": "积分商城小程序",
"appId": "wx_points_PLACEHOLDER",
"backend": "scrm-shopmall(points-mall,单后端,与 web points 同构)",
"source": "points-mall"
}
]
}
import { mp } from '@uj/eslint-config';
// 小程序 lane:禁止引用 web/host 独占运行时(见 @uj/eslint-config 的 mp 预设)。
export default mp();
{
"name": "@uj/mp-sales",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "eslint ."
},
"dependencies": {
"@uj/api-core": "workspace:*"
},
"devDependencies": {
"@uj/contracts": "workspace:*",
"@uj/eslint-config": "workspace:*",
"@uj/typescript-config": "workspace:*",
"typescript": "catalog:"
}
}
import {
createRpcDispatcher,
createWxSender,
createSha1Signer,
registerGateway,
type GatewayStrategy,
type GatewayCredential,
type NormalizedEnvelope,
type RpcCall,
} from '@uj/api-core';
/**
* 车生活小程序(SCRM)(apps/mp lane 脚手架,由 scripts/sync-mp-apps.mjs 依据 apps/mp/manifest.json 生成)。
*
* 与 web 子应用共用同一套 @uj/api-core 契约,差异只在 transport 一个参数:
* - web 子应用:createHostSender(requestViaHost()) 把请求交回主壳 axios;
* - 原生小程序:createWxSender() 直接用 wx.request(不经由主壳,不破坏请求层边界)。
*
* 签名用 api-core 内置 SHA1 预设:原生小程序 RPC 网关走 SHA1(secret 前后包裹、
* appKey/format/method/v + params 全签),与 web points 子应用的 MD5 网关是两套不同
* 算法——同一后端家族、不同端用不同摘要,故 mp 走 createSha1Signer。
*
* 注意:本文件在微信运行时被 import 时才会执行 createWxSender();
* 类型检查 / lint 不会执行这段代码,因此无需担心 Node 环境下 wx 缺失。
*/
export const salesGateway: GatewayStrategy = {
id: 'sales-backend',
// 落点随接入项目而变:scrm 系为 rop-scrm-<dir>/router,dj 系为 rop-dj-<dir>/router。
router: 'rop-scrm-sales/router',
tokenHeader: 'token',
// 原生小程序签名:SHA1 预设;换算法(HMAC / MD5)只改这一行。
signer: createSha1Signer({ id: 'sales-sha1' }),
// 网关级常量参数:并进签名与请求体(会话态 sessionId 等业务参数在调用时再传)。
fixedParams: { locale: 'zh_CN', source: 'dj-wechat' },
// 把对方信封归一成主壳拦截器认得的 { data } / { code, message }。
normalize(body: unknown): NormalizedEnvelope {
if (!body || typeof body !== 'object') return { data: body };
const env = body as Record<string, unknown>;
const code = env['code'];
if (String(code) === '0') return { data: env['data'] };
return {
code: Number(code) || 500,
message: typeof env['message'] === 'string' ? env['message'] : '请求失败',
};
},
};
registerGateway(salesGateway);
/** 运行时凭据:真实项目从配置中心 / 编译变量注入,本层不留密钥字面量。 */
const credentials = new Map<string, GatewayCredential>([
['sales-backend', { origin: 'https://sales.example.com', appKey: 'app-key', secret: 'app-secret', version: '1.0', format: 'json' }],
]);
const dispatch = createRpcDispatcher({
// 原生小程序 transport:wx.request(非 wujie 环境,可自行发请求)。
sender: createWxSender(),
resolveCredential: (id) => {
const c = credentials.get(id);
if (!c) throw new Error(`未配置网关 ${id} 的凭据`);
return c;
},
resolveToken: () => '',
timeout: 30000,
});
/** 业务侧调用:只说方法名和参数,不关心对方怎么加签 / 怎么发。 */
export function callSales<T = unknown>(method: string, params: Record<string, unknown>): Promise<T> {
const call: RpcCall = { gateway: 'sales-backend', method, params, signed: true };
return dispatch(call) as Promise<T>;
}
{
"extends": "../../../packages/typescript-config/mini-program.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@uj/api-core": [
"../../../packages/api-core/src/index.ts"
],
"@uj/contracts": [
"../../../packages/contracts/src/index.ts"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.d.ts"
]
}
import { mp } from '@uj/eslint-config';
// 小程序 lane:禁止引用 web/host 独占运行时(见 @uj/eslint-config 的 mp 预设)。
export default mp();
{
"name": "@uj/mp-store",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "eslint ."
},
"dependencies": {
"@uj/api-core": "workspace:*"
},
"devDependencies": {
"@uj/contracts": "workspace:*",
"@uj/eslint-config": "workspace:*",
"@uj/typescript-config": "workspace:*",
"typescript": "catalog:"
}
}
import {
createRpcDispatcher,
createWxSender,
createSha1Signer,
registerGateway,
type GatewayStrategy,
type GatewayCredential,
type NormalizedEnvelope,
type RpcCall,
} from '@uj/api-core';
/**
* 门店助手小程序(apps/mp lane 脚手架,由 scripts/sync-mp-apps.mjs 依据 apps/mp/manifest.json 生成)。
*
* 与 web 子应用共用同一套 @uj/api-core 契约,差异只在 transport 一个参数:
* - web 子应用:createHostSender(requestViaHost()) 把请求交回主壳 axios;
* - 原生小程序:createWxSender() 直接用 wx.request(不经由主壳,不破坏请求层边界)。
*
* 签名用 api-core 内置 SHA1 预设:原生小程序 RPC 网关走 SHA1(secret 前后包裹、
* appKey/format/method/v + params 全签),与 web points 子应用的 MD5 网关是两套不同
* 算法——同一后端家族、不同端用不同摘要,故 mp 走 createSha1Signer。
*
* 注意:本文件在微信运行时被 import 时才会执行 createWxSender();
* 类型检查 / lint 不会执行这段代码,因此无需担心 Node 环境下 wx 缺失。
*/
export const storeGateway: GatewayStrategy = {
id: 'store-backend',
// 落点随接入项目而变:scrm 系为 rop-scrm-<dir>/router,dj 系为 rop-dj-<dir>/router。
router: 'rop-scrm-store/router',
tokenHeader: 'token',
// 原生小程序签名:SHA1 预设;换算法(HMAC / MD5)只改这一行。
signer: createSha1Signer({ id: 'store-sha1' }),
// 网关级常量参数:并进签名与请求体(会话态 sessionId 等业务参数在调用时再传)。
fixedParams: { locale: 'zh_CN', source: 'dj-wechat' },
// 把对方信封归一成主壳拦截器认得的 { data } / { code, message }。
normalize(body: unknown): NormalizedEnvelope {
if (!body || typeof body !== 'object') return { data: body };
const env = body as Record<string, unknown>;
const code = env['code'];
if (String(code) === '0') return { data: env['data'] };
return {
code: Number(code) || 500,
message: typeof env['message'] === 'string' ? env['message'] : '请求失败',
};
},
};
registerGateway(storeGateway);
/** 运行时凭据:真实项目从配置中心 / 编译变量注入,本层不留密钥字面量。 */
const credentials = new Map<string, GatewayCredential>([
['store-backend', { origin: 'https://store.example.com', appKey: 'app-key', secret: 'app-secret', version: '1.0', format: 'json' }],
]);
const dispatch = createRpcDispatcher({
// 原生小程序 transport:wx.request(非 wujie 环境,可自行发请求)。
sender: createWxSender(),
resolveCredential: (id) => {
const c = credentials.get(id);
if (!c) throw new Error(`未配置网关 ${id} 的凭据`);
return c;
},
resolveToken: () => '',
timeout: 30000,
});
/** 业务侧调用:只说方法名和参数,不关心对方怎么加签 / 怎么发。 */
export function callStore<T = unknown>(method: string, params: Record<string, unknown>): Promise<T> {
const call: RpcCall = { gateway: 'store-backend', method, params, signed: true };
return dispatch(call) as Promise<T>;
}
{
"extends": "../../../packages/typescript-config/mini-program.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@uj/api-core": [
"../../../packages/api-core/src/index.ts"
],
"@uj/contracts": [
"../../../packages/contracts/src/index.ts"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.d.ts"
]
}
import { mp } from '@uj/eslint-config';
// 小程序 lane:禁止引用 web/host 独占运行时(见 @uj/eslint-config 的 mp 预设)。
export default mp();
{
"name": "@uj/mp-usedcar",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "eslint ."
},
"dependencies": {
"@uj/api-core": "workspace:*"
},
"devDependencies": {
"@uj/contracts": "workspace:*",
"@uj/eslint-config": "workspace:*",
"@uj/typescript-config": "workspace:*",
"typescript": "catalog:"
}
}
import {
createRpcDispatcher,
createWxSender,
createSha1Signer,
registerGateway,
type GatewayStrategy,
type GatewayCredential,
type NormalizedEnvelope,
type RpcCall,
} from '@uj/api-core';
/**
* 二手车 / 车精品小程序(apps/mp lane 脚手架,由 scripts/sync-mp-apps.mjs 依据 apps/mp/manifest.json 生成)。
*
* 与 web 子应用共用同一套 @uj/api-core 契约,差异只在 transport 一个参数:
* - web 子应用:createHostSender(requestViaHost()) 把请求交回主壳 axios;
* - 原生小程序:createWxSender() 直接用 wx.request(不经由主壳,不破坏请求层边界)。
*
* 签名用 api-core 内置 SHA1 预设:原生小程序 RPC 网关走 SHA1(secret 前后包裹、
* appKey/format/method/v + params 全签),与 web points 子应用的 MD5 网关是两套不同
* 算法——同一后端家族、不同端用不同摘要,故 mp 走 createSha1Signer。
*
* 注意:本文件在微信运行时被 import 时才会执行 createWxSender();
* 类型检查 / lint 不会执行这段代码,因此无需担心 Node 环境下 wx 缺失。
*/
export const usedcarGateway: GatewayStrategy = {
id: 'usedcar-backend',
// 落点随接入项目而变:scrm 系为 rop-scrm-<dir>/router,dj 系为 rop-dj-<dir>/router。
router: 'rop-scrm-usedcar/router',
tokenHeader: 'token',
// 原生小程序签名:SHA1 预设;换算法(HMAC / MD5)只改这一行。
signer: createSha1Signer({ id: 'usedcar-sha1' }),
// 网关级常量参数:并进签名与请求体(会话态 sessionId 等业务参数在调用时再传)。
fixedParams: { locale: 'zh_CN', source: 'dj-wechat' },
// 把对方信封归一成主壳拦截器认得的 { data } / { code, message }。
normalize(body: unknown): NormalizedEnvelope {
if (!body || typeof body !== 'object') return { data: body };
const env = body as Record<string, unknown>;
const code = env['code'];
if (String(code) === '0') return { data: env['data'] };
return {
code: Number(code) || 500,
message: typeof env['message'] === 'string' ? env['message'] : '请求失败',
};
},
};
registerGateway(usedcarGateway);
/** 运行时凭据:真实项目从配置中心 / 编译变量注入,本层不留密钥字面量。 */
const credentials = new Map<string, GatewayCredential>([
['usedcar-backend', { origin: 'https://usedcar.example.com', appKey: 'app-key', secret: 'app-secret', version: '1.0', format: 'json' }],
]);
const dispatch = createRpcDispatcher({
// 原生小程序 transport:wx.request(非 wujie 环境,可自行发请求)。
sender: createWxSender(),
resolveCredential: (id) => {
const c = credentials.get(id);
if (!c) throw new Error(`未配置网关 ${id} 的凭据`);
return c;
},
resolveToken: () => '',
timeout: 30000,
});
/** 业务侧调用:只说方法名和参数,不关心对方怎么加签 / 怎么发。 */
export function callUsedcar<T = unknown>(method: string, params: Record<string, unknown>): Promise<T> {
const call: RpcCall = { gateway: 'usedcar-backend', method, params, signed: true };
return dispatch(call) as Promise<T>;
}
{
"extends": "../../../packages/typescript-config/mini-program.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@uj/api-core": [
"../../../packages/api-core/src/index.ts"
],
"@uj/contracts": [
"../../../packages/contracts/src/index.ts"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.d.ts"
]
}
......@@ -9,7 +9,7 @@ import { app } from '@uj/eslint-config';
*/
export default [
{
ignores: ['**/dist/**', '**/node_modules/**', '**/.turbo/**', '**/coverage/**', '.release/**'],
ignores: ['**/dist/**', '**/node_modules/**', '**/.turbo/**', '**/coverage/**', '.release/**', '**/temp/**', '**/apps/mp/**/*.js'],
},
...app(),
];
......@@ -38,6 +38,7 @@
"release:prune": "node scripts/release/release-prune.mjs",
"sync": "node scripts/sync-from-uj-store.mjs",
"gen:tsconfig": "node scripts/gen-tsconfig.mjs",
"mp:sync": "node scripts/sync-mp-apps.mjs",
"verify": "node scripts/check-boundaries.mjs && node scripts/reconcile.mjs && pnpm typecheck && pnpm lint && pnpm lint:all && pnpm format:check",
"ci": "pnpm verify && pnpm build"
},
......
......@@ -3,9 +3,24 @@
"version": "0.0.0",
"private": true,
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"miniprogram": "./dist/index.cjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.cjs"
}
},
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"lint": "eslint . --max-warnings=0",
"typecheck": "tsc --noEmit"
},
......@@ -14,6 +29,7 @@
"@uj/eslint-config": "workspace:*",
"@uj/typescript-config": "workspace:*",
"eslint": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
}
}
......@@ -150,3 +150,96 @@ export async function hmacSha256(message: string, secret: string): Promise<strin
.map((b) => b.toString(16).padStart(2, '0'))
.join('');
}
/**
* SHA1(RFC 3174)。
*
* 原生小程序(points-mall / store-assistant / business-assistant / scrm-carlife)的 RPC 网关
* 走 SHA1 加签(`sha1(secret + 拼接原文 + secret).toUpperCase()`),与 web points 子应用的
* MD5 网关是**两套不同算法**——同一网关家族、不同端用不同摘要。为不让 mp 重新造轮子,这里
* 提供零依赖纯实现,与 MD5 共用 `toUtf8Bytes`,并已用 RFC 3174 测试向量核对。
*/
function leftRotate32(value: number, amount: number): number {
return ((value << amount) | (value >>> (32 - amount))) >>> 0;
}
function toHexBigEndian(word: number): string {
return (word >>> 0).toString(16).padStart(8, '0');
}
export function sha1(input: string): string {
const bytes = toUtf8Bytes(input);
const bitLen = bytes.length * 8;
bytes.push(0x80);
while (bytes.length % 64 !== 56) bytes.push(0);
// 64 位大端长度;本场景 message 远小于 2^32 位,高 32 位恒为 0。
const hi = Math.floor(bitLen / 2 ** 32);
const lo = bitLen >>> 0;
bytes.push(
(hi >>> 24) & 0xff,
(hi >>> 16) & 0xff,
(hi >>> 8) & 0xff,
hi & 0xff,
(lo >>> 24) & 0xff,
(lo >>> 16) & 0xff,
(lo >>> 8) & 0xff,
lo & 0xff,
);
let h0 = 0x67452301;
let h1 = 0xefcdab89;
let h2 = 0x98badcfe;
let h3 = 0x10325476;
let h4 = 0xc3d2e1f0;
const w = new Array<number>(80);
for (let i = 0; i < bytes.length; i += 64) {
for (let j = 0; j < 16; j += 1) {
const p = i + j * 4;
w[j] =
((bytes[p]! << 24) |
(bytes[p + 1]! << 16) |
(bytes[p + 2]! << 8) |
bytes[p + 3]!) >>>
0;
}
for (let j = 16; j < 80; j += 1) {
w[j] = leftRotate32(w[j - 3]! ^ w[j - 8]! ^ w[j - 14]! ^ w[j - 16]!, 1);
}
let a = h0;
let b = h1;
let c = h2;
let d = h3;
let e = h4;
for (let j = 0; j < 80; j += 1) {
let f: number;
let k: number;
if (j < 20) {
f = (b & c) | (~b & d);
k = 0x5a827999;
} else if (j < 40) {
f = b ^ c ^ d;
k = 0x6ed9eba1;
} else if (j < 60) {
f = (b & c) | (b & d) | (c & d);
k = 0x8f1bbcdc;
} else {
f = b ^ c ^ d;
k = 0xca62c1d6;
}
const temp = (leftRotate32(a, 5) + f + e + k + w[j]!) | 0;
e = d;
d = c;
c = leftRotate32(b, 30);
b = a;
a = temp >>> 0;
}
h0 = (h0 + a) | 0;
h1 = (h1 + b) | 0;
h2 = (h2 + c) | 0;
h3 = (h3 + d) | 0;
h4 = (h4 + e) | 0;
}
return [h0, h1, h2, h3, h4].map(toHexBigEndian).join('');
}
......@@ -52,7 +52,12 @@ export function createRpcDispatcher(deps: RpcDispatcherDeps) {
const credential = resolveCredential(call.gateway);
const needsSign = call.signed !== false;
const body: Record<string, unknown> = { ...call.params, method: call.method };
// 网关级常量参数(locale / source 等)先并入,业务参数可覆盖;签名与请求体都基于这份有效参数。
const effectiveParams: Record<string, unknown> = {
...strategy.fixedParams,
...call.params,
};
const body: Record<string, unknown> = { ...effectiveParams, method: call.method };
if (needsSign) {
if (!credential.secret) {
throw new Error(
......@@ -62,7 +67,7 @@ export function createRpcDispatcher(deps: RpcDispatcherDeps) {
const signFields = await Promise.resolve(
strategy.signer.fields({
method: call.method,
params: call.params,
params: effectiveParams,
timestamp: Date.now(),
appKey: credential.appKey,
secret: credential.secret,
......
......@@ -24,10 +24,11 @@ export {
} from './senders';
export type { HostRequestConfig, HostSendFn } from './senders';
// 签名策略适配:通用工厂 + MD5 / HMAC / none 三种预设,算法可注入。
// 签名策略适配:通用工厂 + MD5 / SHA1 / HMAC / none 四种预设,算法可注入。
export {
createSigner,
createMd5Signer,
createSha1Signer,
createHmacSigner,
createNoneSigner,
} from './signers';
......@@ -41,4 +42,4 @@ export type {
} from './signers';
// 摘要 / MAC 算法 helper(供自定义 Signer 注入,例如 mp 侧引 crypto-js 实现同步 HMAC)。
export { md5, hmacSha256 } from './crypto';
export { md5, sha1, hmacSha256 } from './crypto';
import { hmacSha256, md5 } from './crypto';
import { hmacSha256, md5, sha1 } from './crypto';
import type { Signer, SignInput } from './types';
/**
......@@ -18,12 +18,14 @@ export type SignFieldNames = Partial<
export interface SignerOptions {
/** 策略 id(用于排查 / 区分算法)。 */
id?: string;
/** 摘要 / MAC 算法。内置 'md5' | 'hmac-sha256',或传函数自定义。 */
algorithm: SignAlgorithm | 'md5' | 'hmac-sha256';
/** 摘要 / MAC 算法。内置 'md5' | 'hmac-sha256' | 'sha1',或传函数自定义。 */
algorithm: SignAlgorithm | 'md5' | 'hmac-sha256' | 'sha1';
/** secret 包裹方式:both=`${secret}${body}${secret}` / prefix / suffix / none。默认 'none'。 */
secretWrap?: 'both' | 'prefix' | 'suffix' | 'none';
/** 是否把 appKey/format/method/timestamp/v 并进(除 params 外)。默认 true。 */
includeDefaults?: boolean;
/** 在 includeDefaults 为真时,剔除其中不需要的字段(mp 的 ROP/SHA1 方案不用 timestamp)。 */
excludeDefaults?: Array<'appKey' | 'format' | 'method' | 'timestamp' | 'version'>;
/** 系统字段输出名映射(默认 appKey/format/method/timestamp/v/sign)。 */
fieldNames?: SignFieldNames;
/** 值序列化(默认 glsx 风格:字符串原样、数/布尔 String、其它 JSON.stringify)。 */
......@@ -54,6 +56,7 @@ const DEFAULT_FIELD_NAMES = {
function resolveAlgorithm(algo: SignerOptions['algorithm']): SignAlgorithm {
if (algo === 'md5') return (message) => md5(message);
if (algo === 'hmac-sha256') return (message, secret) => hmacSha256(message, secret);
if (algo === 'sha1') return (message) => sha1(message);
return algo;
}
......@@ -83,6 +86,7 @@ export function createSigner(options: SignerOptions): Signer {
algorithm,
secretWrap = 'none',
includeDefaults = true,
excludeDefaults = [],
fieldNames = {},
canonicalize = DEFAULT_CANONICALIZE,
uppercase = false,
......@@ -90,6 +94,7 @@ export function createSigner(options: SignerOptions): Signer {
} = options;
const algo = resolveAlgorithm(algorithm);
const names = { ...DEFAULT_FIELD_NAMES, ...fieldNames };
const excluded = new Set(excludeDefaults);
return {
id,
......@@ -98,11 +103,11 @@ export function createSigner(options: SignerOptions): Signer {
const ignored = new Set(exclude ?? []);
const picked: Record<string, unknown> = {};
if (includeDefaults) {
picked[names.appKey] = appKey;
picked[names.format] = format;
picked[names.method] = method;
picked[names.timestamp] = timestamp;
picked[names.version] = version;
if (!excluded.has('appKey')) picked[names.appKey] = appKey;
if (!excluded.has('format')) picked[names.format] = format;
if (!excluded.has('method')) picked[names.method] = method;
if (!excluded.has('timestamp')) picked[names.timestamp] = timestamp;
if (!excluded.has('version')) picked[names.version] = version;
}
if (includeParams) {
for (const [key, value] of Object.entries(params)) {
......@@ -119,6 +124,7 @@ export function createSigner(options: SignerOptions): Signer {
const signValue = await algo(wrapSecret(body, secret, secretWrap), secret);
const out: Record<string, unknown> = {};
for (const key of [names.appKey, names.format, names.method, names.timestamp, names.version]) {
if (excluded.has(key as 'appKey' | 'format' | 'method' | 'timestamp' | 'version')) continue;
if (picked[key] !== undefined) out[key] = picked[key];
}
out[names.sign] = uppercase ? signValue.toUpperCase() : signValue;
......@@ -141,6 +147,26 @@ export function createMd5Signer(options: { id?: string; uppercase?: boolean } =
});
}
/**
* SHA1 加签预设(原生小程序 ROP 方案):secret 前后包裹、`appKey/format/method/v` 进原文 +
* params 全签(mp 会把 locale / source / sessionId 放进 params,一并参与签名)、不挂 timestamp
* (mp 用 v 而非时间戳)、输出 sign 大写。
*
* 与 web points 子应用的 MD5 网关同属一个后端家族,但**算法是 SHA1**——两套不同摘要并存,
* 故这里独立预设,不让 mp 复用 web 的 MD5 signer。原文拼接使用默认 glsx 风格(扁平参数下与
* mp 的 qs 拼接等价;仅当参数含嵌套对象 / 数组时才可能分叉,那种情况可改用 qs 或自定义 canonicalize)。
*/
export function createSha1Signer(options: { id?: string; uppercase?: boolean } = {}): Signer {
return createSigner({
id: options.id ?? 'glsx-sha1',
algorithm: 'sha1',
secretWrap: 'both',
includeDefaults: true,
excludeDefaults: ['timestamp'],
uppercase: options.uppercase ?? true,
});
}
/** 输出头名(glsk 风格:X-App-Id / X-Nonce / X-Timestamp / X-Sign)。 */
export type HmacHeaderNames = Partial<Record<'appId' | 'nonce' | 'timestamp' | 'sign', string>>;
......
......@@ -66,6 +66,11 @@ export interface GatewayStrategy {
signer: Signer;
/** 返回值映射:把该系统的响应包归一成主壳拦截器认得的形状 */
normalize(body: unknown): NormalizedEnvelope;
/**
* 该网关每次请求都固定携带、且参与签名的常量参数(如 mp 的 locale='zh_CN' / source='dj-wechat')。
* dispatcher 在签名前把它并入业务参数;业务调用时可再覆盖同名字段。
*/
fixedParams?: Record<string, unknown>;
}
/** 网关运行时凭据(通用形状;具体取值来自各域的 .env / 配置中心注入)。 */
......
import { defineConfig } from 'tsup';
/**
* api-core 是唯一需要「出 JS 产物」的包:web 子应用走源码 alias(不消费 dist),
* 但原生小程序「构建 npm」只能吃编译后的 CommonJS / 带 main/miniprogram 入口的包,
* 所以这里把纯 TS 源打成单文件 bundle。
*
* - format: ['cjs', 'esm'] —— WeChat 构建 npm 偏好 CJS(走 main / miniprogram),
* web / node 可走 ESM(走 module)。
* - dts: true —— 顺手产出类型声明,供 TS 消费者(不影响 mp 的 JS 消费)。
* - external: ['@uj/contracts'] —— HttpMethod 是 type-only 导入,运行期零耦合;
* 显式 external 让 dts 仅保留类型引用,不把 workspace 包打进 bundle。
* - 本包零运行时依赖,bundle 完全自包含。
*/
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
target: 'es2018',
sourcemap: true,
external: ['@uj/contracts'],
});
......@@ -63,4 +63,74 @@ export const app = (options = {}) =>
prettier,
);
/**
* 小程序 lane 的 ESLint(flat) 配置(原生微信小程序,非 web、非 React DOM)。
*
* 与 app() 的区别:
* - 不加载 react-hooks / react-refresh(原生 mp 用 wxml,不写 JSX 组件树);
* - 注入 wx / uni / App / Page / Component / getApp 等小程序全局;
* - 硬性禁止引用 web/host 独占运行时(platform-core / platform-sdk / vite-config / @uj/web-* / wujie),
* 因为小程序自带 wx.request,不经主壳 props.request 代理,也不跑 vite 构建。
* 小程序复用 @uj/api-core(createWxSender + 各类 Signer),但不得反向耦合 web lane。
*/
export const mp = () =>
tseslint.config(
{ ignores: ['dist/**', 'node_modules/**'] },
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.{ts,tsx,js,mjs}'],
languageOptions: {
globals: {
...globals.node,
wx: 'readonly',
uni: 'readonly',
App: 'readonly',
Page: 'readonly',
Component: 'readonly',
getApp: 'readonly',
getCurrentPages: 'readonly',
},
},
},
{
files: ['**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@uj/platform-core', '@uj/platform-core/*'],
message:
'小程序禁止引用 host 独占运行时(axios/RSA/PEM)。请改用 @uj/api-core(createWxSender)。',
},
{
group: ['@uj/platform-sdk', '@uj/platform-sdk/*'],
message: '小程序不经由主壳 props.request,请勿引用 web 子应用 SDK @uj/platform-sdk。',
},
{
group: ['@uj/vite-config', '@uj/vite-config/*'],
message: '小程序不跑 vite 构建,请勿引用 @uj/vite-config。',
},
{
group: ['@uj/web-*'],
message: '小程序不得直接依赖 web 子应用 / 主壳包(@uj/web-*)。',
},
{
group: ['wujie'],
message: '小程序无 wujie 微前端容器,请勿直接 import wujie。',
},
],
},
],
},
},
prettier,
);
export default app();
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM"],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"noEmit": true
}
}
......@@ -5,7 +5,8 @@
"type": "module",
"exports": {
"./react-app.json": "./react-app.json",
"./react-lib.json": "./react-lib.json"
"./react-lib.json": "./react-lib.json",
"./mini-program.json": "./mini-program.json"
},
"devDependencies": {
"typescript": "catalog:"
......
......@@ -72,6 +72,9 @@ catalogs:
react-router-dom:
specifier: ^7.1.5
version: 7.18.5
tsup:
specifier: ^8.3.6
version: 8.5.1
turbo:
specifier: ^2.4.0
version: 2.11.10
......@@ -135,6 +138,101 @@ importers:
specifier: 'catalog:'
version: 8.72.1(eslint@9.39.4)(typescript@5.9.3)
apps/mp/example:
dependencies:
'@uj/api-core':
specifier: workspace:*
version: link:../../../packages/api-core
devDependencies:
'@uj/contracts':
specifier: workspace:*
version: link:../../../packages/contracts
'@uj/eslint-config':
specifier: workspace:*
version: link:../../../packages/eslint-config
'@uj/typescript-config':
specifier: workspace:*
version: link:../../../packages/typescript-config
typescript:
specifier: 'catalog:'
version: 5.9.3
apps/mp/points:
dependencies:
'@uj/api-core':
specifier: workspace:*
version: link:../../../packages/api-core
devDependencies:
'@uj/contracts':
specifier: workspace:*
version: link:../../../packages/contracts
'@uj/eslint-config':
specifier: workspace:*
version: link:../../../packages/eslint-config
'@uj/typescript-config':
specifier: workspace:*
version: link:../../../packages/typescript-config
typescript:
specifier: 'catalog:'
version: 5.9.3
apps/mp/sales:
dependencies:
'@uj/api-core':
specifier: workspace:*
version: link:../../../packages/api-core
devDependencies:
'@uj/contracts':
specifier: workspace:*
version: link:../../../packages/contracts
'@uj/eslint-config':
specifier: workspace:*
version: link:../../../packages/eslint-config
'@uj/typescript-config':
specifier: workspace:*
version: link:../../../packages/typescript-config
typescript:
specifier: 'catalog:'
version: 5.9.3
apps/mp/store:
dependencies:
'@uj/api-core':
specifier: workspace:*
version: link:../../../packages/api-core
devDependencies:
'@uj/contracts':
specifier: workspace:*
version: link:../../../packages/contracts
'@uj/eslint-config':
specifier: workspace:*
version: link:../../../packages/eslint-config
'@uj/typescript-config':
specifier: workspace:*
version: link:../../../packages/typescript-config
typescript:
specifier: 'catalog:'
version: 5.9.3
apps/mp/usedcar:
dependencies:
'@uj/api-core':
specifier: workspace:*
version: link:../../../packages/api-core
devDependencies:
'@uj/contracts':
specifier: workspace:*
version: link:../../../packages/contracts
'@uj/eslint-config':
specifier: workspace:*
version: link:../../../packages/eslint-config
'@uj/typescript-config':
specifier: workspace:*
version: link:../../../packages/typescript-config
typescript:
specifier: 'catalog:'
version: 5.9.3
apps/web/shell:
dependencies:
'@ant-design/icons':
......@@ -435,6 +533,9 @@ importers:
eslint:
specifier: 'catalog:'
version: 9.39.4
tsup:
specifier: 'catalog:'
version: 8.5.1(postcss@8.5.32)(typescript@5.9.3)
typescript:
specifier: 'catalog:'
version: 5.9.3
......@@ -789,156 +890,312 @@ packages:
cpu: [ppc64]
os: [aix]
'@esbuild/aix-ppc64@0.27.7':
resolution: {integrity: sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
'@esbuild/android-arm64@0.25.12':
resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [android]
'@esbuild/android-arm64@0.27.7':
resolution: {integrity: sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==}
engines: {node: '>=18'}
cpu: [arm64]
os: [android]
'@esbuild/android-arm@0.25.12':
resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==}
engines: {node: '>=18'}
cpu: [arm]
os: [android]
'@esbuild/android-arm@0.27.7':
resolution: {integrity: sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [android]
'@esbuild/android-x64@0.25.12':
resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==}
engines: {node: '>=18'}
cpu: [x64]
os: [android]
'@esbuild/android-x64@0.27.7':
resolution: {integrity: sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==}
engines: {node: '>=18'}
cpu: [x64]
os: [android]
'@esbuild/darwin-arm64@0.25.12':
resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
'@esbuild/darwin-arm64@0.27.7':
resolution: {integrity: sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
'@esbuild/darwin-x64@0.25.12':
resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==}
engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
'@esbuild/darwin-x64@0.27.7':
resolution: {integrity: sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
'@esbuild/freebsd-arm64@0.25.12':
resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
'@esbuild/freebsd-arm64@0.27.7':
resolution: {integrity: sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==}
engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
'@esbuild/freebsd-x64@0.25.12':
resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
'@esbuild/freebsd-x64@0.27.7':
resolution: {integrity: sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
'@esbuild/linux-arm64@0.25.12':
resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==}
engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
'@esbuild/linux-arm64@0.27.7':
resolution: {integrity: sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==}
engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
'@esbuild/linux-arm@0.25.12':
resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==}
engines: {node: '>=18'}
cpu: [arm]
os: [linux]
'@esbuild/linux-arm@0.27.7':
resolution: {integrity: sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==}
engines: {node: '>=18'}
cpu: [arm]
os: [linux]
'@esbuild/linux-ia32@0.25.12':
resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==}
engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
'@esbuild/linux-ia32@0.27.7':
resolution: {integrity: sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==}
engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
'@esbuild/linux-loong64@0.25.12':
resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==}
engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
'@esbuild/linux-loong64@0.27.7':
resolution: {integrity: sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==}
engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
'@esbuild/linux-mips64el@0.25.12':
resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==}
engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
'@esbuild/linux-mips64el@0.27.7':
resolution: {integrity: sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==}
engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
'@esbuild/linux-ppc64@0.25.12':
resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
'@esbuild/linux-ppc64@0.27.7':
resolution: {integrity: sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
'@esbuild/linux-riscv64@0.25.12':
resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==}
engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
'@esbuild/linux-riscv64@0.27.7':
resolution: {integrity: sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==}
engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
'@esbuild/linux-s390x@0.25.12':
resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==}
engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
'@esbuild/linux-s390x@0.27.7':
resolution: {integrity: sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==}
engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
'@esbuild/linux-x64@0.25.12':
resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==}
engines: {node: '>=18'}
cpu: [x64]
os: [linux]
'@esbuild/linux-x64@0.27.7':
resolution: {integrity: sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==}
engines: {node: '>=18'}
cpu: [x64]
os: [linux]
'@esbuild/netbsd-arm64@0.25.12':
resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [netbsd]
'@esbuild/netbsd-arm64@0.27.7':
resolution: {integrity: sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==}
engines: {node: '>=18'}
cpu: [arm64]
os: [netbsd]
'@esbuild/netbsd-x64@0.25.12':
resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
'@esbuild/netbsd-x64@0.27.7':
resolution: {integrity: sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==}
engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
'@esbuild/openbsd-arm64@0.25.12':
resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openbsd]
'@esbuild/openbsd-arm64@0.27.7':
resolution: {integrity: sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openbsd]
'@esbuild/openbsd-x64@0.25.12':
resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==}
engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
'@esbuild/openbsd-x64@0.27.7':
resolution: {integrity: sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==}
engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
'@esbuild/openharmony-arm64@0.25.12':
resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openharmony]
'@esbuild/openharmony-arm64@0.27.7':
resolution: {integrity: sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openharmony]
'@esbuild/sunos-x64@0.25.12':
resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==}
engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
'@esbuild/sunos-x64@0.27.7':
resolution: {integrity: sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==}
engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
'@esbuild/win32-arm64@0.25.12':
resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
'@esbuild/win32-arm64@0.27.7':
resolution: {integrity: sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==}
engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
'@esbuild/win32-ia32@0.25.12':
resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==}
engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
'@esbuild/win32-ia32@0.27.7':
resolution: {integrity: sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==}
engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
'@esbuild/win32-x64@0.25.12':
resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==}
engines: {node: '>=18'}
cpu: [x64]
os: [win32]
'@esbuild/win32-x64@0.27.7':
resolution: {integrity: sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==}
engines: {node: '>=18'}
cpu: [x64]
os: [win32]
'@eslint-community/eslint-utils@4.10.1':
resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
......@@ -1612,6 +1869,9 @@ packages:
react: '>=18.0.0'
react-dom: '>=18.0.0'
any-promise@1.3.0:
resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==}
argparse@2.0.1:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
......@@ -1645,6 +1905,16 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
bundle-require@5.1.0:
resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
peerDependencies:
esbuild: '>=0.18'
cac@6.7.14:
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'}
call-bind-apply-helpers@1.0.2:
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
engines: {node: '>= 0.4'}
......@@ -1660,6 +1930,10 @@ packages:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
chokidar@4.0.3:
resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==}
engines: {node: '>= 14.16.0'}
clsx@2.1.1:
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
engines: {node: '>=6'}
......@@ -1675,12 +1949,23 @@ packages:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
commander@4.1.1:
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
engines: {node: '>= 6'}
compute-scroll-into-view@3.1.1:
resolution: {integrity: sha512-VRhuHOLoKYOy4UbilLbUzbYg93XLjv2PncJC50EuTWPA3gaja1UjBsUP/D/9/juV3vQFr6XBEzn9KCAHdUvOHw==}
concat-map@0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
confbox@0.1.8:
resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==}
consola@3.4.2:
resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==}
engines: {node: ^14.18.0 || >=16.10.0}
convert-source-map@2.0.0:
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
......@@ -1742,6 +2027,11 @@ packages:
engines: {node: '>=18'}
hasBin: true
esbuild@0.27.7:
resolution: {integrity: sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==}
engines: {node: '>=18'}
hasBin: true
escalade@3.2.0:
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
engines: {node: '>=6'}
......@@ -1839,6 +2129,9 @@ packages:
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
engines: {node: '>=10'}
fix-dts-default-cjs-exports@1.0.1:
resolution: {integrity: sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==}
flat-cache@4.0.1:
resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}
engines: {node: '>=16'}
......@@ -1945,6 +2238,10 @@ packages:
isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
joycon@3.1.1:
resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==}
engines: {node: '>=10'}
js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
......@@ -1985,6 +2282,17 @@ packages:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
lilconfig@3.1.4:
resolution: {integrity: sha512-zJZyBmQhArDRefuWTypZxwDpFDIYmrj8ypSBvwGD5P13Y95s6DjzKgu4DVdGbeQa5PDEsAOCAPNk4X+QOR006w==}
engines: {node: '>=14'}
lines-and-columns@1.2.4:
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
load-tsconfig@0.2.5:
resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
locate-path@6.0.0:
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
engines: {node: '>=10'}
......@@ -1998,6 +2306,9 @@ packages:
lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
magic-string@0.30.21:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
math-intrinsics@1.1.0:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
......@@ -2017,9 +2328,15 @@ packages:
minimatch@3.1.5:
resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==}
mlly@1.8.2:
resolution: {integrity: sha512-d+ObxMQFmbt10sretNDytwt85VrbkhhUA/JBGm1MPaWJ65Cl4wOgLaB1NYvJSZ0Ef03MMEU/0xpPMXUIQ29UfA==}
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
mz@2.7.0:
resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==}
nanoid@3.3.20:
resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
......@@ -2032,6 +2349,10 @@ packages:
resolution: {integrity: sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q==}
engines: {node: '>=18'}
object-assign@4.1.1:
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
engines: {node: '>=0.10.0'}
optionator@0.9.4:
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
engines: {node: '>= 0.8.0'}
......@@ -2056,6 +2377,9 @@ packages:
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
engines: {node: '>=8'}
pathe@2.0.3:
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
......@@ -2063,6 +2387,31 @@ packages:
resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}
engines: {node: '>=12'}
pirates@4.0.7:
resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==}
engines: {node: '>= 6'}
pkg-types@1.3.1:
resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}
postcss-load-config@6.0.1:
resolution: {integrity: sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==}
engines: {node: '>= 18'}
peerDependencies:
jiti: '>=1.21.0'
postcss: '>=8.0.9'
tsx: ^4.8.1
yaml: ^2.4.2
peerDependenciesMeta:
jiti:
optional: true
postcss:
optional: true
tsx:
optional: true
yaml:
optional: true
postcss@8.5.32:
resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==}
engines: {node: ^10 || ^12 || >=14}
......@@ -2117,10 +2466,18 @@ packages:
resolution: {integrity: sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==}
engines: {node: '>=0.10.0'}
readdirp@4.1.2:
resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==}
engines: {node: '>= 14.18.0'}
resolve-from@4.0.0:
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'}
resolve-from@5.0.0:
resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
engines: {node: '>=8'}
rollup@4.67.5:
resolution: {integrity: sha512-3Ve5VH1hacCVutdpbmu/htg4kz+JCOIWgy4Q3hjHPYGHeHeIElNHJ0LcJ3rCfIsd5G7qOl5k5mwpzGMj9kdHPA==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
......@@ -2156,6 +2513,10 @@ packages:
resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==}
engines: {node: '>=0.10.0'}
source-map@0.7.6:
resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==}
engines: {node: '>= 12'}
string-convert@0.2.1:
resolution: {integrity: sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==}
......@@ -2166,24 +2527,65 @@ packages:
stylis@4.4.0:
resolution: {integrity: sha512-5Z9ZpRzfuH6l/UAvCPAPUo3665Nk2wLaZU3x+TLHKVzIz33+sbJqbtrYoC3KD4/uVOr2Zp+L0LySezP9OHV9yA==}
sucrase@3.35.1:
resolution: {integrity: sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==}
engines: {node: '>=16 || 14 >=14.17'}
hasBin: true
supports-color@7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
thenify-all@1.6.0:
resolution: {integrity: sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==}
engines: {node: '>=0.8'}
thenify@3.3.1:
resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==}
throttle-debounce@5.0.2:
resolution: {integrity: sha512-B71/4oyj61iNH0KeCamLuE2rmKuTO5byTOSVwECM5FA7TiAiAW+UqTKZ9ERueC4qvgSttUhdmq1mXC3kJqGX7A==}
engines: {node: '>=12.22'}
tinyexec@0.3.2:
resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
tinyglobby@0.2.17:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
tree-kill@1.2.2:
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
hasBin: true
ts-api-utils@2.5.0:
resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}
engines: {node: '>=18.12'}
peerDependencies:
typescript: '>=4.8.4'
ts-interface-checker@0.1.13:
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
tsup@8.5.1:
resolution: {integrity: sha512-xtgkqwdhpKWr3tKPmCkvYmS9xnQK3m3XgxZHwSUjvfTjp7YfXe5tT3GgWi0F2N+ZSMsOeWeZFh7ZZFg5iPhing==}
engines: {node: '>=18'}
hasBin: true
peerDependencies:
'@microsoft/api-extractor': ^7.36.0
'@swc/core': ^1
postcss: ^8.4.12
typescript: '>=4.5.0'
peerDependenciesMeta:
'@microsoft/api-extractor':
optional: true
'@swc/core':
optional: true
postcss:
optional: true
typescript:
optional: true
turbo@2.11.10:
resolution: {integrity: sha512-3GJYwig8ygEI89oaOZdduJX8/aw6O9eRPYHoIt6T3FZl9hkKjiyIspufJoVgqXihPoJu8M5CSV0DlZvzfohBCw==}
hasBin: true
......@@ -2204,6 +2606,9 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
ufo@1.6.4:
resolution: {integrity: sha512-JFNbkD1Svwe0KvGi8GOeLcP4kAWQ609twvCdcHxq1oSL8svv39ZuSvajcD8B+5D0eL4+s1Is2D/O6KN3qcTeRA==}
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
......@@ -2464,81 +2869,159 @@ snapshots:
'@esbuild/aix-ppc64@0.25.12':
optional: true
'@esbuild/aix-ppc64@0.27.7':
optional: true
'@esbuild/android-arm64@0.25.12':
optional: true
'@esbuild/android-arm64@0.27.7':
optional: true
'@esbuild/android-arm@0.25.12':
optional: true
'@esbuild/android-arm@0.27.7':
optional: true
'@esbuild/android-x64@0.25.12':
optional: true
'@esbuild/android-x64@0.27.7':
optional: true
'@esbuild/darwin-arm64@0.25.12':
optional: true
'@esbuild/darwin-arm64@0.27.7':
optional: true
'@esbuild/darwin-x64@0.25.12':
optional: true
'@esbuild/darwin-x64@0.27.7':
optional: true
'@esbuild/freebsd-arm64@0.25.12':
optional: true
'@esbuild/freebsd-arm64@0.27.7':
optional: true
'@esbuild/freebsd-x64@0.25.12':
optional: true
'@esbuild/freebsd-x64@0.27.7':
optional: true
'@esbuild/linux-arm64@0.25.12':
optional: true
'@esbuild/linux-arm64@0.27.7':
optional: true
'@esbuild/linux-arm@0.25.12':
optional: true
'@esbuild/linux-arm@0.27.7':
optional: true
'@esbuild/linux-ia32@0.25.12':
optional: true
'@esbuild/linux-ia32@0.27.7':
optional: true
'@esbuild/linux-loong64@0.25.12':
optional: true
'@esbuild/linux-loong64@0.27.7':
optional: true
'@esbuild/linux-mips64el@0.25.12':
optional: true
'@esbuild/linux-mips64el@0.27.7':
optional: true
'@esbuild/linux-ppc64@0.25.12':
optional: true
'@esbuild/linux-ppc64@0.27.7':
optional: true
'@esbuild/linux-riscv64@0.25.12':
optional: true
'@esbuild/linux-riscv64@0.27.7':
optional: true
'@esbuild/linux-s390x@0.25.12':
optional: true
'@esbuild/linux-s390x@0.27.7':
optional: true
'@esbuild/linux-x64@0.25.12':
optional: true
'@esbuild/linux-x64@0.27.7':
optional: true
'@esbuild/netbsd-arm64@0.25.12':
optional: true
'@esbuild/netbsd-arm64@0.27.7':
optional: true
'@esbuild/netbsd-x64@0.25.12':
optional: true
'@esbuild/netbsd-x64@0.27.7':
optional: true
'@esbuild/openbsd-arm64@0.25.12':
optional: true
'@esbuild/openbsd-arm64@0.27.7':
optional: true
'@esbuild/openbsd-x64@0.25.12':
optional: true
'@esbuild/openbsd-x64@0.27.7':
optional: true
'@esbuild/openharmony-arm64@0.25.12':
optional: true
'@esbuild/openharmony-arm64@0.27.7':
optional: true
'@esbuild/sunos-x64@0.25.12':
optional: true
'@esbuild/sunos-x64@0.27.7':
optional: true
'@esbuild/win32-arm64@0.25.12':
optional: true
'@esbuild/win32-arm64@0.27.7':
optional: true
'@esbuild/win32-ia32@0.25.12':
optional: true
'@esbuild/win32-ia32@0.27.7':
optional: true
'@esbuild/win32-x64@0.25.12':
optional: true
'@esbuild/win32-x64@0.27.7':
optional: true
'@eslint-community/eslint-utils@4.10.1(eslint@9.39.4)':
dependencies:
eslint: 9.39.4
......@@ -3299,6 +3782,8 @@ snapshots:
- luxon
- moment
any-promise@1.3.0: {}
argparse@2.0.1: {}
asynckit@0.4.0: {}
......@@ -3336,6 +3821,13 @@ snapshots:
node-releases: 2.0.63
update-browserslist-db: 1.3.4(browserslist@4.29.5)
bundle-require@5.1.0(esbuild@0.27.7):
dependencies:
esbuild: 0.27.7
load-tsconfig: 0.2.5
cac@6.7.14: {}
call-bind-apply-helpers@1.0.2:
dependencies:
es-errors: 1.3.0
......@@ -3350,6 +3842,10 @@ snapshots:
ansi-styles: 4.3.0
supports-color: 7.2.0
chokidar@4.0.3:
dependencies:
readdirp: 4.1.2
clsx@2.1.1: {}
color-convert@2.0.1:
......@@ -3362,10 +3858,16 @@ snapshots:
dependencies:
delayed-stream: 1.0.0
commander@4.1.1: {}
compute-scroll-into-view@3.1.1: {}
concat-map@0.0.1: {}
confbox@0.1.8: {}
consola@3.4.2: {}
convert-source-map@2.0.0: {}
cookie@1.1.1: {}
......@@ -3440,6 +3942,35 @@ snapshots:
'@esbuild/win32-ia32': 0.25.12
'@esbuild/win32-x64': 0.25.12
esbuild@0.27.7:
optionalDependencies:
'@esbuild/aix-ppc64': 0.27.7
'@esbuild/android-arm': 0.27.7
'@esbuild/android-arm64': 0.27.7
'@esbuild/android-x64': 0.27.7
'@esbuild/darwin-arm64': 0.27.7
'@esbuild/darwin-x64': 0.27.7
'@esbuild/freebsd-arm64': 0.27.7
'@esbuild/freebsd-x64': 0.27.7
'@esbuild/linux-arm': 0.27.7
'@esbuild/linux-arm64': 0.27.7
'@esbuild/linux-ia32': 0.27.7
'@esbuild/linux-loong64': 0.27.7
'@esbuild/linux-mips64el': 0.27.7
'@esbuild/linux-ppc64': 0.27.7
'@esbuild/linux-riscv64': 0.27.7
'@esbuild/linux-s390x': 0.27.7
'@esbuild/linux-x64': 0.27.7
'@esbuild/netbsd-arm64': 0.27.7
'@esbuild/netbsd-x64': 0.27.7
'@esbuild/openbsd-arm64': 0.27.7
'@esbuild/openbsd-x64': 0.27.7
'@esbuild/openharmony-arm64': 0.27.7
'@esbuild/sunos-x64': 0.27.7
'@esbuild/win32-arm64': 0.27.7
'@esbuild/win32-ia32': 0.27.7
'@esbuild/win32-x64': 0.27.7
escalade@3.2.0: {}
escape-string-regexp@4.0.0: {}
......@@ -3543,6 +4074,12 @@ snapshots:
locate-path: 6.0.0
path-exists: 4.0.0
fix-dts-default-cjs-exports@1.0.1:
dependencies:
magic-string: 0.30.21
mlly: 1.8.2
rollup: 4.67.5
flat-cache@4.0.1:
dependencies:
flatted: 3.4.4
......@@ -3635,6 +4172,8 @@ snapshots:
isexe@2.0.0: {}
joycon@3.1.1: {}
js-tokens@4.0.0: {}
js-yaml@4.3.2:
......@@ -3666,6 +4205,12 @@ snapshots:
prelude-ls: 1.2.1
type-check: 0.4.0
lilconfig@3.1.4: {}
lines-and-columns@1.2.4: {}
load-tsconfig@0.2.5: {}
locate-path@6.0.0:
dependencies:
p-locate: 5.0.0
......@@ -3678,6 +4223,10 @@ snapshots:
dependencies:
yallist: 3.1.1
magic-string@0.30.21:
dependencies:
'@jridgewell/sourcemap-codec': 1.6.0
math-intrinsics@1.1.0: {}
mime-db@1.52.0: {}
......@@ -3694,14 +4243,29 @@ snapshots:
dependencies:
brace-expansion: 1.1.21
mlly@1.8.2:
dependencies:
acorn: 8.19.0
pathe: 2.0.3
pkg-types: 1.3.1
ufo: 1.6.4
ms@2.1.3: {}
mz@2.7.0:
dependencies:
any-promise: 1.3.0
object-assign: 4.1.1
thenify-all: 1.6.0
nanoid@3.3.20: {}
natural-compare@1.4.0: {}
node-releases@2.0.63: {}
object-assign@4.1.1: {}
optionator@0.9.4:
dependencies:
deep-is: 0.1.4
......@@ -3727,10 +4291,26 @@ snapshots:
path-key@3.1.1: {}
pathe@2.0.3: {}
picocolors@1.1.1: {}
picomatch@4.0.7: {}
pirates@4.0.7: {}
pkg-types@1.3.1:
dependencies:
confbox: 0.1.8
mlly: 1.8.2
pathe: 2.0.3
postcss-load-config@6.0.1(postcss@8.5.32):
dependencies:
lilconfig: 3.1.4
optionalDependencies:
postcss: 8.5.32
postcss@8.5.32:
dependencies:
nanoid: 3.3.20
......@@ -3770,8 +4350,12 @@ snapshots:
react@19.3.1: {}
readdirp@4.1.2: {}
resolve-from@4.0.0: {}
resolve-from@5.0.0: {}
rollup@4.67.5:
dependencies:
'@types/estree': 1.0.10
......@@ -3824,27 +4408,81 @@ snapshots:
source-map-js@1.2.2: {}
source-map@0.7.6: {}
string-convert@0.2.1: {}
strip-json-comments@3.1.1: {}
stylis@4.4.0: {}
sucrase@3.35.1:
dependencies:
'@jridgewell/gen-mapping': 0.3.13
commander: 4.1.1
lines-and-columns: 1.2.4
mz: 2.7.0
pirates: 4.0.7
tinyglobby: 0.2.17
ts-interface-checker: 0.1.13
supports-color@7.2.0:
dependencies:
has-flag: 4.0.0
thenify-all@1.6.0:
dependencies:
thenify: 3.3.1
thenify@3.3.1:
dependencies:
any-promise: 1.3.0
throttle-debounce@5.0.2: {}
tinyexec@0.3.2: {}
tinyglobby@0.2.17:
dependencies:
fdir: 6.5.0(picomatch@4.0.7)
picomatch: 4.0.7
tree-kill@1.2.2: {}
ts-api-utils@2.5.0(typescript@5.9.3):
dependencies:
typescript: 5.9.3
ts-interface-checker@0.1.13: {}
tsup@8.5.1(postcss@8.5.32)(typescript@5.9.3):
dependencies:
bundle-require: 5.1.0(esbuild@0.27.7)
cac: 6.7.14
chokidar: 4.0.3
consola: 3.4.2
debug: 4.4.3
esbuild: 0.27.7
fix-dts-default-cjs-exports: 1.0.1
joycon: 3.1.1
picocolors: 1.1.1
postcss-load-config: 6.0.1(postcss@8.5.32)
resolve-from: 5.0.0
rollup: 4.67.5
source-map: 0.7.6
sucrase: 3.35.1
tinyexec: 0.3.2
tinyglobby: 0.2.17
tree-kill: 1.2.2
optionalDependencies:
postcss: 8.5.32
typescript: 5.9.3
transitivePeerDependencies:
- jiti
- supports-color
- tsx
- yaml
turbo@2.11.10:
optionalDependencies:
'@turbo/darwin-64': 2.11.10
......@@ -3871,6 +4509,8 @@ snapshots:
typescript@5.9.3: {}
ufo@1.6.4: {}
undici-types@6.21.0: {}
update-browserslist-db@1.3.4(browserslist@4.29.5):
......
......@@ -63,6 +63,9 @@ catalogs:
# vitest 2.x 只依赖 vite ^5,会和 vite 6 装出两份 vite,
# 导致插件拿到 vite 5 的 Plugin 类型;3.x 可复用同一份 vite(genesis 踩过一次)。
vitest: ^3.2.4
# 仅 api-core 用的打包器:把 TS 源打成单文件 ESM+CJS+ d.ts,
# 供原生小程序「构建 npm」消费(web 子应用仍走源码 alias,不受影响)。
tsup: ^8.3.6
# --- Lint / 格式 ---
eslint: ^9.19.0
......
......@@ -5,16 +5,22 @@ import { fileURLToPath } from 'node:url';
/**
* 架构边界闸门(CI 必跑)。
*
* ESLint 只能看 import 语句,看不住配置与全局变量;这里从磁盘事实复查四条硬约束:
* 1. 子应用不得引用 @uj/platform-core(host 独占运行时)
* 2. 子应用不得出现 PEM 虚拟模块 / 签名密钥 env(请求层不下放)
* 3. 子应用 vite.config 不得挂 /api 代理或读密钥
* 4. 子应用不得直接 import wujie core(应只用 window.$wujie)
* 本仓库有两条独立技术栈,护栏分别设置:
* - web lane(apps/web):主壳 + wujie 微前端子应用,受下方「web 子应用」四条硬约束;
* - mp lane(apps/mp):原生小程序,自带 wx.request,不经主壳代理,受「小程序」护栏约束。
*
* 这四条任何一条破了,症状都不是编译错误,而是「登录 10011」「两份签名状态」
* ESLint 只能看 import 语句,看不住配置与全局变量;这里从磁盘事实复查硬约束:
* 【web 子应用】不得:引用 @uj/platform-core(host 独占运行时)/ 出现 PEM 虚拟模块或签名密钥
* env(请求层不下放)/ vite.config 挂 /api 代理或读密钥 / 直接 import wujie core /
* 运行时 import axios / 跨子应用依赖 @uj/web-*。
* 【小程序】不得:反向引用 web/host 独占运行时(platform-core / platform-sdk / vite-config /
* @uj/web-* / wujie)—— 小程序复用 @uj/api-core(createWxSender),但不耦合 web lane。
*
* 这些约束任何一条破了,症状都不是编译错误,而是「登录 10011」「两份签名状态」
* 「两份 Context」这类运行时故障,必须静态拦住。
*/
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
// web lane:主壳 + wujie 子应用。小程序 lane 在 apps/mp,单独处理,不混入本扫描根。
const SUBAPPS_ROOT = path.join(ROOT, 'apps', 'web', 'subapps');
const errors = [];
const warnings = [];
......@@ -96,6 +102,59 @@ for (const appDir of subappDirs) {
}
}
// ---------------------------------------------------------------------------
// 小程序 lane(apps/mp):与 web 子应用是两条独立技术栈,分别设护栏。
// web 子应用的「请求层不下放」规则不适用于 mp(mp 自带 wx.request,不经主壳代理),
// 但 mp 也不得反向耦合 web/host 独占运行时(axios/RSA/PEM/vite/wujie/主壳子应用包)。
// 这条护栏保证「mp 引入 @uj/api-core 复用请求/签名适配」不会退化成「mp 偷偷引 web 运行时」。
// ---------------------------------------------------------------------------
const MP_ROOT = path.join(ROOT, 'apps', 'mp');
const MP_RULES = [
{
id: 'host-runtime',
re: /@uj\/platform-core/,
message: '小程序引用了 host 独占运行时 @uj/platform-core;请改用 @uj/api-core(createWxSender)。',
},
{
id: 'web-sdk',
re: /@uj\/platform-sdk/,
message: '小程序不经由主壳 props.request,请勿引用 web 子应用 SDK @uj/platform-sdk。',
},
{
id: 'web-build',
re: /@uj\/vite-config/,
message: '小程序不跑 vite 构建,请勿引用 @uj/vite-config。',
},
{
id: 'cross-lane',
re: /@uj\/web-/,
message: '小程序不得直接依赖 web 子应用 / 主壳包(@uj/web-*)。',
},
{
id: 'wujie-core',
re: /from\s+['"]wujie['"]/,
message: '小程序无 wujie 微前端容器,请勿直接 import wujie。',
},
];
if (fs.existsSync(MP_ROOT)) {
const mpDirs = fs
.readdirSync(MP_ROOT, { withFileTypes: true })
.filter((e) => e.isDirectory())
.map((e) => path.join(MP_ROOT, e.name));
for (const appDir of mpDirs) {
const files = collect(path.join(appDir, 'src'), ['.ts', '.tsx']);
for (const file of files) {
const text = fs.readFileSync(file, 'utf8');
const rel = path.relative(ROOT, file).split(path.sep).join('/');
for (const rule of MP_RULES) {
if (rule.re.test(text)) errors.push(`[${rule.id}] ${rel}: ${rule.message}`);
}
}
}
console.log(`[boundaries] 扫描 ${mpDirs.length} 个小程序`);
}
// 反向检查:只有 shell 允许读 PEM 虚拟模块。
const shellConfig = path.join(ROOT, 'apps/web/shell/vite.config.ts');
if (fs.existsSync(shellConfig)) {
......
#!/usr/bin/env node
/**
* mp lane 名字真源的消费端。
*
* 唯一真源:apps/mp/manifest.json(定义所有原生小程序 lane 的 dir / displayName / appId / backend)。
* 本脚本依据 manifest 为每个小程序生成 / 同步脚手架(package.json / tsconfig.json / eslint.config.js / src/index.ts)。
*
* 用法:
* node scripts/sync-mp-apps.mjs # 新增缺失的 lane、同步包名,不删除多余目录(仅警告)
* node scripts/sync-mp-apps.mjs --prune # 额外删除不在 manifest 中的 apps/mp 子目录(example / manifest 除外)
*
* 改名流程:改 manifest 的 dir -> 跑本脚本(旧目录会告警)-> 加 --prune 清掉旧目录。
*/
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, rmSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, '..');
const MP_ROOT = join(ROOT, 'apps', 'mp');
const manifestPath = join(MP_ROOT, 'manifest.json');
const PRUNE = process.argv.includes('--prune');
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
if (!Array.isArray(manifest.apps)) {
console.error('[错误] manifest.json 缺少 apps 数组');
process.exit(1);
}
const apps = manifest.apps;
const wantedDirs = new Set(apps.map((a) => a.dir));
function templatePackageJson(dir) {
return {
name: `@uj/mp-${dir}`,
version: '0.0.0',
private: true,
type: 'module',
scripts: { typecheck: 'tsc --noEmit', lint: 'eslint .' },
dependencies: { '@uj/api-core': 'workspace:*' },
devDependencies: {
'@uj/contracts': 'workspace:*',
'@uj/eslint-config': 'workspace:*',
'@uj/typescript-config': 'workspace:*',
typescript: 'catalog:',
},
};
}
function templateTsconfig() {
return {
extends: '../../../packages/typescript-config/mini-program.json',
compilerOptions: {
baseUrl: '.',
paths: {
'@uj/api-core': ['../../../packages/api-core/src/index.ts'],
'@uj/contracts': ['../../../packages/contracts/src/index.ts'],
},
},
include: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.d.ts'],
};
}
function templateEslint() {
return [
"import { mp } from '@uj/eslint-config';",
'',
'// 小程序 lane:禁止引用 web/host 独占运行时(见 @uj/eslint-config 的 mp 预设)。',
'export default mp();',
'',
].join('\n');
}
function templateIndexTs(dir, displayName) {
const gatewayId = `${dir}-backend`;
const signerId = `${dir}-sha1`;
// dir 可能含连字符(如 uj-points),不能直接当 JS 标识符用。
// 转 camelCase 供 const / 函数名使用;id 字符串仍保留原 dir(带连字符,合法)。
const camelDir = dir.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
const capCamel = camelDir.charAt(0).toUpperCase() + camelDir.slice(1);
const L = [];
L.push("import {");
L.push(" createRpcDispatcher,");
L.push(" createWxSender,");
L.push(" createSha1Signer,");
L.push(" registerGateway,");
L.push(" type GatewayStrategy,");
L.push(" type GatewayCredential,");
L.push(" type NormalizedEnvelope,");
L.push(" type RpcCall,");
L.push("} from '@uj/api-core';");
L.push('');
L.push('/**');
L.push(` * ${displayName}(apps/mp lane 脚手架,由 scripts/sync-mp-apps.mjs 依据 apps/mp/manifest.json 生成)。`);
L.push(' *');
L.push(' * 与 web 子应用共用同一套 @uj/api-core 契约,差异只在 transport 一个参数:');
L.push(' * - web 子应用:createHostSender(requestViaHost()) 把请求交回主壳 axios;');
L.push(' * - 原生小程序:createWxSender() 直接用 wx.request(不经由主壳,不破坏请求层边界)。');
L.push(' *');
L.push(' * 签名用 api-core 内置 SHA1 预设:原生小程序 RPC 网关走 SHA1(secret 前后包裹、');
L.push(' * appKey/format/method/v + params 全签),与 web points 子应用的 MD5 网关是两套不同');
L.push(' * 算法——同一后端家族、不同端用不同摘要,故 mp 走 createSha1Signer。');
L.push(' *');
L.push(' * 注意:本文件在微信运行时被 import 时才会执行 createWxSender();');
L.push(' * 类型检查 / lint 不会执行这段代码,因此无需担心 Node 环境下 wx 缺失。');
L.push(' */');
L.push(`export const ${camelDir}Gateway: GatewayStrategy = {`);
L.push(` id: '${gatewayId}',`);
L.push(` // 落点随接入项目而变:scrm 系为 rop-scrm-<dir>/router,dj 系为 rop-dj-<dir>/router。`);
L.push(` router: 'rop-scrm-${dir}/router',`);
L.push(" tokenHeader: 'token',");
L.push(` // 原生小程序签名:SHA1 预设;换算法(HMAC / MD5)只改这一行。`);
L.push(` signer: createSha1Signer({ id: '${signerId}' }),`);
L.push(" // 网关级常量参数:并进签名与请求体(会话态 sessionId 等业务参数在调用时再传)。");
L.push(" fixedParams: { locale: 'zh_CN', source: 'dj-wechat' },");
L.push(' // 把对方信封归一成主壳拦截器认得的 { data } / { code, message }。');
L.push(' normalize(body: unknown): NormalizedEnvelope {');
L.push(" if (!body || typeof body !== 'object') return { data: body };");
L.push(' const env = body as Record<string, unknown>;');
L.push(" const code = env['code'];");
L.push(" if (String(code) === '0') return { data: env['data'] };");
L.push(' return {');
L.push(' code: Number(code) || 500,');
L.push(" message: typeof env['message'] === 'string' ? env['message'] : '请求失败',");
L.push(' };');
L.push(' },');
L.push('};');
L.push(`registerGateway(${camelDir}Gateway);`);
L.push('');
L.push('/** 运行时凭据:真实项目从配置中心 / 编译变量注入,本层不留密钥字面量。 */');
L.push('const credentials = new Map<string, GatewayCredential>([');
L.push(` ['${gatewayId}', { origin: 'https://${dir}.example.com', appKey: 'app-key', secret: 'app-secret', version: '1.0', format: 'json' }],`);
L.push(']);');
L.push('');
L.push('const dispatch = createRpcDispatcher({');
L.push(' // 原生小程序 transport:wx.request(非 wujie 环境,可自行发请求)。');
L.push(' sender: createWxSender(),');
L.push(' resolveCredential: (id) => {');
L.push(' const c = credentials.get(id);');
L.push(' if (!c) throw new Error(`未配置网关 ${id} 的凭据`);');
L.push(' return c;');
L.push(' },');
L.push(" resolveToken: () => '',");
L.push(' timeout: 30000,');
L.push('});');
L.push('');
L.push('/** 业务侧调用:只说方法名和参数,不关心对方怎么加签 / 怎么发。 */');
L.push(`export function call${capCamel}<T = unknown>(method: string, params: Record<string, unknown>): Promise<T> {`);
L.push(` const call: RpcCall = { gateway: '${gatewayId}', method, params, signed: true };`);
L.push(' return dispatch(call) as Promise<T>;');
L.push('}');
L.push('');
return L.join('\n');
}
let created = 0;
for (const app of apps) {
const { dir, displayName } = app;
if (!dir || !/^[a-z][a-z0-9-]*$/.test(dir)) {
console.error(`[错误] 非法 dir: ${dir}(需小写字母开头,含小写字母/数字/连字符)`);
process.exit(1);
}
const appDir = join(MP_ROOT, dir);
const srcDir = join(appDir, 'src');
mkdirSync(srcDir, { recursive: true });
const pkgPath = join(appDir, 'package.json');
const expectedName = `@uj/mp-${dir}`;
if (existsSync(pkgPath)) {
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
if (pkg.name !== expectedName) {
pkg.name = expectedName;
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
console.log(`同步 name -> ${expectedName} (${dir})`);
}
} else {
writeFileSync(pkgPath, `${JSON.stringify(templatePackageJson(dir), null, 2)}\n`);
console.log(`新建 ${dir}/package.json`);
}
const tsconfigPath = join(appDir, 'tsconfig.json');
if (!existsSync(tsconfigPath)) {
writeFileSync(tsconfigPath, `${JSON.stringify(templateTsconfig(), null, 2)}\n`);
}
const eslintPath = join(appDir, 'eslint.config.js');
if (!existsSync(eslintPath)) {
writeFileSync(eslintPath, templateEslint());
}
const indexPath = join(srcDir, 'index.ts');
if (!existsSync(indexPath)) {
writeFileSync(indexPath, templateIndexTs(dir, displayName));
created++;
console.log(`新建 ${dir}/src/index.ts (${displayName})`);
}
}
// 反向校验:磁盘上不在 manifest 的 apps/mp 子目录(排除 example / manifest / 脚本 / node_modules),提示或清理。
const reserved = new Set(['example', 'node_modules']);
const entries = readdirSync(MP_ROOT, { withFileTypes: true });
const stale = entries
.filter((e) => e.isDirectory() && !wantedDirs.has(e.name) && !reserved.has(e.name))
.map((e) => e.name);
for (const s of stale) {
const p = join(MP_ROOT, s);
if (PRUNE) {
rmSync(p, { recursive: true, force: true });
console.log(`[prune] 删除不在 manifest 的 lane: ${s}`);
} else {
console.warn(`[警告] 磁盘存在不在 manifest 的 lane: ${s}(如需删除请加 --prune 重跑)`);
}
}
console.log(`\n完成:manifest 含 ${apps.length} 个小程序,本次新建 ${created} 个 index.ts 脚手架。`);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!