@tinkerlandai/indiana-sdk 0.0.1 → 0.2.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 +17 -0
- package/README.md +52 -264
- package/dist/{api-DDlcUvTv.d.ts → ai-usage-CO0lDavO.d.ts} +3163 -660
- package/dist/chunk-EZFAY4ZL.js +1 -0
- package/dist/chunk-ULRVTA45.js +1 -0
- package/dist/chunk-YOH6DIUN.js +27 -0
- package/dist/{coupon-gncDkBtm.d.ts → customer-page-aZb5Twue.d.ts} +122 -3
- package/dist/funnel-runtime-host-OJJSHKUD.js +1 -0
- package/dist/funnel-runtime-start-DvrWekm0.d.ts +9330 -0
- package/dist/index.d.ts +8677 -1611
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/paywall-HCADUT22.js +1 -0
- package/dist/popup.d.ts +19 -123
- package/dist/popup.js +5 -4
- package/dist/{funnel-runtime-C05ZECiP.d.ts → screen-DfuSw6Tz.d.ts} +320 -2419
- package/dist/server.d.ts +4 -765
- package/dist/server.js +1 -1
- package/dist/src-3GT6E6XD.js +1 -0
- package/package.json +3 -3
- package/dist/ai-usage-CzA11PV5.d.ts +0 -235
- package/dist/chunk-IUDHYOKC.js +0 -21
- package/dist/chunk-OIWEFX7U.js +0 -1
- package/dist/chunk-TDSKWZTO.js +0 -1
- package/dist/feature-client-CyYevYy2.d.ts +0 -450
- package/dist/funnel-runtime-host-DWRQK5U2.js +0 -4
- package/dist/src-MCXYJ2QR.js +0 -1
package/dist/openrouter.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OpenRouter } from '@openrouter/sdk';
|
|
2
2
|
import { ChatUsage } from '@openrouter/sdk/models';
|
|
3
|
-
import { F as FoundationApi } from './
|
|
4
|
-
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-CzA11PV5.js';
|
|
5
|
-
import 'zod';
|
|
3
|
+
import { c as createAiPricing, F as FoundationApi, a as AiUsageContext, b as AiTokenUsage, d as AiTokenQuote } from './ai-usage-CO0lDavO.js';
|
|
6
4
|
import '@ai-sdk/provider';
|
|
5
|
+
import './screen-DfuSw6Tz.js';
|
|
6
|
+
import 'zod';
|
|
7
7
|
|
|
8
8
|
type OpenRouterUsageRecord = {
|
|
9
9
|
context: AiUsageContext;
|
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-EZFAY4ZL.js";import"./chunk-YOH6DIUN.js";import{z as R}from"zod";var c=R.number().int().min(0).max(1e9);function k(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function h(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):k(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await h({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:A}=await w.read();if(A){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,h as trackOpenRouterUsage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as H}from"./chunk-6X42DWOM.js";import{a as m}from"./chunk-EZFAY4ZL.js";import{Oe as V,cl as B,ne as U,y as M}from"./chunk-YOH6DIUN.js";async function F(y,t,d){if(t.status!=="complete")throw new m("INVALID_RESPONSE","A verified completed purchase is required");if(await d.onComplete?.(t),!y||!d.check)return;let a=U.parse(await d.check());if(a.internal_feature_id!==y.internal_feature_id||a.quantity!==y.quantity)throw new m("INVALID_RESPONSE","The access requirement changed");a.allowed&&await d.onAccessGranted?.(a)}async function re(y,t){let d=t.check?U.parse(await t.check()):null;if(d?.allowed)return await t.onAccessGranted?.(d),{check:d,host:null};let a=await t.start(),p=a.view;if(!p)throw new m("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:j}=await import("./popup.js"),n=y.ownerDocument,A=new AbortController,E=n.createElement("section"),$=n.createElement("div"),I=n.createElement("div"),g=n.createElement("p"),v=n.createElement("button"),D=n.createElement("button"),f=n.createElement("dialog"),L=n.activeElement,w=p.document.screen.strings.defaultLocale.startsWith("zh");E.dataset.indianaPaywall="",E.setAttribute("aria-label",p.document.name),E.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",I.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",g.setAttribute("role","status"),D.textContent=w?"\u5173\u95ED":"Close",v.textContent=w?"\u91CD\u8BD5":"Retry",v.hidden=!0,I.append(g,v,D),E.append($,I);let N=p.document.presentation;if(N.type==="inline")y.append(E);else{let e={sm:420,md:640,lg:900};f.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in N?e[N.size]+"px":"100vw"}`,f.setAttribute("aria-label",p.document.name),f.append(E),y.append(f),f.showModal()}let u=!1,_=!1,l=null,T=!1,i=null,P=null,R=e=>{g.textContent=e instanceof Error?e.message:w?"\u8BF7\u6C42\u5931\u8D25":"Request failed",H(t.onError,e),v.hidden=i===null};async function b(e){if(!(_||u)){_=!0,v.hidden=!0,g.textContent="";try{await e()}catch(o){u||R(o)}finally{_=!1}}}async function W(e){await F(d,e,t)}async function S(e){if(u)return;if(g.textContent=e.status,e.status==="complete"){i=null,await W(e);return}if(e.status!=="pending"){i=null,l=null;return}let o=Date.now()+6e5,c=2e3;for(;!u&&Date.now()<o;){if(await new Promise(h=>{let x=()=>{clearTimeout(C),h()},C=setTimeout(()=>{A.signal.removeEventListener("abort",x),h()},c);A.signal.addEventListener("abort",x,{once:!0})}),u)return;let r=await a.read();if(r.status!=="pending"){await S(r);return}c=Math.min(c*1.5,3e4)}i=async()=>S(await a.read()),v.hidden=!1}async function z(){P?.remove(),P=null,i=z;let e=await a.confirm();if(e.status==="pending"){if(e.checkoutUrl)t.onCheckoutUrl?await t.onCheckoutUrl(e.checkoutUrl):n.defaultView?.location.assign(e.checkoutUrl);else if(e.execution||e.nativePurchase){if(!t.onPurchase)throw new m("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await t.onPurchase({operation:e,signal:A.signal})}}i=async()=>S(await a.read()),await S(e)}function J(e){P?.remove();let o=n.createElement("div"),c=n.createElement("button"),r=n.createElement("button"),h=n.createElement("p");h.textContent=e.lines.map(s=>s.productName).join(", ")+" \xB7 "+M(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),c.textContent=w?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",r.textContent=w?"\u53D6\u6D88":"Cancel",c.onclick=()=>{b(z)};let x=async()=>{await a.cancel(),!u&&(l=null,i=null,o.remove(),P=null)};r.onclick=()=>{i=x,b(x)};let C=n.createElement("div");for(let s of e.lines){let q=n.createElement("p");if(q.textContent=`${s.productName} \xB7 ${M(s.catalogAmountMinor,e.currency)}${B(s.interval,w?"zh-CN":"en",s.intervalCount??1)}`,C.append(q),s.trial){let G=n.createElement("p");G.textContent=w?`\u8BD5\u7528 ${s.trial.days} \u5929\uFF1B${s.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${s.trial.days}; ${s.trial.cardRequired?"a payment method is required":"no payment method is required"}`,C.append(G)}}if(!e.charge){let s=n.createElement("p");s.textContent=w?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",C.append(s)}o.append(h,C,c,r),I.prepend(o),P=o,i=null}async function Q(){if(!l)return;if(i=Q,!T){let o=a.view,c=o?.document.buttons[l.actionId],r=o&&c?.type==="checkout"?V(c.product,l.selection,o.capabilities):null;if(!r)throw new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let h=await t.resolveOfferId?.({actionId:l.actionId,productVersionId:r});if(u)return;h!==void 0&&(l.offerId=h),T=!0}let e=await a.preview(l);u||J(e)}let O=j($,{mode:"live",rendererUrl:a.webViewUrl,title:p.document.name,onAction(e,o={}){let c=a.view,r=c?.document.buttons[e];if(r){if(r.type==="close"){b(async()=>{await t.onAction?.(e),k(t.onAction?"action":"dismiss")});return}if(r.type==="action"){i=async()=>{if(r.action.type==="event"){if(!t.onEvent)throw new m("EVENT_HANDLER_REQUIRED","Provide the event handler");await t.onEvent(r.action.event)}else t.onOpenUrl?await t.onOpenUrl(r.action.url):n.defaultView?.location.assign(r.action.url);await t.onAction?.(e),i=null},b(i);return}if(!c||!V(r.product,o,c.capabilities)){R(new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(l&&l.actionId!==e){R(new m("COMMAND_PENDING","Finish the current purchase"));return}l||(l={requestId:crypto.randomUUID(),actionId:e,selection:o},T=!1),b(Q)}},onEscape:()=>k("dismiss"),onError:e=>R(new Error(e))});O.update(p.document.screen,p.document.screen.strings.defaultLocale,{capabilities:p.capabilities,serverInput:{bindings:[],answers:{}}});try{await O.ready}catch(e){throw k(),e}function k(e="destroy"){u||(u=!0,A.abort(),O.destroy(),a.destroy(),f.open&&f.close(),f.remove(),E.remove(),L instanceof HTMLElement&&L.isConnected&&L.focus(),e==="dismiss"&&H(t.onDismiss))}return D.onclick=()=>k("dismiss"),f.addEventListener("cancel",e=>{e.preventDefault(),k("dismiss")}),v.onclick=()=>{i&&b(i)},{check:d,host:{destroy:k,refresh:async()=>{let e=await a.refresh();return u||O.updateCapabilities(e.capabilities),e}}}}export{re as showPaywall};
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as ScreenAction, b as ScreenNode, c as ScreenDocument, d as SurfaceData } from './screen-DfuSw6Tz.js';
|
|
2
|
+
import { O as Offer, b as OfferUnavailableReason, c as CustomerPageData, a as CustomerDataIntent } from './customer-page-aZb5Twue.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { WindowLike } from 'dompurify';
|
|
5
5
|
|
|
@@ -24,127 +24,22 @@ type PopupEvent = {
|
|
|
24
24
|
reason: OfferUnavailableReason | "error" | null;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
declare const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
credit_packs: "credit_packs";
|
|
37
|
-
credit_pack_orders: "credit_pack_orders";
|
|
38
|
-
offer_history: "offer_history";
|
|
39
|
-
}>;
|
|
40
|
-
status: z.ZodEnum<{
|
|
41
|
-
error: "error";
|
|
42
|
-
ready: "ready";
|
|
43
|
-
idle: "idle";
|
|
44
|
-
loading: "loading";
|
|
45
|
-
}>;
|
|
46
|
-
stale: z.ZodBoolean;
|
|
47
|
-
preview: z.ZodBoolean;
|
|
48
|
-
errorCode: z.ZodOptional<z.ZodString>;
|
|
49
|
-
errorMessage: z.ZodOptional<z.ZodString>;
|
|
50
|
-
resources: z.ZodArray<z.ZodObject<{
|
|
51
|
-
key: z.ZodString;
|
|
52
|
-
name: z.ZodString;
|
|
53
|
-
spendable: z.ZodString;
|
|
54
|
-
reserved: z.ZodString;
|
|
55
|
-
available: z.ZodString;
|
|
56
|
-
expiry: z.ZodNullable<z.ZodString>;
|
|
57
|
-
sources: z.ZodArray<z.ZodObject<{
|
|
58
|
-
id: z.ZodString;
|
|
59
|
-
label: z.ZodString;
|
|
60
|
-
detail: z.ZodArray<z.ZodString>;
|
|
61
|
-
value: z.ZodOptional<z.ZodString>;
|
|
62
|
-
status: z.ZodOptional<z.ZodString>;
|
|
63
|
-
facts: z.ZodArray<z.ZodObject<{
|
|
64
|
-
label: z.ZodString;
|
|
65
|
-
value: z.ZodString;
|
|
66
|
-
}, z.core.$strict>>;
|
|
67
|
-
purchaseId: z.ZodOptional<z.ZodUUID>;
|
|
68
|
-
invoiceUrl: z.ZodOptional<z.ZodURL>;
|
|
69
|
-
billingActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
70
|
-
action: z.ZodLiteral<"invoice_open">;
|
|
71
|
-
label: z.ZodString;
|
|
72
|
-
}, z.core.$strict>>>;
|
|
73
|
-
membershipActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
74
|
-
value: z.ZodString;
|
|
75
|
-
label: z.ZodString;
|
|
76
|
-
}, z.core.$strict>>>;
|
|
77
|
-
}, z.core.$strict>>;
|
|
78
|
-
sourceCount: z.ZodNumber;
|
|
79
|
-
sourcePage: z.ZodNumber;
|
|
80
|
-
hasNextSources: z.ZodBoolean;
|
|
81
|
-
hasPreviousSources: z.ZodBoolean;
|
|
82
|
-
}, z.core.$strict>>;
|
|
83
|
-
rows: z.ZodArray<z.ZodObject<{
|
|
84
|
-
id: z.ZodString;
|
|
85
|
-
label: z.ZodString;
|
|
86
|
-
detail: z.ZodArray<z.ZodString>;
|
|
87
|
-
value: z.ZodOptional<z.ZodString>;
|
|
88
|
-
status: z.ZodOptional<z.ZodString>;
|
|
89
|
-
facts: z.ZodArray<z.ZodObject<{
|
|
90
|
-
label: z.ZodString;
|
|
91
|
-
value: z.ZodString;
|
|
92
|
-
}, z.core.$strict>>;
|
|
93
|
-
purchaseId: z.ZodOptional<z.ZodUUID>;
|
|
94
|
-
invoiceUrl: z.ZodOptional<z.ZodURL>;
|
|
95
|
-
billingActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
96
|
-
action: z.ZodLiteral<"invoice_open">;
|
|
97
|
-
label: z.ZodString;
|
|
98
|
-
}, z.core.$strict>>>;
|
|
99
|
-
membershipActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
100
|
-
value: z.ZodString;
|
|
101
|
-
label: z.ZodString;
|
|
102
|
-
}, z.core.$strict>>>;
|
|
103
|
-
}, z.core.$strict>>;
|
|
104
|
-
hasNext: z.ZodBoolean;
|
|
105
|
-
hasPrevious: z.ZodBoolean;
|
|
106
|
-
page: z.ZodNumber;
|
|
107
|
-
filter: z.ZodString;
|
|
108
|
-
updatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
109
|
-
buyingId: z.ZodOptional<z.ZodUUID>;
|
|
110
|
-
membershipBusy: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
-
billingBusy: z.ZodOptional<z.ZodBoolean>;
|
|
112
|
-
membershipReview: z.ZodOptional<z.ZodObject<{
|
|
113
|
-
title: z.ZodString;
|
|
114
|
-
note: z.ZodString;
|
|
115
|
-
facts: z.ZodArray<z.ZodObject<{
|
|
116
|
-
label: z.ZodString;
|
|
117
|
-
value: z.ZodString;
|
|
118
|
-
}, z.core.$strict>>;
|
|
119
|
-
}, z.core.$strict>>;
|
|
120
|
-
membershipResult: z.ZodOptional<z.ZodString>;
|
|
27
|
+
declare const screenAnswersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
28
|
+
declare const screenParametersSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
29
|
+
type ScreenParameters = z.infer<typeof screenParametersSchema>;
|
|
30
|
+
type ScreenAnswers = z.infer<typeof screenAnswersSchema>;
|
|
31
|
+
declare const screenRendererInputSchema: z.ZodObject<{
|
|
32
|
+
bindings: z.ZodArray<z.ZodObject<{
|
|
33
|
+
key: z.ZodString;
|
|
34
|
+
componentId: z.ZodString;
|
|
35
|
+
required: z.ZodBoolean;
|
|
121
36
|
}, z.core.$strict>>;
|
|
37
|
+
answers: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
122
38
|
}, z.core.$strict>;
|
|
123
|
-
type
|
|
124
|
-
declare const customerDataIntentSchema: z.ZodObject<{
|
|
125
|
-
nodeId: z.ZodString;
|
|
126
|
-
action: z.ZodEnum<{
|
|
127
|
-
invoice_open: "invoice_open";
|
|
128
|
-
filter: "filter";
|
|
129
|
-
billing_adjustment: "billing_adjustment";
|
|
130
|
-
billing_authorization: "billing_authorization";
|
|
131
|
-
buy_pack: "buy_pack";
|
|
132
|
-
billing_portal: "billing_portal";
|
|
133
|
-
refresh: "refresh";
|
|
134
|
-
next: "next";
|
|
135
|
-
previous: "previous";
|
|
136
|
-
membership_preview: "membership_preview";
|
|
137
|
-
membership_confirm: "membership_confirm";
|
|
138
|
-
membership_dismiss: "membership_dismiss";
|
|
139
|
-
sources_next: "sources_next";
|
|
140
|
-
sources_previous: "sources_previous";
|
|
141
|
-
}>;
|
|
142
|
-
value: z.ZodOptional<z.ZodString>;
|
|
143
|
-
}, z.core.$strict>;
|
|
144
|
-
type CustomerDataIntent = z.infer<typeof customerDataIntentSchema>;
|
|
39
|
+
type ScreenRendererInput = z.infer<typeof screenRendererInputSchema>;
|
|
145
40
|
|
|
146
41
|
/**
|
|
147
|
-
*
|
|
42
|
+
* Render the current ScreenDocument 4 into DOM.
|
|
148
43
|
*
|
|
149
44
|
* 这个函数会被 `rendererRuntime.toString()` 序列化后放进沙箱 iframe(Web)或 WebView(iOS / Android)
|
|
150
45
|
* 里单独执行,所以**必须完全自包含**:不能引用函数外的任何变量、导入或辅助函数(类型除外)。
|
|
@@ -225,10 +120,11 @@ type ScreenPreviewHandle = {
|
|
|
225
120
|
update(doc: ScreenDocument, locale: string,
|
|
226
121
|
/** Current single-screen presentation and server-owned input bindings. */
|
|
227
122
|
options?: {
|
|
228
|
-
parameters?:
|
|
123
|
+
parameters?: ScreenParameters;
|
|
229
124
|
capabilities?: SurfaceData;
|
|
230
125
|
customerData?: CustomerPageData;
|
|
231
|
-
serverInput?:
|
|
126
|
+
serverInput?: ScreenRendererInput;
|
|
127
|
+
selection?: Record<string, string | boolean>;
|
|
232
128
|
}): void;
|
|
233
129
|
updateCustomerData(data: CustomerPageData): void;
|
|
234
130
|
updateCapabilities(data: SurfaceData): void;
|
|
@@ -252,8 +148,8 @@ declare function mountScreenPreview(container: HTMLElement, options?: {
|
|
|
252
148
|
onHover?: (id: string | null) => void;
|
|
253
149
|
onSelect?: (id: string | null) => void;
|
|
254
150
|
onEdit?: (id: string) => void;
|
|
255
|
-
onAction?: (actionId: string, selection?: Record<string, string | boolean>, answers?:
|
|
256
|
-
onAnswers?: (answers:
|
|
151
|
+
onAction?: (actionId: string, selection?: Record<string, string | boolean>, answers?: ScreenAnswers) => void;
|
|
152
|
+
onAnswers?: (answers: ScreenAnswers) => void;
|
|
257
153
|
onRendered?: () => void;
|
|
258
154
|
/** Live previews report the page actually rendered, when the current screen is rendered. */
|
|
259
155
|
onPageChange?: (pageId: string) => void;
|