@lark-base-open/base-database-app-sdk 0.5.1 → 0.6.0-durable.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.0-durable.0] - 2026-11-03
4
+
5
+ ### Added
6
+
7
+ - 在 0.5.2 功能基线上提供 `/durable/workflow` 与 `/durable/activity`,支持持久化步骤、等待、进度、事件及站点 Function 调用。
8
+ - 提供 Durable 使用文档和可编译的 Workflow/Activity 示例。
9
+
10
+ ### Compatibility
11
+
12
+ - Durable 入口需要平台提供匹配的托管运行时;Temporal 1.24.0 作为可选 peer 依赖提供。
13
+
14
+ ## 0.5.2 - 2026-10-30
15
+
16
+ ### Added
17
+
18
+ - 新增显式 `styleScope: 'components'`,SDK 基础样式只作用于自身组件,业务页面自行声明完整配色。
19
+ - 页面默认同步 hash 路由到支持 `runtime.route` 的宿主;提供 `routeSync` 关闭选项和独立 `installRouteSync`,旧宿主不发送路由事件。
20
+ - 使用 BrowserRouter 改变产物路径时提供脱敏英文诊断,hash 路由的新标签页请求由宿主处理。
21
+
22
+ ### Compatibility
23
+
24
+ - 默认 `theme: 'host'` 和 `styleScope: 'legacy'` 保持不变;保留 `.base-app-platform`、`data-theme` 及主题变量,不要求存量站点迁移。
25
+ - `startBaseApp` 默认开启路由同步;未声明 `runtime.route` 的旧宿主不接收路由事件。需要关闭同步时设置 `routeSync:false`。
26
+ - Channel 0.2.1 将 `#/` 链接的 `target="_blank"`、修饰键点击、中键及新窗口 `window.open` 请求交给宿主 OpenLink。支持 OpenLink 但未适配深链接的旧宿主可能仍打开 CDN 产物地址,不能保证得到可分享的站点子页面链接。
27
+ - `routeSync:false` 不关闭 linkGuard;需要保留原生链接处理时另设 `linkGuard:false`,该选项也会关闭其他链接拦截。原生右键打开和复制链接地址直接使用元素 `href`,不经过点击拦截。
28
+
3
29
  ## 0.5.1 - 2026-10-27
4
30
 
5
31
  ### Fixed
@@ -13,6 +39,12 @@
13
39
  - 页面启动时向平台报告所用的 SDK 版本,便于排查问题。
14
40
  - 页面出现未处理的错误时,错误信息会上报给平台;内容会截断,并去掉链接里的参数。
15
41
 
42
+ ## [0.5.0-durable.0] - 2026-10-26
43
+
44
+ ### Added
45
+
46
+ - 新增 Durable Workflow 与 Activity 入口,支持持久化步骤、等待、进度和站点 Function 调用。
47
+
16
48
  ## 0.4.2 - 2026-10-26
17
49
 
18
50
  ### Fixed
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  用于开发以飞书多维表格为数据后端的 Base Database 应用,提供页面与服务端运行时、平台组件、版本化能力查询与测试工具。
4
4
 
5
- 安装:`npm install @lark-base-open/base-database-app-sdk@0.5.1`。从旧版本升级前请阅读 [变更记录](CHANGELOG.md)。
5
+ 安装:`npm install @lark-base-open/base-database-app-sdk@0.6.0-durable.0`。从旧版本升级前请阅读 [变更记录](CHANGELOG.md)。
6
6
 
7
- 运行环境需支持 ES2022;页面 API 需要 Base Database 页面宿主,服务端 API 用于 Node.js / FaaS。组件需要 React 与 React DOM 19.2,页面查询能力使用 @tanstack/react-query 5.104.1;npm 会安装声明的依赖与必需 peer。底层通信依赖 base-site-channel 0.2.0。
7
+ 运行环境需支持 ES2022;页面 API 需要 Base Database 页面宿主,服务端 API 用于 Node.js / FaaS。组件需要 React 与 React DOM 19.2,页面查询能力使用 @tanstack/react-query 5.104.1;npm 会安装声明的依赖与必需 peer。底层通信依赖 base-site-channel 0.2.1。
8
8
 
9
9
  server/shared 同时提供 ESM 和 CJS;page/components/testing/vite 仅 ESM。
10
10
 
@@ -31,3 +31,11 @@ export function mountPage() {
31
31
  SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务规则、服务端契约、Mutation 结果、CLI 命令与应用发布流程,请查阅 [@lark-base-open/base-database-cli](https://www.npmjs.com/package/@lark-base-open/base-database-cli) 随包安装的 lark-base-database Skill 及其 references。升级 CLI 时以该版本随包 Skill 为准。
32
32
 
33
33
  页面类型客户端生成使用 [codegen](docs/codegen.md) 入口;CLI 仅提取契约、隔离调用并写入返回文件。
34
+
35
+ 新建工程可显式开启 `styleScope: 'components'` 隔离业务样式;主题和迁移契约见 [启动说明](docs/start-base-app.md)。
36
+
37
+ ## Durable Function
38
+
39
+ 本预发布版本通过 npm 的 `durable` 标签提供 `/durable/workflow` 和 `/durable/activity` 持久化函数 API,见 [Durable 文档](docs/durable.md)。
40
+
41
+ 使用前需确认平台部署了匹配的 Durable 运行时;Temporal 为可选 peer,仅 Durable 开发和执行环境安装匹配版本,普通页面和普通 Function 不依赖它。ESM import 与 CJS require 共享 Durable 模块。
package/capabilities.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sdkVersion": "0.5.1",
3
+ "sdkVersion": "0.6.0-durable.0",
4
4
  "capabilities": {
5
5
  "runtime.diagnostic": {
6
6
  "required": [
@@ -115,6 +115,12 @@
115
115
  "site.v1.link.open"
116
116
  ],
117
117
  "baseline": true
118
+ },
119
+ "runtime.route": {
120
+ "required": [
121
+ "site.v1.route.changed"
122
+ ],
123
+ "baseline": false
118
124
  }
119
125
  }
120
126
  }
@@ -0,0 +1 @@
1
+ import{a as He,b as re,c as ze}from"./chunk-ZKBZAK4L.js";import{a as oe}from"./chunk-3JX3FIBG.js";import{a as $}from"./chunk-OHPYKFCM.js";import{createContext as sn,useContext as ct}from"react";import{createContext as Zt,useContext as Xt,useEffect as en,useSyncExternalStore as tn}from"react";import{capabilityNames as Tt}from"@lark-base-open/base-site-channel/capabilities";import*as I from"@lark-base-open/base-site-channel/runtime";import{SITE_RUNTIME_PROTOCOL_VERSION as qn,SiteRuntimeApi as le,SiteRuntimeEvent as Yn,SiteRuntimeFunction as Gn,SiteRuntimeErrorCode as Kn,readSiteAITextDelta as Jn,isValidSiteFunctionName as Qn}from"@lark-base-open/base-site-channel/runtime-contract";var J=()=>{throw new oe(re.ContextInvalid,"\u5BBF\u4E3B\u80FD\u529B\u5B57\u6BB5\u65E0\u6548")};function ve(e){if(!e||typeof e!="object")return J();if(e.capabilities===void 0)return Object.fromEntries(Object.entries(He).filter(([,o])=>o.baseline).map(([o])=>[o,{version:1}]));let t=e.capabilities;if(!t||typeof t!="object"||Array.isArray(t))return J();let n=Object.entries(t);return n.some(([,o])=>!o||typeof o!="object"||Array.isArray(o)||!Number.isSafeInteger(o.version)||o.version<=0)?J():Object.fromEntries(n.map(([o,r])=>[o,{version:r.version}]))}function It(e,t,n=1){if(!Number.isSafeInteger(n)||n<1)return J();let o=ve(e);return Object.prototype.hasOwnProperty.call(o,t)&&o[t].version>=n}async function kt(e=P){return ve(await e.getRuntimeContext())}var Xn=kt;async function Lt(e,t=1,n=P){let o=await n.getRuntimeContext(),r=ve(o),i=It(o,e,t),a=o.capabilityUnavailable;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return J();let s=a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:void 0;return s!==void 0&&(!s||typeof s!="object"||!["permission-denied","region-unavailable","temporarily-unavailable"].includes(s.reason)||typeof s.retryable!="boolean")?J():{name:e,requiredVersion:t,version:Object.prototype.hasOwnProperty.call(r,e)?r[e].version:null,supported:i,source:o.capabilities===void 0?"host-baseline":"advertised",availability:i?s?.reason??"unknown":"unsupported"}}async function Ve(e,t=1,n=P){let o=await n.getRuntimeContext(),r=await Lt(e,t,{getRuntimeContext:async()=>o});if(!r.supported)throw new ze(e,t);let i={"permission-denied":re.PermissionDenied,"region-unavailable":re.RegionUnavailable,"temporarily-unavailable":re.TemporarilyUnavailable};if(r.availability in i)throw new oe(i[r.availability],"\u5BBF\u4E3B\u660E\u786E\u62D2\u7EDD\u6B64\u80FD\u529B",void 0,o.capabilityUnavailable?.[e]?.retryable)}function qe(e,t){let n,o=!1,r,i=new Promise(a=>{r=a});return e.registerApi($.pairApi,async a=>{if(!a||!/^[A-Za-z0-9_-]{43}$/.test(a.challenge))throw new Error("INVALID_PAIRING_CHALLENGE");n=a.challenge;let s=n;o&&(o=!1,i=new Promise(u=>{r=u}));let c=await t($.endpoint,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:s})});if(!c.ok)throw new Error("DEVELOPMENT_PAIRING_FAILED");let d=await c.json();if(!/^[A-Za-z0-9_-]{43}$/.test(d.proof))throw new Error("INVALID_PAIRING_PROOF");return{proof:d.proof}}),e.subscribeEvent($.pairedEvent,a=>{n&&a?.challenge===n&&(o=!0,r())}),{reset:()=>{n=void 0,o&&(o=!1,i=new Promise(a=>{r=a}))},wait:async()=>{let a;do a=i,await a;while(a!==i)}}}var Ye=typeof window<"u"&&window.location.protocol==="http:"&&window.location.hostname===$.host&&Number(window.location.port)>=$.portMin&&Number(window.location.port)<=$.portMax;var Ge=I.siteRuntime,M=Ge.getChannel?.()??Ge.channel,_t=Ye&&typeof window<"u"&&window.parent!==window?qe(M,globalThis.fetch.bind(globalThis)):void 0;function Ke(e,t=async()=>{}){let n=new Map,o=async(r,i)=>{await t();for(let a of Tt(r,i))try{await Ve(a,1,{getRuntimeContext:()=>e.invokeApi(le.RuntimeContext,void 0)})}catch(s){throw s instanceof Error&&"code"in s?Object.assign(new I.SiteRuntimeInvocationError(String(s.code),s.message),s):s}};return{subscribeEvent:(r,i)=>e.subscribeEvent(r,i),emitEvent:async(r,i)=>(await o(r,i),e.emitEvent(r,i)),invokeApi:async(r,i,a)=>{let s=i?.requestId??i?.subscriptionId??i?.uploadId,c=r===le.HttpRequestCancel||r===le.AttachmentUploadCancel||r.endsWith(".close");if(c&&s&&n.has(s)){n.get(s).canceled=!0;return}let d={canceled:!1};!c&&s&&n.set(s,d);try{if(await o(r,i),d.canceled)throw new DOMException("The operation was aborted","AbortError");return s&&n.delete(s),await e.invokeApi(r,i,a)}finally{s&&n.get(s)===d&&n.delete(s)}}}}var Mt={invokeApi:M.invokeApi.bind(M),emitEvent:M.emitEvent.bind(M),subscribeEvent:M.subscribeEvent.bind(M)},Re=Ke(Mt,async()=>{if(typeof window<"u"&&window.parent===window)throw new I.SiteRuntimeInvocationError("CHANNEL_UNAVAILABLE","\u9875\u9762\u672A\u8FDE\u63A5\u5BBF\u4E3B channel");await _t?.wait()});M.invokeApi=Re.invokeApi;M.emitEvent=Re.emitEvent;var Ce=class extends I.SiteRuntimeClient{constructor(t){super(t?Ke(t):Re)}},so=e=>new Ce(e),P=I.siteRuntime,{invokeHttp:ue,invokeApi:co,getCurrentUser:ae,logout:Ee,requestEdit:Dt,uploadAttachment:lo,openLink:de}=P,Ft=(e=P,t)=>I.createSiteRuntimeFetch(e,t),N=Ft();var Ot=ue,Nt=/^\/?(preview\/)?app\/([^/]+)(\/|$)/,Je=/^[A-Za-z0-9_-]+$/,We="/space/api/bitable/site/v1",Bt="/space/api/box/file/temporary_download_url",Q="preview",ie=null;function jt(){let t=(typeof globalThis.location>"u"?void 0:globalThis.location)?.ancestorOrigins?.[0];if(t)return t;let n=typeof globalThis.document>"u"?"":globalThis.document.referrer;if(!n)return"";try{return new URL(n).origin}catch{return""}}function Se(){let e=typeof globalThis.location>"u"?"":globalThis.location.pathname,t=Nt.exec(e),n=jt();return t?{env:t[1]?Q:"prod",gatewayOrigin:n,token:decodeURIComponent(t[2]??"")}:{env:"prod",gatewayOrigin:n,token:""}}function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $t(e){return e===Q||e==="prod"}function Ht(e){if(!H(e))return{};let t=typeof e.siteToken=="string"?e.siteToken.trim():"";return{...t?{token:t}:{},...$t(e.env)?{env:e.env}:{}}}async function z(){return ie||(ie=(async()=>{let e=Se(),t={},n;try{n=await P.getRuntimeContext(),t=Ht(n)}catch(r){console.warn("Could not read the host Runtime context; inferring it from the artifact path",r)}pe=Qt(n);let o={env:t.env??e.env,gatewayOrigin:e.gatewayOrigin,token:t.token??e.token};return o.token||console.error("Cannot determine the app token: the host did not provide siteToken and the current path does not match an artifact path"),o})().catch(e=>{throw ie=null,pe={...Pe},e}),ie)}function Ue(e){return!!(e.tableId.trim()&&e.fieldId.trim()&&e.recordId.trim()&&e.fileToken.trim())}function Ze(e,t){return JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},siteToken:e.token,siteEnv:e.env}})}function Xe(e,t){if(t instanceof Error)return t;let n=H(t)?t.code:void 0,o=typeof n=="string"||typeof n=="number"?String(n):"",r=o==="REQUEST_TIMEOUT"||o==="10005"?`${e} timed out`:`${e} failed`;return Object.assign(new Error(`${r}${o?` (code ${o})`:""}`),{cause:t,...o?{code:o}:{}})}async function et(e,t=360,n={}){if(n.signal?.throwIfAborted(),!Ue(e)||!Number.isFinite(t)||t<=0)throw new Error("Attachment location or image size is invalid");let o=await z();if(n.signal?.throwIfAborted(),!o.token)throw new Error("Cannot load the attachment image without an app token");let r=[120,360,720,1280].find(c=>c>=t)??1280,i=new URLSearchParams({extra:Ze(o,e),width:String(r),height:String(r),policy:"allow_up",fallback_source:"1"}),a=await Ot({url:`/space/api/box/stream/download/v2/cover/${encodeURIComponent(e.fileToken)}?${i}`,init:{method:"GET",responseType:"arrayBuffer",timeoutMs:45e3},signal:n.signal}).catch(c=>{throw Xe("Attachment image request",c)});if(!a.ok){let c=a.headers.get("x-tt-logid");throw new Error(`Failed to load attachment image: HTTP ${a.status}${c?`, LogID ${c}`:""}`)}let s=await a.blob();if(!s.size||!s.type.startsWith("image/"))throw new Error("The host did not return a valid image");return s}async function zt(e,t){if(!e.token)throw new Error("Cannot get an attachment download URL without an app token");if(!Ue(t))throw new Error("Cannot get an attachment download URL: the attachment location is incomplete");let n=await N(Bt,{body:JSON.stringify({extra:Ze(e,t),file_token:t.fileToken}),headers:{"content-type":"application/json"},method:"POST"}).catch(s=>{throw Xe("Attachment download URL request",s)}),o=n.headers?.get("x-tt-logid")?.trim(),r;try{r=await n.json()}catch{throw new Error(n.ok?`Attachment download URL response is not valid JSON${o?`, LogID ${o}`:""}`:`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`)}let i=H(r)?r.code:void 0;if(typeof i=="number"&&i!==0||typeof i=="string"&&i.trim()!==""&&i.trim()!=="0"){let s=new Error(`Attachment service could not provide a download URL (code ${String(i)}${o?`, LogID ${o}`:""})`);throw Object.assign(s,{code:String(i),cause:r})}if(!n.ok)throw new Error(`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`);let a=H(r)&&H(r.data)&&typeof r.data.url=="string"?r.data.url.trim():"";if(!a)throw new Error(`Attachment download URL response is missing data.url${o?`, LogID ${o}`:""}`);return a}function tt(e){let t=new URLSearchParams;e.env===Q&&t.set("env",Q);let n=t.toString(),o=`${We}/${encodeURIComponent(e.token)}/invoke_get`;return n?`${o}?${n}`:o}function nt(e,t){if(!Je.test(t))throw new TypeError(`functionId ${t} does not match the required pattern ${String(Je)}`);let n=`${We}/${encodeURIComponent(e.token)}/functions/${encodeURIComponent(t)}/invoke`;return e.env===Q?`${n}?env=${encodeURIComponent(Q)}`:n}var Vt="x-base-site-session-id",qt="x-base-site-read-your-writes",Yt=800008918,Qe=new Map,Pe={maxRetries:3,intervalMs:300},pe={...Pe},Gt=10,Kt=100,Jt=2e3;function Qt(e){let t=H(e)?e.readYourWritesRetry:void 0;return H(t)&&Number.isInteger(t.maxRetries)&&t.maxRetries>=0&&t.maxRetries<=Gt&&Number.isInteger(t.intervalMs)&&t.intervalMs>=Kt&&t.intervalMs<=Jt?{maxRetries:t.maxRetries,intervalMs:t.intervalMs}:{...Pe}}function Wt(e){let t=Qe.get(e);if(t)return t;let n=`baseSite:session:${e}`,o;try{o=localStorage.getItem(n)||void 0}catch{o=void 0}if(!o){try{o=crypto.randomUUID()}catch{return}try{localStorage.setItem(n,o)}catch{}}return Qe.set(e,o),o}function ot(e){let t=Wt(e);return{"content-type":"application/json",...t?{[Vt]:t}:{}}}var xe=class extends oe{logId;constructor(t={}){super("FUNCTION_INVOKE_FAILED","The write has succeeded but the data is not readable yet. Do not repeat the write; retry the query shortly.","800008918",!0),this.name="DataNotReadyError",this.logId=t.logId}};async function fo(e,t,n){let o=await z();if(!o.token)throw new Error(`Cannot invoke Function ${e} without an app token`);let r=n?.readYourWrites!==!1,i={...ot(o.token),...r?{[qt]:"1"}:{}},a=()=>ue({url:nt(o,e),init:{body:JSON.stringify({params:t}),headers:i,method:"POST"}});for(let s=0;;s++){let c=await a();if(!c.ok)throw new Error(`Function ${e} request failed: HTTP ${c.status}`);let d=await c.json();if(r&&d?.code===Yt){if(s<pe.maxRetries){await new Promise(u=>setTimeout(u,pe.intervalMs));continue}throw new xe({logId:d.data?.log_id})}return d}}async function go(e,t){if(!Array.isArray(t)||t.length<1||t.length>200||t.some(r=>r===null||typeof r!="object"||Array.isArray(r)))throw new TypeError("Mutation batch requires 1 to 200 named parameter objects");let n=await z();if(!n.token)throw new Error("\u5E94\u7528 token \u672A\u786E\u5B9A\uFF0C\u65E0\u6CD5\u8C03\u7528 Mutation");let o=await ue({url:nt(n,e),init:{body:JSON.stringify({batch:t.map(r=>({params:r}))}),headers:ot(n.token),method:"POST"}});if(!o.ok)throw new Error(`Mutation \u8C03\u7528\u5931\u8D25\uFF1AHTTP ${o.status}`);return await o.json()}async function ho(e,t){let n=await zt(e,t);if(!(await de(n)).opened)throw new Error("The host did not open the attachment download link")}function bo(e,t,n=360){if(!e.gatewayOrigin||!e.token||!Ue(t))return"";let o=[120,360,720,1280].find(i=>i>=n)??1280,r=new URLSearchParams({extra:JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},baseAppToken:e.token}}),width:String(o),height:String(o),policy:"allow_up",fallback_source:"1"});return`${e.gatewayOrigin}/space/api/box/stream/download/v2/cover/${encodeURIComponent(t.fileToken)}?${r.toString()}`}var Le=Zt(void 0),at=[{id:"en",locale:"en-US",match:/^en(?:-|$)/},{id:"zh",locale:"zh-CN",match:/^zh(?:-|$)/},{id:"ja",locale:"ja-JP",match:/^ja(?:-|$)/}],Ie=new Set,it,Ae=null;function ke(e){if(typeof e!="string")return;let t=e.trim().replace(/_/g,"-").toLowerCase();return at.find(({match:n})=>n.test(t))?.id}function nn(){return typeof navigator>"u"?void 0:navigator.language}function on(e,t){return ke(e)??ke(t)??"en"}function V(){return it??on(void 0,nn())}function Te(e=V()){return at.find(({id:t})=>t===e)?.locale??"en-US"}function rn(e){return Ie.add(e),()=>Ie.delete(e)}function rt(e){it=ke(e);let t=V();st(t);for(let n of Ie)n();return t}function st(e){typeof document<"u"&&(document.documentElement.lang=Te(e))}function an(){return Ae||(st(V()),Ae=P.getRuntimeContext().then(e=>rt(e?.locale)).catch(()=>rt(void 0))),Ae}function k(){let e=Xt(Le),t=tn(rn,V,()=>"en");return en(()=>{e||an()},[e]),e??t}import{jsx as _e}from"react/jsx-runtime";var Me=sn(null);function Uo({children:e,styleScope:t="legacy",...n}){return _e(Me.Provider,{value:n,children:_e(Le.Provider,{value:n.locale,children:_e("div",{className:"base-app-platform","data-theme":n.theme,"data-base-app-style-scope":t,children:e})})})}function Po(){let e=ct(Me);if(!e)throw new Error("BASE_APP_PROVIDER_REQUIRED");return e}function me(){return ct(Me)}import{useState as Z,useEffect as gt,useLayoutEffect as hn,useRef as Fe,useId as bn}from"react";import{jsx as D,jsxs as cn}from"react/jsx-runtime";function lt(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:D("path",{d:"M17.1956 16.3595C17.6558 16.3595 18.0289 16.7326 18.0289 17.1928C18.0287 17.6529 17.6557 18.0261 17.1956 18.0261H9.48724C9.0273 18.0259 8.65411 17.6527 8.6539 17.1928C8.6539 16.7327 9.02717 16.3597 9.48724 16.3595H17.1956ZM12.5732 2.47195C13.8817 1.28992 15.902 1.32977 17.163 2.59076L17.281 2.71527C18.4249 3.98149 18.4257 5.91435 17.2818 7.18061L17.163 7.3043L9.32366 15.1445C9.12419 15.3439 8.89959 15.5169 8.65716 15.6596L8.40976 15.7923L4.13079 17.8471C2.75554 18.5075 1.31776 17.1336 1.84889 15.7565L1.90667 15.623L3.96152 11.344C4.12431 11.0051 4.34347 10.696 4.60931 10.4301L12.4495 2.59076L12.5732 2.47195ZM5.78769 11.6093C5.65491 11.7421 5.54596 11.8966 5.46461 12.0659L3.40976 16.344L7.68792 14.2892C7.85719 14.2078 8.01164 14.0989 8.14446 13.9661L13.4643 8.64545L11.1075 6.28868L5.78769 11.6093ZM15.9846 3.76915C15.3338 3.11835 14.2788 3.11851 13.6279 3.76915L12.2867 5.11029L14.6435 7.46706L15.9846 6.12592C16.6353 5.47503 16.6354 4.41994 15.9846 3.76915Z",fill:"currentColor"})})}function ut(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"24",height:"6",viewBox:"0 0 24 6",fill:"none",children:D("path",{d:"M8.4383 1.99309L11.2526 5.15916C11.6504 5.60668 12.3496 5.60668 12.7474 5.15916L15.5617 1.99309C16.6886 0.725344 18.3038 0 20 0L12 0L4 0C5.69619 0 7.31142 0.725345 8.4383 1.99309Z",fill:"#1F2329"})})}function dt(){return cn("svg",{"aria-hidden":"true",focusable:"false",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[D("circle",{cx:"8.00008",cy:"8.00033",r:"7.33333",fill:"#1456F0"}),D("path",{d:"M8 5.33333C8.36819 5.33333 8.66667 5.03486 8.66667 4.66667C8.66667 4.29848 8.36819 4 8 4C7.63181 4 7.33333 4.29848 7.33333 4.66667C7.33333 5.03486 7.63181 5.33333 8 5.33333Z",fill:"white"}),D("path",{d:"M7.33333 6C6.96514 6 6.66667 6.29848 6.66667 6.66667C6.66667 7.03486 6.96514 7.33333 7.33333 7.33333V10H6.66667C6.29848 10 6 10.2985 6 10.6667C6 11.0349 6.29848 11.3333 6.66667 11.3333H9.33333C9.70152 11.3333 10 11.0349 10 10.6667C10 10.2985 9.70152 10 9.33333 10H8.66667V6.66667C8.66667 6.29848 8.36819 6 8 6H7.33333Z",fill:"white"})]})}function pt(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M13.5043 13.5042C13.7646 13.2439 13.7665 12.8237 13.5062 12.5633L8.94298 8.00013L13.5061 3.43697C13.7665 3.17662 13.7646 2.7564 13.5043 2.49605C13.2439 2.2357 12.8237 2.23382 12.5633 2.49416C12.303 2.75451 8.00017 7.05732 8.00017 7.05732L3.43697 2.49413C3.17662 2.23378 2.7564 2.23566 2.49605 2.49601C2.2357 2.75636 2.23381 3.17658 2.49416 3.43693L7.05736 8.00013L2.49413 12.5634C2.23378 12.8237 2.23566 13.2439 2.49601 13.5043C2.75636 13.7646 3.17659 13.7665 3.43693 13.5062L8.00017 8.94294L12.5634 13.5061C12.8237 13.7665 13.2439 13.7646 13.5043 13.5042Z",fill:"#646A73"})})}import{QueryClient as ln}from"@tanstack/react-query";var De=new ln({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}});function fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ge(e,t){let n=e[t];return typeof n=="string"?n.trim():""}function un(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function q(){return{baseBindings:[],name:"",description:"",isOwner:!1,allowEdit:!1,organization:""}}function dn(){let e=document.querySelector('meta[name="description"]');return e instanceof HTMLMetaElement?e:null}function pn(e){if(e.name&&(document.title=e.name),e.description){let t=dn();t&&(t.content=e.description)}}function mn(e){return Array.isArray(e)?e.reduce((t,n)=>{if(!fe(n))return t;let o=ge(n,"baseToken");return o&&t.push({baseToken:o,tableIds:un(n.tableIds)}),t},[]):[]}function fn(e){if(!fe(e)||e.code!==0)return q();let t=e.data;if(!fe(t))return q();let n=t.site;return fe(n)?{baseBindings:mn(n.baseBindings),description:ge(n,"description"),name:ge(n,"name"),isOwner:t.isOwner===!0,allowEdit:n.allowEdit===void 0?t.isOwner===!0:n.allowEdit===!0,organization:ge(n,"organization")}:q()}async function mt(e){try{let t=await N(tt(e),{method:"GET"});if(!t.ok)return q();let n=await t.json(),o=fn(n);return pn(o),o}catch{return q()}}async function W(){let e=await z();if(!e.token)return q();let t=await ae().catch(()=>null);return t?.userId?De.fetchQuery({queryKey:["project-meta",e.token,e.env,t.userId],queryFn:()=>mt(e)}):mt(e)}var gn="https://feishu.cn/base/site/detail/overview";async function ft(){try{await P.requestEdit();return}catch{let{token:e}=await z(),t=new URL(gn);if(t.searchParams.set("token",e),!(await de(t.toString())).opened)throw new Error("Management page was not opened")}}import{jsx as S,jsxs as he}from"react/jsx-runtime";var yn={en:{openFailed:"Unable to open the management page. Please try again.",editSite:"Edit and manage your apps",hidePanel:"Hide until next visit",hiddenConfirmation:"Edit button hidden until you reopen the app",dismissNotification:"Dismiss notification"},zh:{openFailed:"\u65E0\u6CD5\u6253\u5F00\u7BA1\u7406\u9875\u9762\uFF0C\u8BF7\u91CD\u8BD5",editSite:"\u7F16\u8F91\u4E0E\u7BA1\u7406\u5E94\u7528",hidePanel:"\u9690\u85CF",hiddenConfirmation:"\u7F16\u8F91\u6309\u94AE\u5DF2\u9690\u85CF\uFF0C\u76F4\u81F3\u4E0B\u6B21\u91CD\u65B0\u6253\u5F00\u5E94\u7528",dismissNotification:"\u5173\u95ED\u63D0\u793A"},ja:{openFailed:"\u7BA1\u7406\u30DA\u30FC\u30B8\u3092\u958B\u3051\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",editSite:"\u30A2\u30D7\u30EA\u3092\u7DE8\u96C6\u30FB\u7BA1\u7406",hidePanel:"\u6B21\u56DE\u306E\u30A2\u30AF\u30BB\u30B9\u307E\u3067\u975E\u8868\u793A",hiddenConfirmation:"\u7DE8\u96C6\u30DC\u30BF\u30F3\u3092\u975E\u8868\u793A\u306B\u3057\u307E\u3057\u305F\u3002\u30A2\u30D7\u30EA\u3092\u518D\u5EA6\u958B\u304F\u3068\u8868\u793A\u3055\u308C\u307E\u3059",dismissNotification:"\u901A\u77E5\u3092\u9589\u3058\u308B"}};function Yo({position:e="bottom-right",className:t="",slots:n={}}){let o=yn[k()],[r,i]=Z(!1),[a,s]=Z(!1),[c,d]=Z(!1),[u,p]=Z(!1),[m,g]=Z(null),[f,E]=Z(null),x=Fe(null),O=Fe(null),U=Fe(null),_=bn();hn(()=>{if(!m)return;let h=m==="edit"?x.current:O.current,w=U.current;if(!h||!w)return;let v=()=>{let X=h.getBoundingClientRect(),ee=X.left+X.width/2,te=Math.ceil(w.getBoundingClientRect().width),ne=Math.max(8,Math.min(ee-te/2,window.innerWidth-te-8));E({left:ne,top:X.top-w.offsetHeight-14,arrowLeft:ee-ne})};v(),window.addEventListener("resize",v);let K=new ResizeObserver(v);return K.observe(w),()=>{window.removeEventListener("resize",v),K.disconnect()}},[m,o,e,n.tooltip]),gt(()=>{let h=!0;return W().then(w=>{h&&i(w.allowEdit&&Se().env==="prod")}).catch(()=>{}),()=>{h=!1}},[]),gt(()=>{if(!c)return;let h=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(h)},[c]);let A=n.trigger,y=n.tooltip;return r?a?c?he("div",{className:"base-app-platform base-app-notice",role:"status",children:[S(dt,{}),S("span",{children:o.hiddenConfirmation}),S("button",{type:"button","aria-label":o.dismissNotification,onClick:()=>d(!1),children:S(pt,{})})]}):null:he("div",{className:`base-app-platform base-app-floating ${t}`,"data-position":e,children:[u?S("div",{role:"alert",children:o.openFailed}):null,m?he("div",{ref:U,id:_,role:"tooltip",style:f?{left:f.left,top:f.top}:{visibility:"hidden"},children:[y?S(y,{text:m==="edit"?o.editSite:o.hidePanel}):m==="edit"?o.editSite:o.hidePanel,S("span",{className:"base-app-floating-caret",style:{left:f?.arrowLeft},children:S(ut,{})})]}):null,he("div",{className:"base-app-floating-controls",children:[S("button",{ref:x,type:"button",className:"base-app-floating-edit","aria-describedby":m==="edit"?_:void 0,"aria-label":o.editSite,onFocus:()=>g("edit"),onBlur:()=>g(null),onMouseEnter:()=>g("edit"),onMouseLeave:()=>g(null),onClick:()=>{p(!1),ft().catch(()=>p(!0))},children:A?S(A,{}):S(lt,{})}),S("button",{ref:O,type:"button",className:"base-app-floating-hide","aria-describedby":m==="hide"?_:void 0,"aria-label":o.hidePanel,onFocus:()=>g("hide"),onBlur:()=>g(null),onMouseEnter:()=>g("hide"),onMouseLeave:()=>g(null),onClick:()=>{s(!0),g(null),d(!0)},children:S("span",{"aria-hidden":"true",children:"\xD7"})})]})]}):null}var Oe=new Set;function ht(e){return Oe.add(e),()=>{Oe.delete(e)}}function bt(){for(let e of Oe)e()}import{useEffect as wn,useState as wt}from"react";import*as B from"@radix-ui/react-popover";async function yt(){try{let e=await ae();if(typeof e?.name=="string"&&e.name)return{name:e.name,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:"",tenantName:""}}catch{}try{let e=await N("/space/api/user/",{headers:{accept:"application/json"}});if(!e.ok)return null;let n=(await e.json()).data;return!n||typeof n.name!="string"||!n.name?null:{name:n.name,avatarUrl:typeof n.avatar_url=="string"?n.avatar_url:"",tenantName:typeof n.tenant_name=="string"?n.tenant_name:""}}catch{return null}}import{Fragment as Cn,jsx as L,jsxs as Ne}from"react/jsx-runtime";var vn={en:{account:"Account",logout:"Log out"},zh:{account:"\u8D26\u53F7",logout:"\u9000\u51FA\u767B\u5F55"},ja:{account:"\u30A2\u30AB\u30A6\u30F3\u30C8",logout:"\u30ED\u30B0\u30A2\u30A6\u30C8"}};function ir({audience:e="enterprise",align:t="right",side:n="down",showName:o=!0,className:r="",slots:i={}}){let[a,s]=wt(null),[c,d]=wt(""),u=me(),p=vn[k()];if(wn(()=>{if(e!=="enterprise")return;let f=!0;return Promise.all([yt(),W().catch(()=>null)]).then(([E,x])=>{f&&(s(E),d(E?.tenantName||x?.organization||""))}),()=>{f=!1}},[e]),e!=="enterprise"||!a)return null;let m=i.trigger,g=i.organization;return Ne(B.Root,{children:[L(B.Trigger,{asChild:!0,children:L("button",{className:`base-app-platform base-app-user-menu ${r}`,"aria-label":p.account,children:m?L(m,{user:a}):Ne(Cn,{children:[a.avatarUrl?L("img",{src:a.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):L("span",{children:a.name.slice(0,1)}),o?a.name:null]})})}),L(B.Portal,{children:Ne(B.Content,{"data-theme":u?.theme,className:"base-app-platform base-app-popover",align:t==="right"?"end":"start",side:n==="up"?"top":"bottom",sideOffset:8,collisionPadding:8,children:[L("strong",{children:a.name}),g?L(g,{name:c}):L("p",{children:c}),L("button",{onClick:()=>{bt(),De.clear(),Ee().catch(()=>{for(let f of["base-site-session","session","sl_session"])document.cookie=`${f}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;window.location.reload()})},children:p.logout})]})})]})}import{useEffect as be,useRef as Rt,useState as Y}from"react";import{Command as se}from"cmdk";import{QueryClient as _n,useQuery as Mn}from"@tanstack/react-query";var Rn="/space/api/mention/recommend.v2/",En="8",xn="4",Sn="0",Un=20,vt={en:{businessError:e=>`Could not search members (error code ${e})`,httpError:e=>`Member search request failed: HTTP ${e}`,invalidResponse:"Member search response has an invalid structure",noBoundBase:"Cannot search members: the application is not bound to a Base"},zh:{businessError:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,httpError:e=>`\u641C\u7D22\u6210\u5458\u8BF7\u6C42\u5931\u8D25\uFF1AHTTP ${e}`,invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",noBoundBase:"\u65E0\u6CD5\u641C\u7D22\u6210\u5458\uFF1A\u5E94\u7528\u5C1A\u672A\u7ED1\u5B9A\u591A\u7EF4\u8868\u683C"},ja:{businessError:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,httpError:e=>`\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF1AHTTP ${e}`,invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",noBoundBase:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\uFF1A\u30A2\u30D7\u30EA\u306BBase\u304C\u95A2\u9023\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093"}};async function Ct(e,t,n){let o=t??V(),r=vt[o],a=(await W()).baseBindings[0]?.baseToken;if(!a)throw new Error(r.noBoundBase);let s=new URLSearchParams({config_source:"0",obj_type:En,source:xn,token:a,type:Sn,user_type:"0",content:e.trim().slice(0,50)}).toString(),c=await N(Rn,{signal:n,body:s,headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST"});if(!c.ok)throw new Error(r.httpError(c.status));let d=await c.json();return{code:0,msg:"ok",data:Pn(d,o)}}function Pn(e,t=V()){let n=Te(t),o=vt[t],r=An(e,o);if(!r)throw new Error(o.invalidResponse);let i=r.entities,a=T(i)?i.users:void 0;if(!T(a)||!Array.isArray(r.result_list))throw new Error(o.invalidResponse);let s=[],c=new Set;for(let d of r.result_list){if(!T(d)||Number(d.type)!==0)continue;let u=b(d.token);if(!u)continue;let p=a[u];if(!T(p))continue;let m=b(p.user_id)||b(p.id)||u,g=In(p,n);if(!m||!g||c.has(m))continue;c.add(m);let f=b(p.avatar_url),E=b(p.open_id);if(s.push({avatar:{avatar_72:f,avatar_240:f,avatar_640:f,avatar_origin:f},department_ids:Tn(p.department_ids),description:kn(p,n),is_external:p.is_external===!0,name:g,user_id:m,...E?{open_id:E}:{}}),s.length>=Un)break}return{users:s}}function An(e,t){if(T(e)){if(typeof e.code=="number"&&e.code!==0){let n=b(e.msg);throw Object.assign(new Error(n||t.businessError(e.code)),{code:String(e.code),cause:e})}return"entities"in e&&"result_list"in e?e:T(e.data)?e.data:void 0}}function In(e,t){let n=e.display_name;if(typeof n=="string"&&n.trim())return n.trim();let o=t.toLowerCase().replace("-","_"),r=o.split("_")[0],i=T(n)?n:{},a=T(i.i18n_value)?i.i18n_value:i,s=r==="zh"?e.cn_name:r==="en"?e.en_name:void 0;return b(a[o])||b(a[r])||b(s)||b(i.value)||b(e.name)||b(e.en_name)||b(e.cn_name)}function kn(e,t){let n=e.is_external===!0?e.i18n_tenant:e.i18n_department;return Ln(n,t)||b(e.department)}function Ln(e,t){if(typeof e=="string")return e.trim();if(!T(e))return"";let n=t.toLowerCase().replace("-","_"),o=n.split("_")[0]??"",r=T(e.i18n_value)?e.i18n_value:e,i=b(r[n])||b(r[o]);if("i18n_value"in e)return i||b(e.value);let a=o==="zh"?b(r.zh_cn)||b(r.en_us):b(r.en_us)||b(r.zh_cn);return i||b(e.value)||a}function b(e){return typeof e=="string"?e.trim():""}function Tn(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Fragment as xt,jsx as R,jsxs as Be}from"react/jsx-runtime";var St={en:{invalidResponse:"Member search response has an invalid structure",loading:"Loading...",memberList:"Member list",noMatches:"No matching members. Try another search term.",noRecommendations:"No recommended members yet",recordCreator:"Add the person who created this record",searchFailed:"Member search failed",searchFailedCode:e=>`Could not search members (error code ${e})`,searchMembers:"Search members"},zh:{invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",loading:"\u52A0\u8F7D\u4E2D...",memberList:"\u6210\u5458\u5217\u8868",noMatches:"\u6CA1\u6709\u5339\u914D\u7684\u6210\u5458\uFF0C\u8BF7\u6362\u4E2A\u5173\u952E\u8BCD",noRecommendations:"\u6682\u65E0\u63A8\u8350\u6210\u5458",recordCreator:"\u6DFB\u52A0\u6B64\u8BB0\u5F55\u7684\u4EBA\u5458",searchFailed:"\u641C\u7D22\u6210\u5458\u5931\u8D25",searchFailedCode:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,searchMembers:"\u641C\u7D22\u6210\u5458"},ja:{invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",memberList:"\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7",noMatches:"\u4E00\u81F4\u3059\u308B\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093\u3002\u5225\u306E\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22\u3057\u3066\u304F\u3060\u3055\u3044\u3002",noRecommendations:"\u304A\u3059\u3059\u3081\u306E\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093",recordCreator:"\u3053\u306E\u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210\u8005\u3092\u8FFD\u52A0",searchFailed:"\u30E1\u30F3\u30D0\u30FC\u306E\u691C\u7D22\u306B\u5931\u6557\u3057\u307E\u3057\u305F",searchFailedCode:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,searchMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22"}};function ye(e){let[t,n]=Y(!1),[o,r]=Y(!1);be(()=>r(!0),[]);let i=k(),a=St[i],[s]=Y(()=>new _n({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}}));be(()=>{let l=ht(()=>{n(!0),s.clear()});return()=>{l(),s.clear()}},[s]);let c=Object.prototype.hasOwnProperty.call(e,"value"),d=Rt(c);be(()=>{c!==d.current&&console.warn("UserSelectorPanel controlled mode changed")},[c]);let[u,p]=Y(e.defaultValue),m=c?e.value:u,g=Array.isArray(m)?m:m?[m]:[],[f,E]=Y(""),[x,O]=Y(""),[U,_]=Y(!1),A=Rt(!1);be(()=>{if(U)return;let l=setTimeout(()=>O(f.trim()),f.trim()?400:0);return()=>clearTimeout(l)},[f,U]);let y=Mn({queryKey:["members",i,x],queryFn:async({signal:l})=>{let C=await Ct(x,i,l);return Dn(C,i)},enabled:!t&&o&&!U&&f.trim()===x},s),h=e.loading||y.isFetching||f.trim()!==x,w=!t&&!h&&!y.error&&y.data?[...y.data.users,...g.filter(l=>!y.data.users.some(C=>C.user_id===l.user_id))]:[],v=(l,C)=>{E(l),e.onSearch?.(l,{action:C})},K=()=>{v("","AutoClear"),e.onClose?.()},X=l=>{if(A.current)return;let C=g.some(we=>we.user_id===l.user_id),ce=e.mode==="multiple"?C?g.filter(we=>we.user_id!==l.user_id):[...g,l]:C?void 0:l;c||p(ce),e.onChange?.(ce,{option:l,action:C?"Remove":"Select"}),C||e.onSelect?.(l,{option:l}),e.mode==="multiple"?v("","AutoClear"):K()},ee=e.slots?.empty,te=e.slots?.loading,ne=e.slots?.option,$e=e.slots?.footer;return Be(se,{shouldFilter:!1,loop:!0,className:`base-app-platform base-app-selector ${e.className??""}`,label:a.memberList,children:[R(se.Input,{autoFocus:!0,placeholder:a.searchMembers,"aria-label":a.searchMembers,value:f,onValueChange:l=>v(l,"Input"),onCompositionStart:()=>{A.current=!0,_(!0)},onCompositionEnd:()=>{A.current=!1,_(!1)},onKeyDown:l=>{if(e.onKeyDown?.(l),l.defaultPrevented){l.stopPropagation();return}if(A.current||Fn(l)){l.stopPropagation();return}l.key==="Escape"&&(l.preventDefault(),K())}}),R(se.List,{"aria-label":a.memberList,"aria-multiselectable":e.mode==="multiple"||void 0,children:h?R("div",{role:"status",children:te?R(te,{}):a.loading}):y.error?R("div",{role:"alert",children:a.searchFailed}):Be(xt,{children:[e.onSelectRecordCreator?R(se.Item,{value:"record-creator",onSelect:()=>{e.onSelectRecordCreator?.(),K()},children:a.recordCreator}):null,w.map(l=>{let C=g.some(ce=>ce.user_id===l.user_id);return R(se.Item,{value:l.user_id,onSelect:()=>X(l),"data-checked":C,children:ne?R(ne,{user:l,selected:C}):Be(xt,{children:[R("span",{children:l.name}),R("small",{children:e.getUserDescription?.(l)??l.description}),C?R("span",{"aria-label":"selected",children:"\u2713"}):null]})},l.user_id)}),!w.length&&!e.onSelectRecordCreator?R("div",{role:"status",children:ee?R(ee,{}):f.trim()?a.noMatches:a.noRecommendations}):null]})}),$e?R($e,{}):null]})}function Dn(e,t){let n=St[t];if(!Et(e)||typeof e.code!="number")throw new Error(n.invalidResponse);if(e.code!==0){let o=typeof e.msg=="string"?e.msg.trim():"";throw Object.assign(new Error(o||n.searchFailedCode(e.code)),{code:String(e.code),cause:e})}if(!Et(e.data)||!Array.isArray(e.data.users))throw new Error(n.invalidResponse);return{users:e.data.users}}function Et(e){return typeof e=="object"&&e!==null}function Fn(e){return e.nativeEvent?.isComposing===!0||e.keyCode===229}import{useState as On,useRef as Nn}from"react";import*as j from"@radix-ui/react-popover";import{jsx as F,jsxs as Ut}from"react/jsx-runtime";var Bn={en:{clearSelected:"Clear selected members",removeMember:e=>`Remove member ${e}`,selectMembers:"Select members"},zh:{clearSelected:"\u6E05\u9664\u5DF2\u9009\u6210\u5458",removeMember:e=>`\u79FB\u9664\u6210\u5458 ${e}`,selectMembers:"\u9009\u62E9\u6210\u5458"},ja:{clearSelected:"\u9078\u629E\u3057\u305F\u30E1\u30F3\u30D0\u30FC\u3092\u30AF\u30EA\u30A2",removeMember:e=>`\u30E1\u30F3\u30D0\u30FC ${e} \u3092\u524A\u9664`,selectMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u9078\u629E"}};function Pt(e){let t=Nn(null),n=me(),o=Bn[k()],[r,i]=On(!1),a=Array.isArray(e.value)?e.value:e.value?[e.value]:[],s=u=>{i(u),u!==r&&e.onDropdownVisibleChange?.(u)},c=e.slots?.trigger,d=e.slots?.chip;return Ut(j.Root,{open:r,onOpenChange:s,children:[Ut("div",{ref:t,className:`base-app-platform base-app-editor ${e.className??""}`,onClickCapture:u=>{u.target.closest("[data-base-app-trigger]")&&e.onClick?.(u)},children:[F(j.Trigger,{asChild:!0,children:F("button",{type:"button","data-base-app-trigger":"","aria-label":o.selectMembers,onFocus:e.onFocus,onBlur:e.onBlur,children:c?F(c,{value:e.value}):a.length?a.map(u=>F("span",{children:d?F(d,{user:u}):u.name},u.user_id)):o.selectMembers})}),a.map(u=>F("button",{type:"button","aria-label":e.mode==="multiple"?o.removeMember(u.name):o.clearSelected,onClick:p=>{p.stopPropagation(),e.onChange?.(e.mode==="multiple"?a.filter(m=>m.user_id!==u.user_id):void 0),e.mode==="multiple"?e.onRemove?.(u):e.onClear?.()},children:"\xD7"},u.user_id))]}),F(j.Portal,{container:e.portalContainer??t.current?.closest("dialog")??void 0,children:F(j.Content,{"data-theme":n?.theme,className:"base-app-platform base-app-popover",sideOffset:4,collisionPadding:8,children:F(ye,{...e,slots:void 0,onChange:(u,p)=>{e.onChange?.(u),p.action==="Remove"&&p.option&&e.onRemove?.(p.option)},onClose:()=>s(!1)})})})]})}import{useEffect as At,useRef as jn,useState as je}from"react";import{jsx as G,jsxs as Hn}from"react/jsx-runtime";var $n={en:{decodeFailed:"Image could not be decoded",loadFailed:"Failed to load image",loading:"Loading image",retry:"Retry image"},zh:{decodeFailed:"\u56FE\u7247\u65E0\u6CD5\u89E3\u7801",loadFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",loading:"\u56FE\u7247\u52A0\u8F7D\u4E2D",retry:"\u91CD\u8BD5\u56FE\u7247"},ja:{decodeFailed:"\u753B\u50CF\u3092\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",loadFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",loading:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D",retry:"\u753B\u50CF\u3092\u518D\u8AAD\u307F\u8FBC\u307F"}};function Tr({attachment:e,size:t=360,alt:n,className:o,slots:r={}}){let i=k(),a=$n[i],s=jn(null),[c,d]=je(!1),[u,p]=je(0),[m,g]=je({key:"",url:"",error:""}),{tableId:f,fieldId:E,recordId:x,fileToken:O}=e,U=JSON.stringify([f,E,x,O,t,u]);At(()=>{if(typeof IntersectionObserver>"u"){d(!0);return}let h=new IntersectionObserver(w=>{w.some(v=>v.isIntersecting)&&(d(!0),h.disconnect())},{rootMargin:"200px"});return s.current&&h.observe(s.current),()=>h.disconnect()},[]),At(()=>{if(!c)return;let h=new AbortController,w="";return et({tableId:f,fieldId:E,recordId:x,fileToken:O},t,{signal:h.signal}).then(v=>{h.signal.aborted||(w=URL.createObjectURL(v),g({key:U,url:w,error:""}))}).catch(v=>{h.signal.aborted||g({key:U,url:"",error:v instanceof Error?v.message:"",localError:v instanceof Error?void 0:"loadFailed"})}),()=>{h.abort(),w&&URL.revokeObjectURL(w)}},[c,U,f,E,x,O,t]);let _=r.loading,A=r.error,y=m.key===U?m:void 0;return G("span",{ref:s,className:`base-app-platform base-app-attachment ${o??""}`,"aria-busy":!y,children:y?.url?G("img",{src:y.url,alt:n,onError:()=>g({key:U,url:"",error:"",localError:"decodeFailed"})}):y?.error||y?.localError?A?G(A,{code:"ATTACHMENT_LOAD_FAILED",retry:()=>p(h=>h+1)}):Hn("span",{children:[G("span",{role:"status",children:y.localError?a[y.localError]:y.error}),G("button",{type:"button",onClick:()=>p(h=>h+1),children:a.retry})]}):G("span",{role:"status",children:_?G(_,{}):a.loading})})}export{qn as a,le as b,Yn as c,Gn as d,Kn as e,Jn as f,Qn as g,Ke as h,Re as i,Ce as j,so as k,P as l,ue as m,co as n,ae as o,Ee as p,Dt as q,lo as r,de as s,Ft as t,N as u,ve as v,It as w,kt as x,Xn as y,Lt as z,Ve as A,Se as B,z as C,et as D,zt as E,tt as F,nt as G,xe as H,fo as I,go as J,ho as K,bo as L,Le as M,on as N,V as O,Te as P,an as Q,k as R,Uo as S,Po as T,me as U,De as V,Yo as W,ir as X,ye as Y,Pt as Z,Tr as _};
@@ -1,4 +1,4 @@
1
- export { a3 as AttachmentImage, W as BaseAppContextValue, X as BaseAppProvider, a0 as DatabaseAudience, a2 as DatabaseUserMenu, a1 as DatabaseUserMenuProps, $ as FloatingButton, _ as FloatingButtonProps, U as UiLanguage, a4 as UiLanguageContext, L as User, P as UserSelectorAction, R as UserSelectorEditor, T as UserSelectorEditorProps, V as UserSelectorEditorValue, O as UserSelectorMode, J as UserSelectorPanel, K as UserSelectorPanelProps, Q as UserSelectorSearchAction, N as UserSelectorValue, a6 as getUiLanguage, a7 as getUiLocale, a8 as initializeUiLanguage, a5 as selectUiLanguage, Y as useBaseApp, Z as useOptionalBaseApp, a9 as useUiLanguage } from './index-99514181.js';
1
+ export { a3 as AttachmentImage, W as BaseAppContextValue, X as BaseAppProvider, a0 as DatabaseAudience, a2 as DatabaseUserMenu, a1 as DatabaseUserMenuProps, $ as FloatingButton, _ as FloatingButtonProps, U as UiLanguage, a4 as UiLanguageContext, L as User, P as UserSelectorAction, R as UserSelectorEditor, T as UserSelectorEditorProps, V as UserSelectorEditorValue, O as UserSelectorMode, J as UserSelectorPanel, K as UserSelectorPanelProps, Q as UserSelectorSearchAction, N as UserSelectorValue, a6 as getUiLanguage, a7 as getUiLocale, a8 as initializeUiLanguage, a5 as selectUiLanguage, Y as useBaseApp, Z as useOptionalBaseApp, a9 as useUiLanguage } from './index-f0f8b30f.js';
2
2
  import 'react';
3
3
  import '@lark-base-open/base-site-channel/runtime';
4
4
  import './capabilities-83939715.js';
@@ -1 +1 @@
1
- import{M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h,U as i,W as j,X as k,Y as l,Z as m,_ as n}from"./chunk-OF7TEKK6.js";import"./chunk-ZKBZAK4L.js";import"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export{n as AttachmentImage,g as BaseAppProvider,k as DatabaseUserMenu,j as FloatingButton,a as UiLanguageContext,m as UserSelectorEditor,l as UserSelectorPanel,c as getUiLanguage,d as getUiLocale,e as initializeUiLanguage,b as selectUiLanguage,h as useBaseApp,i as useOptionalBaseApp,f as useUiLanguage};
1
+ import{M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h,U as i,W as j,X as k,Y as l,Z as m,_ as n}from"./chunk-EG6R7YAD.js";import"./chunk-ZKBZAK4L.js";import"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export{n as AttachmentImage,g as BaseAppProvider,k as DatabaseUserMenu,j as FloatingButton,a as UiLanguageContext,m as UserSelectorEditor,l as UserSelectorPanel,c as getUiLanguage,d as getUiLocale,e as initializeUiLanguage,b as selectUiLanguage,h as useBaseApp,i as useOptionalBaseApp,f as useUiLanguage};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAttempt = getAttempt;
4
+ exports.cancellationSignal = cancellationSignal;
5
+ exports.__installCapabilityTransport = __installCapabilityTransport;
6
+ exports.invokeFunction = invokeFunction;
7
+ const activity_1 = require("@temporalio/activity");
8
+ function getAttempt() { return (0, activity_1.activityInfo)().attempt; }
9
+ function cancellationSignal() { return activity_1.Context.current().cancellationSignal; }
10
+ let capabilityTransport;
11
+ // 只由通用 Worker 启动器装配;公开 SDK 类型不暴露凭证或配置入口。
12
+ /** @internal */
13
+ function __installCapabilityTransport(transport) {
14
+ if (capabilityTransport)
15
+ throw new Error('Site capability transport is already configured');
16
+ capabilityTransport = transport;
17
+ }
18
+ /** input 与普通 Site Function 的请求体一致,例如 { params: { city: '北京' } }。 */
19
+ async function invokeFunction(functionId, input, options) {
20
+ if (!functionId || !options?.key || options.key.length > 256)
21
+ throw new Error('Function and a stable call key are required');
22
+ if (!capabilityTransport)
23
+ throw new Error('Site capability transport is unavailable');
24
+ return capabilityTransport((0, activity_1.activityInfo)().taskToken, { function_id: functionId, call_key: options.key, payload: input }, cancellationSignal());
25
+ }
@@ -0,0 +1,6 @@
1
+ export declare function getAttempt(): number;
2
+ export declare function cancellationSignal(): AbortSignal;
3
+ /** input 与普通 Site Function 的请求体一致,例如 { params: { city: '北京' } }。 */
4
+ export declare function invokeFunction<T = unknown>(functionId: string, input: Record<string, unknown>, options: {
5
+ key: string;
6
+ }): Promise<T>;
@@ -0,0 +1,6 @@
1
+ export declare function getAttempt(): number;
2
+ export declare function cancellationSignal(): AbortSignal;
3
+ /** input 与普通 Site Function 的请求体一致,例如 { params: { city: '北京' } }。 */
4
+ export declare function invokeFunction<T = unknown>(functionId: string, input: Record<string, unknown>, options: {
5
+ key: string;
6
+ }): Promise<T>;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runDefinition = runDefinition;
4
+ exports.callStep = callStep;
5
+ exports.sleep = sleep;
6
+ exports.reportProgress = reportProgress;
7
+ exports.waitForEvent = waitForEvent;
8
+ const workflow_1 = require("@temporalio/workflow");
9
+ let state;
10
+ let definition;
11
+ let keys;
12
+ let events;
13
+ let receivedEvents;
14
+ let eventOverflow;
15
+ function receiveEvent(name, data, id) {
16
+ if (!(definition.events ?? ['approval']).includes(name))
17
+ return;
18
+ const key = id === undefined ? undefined : name + ':' + id;
19
+ if (key && receivedEvents.has(key))
20
+ return;
21
+ if (receivedEvents.size >= 1000 || [...events.values()].reduce((n, items) => n + items.length, 0) >= 1000) {
22
+ eventOverflow = true;
23
+ return;
24
+ }
25
+ if (key)
26
+ receivedEvents.add(key);
27
+ const pending = events.get(name) ?? [];
28
+ pending.push(data);
29
+ events.set(name, pending);
30
+ }
31
+ /** @internal */
32
+ async function runDefinition(meta, fn, input) {
33
+ definition = meta;
34
+ keys = new Set();
35
+ events = new Map();
36
+ receivedEvents = new Set();
37
+ eventOverflow = false;
38
+ state = { stage: 'starting', processed: 0, total: 0, paused: false, approved: false, results: [] };
39
+ (0, workflow_1.setHandler)((0, workflow_1.defineQuery)('progress'), () => ({ ...state, results: [...state.results] }));
40
+ (0, workflow_1.setHandler)((0, workflow_1.defineSignal)('pause'), () => { state.paused = true; });
41
+ (0, workflow_1.setHandler)((0, workflow_1.defineSignal)('resume'), () => { state.paused = false; });
42
+ (0, workflow_1.setHandler)((0, workflow_1.defineSignal)('approve'), () => { state.approved = true; receiveEvent('approval', { approved: true }); });
43
+ (0, workflow_1.setHandler)((0, workflow_1.defineSignal)('event'), (event) => {
44
+ if (!event || typeof event.name !== 'string' || typeof event.id !== 'string' || event.id.length < 8 || event.id.length > 128)
45
+ return;
46
+ receiveEvent(event.name, event.data, event.id);
47
+ });
48
+ try {
49
+ const result = await fn(input);
50
+ await boundary();
51
+ state.stage = 'completed';
52
+ return result;
53
+ }
54
+ catch (e) {
55
+ if (e instanceof TypeError || e instanceof RangeError)
56
+ throw workflow_1.ApplicationFailure.nonRetryable('Durable Function definition error', 'DefinitionError');
57
+ throw e;
58
+ }
59
+ }
60
+ async function boundary() {
61
+ if (eventOverflow)
62
+ throw workflow_1.ApplicationFailure.nonRetryable('Durable event limit exceeded', 'EventLimitExceeded');
63
+ if (state.paused) {
64
+ state.stage = 'paused';
65
+ await (0, workflow_1.condition)(() => !state.paused || eventOverflow);
66
+ }
67
+ if (eventOverflow)
68
+ throw workflow_1.ApplicationFailure.nonRetryable('Durable event limit exceeded', 'EventLimitExceeded');
69
+ }
70
+ async function callStep(name, args, options) {
71
+ await boundary();
72
+ if (!definition.activities[name] || !options.key || keys.has(options.key) || keys.size >= 100)
73
+ throw workflow_1.ApplicationFailure.nonRetryable('Invalid or repeated step key', 'DefinitionError');
74
+ keys.add(options.key);
75
+ const policy = definition.activities[name];
76
+ state.stage = 'processing';
77
+ const activity = definition.id + '__' + name;
78
+ const proxy = (0, workflow_1.proxyActivities)({
79
+ activityId: options.key, startToCloseTimeout: policy.timeout, scheduleToCloseTimeout: '2 minutes',
80
+ retry: { initialInterval: '1 second', maximumInterval: '5 seconds', maximumAttempts: policy.retry.maximumAttempts },
81
+ });
82
+ return proxy[activity](args);
83
+ }
84
+ async function sleep(milliseconds) {
85
+ await boundary();
86
+ state.stage = 'durable_wait';
87
+ await (0, workflow_1.sleep)(milliseconds);
88
+ await boundary();
89
+ }
90
+ function reportProgress(progress) {
91
+ Object.assign(state, progress);
92
+ }
93
+ async function waitForEvent(name, options) {
94
+ if (!(definition.events ?? ['approval']).includes(name))
95
+ throw workflow_1.ApplicationFailure.nonRetryable('Undeclared event', 'DefinitionError');
96
+ if (!Number.isFinite(options.timeout) || options.timeout <= 0)
97
+ throw workflow_1.ApplicationFailure.nonRetryable('Invalid event timeout', 'DefinitionError');
98
+ await boundary();
99
+ state.stage = 'waiting_' + name;
100
+ if (!await (0, workflow_1.condition)(() => (events.get(name)?.length ?? 0) > 0 || eventOverflow, options.timeout))
101
+ throw workflow_1.ApplicationFailure.nonRetryable('Event wait timed out', 'EventTimeout');
102
+ await boundary();
103
+ const result = events.get(name).shift();
104
+ if (name === 'approval')
105
+ state.approved = false;
106
+ return result;
107
+ }
@@ -0,0 +1,15 @@
1
+ type Json = any;
2
+ export declare function callStep<T>(name: string, args: Json, options: {
3
+ key: string;
4
+ }): Promise<T>;
5
+ export declare function sleep(milliseconds: number): Promise<void>;
6
+ export declare function reportProgress(progress: {
7
+ stage?: string;
8
+ processed: number;
9
+ total: number;
10
+ results?: Json[];
11
+ }): void;
12
+ export declare function waitForEvent<T = Json>(name: string, options: {
13
+ timeout: number;
14
+ }): Promise<T>;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ type Json = any;
2
+ export declare function callStep<T>(name: string, args: Json, options: {
3
+ key: string;
4
+ }): Promise<T>;
5
+ export declare function sleep(milliseconds: number): Promise<void>;
6
+ export declare function reportProgress(progress: {
7
+ stage?: string;
8
+ processed: number;
9
+ total: number;
10
+ results?: Json[];
11
+ }): void;
12
+ export declare function waitForEvent<T = Json>(name: string, options: {
13
+ timeout: number;
14
+ }): Promise<T>;
15
+ export {};
@@ -203,8 +203,9 @@ interface BaseAppContextValue {
203
203
  mode?: string;
204
204
  onDiagnostic?: (record: RuntimeDiagnostic) => void;
205
205
  }
206
- declare function BaseAppProvider({ children, ...value }: BaseAppContextValue & {
206
+ declare function BaseAppProvider({ children, styleScope, ...value }: BaseAppContextValue & {
207
207
  children?: React__default.ReactNode;
208
+ styleScope?: "legacy" | "components";
208
209
  }): React__default.JSX.Element;
209
210
  declare function useBaseApp(): BaseAppContextValue;
210
211
  declare function useOptionalBaseApp(): BaseAppContextValue | null;
package/dist/page.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as channelRuntime from '@lark-base-open/base-site-channel/runtime';
2
- import { LinkGuardOptions as LinkGuardOptions$1, CallSiteAIFunctionParams as CallSiteAIFunctionParams$1, InvokeSiteAIFunctionStreamParams as InvokeSiteAIFunctionStreamParams$1, SiteAIVideoTask, SiteAIImageAsset, SiteAIFunctionResult, SiteAIFunctionStreamHandle } from '@lark-base-open/base-site-channel/runtime';
2
+ import { LinkGuardOptions as LinkGuardOptions$1, CallSiteAIFunctionParams as CallSiteAIFunctionParams$1, InvokeSiteAIFunctionStreamParams as InvokeSiteAIFunctionStreamParams$1, SiteAIVideoTask, SiteAIImageAsset, SiteAIFunctionResult, SiteAIFunctionStreamHandle, RouteSyncOptions as RouteSyncOptions$1 } from '@lark-base-open/base-site-channel/runtime';
3
3
  export * from '@lark-base-open/base-site-channel/runtime';
4
4
  export { SiteChatbotStreamError } from '@lark-base-open/base-site-channel/runtime';
5
5
  import { RuntimeDiagnostic } from './shared.js';
@@ -8,8 +8,8 @@ import { R as RuntimeContextReader } from './capabilities-83939715.js';
8
8
  export { S as SiteRuntimeContext, g as getCapabilities, a as getRuntimeCapabilities, h as hasCapability, q as queryCapability, r as readCapabilities, b as requireCapability } from './capabilities-83939715.js';
9
9
  export * from '@lark-base-open/base-site-channel/runtime-contract';
10
10
  export { SITE_RUNTIME_PROTOCOL_VERSION, SiteRuntimeApi, SiteRuntimeErrorCode, SiteRuntimeEvent, SiteRuntimeFunction, isValidSiteFunctionName, readSiteAITextDelta } from '@lark-base-open/base-site-channel/runtime-contract';
11
- import { U as UiLanguage } from './index-99514181.js';
12
- export { a3 as AttachmentImage, W as BaseAppContextValue, X as BaseAppProvider, D as DataNotReadyError, p as DatabaseAttachmentRef, a0 as DatabaseAudience, n as DatabaseContext, q as DatabaseEnv, w as DatabaseFunctionInputMap, u as DatabaseFunctionInvocation, v as DatabaseFunctionOptions, x as DatabaseFunctionOutputMap, t as DatabaseFunctionResponse, B as DatabaseMutationResult, A as DatabaseQueryResult, a2 as DatabaseUserMenu, a1 as DatabaseUserMenuProps, $ as FloatingButton, _ as FloatingButtonProps, F as FunctionInputMap, y as FunctionOutputMap, z as MutationFunctionId, M as MutationFunctionMap, S as SiteRuntimeClient, a4 as UiLanguageContext, L as User, P as UserSelectorAction, R as UserSelectorEditor, T as UserSelectorEditorProps, V as UserSelectorEditorValue, O as UserSelectorMode, J as UserSelectorPanel, K as UserSelectorPanelProps, Q as UserSelectorSearchAction, N as UserSelectorValue, d as buildAttachmentCoverUrl, j as buildDatabaseInvokeFunctionPath, h as buildDatabaseInvokeGetPath, C as createSiteRuntimeClient, E as createSiteRuntimeFetch, f as fetch, c as fetchAttachmentCover, e as fetchAttachmentDownloadUrl, g as getCurrentUser, a as getDatabaseContext, a6 as getUiLanguage, a7 as getUiLocale, a8 as initializeUiLanguage, G as invokeApi, k as invokeDatabaseFunction, m as invokeDatabaseMutationBatch, i as invokeHttp, l as logout, o as openAttachmentDownload, I as openLink, r as requestEdit, b as resolveDatabaseContext, a5 as selectUiLanguage, s as siteRuntime, H as uploadAttachment, Y as useBaseApp, Z as useOptionalBaseApp, a9 as useUiLanguage } from './index-99514181.js';
11
+ import { U as UiLanguage } from './index-f0f8b30f.js';
12
+ export { a3 as AttachmentImage, W as BaseAppContextValue, X as BaseAppProvider, D as DataNotReadyError, p as DatabaseAttachmentRef, a0 as DatabaseAudience, n as DatabaseContext, q as DatabaseEnv, w as DatabaseFunctionInputMap, u as DatabaseFunctionInvocation, v as DatabaseFunctionOptions, x as DatabaseFunctionOutputMap, t as DatabaseFunctionResponse, B as DatabaseMutationResult, A as DatabaseQueryResult, a2 as DatabaseUserMenu, a1 as DatabaseUserMenuProps, $ as FloatingButton, _ as FloatingButtonProps, F as FunctionInputMap, y as FunctionOutputMap, z as MutationFunctionId, M as MutationFunctionMap, S as SiteRuntimeClient, a4 as UiLanguageContext, L as User, P as UserSelectorAction, R as UserSelectorEditor, T as UserSelectorEditorProps, V as UserSelectorEditorValue, O as UserSelectorMode, J as UserSelectorPanel, K as UserSelectorPanelProps, Q as UserSelectorSearchAction, N as UserSelectorValue, d as buildAttachmentCoverUrl, j as buildDatabaseInvokeFunctionPath, h as buildDatabaseInvokeGetPath, C as createSiteRuntimeClient, E as createSiteRuntimeFetch, f as fetch, c as fetchAttachmentCover, e as fetchAttachmentDownloadUrl, g as getCurrentUser, a as getDatabaseContext, a6 as getUiLanguage, a7 as getUiLocale, a8 as initializeUiLanguage, G as invokeApi, k as invokeDatabaseFunction, m as invokeDatabaseMutationBatch, i as invokeHttp, l as logout, o as openAttachmentDownload, I as openLink, r as requestEdit, b as resolveDatabaseContext, a5 as selectUiLanguage, s as siteRuntime, H as uploadAttachment, Y as useBaseApp, Z as useOptionalBaseApp, a9 as useUiLanguage } from './index-f0f8b30f.js';
13
13
  import React__default from 'react';
14
14
  export { CAPABILITY_CATALOG } from '@lark-base-open/base-site-channel/capabilities';
15
15
 
@@ -105,9 +105,12 @@ interface StartBaseAppOptions {
105
105
  root?: HTMLElement | string;
106
106
  strictMode?: boolean;
107
107
  linkGuard?: boolean;
108
+ routeSync?: boolean;
108
109
  reportLifecycle?: boolean;
109
110
  platformUI?: boolean;
110
111
  theme?: "host" | "light" | "dark";
112
+ /** 默认 legacy 保留存量基础样式;components 只给 SDK 组件设置样式。 */
113
+ styleScope?: "legacy" | "components";
111
114
  locale?: "host" | UiLanguage;
112
115
  providers?: (children: React__default.ReactNode) => React__default.ReactNode;
113
116
  onDiagnostic?: (record: RuntimeDiagnostic) => void;
@@ -135,4 +138,10 @@ declare class SiteChatbotStreamAdapter extends channelRuntime.SiteChatbotStreamA
135
138
  constructor(options: ConstructorParameters<typeof channelRuntime.SiteChatbotStreamAdapter>[0]);
136
139
  }
137
140
 
138
- export { BaseAppHandle, CallSiteAIFunctionParams, DevelopmentPairChallenge, DevelopmentPairProof, InvokeSiteAIFunctionStreamParams, LinkGuardOptions, RuntimeContextReader, RuntimeDiagnostic, SiteAIMediaTask, SiteAIMessage, SiteAIMessageContentPart, SiteChatbotStreamAdapter, StartBaseAppOptions, UiLanguage, callSiteAIFunction, createSiteAIFunctionTask, getSiteAIFunctionTask, hasRunnableMediaTask, installLinkGuard, invokeSiteAIFunctionStream, normalizeSiteAIMediaTask, startBaseApp };
141
+ interface RouteSyncOptions extends Omit<RouteSyncOptions$1, "onDiagnostic"> {
142
+ onDiagnostic?: (diagnostic: RuntimeDiagnostic) => void;
143
+ }
144
+ /** The Channel runtime owns observation and opt-in capability checks. */
145
+ declare function installRouteSync(options?: RouteSyncOptions): () => void;
146
+
147
+ export { BaseAppHandle, CallSiteAIFunctionParams, DevelopmentPairChallenge, DevelopmentPairProof, InvokeSiteAIFunctionStreamParams, LinkGuardOptions, RouteSyncOptions, RuntimeContextReader, RuntimeDiagnostic, SiteAIMediaTask, SiteAIMessage, SiteAIMessageContentPart, SiteChatbotStreamAdapter, StartBaseAppOptions, UiLanguage, callSiteAIFunction, createSiteAIFunctionTask, getSiteAIFunctionTask, hasRunnableMediaTask, installLinkGuard, installRouteSync, invokeSiteAIFunctionStream, normalizeSiteAIMediaTask, startBaseApp };
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{A as Ye,B as le,C as pe,D as fe,E as Se,F as Ae,G as ge,H as Ie,I as ke,J as ye,K as he,L as Re,M as Je,N as O,O as Xe,P as L,Q as Ze,R as $e,S as B,T as et,U as tt,V as N,W as U,X as nt,Y as it,Z as rt,_ as at,a as j,b as Y,c as J,d as X,e as Z,f as $,g as ee,h as x,i as D,j as te,k as ne,l as m,m as ie,n as re,o as ae,p as oe,q as se,r as ce,s as ue,t as de,u as me,v as Ke,w as v,x as We,y as Qe,z as je}from"./chunk-OF7TEKK6.js";import{a as He,b as ze,c as w,d as R}from"./chunk-ZKBZAK4L.js";import{a as qe}from"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export*from"@lark-base-open/base-site-channel/runtime";import{installLinkGuard as Fe}from"@lark-base-open/base-site-channel/runtime";function M(e={}){let t=!0,n,i=s=>{let c=R(s);e.onDiagnostic?e.onDiagnostic(c):console.warn("[Base Database SDK]",c)},a=e.runtime??m;return Promise.resolve().then(()=>a.getRuntimeContext()).then(s=>{if(t){if(!v(s,"link.open")){i(new w("link.open",1));return}n=Fe(e)}}).catch(s=>{t&&i(s)}),()=>{t=!1,n?.()}}export*from"@lark-base-open/base-site-channel/runtime-contract";import{SiteChatbotStreamError as Ot}from"@lark-base-open/base-site-channel/runtime";import*as u from"@lark-base-open/base-site-channel/runtime";var P=class extends u.SiteChatbotStreamAdapter{constructor(t){super({...t,channel:t.channel?x(t.channel):D})}},F=e=>({...e,channel:e?.channel?x(e.channel):D}),G=(e,t)=>u.callSiteAIFunction(e,F(t)),V=(e,t)=>u.invokeSiteAIFunctionStream(e,F(t)),q=(e,t)=>u.createSiteAIFunctionTask(e,F(t)),H=(e,t,n)=>u.getSiteAIFunctionTask(e,t,F(n));var Te=new Set(["cancelled","failed","queued","running","succeeded"]);async function be(e){let t=await G(e);return e.input&&!e.messages?k(t):t}function Ce(e){return V(e)}function o(e,t){for(let n of t){let i=e[n];if(typeof i=="string"&&i.trim())return i}}function xe(e,t){for(let n of t){let i=e[n];if(typeof i=="number"&&Number.isFinite(i))return i}}function De(e){let t=o(e,["capabilityType","capability_type","CapabilityType"]);return t==="image"||t==="video"?t:void 0}function Me(e){if(Array.isArray(e))return e.filter(b).map(t=>{let n=o(t,["size","Size"]),i=o(t,["token","Token"]),a=o(t,["url","URL"]);return{safetyStatus:o(t,["safetyStatus","safety_status","SafetyStatus"])??"",...n?{size:n}:{},...i?{token:i}:{},...a?{url:a}:{}}})}function Pe(e){if(!b(e))return;let t=e.durationSeconds??e.duration_seconds??e.DurationSeconds,n=o(e,["token","Token"]),i=o(e,["url","URL"]);return{...typeof t=="number"?{durationSeconds:t}:{},...n?{token:n}:{},...i?{url:i}:{}}}function T(e,t="INVALID_AI_FUNCTION_TASK"){let n=new Error(e);return n.name="SiteAIFunctionTaskError",n.code=t,n}function k(e){if(!b(e))throw T("AI Function task response has an invalid structure");let t=_e(e);if(t)throw T(t.message,t.code);if("data"in e&&e.data!==void 0)return k(e.data);let n=o(e,["type","Type"]),i=o(e,["taskId","task_id","TaskID"]),a=e.status??e.Status;if(n!=="image_task"&&n!=="video_task"||!i||typeof a!="string"||!Te.has(a))throw T("AI Function task response has an invalid structure");let s=Me(e.imageAssets??e.image_assets??e.ImageAssets),c=Pe(e.videoAsset??e.video_asset??e.VideoAsset),l=xe(e,["progress","Progress"]),I=De(e),p=o(e,["errCode","err_code","ErrCode"]),f=o(e,["errMessage","err_message","ErrMessage"]);return{...I?{capabilityType:I}:{},...p?{errCode:p}:{},...f?{errMessage:f}:{},...s?{imageAssets:s}:{},...l!==void 0?{progress:l}:{},...c?{videoAsset:c}:{},requestId:o(e,["requestId","request_id","RequestID"])??"",status:a,taskId:i,type:n}}function _e(e){let t=e.code??e.Code;if(typeof t=="number"&&t!==0||typeof t=="string"&&t&&t!=="0")return{code:String(t),message:o(e,["msg","message","Message"])??"Failed to create the AI Function task"};let n=e.BaseResp??e.base_resp??e.baseResp;if(!b(n))return;let i=n.StatusCode??n.status_code??n.statusCode;if(typeof i=="number"&&i!==0||typeof i=="string"&&i&&i!=="0")return{code:String(i),message:o(n,["StatusMessage","status_message","statusMessage"])??"Failed to create the AI Function task"}}function Ee(e){return!!e.taskId.trim()&&(e.status==="queued"||e.status==="running")}async function we(e){return k(await q(e))}async function ve(e,t){if(!t.trim())throw T("AI Function task ID must not be empty");return k(await H(e,t))}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Component as Oe,StrictMode as Le,useEffect as Be,useState as Ne}from"react";import{createRoot as Ue}from"react-dom/client";import{Fragment as Ge,jsx as d,jsxs as Ve}from"react/jsx-runtime";var _=new WeakSet,C=class extends Oe{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){this.props.failed(t)}render(){let t=this.props.fallback;return this.state.failed?t?d(t,{code:"APP_BOOT_FAILED"}):d("div",{role:"alert",children:"APP_BOOT_FAILED"}):this.props.children}};function bt(e){let t,n,i=new Promise((r,g)=>{t=r,n=g});i.catch(()=>{});let a=!1,s=!1,c=!1,l,I=()=>{},p=()=>{},f=r=>{try{e.onDiagnostic?.(R(r))}catch{}},S=r=>{f(r),!(a||s||c)&&(c=!0,n(r),e.reportLifecycle!==!1&&m.reportLoadFailed("APP_BOOT_FAILED",{appSdk:"0.5.1"}).catch(f))},A;try{A=typeof e.root=="string"?document.querySelector(e.root):e.root??document.querySelector("#root")}catch(r){return S(r),{ready:i,dispose(){a=!0}}}if(!A)return S(new Error("APP_ROOT_NOT_FOUND")),{ready:i,dispose(){a=!0}};if(_.has(A))throw new Error("APP_ALREADY_STARTED");_.add(A);let z=()=>{a||(a=!0,I(),p(),l?.unmount(),_.delete(A),N.clear(),!s&&!c&&n(new Error("APP_DISPOSED")))},K=()=>{queueMicrotask(()=>{a||c||s||(s=!0,e.reportLifecycle===!1?t():m.ready({appSdk:"0.5.1"}).then(t,r=>{f(r),n(r)}))})};function W({locale:r,theme:g}){let[y,h]=Ne();Be(()=>(p=m.subscribeModeChanged(h),K(),()=>p()),[]);let Q=e.app,E=Ve(Ge,{children:[d(Q,{}),e.platformUI===!1?null:d(U,{})]});return d(B,{runtime:m,theme:g,locale:r,mode:y,onDiagnostic:e.onDiagnostic,children:e.providers?e.providers(E):E})}try{l=Ue(A);let r=e.slots?.loading;r&&l.render(d(C,{failed:S,fallback:e.slots?.error,children:d(r,{})})),m.getRuntimeContext().then(g=>{if(a||c)return;let y=e.locale&&e.locale!=="host"?e.locale:O(g.locale,"en");document.documentElement.lang=L(y),e.linkGuard!==!1&&(I=M({onDiagnostic:e.onDiagnostic}));let h=d(C,{failed:S,fallback:e.slots?.error,children:d(W,{locale:y,theme:e.theme&&e.theme!=="host"?e.theme:g.colorScheme==="dark"?"dark":"light"})});l.render(e.strictMode===!1?h:d(Le,{children:h}))}).catch(S)}catch(r){S(r)}return{ready:i,dispose:z}}export{at as AttachmentImage,B as BaseAppProvider,He as CAPABILITY_CATALOG,w as CapabilityUnavailableError,Ie as DataNotReadyError,nt as DatabaseUserMenu,ze as DiagnosticCode,U as FloatingButton,qe as SDKError,j as SITE_RUNTIME_PROTOCOL_VERSION,P as SiteChatbotStreamAdapter,Ot as SiteChatbotStreamError,Y as SiteRuntimeApi,te as SiteRuntimeClient,Z as SiteRuntimeErrorCode,J as SiteRuntimeEvent,X as SiteRuntimeFunction,Je as UiLanguageContext,rt as UserSelectorEditor,it as UserSelectorPanel,Re as buildAttachmentCoverUrl,ge as buildDatabaseInvokeFunctionPath,Ae as buildDatabaseInvokeGetPath,be as callSiteAIFunction,R as classifyRuntimeError,we as createSiteAIFunctionTask,ne as createSiteRuntimeClient,de as createSiteRuntimeFetch,me as fetch,fe as fetchAttachmentCover,Se as fetchAttachmentDownloadUrl,We as getCapabilities,ae as getCurrentUser,le as getDatabaseContext,Qe as getRuntimeCapabilities,ve as getSiteAIFunctionTask,Xe as getUiLanguage,L as getUiLocale,v as hasCapability,Ee as hasRunnableMediaTask,Ze as initializeUiLanguage,M as installLinkGuard,re as invokeApi,ke as invokeDatabaseFunction,ye as invokeDatabaseMutationBatch,ie as invokeHttp,Ce as invokeSiteAIFunctionStream,ee as isValidSiteFunctionName,oe as logout,k as normalizeSiteAIMediaTask,he as openAttachmentDownload,ue as openLink,je as queryCapability,Ke as readCapabilities,$ as readSiteAITextDelta,se as requestEdit,Ye as requireCapability,pe as resolveDatabaseContext,O as selectUiLanguage,m as siteRuntime,bt as startBaseApp,ce as uploadAttachment,et as useBaseApp,tt as useOptionalBaseApp,$e as useUiLanguage};
1
+ import{A as Ze,B as Se,C as fe,D as ge,E as Ae,F as Ie,G as ye,H as ke,I as Re,J as he,K as Fe,L as Te,M as $e,N as B,O as et,P as U,Q as tt,R as nt,S as N,T as ot,U as it,V as G,W as V,X as at,Y as rt,Z as st,_ as ct,a as J,b as X,c as Z,d as $,e as ee,f as te,g as ne,h as x,i as _,j as oe,k as ie,l as m,m as ae,n as re,o as se,p as ce,q as ue,r as de,s as me,t as le,u as pe,v as Ye,w as L,x as je,y as Je,z as Xe}from"./chunk-EG6R7YAD.js";import{a as We,b as Qe,c as v,d as h}from"./chunk-ZKBZAK4L.js";import{a as Ke}from"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export*from"@lark-base-open/base-site-channel/runtime";import{installLinkGuard as De}from"@lark-base-open/base-site-channel/runtime";function P(e={}){let t=!0,n,o=s=>{let c=h(s);e.onDiagnostic?e.onDiagnostic(c):console.warn("[Base Database SDK]",c)},a=e.runtime??m;return Promise.resolve().then(()=>a.getRuntimeContext()).then(s=>{if(t){if(!L(s,"link.open")){o(new v("link.open",1));return}n=De(e)}}).catch(s=>{t&&o(s)}),()=>{t=!1,n?.()}}export*from"@lark-base-open/base-site-channel/runtime-contract";import{SiteChatbotStreamError as Vt}from"@lark-base-open/base-site-channel/runtime";import*as u from"@lark-base-open/base-site-channel/runtime";var M=class extends u.SiteChatbotStreamAdapter{constructor(t){super({...t,channel:t.channel?x(t.channel):_})}},F=e=>({...e,channel:e?.channel?x(e.channel):_}),q=(e,t)=>u.callSiteAIFunction(e,F(t)),H=(e,t)=>u.invokeSiteAIFunctionStream(e,F(t)),z=(e,t)=>u.createSiteAIFunctionTask(e,F(t)),K=(e,t,n)=>u.getSiteAIFunctionTask(e,t,F(n));var be=new Set(["cancelled","failed","queued","running","succeeded"]);async function Ce(e){let t=await q(e);return e.input&&!e.messages?y(t):t}function xe(e){return H(e)}function r(e,t){for(let n of t){let o=e[n];if(typeof o=="string"&&o.trim())return o}}function _e(e,t){for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return o}}function Pe(e){let t=r(e,["capabilityType","capability_type","CapabilityType"]);return t==="image"||t==="video"?t:void 0}function Me(e){if(Array.isArray(e))return e.filter(D).map(t=>{let n=r(t,["size","Size"]),o=r(t,["token","Token"]),a=r(t,["url","URL"]);return{safetyStatus:r(t,["safetyStatus","safety_status","SafetyStatus"])??"",...n?{size:n}:{},...o?{token:o}:{},...a?{url:a}:{}}})}function Ee(e){if(!D(e))return;let t=e.durationSeconds??e.duration_seconds??e.DurationSeconds,n=r(e,["token","Token"]),o=r(e,["url","URL"]);return{...typeof t=="number"?{durationSeconds:t}:{},...n?{token:n}:{},...o?{url:o}:{}}}function T(e,t="INVALID_AI_FUNCTION_TASK"){let n=new Error(e);return n.name="SiteAIFunctionTaskError",n.code=t,n}function y(e){if(!D(e))throw T("AI Function task response has an invalid structure");let t=Oe(e);if(t)throw T(t.message,t.code);if("data"in e&&e.data!==void 0)return y(e.data);let n=r(e,["type","Type"]),o=r(e,["taskId","task_id","TaskID"]),a=e.status??e.Status;if(n!=="image_task"&&n!=="video_task"||!o||typeof a!="string"||!be.has(a))throw T("AI Function task response has an invalid structure");let s=Me(e.imageAssets??e.image_assets??e.ImageAssets),c=Ee(e.videoAsset??e.video_asset??e.VideoAsset),l=_e(e,["progress","Progress"]),A=Pe(e),I=r(e,["errCode","err_code","ErrCode"]),S=r(e,["errMessage","err_message","ErrMessage"]);return{...A?{capabilityType:A}:{},...I?{errCode:I}:{},...S?{errMessage:S}:{},...s?{imageAssets:s}:{},...l!==void 0?{progress:l}:{},...c?{videoAsset:c}:{},requestId:r(e,["requestId","request_id","RequestID"])??"",status:a,taskId:o,type:n}}function Oe(e){let t=e.code??e.Code;if(typeof t=="number"&&t!==0||typeof t=="string"&&t&&t!=="0")return{code:String(t),message:r(e,["msg","message","Message"])??"Failed to create the AI Function task"};let n=e.BaseResp??e.base_resp??e.baseResp;if(!D(n))return;let o=n.StatusCode??n.status_code??n.statusCode;if(typeof o=="number"&&o!==0||typeof o=="string"&&o&&o!=="0")return{code:String(o),message:r(n,["StatusMessage","status_message","statusMessage"])??"Failed to create the AI Function task"}}function we(e){return!!e.taskId.trim()&&(e.status==="queued"||e.status==="running")}async function ve(e){return y(await z(e))}async function Le(e,t){if(!t.trim())throw T("AI Function task ID must not be empty");return y(await K(e,t))}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Component as Ue,StrictMode as Ne,useEffect as Ge,useState as Ve}from"react";import{createRoot as qe}from"react-dom/client";import{installRouteSync as Be}from"@lark-base-open/base-site-channel/runtime";function E(e={}){return Be({...e,onDiagnostic:t=>{let n={source:"sdk",code:t.code,category:t.code==="PATH_ROUTING_UNSUPPORTED"?"protocol":"unknown",retryable:t.code==="ROUTE_SYNC_UNAVAILABLE",message:t.message,redaction:"\u539F\u59CB\u9519\u8BEF\u6D88\u606F\u548C\u4E1A\u52A1\u53C2\u6570\u5DF2\u7701\u7565"};e.onDiagnostic?e.onDiagnostic(n):console.warn("[Base Database SDK]",n.message)}})}import{Fragment as He,jsx as d,jsxs as ze}from"react/jsx-runtime";var O=new WeakSet,b=class extends Ue{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){this.props.failed(t)}render(){let t=this.props.fallback;return this.state.failed?t?d(t,{code:"APP_BOOT_FAILED"}):d("div",{role:"alert",children:"APP_BOOT_FAILED"}):this.props.children}};function Mt(e){let t,n,o=new Promise((i,p)=>{t=i,n=p});o.catch(()=>{});let a=!1,s=!1,c=!1,l,A=()=>{},I=()=>{},S=()=>{},C=i=>{try{e.onDiagnostic?.(h(i))}catch{}},f=i=>{C(i),!(a||s||c)&&(c=!0,n(i),e.reportLifecycle!==!1&&m.reportLoadFailed("APP_BOOT_FAILED",{appSdk:"0.6.0-durable.0"}).catch(C))},g;try{g=typeof e.root=="string"?document.querySelector(e.root):e.root??document.querySelector("#root")}catch(i){return f(i),{ready:o,dispose(){a=!0}}}if(!g)return f(new Error("APP_ROOT_NOT_FOUND")),{ready:o,dispose(){a=!0}};if(O.has(g))throw new Error("APP_ALREADY_STARTED");O.add(g);let W=()=>{a||(a=!0,A(),I(),S(),l?.unmount(),O.delete(g),G.clear(),!s&&!c&&n(new Error("APP_DISPOSED")))},Q=()=>{queueMicrotask(()=>{a||c||s||(s=!0,e.reportLifecycle===!1?t():m.ready({appSdk:"0.6.0-durable.0"}).then(t,i=>{C(i),n(i)}))})};function Y({locale:i,theme:p}){let[k,R]=Ve();Ge(()=>(S=m.subscribeModeChanged(R),Q(),()=>S()),[]);let j=e.app,w=ze(He,{children:[d(j,{}),e.platformUI===!1?null:d(V,{})]});return d(N,{runtime:m,theme:p,styleScope:e.styleScope,locale:i,mode:k,onDiagnostic:e.onDiagnostic,children:e.providers?e.providers(w):w})}try{l=qe(g);let i=e.slots?.loading;i&&l.render(d(b,{failed:f,fallback:e.slots?.error,children:d(i,{})})),m.getRuntimeContext().then(p=>{if(a||c)return;let k=e.locale&&e.locale!=="host"?e.locale:B(p.locale,"en");document.documentElement.lang=U(k),e.linkGuard!==!1&&(A=P({onDiagnostic:e.onDiagnostic})),e.routeSync!==!1&&(I=E({context:p,onDiagnostic:e.onDiagnostic}));let R=d(b,{failed:f,fallback:e.slots?.error,children:d(Y,{locale:k,theme:e.theme&&e.theme!=="host"?e.theme:p.colorScheme==="dark"?"dark":"light"})});l.render(e.strictMode===!1?R:d(Ne,{children:R}))}).catch(f)}catch(i){f(i)}return{ready:o,dispose:W}}export{ct as AttachmentImage,N as BaseAppProvider,We as CAPABILITY_CATALOG,v as CapabilityUnavailableError,ke as DataNotReadyError,at as DatabaseUserMenu,Qe as DiagnosticCode,V as FloatingButton,Ke as SDKError,J as SITE_RUNTIME_PROTOCOL_VERSION,M as SiteChatbotStreamAdapter,Vt as SiteChatbotStreamError,X as SiteRuntimeApi,oe as SiteRuntimeClient,ee as SiteRuntimeErrorCode,Z as SiteRuntimeEvent,$ as SiteRuntimeFunction,$e as UiLanguageContext,st as UserSelectorEditor,rt as UserSelectorPanel,Te as buildAttachmentCoverUrl,ye as buildDatabaseInvokeFunctionPath,Ie as buildDatabaseInvokeGetPath,Ce as callSiteAIFunction,h as classifyRuntimeError,ve as createSiteAIFunctionTask,ie as createSiteRuntimeClient,le as createSiteRuntimeFetch,pe as fetch,ge as fetchAttachmentCover,Ae as fetchAttachmentDownloadUrl,je as getCapabilities,se as getCurrentUser,Se as getDatabaseContext,Je as getRuntimeCapabilities,Le as getSiteAIFunctionTask,et as getUiLanguage,U as getUiLocale,L as hasCapability,we as hasRunnableMediaTask,tt as initializeUiLanguage,P as installLinkGuard,E as installRouteSync,re as invokeApi,Re as invokeDatabaseFunction,he as invokeDatabaseMutationBatch,ae as invokeHttp,xe as invokeSiteAIFunctionStream,ne as isValidSiteFunctionName,ce as logout,y as normalizeSiteAIMediaTask,Fe as openAttachmentDownload,me as openLink,Xe as queryCapability,Ye as readCapabilities,te as readSiteAITextDelta,ue as requestEdit,Ze as requireCapability,fe as resolveDatabaseContext,B as selectUiLanguage,m as siteRuntime,Mt as startBaseApp,de as uploadAttachment,ot as useBaseApp,it as useOptionalBaseApp,nt as useUiLanguage};
package/dist/theme.css CHANGED
@@ -12,9 +12,6 @@
12
12
  --base-app-z-popover: 1000;
13
13
  --base-app-z-floating: 900;
14
14
  --base-app-shadow: 0 4px 20px #0002;
15
- color: var(--base-app-color-fg);
16
- font: var(--base-app-font-size) / 1.5 var(--base-app-font-family);
17
- box-sizing: border-box;
18
15
  }
19
16
  .base-app-platform[data-theme="dark"],
20
17
  [data-theme="dark"] .base-app-platform {
@@ -33,7 +30,12 @@
33
30
  --base-app-color-accent: #7da6ff;
34
31
  }
35
32
  }
36
- .base-app-platform button {
33
+ .base-app-platform:where(:not([data-base-app-style-scope="components"])) {
34
+ color: var(--base-app-color-fg);
35
+ font: var(--base-app-font-size) / 1.5 var(--base-app-font-family);
36
+ box-sizing: border-box;
37
+ }
38
+ .base-app-platform:where(:not([data-base-app-style-scope="components"])) button {
37
39
  font: inherit;
38
40
  color: inherit;
39
41
  background: var(--base-app-color-bg);
@@ -42,8 +44,16 @@
42
44
  padding: 6px 10px;
43
45
  cursor: pointer;
44
46
  }
45
- .base-app-platform button:focus-visible,
46
- .base-app-platform input:focus-visible {
47
+ button.base-app-platform {
48
+ background: var(--base-app-color-bg);
49
+ border: 1px solid var(--base-app-color-border);
50
+ border-radius: var(--base-app-radius);
51
+ padding: 6px 10px;
52
+ cursor: pointer;
53
+ }
54
+ .base-app-platform:where(:not([data-base-app-style-scope="components"])) button:focus-visible,
55
+ .base-app-platform:where(:not([data-base-app-style-scope="components"])) input:focus-visible,
56
+ button.base-app-platform:focus-visible {
47
57
  outline: 2px solid var(--base-app-color-accent);
48
58
  outline-offset: 2px;
49
59
  }
@@ -277,11 +287,11 @@
277
287
  .base-app-attachment img {
278
288
  max-width: 100%;
279
289
  }
280
- .base-app-platform [role="alert"] {
290
+ .base-app-platform:where(:not([data-base-app-style-scope="components"])) [role="alert"] {
281
291
  color: var(--base-app-color-danger);
282
292
  }
283
293
  @media (prefers-reduced-motion: reduce) {
284
- .base-app-platform * {
294
+ .base-app-platform:where(:not([data-base-app-style-scope="components"])) * {
285
295
  animation: none !important;
286
296
  transition: none !important;
287
297
  }
@@ -33,3 +33,7 @@ export function Details({ attachment }: { attachment: DatabaseAttachmentRef }) {
33
33
  </BaseAppProvider>;
34
34
  }
35
35
  ```
36
+
37
+ ## 业务样式隔离
38
+
39
+ `BaseAppProvider` 支持 `styleScope: 'legacy' | 'components'`。默认 legacy 保持既有基础样式;components 仅给 SDK 组件施加样式。外层 `.base-app-platform` 类名、`data-theme` 和主题变量不变,已有业务 token 映射继续有效。独立 Provider 的 host 主题按浏览器媒体查询解析,startBaseApp 的 host 按宿主 RuntimeContext 解析。
@@ -0,0 +1,54 @@
1
+ # Base Site Durable SDK
2
+
3
+ 供 Base Site 的 Durable Function 源码使用。Workflow 定义执行顺序和等待,Activity 执行网络请求、站点 Function 调用等业务操作。执行由 DevCenter 管理的 Worker 承载。
4
+
5
+ Durable 是 App SDK 的两个子入口。预发布版本 0.6.0-durable.0 使用 npm 的 durable 标签。使用前需确认目标平台已部署匹配的 Durable 运行时。
6
+
7
+ ## 构建与安装
8
+
9
+ 安装此预发布版本:`npm install @lark-base-open/base-database-app-sdk@0.6.0-durable.0`。
10
+
11
+ 本地开发 SDK 时,在 SDK 根目录执行 `npm ci`、`npm run build`、`npm pack`。构建完成类型检查、JS 编译和公开声明生成。在使用项目中通过 `npm install <tarball-path>` 安装。Temporal 是可选 peer。开发时若直接加载 Durable 模块,需要安装 `@temporalio/workflow@1.24.0` 与 `@temporalio/activity@1.24.0`;只做公开类型检查不需要加载它们。托管 Worker 负责提供匹配版本,当前固定为 1.24.0。
12
+
13
+ Durable 使用 `/durable/workflow` 和 `/durable/activity` 两个入口。Workflow API 在 Temporal Workflow 执行上下文内使用,Activity API 在托管 Worker 的 Activity 上下文内使用;普通 Node 进程中的 import 成功不代表任务可以执行。
14
+
15
+ ## 编排与步骤
16
+
17
+ `workflow.ts`:
18
+
19
+ <!-- example: durable-workflow.ts -->
20
+ ```ts
21
+ import { callStep, reportProgress, sleep } from '@lark-base-open/base-database-app-sdk/durable/workflow';
22
+
23
+ export default async function task(input: { value: number }) {
24
+ const result = await callStep<number>('double', input, { key: 'double-input' });
25
+ reportProgress({ processed: 1, total: 1 });
26
+ await sleep(1000);
27
+ return result;
28
+ }
29
+ ```
30
+
31
+ `activities.ts`:
32
+
33
+ <!-- example: durable-activities.ts -->
34
+ ```ts
35
+ export async function double(input: { value: number }): Promise<number> {
36
+ return input.value * 2;
37
+ }
38
+ ```
39
+
40
+ 在对应 Function 的 `meta.json` 中声明 `double` Activity 的 timeout 和 retry.maximumAttempts。输入 Schema、发布方式和任务调用接口由 Site/DevCenter 契约管理。
41
+
42
+ `callStep` 的 key 在同一次 Workflow 中必须唯一;等待使用 SDK 的 `sleep` 或 `waitForEvent`,外部 I/O 放入 Activity。暂停在 SDK 边界生效,不中断已经开始执行的 Activity。
43
+
44
+ ## 站点能力
45
+
46
+ Activity 通过 `invokeFunction(functionId, input, { key })` 调用同一站点的普通 Function,input 与普通调用请求体一致,例如 `{ params: { city: '北京' } }`。key 表示同一个业务调用,Activity 重试时保持不变。平台注入调用通道和执行凭证,业务源码不传 token。
47
+
48
+ 请求结果未知时 Activity 可能重试。稳定 key 不等于业务端已经去重,写操作仍须由 Function 实现幂等处理。
49
+
50
+ ## 类型维护
51
+
52
+ 公开声明由 TypeScript 源码生成,内部启动器接口不出现在公开声明中。修改源码后执行 `npm run build`。平台私有传输实现不进入 SDK tarball。
53
+
54
+ SDK 的构建、声明与打包测试由本目录独立维护。执行端消费本包的 tarball;平台凭证传输和 Worker 管理不进入此包。
package/docs/exports.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  ## page
6
6
 
7
- 值:`AttachmentImage`、`BaseAppProvider`、`CAPABILITY_CATALOG`、`CapabilityUnavailableError`、`DataNotReadyError`、`DatabaseUserMenu`、`DiagnosticCode`、`FloatingButton`、`SDKError`、`SITE_RUNTIME_PROTOCOL_VERSION`、`SiteChatbotStreamAdapter`、`SiteChatbotStreamError`、`SiteRuntimeApi`、`SiteRuntimeClient`、`SiteRuntimeErrorCode`、`SiteRuntimeEvent`、`SiteRuntimeFunction`、`SiteRuntimeInvocationError`、`UiLanguageContext`、`UserSelectorEditor`、`UserSelectorPanel`、`buildAttachmentCoverUrl`、`buildDatabaseInvokeFunctionPath`、`buildDatabaseInvokeGetPath`、`callSiteAIFunction`、`classifyRuntimeError`、`createSiteAIFunctionTask`、`createSiteRuntimeClient`、`createSiteRuntimeFetch`、`fetch`、`fetchAttachmentCover`、`fetchAttachmentDownloadUrl`、`getCapabilities`、`getCurrentUser`、`getDatabaseContext`、`getRuntimeCapabilities`、`getSiteAIFunctionTask`、`getUiLanguage`、`getUiLocale`、`hasCapability`、`hasRunnableMediaTask`、`initializeUiLanguage`、`installLinkGuard`、`invokeApi`、`invokeDatabaseFunction`、`invokeDatabaseMutationBatch`、`invokeHttp`、`invokeSiteAIFunctionStream`、`isValidSiteFunctionName`、`logout`、`normalizeSiteAIMediaTask`、`openAttachmentDownload`、`openLink`、`queryCapability`、`readCapabilities`、`readSiteAITextDelta`、`requestEdit`、`requireCapability`、`resolveDatabaseContext`、`selectUiLanguage`、`siteRuntime`、`startBaseApp`、`uploadAttachment`、`useBaseApp`、`useOptionalBaseApp`、`useUiLanguage`。
7
+ 值:`AttachmentImage`、`BaseAppProvider`、`CAPABILITY_CATALOG`、`CapabilityUnavailableError`、`DataNotReadyError`、`DatabaseUserMenu`、`DiagnosticCode`、`FloatingButton`、`SDKError`、`SITE_RUNTIME_PROTOCOL_VERSION`、`SiteChatbotStreamAdapter`、`SiteChatbotStreamError`、`SiteRuntimeApi`、`SiteRuntimeClient`、`SiteRuntimeErrorCode`、`SiteRuntimeEvent`、`SiteRuntimeFunction`、`SiteRuntimeInvocationError`、`UiLanguageContext`、`UserSelectorEditor`、`UserSelectorPanel`、`buildAttachmentCoverUrl`、`buildDatabaseInvokeFunctionPath`、`buildDatabaseInvokeGetPath`、`callSiteAIFunction`、`classifyRuntimeError`、`createSiteAIFunctionTask`、`createSiteRuntimeClient`、`createSiteRuntimeFetch`、`fetch`、`fetchAttachmentCover`、`fetchAttachmentDownloadUrl`、`getCapabilities`、`getCurrentUser`、`getDatabaseContext`、`getRuntimeCapabilities`、`getSiteAIFunctionTask`、`getUiLanguage`、`getUiLocale`、`hasCapability`、`hasRunnableMediaTask`、`initializeUiLanguage`、`installLinkGuard`、`installRouteSync`、`invokeApi`、`invokeDatabaseFunction`、`invokeDatabaseMutationBatch`、`invokeHttp`、`invokeSiteAIFunctionStream`、`isValidSiteFunctionName`、`logout`、`normalizeSiteAIMediaTask`、`openAttachmentDownload`、`openLink`、`queryCapability`、`readCapabilities`、`readSiteAITextDelta`、`requestEdit`、`requireCapability`、`resolveDatabaseContext`、`selectUiLanguage`、`siteRuntime`、`startBaseApp`、`uploadAttachment`、`useBaseApp`、`useOptionalBaseApp`、`useUiLanguage`。
8
8
 
9
- 类型与值完整清单:`AttachmentImage`、`BaseAppContextValue`、`BaseAppHandle`、`BaseAppProvider`、`CAPABILITY_CATALOG`、`CallSiteAIFunctionParams`、`CapabilityContext`、`CapabilityDescriptor`、`CapabilityMap`、`CapabilityName`、`CapabilityQueryResult`、`CapabilityUnavailableError`、`CapabilityUnavailableReason`、`DataNotReadyError`、`DatabaseAttachmentRef`、`DatabaseAudience`、`DatabaseContext`、`DatabaseEnv`、`DatabaseFunctionInputMap`、`DatabaseFunctionInvocation`、`DatabaseFunctionOptions`、`DatabaseFunctionOutputMap`、`DatabaseFunctionResponse`、`DatabaseMutationResult`、`DatabaseQueryResult`、`DatabaseUserMenu`、`DatabaseUserMenuProps`、`DevelopmentPairChallenge`、`DevelopmentPairProof`、`DiagnosticCategory`、`DiagnosticCode`、`FloatingButton`、`FloatingButtonProps`、`FunctionEnvelope`、`FunctionInputMap`、`FunctionMap`、`FunctionOutputMap`、`InvokeSiteAIFunctionStreamParams`、`JsonValue`、`LinkGuardOptions`、`MutationFunctionId`、`MutationFunctionMap`、`RuntimeCapabilities`、`RuntimeChannel`、`RuntimeContextReader`、`RuntimeDiagnostic`、`SDKError`、`SDKErrorOptions`、`SITE_RUNTIME_PROTOCOL_VERSION`、`SiteAIAudioContentPart`、`SiteAICapabilityType`、`SiteAIFileContentPart`、`SiteAIFunctionArguments`、`SiteAIFunctionError`、`SiteAIFunctionOptions`、`SiteAIFunctionParams`、`SiteAIFunctionResult`、`SiteAIFunctionStreamCloseRequest`、`SiteAIFunctionStreamDone`、`SiteAIFunctionStreamError`、`SiteAIFunctionStreamHandle`、`SiteAIFunctionStreamMessage`、`SiteAIFunctionStreamOpenRequest`、`SiteAIFunctionVariables`、`SiteAIImageAsset`、`SiteAIImageContentPart`、`SiteAIImageGenerationInput`、`SiteAIImageTask`、`SiteAIMediaTask`、`SiteAIMediaTaskBase`、`SiteAIMessage`、`SiteAIMessageContentPart`、`SiteAIStreamDelta`、`SiteAIStreamMessageParam`、`SiteAITaskStatus`、`SiteAITextContentPart`、`SiteAITextDelta`、`SiteAITextMessageParam`、`SiteAIUserMessageParam`、`SiteAIVideoAsset`、`SiteAIVideoContentPart`、`SiteAIVideoGenerationInput`、`SiteAIVideoTask`、`SiteAttachmentTarget`、`SiteAttachmentUploadCancelRequest`、`SiteAttachmentUploadOptions`、`SiteAttachmentUploadPayload`、`SiteAttachmentUploadProgress`、`SiteAttachmentUploadRequest`、`SiteAttachmentUploadResult`、`SiteChatbotStreamAdapter`、`SiteChatbotStreamCloseRequest`、`SiteChatbotStreamError`、`SiteChatbotStreamMessage`、`SiteChatbotStreamOpenRequest`、`SiteFunctionDefinition`、`SiteFunctionInvokeRequest`、`SiteFunctionValidationIssue`、`SiteHttpCancelRequest`、`SiteHttpMethod`、`SiteHttpRequest`、`SiteHttpRequestInit`、`SiteHttpRequestOptions`、`SiteHttpResponse`、`SiteHttpResponseType`、`SiteOpenLinkRequest`、`SiteOpenLinkResult`、`SiteProjectEnv`、`SiteRuntimeApi`、`SiteRuntimeClient`、`SiteRuntimeContext`、`SiteRuntimeDiagnostic`、`SiteRuntimeError`、`SiteRuntimeErrorCode`、`SiteRuntimeEvent`、`SiteRuntimeFunction`、`SiteRuntimeInvocationError`、`SiteRuntimeLoadFailedEvent`、`SiteRuntimeModeChangedEvent`、`SiteRuntimeReadyEvent`、`SiteRuntimeUserInfo`、`SiteRuntimeVersions`、`StartBaseAppOptions`、`UiLanguage`、`UiLanguageContext`、`User`、`UserSelectorAction`、`UserSelectorEditor`、`UserSelectorEditorProps`、`UserSelectorEditorValue`、`UserSelectorMode`、`UserSelectorPanel`、`UserSelectorPanelProps`、`UserSelectorSearchAction`、`UserSelectorValue`、`WriteResult`、`buildAttachmentCoverUrl`、`buildDatabaseInvokeFunctionPath`、`buildDatabaseInvokeGetPath`、`callSiteAIFunction`、`classifyRuntimeError`、`createSiteAIFunctionTask`、`createSiteRuntimeClient`、`createSiteRuntimeFetch`、`fetch`、`fetchAttachmentCover`、`fetchAttachmentDownloadUrl`、`getCapabilities`、`getCurrentUser`、`getDatabaseContext`、`getRuntimeCapabilities`、`getSiteAIFunctionTask`、`getUiLanguage`、`getUiLocale`、`hasCapability`、`hasRunnableMediaTask`、`initializeUiLanguage`、`installLinkGuard`、`invokeApi`、`invokeDatabaseFunction`、`invokeDatabaseMutationBatch`、`invokeHttp`、`invokeSiteAIFunctionStream`、`isValidSiteFunctionName`、`logout`、`normalizeSiteAIMediaTask`、`openAttachmentDownload`、`openLink`、`queryCapability`、`readCapabilities`、`readSiteAITextDelta`、`requestEdit`、`requireCapability`、`resolveDatabaseContext`、`selectUiLanguage`、`siteRuntime`、`startBaseApp`、`uploadAttachment`、`useBaseApp`、`useOptionalBaseApp`、`useUiLanguage`。
9
+ 类型与值完整清单:`AttachmentImage`、`BaseAppContextValue`、`BaseAppHandle`、`BaseAppProvider`、`CAPABILITY_CATALOG`、`CallSiteAIFunctionParams`、`CapabilityContext`、`CapabilityDescriptor`、`CapabilityMap`、`CapabilityName`、`CapabilityQueryResult`、`CapabilityUnavailableError`、`CapabilityUnavailableReason`、`DataNotReadyError`、`DatabaseAttachmentRef`、`DatabaseAudience`、`DatabaseContext`、`DatabaseEnv`、`DatabaseFunctionInputMap`、`DatabaseFunctionInvocation`、`DatabaseFunctionOptions`、`DatabaseFunctionOutputMap`、`DatabaseFunctionResponse`、`DatabaseMutationResult`、`DatabaseQueryResult`、`DatabaseUserMenu`、`DatabaseUserMenuProps`、`DevelopmentPairChallenge`、`DevelopmentPairProof`、`DiagnosticCategory`、`DiagnosticCode`、`FloatingButton`、`FloatingButtonProps`、`FunctionEnvelope`、`FunctionInputMap`、`FunctionMap`、`FunctionOutputMap`、`InvokeSiteAIFunctionStreamParams`、`JsonValue`、`LinkGuardOptions`、`MutationFunctionId`、`MutationFunctionMap`、`RouteSyncDiagnostic`、`RouteSyncOptions`、`RuntimeCapabilities`、`RuntimeChannel`、`RuntimeContextReader`、`RuntimeDiagnostic`、`SDKError`、`SDKErrorOptions`、`SITE_RUNTIME_PROTOCOL_VERSION`、`SiteAIAudioContentPart`、`SiteAICapabilityType`、`SiteAIFileContentPart`、`SiteAIFunctionArguments`、`SiteAIFunctionError`、`SiteAIFunctionOptions`、`SiteAIFunctionParams`、`SiteAIFunctionResult`、`SiteAIFunctionStreamCloseRequest`、`SiteAIFunctionStreamDone`、`SiteAIFunctionStreamError`、`SiteAIFunctionStreamHandle`、`SiteAIFunctionStreamMessage`、`SiteAIFunctionStreamOpenRequest`、`SiteAIFunctionVariables`、`SiteAIImageAsset`、`SiteAIImageContentPart`、`SiteAIImageGenerationInput`、`SiteAIImageTask`、`SiteAIMediaTask`、`SiteAIMediaTaskBase`、`SiteAIMessage`、`SiteAIMessageContentPart`、`SiteAIStreamDelta`、`SiteAIStreamMessageParam`、`SiteAITaskStatus`、`SiteAITextContentPart`、`SiteAITextDelta`、`SiteAITextMessageParam`、`SiteAIUserMessageParam`、`SiteAIVideoAsset`、`SiteAIVideoContentPart`、`SiteAIVideoGenerationInput`、`SiteAIVideoTask`、`SiteAttachmentTarget`、`SiteAttachmentUploadCancelRequest`、`SiteAttachmentUploadOptions`、`SiteAttachmentUploadPayload`、`SiteAttachmentUploadProgress`、`SiteAttachmentUploadRequest`、`SiteAttachmentUploadResult`、`SiteChatbotStreamAdapter`、`SiteChatbotStreamCloseRequest`、`SiteChatbotStreamError`、`SiteChatbotStreamMessage`、`SiteChatbotStreamOpenRequest`、`SiteFunctionDefinition`、`SiteFunctionInvokeRequest`、`SiteFunctionValidationIssue`、`SiteHttpCancelRequest`、`SiteHttpMethod`、`SiteHttpRequest`、`SiteHttpRequestInit`、`SiteHttpRequestOptions`、`SiteHttpResponse`、`SiteHttpResponseType`、`SiteOpenLinkRequest`、`SiteOpenLinkResult`、`SiteProjectEnv`、`SiteRouteChangedEvent`、`SiteRuntimeApi`、`SiteRuntimeClient`、`SiteRuntimeContext`、`SiteRuntimeDiagnostic`、`SiteRuntimeError`、`SiteRuntimeErrorCode`、`SiteRuntimeEvent`、`SiteRuntimeFunction`、`SiteRuntimeInvocationError`、`SiteRuntimeLoadFailedEvent`、`SiteRuntimeModeChangedEvent`、`SiteRuntimeReadyEvent`、`SiteRuntimeUserInfo`、`SiteRuntimeVersions`、`StartBaseAppOptions`、`UiLanguage`、`UiLanguageContext`、`User`、`UserSelectorAction`、`UserSelectorEditor`、`UserSelectorEditorProps`、`UserSelectorEditorValue`、`UserSelectorMode`、`UserSelectorPanel`、`UserSelectorPanelProps`、`UserSelectorSearchAction`、`UserSelectorValue`、`WriteResult`、`buildAttachmentCoverUrl`、`buildDatabaseInvokeFunctionPath`、`buildDatabaseInvokeGetPath`、`callSiteAIFunction`、`classifyRuntimeError`、`createSiteAIFunctionTask`、`createSiteRuntimeClient`、`createSiteRuntimeFetch`、`fetch`、`fetchAttachmentCover`、`fetchAttachmentDownloadUrl`、`getCapabilities`、`getCurrentUser`、`getDatabaseContext`、`getRuntimeCapabilities`、`getSiteAIFunctionTask`、`getUiLanguage`、`getUiLocale`、`hasCapability`、`hasRunnableMediaTask`、`initializeUiLanguage`、`installLinkGuard`、`installRouteSync`、`invokeApi`、`invokeDatabaseFunction`、`invokeDatabaseMutationBatch`、`invokeHttp`、`invokeSiteAIFunctionStream`、`isValidSiteFunctionName`、`logout`、`normalizeSiteAIMediaTask`、`openAttachmentDownload`、`openLink`、`queryCapability`、`readCapabilities`、`readSiteAITextDelta`、`requestEdit`、`requireCapability`、`resolveDatabaseContext`、`selectUiLanguage`、`siteRuntime`、`startBaseApp`、`uploadAttachment`、`useBaseApp`、`useOptionalBaseApp`、`useUiLanguage`。
10
10
 
11
11
  ## server
12
12
 
@@ -43,3 +43,15 @@
43
43
  值:`CodegenError`、`SUPPORTED_CONTRACT_FORMAT_VERSIONS`、`generateFunctionClients`、`validateContractData`。
44
44
 
45
45
  类型与值完整清单:`ClientContract`、`CodegenError`、`FunctionContractData`、`FunctionInputContract`、`GeneratedFile`、`SUPPORTED_CONTRACT_FORMAT_VERSIONS`、`generateFunctionClients`、`validateContractData`。
46
+
47
+ ## durable/workflow
48
+
49
+ 值:`callStep`、`reportProgress`、`sleep`、`waitForEvent`。
50
+
51
+ 类型与值完整清单:`callStep`、`reportProgress`、`sleep`、`waitForEvent`。
52
+
53
+ ## durable/activity
54
+
55
+ 值:`cancellationSignal`、`getAttempt`、`invokeFunction`。
56
+
57
+ 类型与值完整清单:`cancellationSignal`、`getAttempt`、`invokeFunction`。
@@ -2,9 +2,15 @@
2
2
 
3
3
  从 `/page` 导入 [`startBaseApp`](exports.md#page),传入 `app: App`(React ComponentType),通过 `/page/styles.css` 加载组件样式。SDK 不认识业务 App 的路径,也不会在 Node 侧执行业务代码。返回 `{ ready, dispose }`;ready 是首次 React effect 提交后的宿主通知 Promise。调用者应处理 ready 拒绝,并在热替换或移除页面时 dispose。
4
4
 
5
- 选项与默认值:root 为 `#root`(可传选择器或 HTMLElement);strictMode、linkGuard、reportLifecycle、platformUI 均为 true。theme 为 host,取宿主 colorScheme;locale 为 host,取宿主语言,不支持的语言映射 en。locale 可显式设 zh/en/ja,theme 可设 light/dark。providers 接收 ReactNode 并返回包裹后的 ReactNode;slots.loading 与 slots.error 接受 React 组件,error 只收到安全 code。onDiagnostic 接收 SDK 的脱敏 [`RuntimeDiagnostic`](exports.md#page)。
5
+ 选项与默认值:root 为 `#root`(可传选择器或 HTMLElement);strictMode、linkGuard、routeSync、reportLifecycle、platformUI 均为 true。theme 为 host,取宿主 colorScheme;locale 为 host,取宿主语言,不支持的语言映射 en。locale 可显式设 zh/en/ja,theme 可设 light/dark。providers 接收 ReactNode 并返回包裹后的 ReactNode;slots.loading 与 slots.error 接受 React 组件,error 只收到安全 code。onDiagnostic 接收 SDK 的脱敏 [`RuntimeDiagnostic`](exports.md#page)。
6
6
 
7
- 顺序:解析 root、发起 channel 上下文请求、能力感知链接拦截、Provider/错误边界/App、首次 effect 后 ready。StrictMode 不重复上报。启动错误报 APP_BOOT_FAILED;ready 之后的业务错误只交 onDiagnostic。root 缺失使 ready 拒绝,重复挂载同一 root 同步抛 APP_ALREADY_STARTED。dispose 幂等,卸载 React、退订 mode、清理链接拦截和 UI 缓存;ready 前 dispose 使 ready 拒绝 APP_DISPOSED。共享 channel 连接不销毁,以免影响同页面其他调用者。
7
+ `styleScope` 默认 `legacy`,保留业务内容从 `.base-app-platform` 继承的基础样式。
8
+ 新工程使用 `styleScope: 'components'`:外层仍保留 `.base-app-platform`、`data-theme` 和所有 `--base-app-*` 变量,
9
+ 但不再给业务内容设置文字、字体、按钮、输入焦点和告警样式;业务根容器必须成对声明背景和文字颜色。
10
+ SDK 组件自身仍按 Provider 主题渲染。`theme` 默认仍是 `host`,固定浅色显式写 `theme: 'light'`。
11
+ 业务要跟随主题时,在业务根容器映射 `--base-app-color-bg/fg/muted/border`,不要只切换背景或只切换文字。
12
+
13
+ 顺序:解析 root、发起 channel 上下文请求、能力感知链接拦截与路由同步、Provider/错误边界/App、首次 effect 后 ready。StrictMode 不重复上报。启动错误报 APP_BOOT_FAILED;ready 之后的业务错误只交 onDiagnostic。root 缺失使 ready 拒绝,重复挂载同一 root 同步抛 APP_ALREADY_STARTED。dispose 幂等,卸载 React、退订 mode、清理链接拦截、路由监听和 UI 缓存;ready 前 dispose 使 ready 拒绝 APP_DISPOSED。共享 channel 连接不销毁,以免影响同页面其他调用者。
8
14
 
9
15
  linkGuard:false 完全不安装拦截;能力不支持时 SDK 同样保持原生行为。reportLifecycle:false 不发 ready/load-failed,但 ready Promise 仍表达本地挂载结果。platformUI:false 隐藏默认悬浮按钮,不改变权限或宿主开发标识。关闭选项用于迁移中明确选择行为。
10
16
 
@@ -43,3 +49,18 @@ export const plugins = [baseAppDevelopmentPairingPlugin()];
43
49
  ## 生命周期版本上报(0.5.0)
44
50
 
45
51
  应用启动成功或失败时会自动报告 SDK 版本,便于排查问题,无需新增配置。
52
+
53
+
54
+ ## 页面地址与路由同步
55
+
56
+ 站点使用 hash 路由(例如 react-router 的 `createHashRouter` 或 `HashRouter`)。宿主将外层 `/baseapp/<app-token>/orders/123?status=open` 映射为产物 URL 的 `#/orders/123?status=open`;iframe 内重载仍只请求产物根路径。路由与查询参数会进入地址栏、分享链接和网关日志,不放置令牌、密钥或不宜分享的数据。
57
+
58
+ `startBaseApp` 默认安装 `installRouteSync`,`routeSync:false` 关闭。它包装 history.pushState/replaceState 并监听 popstate/hashchange,微任务合并重复变化;仅宿主显式声明 `runtime.route` 能力时回报。能力表缺失或为空时不发送路由事件。首报读取安装后的当前 hash,覆盖先于安装完成的初始重定向。dispose 还原监听和仍属于本安装的 history 包装。
59
+
60
+ `installRouteSync` 也从 `/page` 独立导出,供保留自有 bootstrap 的页面安装一次并在卸载时清理;通过 startBaseApp 启动时不再重复安装。`onDiagnostic` 接收固定英文 `PATH_ROUTING_UNSUPPORTED` 诊断,提示将 BrowserRouter 改为 hash router;诊断不包含原始地址或查询参数。
61
+
62
+ 同标签 hash 导航保持原生行为。配套 linkGuard 将 `#/...` 链接的中键、修饰键、新标签页和 window.open 请求交给 OpenLink,宿主负责转换为对应的外层地址;普通 `#section` 锚点不参与路由。
63
+
64
+ 路由同步与 linkGuard 独立:`routeSync:false` 只关闭路由回报。支持 OpenLink 但没有深链接转换能力的旧宿主可能仍打开 CDN 产物地址,不会自动变成可分享的站点链接。需要保留原生链接处理时另设 `linkGuard:false`;这也会关闭其他链接拦截,并不补齐旧宿主的深链接能力。
65
+
66
+ 原生右键菜单的“在新标签页中打开”和“复制链接地址”直接使用元素的 `href`,不会经过点击拦截。需要这些操作得到站点子页面链接时,应让 `href` 指向可分享的宿主地址。
@@ -0,0 +1,3 @@
1
+ export async function double(input: { value: number }): Promise<number> {
2
+ return input.value * 2;
3
+ }
@@ -0,0 +1,8 @@
1
+ import { callStep, reportProgress, sleep } from '@lark-base-open/base-database-app-sdk/durable/workflow';
2
+
3
+ export default async function task(input: { value: number }) {
4
+ const result = await callStep<number>('double', input, { key: 'double-input' });
5
+ reportProgress({ processed: 1, total: 1 });
6
+ await sleep(1000);
7
+ return result;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-base-open/base-database-app-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.6.0-durable.0",
4
4
  "description": "Base Database 页面与服务端 SDK、平台组件及测试工具",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -54,6 +54,26 @@
54
54
  "types": "./dist/codegen.d.cts",
55
55
  "default": "./dist/codegen.cjs"
56
56
  }
57
+ },
58
+ "./durable/workflow": {
59
+ "import": {
60
+ "types": "./dist/durable/workflow.d.cts",
61
+ "default": "./dist/durable/workflow.cjs"
62
+ },
63
+ "require": {
64
+ "types": "./dist/durable/workflow.d.cts",
65
+ "default": "./dist/durable/workflow.cjs"
66
+ }
67
+ },
68
+ "./durable/activity": {
69
+ "import": {
70
+ "types": "./dist/durable/activity.d.cts",
71
+ "default": "./dist/durable/activity.cjs"
72
+ },
73
+ "require": {
74
+ "types": "./dist/durable/activity.d.cts",
75
+ "default": "./dist/durable/activity.cjs"
76
+ }
57
77
  }
58
78
  },
59
79
  "files": [
@@ -67,7 +87,7 @@
67
87
  "development-pairing.json"
68
88
  ],
69
89
  "dependencies": {
70
- "@lark-base-open/base-site-channel": "0.2.0",
90
+ "@lark-base-open/base-site-channel": "0.2.1",
71
91
  "@radix-ui/react-popover": "1.2.0",
72
92
  "@standard-schema/spec": "1.0.0",
73
93
  "cmdk": "1.1.1",
@@ -77,11 +97,19 @@
77
97
  "@tanstack/react-query": "5.104.1",
78
98
  "msw": "2.11.6",
79
99
  "react": "^19.2.0",
80
- "react-dom": "^19.2.0"
100
+ "react-dom": "^19.2.0",
101
+ "@temporalio/activity": "1.24.0",
102
+ "@temporalio/workflow": "1.24.0"
81
103
  },
82
104
  "peerDependenciesMeta": {
83
105
  "msw": {
84
106
  "optional": true
107
+ },
108
+ "@temporalio/activity": {
109
+ "optional": true
110
+ },
111
+ "@temporalio/workflow": {
112
+ "optional": true
85
113
  }
86
114
  },
87
115
  "typesVersions": {
@@ -94,6 +122,12 @@
94
122
  ],
95
123
  "codegen": [
96
124
  "dist/codegen.d.cts"
125
+ ],
126
+ "durable/workflow": [
127
+ "dist/durable/workflow.d.ts"
128
+ ],
129
+ "durable/activity": [
130
+ "dist/durable/activity.d.ts"
97
131
  ]
98
132
  }
99
133
  }
@@ -1 +0,0 @@
1
- import{a as He,b as re,c as ze}from"./chunk-ZKBZAK4L.js";import{a as oe}from"./chunk-3JX3FIBG.js";import{a as $}from"./chunk-OHPYKFCM.js";import{createContext as sn,useContext as ct}from"react";import{createContext as Zt,useContext as Xt,useEffect as en,useSyncExternalStore as tn}from"react";import{capabilityNames as Tt}from"@lark-base-open/base-site-channel/capabilities";import*as I from"@lark-base-open/base-site-channel/runtime";import{SITE_RUNTIME_PROTOCOL_VERSION as qn,SiteRuntimeApi as le,SiteRuntimeEvent as Yn,SiteRuntimeFunction as Gn,SiteRuntimeErrorCode as Kn,readSiteAITextDelta as Jn,isValidSiteFunctionName as Qn}from"@lark-base-open/base-site-channel/runtime-contract";var J=()=>{throw new oe(re.ContextInvalid,"\u5BBF\u4E3B\u80FD\u529B\u5B57\u6BB5\u65E0\u6548")};function ve(e){if(!e||typeof e!="object")return J();if(e.capabilities===void 0)return Object.fromEntries(Object.entries(He).filter(([,o])=>o.baseline).map(([o])=>[o,{version:1}]));let t=e.capabilities;if(!t||typeof t!="object"||Array.isArray(t))return J();let n=Object.entries(t);return n.some(([,o])=>!o||typeof o!="object"||Array.isArray(o)||!Number.isSafeInteger(o.version)||o.version<=0)?J():Object.fromEntries(n.map(([o,r])=>[o,{version:r.version}]))}function It(e,t,n=1){if(!Number.isSafeInteger(n)||n<1)return J();let o=ve(e);return Object.prototype.hasOwnProperty.call(o,t)&&o[t].version>=n}async function kt(e=P){return ve(await e.getRuntimeContext())}var Xn=kt;async function Lt(e,t=1,n=P){let o=await n.getRuntimeContext(),r=ve(o),i=It(o,e,t),a=o.capabilityUnavailable;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return J();let s=a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:void 0;return s!==void 0&&(!s||typeof s!="object"||!["permission-denied","region-unavailable","temporarily-unavailable"].includes(s.reason)||typeof s.retryable!="boolean")?J():{name:e,requiredVersion:t,version:Object.prototype.hasOwnProperty.call(r,e)?r[e].version:null,supported:i,source:o.capabilities===void 0?"host-baseline":"advertised",availability:i?s?.reason??"unknown":"unsupported"}}async function Ve(e,t=1,n=P){let o=await n.getRuntimeContext(),r=await Lt(e,t,{getRuntimeContext:async()=>o});if(!r.supported)throw new ze(e,t);let i={"permission-denied":re.PermissionDenied,"region-unavailable":re.RegionUnavailable,"temporarily-unavailable":re.TemporarilyUnavailable};if(r.availability in i)throw new oe(i[r.availability],"\u5BBF\u4E3B\u660E\u786E\u62D2\u7EDD\u6B64\u80FD\u529B",void 0,o.capabilityUnavailable?.[e]?.retryable)}function qe(e,t){let n,o=!1,r,i=new Promise(a=>{r=a});return e.registerApi($.pairApi,async a=>{if(!a||!/^[A-Za-z0-9_-]{43}$/.test(a.challenge))throw new Error("INVALID_PAIRING_CHALLENGE");n=a.challenge;let s=n;o&&(o=!1,i=new Promise(u=>{r=u}));let c=await t($.endpoint,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:s})});if(!c.ok)throw new Error("DEVELOPMENT_PAIRING_FAILED");let d=await c.json();if(!/^[A-Za-z0-9_-]{43}$/.test(d.proof))throw new Error("INVALID_PAIRING_PROOF");return{proof:d.proof}}),e.subscribeEvent($.pairedEvent,a=>{n&&a?.challenge===n&&(o=!0,r())}),{reset:()=>{n=void 0,o&&(o=!1,i=new Promise(a=>{r=a}))},wait:async()=>{let a;do a=i,await a;while(a!==i)}}}var Ye=typeof window<"u"&&window.location.protocol==="http:"&&window.location.hostname===$.host&&Number(window.location.port)>=$.portMin&&Number(window.location.port)<=$.portMax;var Ge=I.siteRuntime,M=Ge.getChannel?.()??Ge.channel,_t=Ye&&typeof window<"u"&&window.parent!==window?qe(M,globalThis.fetch.bind(globalThis)):void 0;function Ke(e,t=async()=>{}){let n=new Map,o=async(r,i)=>{await t();for(let a of Tt(r,i))try{await Ve(a,1,{getRuntimeContext:()=>e.invokeApi(le.RuntimeContext,void 0)})}catch(s){throw s instanceof Error&&"code"in s?Object.assign(new I.SiteRuntimeInvocationError(String(s.code),s.message),s):s}};return{subscribeEvent:(r,i)=>e.subscribeEvent(r,i),emitEvent:async(r,i)=>(await o(r,i),e.emitEvent(r,i)),invokeApi:async(r,i,a)=>{let s=i?.requestId??i?.subscriptionId??i?.uploadId,c=r===le.HttpRequestCancel||r===le.AttachmentUploadCancel||r.endsWith(".close");if(c&&s&&n.has(s)){n.get(s).canceled=!0;return}let d={canceled:!1};!c&&s&&n.set(s,d);try{if(await o(r,i),d.canceled)throw new DOMException("The operation was aborted","AbortError");return s&&n.delete(s),await e.invokeApi(r,i,a)}finally{s&&n.get(s)===d&&n.delete(s)}}}}var Mt={invokeApi:M.invokeApi.bind(M),emitEvent:M.emitEvent.bind(M),subscribeEvent:M.subscribeEvent.bind(M)},Re=Ke(Mt,async()=>{if(typeof window<"u"&&window.parent===window)throw new I.SiteRuntimeInvocationError("CHANNEL_UNAVAILABLE","\u9875\u9762\u672A\u8FDE\u63A5\u5BBF\u4E3B channel");await _t?.wait()});M.invokeApi=Re.invokeApi;M.emitEvent=Re.emitEvent;var Ce=class extends I.SiteRuntimeClient{constructor(t){super(t?Ke(t):Re)}},so=e=>new Ce(e),P=I.siteRuntime,{invokeHttp:ue,invokeApi:co,getCurrentUser:ae,logout:Ee,requestEdit:Dt,uploadAttachment:lo,openLink:de}=P,Ft=(e=P,t)=>I.createSiteRuntimeFetch(e,t),N=Ft();var Ot=ue,Nt=/^\/?(preview\/)?app\/([^/]+)(\/|$)/,Je=/^[A-Za-z0-9_-]+$/,We="/space/api/bitable/site/v1",Bt="/space/api/box/file/temporary_download_url",Q="preview",ie=null;function jt(){let t=(typeof globalThis.location>"u"?void 0:globalThis.location)?.ancestorOrigins?.[0];if(t)return t;let n=typeof globalThis.document>"u"?"":globalThis.document.referrer;if(!n)return"";try{return new URL(n).origin}catch{return""}}function Ue(){let e=typeof globalThis.location>"u"?"":globalThis.location.pathname,t=Nt.exec(e),n=jt();return t?{env:t[1]?Q:"prod",gatewayOrigin:n,token:decodeURIComponent(t[2]??"")}:{env:"prod",gatewayOrigin:n,token:""}}function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $t(e){return e===Q||e==="prod"}function Ht(e){if(!H(e))return{};let t=typeof e.siteToken=="string"?e.siteToken.trim():"";return{...t?{token:t}:{},...$t(e.env)?{env:e.env}:{}}}async function z(){return ie||(ie=(async()=>{let e=Ue(),t={},n;try{n=await P.getRuntimeContext(),t=Ht(n)}catch(r){console.warn("Could not read the host Runtime context; inferring it from the artifact path",r)}pe=Qt(n);let o={env:t.env??e.env,gatewayOrigin:e.gatewayOrigin,token:t.token??e.token};return o.token||console.error("Cannot determine the app token: the host did not provide siteToken and the current path does not match an artifact path"),o})().catch(e=>{throw ie=null,pe={...Pe},e}),ie)}function Se(e){return!!(e.tableId.trim()&&e.fieldId.trim()&&e.recordId.trim()&&e.fileToken.trim())}function Ze(e,t){return JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},siteToken:e.token,siteEnv:e.env}})}function Xe(e,t){if(t instanceof Error)return t;let n=H(t)?t.code:void 0,o=typeof n=="string"||typeof n=="number"?String(n):"",r=o==="REQUEST_TIMEOUT"||o==="10005"?`${e} timed out`:`${e} failed`;return Object.assign(new Error(`${r}${o?` (code ${o})`:""}`),{cause:t,...o?{code:o}:{}})}async function et(e,t=360,n={}){if(n.signal?.throwIfAborted(),!Se(e)||!Number.isFinite(t)||t<=0)throw new Error("Attachment location or image size is invalid");let o=await z();if(n.signal?.throwIfAborted(),!o.token)throw new Error("Cannot load the attachment image without an app token");let r=[120,360,720,1280].find(c=>c>=t)??1280,i=new URLSearchParams({extra:Ze(o,e),width:String(r),height:String(r),policy:"allow_up",fallback_source:"1"}),a=await Ot({url:`/space/api/box/stream/download/v2/cover/${encodeURIComponent(e.fileToken)}?${i}`,init:{method:"GET",responseType:"arrayBuffer",timeoutMs:45e3},signal:n.signal}).catch(c=>{throw Xe("Attachment image request",c)});if(!a.ok){let c=a.headers.get("x-tt-logid");throw new Error(`Failed to load attachment image: HTTP ${a.status}${c?`, LogID ${c}`:""}`)}let s=await a.blob();if(!s.size||!s.type.startsWith("image/"))throw new Error("The host did not return a valid image");return s}async function zt(e,t){if(!e.token)throw new Error("Cannot get an attachment download URL without an app token");if(!Se(t))throw new Error("Cannot get an attachment download URL: the attachment location is incomplete");let n=await N(Bt,{body:JSON.stringify({extra:Ze(e,t),file_token:t.fileToken}),headers:{"content-type":"application/json"},method:"POST"}).catch(s=>{throw Xe("Attachment download URL request",s)}),o=n.headers?.get("x-tt-logid")?.trim(),r;try{r=await n.json()}catch{throw new Error(n.ok?`Attachment download URL response is not valid JSON${o?`, LogID ${o}`:""}`:`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`)}let i=H(r)?r.code:void 0;if(typeof i=="number"&&i!==0||typeof i=="string"&&i.trim()!==""&&i.trim()!=="0"){let s=new Error(`Attachment service could not provide a download URL (code ${String(i)}${o?`, LogID ${o}`:""})`);throw Object.assign(s,{code:String(i),cause:r})}if(!n.ok)throw new Error(`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`);let a=H(r)&&H(r.data)&&typeof r.data.url=="string"?r.data.url.trim():"";if(!a)throw new Error(`Attachment download URL response is missing data.url${o?`, LogID ${o}`:""}`);return a}function tt(e){let t=new URLSearchParams;e.env===Q&&t.set("env",Q);let n=t.toString(),o=`${We}/${encodeURIComponent(e.token)}/invoke_get`;return n?`${o}?${n}`:o}function nt(e,t){if(!Je.test(t))throw new TypeError(`functionId ${t} does not match the required pattern ${String(Je)}`);let n=`${We}/${encodeURIComponent(e.token)}/functions/${encodeURIComponent(t)}/invoke`;return e.env===Q?`${n}?env=${encodeURIComponent(Q)}`:n}var Vt="x-base-site-session-id",qt="x-base-site-read-your-writes",Yt=800008918,Qe=new Map,Pe={maxRetries:3,intervalMs:300},pe={...Pe},Gt=10,Kt=100,Jt=2e3;function Qt(e){let t=H(e)?e.readYourWritesRetry:void 0;return H(t)&&Number.isInteger(t.maxRetries)&&t.maxRetries>=0&&t.maxRetries<=Gt&&Number.isInteger(t.intervalMs)&&t.intervalMs>=Kt&&t.intervalMs<=Jt?{maxRetries:t.maxRetries,intervalMs:t.intervalMs}:{...Pe}}function Wt(e){let t=Qe.get(e);if(t)return t;let n=`baseSite:session:${e}`,o;try{o=localStorage.getItem(n)||void 0}catch{o=void 0}if(!o){try{o=crypto.randomUUID()}catch{return}try{localStorage.setItem(n,o)}catch{}}return Qe.set(e,o),o}function ot(e){let t=Wt(e);return{"content-type":"application/json",...t?{[Vt]:t}:{}}}var xe=class extends oe{logId;constructor(t={}){super("FUNCTION_INVOKE_FAILED","The write has succeeded but the data is not readable yet. Do not repeat the write; retry the query shortly.","800008918",!0),this.name="DataNotReadyError",this.logId=t.logId}};async function fo(e,t,n){let o=await z();if(!o.token)throw new Error(`Cannot invoke Function ${e} without an app token`);let r=n?.readYourWrites!==!1,i={...ot(o.token),...r?{[qt]:"1"}:{}},a=()=>ue({url:nt(o,e),init:{body:JSON.stringify({params:t}),headers:i,method:"POST"}});for(let s=0;;s++){let c=await a();if(!c.ok)throw new Error(`Function ${e} request failed: HTTP ${c.status}`);let d=await c.json();if(r&&d?.code===Yt){if(s<pe.maxRetries){await new Promise(u=>setTimeout(u,pe.intervalMs));continue}throw new xe({logId:d.data?.log_id})}return d}}async function go(e,t){if(!Array.isArray(t)||t.length<1||t.length>200||t.some(r=>r===null||typeof r!="object"||Array.isArray(r)))throw new TypeError("Mutation batch requires 1 to 200 named parameter objects");let n=await z();if(!n.token)throw new Error("\u5E94\u7528 token \u672A\u786E\u5B9A\uFF0C\u65E0\u6CD5\u8C03\u7528 Mutation");let o=await ue({url:nt(n,e),init:{body:JSON.stringify({batch:t.map(r=>({params:r}))}),headers:ot(n.token),method:"POST"}});if(!o.ok)throw new Error(`Mutation \u8C03\u7528\u5931\u8D25\uFF1AHTTP ${o.status}`);return await o.json()}async function ho(e,t){let n=await zt(e,t);if(!(await de(n)).opened)throw new Error("The host did not open the attachment download link")}function bo(e,t,n=360){if(!e.gatewayOrigin||!e.token||!Se(t))return"";let o=[120,360,720,1280].find(i=>i>=n)??1280,r=new URLSearchParams({extra:JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},baseAppToken:e.token}}),width:String(o),height:String(o),policy:"allow_up",fallback_source:"1"});return`${e.gatewayOrigin}/space/api/box/stream/download/v2/cover/${encodeURIComponent(t.fileToken)}?${r.toString()}`}var Le=Zt(void 0),at=[{id:"en",locale:"en-US",match:/^en(?:-|$)/},{id:"zh",locale:"zh-CN",match:/^zh(?:-|$)/},{id:"ja",locale:"ja-JP",match:/^ja(?:-|$)/}],Ie=new Set,it,Ae=null;function ke(e){if(typeof e!="string")return;let t=e.trim().replace(/_/g,"-").toLowerCase();return at.find(({match:n})=>n.test(t))?.id}function nn(){return typeof navigator>"u"?void 0:navigator.language}function on(e,t){return ke(e)??ke(t)??"en"}function V(){return it??on(void 0,nn())}function Te(e=V()){return at.find(({id:t})=>t===e)?.locale??"en-US"}function rn(e){return Ie.add(e),()=>Ie.delete(e)}function rt(e){it=ke(e);let t=V();st(t);for(let n of Ie)n();return t}function st(e){typeof document<"u"&&(document.documentElement.lang=Te(e))}function an(){return Ae||(st(V()),Ae=P.getRuntimeContext().then(e=>rt(e?.locale)).catch(()=>rt(void 0))),Ae}function k(){let e=Xt(Le),t=tn(rn,V,()=>"en");return en(()=>{e||an()},[e]),e??t}import{jsx as _e}from"react/jsx-runtime";var Me=sn(null);function So({children:e,...t}){return _e(Me.Provider,{value:t,children:_e(Le.Provider,{value:t.locale,children:_e("div",{className:"base-app-platform","data-theme":t.theme,children:e})})})}function Po(){let e=ct(Me);if(!e)throw new Error("BASE_APP_PROVIDER_REQUIRED");return e}function me(){return ct(Me)}import{useState as Z,useEffect as gt,useLayoutEffect as hn,useRef as Fe,useId as bn}from"react";import{jsx as D,jsxs as cn}from"react/jsx-runtime";function lt(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:D("path",{d:"M17.1956 16.3595C17.6558 16.3595 18.0289 16.7326 18.0289 17.1928C18.0287 17.6529 17.6557 18.0261 17.1956 18.0261H9.48724C9.0273 18.0259 8.65411 17.6527 8.6539 17.1928C8.6539 16.7327 9.02717 16.3597 9.48724 16.3595H17.1956ZM12.5732 2.47195C13.8817 1.28992 15.902 1.32977 17.163 2.59076L17.281 2.71527C18.4249 3.98149 18.4257 5.91435 17.2818 7.18061L17.163 7.3043L9.32366 15.1445C9.12419 15.3439 8.89959 15.5169 8.65716 15.6596L8.40976 15.7923L4.13079 17.8471C2.75554 18.5075 1.31776 17.1336 1.84889 15.7565L1.90667 15.623L3.96152 11.344C4.12431 11.0051 4.34347 10.696 4.60931 10.4301L12.4495 2.59076L12.5732 2.47195ZM5.78769 11.6093C5.65491 11.7421 5.54596 11.8966 5.46461 12.0659L3.40976 16.344L7.68792 14.2892C7.85719 14.2078 8.01164 14.0989 8.14446 13.9661L13.4643 8.64545L11.1075 6.28868L5.78769 11.6093ZM15.9846 3.76915C15.3338 3.11835 14.2788 3.11851 13.6279 3.76915L12.2867 5.11029L14.6435 7.46706L15.9846 6.12592C16.6353 5.47503 16.6354 4.41994 15.9846 3.76915Z",fill:"currentColor"})})}function ut(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"24",height:"6",viewBox:"0 0 24 6",fill:"none",children:D("path",{d:"M8.4383 1.99309L11.2526 5.15916C11.6504 5.60668 12.3496 5.60668 12.7474 5.15916L15.5617 1.99309C16.6886 0.725344 18.3038 0 20 0L12 0L4 0C5.69619 0 7.31142 0.725345 8.4383 1.99309Z",fill:"#1F2329"})})}function dt(){return cn("svg",{"aria-hidden":"true",focusable:"false",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[D("circle",{cx:"8.00008",cy:"8.00033",r:"7.33333",fill:"#1456F0"}),D("path",{d:"M8 5.33333C8.36819 5.33333 8.66667 5.03486 8.66667 4.66667C8.66667 4.29848 8.36819 4 8 4C7.63181 4 7.33333 4.29848 7.33333 4.66667C7.33333 5.03486 7.63181 5.33333 8 5.33333Z",fill:"white"}),D("path",{d:"M7.33333 6C6.96514 6 6.66667 6.29848 6.66667 6.66667C6.66667 7.03486 6.96514 7.33333 7.33333 7.33333V10H6.66667C6.29848 10 6 10.2985 6 10.6667C6 11.0349 6.29848 11.3333 6.66667 11.3333H9.33333C9.70152 11.3333 10 11.0349 10 10.6667C10 10.2985 9.70152 10 9.33333 10H8.66667V6.66667C8.66667 6.29848 8.36819 6 8 6H7.33333Z",fill:"white"})]})}function pt(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M13.5043 13.5042C13.7646 13.2439 13.7665 12.8237 13.5062 12.5633L8.94298 8.00013L13.5061 3.43697C13.7665 3.17662 13.7646 2.7564 13.5043 2.49605C13.2439 2.2357 12.8237 2.23382 12.5633 2.49416C12.303 2.75451 8.00017 7.05732 8.00017 7.05732L3.43697 2.49413C3.17662 2.23378 2.7564 2.23566 2.49605 2.49601C2.2357 2.75636 2.23381 3.17658 2.49416 3.43693L7.05736 8.00013L2.49413 12.5634C2.23378 12.8237 2.23566 13.2439 2.49601 13.5043C2.75636 13.7646 3.17659 13.7665 3.43693 13.5062L8.00017 8.94294L12.5634 13.5061C12.8237 13.7665 13.2439 13.7646 13.5043 13.5042Z",fill:"#646A73"})})}import{QueryClient as ln}from"@tanstack/react-query";var De=new ln({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}});function fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ge(e,t){let n=e[t];return typeof n=="string"?n.trim():""}function un(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function q(){return{baseBindings:[],name:"",description:"",isOwner:!1,allowEdit:!1,organization:""}}function dn(){let e=document.querySelector('meta[name="description"]');return e instanceof HTMLMetaElement?e:null}function pn(e){if(e.name&&(document.title=e.name),e.description){let t=dn();t&&(t.content=e.description)}}function mn(e){return Array.isArray(e)?e.reduce((t,n)=>{if(!fe(n))return t;let o=ge(n,"baseToken");return o&&t.push({baseToken:o,tableIds:un(n.tableIds)}),t},[]):[]}function fn(e){if(!fe(e)||e.code!==0)return q();let t=e.data;if(!fe(t))return q();let n=t.site;return fe(n)?{baseBindings:mn(n.baseBindings),description:ge(n,"description"),name:ge(n,"name"),isOwner:t.isOwner===!0,allowEdit:n.allowEdit===void 0?t.isOwner===!0:n.allowEdit===!0,organization:ge(n,"organization")}:q()}async function mt(e){try{let t=await N(tt(e),{method:"GET"});if(!t.ok)return q();let n=await t.json(),o=fn(n);return pn(o),o}catch{return q()}}async function W(){let e=await z();if(!e.token)return q();let t=await ae().catch(()=>null);return t?.userId?De.fetchQuery({queryKey:["project-meta",e.token,e.env,t.userId],queryFn:()=>mt(e)}):mt(e)}var gn="https://feishu.cn/base/site/detail/overview";async function ft(){try{await P.requestEdit();return}catch{let{token:e}=await z(),t=new URL(gn);if(t.searchParams.set("token",e),!(await de(t.toString())).opened)throw new Error("Management page was not opened")}}import{jsx as U,jsxs as he}from"react/jsx-runtime";var yn={en:{openFailed:"Unable to open the management page. Please try again.",editSite:"Edit and manage your apps",hidePanel:"Hide until next visit",hiddenConfirmation:"Edit button hidden until you reopen the app",dismissNotification:"Dismiss notification"},zh:{openFailed:"\u65E0\u6CD5\u6253\u5F00\u7BA1\u7406\u9875\u9762\uFF0C\u8BF7\u91CD\u8BD5",editSite:"\u7F16\u8F91\u4E0E\u7BA1\u7406\u5E94\u7528",hidePanel:"\u9690\u85CF",hiddenConfirmation:"\u7F16\u8F91\u6309\u94AE\u5DF2\u9690\u85CF\uFF0C\u76F4\u81F3\u4E0B\u6B21\u91CD\u65B0\u6253\u5F00\u5E94\u7528",dismissNotification:"\u5173\u95ED\u63D0\u793A"},ja:{openFailed:"\u7BA1\u7406\u30DA\u30FC\u30B8\u3092\u958B\u3051\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",editSite:"\u30A2\u30D7\u30EA\u3092\u7DE8\u96C6\u30FB\u7BA1\u7406",hidePanel:"\u6B21\u56DE\u306E\u30A2\u30AF\u30BB\u30B9\u307E\u3067\u975E\u8868\u793A",hiddenConfirmation:"\u7DE8\u96C6\u30DC\u30BF\u30F3\u3092\u975E\u8868\u793A\u306B\u3057\u307E\u3057\u305F\u3002\u30A2\u30D7\u30EA\u3092\u518D\u5EA6\u958B\u304F\u3068\u8868\u793A\u3055\u308C\u307E\u3059",dismissNotification:"\u901A\u77E5\u3092\u9589\u3058\u308B"}};function Yo({position:e="bottom-right",className:t="",slots:n={}}){let o=yn[k()],[r,i]=Z(!1),[a,s]=Z(!1),[c,d]=Z(!1),[u,p]=Z(!1),[m,g]=Z(null),[f,E]=Z(null),x=Fe(null),O=Fe(null),S=Fe(null),_=bn();hn(()=>{if(!m)return;let h=m==="edit"?x.current:O.current,w=S.current;if(!h||!w)return;let v=()=>{let X=h.getBoundingClientRect(),ee=X.left+X.width/2,te=Math.ceil(w.getBoundingClientRect().width),ne=Math.max(8,Math.min(ee-te/2,window.innerWidth-te-8));E({left:ne,top:X.top-w.offsetHeight-14,arrowLeft:ee-ne})};v(),window.addEventListener("resize",v);let K=new ResizeObserver(v);return K.observe(w),()=>{window.removeEventListener("resize",v),K.disconnect()}},[m,o,e,n.tooltip]),gt(()=>{let h=!0;return W().then(w=>{h&&i(w.allowEdit&&Ue().env==="prod")}).catch(()=>{}),()=>{h=!1}},[]),gt(()=>{if(!c)return;let h=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(h)},[c]);let A=n.trigger,y=n.tooltip;return r?a?c?he("div",{className:"base-app-platform base-app-notice",role:"status",children:[U(dt,{}),U("span",{children:o.hiddenConfirmation}),U("button",{type:"button","aria-label":o.dismissNotification,onClick:()=>d(!1),children:U(pt,{})})]}):null:he("div",{className:`base-app-platform base-app-floating ${t}`,"data-position":e,children:[u?U("div",{role:"alert",children:o.openFailed}):null,m?he("div",{ref:S,id:_,role:"tooltip",style:f?{left:f.left,top:f.top}:{visibility:"hidden"},children:[y?U(y,{text:m==="edit"?o.editSite:o.hidePanel}):m==="edit"?o.editSite:o.hidePanel,U("span",{className:"base-app-floating-caret",style:{left:f?.arrowLeft},children:U(ut,{})})]}):null,he("div",{className:"base-app-floating-controls",children:[U("button",{ref:x,type:"button",className:"base-app-floating-edit","aria-describedby":m==="edit"?_:void 0,"aria-label":o.editSite,onFocus:()=>g("edit"),onBlur:()=>g(null),onMouseEnter:()=>g("edit"),onMouseLeave:()=>g(null),onClick:()=>{p(!1),ft().catch(()=>p(!0))},children:A?U(A,{}):U(lt,{})}),U("button",{ref:O,type:"button",className:"base-app-floating-hide","aria-describedby":m==="hide"?_:void 0,"aria-label":o.hidePanel,onFocus:()=>g("hide"),onBlur:()=>g(null),onMouseEnter:()=>g("hide"),onMouseLeave:()=>g(null),onClick:()=>{s(!0),g(null),d(!0)},children:U("span",{"aria-hidden":"true",children:"\xD7"})})]})]}):null}var Oe=new Set;function ht(e){return Oe.add(e),()=>{Oe.delete(e)}}function bt(){for(let e of Oe)e()}import{useEffect as wn,useState as wt}from"react";import*as B from"@radix-ui/react-popover";async function yt(){try{let e=await ae();if(typeof e?.name=="string"&&e.name)return{name:e.name,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:"",tenantName:""}}catch{}try{let e=await N("/space/api/user/",{headers:{accept:"application/json"}});if(!e.ok)return null;let n=(await e.json()).data;return!n||typeof n.name!="string"||!n.name?null:{name:n.name,avatarUrl:typeof n.avatar_url=="string"?n.avatar_url:"",tenantName:typeof n.tenant_name=="string"?n.tenant_name:""}}catch{return null}}import{Fragment as Cn,jsx as L,jsxs as Ne}from"react/jsx-runtime";var vn={en:{account:"Account",logout:"Log out"},zh:{account:"\u8D26\u53F7",logout:"\u9000\u51FA\u767B\u5F55"},ja:{account:"\u30A2\u30AB\u30A6\u30F3\u30C8",logout:"\u30ED\u30B0\u30A2\u30A6\u30C8"}};function ir({audience:e="enterprise",align:t="right",side:n="down",showName:o=!0,className:r="",slots:i={}}){let[a,s]=wt(null),[c,d]=wt(""),u=me(),p=vn[k()];if(wn(()=>{if(e!=="enterprise")return;let f=!0;return Promise.all([yt(),W().catch(()=>null)]).then(([E,x])=>{f&&(s(E),d(E?.tenantName||x?.organization||""))}),()=>{f=!1}},[e]),e!=="enterprise"||!a)return null;let m=i.trigger,g=i.organization;return Ne(B.Root,{children:[L(B.Trigger,{asChild:!0,children:L("button",{className:`base-app-platform base-app-user-menu ${r}`,"aria-label":p.account,children:m?L(m,{user:a}):Ne(Cn,{children:[a.avatarUrl?L("img",{src:a.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):L("span",{children:a.name.slice(0,1)}),o?a.name:null]})})}),L(B.Portal,{children:Ne(B.Content,{"data-theme":u?.theme,className:"base-app-platform base-app-popover",align:t==="right"?"end":"start",side:n==="up"?"top":"bottom",sideOffset:8,collisionPadding:8,children:[L("strong",{children:a.name}),g?L(g,{name:c}):L("p",{children:c}),L("button",{onClick:()=>{bt(),De.clear(),Ee().catch(()=>{for(let f of["base-site-session","session","sl_session"])document.cookie=`${f}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;window.location.reload()})},children:p.logout})]})})]})}import{useEffect as be,useRef as Rt,useState as Y}from"react";import{Command as se}from"cmdk";import{QueryClient as _n,useQuery as Mn}from"@tanstack/react-query";var Rn="/space/api/mention/recommend.v2/",En="8",xn="4",Un="0",Sn=20,vt={en:{businessError:e=>`Could not search members (error code ${e})`,httpError:e=>`Member search request failed: HTTP ${e}`,invalidResponse:"Member search response has an invalid structure",noBoundBase:"Cannot search members: the application is not bound to a Base"},zh:{businessError:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,httpError:e=>`\u641C\u7D22\u6210\u5458\u8BF7\u6C42\u5931\u8D25\uFF1AHTTP ${e}`,invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",noBoundBase:"\u65E0\u6CD5\u641C\u7D22\u6210\u5458\uFF1A\u5E94\u7528\u5C1A\u672A\u7ED1\u5B9A\u591A\u7EF4\u8868\u683C"},ja:{businessError:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,httpError:e=>`\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF1AHTTP ${e}`,invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",noBoundBase:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\uFF1A\u30A2\u30D7\u30EA\u306BBase\u304C\u95A2\u9023\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093"}};async function Ct(e,t,n){let o=t??V(),r=vt[o],a=(await W()).baseBindings[0]?.baseToken;if(!a)throw new Error(r.noBoundBase);let s=new URLSearchParams({config_source:"0",obj_type:En,source:xn,token:a,type:Un,user_type:"0",content:e.trim().slice(0,50)}).toString(),c=await N(Rn,{signal:n,body:s,headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST"});if(!c.ok)throw new Error(r.httpError(c.status));let d=await c.json();return{code:0,msg:"ok",data:Pn(d,o)}}function Pn(e,t=V()){let n=Te(t),o=vt[t],r=An(e,o);if(!r)throw new Error(o.invalidResponse);let i=r.entities,a=T(i)?i.users:void 0;if(!T(a)||!Array.isArray(r.result_list))throw new Error(o.invalidResponse);let s=[],c=new Set;for(let d of r.result_list){if(!T(d)||Number(d.type)!==0)continue;let u=b(d.token);if(!u)continue;let p=a[u];if(!T(p))continue;let m=b(p.user_id)||b(p.id)||u,g=In(p,n);if(!m||!g||c.has(m))continue;c.add(m);let f=b(p.avatar_url),E=b(p.open_id);if(s.push({avatar:{avatar_72:f,avatar_240:f,avatar_640:f,avatar_origin:f},department_ids:Tn(p.department_ids),description:kn(p,n),is_external:p.is_external===!0,name:g,user_id:m,...E?{open_id:E}:{}}),s.length>=Sn)break}return{users:s}}function An(e,t){if(T(e)){if(typeof e.code=="number"&&e.code!==0){let n=b(e.msg);throw Object.assign(new Error(n||t.businessError(e.code)),{code:String(e.code),cause:e})}return"entities"in e&&"result_list"in e?e:T(e.data)?e.data:void 0}}function In(e,t){let n=e.display_name;if(typeof n=="string"&&n.trim())return n.trim();let o=t.toLowerCase().replace("-","_"),r=o.split("_")[0],i=T(n)?n:{},a=T(i.i18n_value)?i.i18n_value:i,s=r==="zh"?e.cn_name:r==="en"?e.en_name:void 0;return b(a[o])||b(a[r])||b(s)||b(i.value)||b(e.name)||b(e.en_name)||b(e.cn_name)}function kn(e,t){let n=e.is_external===!0?e.i18n_tenant:e.i18n_department;return Ln(n,t)||b(e.department)}function Ln(e,t){if(typeof e=="string")return e.trim();if(!T(e))return"";let n=t.toLowerCase().replace("-","_"),o=n.split("_")[0]??"",r=T(e.i18n_value)?e.i18n_value:e,i=b(r[n])||b(r[o]);if("i18n_value"in e)return i||b(e.value);let a=o==="zh"?b(r.zh_cn)||b(r.en_us):b(r.en_us)||b(r.zh_cn);return i||b(e.value)||a}function b(e){return typeof e=="string"?e.trim():""}function Tn(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Fragment as xt,jsx as R,jsxs as Be}from"react/jsx-runtime";var Ut={en:{invalidResponse:"Member search response has an invalid structure",loading:"Loading...",memberList:"Member list",noMatches:"No matching members. Try another search term.",noRecommendations:"No recommended members yet",recordCreator:"Add the person who created this record",searchFailed:"Member search failed",searchFailedCode:e=>`Could not search members (error code ${e})`,searchMembers:"Search members"},zh:{invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",loading:"\u52A0\u8F7D\u4E2D...",memberList:"\u6210\u5458\u5217\u8868",noMatches:"\u6CA1\u6709\u5339\u914D\u7684\u6210\u5458\uFF0C\u8BF7\u6362\u4E2A\u5173\u952E\u8BCD",noRecommendations:"\u6682\u65E0\u63A8\u8350\u6210\u5458",recordCreator:"\u6DFB\u52A0\u6B64\u8BB0\u5F55\u7684\u4EBA\u5458",searchFailed:"\u641C\u7D22\u6210\u5458\u5931\u8D25",searchFailedCode:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,searchMembers:"\u641C\u7D22\u6210\u5458"},ja:{invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",memberList:"\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7",noMatches:"\u4E00\u81F4\u3059\u308B\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093\u3002\u5225\u306E\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22\u3057\u3066\u304F\u3060\u3055\u3044\u3002",noRecommendations:"\u304A\u3059\u3059\u3081\u306E\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093",recordCreator:"\u3053\u306E\u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210\u8005\u3092\u8FFD\u52A0",searchFailed:"\u30E1\u30F3\u30D0\u30FC\u306E\u691C\u7D22\u306B\u5931\u6557\u3057\u307E\u3057\u305F",searchFailedCode:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,searchMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22"}};function ye(e){let[t,n]=Y(!1),[o,r]=Y(!1);be(()=>r(!0),[]);let i=k(),a=Ut[i],[s]=Y(()=>new _n({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}}));be(()=>{let l=ht(()=>{n(!0),s.clear()});return()=>{l(),s.clear()}},[s]);let c=Object.prototype.hasOwnProperty.call(e,"value"),d=Rt(c);be(()=>{c!==d.current&&console.warn("UserSelectorPanel controlled mode changed")},[c]);let[u,p]=Y(e.defaultValue),m=c?e.value:u,g=Array.isArray(m)?m:m?[m]:[],[f,E]=Y(""),[x,O]=Y(""),[S,_]=Y(!1),A=Rt(!1);be(()=>{if(S)return;let l=setTimeout(()=>O(f.trim()),f.trim()?400:0);return()=>clearTimeout(l)},[f,S]);let y=Mn({queryKey:["members",i,x],queryFn:async({signal:l})=>{let C=await Ct(x,i,l);return Dn(C,i)},enabled:!t&&o&&!S&&f.trim()===x},s),h=e.loading||y.isFetching||f.trim()!==x,w=!t&&!h&&!y.error&&y.data?[...y.data.users,...g.filter(l=>!y.data.users.some(C=>C.user_id===l.user_id))]:[],v=(l,C)=>{E(l),e.onSearch?.(l,{action:C})},K=()=>{v("","AutoClear"),e.onClose?.()},X=l=>{if(A.current)return;let C=g.some(we=>we.user_id===l.user_id),ce=e.mode==="multiple"?C?g.filter(we=>we.user_id!==l.user_id):[...g,l]:C?void 0:l;c||p(ce),e.onChange?.(ce,{option:l,action:C?"Remove":"Select"}),C||e.onSelect?.(l,{option:l}),e.mode==="multiple"?v("","AutoClear"):K()},ee=e.slots?.empty,te=e.slots?.loading,ne=e.slots?.option,$e=e.slots?.footer;return Be(se,{shouldFilter:!1,loop:!0,className:`base-app-platform base-app-selector ${e.className??""}`,label:a.memberList,children:[R(se.Input,{autoFocus:!0,placeholder:a.searchMembers,"aria-label":a.searchMembers,value:f,onValueChange:l=>v(l,"Input"),onCompositionStart:()=>{A.current=!0,_(!0)},onCompositionEnd:()=>{A.current=!1,_(!1)},onKeyDown:l=>{if(e.onKeyDown?.(l),l.defaultPrevented){l.stopPropagation();return}if(A.current||Fn(l)){l.stopPropagation();return}l.key==="Escape"&&(l.preventDefault(),K())}}),R(se.List,{"aria-label":a.memberList,"aria-multiselectable":e.mode==="multiple"||void 0,children:h?R("div",{role:"status",children:te?R(te,{}):a.loading}):y.error?R("div",{role:"alert",children:a.searchFailed}):Be(xt,{children:[e.onSelectRecordCreator?R(se.Item,{value:"record-creator",onSelect:()=>{e.onSelectRecordCreator?.(),K()},children:a.recordCreator}):null,w.map(l=>{let C=g.some(ce=>ce.user_id===l.user_id);return R(se.Item,{value:l.user_id,onSelect:()=>X(l),"data-checked":C,children:ne?R(ne,{user:l,selected:C}):Be(xt,{children:[R("span",{children:l.name}),R("small",{children:e.getUserDescription?.(l)??l.description}),C?R("span",{"aria-label":"selected",children:"\u2713"}):null]})},l.user_id)}),!w.length&&!e.onSelectRecordCreator?R("div",{role:"status",children:ee?R(ee,{}):f.trim()?a.noMatches:a.noRecommendations}):null]})}),$e?R($e,{}):null]})}function Dn(e,t){let n=Ut[t];if(!Et(e)||typeof e.code!="number")throw new Error(n.invalidResponse);if(e.code!==0){let o=typeof e.msg=="string"?e.msg.trim():"";throw Object.assign(new Error(o||n.searchFailedCode(e.code)),{code:String(e.code),cause:e})}if(!Et(e.data)||!Array.isArray(e.data.users))throw new Error(n.invalidResponse);return{users:e.data.users}}function Et(e){return typeof e=="object"&&e!==null}function Fn(e){return e.nativeEvent?.isComposing===!0||e.keyCode===229}import{useState as On,useRef as Nn}from"react";import*as j from"@radix-ui/react-popover";import{jsx as F,jsxs as St}from"react/jsx-runtime";var Bn={en:{clearSelected:"Clear selected members",removeMember:e=>`Remove member ${e}`,selectMembers:"Select members"},zh:{clearSelected:"\u6E05\u9664\u5DF2\u9009\u6210\u5458",removeMember:e=>`\u79FB\u9664\u6210\u5458 ${e}`,selectMembers:"\u9009\u62E9\u6210\u5458"},ja:{clearSelected:"\u9078\u629E\u3057\u305F\u30E1\u30F3\u30D0\u30FC\u3092\u30AF\u30EA\u30A2",removeMember:e=>`\u30E1\u30F3\u30D0\u30FC ${e} \u3092\u524A\u9664`,selectMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u9078\u629E"}};function Pt(e){let t=Nn(null),n=me(),o=Bn[k()],[r,i]=On(!1),a=Array.isArray(e.value)?e.value:e.value?[e.value]:[],s=u=>{i(u),u!==r&&e.onDropdownVisibleChange?.(u)},c=e.slots?.trigger,d=e.slots?.chip;return St(j.Root,{open:r,onOpenChange:s,children:[St("div",{ref:t,className:`base-app-platform base-app-editor ${e.className??""}`,onClickCapture:u=>{u.target.closest("[data-base-app-trigger]")&&e.onClick?.(u)},children:[F(j.Trigger,{asChild:!0,children:F("button",{type:"button","data-base-app-trigger":"","aria-label":o.selectMembers,onFocus:e.onFocus,onBlur:e.onBlur,children:c?F(c,{value:e.value}):a.length?a.map(u=>F("span",{children:d?F(d,{user:u}):u.name},u.user_id)):o.selectMembers})}),a.map(u=>F("button",{type:"button","aria-label":e.mode==="multiple"?o.removeMember(u.name):o.clearSelected,onClick:p=>{p.stopPropagation(),e.onChange?.(e.mode==="multiple"?a.filter(m=>m.user_id!==u.user_id):void 0),e.mode==="multiple"?e.onRemove?.(u):e.onClear?.()},children:"\xD7"},u.user_id))]}),F(j.Portal,{container:e.portalContainer??t.current?.closest("dialog")??void 0,children:F(j.Content,{"data-theme":n?.theme,className:"base-app-platform base-app-popover",sideOffset:4,collisionPadding:8,children:F(ye,{...e,slots:void 0,onChange:(u,p)=>{e.onChange?.(u),p.action==="Remove"&&p.option&&e.onRemove?.(p.option)},onClose:()=>s(!1)})})})]})}import{useEffect as At,useRef as jn,useState as je}from"react";import{jsx as G,jsxs as Hn}from"react/jsx-runtime";var $n={en:{decodeFailed:"Image could not be decoded",loadFailed:"Failed to load image",loading:"Loading image",retry:"Retry image"},zh:{decodeFailed:"\u56FE\u7247\u65E0\u6CD5\u89E3\u7801",loadFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",loading:"\u56FE\u7247\u52A0\u8F7D\u4E2D",retry:"\u91CD\u8BD5\u56FE\u7247"},ja:{decodeFailed:"\u753B\u50CF\u3092\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",loadFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",loading:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D",retry:"\u753B\u50CF\u3092\u518D\u8AAD\u307F\u8FBC\u307F"}};function Tr({attachment:e,size:t=360,alt:n,className:o,slots:r={}}){let i=k(),a=$n[i],s=jn(null),[c,d]=je(!1),[u,p]=je(0),[m,g]=je({key:"",url:"",error:""}),{tableId:f,fieldId:E,recordId:x,fileToken:O}=e,S=JSON.stringify([f,E,x,O,t,u]);At(()=>{if(typeof IntersectionObserver>"u"){d(!0);return}let h=new IntersectionObserver(w=>{w.some(v=>v.isIntersecting)&&(d(!0),h.disconnect())},{rootMargin:"200px"});return s.current&&h.observe(s.current),()=>h.disconnect()},[]),At(()=>{if(!c)return;let h=new AbortController,w="";return et({tableId:f,fieldId:E,recordId:x,fileToken:O},t,{signal:h.signal}).then(v=>{h.signal.aborted||(w=URL.createObjectURL(v),g({key:S,url:w,error:""}))}).catch(v=>{h.signal.aborted||g({key:S,url:"",error:v instanceof Error?v.message:"",localError:v instanceof Error?void 0:"loadFailed"})}),()=>{h.abort(),w&&URL.revokeObjectURL(w)}},[c,S,f,E,x,O,t]);let _=r.loading,A=r.error,y=m.key===S?m:void 0;return G("span",{ref:s,className:`base-app-platform base-app-attachment ${o??""}`,"aria-busy":!y,children:y?.url?G("img",{src:y.url,alt:n,onError:()=>g({key:S,url:"",error:"",localError:"decodeFailed"})}):y?.error||y?.localError?A?G(A,{code:"ATTACHMENT_LOAD_FAILED",retry:()=>p(h=>h+1)}):Hn("span",{children:[G("span",{role:"status",children:y.localError?a[y.localError]:y.error}),G("button",{type:"button",onClick:()=>p(h=>h+1),children:a.retry})]}):G("span",{role:"status",children:_?G(_,{}):a.loading})})}export{qn as a,le as b,Yn as c,Gn as d,Kn as e,Jn as f,Qn as g,Ke as h,Re as i,Ce as j,so as k,P as l,ue as m,co as n,ae as o,Ee as p,Dt as q,lo as r,de as s,Ft as t,N as u,ve as v,It as w,kt as x,Xn as y,Lt as z,Ve as A,Ue as B,z as C,et as D,zt as E,tt as F,nt as G,xe as H,fo as I,go as J,ho as K,bo as L,Le as M,on as N,V as O,Te as P,an as Q,k as R,So as S,Po as T,me as U,De as V,Yo as W,ir as X,ye as Y,Pt as Z,Tr as _};