@lark-base-open/base-database-app-sdk 0.5.0-durable.0 → 0.5.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,10 +1,25 @@
1
1
  # Changelog
2
2
 
3
- ## [0.5.0-durable.0] - 2026-10-26
3
+ ## 0.5.0 - 2026-10-27
4
4
 
5
5
  ### Added
6
6
 
7
- - 新增 Durable Workflow 与 Activity 入口,支持持久化步骤、等待、进度和站点 Function 调用。
7
+ - 页面启动时向平台报告所用的 SDK 版本,便于排查问题。
8
+ - 页面出现未处理的错误时,错误信息会上报给平台;内容会截断,并去掉链接里的参数。
9
+
10
+ ## 0.4.2 - 2026-10-26
11
+
12
+ ### Fixed
13
+
14
+ - 悬浮编辑控件的中文隐藏提示改为“隐藏”,悬停关闭按钮时编辑图标保持高亮。
15
+ - 修复隐藏通知在常见屏宽下意外换行的问题;极窄屏幕下保留完整文案并自然换行。
16
+
17
+ ## 0.4.1 - 2026-10-26
18
+
19
+ ### Fixed
20
+
21
+ - 恢复悬浮编辑按钮、隐藏按钮和隐藏提示的样式。
22
+ - 修复悬浮按钮提示框在窄屏和左右定位时超出视口的问题。
8
23
 
9
24
  ## 0.4.0 - 2026-10-23
10
25
 
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.0-durable.0`。从旧版本升级前请阅读 [变更记录](CHANGELOG.md)。
5
+ 安装:`npm install @lark-base-open/base-database-app-sdk@0.5.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.1.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。
8
8
 
9
9
  server/shared 同时提供 ESM 和 CJS;page/components/testing/vite 仅 ESM。
10
10
 
@@ -34,9 +34,9 @@ SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务
34
34
 
35
35
  ## npm 发布
36
36
 
37
- 本版本依赖已发布的 channel 0.1.6,锁文件必须解析到 `registry.npmjs.org` 的制品。AI Function 调用需要后端与宿主支持 `functions/:key/invoke`。
37
+ SDK 0.5.0 依赖已发布的 channel 0.2.0,锁文件必须解析到 `registry.npmjs.org` 的制品。AI Function 调用需要后端与宿主支持 `functions/:key/invoke`。
38
38
 
39
- 本预发布版本使用 `durable` 标签,保留 `latest` 指向 0.4.0。0.4.0 默认开启写后读,数据未就绪时自动重试并可能抛出 `DataNotReadyError`;需要按[写后读说明](docs/page.md#写后读)处理新异常,或传入 `{ readYourWrites: false }` 保持普通查询行为。契约生成使用工程安装的 SDK `./codegen` 入口;已安装旧 SDK 的工程不会因为单独升级 CLI 而自动切换到 0.4.0。0.3.0 将批量 Mutation 的 ID、输入和输出绑定到生成契约,收紧公开类型接口;0.2.0 对直接 Function 调用的返回泛型也有不兼容变化,跨版本升级见[升级指引](docs/upgrade.md)。
39
+ 本版本拟发布到 `latest`,页面启动时向平台报告所用的 SDK 版本,未处理的错误会截断并去掉链接参数后上报给平台;API 与默认行为与 0.4.2 相同。跨版本升级见[升级指引](docs/upgrade.md)。
40
40
 
41
41
  `CHANGELOG.md` 只记录简要版本变化,升级与迁移指导由[升级指引](docs/upgrade.md)及配套 CLI 的建站 Skill 提供。`check:migrations` 检查当前版本、重复编号和已有 Migration 的格式,不强制新增 Migration 章节。
42
42
 
@@ -51,19 +51,15 @@ Changelog 检查不能证明迁移可用。发布者还须按升级指导在旧
51
51
  - `node scripts/sync-capabilities.mjs --check`
52
52
  - `npm run docs:exports`
53
53
  - `npm pack --dry-run --json`
54
- - `npm publish --dry-run --tag durable --registry=https://registry.npmjs.org/`
54
+ - `npm publish --dry-run --tag latest --registry=https://registry.npmjs.org/`
55
55
 
56
56
  核对打包清单包含 dist、docs、examples、README、CHANGELOG、LICENSE、capabilities.json 与 development-pairing.json,以及所有 exports 指向的文件;不得包含测试、私有源码或本地配置。SDK 不提供根入口。
57
57
 
58
58
  检查通过后,由有发布权限的用户本人执行;先确认 `npm whoami` 返回预期账号:
59
59
 
60
60
  - `npm whoami --registry=https://registry.npmjs.org/`
61
- - `npm publish --tag durable --registry=https://registry.npmjs.org/`
62
- - `npm view @lark-base-open/base-database-app-sdk@0.5.0-durable.0 version dist --json --registry=https://registry.npmjs.org/`
61
+ - `npm publish --tag latest --registry=https://registry.npmjs.org/`
62
+ - `npm view @lark-base-open/base-database-app-sdk@0.5.0 version dist --json --registry=https://registry.npmjs.org/`
63
63
  - `npm view @lark-base-open/base-database-app-sdk dist-tags versions --json --registry=https://registry.npmjs.org/`
64
64
 
65
- 回读应确认 `durable` 为 `0.5.0-durable.0`,`latest` 仍为 `0.4.0`。
66
-
67
- ## Durable Function(预发布)
68
-
69
- `/durable/workflow` 和 `/durable/activity` 提供持久化函数 API,使用方法与运行环境见 [Durable 文档](docs/durable.md)。新增入口从 0.5.0-durable.0 提供,0.4.0 不包含这些入口。使用前需确认目标平台已部署匹配的 Durable 运行时;发布 SDK 不代表平台已开放该能力。Temporal 为可选 peer,仅 Durable 开发和执行环境安装匹配版本;普通页面和普通 Function 不依赖它。ESM import 与 CJS require 共享 Durable 模块。
65
+ 回读应确认 `latest` 为 `0.5.0`。
package/capabilities.json CHANGED
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sdkVersion": "0.5.0-durable.0",
3
+ "sdkVersion": "0.5.0",
4
4
  "capabilities": {
5
+ "runtime.diagnostic": {
6
+ "required": [
7
+ "site.v1.runtime.diagnostic"
8
+ ],
9
+ "baseline": false
10
+ },
5
11
  "runtime.context": {
6
12
  "required": [
7
13
  "site.v1.runtime.context"
@@ -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 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 _};
@@ -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-KJQ3P646.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-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};
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 L,O as Xe,P as O,Q as Ze,R as $e,S as B,T as et,U as tt,V as U,W as G,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 M,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 _,x as We,y as Qe,z as je}from"./chunk-KJQ3P646.js";import{a as Ve,b as ze,c as v,d as R}from"./chunk-ZKBZAK4L.js";import{a as He}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 D(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(!_(s,"link.open")){i(new v("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 Lt}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):M})}},F=e=>({...e,channel:e?.channel?x(e.channel):M}),N=(e,t)=>u.callSiteAIFunction(e,F(t)),q=(e,t)=>u.invokeSiteAIFunctionStream(e,F(t)),H=(e,t)=>u.createSiteAIFunctionTask(e,F(t)),V=(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 N(e);return e.input&&!e.messages?k(t):t}function Ce(e){return q(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 Me(e){let t=o(e,["capabilityType","capability_type","CapabilityType"]);return t==="image"||t==="video"?t:void 0}function De(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=Ee(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=De(e.imageAssets??e.image_assets??e.ImageAssets),c=Pe(e.videoAsset??e.video_asset??e.VideoAsset),l=xe(e,["progress","Progress"]),I=Me(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 Ee(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 we(e){return!!e.taskId.trim()&&(e.status==="queued"||e.status==="running")}async function ve(e){return k(await H(e))}async function _e(e,t){if(!t.trim())throw T("AI Function task ID must not be empty");return k(await V(e,t))}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Component as Le,StrictMode as Oe,useEffect as Be,useState as Ue}from"react";import{createRoot as Ge}from"react-dom/client";import{Fragment as Ne,jsx as d,jsxs as qe}from"react/jsx-runtime";var E=new WeakSet,C=class extends Le{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").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(E.has(A))throw new Error("APP_ALREADY_STARTED");E.add(A);let z=()=>{a||(a=!0,I(),p(),l?.unmount(),E.delete(A),U.clear(),!s&&!c&&n(new Error("APP_DISPOSED")))},K=()=>{queueMicrotask(()=>{a||c||s||(s=!0,e.reportLifecycle===!1?t():m.ready().then(t,r=>{f(r),n(r)}))})};function W({locale:r,theme:g}){let[y,h]=Ue();Be(()=>(p=m.subscribeModeChanged(h),K(),()=>p()),[]);let Q=e.app,w=qe(Ne,{children:[d(Q,{}),e.platformUI===!1?null:d(G,{})]});return d(B,{runtime:m,theme:g,locale:r,mode:y,onDiagnostic:e.onDiagnostic,children:e.providers?e.providers(w):w})}try{l=Ge(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:L(g.locale,"en");document.documentElement.lang=O(y),e.linkGuard!==!1&&(I=D({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(Oe,{children:h}))}).catch(S)}catch(r){S(r)}return{ready:i,dispose:z}}export{at as AttachmentImage,B as BaseAppProvider,Ve as CAPABILITY_CATALOG,v as CapabilityUnavailableError,Ie as DataNotReadyError,nt as DatabaseUserMenu,ze as DiagnosticCode,G as FloatingButton,He as SDKError,j as SITE_RUNTIME_PROTOCOL_VERSION,P as SiteChatbotStreamAdapter,Lt 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,ve 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,_e as getSiteAIFunctionTask,Xe as getUiLanguage,O as getUiLocale,_ as hasCapability,we as hasRunnableMediaTask,Ze as initializeUiLanguage,D 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,L as selectUiLanguage,m as siteRuntime,bt as startBaseApp,ce as uploadAttachment,et as useBaseApp,tt as useOptionalBaseApp,$e as useUiLanguage};
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.0"}).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.0"}).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};
package/dist/theme.css CHANGED
@@ -114,17 +114,97 @@
114
114
  }
115
115
  .base-app-floating {
116
116
  position: fixed;
117
- bottom: 24px;
117
+ bottom: 40px;
118
118
  right: 24px;
119
119
  z-index: var(--base-app-z-floating);
120
- display: flex;
121
- gap: 4px;
122
120
  }
123
121
  .base-app-floating[data-position="bottom-left"] {
124
122
  left: 24px;
125
123
  right: auto;
126
124
  }
127
- .base-app-floating [role="tooltip"],
125
+ .base-app-floating-controls {
126
+ position: relative;
127
+ display: flex;
128
+ padding: 2px;
129
+ border-radius: 50%;
130
+ background: #fff;
131
+ box-shadow:
132
+ 0 4px 4px rgb(31 35 41 / 6%),
133
+ 0 6px 6px rgb(31 35 41 / 4%),
134
+ 0 8px 12px rgb(31 35 41 / 4%);
135
+ }
136
+ .base-app-floating .base-app-floating-edit {
137
+ display: flex;
138
+ align-items: center;
139
+ justify-content: center;
140
+ width: 48px;
141
+ height: 48px;
142
+ padding: 0;
143
+ border: 0;
144
+ border-radius: 50%;
145
+ background: transparent;
146
+ color: #2b2f36;
147
+ }
148
+ .base-app-floating-controls:hover .base-app-floating-edit,
149
+ .base-app-floating-edit:focus-visible {
150
+ color: #1456f0;
151
+ }
152
+ .base-app-floating .base-app-floating-hide {
153
+ position: absolute;
154
+ top: -4px;
155
+ right: -4px;
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ width: 16px;
160
+ height: 16px;
161
+ padding: 0;
162
+ border: 0;
163
+ border-radius: 50%;
164
+ background: #c8c9cc;
165
+ color: #646a73;
166
+ font-size: 14px;
167
+ line-height: 1;
168
+ opacity: 0;
169
+ transition: opacity 150ms;
170
+ }
171
+ .base-app-floating-controls:hover .base-app-floating-hide,
172
+ .base-app-floating-hide:focus-visible {
173
+ opacity: 1;
174
+ }
175
+ .base-app-floating .base-app-floating-hide:hover {
176
+ background: #b7b9bd;
177
+ }
178
+ .base-app-floating [role="tooltip"] {
179
+ pointer-events: none;
180
+ position: fixed;
181
+ z-index: var(--base-app-z-popover);
182
+ box-sizing: border-box;
183
+ width: max-content;
184
+ max-width: calc(100vw - 16px);
185
+ padding: 8px 12px;
186
+ border-radius: 8px;
187
+ background: #1f2329;
188
+ color: #fff;
189
+ font-size: 12px;
190
+ line-height: 20px;
191
+ white-space: normal;
192
+ overflow-wrap: anywhere;
193
+ box-shadow:
194
+ 0 8px 24px 8px rgb(31 35 41 / 4%),
195
+ 0 6px 12px rgb(31 35 41 / 4%),
196
+ 0 4px 8px -8px rgb(31 35 41 / 6%);
197
+ }
198
+ .base-app-floating-caret {
199
+ position: absolute;
200
+ top: 100%;
201
+ width: 24px;
202
+ height: 6px;
203
+ transform: translateX(-50%);
204
+ }
205
+ .base-app-floating-caret svg {
206
+ display: block;
207
+ }
128
208
  .base-app-floating [role="alert"] {
129
209
  position: absolute;
130
210
  bottom: 100%;
@@ -136,12 +216,53 @@
136
216
  }
137
217
  .base-app-notice {
138
218
  position: fixed;
139
- top: 20px;
219
+ top: 32px;
140
220
  left: 50%;
141
221
  transform: translateX(-50%);
142
- background: var(--base-app-color-bg);
143
- padding: 12px;
144
- z-index: var(--base-app-z-floating);
222
+ display: flex;
223
+ align-items: center;
224
+ gap: 8px;
225
+ width: max-content;
226
+ max-width: calc(100vw - 32px);
227
+ min-height: 54px;
228
+ padding: 16px 20px;
229
+ border-radius: 6px;
230
+ background: #f0f4ff;
231
+ color: #1f2329;
232
+ font-size: 14px;
233
+ font-weight: 500;
234
+ line-height: 22px;
235
+ box-shadow:
236
+ inset 0 0 0 1px #1456f0,
237
+ 0 8px 24px 8px rgb(31 35 41 / 4%),
238
+ 0 6px 12px rgb(31 35 41 / 4%),
239
+ 0 4px 8px -8px rgb(31 35 41 / 6%);
240
+ z-index: var(--base-app-z-popover);
241
+ }
242
+ .base-app-notice > svg,
243
+ .base-app-notice button {
244
+ flex-shrink: 0;
245
+ }
246
+ .base-app-notice > span {
247
+ flex: 1;
248
+ min-width: 0;
249
+ padding: 0 8px 0 4px;
250
+ }
251
+ .base-app-notice button {
252
+ display: flex;
253
+ width: 16px;
254
+ height: 16px;
255
+ padding: 0;
256
+ border: 0;
257
+ background: transparent;
258
+ }
259
+ @media (max-width: 400px) {
260
+ .base-app-notice {
261
+ padding-inline: 8px;
262
+ }
263
+ .base-app-notice > span {
264
+ padding-inline: 0;
265
+ }
145
266
  }
146
267
  .base-app-user-menu {
147
268
  display: inline-flex;
@@ -5,6 +5,7 @@
5
5
  | 能力 | 分类 | 缺字段时 host-baseline(版本 1) |
6
6
  |---|---|---|
7
7
  | runtime.context | 关键 | 是 |
8
+ | runtime.diagnostic | 可选;SDK 无对应 API,仅 Channel 内部使用 | 否,须由宿主显式声明 |
8
9
  | http.request | 关键 | 是 |
9
10
  | http.binary | 关键 | 是 |
10
11
  | http.cancel | 可选 | 是 |
package/docs/exports.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
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`。
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`、`SiteRuntimeError`、`SiteRuntimeErrorCode`、`SiteRuntimeEvent`、`SiteRuntimeFunction`、`SiteRuntimeInvocationError`、`SiteRuntimeLoadFailedEvent`、`SiteRuntimeModeChangedEvent`、`SiteRuntimeReadyEvent`、`SiteRuntimeUserInfo`、`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`、`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`。
10
10
 
11
11
  ## server
12
12
 
@@ -43,15 +43,3 @@
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`。
@@ -45,3 +45,7 @@ export const plugins = [baseAppDevelopmentPairingPlugin()];
45
45
  Vite HMR 不关闭 gate,不重新配对;仅整页或 iframe 重载重新配对。普通页面与旧 channel 宿主/夹具组合保留原行为。
46
46
 
47
47
  平台 UI 使用 @tanstack/react-query,BaseAppProvider 管理缓存生命周期和应用/环境/身份隔离;它是组件的必需 peer。React/ReactDOM peer 接受 ^19.2.0,业务可按锁文件使用兼容补丁版本。server/shared 没有 React 运行时导入。
48
+
49
+ ## 生命周期版本上报(0.5.0)
50
+
51
+ startBaseApp 的 ready 与 APP_BOOT_FAILED 路径将构建时注入的 App SDK 版本传给 Channel 0.2.0。Channel 附加自身版本及可选 head meta 的 cli/builder;没有 meta 不推断版本。字段均向后兼容,不新增调用方必填配置。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-base-open/base-database-app-sdk",
3
- "version": "0.5.0-durable.0",
3
+ "version": "0.5.0",
4
4
  "description": "Base Database 页面与服务端 SDK、平台组件及测试工具",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -54,26 +54,6 @@
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
- }
77
57
  }
78
58
  },
79
59
  "files": [
@@ -87,7 +67,7 @@
87
67
  "development-pairing.json"
88
68
  ],
89
69
  "scripts": {
90
- "build": "node scripts/sync-contract-schema.mjs --check && node scripts/sync-capabilities.mjs && tsup && tsup --config tsup.cjs.config.ts && cp src/page/theme.css dist/theme.css && node scripts/build-durable.cjs",
70
+ "build": "node scripts/sync-contract-schema.mjs --check && node scripts/sync-capabilities.mjs && tsup && tsup --config tsup.cjs.config.ts && cp src/page/theme.css dist/theme.css",
91
71
  "test": "npm run check:migrations && node scripts/sync-capabilities.mjs --check && npm run build && node --import tsx --test test/*.test.ts && npm run test:types && npm run test:components",
92
72
  "check:migrations": "node scripts/check-migrations.mjs",
93
73
  "prepublishOnly": "npm run check:migrations",
@@ -97,7 +77,7 @@
97
77
  "docs:exports": "node scripts/doc-exports.mjs"
98
78
  },
99
79
  "dependencies": {
100
- "@lark-base-open/base-site-channel": "0.1.6",
80
+ "@lark-base-open/base-site-channel": "0.2.0",
101
81
  "@radix-ui/react-popover": "1.2.0",
102
82
  "@standard-schema/spec": "1.0.0",
103
83
  "cmdk": "1.1.1",
@@ -107,19 +87,11 @@
107
87
  "@tanstack/react-query": "5.104.1",
108
88
  "msw": "2.11.6",
109
89
  "react": "^19.2.0",
110
- "react-dom": "^19.2.0",
111
- "@temporalio/activity": "1.24.0",
112
- "@temporalio/workflow": "1.24.0"
90
+ "react-dom": "^19.2.0"
113
91
  },
114
92
  "peerDependenciesMeta": {
115
93
  "msw": {
116
94
  "optional": true
117
- },
118
- "@temporalio/activity": {
119
- "optional": true
120
- },
121
- "@temporalio/workflow": {
122
- "optional": true
123
95
  }
124
96
  },
125
97
  "devDependencies": {
@@ -134,9 +106,7 @@
134
106
  "tsx": "4.20.3",
135
107
  "typescript": "5.8.3",
136
108
  "vitest": "3.2.4",
137
- "zod": "4.2.1",
138
- "@temporalio/activity": "1.24.0",
139
- "@temporalio/workflow": "1.24.0"
109
+ "zod": "4.2.1"
140
110
  },
141
111
  "typesVersions": {
142
112
  "*": {
@@ -148,12 +118,6 @@
148
118
  ],
149
119
  "codegen": [
150
120
  "dist/codegen.d.cts"
151
- ],
152
- "durable/workflow": [
153
- "dist/durable/workflow.d.ts"
154
- ],
155
- "durable/activity": [
156
- "dist/durable/activity.d.ts"
157
121
  ]
158
122
  }
159
123
  }
@@ -1 +0,0 @@
1
- import{a as Ne,b as W,c as Be}from"./chunk-ZKBZAK4L.js";import{a as Q}from"./chunk-3JX3FIBG.js";import{a as N}from"./chunk-OHPYKFCM.js";import{createContext as en,useContext as rt}from"react";import{createContext as Yt,useContext as Gt,useEffect as Kt,useSyncExternalStore as Jt}from"react";import{capabilityNames as xt}from"@lark-base-open/base-site-channel/capabilities";import*as S from"@lark-base-open/base-site-channel/runtime";import{SITE_RUNTIME_PROTOCOL_VERSION as On,SiteRuntimeApi as oe,SiteRuntimeEvent as Fn,SiteRuntimeFunction as Nn,SiteRuntimeErrorCode as Bn,readSiteAITextDelta as jn,isValidSiteFunctionName as $n}from"@lark-base-open/base-site-channel/runtime-contract";var Y=()=>{throw new Q(W.ContextInvalid,"\u5BBF\u4E3B\u80FD\u529B\u5B57\u6BB5\u65E0\u6548")};function fe(e){if(!e||typeof e!="object")return Y();if(e.capabilities===void 0)return Object.fromEntries(Object.entries(Ne).filter(([,o])=>o.baseline).map(([o])=>[o,{version:1}]));let t=e.capabilities;if(!t||typeof t!="object"||Array.isArray(t))return Y();let n=Object.entries(t);return n.some(([,o])=>!o||typeof o!="object"||Array.isArray(o)||!Number.isSafeInteger(o.version)||o.version<=0)?Y():Object.fromEntries(n.map(([o,r])=>[o,{version:r.version}]))}function Et(e,t,n=1){if(!Number.isSafeInteger(n)||n<1)return Y();let o=fe(e);return Object.prototype.hasOwnProperty.call(o,t)&&o[t].version>=n}async function Ut(e=E){return fe(await e.getRuntimeContext())}var qn=Ut;async function St(e,t=1,n=E){let o=await n.getRuntimeContext(),r=fe(o),i=Et(o,e,t),a=o.capabilityUnavailable;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return Y();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")?Y():{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 je(e,t=1,n=E){let o=await n.getRuntimeContext(),r=await St(e,t,{getRuntimeContext:async()=>o});if(!r.supported)throw new Be(e,t);let i={"permission-denied":W.PermissionDenied,"region-unavailable":W.RegionUnavailable,"temporarily-unavailable":W.TemporarilyUnavailable};if(r.availability in i)throw new Q(i[r.availability],"\u5BBF\u4E3B\u660E\u786E\u62D2\u7EDD\u6B64\u80FD\u529B",void 0,o.capabilityUnavailable?.[e]?.retryable)}function $e(e,t){let n,o=!1,r,i=new Promise(a=>{r=a});return e.registerApi(N.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(N.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(N.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 He=typeof window<"u"&&window.location.protocol==="http:"&&window.location.hostname===N.host&&Number(window.location.port)>=N.portMin&&Number(window.location.port)<=N.portMax;var ze=S.siteRuntime,_=ze.getChannel?.()??ze.channel,Pt=He&&typeof window<"u"&&window.parent!==window?$e(_,globalThis.fetch.bind(globalThis)):void 0;function qe(e,t=async()=>{}){let n=new Map,o=async(r,i)=>{await t();for(let a of xt(r,i))try{await je(a,1,{getRuntimeContext:()=>e.invokeApi(oe.RuntimeContext,void 0)})}catch(s){throw s instanceof Error&&"code"in s?Object.assign(new S.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===oe.HttpRequestCancel||r===oe.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 At={invokeApi:_.invokeApi.bind(_),emitEvent:_.emitEvent.bind(_),subscribeEvent:_.subscribeEvent.bind(_)},be=qe(At,async()=>{if(typeof window<"u"&&window.parent===window)throw new S.SiteRuntimeInvocationError("CHANNEL_UNAVAILABLE","\u9875\u9762\u672A\u8FDE\u63A5\u5BBF\u4E3B channel");await Pt?.wait()});_.invokeApi=be.invokeApi;_.emitEvent=be.emitEvent;var ge=class extends S.SiteRuntimeClient{constructor(t){super(t?qe(t):be)}},Xn=e=>new ge(e),E=S.siteRuntime,{invokeHttp:re,invokeApi:Zn,getCurrentUser:X,logout:he,requestEdit:kt,uploadAttachment:eo,openLink:ae}=E,It=(e=E,t)=>S.createSiteRuntimeFetch(e,t),D=It();var _t=re,Tt=/^\/?(preview\/)?app\/([^/]+)(\/|$)/,Ve=/^[A-Za-z0-9_-]+$/,Ge="/space/api/bitable/site/v1",Dt="/space/api/box/file/temporary_download_url",G="preview",Z=null;function Mt(){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 we(){let e=typeof globalThis.location>"u"?"":globalThis.location.pathname,t=Tt.exec(e),n=Mt();return t?{env:t[1]?G:"prod",gatewayOrigin:n,token:decodeURIComponent(t[2]??"")}:{env:"prod",gatewayOrigin:n,token:""}}function B(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Lt(e){return e===G||e==="prod"}function Ot(e){if(!B(e))return{};let t=typeof e.siteToken=="string"?e.siteToken.trim():"";return{...t?{token:t}:{},...Lt(e.env)?{env:e.env}:{}}}async function j(){return Z||(Z=(async()=>{let e=we(),t={},n;try{n=await E.getRuntimeContext(),t=Ot(n)}catch(r){console.warn("Could not read the host Runtime context; inferring it from the artifact path",r)}ie=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 Z=null,ie={...Re},e}),Z)}function ve(e){return!!(e.tableId.trim()&&e.fieldId.trim()&&e.recordId.trim()&&e.fileToken.trim())}function Ke(e,t){return JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},siteToken:e.token,siteEnv:e.env}})}function Je(e,t){if(t instanceof Error)return t;let n=B(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 Qe(e,t=360,n={}){if(n.signal?.throwIfAborted(),!ve(e)||!Number.isFinite(t)||t<=0)throw new Error("Attachment location or image size is invalid");let o=await j();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:Ke(o,e),width:String(r),height:String(r),policy:"allow_up",fallback_source:"1"}),a=await _t({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 Je("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 Ft(e,t){if(!e.token)throw new Error("Cannot get an attachment download URL without an app token");if(!ve(t))throw new Error("Cannot get an attachment download URL: the attachment location is incomplete");let n=await D(Dt,{body:JSON.stringify({extra:Ke(e,t),file_token:t.fileToken}),headers:{"content-type":"application/json"},method:"POST"}).catch(s=>{throw Je("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=B(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=B(r)&&B(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 We(e){let t=new URLSearchParams;e.env===G&&t.set("env",G);let n=t.toString(),o=`${Ge}/${encodeURIComponent(e.token)}/invoke_get`;return n?`${o}?${n}`:o}function Xe(e,t){if(!Ve.test(t))throw new TypeError(`functionId ${t} does not match the required pattern ${String(Ve)}`);let n=`${Ge}/${encodeURIComponent(e.token)}/functions/${encodeURIComponent(t)}/invoke`;return e.env===G?`${n}?env=${encodeURIComponent(G)}`:n}var Nt="x-base-site-session-id",Bt="x-base-site-read-your-writes",jt=800008918,Ye=new Map,Re={maxRetries:3,intervalMs:300},ie={...Re},$t=10,Ht=100,zt=2e3;function qt(e){let t=B(e)?e.readYourWritesRetry:void 0;return B(t)&&Number.isInteger(t.maxRetries)&&t.maxRetries>=0&&t.maxRetries<=$t&&Number.isInteger(t.intervalMs)&&t.intervalMs>=Ht&&t.intervalMs<=zt?{maxRetries:t.maxRetries,intervalMs:t.intervalMs}:{...Re}}function Vt(e){let t=Ye.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 Ye.set(e,o),o}function Ze(e){let t=Vt(e);return{"content-type":"application/json",...t?{[Nt]:t}:{}}}var ye=class extends Q{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 ro(e,t,n){let o=await j();if(!o.token)throw new Error(`Cannot invoke Function ${e} without an app token`);let r=n?.readYourWrites!==!1,i={...Ze(o.token),...r?{[Bt]:"1"}:{}},a=()=>re({url:Xe(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===jt){if(s<ie.maxRetries){await new Promise(u=>setTimeout(u,ie.intervalMs));continue}throw new ye({logId:d.data?.log_id})}return d}}async function ao(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 j();if(!n.token)throw new Error("\u5E94\u7528 token \u672A\u786E\u5B9A\uFF0C\u65E0\u6CD5\u8C03\u7528 Mutation");let o=await re({url:Xe(n,e),init:{body:JSON.stringify({batch:t.map(r=>({params:r}))}),headers:Ze(n.token),method:"POST"}});if(!o.ok)throw new Error(`Mutation \u8C03\u7528\u5931\u8D25\uFF1AHTTP ${o.status}`);return await o.json()}async function io(e,t){let n=await Ft(e,t);if(!(await ae(n)).opened)throw new Error("The host did not open the attachment download link")}function so(e,t,n=360){if(!e.gatewayOrigin||!e.token||!ve(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 Se=Yt(void 0),tt=[{id:"en",locale:"en-US",match:/^en(?:-|$)/},{id:"zh",locale:"zh-CN",match:/^zh(?:-|$)/},{id:"ja",locale:"ja-JP",match:/^ja(?:-|$)/}],Ee=new Set,nt,Ce=null;function Ue(e){if(typeof e!="string")return;let t=e.trim().replace(/_/g,"-").toLowerCase();return tt.find(({match:n})=>n.test(t))?.id}function Qt(){return typeof navigator>"u"?void 0:navigator.language}function Wt(e,t){return Ue(e)??Ue(t)??"en"}function $(){return nt??Wt(void 0,Qt())}function xe(e=$()){return tt.find(({id:t})=>t===e)?.locale??"en-US"}function Xt(e){return Ee.add(e),()=>Ee.delete(e)}function et(e){nt=Ue(e);let t=$();ot(t);for(let n of Ee)n();return t}function ot(e){typeof document<"u"&&(document.documentElement.lang=xe(e))}function Zt(){return Ce||(ot($()),Ce=E.getRuntimeContext().then(e=>et(e?.locale)).catch(()=>et(void 0))),Ce}function x(){let e=Gt(Se),t=Jt(Xt,$,()=>"en");return Kt(()=>{e||Zt()},[e]),e??t}import{jsx as Pe}from"react/jsx-runtime";var Ae=en(null);function ho({children:e,...t}){return Pe(Ae.Provider,{value:t,children:Pe(Se.Provider,{value:t.locale,children:Pe("div",{className:"base-app-platform","data-theme":t.theme,children:e})})})}function yo(){let e=rt(Ae);if(!e)throw new Error("BASE_APP_PROVIDER_REQUIRED");return e}function se(){return rt(Ae)}import{useState as ee,useEffect as st}from"react";import{QueryClient as tn}from"@tanstack/react-query";var ke=new tn({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}});function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function le(e,t){let n=e[t];return typeof n=="string"?n.trim():""}function nn(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function H(){return{baseBindings:[],name:"",description:"",isOwner:!1,allowEdit:!1,organization:""}}function on(){let e=document.querySelector('meta[name="description"]');return e instanceof HTMLMetaElement?e:null}function rn(e){if(e.name&&(document.title=e.name),e.description){let t=on();t&&(t.content=e.description)}}function an(e){return Array.isArray(e)?e.reduce((t,n)=>{if(!ce(n))return t;let o=le(n,"baseToken");return o&&t.push({baseToken:o,tableIds:nn(n.tableIds)}),t},[]):[]}function sn(e){if(!ce(e)||e.code!==0)return H();let t=e.data;if(!ce(t))return H();let n=t.site;return ce(n)?{baseBindings:an(n.baseBindings),description:le(n,"description"),name:le(n,"name"),isOwner:t.isOwner===!0,allowEdit:n.allowEdit===void 0?t.isOwner===!0:n.allowEdit===!0,organization:le(n,"organization")}:H()}async function at(e){try{let t=await D(We(e),{method:"GET"});if(!t.ok)return H();let n=await t.json(),o=sn(n);return rn(o),o}catch{return H()}}async function K(){let e=await j();if(!e.token)return H();let t=await X().catch(()=>null);return t?.userId?ke.fetchQuery({queryKey:["project-meta",e.token,e.env,t.userId],queryFn:()=>at(e)}):at(e)}var cn="https://feishu.cn/base/site/detail/overview";async function it(){try{await E.requestEdit();return}catch{let{token:e}=await j(),t=new URL(cn);if(t.searchParams.set("token",e),!(await ae(t.toString())).opened)throw new Error("Management page was not opened")}}import{jsx as z,jsxs as ct}from"react/jsx-runtime";var ln={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\u9762\u677F",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 Mo({position:e="bottom-right",className:t="",slots:n={}}){let o=ln[x()],[r,i]=ee(!1),[a,s]=ee(!1),[c,d]=ee(!1),[u,p]=ee(!1),[b,g]=ee(!1);st(()=>{let h=!0;return K().then(O=>{h&&i(O.allowEdit&&we().env==="prod")}).catch(()=>{}),()=>{h=!1}},[]),st(()=>{if(!c)return;let h=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(h)},[c]);let m=n.trigger,v=n.tooltip;return r?a?c?ct("div",{className:"base-app-platform base-app-notice",role:"status",children:[o.hiddenConfirmation,z("button",{"aria-label":o.dismissNotification,onClick:()=>d(!1),children:"\xD7"})]}):null:ct("div",{className:`base-app-platform base-app-floating ${t}`,"data-position":e,children:[u?z("div",{role:"alert",children:o.openFailed}):null,b?z("div",{role:"tooltip",children:v?z(v,{text:o.editSite}):o.editSite}):null,z("button",{"aria-label":o.editSite,onFocus:()=>g(!0),onBlur:()=>g(!1),onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),onClick:()=>{p(!1),it().catch(()=>p(!0))},children:m?z(m,{}):"\u270E"}),z("button",{"aria-label":o.hidePanel,onClick:()=>{s(!0),d(!0)},children:"\xD7"})]}):null}var Ie=new Set;function lt(e){return Ie.add(e),()=>{Ie.delete(e)}}function ut(){for(let e of Ie)e()}import{useEffect as un,useState as pt}from"react";import*as M from"@radix-ui/react-popover";async function dt(){try{let e=await X();if(typeof e?.name=="string"&&e.name)return{name:e.name,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:"",tenantName:""}}catch{}try{let e=await D("/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 pn,jsx as P,jsxs as _e}from"react/jsx-runtime";var dn={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 Ko({audience:e="enterprise",align:t="right",side:n="down",showName:o=!0,className:r="",slots:i={}}){let[a,s]=pt(null),[c,d]=pt(""),u=se(),p=dn[x()];if(un(()=>{if(e!=="enterprise")return;let m=!0;return Promise.all([dt(),K().catch(()=>null)]).then(([v,h])=>{m&&(s(v),d(v?.tenantName||h?.organization||""))}),()=>{m=!1}},[e]),e!=="enterprise"||!a)return null;let b=i.trigger,g=i.organization;return _e(M.Root,{children:[P(M.Trigger,{asChild:!0,children:P("button",{className:`base-app-platform base-app-user-menu ${r}`,"aria-label":p.account,children:b?P(b,{user:a}):_e(pn,{children:[a.avatarUrl?P("img",{src:a.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):P("span",{children:a.name.slice(0,1)}),o?a.name:null]})})}),P(M.Portal,{children:_e(M.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:[P("strong",{children:a.name}),g?P(g,{name:c}):P("p",{children:c}),P("button",{onClick:()=>{ut(),ke.clear(),he().catch(()=>{for(let m of["base-site-session","session","sl_session"])document.cookie=`${m}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;window.location.reload()})},children:p.logout})]})})]})}import{useEffect as ue,useRef as gt,useState as q}from"react";import{Command as te}from"cmdk";import{QueryClient as Un,useQuery as Sn}from"@tanstack/react-query";var mn="/space/api/mention/recommend.v2/",fn="8",gn="4",bn="0",hn=20,mt={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 ft(e,t,n){let o=t??$(),r=mt[o],a=(await K()).baseBindings[0]?.baseToken;if(!a)throw new Error(r.noBoundBase);let s=new URLSearchParams({config_source:"0",obj_type:fn,source:gn,token:a,type:bn,user_type:"0",content:e.trim().slice(0,50)}).toString(),c=await D(mn,{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:yn(d,o)}}function yn(e,t=$()){let n=xe(t),o=mt[t],r=wn(e,o);if(!r)throw new Error(o.invalidResponse);let i=r.entities,a=A(i)?i.users:void 0;if(!A(a)||!Array.isArray(r.result_list))throw new Error(o.invalidResponse);let s=[],c=new Set;for(let d of r.result_list){if(!A(d)||Number(d.type)!==0)continue;let u=f(d.token);if(!u)continue;let p=a[u];if(!A(p))continue;let b=f(p.user_id)||f(p.id)||u,g=vn(p,n);if(!b||!g||c.has(b))continue;c.add(b);let m=f(p.avatar_url),v=f(p.open_id);if(s.push({avatar:{avatar_72:m,avatar_240:m,avatar_640:m,avatar_origin:m},department_ids:En(p.department_ids),description:Rn(p,n),is_external:p.is_external===!0,name:g,user_id:b,...v?{open_id:v}:{}}),s.length>=hn)break}return{users:s}}function wn(e,t){if(A(e)){if(typeof e.code=="number"&&e.code!==0){let n=f(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:A(e.data)?e.data:void 0}}function vn(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=A(n)?n:{},a=A(i.i18n_value)?i.i18n_value:i,s=r==="zh"?e.cn_name:r==="en"?e.en_name:void 0;return f(a[o])||f(a[r])||f(s)||f(i.value)||f(e.name)||f(e.en_name)||f(e.cn_name)}function Rn(e,t){let n=e.is_external===!0?e.i18n_tenant:e.i18n_department;return Cn(n,t)||f(e.department)}function Cn(e,t){if(typeof e=="string")return e.trim();if(!A(e))return"";let n=t.toLowerCase().replace("-","_"),o=n.split("_")[0]??"",r=A(e.i18n_value)?e.i18n_value:e,i=f(r[n])||f(r[o]);if("i18n_value"in e)return i||f(e.value);let a=o==="zh"?f(r.zh_cn)||f(r.en_us):f(r.en_us)||f(r.zh_cn);return i||f(e.value)||a}function f(e){return typeof e=="string"?e.trim():""}function En(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Fragment as ht,jsx as C,jsxs as Te}from"react/jsx-runtime";var yt={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 de(e){let[t,n]=q(!1),[o,r]=q(!1);ue(()=>r(!0),[]);let i=x(),a=yt[i],[s]=q(()=>new Un({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}}));ue(()=>{let l=lt(()=>{n(!0),s.clear()});return()=>{l(),s.clear()}},[s]);let c=Object.prototype.hasOwnProperty.call(e,"value"),d=gt(c);ue(()=>{c!==d.current&&console.warn("UserSelectorPanel controlled mode changed")},[c]);let[u,p]=q(e.defaultValue),b=c?e.value:u,g=Array.isArray(b)?b:b?[b]:[],[m,v]=q(""),[h,O]=q(""),[k,J]=q(!1),F=gt(!1);ue(()=>{if(k)return;let l=setTimeout(()=>O(m.trim()),m.trim()?400:0);return()=>clearTimeout(l)},[m,k]);let y=Sn({queryKey:["members",i,h],queryFn:async({signal:l})=>{let R=await ft(h,i,l);return xn(R,i)},enabled:!t&&o&&!k&&m.trim()===h},s),w=e.loading||y.isFetching||m.trim()!==h,I=!t&&!w&&!y.error&&y.data?[...y.data.users,...g.filter(l=>!y.data.users.some(R=>R.user_id===l.user_id))]:[],U=(l,R)=>{v(l),e.onSearch?.(l,{action:R})},pe=()=>{U("","AutoClear"),e.onClose?.()},Ct=l=>{if(F.current)return;let R=g.some(me=>me.user_id===l.user_id),ne=e.mode==="multiple"?R?g.filter(me=>me.user_id!==l.user_id):[...g,l]:R?void 0:l;c||p(ne),e.onChange?.(ne,{option:l,action:R?"Remove":"Select"}),R||e.onSelect?.(l,{option:l}),e.mode==="multiple"?U("","AutoClear"):pe()},Me=e.slots?.empty,Le=e.slots?.loading,Oe=e.slots?.option,Fe=e.slots?.footer;return Te(te,{shouldFilter:!1,loop:!0,className:`base-app-platform base-app-selector ${e.className??""}`,label:a.memberList,children:[C(te.Input,{autoFocus:!0,placeholder:a.searchMembers,"aria-label":a.searchMembers,value:m,onValueChange:l=>U(l,"Input"),onCompositionStart:()=>{F.current=!0,J(!0)},onCompositionEnd:()=>{F.current=!1,J(!1)},onKeyDown:l=>{if(e.onKeyDown?.(l),l.defaultPrevented){l.stopPropagation();return}if(F.current||Pn(l)){l.stopPropagation();return}l.key==="Escape"&&(l.preventDefault(),pe())}}),C(te.List,{"aria-label":a.memberList,"aria-multiselectable":e.mode==="multiple"||void 0,children:w?C("div",{role:"status",children:Le?C(Le,{}):a.loading}):y.error?C("div",{role:"alert",children:a.searchFailed}):Te(ht,{children:[e.onSelectRecordCreator?C(te.Item,{value:"record-creator",onSelect:()=>{e.onSelectRecordCreator?.(),pe()},children:a.recordCreator}):null,I.map(l=>{let R=g.some(ne=>ne.user_id===l.user_id);return C(te.Item,{value:l.user_id,onSelect:()=>Ct(l),"data-checked":R,children:Oe?C(Oe,{user:l,selected:R}):Te(ht,{children:[C("span",{children:l.name}),C("small",{children:e.getUserDescription?.(l)??l.description}),R?C("span",{"aria-label":"selected",children:"\u2713"}):null]})},l.user_id)}),!I.length&&!e.onSelectRecordCreator?C("div",{role:"status",children:Me?C(Me,{}):m.trim()?a.noMatches:a.noRecommendations}):null]})}),Fe?C(Fe,{}):null]})}function xn(e,t){let n=yt[t];if(!bt(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(!bt(e.data)||!Array.isArray(e.data.users))throw new Error(n.invalidResponse);return{users:e.data.users}}function bt(e){return typeof e=="object"&&e!==null}function Pn(e){return e.nativeEvent?.isComposing===!0||e.keyCode===229}import{useState as An,useRef as kn}from"react";import*as L from"@radix-ui/react-popover";import{jsx as T,jsxs as wt}from"react/jsx-runtime";var In={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 vt(e){let t=kn(null),n=se(),o=In[x()],[r,i]=An(!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 wt(L.Root,{open:r,onOpenChange:s,children:[wt("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:[T(L.Trigger,{asChild:!0,children:T("button",{type:"button","data-base-app-trigger":"","aria-label":o.selectMembers,onFocus:e.onFocus,onBlur:e.onBlur,children:c?T(c,{value:e.value}):a.length?a.map(u=>T("span",{children:d?T(d,{user:u}):u.name},u.user_id)):o.selectMembers})}),a.map(u=>T("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(b=>b.user_id!==u.user_id):void 0),e.mode==="multiple"?e.onRemove?.(u):e.onClear?.()},children:"\xD7"},u.user_id))]}),T(L.Portal,{container:e.portalContainer??t.current?.closest("dialog")??void 0,children:T(L.Content,{"data-theme":n?.theme,className:"base-app-platform base-app-popover",sideOffset:4,collisionPadding:8,children:T(de,{...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 Rt,useRef as _n,useState as De}from"react";import{jsx as V,jsxs as Dn}from"react/jsx-runtime";var Tn={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 vr({attachment:e,size:t=360,alt:n,className:o,slots:r={}}){let i=x(),a=Tn[i],s=_n(null),[c,d]=De(!1),[u,p]=De(0),[b,g]=De({key:"",url:"",error:""}),{tableId:m,fieldId:v,recordId:h,fileToken:O}=e,k=JSON.stringify([m,v,h,O,t,u]);Rt(()=>{if(typeof IntersectionObserver>"u"){d(!0);return}let w=new IntersectionObserver(I=>{I.some(U=>U.isIntersecting)&&(d(!0),w.disconnect())},{rootMargin:"200px"});return s.current&&w.observe(s.current),()=>w.disconnect()},[]),Rt(()=>{if(!c)return;let w=new AbortController,I="";return Qe({tableId:m,fieldId:v,recordId:h,fileToken:O},t,{signal:w.signal}).then(U=>{w.signal.aborted||(I=URL.createObjectURL(U),g({key:k,url:I,error:""}))}).catch(U=>{w.signal.aborted||g({key:k,url:"",error:U instanceof Error?U.message:"",localError:U instanceof Error?void 0:"loadFailed"})}),()=>{w.abort(),I&&URL.revokeObjectURL(I)}},[c,k,m,v,h,O,t]);let J=r.loading,F=r.error,y=b.key===k?b:void 0;return V("span",{ref:s,className:`base-app-platform base-app-attachment ${o??""}`,"aria-busy":!y,children:y?.url?V("img",{src:y.url,alt:n,onError:()=>g({key:k,url:"",error:"",localError:"decodeFailed"})}):y?.error||y?.localError?F?V(F,{code:"ATTACHMENT_LOAD_FAILED",retry:()=>p(w=>w+1)}):Dn("span",{children:[V("span",{role:"status",children:y.localError?a[y.localError]:y.error}),V("button",{type:"button",onClick:()=>p(w=>w+1),children:a.retry})]}):V("span",{role:"status",children:J?V(J,{}):a.loading})})}export{On as a,oe as b,Fn as c,Nn as d,Bn as e,jn as f,$n as g,qe as h,be as i,ge as j,Xn as k,E as l,re as m,Zn as n,X as o,he as p,kt as q,eo as r,ae as s,It as t,D as u,fe as v,Et as w,Ut as x,qn as y,St as z,je as A,we as B,j as C,Qe as D,Ft as E,We as F,Xe as G,ye as H,ro as I,ao as J,io as K,so as L,Se as M,Wt as N,$ as O,xe as P,Zt as Q,x as R,ho as S,yo as T,se as U,ke as V,Mo as W,Ko as X,de as Y,vt as Z,vr as _};
@@ -1,25 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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>;
@@ -1,6 +0,0 @@
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>;
@@ -1,107 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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 {};
@@ -1,15 +0,0 @@
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 {};
package/docs/durable.md DELETED
@@ -1,54 +0,0 @@
1
- # Base Site Durable SDK
2
-
3
- 供 Base Site 的 Durable Function 源码使用。Workflow 定义执行顺序和等待,Activity 执行网络请求、站点 Function 调用等业务操作。执行由 DevCenter 管理的 Worker 承载。
4
-
5
- Durable 是 App SDK 的两个子入口。预发布版本 0.5.0-durable.0 使用 npm 的 durable 标签;0.4.0 不包含这些入口。使用前需确认目标平台已部署匹配的 Durable 运行时。
6
-
7
- ## 构建与安装
8
-
9
- 安装此预发布版本:`npm install @lark-base-open/base-database-app-sdk@0.5.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 管理不进入此包。
@@ -1,3 +0,0 @@
1
- export async function double(input: { value: number }): Promise<number> {
2
- return input.value * 2;
3
- }
@@ -1,8 +0,0 @@
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
- }