@tbox.cn/app-sdk-client 0.21.4 → 1.0.0-alpha.1
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/dist/client/index.d.ts +53 -4
- package/dist/client/index.js +1 -1
- package/package.json +3 -3
package/dist/client/index.d.ts
CHANGED
|
@@ -400,14 +400,33 @@ type AlipayNavigation = {
|
|
|
400
400
|
*/
|
|
401
401
|
declare function resolveAlipayNavigation(url: string, hostMiniAppId?: string): AlipayNavigation | undefined;
|
|
402
402
|
|
|
403
|
+
type QueryValue = string | number | boolean | null | undefined;
|
|
404
|
+
type Query = Record<string, QueryValue | QueryValue[]>;
|
|
403
405
|
interface RequestOptions {
|
|
404
|
-
|
|
406
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
407
|
+
query?: Query;
|
|
408
|
+
body?: unknown;
|
|
405
409
|
headers?: Record<string, string>;
|
|
406
|
-
/** 取消信号 */
|
|
407
410
|
signal?: AbortSignal;
|
|
408
|
-
|
|
411
|
+
responseType?: 'json' | 'text' | 'response';
|
|
412
|
+
auth?: boolean;
|
|
413
|
+
timeoutMs?: number;
|
|
409
414
|
cache?: RequestCache;
|
|
410
415
|
}
|
|
416
|
+
declare class RequestError extends Error {
|
|
417
|
+
readonly status: number;
|
|
418
|
+
readonly code: string;
|
|
419
|
+
readonly body: unknown;
|
|
420
|
+
constructor(status: number, code: string, message: string, body?: unknown);
|
|
421
|
+
}
|
|
422
|
+
type TokenGetter = () => string | null;
|
|
423
|
+
type RefreshHandler = () => Promise<unknown>;
|
|
424
|
+
declare function configureRequestAuth(options: {
|
|
425
|
+
getToken?: TokenGetter;
|
|
426
|
+
refresh?: RefreshHandler;
|
|
427
|
+
}): void;
|
|
428
|
+
declare function request<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
|
|
429
|
+
|
|
411
430
|
interface HttpResult<T> {
|
|
412
431
|
status: number;
|
|
413
432
|
data: T;
|
|
@@ -445,6 +464,36 @@ declare const httpGet: <T = any>(path: string, opts?: RequestOptions) => Promise
|
|
|
445
464
|
declare const httpPost: <T = any>(path: string, body?: unknown, opts?: RequestOptions) => Promise<HttpResult<T>>;
|
|
446
465
|
declare const httpPostBinary: <T = any>(path: string, body: Blob, opts?: RequestOptions) => Promise<HttpResult<T>>;
|
|
447
466
|
|
|
467
|
+
interface UseRequestOptions {
|
|
468
|
+
immediate?: boolean;
|
|
469
|
+
}
|
|
470
|
+
interface UseRequestResult<T, Input> {
|
|
471
|
+
data: T | undefined;
|
|
472
|
+
error: Error | undefined;
|
|
473
|
+
loading: boolean;
|
|
474
|
+
run: (input: Input) => Promise<T | undefined>;
|
|
475
|
+
refresh: () => Promise<T | undefined>;
|
|
476
|
+
}
|
|
477
|
+
declare function useRequest<T, Input = void>(fn: (input: Input) => Promise<T>, deps?: readonly unknown[], options?: UseRequestOptions): UseRequestResult<T, Input>;
|
|
478
|
+
|
|
479
|
+
interface AppClientModule {
|
|
480
|
+
cards?: Record<string, CardComponent>;
|
|
481
|
+
register: (ctx: ClientContext) => void | Promise<void>;
|
|
482
|
+
}
|
|
483
|
+
declare function getClientContext(): ClientContext;
|
|
484
|
+
declare function registerClientCards(cards: Record<string, CardComponent> | undefined): void;
|
|
485
|
+
/**
|
|
486
|
+
* 注册全部客户端模块。promise 锁而非布尔锁:并发页面 entry 必须等同一次完成,
|
|
487
|
+
* 失败时释放锁允许下一轮(HMR/重试)重新注册。
|
|
488
|
+
*/
|
|
489
|
+
declare function registerClientModules(modules: readonly AppClientModule[]): Promise<void>;
|
|
490
|
+
declare function getRegisteredClientCards(): Record<string, CardComponent>;
|
|
491
|
+
|
|
492
|
+
interface PageMeta {
|
|
493
|
+
title: string;
|
|
494
|
+
meta?: Record<string, unknown>;
|
|
495
|
+
}
|
|
496
|
+
|
|
448
497
|
declare global {
|
|
449
498
|
interface Window {
|
|
450
499
|
my?: AlipayWebViewMy;
|
|
@@ -462,4 +511,4 @@ interface AlipayWebViewMy {
|
|
|
462
511
|
*/
|
|
463
512
|
declare function ensureAlipayJSSDK(): Promise<AlipayWebViewMy | null>;
|
|
464
513
|
|
|
465
|
-
export { type AlipayNavigation, type AlipayWebViewMy, BRIDGE_NAME, BRIDGE_VERSION, type BridgeMediaFile, type BridgeReceipt, type BridgeRequest, CardCarousel, type CardComponentWithFlag, CardFrame, CardRenderer, ClientCardRegistry, type ClientContext, type ClientLogTransport, type ClientModule, ClientSlotRegistry, type CreateServiceOptions, ErrorBoundary, type HttpResult, type JsapiMode, type LoginGateReceipt, MY_ACTION, MY_CALL_ACTION, type PlateKeyboardOptions, type PlateKeyboardResult, type RequestOptions, type RuntimeContainer, type ServiceClient, StatusPill, type StatusPillTone, TBOX_ACTION, ValueText, callCapability, callJsapi, chooseImage, chooseVideo, closePlateKeyboard, configureAuthErrorHandler, configureAuthToken, configureRuntime, createClientContext, createClientLogger, createService, defaultService, ensureAlipayJSSDK, getApiBaseUrl, getApiOrigin, getAuthCode, getContainer, getLocation, getLoginState, getQueryParam, getRuntimeQuery, getWsUrl, hasAlipayBridge, httpGet, httpPost, httpPostBinary, installGlobalErrorReporting, isBridgeReceipt, isInAlipayShell, markSelfRendering, navigateToAlipayPage, openPlateKeyboard, requestPayment, resolveAlipayNavigation, setClientLogTransport, setClientRunContext };
|
|
514
|
+
export { type AlipayNavigation, type AlipayWebViewMy, type AppClientModule, BRIDGE_NAME, BRIDGE_VERSION, type BridgeMediaFile, type BridgeReceipt, type BridgeRequest, CardCarousel, type CardComponentWithFlag, CardFrame, CardRenderer, ClientCardRegistry, type ClientContext, type ClientLogTransport, type ClientModule, ClientSlotRegistry, type CreateServiceOptions, ErrorBoundary, type HttpResult, type JsapiMode, type LoginGateReceipt, MY_ACTION, MY_CALL_ACTION, type PageMeta, type PlateKeyboardOptions, type PlateKeyboardResult, type Query, type QueryValue, RequestError, type RequestOptions, type RuntimeContainer, type ServiceClient, StatusPill, type StatusPillTone, TBOX_ACTION, type UseRequestOptions, type UseRequestResult, ValueText, callCapability, callJsapi, chooseImage, chooseVideo, closePlateKeyboard, configureAuthErrorHandler, configureAuthToken, configureRequestAuth, configureRuntime, createClientContext, createClientLogger, createService, defaultService, ensureAlipayJSSDK, getApiBaseUrl, getApiOrigin, getAuthCode, getClientContext, getContainer, getLocation, getLoginState, getQueryParam, getRegisteredClientCards, getRuntimeQuery, getWsUrl, hasAlipayBridge, httpGet, httpPost, httpPostBinary, installGlobalErrorReporting, isBridgeReceipt, isInAlipayShell, markSelfRendering, navigateToAlipayPage, openPlateKeyboard, registerClientCards, registerClientModules, request, requestPayment, resolveAlipayNavigation, setClientLogTransport, setClientRunContext, useRequest };
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger as Ht}from"@tbox.cn/app-sdk-core";import{createCoreLogger as be,resolveLevel as X,setLogContextProvider as Ce}from"@tbox.cn/app-sdk-core";var N=null;Ce(()=>N??void 0);function he(e){N=e?{requestId:e.runId,conversationId:e.conversationId}:null}function ve(){try{if(typeof localStorage<"u")return X(localStorage.getItem("tbox:logLevel")??void 0,"info")}catch{}try{if(typeof location<"u"){let e=new URLSearchParams(location.search).get("logLevel");if(e)return X(e,"info")}}catch{}return"info"}function g(e){return be({tag:e,getLevel:ve,getContext:()=>N??void 0})}var Y;function we(e){Y=e}function Re(e){if(typeof window>"u"||typeof window.addEventListener!="function")return()=>{};let t=e??g("GLOBAL"),r=new Map,o=1e4,s=a=>{let n=Date.now();for(let[u,l]of r)n-l>=o&&r.delete(u);r.has(a)||(r.set(a,n),t.error(a),Y?.send("error",a))},i=a=>{s(`uncaught: ${a.message} @ ${a.filename}:${a.lineno}`)},d=a=>{let n=a.reason instanceof Error?a.reason.message:String(a.reason);s(`unhandledrejection: ${n}`)};return window.addEventListener("error",i),window.addEventListener("unhandledrejection",d),()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",d)}}import{Component as Te}from"react";var Se=g("ErrorBoundary"),h=class extends Te{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){Se.error("render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};import{jsx as m,jsxs as Ie}from"react/jsx-runtime";var R={info:{bg:"rgba(22,119,255,0.08)",color:"#1677ff"},warning:{bg:"rgba(250,140,22,0.10)",color:"#d46b08"},error:{bg:"rgba(255,77,79,0.08)",color:"#ff4d4f"}};function Ae({notices:e}){return e.length?m("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8},children:e.map(t=>m("div",{style:{fontSize:12,lineHeight:"18px",padding:"4px 10px",borderRadius:8,background:R[t.level]?.bg??R.info.bg,color:R[t.level]?.color??R.info.color},children:t.message},`${t.code}:${t.message}`))}):null}function Pe({card:e,registry:t,onAction:r}){let o=e.status!=="error"?t[e.cardType]:void 0,s=e.status==="error"||!o,i=o?.selfRendersActions===!0,d=!e.isHistory&&!i&&e.actions?.length?e.actions:[],a=typeof e.expiresAt=="number"&&Date.now()>=e.expiresAt;return Ie("div",{className:`tbox-card${s?" tbox-card--fallback":""}${a?" tbox-card--stale":""}`,style:a?{opacity:.55,filter:"grayscale(1)"}:void 0,children:[m(Ae,{notices:e.notices??[]}),e.status==="error"?`卡片渲染失败${e.error?`:${e.error}`:""}`:o?m(h,{fallback:"卡片渲染出错",children:m(o,{data:e.data,cardId:e.id,isHistory:!!e.isHistory,actionTokens:e.actionTokens})}):`未知卡片类型:${e.cardType}`,d.length>0&&m("div",{style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap"},children:d.map(n=>{let u=!n.kind||n.kind==="moduleAction",l=u?e.actionTokens?.[n.actionId]:void 0,p=n.enabled===!1,c=p||!r||u&&!l,f=()=>n.kind==="sendMessage"?{type:"sendMessage",value:n.value??n.label??n.actionId,visible:n.visible??!0}:n.kind==="openLink"?{type:"openLink",url:n.url??""}:{type:"moduleAction",actionId:n.actionId,contextToken:l??""},O=()=>n.style==="primary"?{fontSize:13,padding:"6px 14px",borderRadius:18,border:"1px solid var(--tbox-primary, #1677ff)",color:"#fff",background:"var(--tbox-primary, #1677ff)"}:n.style==="link"?{fontSize:13,padding:"6px 4px",borderRadius:4,border:"none",color:"var(--tbox-primary, #1677ff)",background:"transparent",textDecoration:"underline"}:{fontSize:13,padding:"6px 14px",borderRadius:18,border:"1px solid var(--tbox-primary, #1677ff)",color:"var(--tbox-primary, #1677ff)",background:"transparent"};return m("button",{type:"button",disabled:c,title:p?n.disabledReason:void 0,onClick:()=>!c&&r?.(f()),style:{...O(),cursor:c?"not-allowed":"pointer",opacity:c?.5:1},children:n.label??n.actionId},n.actionId)})})]})}import{Fragment as Ee,jsx as q}from"react/jsx-runtime";function ke({cards:e,renderItem:t,className:r}){if(e.length<=1)return q(Ee,{children:e.length===1?t(e[0]):null});let o=["tbox-card-stack",r].filter(Boolean).join(" ");return q("div",{className:o,style:{display:"flex",flexDirection:"column"},children:e.map(s=>q("div",{children:t(s)},s.id))})}import{jsx as v,jsxs as _}from"react/jsx-runtime";var x=(e,t)=>`var(--${e}, ${t})`;function Le(e){return e.selfRendersActions=!0,e}function Be(e){return _("div",{style:{borderRadius:12,background:x("tbox-card-bg","#ffffff"),padding:"12px 16px",boxShadow:`0 1px 4px ${x("tbox-shadow","rgba(0,0,0,0.06)")}`,...e.style},children:[(e.title||e.subtitle)&&_("div",{style:{marginBottom:8},children:[e.title&&v("div",{style:{fontSize:15,fontWeight:600,color:x("tbox-text-primary","#1a1a1a"),lineHeight:"20px"},children:e.title}),e.subtitle&&v("div",{style:{fontSize:12,color:x("tbox-text-secondary","#888888"),marginTop:2},children:e.subtitle})]}),e.children]})}function Oe(e){return _("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0",gap:12},children:[v("span",{style:{fontSize:13,color:x("tbox-text-secondary","#888888"),flexShrink:0},children:e.label}),v("span",{style:{fontSize:13,color:x("tbox-text-primary","#1a1a1a"),textAlign:"right",wordBreak:"break-all",...e.valueStyle},children:e.value})]})}var Me={success:{fg:"#0f8a5f",bg:"#e6f7f0"},warning:{fg:"#b26a00",bg:"#fff4e0"},neutral:{fg:"#666666",bg:"#f2f3f5"}};function Ne(e){let t=Me[e.tone];return v("span",{style:{display:"inline-block",fontSize:11,lineHeight:"18px",padding:"0 8px",borderRadius:9,color:t.fg,background:t.bg,whiteSpace:"nowrap"},children:e.text})}var Q="";function qe(e){Q=(e.apiBaseUrl??"").trim().replace(/\/$/,"")}function T(){return Q}function Z(){let e=T();return e||(typeof window<"u"?`${window.location.protocol}//${window.location.host}`:"")}function _e(e="/ws"){return Z().replace(/^http/,"ws")+e}var $=null;function ee(){if($)return $;let e={};return typeof window<"u"&&new URLSearchParams(window.location.search).forEach((r,o)=>{e[o]=r}),$=e,e}function te(e){return ee()[e]}function S(){let e=te("container");return e==="alipay-miniapp"||e==="alipay"}function $e(){if(typeof window>"u")return!1;let e=window.my;return!!(e&&typeof e.postMessage=="function")}function De(){return S()?"alipay-miniapp":"browser"}var re=g("bridge"),D="https://appx/web-view.min.js",b=null;function ne(){return typeof window>"u"?null:window.my&&typeof window.my.postMessage=="function"?window.my:null}function W(){if(typeof window>"u")return Promise.resolve(null);let e=ne();return e?Promise.resolve(e):S()?b||(b=new Promise(t=>{let r=!1,o=null,s=null,i=()=>{o&&clearInterval(o),s&&clearTimeout(s),document.removeEventListener("AlipayJSBridgeReady",a)},d=u=>{r||(r=!0,i(),t(u))},a=()=>{let u=ne();u&&d(u)};document.addEventListener("AlipayJSBridgeReady",a);let n=document.querySelector(`script[src="${D}"]`);n||(n=document.createElement("script"),n.src=D,document.head.appendChild(n)),n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>{re.warn("加载支付宝 JSSDK 失败:",D),n?.remove(),d(null)},{once:!0}),o=setInterval(a,50),s=setTimeout(()=>{re.warn("支付宝 JSSDK 已加载,但 my.postMessage 未就绪"),d(null)},5e3),a()}),b.then(t=>{t||(b=null)}),b):Promise.resolve(null)}import{detailForLog as H}from"@tbox.cn/app-sdk-core";var A="open-mini-webview-bridge",We="1.0.0",F="my",K="my.call",V="tbox";function P(e){return!!e&&typeof e=="object"&&e.bridge===A&&typeof e.requestId=="string"}var C=g("bridge"),I=new Map,oe=0,ie=!1,se=300*1e3;function Fe(){return oe+=1,`h5_${Date.now()}_${oe}`}function Ke(e){if(P(e)){ae(e);return}let t=e,r=e;if(r&&typeof r=="object"&&(r.detail!==void 0?t=r.detail:r.data!==void 0&&(t=r.data)),typeof t=="string")try{t=JSON.parse(t)}catch{return}P(t)&&ae(t)}function ae(e){let t=I.get(e.requestId);if(!t){C.debug(`收到无 pending 回执 req=${e.requestId} action=${e.action}`);return}clearTimeout(t.timer),I.delete(e.requestId);let r=Date.now()-t.startedAt;e.success?(C.info(`← ${t.apiName} ok ${r}ms req=${e.requestId}`),t.resolve(e.data)):(C.warn(`← ${t.apiName} fail code=${e.code||"BRIDGE_ERROR"} ${r}ms params=${H(t.params)} req=${e.requestId}`),t.reject({code:e.code||"BRIDGE_ERROR",errorMessage:e.errorMessage||"桥调用失败"}))}async function le(){let e=await W();return e&&!ie&&(e.onMessage=Ke,ie=!0),e}function de(e,t,r,o,s){let i=Fe();return new Promise((d,a)=>{let n=setTimeout(()=>{I.delete(i),C.warn(`← ${r} fail code=BRIDGE_TIMEOUT ${s}ms params=${H(o)} req=${i}`),a({code:"BRIDGE_TIMEOUT",errorMessage:`桥调用超时: ${r}`})},s);I.set(i,{resolve:d,reject:a,timer:n,apiName:r,params:o,startedAt:Date.now()}),C.info(`→ ${t} ${r} req=${i}`),C.debug(`params=${H(o)} req=${i}`),e.postMessage({bridge:A,action:t,apiName:r,params:o,requestId:i})})}async function y(e,t={},r="invoke",o=se){let s=await le();if(!s)throw{code:"BRIDGE_UNAVAILABLE",errorMessage:"支付宝 WebView 桥未就绪"};return de(s,r==="call"?K:"my",e,t,o)}async function w(e,t={},r=se){let o=await le();if(!o)throw{code:"BRIDGE_UNAVAILABLE",errorMessage:"支付宝 WebView 桥未就绪"};return de(o,V,e,t,r)}var G=/^[A-Za-z0-9._-]{1,80}$/u,pe=/[\u0000-\u001F\u007F]/u,ce=/^[A-Za-z][A-Za-z0-9+.-]*:/u;function Ve(e,t){if(!t||!G.test(t))return;let r;try{r=ue(e)}catch{return}if(r.protocol!=="alipays"&&r.protocol!=="alipayrisk"||r.host!=="platformapi"||r.path!=="/startapp")return;let o=(r.appId||r.query.appId||"").trim(),s=(r.query.page||"").trim(),i=(r.query.query||"").trim()||void 0,d=s.replace(/^\/+/,"");if(!(!G.test(o)||!d||pe.test(d)||ce.test(d)||d.split("/").includes(".."))){if(o===t){let a=d.includes("?")?"&":"?";return{apiName:"navigateTo",params:{url:`/${d}${i?`${a}${i}`:""}`}}}return{apiName:"navigateToMiniProgram",params:{appId:o,path:d,...i?{query:i}:{}}}}}function U(e){try{return decodeURIComponent(e)}catch{return e}}function ue(e){if(!e||typeof e!="string")throw new Error("Invalid URL");let t={protocol:"",host:"",path:"",query:{page:"",appId:""},appId:"",page:{path:"",query:{}}},r=e.match(/^([a-zA-Z]+):\/\//),o=e;r&&(t.protocol=r[1],o=o.slice(r[0].length));let s=o.indexOf("?"),i=s===-1?o:o.slice(0,s),d=s===-1?"":o.slice(s+1),a=i.indexOf("/");if(a>0?(t.host=i.slice(0,a),t.path=i.slice(a)):t.host=i,d){let n="",u={};for(let l of d.split("&")){if(l.startsWith("page=")){n=l.slice(5);continue}let p=l.indexOf("="),c=p>=0?l.slice(0,p):l;if(!c)continue;let f=p>=0?l.slice(p+1):"";u[c]=U(f)}if(t.query=u,n){t.query.page=U(n),t.query.appId&&(t.appId=t.query.appId);let l=n.indexOf("?"),p=l>=0?n.slice(0,l):n;t.page.path=U(p)}}return t}function ge(e){if(typeof e!="string")return;let t;try{t=ue(e)}catch{return}if(t.protocol!=="alipays"&&t.protocol!=="alipayrisk"||t.host!=="platformapi"||t.path!=="/startapp")return;let r=(t.appId||t.query.appId||"").trim(),o=(t.query.page||"").trim(),s=(t.query.query||"").trim()||void 0,i=o.replace(/^\/+/,"");if(!G.test(r)||!i||pe.test(i)||ce.test(i)||i.split("/").includes(".."))return;let d=i.includes("?")?"&":"?";return{appId:r,url:`/${i}${s?`${d}${s}`:""}`}}function He(e=9,t){return y("chooseImage",t?{count:e,sourceType:t}:{count:e},"invoke")}function Ue(){return y("chooseVideo",{},"invoke")}async function Ge(){let e=await y("getLocation",{type:0});return{...e,longitude:Number(e.longitude),latitude:Number(e.latitude)}}function Je(e=["auth_base"]){return y("getAuthCode",{scopes:e})}function ze(e){return y("tradePay",{tradeNO:e,orderStr:e})}function je(e){let t=ge(e);return t?y("navigateTo",{url:t.url}):Promise.reject({code:"INVALID_PARAMS",errorMessage:"支付宝小程序跳转链接无效"})}function Xe(e,t=300*1e3){return w("getLoginState",e??{},t)}function Ye(e={}){return w("openPlateKeyboard",{...e})}function Qe(){return w("closePlateKeyboard")}import{KNOWN_CLIENT_SLOT_IDS as Ze}from"@tbox.cn/app-contracts";var k=g("ClientCardRegistry"),fe=g("ClientSlotRegistry"),E=class{cards=new Map;overrides=new Map;inlineFilters=[];register(t,r){if(!t){k.warn("register without cardType skipped");return}this.cards.has(t)&&k.warn(`overwriting existing cardType: ${t}`),this.cards.set(t,r)}registerMap(t){for(let[r,o]of Object.entries(t))this.register(r,o)}registerOverride(t,r){if(!t){k.warn("registerOverride without cardType skipped");return}this.overrides.has(t)&&k.warn(`overwriting existing override: ${t}`),this.overrides.set(t,r)}getOverrides(){return Object.fromEntries(this.overrides)}registerInlineFilter(t){this.inlineFilters.push(t)}applyInlineFilters(t){return this.inlineFilters.length===0?[...t]:this.inlineFilters.reduce((r,o)=>o(r),[...t])}resolve(t){return this.cards.get(t)}getAll(){return Object.fromEntries(this.cards)}has(t){return this.cards.has(t)}get size(){return this.cards.size}},L=class{slots=new Map;register(t,r){Ze.includes(t)||fe.warn(`unknown slot id: ${t}(KNOWN_CLIENT_SLOT_IDS 未含——版本偏斜?照常注册)`),this.slots.has(t)&&fe.warn(`overwriting existing slot: ${t}`),this.slots.set(t,r)}resolve(t){return this.slots.get(t)}has(t){return this.slots.has(t)}get size(){return this.slots.size}};function et(){return{cards:new E,slots:new L}}var tt=g("HTTP"),J=null;function rt(e){J=e}var z=null;function nt(e){z=e}function ot(e,t){if(e!==401)return!1;let r=t?.code;return r==="AUTH_UNAUTHORIZED"||r==="AUTH_TOKEN_EXPIRED"}function it(e){return e.startsWith("/api/auth/")}function ye(e="",t,r={}){let o=e.replace(/\/$/,""),s=r.auth??!1,i=r.dynamicBase??!1,d=l=>({...t?.headers,...l?.headers});function a(){return i?T():o}function n(l){let p=d(l);if(s){let c=J?J():null;c&&!p.Authorization&&(p.Authorization=`Bearer ${c}`)}return p}async function u(l,p,c,f,O=0){let me=l==="POST"&&c instanceof Blob?n(f):l==="POST"?{"Content-Type":"application/json",...n(f)}:n(f),M=await fetch(a()+p,{method:l,headers:me,body:l==="POST"&&c!==void 0?c instanceof Blob?c:JSON.stringify(c):void 0,signal:f?.signal,cache:f?.cache}),j=await M.json().catch(()=>null);if(s&&O===0&&!it(p)&&ot(M.status,j)&&z){try{await z()}catch(xe){tt.warn("401 refresh failed:",xe.message)}return u(l,p,c,f,1)}return{status:M.status,data:j}}return{get:(l,p)=>u("GET",l,void 0,p),post:(l,p,c)=>u("POST",l,p,c),postBinary:(l,p,c)=>u("POST",l,p,c)}}var B=ye("",void 0,{auth:!0,dynamicBase:!0}),at=B.get,st=B.post,lt=B.postBinary;import{sanitizeForLog as ar,detailForLog as sr,truncateForLog as lr}from"@tbox.cn/app-sdk-core";export{A as BRIDGE_NAME,We as BRIDGE_VERSION,ke as CardCarousel,Be as CardFrame,Pe as CardRenderer,E as ClientCardRegistry,L as ClientSlotRegistry,h as ErrorBoundary,F as MY_ACTION,K as MY_CALL_ACTION,Ne as StatusPill,V as TBOX_ACTION,Oe as ValueText,w as callCapability,y as callJsapi,He as chooseImage,Ue as chooseVideo,Qe as closePlateKeyboard,nt as configureAuthErrorHandler,rt as configureAuthToken,qe as configureRuntime,et as createClientContext,g as createClientLogger,Ht as createLogger,ye as createService,B as defaultService,sr as detailForLog,W as ensureAlipayJSSDK,T as getApiBaseUrl,Z as getApiOrigin,Je as getAuthCode,De as getContainer,Ge as getLocation,Xe as getLoginState,te as getQueryParam,ee as getRuntimeQuery,_e as getWsUrl,$e as hasAlipayBridge,at as httpGet,st as httpPost,lt as httpPostBinary,Re as installGlobalErrorReporting,P as isBridgeReceipt,S as isInAlipayShell,Le as markSelfRendering,je as navigateToAlipayPage,Ye as openPlateKeyboard,ze as requestPayment,Ve as resolveAlipayNavigation,ar as sanitizeForLog,we as setClientLogTransport,he as setClientRunContext,lr as truncateForLog};
|
|
1
|
+
import{createLogger as mr}from"@tbox.cn/app-sdk-core";import{createCoreLogger as Le,resolveLevel as ae,setLogContextProvider as Oe}from"@tbox.cn/app-sdk-core";var W=null;Oe(()=>W??void 0);function Me(e){W=e?{requestId:e.runId,conversationId:e.conversationId}:null}function qe(){try{if(typeof localStorage<"u")return ae(localStorage.getItem("tbox:logLevel")??void 0,"info")}catch{}try{if(typeof location<"u"){let e=new URLSearchParams(location.search).get("logLevel");if(e)return ae(e,"info")}}catch{}return"info"}function f(e){return Le({tag:e,getLevel:qe,getContext:()=>W??void 0})}var le;function Be(e){le=e}function Ne(e){if(typeof window>"u"||typeof window.addEventListener!="function")return()=>{};let t=e??f("GLOBAL"),r=new Map,n=1e4,a=d=>{let o=Date.now();for(let[p,u]of r)o-u>=n&&r.delete(p);r.has(d)||(r.set(d,o),t.error(d),le?.send("error",d))},s=d=>{a(`uncaught: ${d.message} @ ${d.filename}:${d.lineno}`)},l=d=>{let o=d.reason instanceof Error?d.reason.message:String(d.reason);a(`unhandledrejection: ${o}`)};return window.addEventListener("error",s),window.addEventListener("unhandledrejection",l),()=>{window.removeEventListener("error",s),window.removeEventListener("unhandledrejection",l)}}import{Component as $e}from"react";var _e=f("ErrorBoundary"),A=class extends $e{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){_e.error("render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};import{jsx as h,jsxs as We}from"react/jsx-runtime";var L={info:{bg:"rgba(22,119,255,0.08)",color:"#1677ff"},warning:{bg:"rgba(250,140,22,0.10)",color:"#d46b08"},error:{bg:"rgba(255,77,79,0.08)",color:"#ff4d4f"}};function De({notices:e}){return e.length?h("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8},children:e.map(t=>h("div",{style:{fontSize:12,lineHeight:"18px",padding:"4px 10px",borderRadius:8,background:L[t.level]?.bg??L.info.bg,color:L[t.level]?.color??L.info.color},children:t.message},`${t.code}:${t.message}`))}):null}function Ue({card:e,registry:t,onAction:r}){let n=e.status!=="error"?t[e.cardType]:void 0,a=e.status==="error"||!n,s=n?.selfRendersActions===!0,l=!e.isHistory&&!s&&e.actions?.length?e.actions:[],d=typeof e.expiresAt=="number"&&Date.now()>=e.expiresAt;return We("div",{className:`tbox-card${a?" tbox-card--fallback":""}${d?" tbox-card--stale":""}`,style:d?{opacity:.55,filter:"grayscale(1)"}:void 0,children:[h(De,{notices:e.notices??[]}),e.status==="error"?`卡片渲染失败${e.error?`:${e.error}`:""}`:n?h(A,{fallback:"卡片渲染出错",children:h(n,{data:e.data,cardId:e.id,isHistory:!!e.isHistory,actionTokens:e.actionTokens})}):`未知卡片类型:${e.cardType}`,l.length>0&&h("div",{style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap"},children:l.map(o=>{let p=!o.kind||o.kind==="moduleAction",u=p?e.actionTokens?.[o.actionId]:void 0,i=o.enabled===!1,c=i||!r||p&&!u,g=()=>o.kind==="sendMessage"?{type:"sendMessage",value:o.value??o.label??o.actionId,visible:o.visible??!0}:o.kind==="openLink"?{type:"openLink",url:o.url??""}:{type:"moduleAction",actionId:o.actionId,contextToken:u??""},y=()=>o.style==="primary"?{fontSize:13,padding:"6px 14px",borderRadius:18,border:"1px solid var(--tbox-primary, #1677ff)",color:"#fff",background:"var(--tbox-primary, #1677ff)"}:o.style==="link"?{fontSize:13,padding:"6px 4px",borderRadius:4,border:"none",color:"var(--tbox-primary, #1677ff)",background:"transparent",textDecoration:"underline"}:{fontSize:13,padding:"6px 14px",borderRadius:18,border:"1px solid var(--tbox-primary, #1677ff)",color:"var(--tbox-primary, #1677ff)",background:"transparent"};return h("button",{type:"button",disabled:c,title:i?o.disabledReason:void 0,onClick:()=>!c&&r?.(g()),style:{...y(),cursor:c?"not-allowed":"pointer",opacity:c?.5:1},children:o.label??o.actionId},o.actionId)})})]})}import{Fragment as Fe,jsx as H}from"react/jsx-runtime";function He({cards:e,renderItem:t,className:r}){if(e.length<=1)return H(Fe,{children:e.length===1?t(e[0]):null});let n=["tbox-card-stack",r].filter(Boolean).join(" ");return H("div",{className:n,style:{display:"flex",flexDirection:"column"},children:e.map(a=>H("div",{children:t(a)},a.id))})}import{jsx as P,jsxs as F}from"react/jsx-runtime";var R=(e,t)=>`var(--${e}, ${t})`;function Ve(e){return e.selfRendersActions=!0,e}function Ge(e){return F("div",{style:{borderRadius:12,background:R("tbox-card-bg","#ffffff"),padding:"12px 16px",boxShadow:`0 1px 4px ${R("tbox-shadow","rgba(0,0,0,0.06)")}`,...e.style},children:[(e.title||e.subtitle)&&F("div",{style:{marginBottom:8},children:[e.title&&P("div",{style:{fontSize:15,fontWeight:600,color:R("tbox-text-primary","#1a1a1a"),lineHeight:"20px"},children:e.title}),e.subtitle&&P("div",{style:{fontSize:12,color:R("tbox-text-secondary","#888888"),marginTop:2},children:e.subtitle})]}),e.children]})}function Ke(e){return F("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0",gap:12},children:[P("span",{style:{fontSize:13,color:R("tbox-text-secondary","#888888"),flexShrink:0},children:e.label}),P("span",{style:{fontSize:13,color:R("tbox-text-primary","#1a1a1a"),textAlign:"right",wordBreak:"break-all",...e.valueStyle},children:e.value})]})}var Je={success:{fg:"#0f8a5f",bg:"#e6f7f0"},warning:{fg:"#b26a00",bg:"#fff4e0"},neutral:{fg:"#666666",bg:"#f2f3f5"}};function ze(e){let t=Je[e.tone];return P("span",{style:{display:"inline-block",fontSize:11,lineHeight:"18px",padding:"0 8px",borderRadius:9,color:t.fg,background:t.bg,whiteSpace:"nowrap"},children:e.text})}var de="";function je(e){de=(e.apiBaseUrl??"").trim().replace(/\/$/,"")}function w(){return de}function ue(){let e=w();return e||(typeof window<"u"?`${window.location.protocol}//${window.location.host}`:"")}function Qe(e="/ws"){return ue().replace(/^http/,"ws")+e}var V=null;function ce(){if(V)return V;let e={};return typeof window<"u"&&new URLSearchParams(window.location.search).forEach((r,n)=>{e[n]=r}),V=e,e}function pe(e){return ce()[e]}function O(){let e=pe("container");return e==="alipay-miniapp"||e==="alipay"}function Ye(){if(typeof window>"u")return!1;let e=window.my;return!!(e&&typeof e.postMessage=="function")}function Xe(){return O()?"alipay-miniapp":"browser"}var ge=f("bridge"),G="https://appx/web-view.min.js",T=null;function fe(){return typeof window>"u"?null:window.my&&typeof window.my.postMessage=="function"?window.my:null}function K(){if(typeof window>"u")return Promise.resolve(null);let e=fe();return e?Promise.resolve(e):O()?T||(T=new Promise(t=>{let r=!1,n=null,a=null,s=()=>{n&&clearInterval(n),a&&clearTimeout(a),document.removeEventListener("AlipayJSBridgeReady",d)},l=p=>{r||(r=!0,s(),t(p))},d=()=>{let p=fe();p&&l(p)};document.addEventListener("AlipayJSBridgeReady",d);let o=document.querySelector(`script[src="${G}"]`);o||(o=document.createElement("script"),o.src=G,document.head.appendChild(o)),o.addEventListener("load",d,{once:!0}),o.addEventListener("error",()=>{ge.warn("加载支付宝 JSSDK 失败:",G),o?.remove(),l(null)},{once:!0}),n=setInterval(d,50),a=setTimeout(()=>{ge.warn("支付宝 JSSDK 已加载,但 my.postMessage 未就绪"),l(null)},5e3),d()}),T.then(t=>{t||(T=null)}),T):Promise.resolve(null)}import{detailForLog as Q}from"@tbox.cn/app-sdk-core";var M="open-mini-webview-bridge",Ze="1.0.0",J="my",z="my.call",j="tbox";function q(e){return!!e&&typeof e=="object"&&e.bridge===M&&typeof e.requestId=="string"}var v=f("bridge"),B=new Map,ye=0,me=!1,Ce=300*1e3;function et(){return ye+=1,`h5_${Date.now()}_${ye}`}function tt(e){if(q(e)){xe(e);return}let t=e,r=e;if(r&&typeof r=="object"&&(r.detail!==void 0?t=r.detail:r.data!==void 0&&(t=r.data)),typeof t=="string")try{t=JSON.parse(t)}catch{return}q(t)&&xe(t)}function xe(e){let t=B.get(e.requestId);if(!t){v.debug(`收到无 pending 回执 req=${e.requestId} action=${e.action}`);return}clearTimeout(t.timer),B.delete(e.requestId);let r=Date.now()-t.startedAt;e.success?(v.info(`← ${t.apiName} ok ${r}ms req=${e.requestId}`),t.resolve(e.data)):(v.warn(`← ${t.apiName} fail code=${e.code||"BRIDGE_ERROR"} ${r}ms params=${Q(t.params)} req=${e.requestId}`),t.reject({code:e.code||"BRIDGE_ERROR",errorMessage:e.errorMessage||"桥调用失败"}))}async function be(){let e=await K();return e&&!me&&(e.onMessage=tt,me=!0),e}function he(e,t,r,n,a){let s=et();return new Promise((l,d)=>{let o=setTimeout(()=>{B.delete(s),v.warn(`← ${r} fail code=BRIDGE_TIMEOUT ${a}ms params=${Q(n)} req=${s}`),d({code:"BRIDGE_TIMEOUT",errorMessage:`桥调用超时: ${r}`})},a);B.set(s,{resolve:l,reject:d,timer:o,apiName:r,params:n,startedAt:Date.now()}),v.info(`→ ${t} ${r} req=${s}`),v.debug(`params=${Q(n)} req=${s}`),e.postMessage({bridge:M,action:t,apiName:r,params:n,requestId:s})})}async function m(e,t={},r="invoke",n=Ce){let a=await be();if(!a)throw{code:"BRIDGE_UNAVAILABLE",errorMessage:"支付宝 WebView 桥未就绪"};return he(a,r==="call"?z:"my",e,t,n)}async function S(e,t={},r=Ce){let n=await be();if(!n)throw{code:"BRIDGE_UNAVAILABLE",errorMessage:"支付宝 WebView 桥未就绪"};return he(n,j,e,t,r)}var X=/^[A-Za-z0-9._-]{1,80}$/u,Re=/[\u0000-\u001F\u007F]/u,we=/^[A-Za-z][A-Za-z0-9+.-]*:/u;function rt(e,t){if(!t||!X.test(t))return;let r;try{r=Te(e)}catch{return}if(r.protocol!=="alipays"&&r.protocol!=="alipayrisk"||r.host!=="platformapi"||r.path!=="/startapp")return;let n=(r.appId||r.query.appId||"").trim(),a=(r.query.page||"").trim(),s=(r.query.query||"").trim()||void 0,l=a.replace(/^\/+/,"");if(!(!X.test(n)||!l||Re.test(l)||we.test(l)||l.split("/").includes(".."))){if(n===t){let d=l.includes("?")?"&":"?";return{apiName:"navigateTo",params:{url:`/${l}${s?`${d}${s}`:""}`}}}return{apiName:"navigateToMiniProgram",params:{appId:n,path:l,...s?{query:s}:{}}}}}function Y(e){try{return decodeURIComponent(e)}catch{return e}}function Te(e){if(!e||typeof e!="string")throw new Error("Invalid URL");let t={protocol:"",host:"",path:"",query:{page:"",appId:""},appId:"",page:{path:"",query:{}}},r=e.match(/^([a-zA-Z]+):\/\//),n=e;r&&(t.protocol=r[1],n=n.slice(r[0].length));let a=n.indexOf("?"),s=a===-1?n:n.slice(0,a),l=a===-1?"":n.slice(a+1),d=s.indexOf("/");if(d>0?(t.host=s.slice(0,d),t.path=s.slice(d)):t.host=s,l){let o="",p={};for(let u of l.split("&")){if(u.startsWith("page=")){o=u.slice(5);continue}let i=u.indexOf("="),c=i>=0?u.slice(0,i):u;if(!c)continue;let g=i>=0?u.slice(i+1):"";p[c]=Y(g)}if(t.query=p,o){t.query.page=Y(o),t.query.appId&&(t.appId=t.query.appId);let u=o.indexOf("?"),i=u>=0?o.slice(0,u):o;t.page.path=Y(i)}}return t}function ve(e){if(typeof e!="string")return;let t;try{t=Te(e)}catch{return}if(t.protocol!=="alipays"&&t.protocol!=="alipayrisk"||t.host!=="platformapi"||t.path!=="/startapp")return;let r=(t.appId||t.query.appId||"").trim(),n=(t.query.page||"").trim(),a=(t.query.query||"").trim()||void 0,s=n.replace(/^\/+/,"");if(!X.test(r)||!s||Re.test(s)||we.test(s)||s.split("/").includes(".."))return;let l=s.includes("?")?"&":"?";return{appId:r,url:`/${s}${a?`${l}${a}`:""}`}}function nt(e=9,t){return m("chooseImage",t?{count:e,sourceType:t}:{count:e},"invoke")}function ot(){return m("chooseVideo",{},"invoke")}async function it(){let e=await m("getLocation",{type:0});return{...e,longitude:Number(e.longitude),latitude:Number(e.latitude)}}function st(e=["auth_base"]){return m("getAuthCode",{scopes:e})}function at(e){return m("tradePay",{tradeNO:e,orderStr:e})}function lt(e){let t=ve(e);return t?m("navigateTo",{url:t.url}):Promise.reject({code:"INVALID_PARAMS",errorMessage:"支付宝小程序跳转链接无效"})}function dt(e,t=300*1e3){return S("getLoginState",e??{},t)}function ut(e={}){return S("openPlateKeyboard",{...e})}function ct(){return S("closePlateKeyboard")}import{KNOWN_CLIENT_SLOT_IDS as pt}from"@tbox.cn/app-contracts";var N=f("ClientCardRegistry"),Ae=f("ClientSlotRegistry"),$=class{cards=new Map;overrides=new Map;inlineFilters=[];register(t,r){if(!t){N.warn("register without cardType skipped");return}this.cards.has(t)&&N.warn(`overwriting existing cardType: ${t}`),this.cards.set(t,r)}registerMap(t){for(let[r,n]of Object.entries(t))this.register(r,n)}registerOverride(t,r){if(!t){N.warn("registerOverride without cardType skipped");return}this.overrides.has(t)&&N.warn(`overwriting existing override: ${t}`),this.overrides.set(t,r)}getOverrides(){return Object.fromEntries(this.overrides)}registerInlineFilter(t){this.inlineFilters.push(t)}applyInlineFilters(t){return this.inlineFilters.length===0?[...t]:this.inlineFilters.reduce((r,n)=>n(r),[...t])}resolve(t){return this.cards.get(t)}getAll(){return Object.fromEntries(this.cards)}has(t){return this.cards.has(t)}get size(){return this.cards.size}},_=class{slots=new Map;register(t,r){pt.includes(t)||Ae.warn(`unknown slot id: ${t}(KNOWN_CLIENT_SLOT_IDS 未含——版本偏斜?照常注册)`),this.slots.has(t)&&Ae.warn(`overwriting existing slot: ${t}`),this.slots.set(t,r)}resolve(t){return this.slots.get(t)}has(t){return this.slots.has(t)}get size(){return this.slots.size}};function Z(){return{cards:new $,slots:new _}}var x=class extends Error{status;code;body;constructor(t,r,n,a){super(n),this.name="RequestError",this.status=t,this.code=r,this.body=a}},ee=null,te=null;function D(e){e.getToken&&(ee=e.getToken),e.refresh&&(te=e.refresh)}function gt(e,t){if(!t)return e;let r=new URLSearchParams;for(let[a,s]of Object.entries(t))if(s!=null)if(Array.isArray(s))for(let l of s)l!=null&&r.append(a,String(l));else r.append(a,String(s));let n=r.toString();return n?`${e}${e.includes("?")?"&":"?"}${n}`:e}function ft(e){return/^https?:\/\//.test(e)?e:`${w().replace(/\/$/,"")}${e.startsWith("/")?e:`/${e}`}`}async function yt(e,t){if(e.status===204)return;if(t==="response")return e;if(t==="text")return e.text();let r=await e.text();if(r)try{return JSON.parse(r)}catch{return r}}async function mt(e,t={}){let r=t.method??"GET";if((r==="GET"||r==="DELETE")&&t.body!==void 0)throw new x(0,"REQUEST_BODY_NOT_ALLOWED",`${r} 请求不能携带 body`);let n={...t.headers},a=t.body===void 0?void 0:JSON.stringify(t.body);a!==void 0&&!n["Content-Type"]&&(n["Content-Type"]="application/json");let s=t.auth??!0;if(s&&ee){let i=ee();i&&!n.Authorization&&(n.Authorization=`Bearer ${i}`)}let l=new AbortController,d=t.timeoutMs??3e4,o=d>0?setTimeout(()=>l.abort(new Error("REQUEST_TIMEOUT")),d):void 0,p=()=>l.abort(t.signal?.reason);t.signal?.addEventListener("abort",p,{once:!0});let u=async()=>fetch(gt(ft(e),t.query),{method:r,headers:n,body:a,signal:l.signal,credentials:s?"include":"same-origin",cache:t.cache});try{let i=await u();if(i.status===401&&s&&te){try{await te()}catch{}i=await u()}let c=t.responseType??"json",g=await yt(i,c);if(!i.ok){let y=g&&typeof g=="object"?g.error:void 0;throw new x(i.status,y?.code??`HTTP_${i.status}`,y?.message??`请求失败(HTTP ${i.status})`,g)}return g}catch(i){throw i instanceof x?i:i.name==="AbortError"?new x(0,"REQUEST_ABORTED","请求已取消",i):new x(0,"REQUEST_FAILED",i.message,i)}finally{o&&clearTimeout(o),t.signal?.removeEventListener("abort",p)}}var xt=f("HTTP"),re=null;function Ct(e){re=e,D({getToken:e})}var ne=null;function bt(e){ne=e,D({refresh:e})}function ht(e,t){if(e!==401)return!1;let r=t?.code;return r==="AUTH_UNAUTHORIZED"||r==="AUTH_TOKEN_EXPIRED"}function Rt(e){return e.startsWith("/api/auth/")}function Pe(e="",t,r={}){let n=e.replace(/\/$/,""),a=r.auth??!1,s=r.dynamicBase??!1,l=u=>({...t?.headers,...u?.headers});function d(){return s?w():n}function o(u){let i=l(u);if(a){let c=re?re():null;c&&!i.Authorization&&(i.Authorization=`Bearer ${c}`)}return i}async function p(u,i,c,g,y=0){let I=u==="POST"&&c instanceof Blob?o(g):u==="POST"?{"Content-Type":"application/json",...o(g)}:o(g),C=await fetch(d()+i,{method:u,headers:I,body:u==="POST"&&c!==void 0?c instanceof Blob?c:JSON.stringify(c):void 0,signal:g?.signal,cache:g?.cache}),b=await C.json().catch(()=>null);if(a&&y===0&&!Rt(i)&&ht(C.status,b)&&ne){try{await ne()}catch(Ie){xt.warn("401 refresh failed:",Ie.message)}return p(u,i,c,g,1)}return{status:C.status,data:b}}return{get:(u,i)=>p("GET",u,void 0,i),post:(u,i,c)=>p("POST",u,i,c),postBinary:(u,i,c)=>p("POST",u,i,c)}}var U=Pe("",void 0,{auth:!0,dynamicBase:!0}),wt=U.get,Tt=U.post,vt=U.postBinary;import{useCallback as Se,useEffect as Ee,useRef as E,useState as oe}from"react";function At(e,t=[],r={}){let[n,a]=oe(void 0),[s,l]=oe(void 0),[d,o]=oe(!1),p=E(void 0),u=E(!1),i=E(!0),c=E(0),g=E(e);g.current=e,Ee(()=>(i.current=!0,()=>{i.current=!1,c.current+=1}),[]);let y=Se(async I=>{p.current=I,u.current=!0;let C=++c.current;o(!0),l(void 0);try{let b=await g.current(I);return i.current&&c.current===C&&a(b),b}catch(b){i.current&&c.current===C&&l(b);return}finally{i.current&&c.current===C&&o(!1)}},[]),se=Se(async()=>{if(u.current)return y(p.current)},[y]);return Ee(()=>{r.immediate===!1||u.current||y(void 0)},t),{data:n,error:s,loading:d,run:y,refresh:se}}var ke,ie;function k(){return ke??=Z(),ke}function Pt(e){e&&k().cards.registerMap(e)}function St(e){return ie??=(async()=>{for(let t of e)t.cards&&k().cards.registerMap(t.cards),await t.register(k())})().catch(t=>{throw ie=void 0,t}),ie}function Et(){return k().cards.getAll()}import{sanitizeForLog as Br,detailForLog as Nr,truncateForLog as $r}from"@tbox.cn/app-sdk-core";export{M as BRIDGE_NAME,Ze as BRIDGE_VERSION,He as CardCarousel,Ge as CardFrame,Ue as CardRenderer,$ as ClientCardRegistry,_ as ClientSlotRegistry,A as ErrorBoundary,J as MY_ACTION,z as MY_CALL_ACTION,x as RequestError,ze as StatusPill,j as TBOX_ACTION,Ke as ValueText,S as callCapability,m as callJsapi,nt as chooseImage,ot as chooseVideo,ct as closePlateKeyboard,bt as configureAuthErrorHandler,Ct as configureAuthToken,D as configureRequestAuth,je as configureRuntime,Z as createClientContext,f as createClientLogger,mr as createLogger,Pe as createService,U as defaultService,Nr as detailForLog,K as ensureAlipayJSSDK,w as getApiBaseUrl,ue as getApiOrigin,st as getAuthCode,k as getClientContext,Xe as getContainer,it as getLocation,dt as getLoginState,pe as getQueryParam,Et as getRegisteredClientCards,ce as getRuntimeQuery,Qe as getWsUrl,Ye as hasAlipayBridge,wt as httpGet,Tt as httpPost,vt as httpPostBinary,Ne as installGlobalErrorReporting,q as isBridgeReceipt,O as isInAlipayShell,Ve as markSelfRendering,lt as navigateToAlipayPage,ut as openPlateKeyboard,Pt as registerClientCards,St as registerClientModules,mt as request,at as requestPayment,rt as resolveAlipayNavigation,Br as sanitizeForLog,Be as setClientLogTransport,Me as setClientRunContext,$r as truncateForLog,At as useRequest};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-sdk-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "tbox 应用平台 SDK client 轴:runtime/http/logger/error-boundary、桥接(支付宝 web-view)、client-context、卡片渲染基元。agent 前端运行时在 @tbox.cn/app-agent-sdk-client。",
|
|
6
6
|
"exports": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@tbox.cn/app-contracts": "0.
|
|
34
|
-
"@tbox.cn/app-sdk-core": "0.
|
|
33
|
+
"@tbox.cn/app-contracts": "1.0.0-alpha.1",
|
|
34
|
+
"@tbox.cn/app-sdk-core": "1.0.0-alpha.1",
|
|
35
35
|
"react": "18.3.1",
|
|
36
36
|
"react-dom": "18.3.1"
|
|
37
37
|
},
|