@tinkerlandai/longplay-sdk 0.10.4 → 0.10.6
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 +9 -0
- package/README.md +9 -3
- package/README.zh-CN.md +6 -4
- package/dist/chunk-5JJZSH23.js +179 -0
- package/dist/chunk-65WKEU2L.js +1 -0
- package/dist/{chunk-MRN4HP4W.js → chunk-AWZFL4HE.js} +1 -1
- package/dist/{chunk-YQHPEP4X.js → chunk-F4YCLQGU.js} +1 -1
- package/dist/{chunk-KBM7BYQY.js → chunk-FRGIXMNP.js} +1 -1
- package/dist/{chunk-HOW7NIIR.js → chunk-FXVZRIJ3.js} +1 -1
- package/dist/{chunk-JB46ZKGZ.js → chunk-HV4THS52.js} +1 -1
- package/dist/{chunk-VMM3GA3L.js → chunk-JSHLBGDY.js} +1 -1
- package/dist/chunk-MOWYD2TV.js +1 -0
- package/dist/chunk-VUWXU4FP.js +1 -0
- package/dist/{chunk-2HFA34QO.js → chunk-WCVK4OMS.js} +2 -2
- package/dist/content-ZQNYKPZT.js +1 -0
- package/dist/{funnel-local-client-CVokI0rx.d.ts → funnel-local-client-B4Z3dvNf.d.ts} +1 -1
- package/dist/{funnel-resource-client-Cv5OjfAn.d.ts → funnel-resource-client-BhbXsB2q.d.ts} +1 -1
- package/dist/funnel-runtime-host-DDBGBB5L.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-XQG2D3PA.js +1 -0
- package/dist/popup.d.ts +2 -1
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +5 -5
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-NLB3FAQJ.js +1 -0
- package/dist/server.d.ts +3 -3
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-VOEFXEPP.js +0 -1
- package/dist/chunk-X6BCUINI.js +0 -173
- package/dist/chunk-ZPZVSC4J.js +0 -1
- package/dist/content-NYMIZRNR.js +0 -1
- package/dist/funnel-runtime-host-UL4DEJDU.js +0 -1
- package/dist/paywall-EJCNWDHK.js +0 -1
- package/dist/screen-renderer-JMHV4GPP.js +0 -1
package/dist/chunk-ZPZVSC4J.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ue,b as me,c as ye,d as ge,e as ve}from"./chunk-SBPTOOYB.js";import{M as fe,Y as le}from"./chunk-2HFA34QO.js";import{ea as pe,oa as we,qa as m}from"./chunk-ACF2FBUB.js";import{b as he,e as be}from"./chunk-EARSGITJ.js";import{d as Ie}from"./chunk-HOW7NIIR.js";import{a as z}from"./chunk-DSPLGTQI.js";import{b as de}from"./chunk-XSVQHPQT.js";function Ce(e){let b=e.view;if(!b?.paywall)throw new m("INVALID_REQUEST","The current node is not a Paywall");let n=b.paywall.receiptId,P=b.nodeId,y=b.visit,p=b.paywall.resolution,u=p,f="document"in p?p:null;function s(i){if(!me(i,p))throw new m("INVALID_RESPONSE","The pinned Paywall binding changed")}let o=b.paywall.quote,D=b.paywall.operation,C=!1,$=new AbortController,d=b.paywall.purchaseRequestId,r=0,c=b.paywall.selectionGeneration??0,T=b.paywall.canReselect===!0,A=null,O=new Map,g=new Map,V=new Map;function L(i){if(i.purchase&&i.purchase.receiptId!==n)throw new m("INVALID_RESPONSE","Purchase receipt changed");let a=i.run.paywall;return i.purchase??(a?.receiptId===n?a:null)}function S(){if(C)throw new m("IDENTITY_CHANGED","Paywall presentation has closed")}function _(i,a,l){if(S(),a!==r||l!==void 0&&o?.operationId!==l)return!1;let I=c,w=i.run.paywall;if(w?.receiptId===n){if((w.selectionGeneration??0)<c)return!1;c=w.selectionGeneration??0,T=w.canReselect===!0,s(w.resolution)}let v=L(i),h=c>I,k=h?v?.quote??null:v?.quote??o,E=v?.operation??(k?.operationId===o?.operationId?D:null);return k&&E&&ye(E,{operationId:k.operationId},"Purchase operation changed"),w?.receiptId===n&&(u=w.resolution,f="document"in u?u:f?{...u,document:f.document,offering:f.offering,capabilities:ue(u.capabilities,f.capabilities)}:null),(h||k?.operationId!==o?.operationId)&&(r++,w?.receiptId===n&&(d=w.purchaseRequestId)),o=k,D=ve(D,E,!0),!0}function x(i,a,l){return new Promise((I,w)=>{let v=!1,h=()=>{clearTimeout(B),$.signal.removeEventListener("abort",H)},k=F=>{v||(v=!0,h(),I(F))},E=F=>{v||(v=!0,h(),w(F))},H=()=>E(new m("IDENTITY_CHANGED","Paywall presentation has closed")),B=setTimeout(()=>E(new m("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,l)),Math.max(0,a-Date.now()));$.signal.addEventListener("abort",H,{once:!0}),$.signal.aborted&&H(),i.then(k,E)})}function J(i){return new Promise(a=>{let l=()=>{clearTimeout(I),$.signal.removeEventListener("abort",l),a()},I=setTimeout(l,i);$.signal.addEventListener("abort",l,{once:!0}),$.signal.aborted&&l()})}async function j(i,a,l){S();let I=O.get(i);if(!I){let h=e.pendingCommands?.find(k=>k.requestId===i)??e.pendingCommand;if(h?.operation==="submit"&&h.requestId===i&&h.nodeId===P&&h.visit===y){a.type==="paywall_quote"&&h.input.type==="paywall_quote"&&h.input.predecessor&&!a.predecessor&&(a={...a,predecessor:h.input.predecessor});let k=le.parse(h),E=le.parse({...h,input:a});if(E.operation!=="submit"||k.operation!=="submit"||JSON.stringify(E.input)!==JSON.stringify(k.input))throw new m("CONFLICT","A restored purchase request cannot change its input");a=E.input,I=k,O.set(i,I)}}if(I){if(JSON.stringify(I.input)!==JSON.stringify(a))throw new m("CONFLICT","A purchase request cannot change its input")}else{let h=e.view;if(!h||h.nodeId!==P||h.visit!==y||h.paywall?.receiptId!==n)throw new m("PRECONDITION_FAILED","The Paywall visit has changed");I={operation:"submit",requestId:i,nodeId:P,visit:y,revision:h.revision,input:a},O.set(i,I)}let w=Date.now()+3e4,v=await x(e.submit(I),w,i);for(;v.run.pendingRequest?.requestId===i&&Date.now()<w&&!C&&(await J(Math.min(1e3,w-Date.now())),!(C||Date.now()>=w));)v=await x(e.resume(i),w,i);if(C)throw new m("IDENTITY_CHANGED","Paywall presentation has closed");if(v.run.pendingRequest?.requestId===i)throw new m("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,i);if(!_(v,l,a.type==="paywall_confirm"||a.type==="paywall_cancel"?a.operationId:void 0))throw new m("PRECONDITION_FAILED","The purchase selection has changed")}async function q(i){if(!o)throw new m("INVALID_REQUEST","A quoted purchase is required");let a=`${i}:${o.operationId}`,l=g.get(a);if(!l){let I=i==="confirm"?"paywall_confirm":"paywall_cancel",w=e.pendingCommands?.find(v=>v.operation==="submit"&&v.input.type===I&&"operationId"in v.input&&v.input.operationId===o.operationId)??e.pendingCommand;l=w?.operation==="submit"&&w.input.type===I&&"operationId"in w.input&&w.input.operationId===o.operationId?w.requestId:crypto.randomUUID(),g.set(a,l)}if(await j(l,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:o.operationId},r),!D)throw new m("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(D)}return{get view(){return structuredClone(f)},get quote(){return o?structuredClone(o):null},get operation(){return D?structuredClone(D):null},get webViewUrl(){return e.webViewUrl},get canReselect(){return T},async refresh(){S();let i=r,a=await e.get();if(_(a,i),a.run.paywall?.receiptId!==n)throw new m("PRECONDITION_FAILED","Paywall presentation has changed");if(!f){if("document"in u||!e.resolvePaywall)throw new m("INVALID_RESPONSE","Public Paywall reader is unavailable");let l=await e.resolvePaywall(u);S(),s(l),f={...u,document:l.document,offering:l.offering,capabilities:ue(u.capabilities,l.capabilities)}}return structuredClone(f)},preview(i){if(!f)return Promise.reject(new m("PRECONDITION_FAILED","Load the Paywall presentation first"));if(d&&d!==i.requestId&&(A||!T))return Promise.reject(new m("COMMAND_PENDING","Retry the original purchase before starting another"));let a=f.document.buttons[i.actionId],l=a?.type==="checkout"?fe(a.product,i.selection,f.capabilities):null;if(!l)return Promise.reject(new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let I=we(f.document.screen,l,i.selection,f.capabilities),w=JSON.stringify({actionId:i.actionId,product:l,featureQuantities:I,offerId:i.offerId,nativeOffer:i.nativeOffer});if(V.has(i.requestId)&&V.get(i.requestId)!==w)return Promise.reject(new m("CONFLICT","A purchase request cannot change its quantities or Product"));if(V.set(i.requestId,w),d===i.requestId&&A)return A;let v=d!==i.requestId&&c>0?{operationId:o?.operationId??null,generation:c}:void 0;if(v&&(!T||c<=0))return Promise.reject(new m("COMMAND_PENDING","Original purchase requires authoritative termination"));d!==i.requestId&&r++;let h=r;d=i.requestId;let k=(async()=>{if(await j(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:l,...Object.keys(I).length?{featureQuantities:I}:{},...v?{predecessor:v}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}},h),!o)throw new m("INVALID_RESPONSE","The accepted quote is missing");return ge(o,{productVersionId:l,featureQuantities:I},"The selected purchase changed"),structuredClone(o)})();return A=k,k.then(()=>{A===k&&(A=null)},E=>{A===k&&(A=null),d===i.requestId&&e.pendingCommand?.requestId!==i.requestId&&E instanceof m&&E.status!==void 0&&E.status<500&&![401,425].includes(E.status)&&(d=null)}),k},confirm:()=>q("confirm"),cancel:()=>q("cancel"),async read(){if(S(),!o)throw new m("INVALID_REQUEST","A quoted purchase is required");let i=o.operationId,a=r,l=e.pendingCommands?.find(h=>h.operation==="submit"&&(h.input.type==="paywall_confirm"||h.input.type==="paywall_cancel")&&h.input.operationId===i)??e.pendingCommand;l?.operation==="submit"&&(l.input.type==="paywall_confirm"||l.input.type==="paywall_cancel")&&l.input.operationId===i&&await e.settle?.(l.requestId);let I=await e.get(void 0,{receiptId:n,operationId:i});S();let w=L(I);if(w?.quote&&w.quote.operationId!==i||w?.operation&&w.operation.operationId!==i)throw new m("INVALID_RESPONSE","Purchase operation changed");let v=_(I,a,i)?D:w?.operation;if(!v)throw new m("INVALID_RESPONSE","The current purchase result is missing");return structuredClone(v)},destroy(){C=!0,$.abort(),O.clear(),g.clear(),V.clear()}}}function Ee(e){let b=new Set,n=new Set,P=null;function y(p){if(e.reviewing||b.has(p)||n.has(p)||e.stopped)return;n.add(p);let u=async()=>{if(e.reviewing||e.stopped||e.key!==p){n.delete(p);return}if(e.busy||e.client.pendingCommand){setTimeout(()=>{u()},250);return}let f=(async()=>{let o=e.client.view,D=e.expected(),C=D.requestId,$=!1;try{await e.client.submit({operation:"shown",...D})}catch(d){if(!(d instanceof m)||d.code!=="CONFLICT"||d.status!==409||e.client.pendingCommand)throw d;await e.client.get();let r=e.client.view;if(e.stopped||e.reviewing||e.key!==p||!r||!o||r.id!==o.id||r.source.versionId!==o.source.versionId||r.nodeId!==D.nodeId||r.visit!==D.visit||r.revision<=D.revision||r.stopped||!r.screen||!["running","waiting"].includes(r.status)||e.client.pendingCommand)throw d;let c=e.expected();C=c.requestId,await e.client.submit({operation:"shown",...c})}for(;!e.stopped&&e.key===p&&e.client.pendingCommand?.requestId===C;){if(!e.client.settle)throw new m("COMMAND_PENDING","The original display acknowledgement is still pending");await e.client.settle(C),$=!0,e.client.pendingCommand?.requestId===C&&await new Promise(d=>setTimeout(d,1500))}e.stopped||e.key!==p||($&&await e.client.get(),!(e.stopped||e.key!==p)&&b.add(p))})();P=f;let s=()=>{P===f&&(P=null),n.delete(p)};f.then(s,o=>{s(),e.busy||e.fail(o)})};u()}return{report:y,get inFlight(){return P}}}function Pe(e){let b={},n=new Map;async function P(y){let p=e.client.view,u=p?.screen,f=u?.customerData.nodes[y.nodeId];if(e.stopped||e.busy||!p||!u||!f)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(y.action)){let r=e.document,c=r?pe(r,y.nodeId):null,T=c?.type==="customer_data"?c.data.outputs?.[y.action]:void 0;T&&u.outputs.includes(T)?await e.perform(()=>e.client.submit({operation:"submit",...e.expected(),input:{type:"screen",output:T,answers:e.answers,selection:y.value?{[y.nodeId]:y.value}:{}}})):await e.onIntent?.(y,p);return}let o=y.action.startsWith("sources_")?f.resources.find(r=>r.key===y.value):null;if(y.action.startsWith("sources_")&&!o)throw new m("INVALID_REQUEST","Choose a current resource");let D=`${p.visit}:${y.nodeId}:${o?.key??""}`,C=n.get(D)??[null],d=b[y.nodeId]??{page:1,after:null,filter:"all",...o?{resourceKey:o.key}:{}};if(y.action==="filter"){let r=y.value;if(!r||!(f.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(r))throw new m("INVALID_REQUEST","Unknown data filter");d={page:1,after:null,filter:r},C.splice(0,C.length,null)}else if(y.action==="next"||y.action==="sources_next"){let r=o?.sources.at(-1),c=o?r?{kind:"ledger",cursor:{at:r.detail[0],id:r.id,type:"source"}}:null:u.dataCursors[y.nodeId];if(!c||!o&&!f.hasNext)return;C[d.page]=c,d={...d,page:d.page+1,after:c}}else if(y.action==="previous"||y.action==="sources_previous"){if(d.page<=1)return;d={...d,page:d.page-1,after:C[d.page-2]??null}}n.set(D,C),b={...b,[y.nodeId]:d},await e.perform(()=>e.client.get({nodeId:p.nodeId,visit:p.visit,revision:p.revision,components:b}))}return{get queries(){return b},intent:P,reset(){b={},n.clear()}}}function Re(e){let{doc:b,holder:n,reviewHolder:P,mountScreenPreview:y}=e,p=!1,u,f=0,s=null,o="",D=new Map,C=r=>r?`${r.id}:${r.nodeId}:${r.visit}:${r.revision}:${r.paywall?.quote?.operationId??""}`:"";async function $(r){if(e.stopped||!e.client.review)return;p||(o=C(e.client.view),D.set(o,structuredClone(e.answers))),p=!0,u=r,n.hidden=!0,e.suspend(!0),P.hidden=!1;let c=++f;try{let T=await e.client.review(r);if(e.stopped||c!==f||!p)return;if(!T.review)throw new m("INVALID_RESPONSE","Historical projection is missing");s?.destroy(),s=null,P.replaceChildren();let A=T.run.locale.startsWith("zh"),O=b.createElement("p");O.textContent=A?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",P.append(O);for(let[L,S]of T.review.pages.entries()){let _=b.createElement("button");_.type="button",_.textContent=A?`\u7B2C ${L+1} \u9875`:`Page ${L+1}`,_.onclick=()=>{$(S.receiptId)},P.append(_)}if(T.review.page){let L=T.review.page,S=b.createElement("div");if(S.inert=!0,P.append(S),s=y(S,{mode:"live",rendererUrl:e.client.webViewUrl,title:L.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{},onEscape:()=>{d()}}),s.update(L.document,T.run.locale,{serverInput:{bindings:L.inputs,answers:L.answers,values:L.values}}),await s.ready,e.stopped||c!==f||!p)return}let g=A?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},V=A?{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"};for(let L of[...T.review.coupons.map((S,_)=>`${A?"\u4F18\u60E0\u5238":"Coupon"} ${_+1}: ${g[S.status]}`),...T.review.purchases.map((S,_)=>`${A?"\u8D2D\u4E70":"Purchase"} ${_+1}: ${V[S.status]}`)]){let S=b.createElement("p");S.textContent=L,P.append(S)}e.client.view&&await e.enqueue(e.client.view)}catch(T){if(c!==f||e.stopped)return;s?.destroy(),s=null,P.replaceChildren(),e.fail(T)}}async function d(){if(!p||e.stopped||!e.client.review)return;let r=++f;try{if(await e.client.review(),e.stopped||r!==f)return;p=!1,f++,s?.destroy(),s=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1;let c=e.client.view;C(c)!==o?(D.set(o,structuredClone(e.answers)),e.resetScreen()):(D.delete(o),e.suspend(!1)),c&&await e.enqueue(c)}catch(c){if(r!==f||e.stopped)return;s?.destroy(),s=null,P.replaceChildren(),e.fail(c)}}return{get active(){return p},get receipt(){return u},open:$,exit:d,get drafts(){return new Map([...D].map(([r,c])=>[r,structuredClone(c)]))},stop(){p=!1,f++,s?.destroy(),s=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1}}}function De(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let b=e.client.pageExperiments.bind(e.client),n=!1,P=!1,y=0,p=!1,u=!1,f,s=new Map,o=new Set,D={},C=new Map,$=he(e.appManifestRelease),d=()=>{for(let g of s.values())g.effect.revert();s.clear();for(let g of C.values())g();C.clear()};function r(g){n||o.has(g)||(o.add(g),b(e.appManifestRelease,[g]).catch(V=>{o.delete(g),z(e.onError,V)}))}async function c(){if(n)return;let g=e.client.view;if(!g||g.stopped||!["running","waiting"].includes(g.status)){y++,d();return}if(p){u=!0;return}p=!0;let V=++y,L=`${g.id}:${g.visit}:${g.revision}`,S=location.href;try{let[_,{applyVisualVariation:x}]=await Promise.all([b(e.appManifestRelease),import("./visual-dom-DQLPBZ2Z.js")]),J=e.client.view;if(n||V!==y||!J||J.stopped||!["running","waiting"].includes(J.status)||`${J.id}:${J.visit}:${J.revision}`!==L||location.href!==S)return;let j=new Set,q=new Set;for(let i of _.assignments){let a=`${_.payload.environmentId}:${i.experimentKey}`;if(q.add(a),C.has(a)||C.set(a,be(a,D)),!!i.inExperiment)for(let l of _.payload.experiments){if(l.key!==i.experimentKey||!de(location.href,l.urlPatterns??[]))continue;let I=l.meta?.findIndex(H=>H.key===i.variationKey)??-1,w=l.variations[I];if(!w?.renderGuard)continue;let v=i.receiptId+":"+l.changeId,h=JSON.stringify([i.variationKey,w]);j.add(v);let k=s.get(v);if(k?.signature===h){k.effect.applied&&r(i.receiptId);continue}s.get(v)?.effect.revert(),s.delete(v);let E=x(w,{requireUniqueTargets:!0,boundVariations:l.variations,allowJs:!1,onApplied:()=>r(i.receiptId),onError:H=>z(e.onError,H)});s.set(v,{signature:h,effect:E}),E.applied&&r(i.receiptId)}}for(let[i,a]of s)j.has(i)||(a.effect.revert(),s.delete(i));for(let[i,a]of C)q.has(i)||(a(),C.delete(i))}catch(_){V===y&&d(),z(e.onError,_)}finally{p=!1,u&&!n&&(u=!1,c())}}let T=e.client.subscribe(()=>{y++,c()}),A=Ie(()=>{y++,d(),c()}),O=async()=>{await c(),n||(f=setTimeout(()=>{O()},15e3))};return{async start(){P||n||(P=!0,await O())},refresh:c,destroy(){n=!0,y++,clearTimeout(f),T(),A(),d(),$.destroy()}}}async function rn(e,b){let n=b,{mountScreenPreview:P}=await import("./screen-renderer-JMHV4GPP.js"),{showPaywall:y}=await import("./paywall-EJCNWDHK.js"),p=n.appManifestRelease?De({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;p?.start();let u=e.ownerDocument,f=u.activeElement,s=u.createElement("section"),o=u.createElement("div"),D=u.createElement("div"),C=u.createElement("div"),$=u.createElement("button");C.hidden=!0,$.type="button";let d=u.createElement("p"),r=u.createElement("p"),c=u.createElement("button"),T=u.createElement("button"),A=u.createElement("button"),O=u.createElement("dialog");s.dataset.indianaFunnel="",s.setAttribute("aria-busy","false"),s.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033;background:#fff",D.style.cssText="display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 20px",d.setAttribute("role","status"),r.setAttribute("role","alert"),r.hidden=!0,c.type=T.type=A.type="button",D.append(c,d,r,A,$,T),s.append(o,C,D),e.append(s);let g=null,V=null,L=null,S="",_="",x="",J="",j="",q=!1,i=0,a=!1,l="",I=null,w=Promise.resolve(),v=null,h=null,k=new Set,E={},H=(t,R=null)=>{q||(h=R,r.textContent=t instanceof Error?t.message:"Request failed",r.hidden=!1,A.hidden=n.client.pendingCommand===null,z(n.onError,t))};function B(){let t=n.client.view;if(!t)throw new m("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let F=Re({client:n.client,doc:u,holder:o,reviewHolder:C,mountScreenPreview:P,get stopped(){return q},get answers(){return E},suspend(t){V?.setSuspended(t)},resetScreen(){S="",_="",x=""},enqueue:Y,fail:H}),ee=Ee({client:n.client,expected:B,fail:H,get stopped(){return q},get reviewing(){return F.active},get key(){return S},get busy(){return i}}),ne=Pe({client:n.client,expected:B,perform:W,onIntent:n.onCustomerDataIntent,get stopped(){return q},get busy(){return i},get document(){return g?.document},get answers(){return E}}),oe=t=>t&&(t.screen||t.paywall)?`${t.id}:${t.nodeId}:${t.visit}`:"";function X(){let t=n.client.view;c.disabled=!F.active&&(i>0||!!n.client.pendingCommand||!t?.canBack||t.stopped||!["running","waiting"].includes(t.status)||!oe(t)||_!==oe(t))}async function W(t,R=!1){if(!(i&&!R||q||F.active&&!R)){i++,s.setAttribute("aria-busy","true"),X(),r.hidden=!0,h=null;try{if(!R&&ee.inFlight){let N=n.client.view;await ee.inFlight;let U=n.client.view;if(!N||!U||U.id!==N.id||U.nodeId!==N.nodeId||U.visit!==N.visit||U.stopped||!["running","waiting"].includes(U.status))throw new m("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}if(q)return;let Q=await t();q||await Y(n.client.view??Q.run)}catch(Q){H(Q,n.client.pendingCommand?.requestId??null)}finally{i=Math.max(0,i-1),s.setAttribute("aria-busy",String(i>0)),q||(A.hidden=n.client.pendingCommand===null,X())}}}function te(){I&&clearTimeout(I),!(q||!L||!["running","waiting"].includes(L.status)&&!n.client.pendingCommand)&&(I=setTimeout(()=>{I=null,ce().finally(te)},L.pendingRequest||n.client.pendingCommand?1500:5e3))}async function ce(){if(!(q||a||i)){if(F.active){await F.open(F.receipt);return}a=!0;try{let t=n.client.pendingCommand;t&&n.client.settle&&await n.client.settle(t.requestId);let R=n.client.view,Q=ne.queries,N=await n.client.get(R?.screen&&Object.keys(Q).length?{nodeId:R.nodeId,visit:R.visit,revision:R.revision,components:Q}:void 0);!q&&Q===ne.queries&&await Y(n.client.view??N.run)}catch(t){H(t)}finally{a=!1}}}function Se(t){let R=t.screen?.presentation;if(!R||R.type==="inline"){O.open&&O.close(),s.parentElement!==e&&e.append(s);return}s.parentElement!==O&&(O.append(s),e.append(O));let Q={sm:420,md:640,lg:900};O.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in R?Q[R.size]+"px":"100vw"}`,O.setAttribute("aria-label",g?.document?.name??t.screen?.content.document.name??"Funnel"),O.open||O.showModal()}async function Fe(t){if(q)return;L=t,h&&n.client.pendingCommand?.requestId!==h&&(r.hidden=!0,h=null);let R=t.locale.startsWith("zh");if($.textContent=R?"\u56DE\u770B":"History",$.hidden=!n.client.review,c.textContent=F.active?R?"\u8FD4\u56DE\u5F53\u524D":"Return to current":R?"\u8FD4\u56DE":"Back",T.textContent=R?"\u5173\u95ED":"Close",A.textContent=R?"\u91CD\u8BD5":"Retry",X(),A.hidden=n.client.pendingCommand===null,d.textContent=t.pendingRequest?R?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?R?"\u7B49\u5F85\u4E2D":"Waiting":"",l!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(l=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,z(n.onState,structuredClone(t))),!t.pendingRequest&&["closed","ineligible","failed"].includes(t.status)){Z();return}if(t.stopped||n.client.configurationReady===!1){F.stop(),g?.destroy(),g=null,V?.destroy(),V=null,o.replaceChildren(),S="",_="",x="",j="",O.open&&O.close(),s.hidden=!0,te();return}if(s.hidden=!1,F.active){te();return}let Q=oe(t);if(Q!==S&&(_="",g?.destroy(),g=null,V?.destroy(),V=null,o.replaceChildren(),S=Q,x="",j="",E={...t.answers},ne.reset()),Se(t),t.screen){let U=t.screen.content;g||(g=P(o,{mode:"live",rendererUrl:n.client.webViewUrl,title:U.document.name,onAction(G,se={},ae={}){if(F.active)return;E={...E,...ae};let Te=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:re})=>Object.hasOwn(E,re)).map(({variable:re})=>[re,E[re]]));W(()=>n.client.submit({operation:"submit",...B(),input:{type:"screen",output:G,answers:Te,selection:se}}))},onAnswers:G=>{F.active||(E={...E,...G})},onCustomerDataIntent:G=>{F.active||ne.intent(G).catch(H)},onEscape:()=>{F.active||ie()},onError:G=>H(new Error(G)),onRendered:()=>ee.report(Q)}));let M={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:E,values:t.screen.values}},K=JSON.stringify([U,t.locale,M.parameters,t.screen.inputs,t.screen.values]);if(K!==x)g.update(U.document,t.locale,M),x=K,J=JSON.stringify(M.capabilities),j=JSON.stringify(M.customerData);else{let G=JSON.stringify(M.capabilities);G!==J&&(g.updateCapabilities(M.capabilities),J=G),JSON.stringify(M.customerData)!==j&&(g.updateCustomerData(M.customerData),j=JSON.stringify(M.customerData))}await g.ready}else if(t.paywall&&!V){let U=await y(o,{canInteract:()=>!F.active&&!q,start:async()=>Ce(n.client),onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resolveOfferId:n.resolveOfferId,onEvent:n.onEvent,onOpenUrl:M=>n.onOpenUrl?n.onOpenUrl({receiptId:t.paywall.receiptId,url:M,openIn:"same_window"}):u.defaultView?.location.assign(M),onAction:async M=>{if(F.active)return;let K=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision,input:{type:"screen",output:M,answers:{}}});await Y(n.client.view??K.run)},onError:H,onDismiss:()=>{!F.active&&!q&&n.client.view?.visit===t.visit&&ie()}});q?U.host?.destroy():(V=U.host,V?.setSuspended(F.active)),ee.report(Q)}if(q)return;_=Q,X();let N=t.instruction;if(N&&(N.type==="open_url"||N.type==="event")&&!k.has(N.receiptId)){let U=u.createElement("button");U.type="button",U.textContent=N.type==="open_url"?`${R?"\u524D\u5F80":"Continue to"} ${new URL(N.url).host}`:R?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let M=B(),K=N.type==="open_url"&&!n.onOpenUrl&&N.openIn==="new_window"?Ne(N.url):null;W(async()=>{let G="success";if(N.type==="open_url")if(n.onOpenUrl)try{G=await n.onOpenUrl({receiptId:N.receiptId,url:N.url,openIn:N.openIn})===!1?"failed":"opened"}catch(ae){z(n.onError,ae),G="failed"}else G=N.openIn==="new_window"&&!K?"failed":"opened";if(N.type==="event"){if(!n.onEvent)throw new m("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(N.event)}if(q||n.client.view?.nodeId!==M.nodeId||n.client.view.visit!==M.visit)throw new m("PRECONDITION_FAILED","The client action visit changed");let se=await n.client.submit({operation:"submit",...M,input:{type:"client_action",receiptId:N.receiptId,outcome:G}});return k.add(N.receiptId),N.type==="open_url"&&!n.onOpenUrl&&N.openIn==="same_window"&&u.defaultView?.location.assign(N.url),se})},o.replaceChildren(U)}!t.pendingRequest&&t.status==="completed"&&!k.has(`complete:${t.id}`)&&(k.add(`complete:${t.id}`),z(n.onComplete,structuredClone(t))),te()}function Ne(t){let R=u.defaultView?.open(t,"_blank")??null;return R&&(R.opener=null),R}function Y(t){return X(),w=w.catch(()=>{}).then(()=>Fe(t)),w}let Oe=n.client.subscribe(t=>{n.client.configurationReady===!1&&(s.hidden=!0,g?.destroy(),g=null,V?.destroy(),V=null,o.replaceChildren(),S="",_="",x="",j="",O.open&&O.close()),Y(t).catch(H)}),ke=n.client.subscribeError?.(H);function ie(){return v||(q?Promise.resolve():n.client.view&&!["running","waiting"].includes(n.client.view.status)?(Z(),Promise.resolve()):(v=W(()=>n.client.submit({operation:"close",...B()}),!0).then(()=>{n.client.view?.status==="closed"&&Z()}).finally(()=>{v=null}),v))}function Z(){p?.destroy(),!q&&(q=!0,I&&clearTimeout(I),Oe(),ke?.(),g?.destroy(),F.stop(),V?.destroy(),O.close(),O.remove(),s.remove(),f instanceof HTMLElement&&f.isConnected&&f.focus(),z(n.onDismiss,L?structuredClone(L):null))}c.onclick=()=>{if(!c.disabled){if(F.active){F.exit();return}W(()=>n.client.submit({operation:"back",...B()}))}},$.onclick=()=>{F.open()},T.onclick=()=>{ie()},A.onclick=()=>{W(()=>n.client.retry())},O.addEventListener("cancel",t=>{t.preventDefault(),ie()});try{let t=await n.client.get();await Y(n.client.view??t.run)}catch(t){throw Z(),t}return{destroy:Z,refresh:ce,review:F.open,exitReview:F.exit,get unappliedDrafts(){return F.drafts}}}export{De as a,rn as b};
|
package/dist/content-NYMIZRNR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as _,j as F}from"./chunk-X6BCUINI.js";import{b as q}from"./chunk-SSLZKIIU.js";import{L as U}from"./chunk-2HFA34QO.js";import{Y as P,ca as M,ja as z,ka as N,qa as d}from"./chunk-ACF2FBUB.js";import{a as v}from"./chunk-DSPLGTQI.js";import"./chunk-G56XGVMS.js";import"./chunk-MRN4HP4W.js";import{a as O}from"./chunk-7DXL3LHT.js";import"./chunk-XSVQHPQT.js";import{z as p}from"zod";var V=new WeakMap;function Q(r){let t={string:p.string(),number:p.number().finite(),boolean:p.boolean(),strings:p.array(p.string()),json:O}[r.type];return r.nullable?t.nullable():t}async function ne(r,t){return W(r,t,!1)}async function re(r,t){return W(r,t,!0)}async function W(r,t,w){t.signal?.throwIfAborted();let T=U.parse(t.content),o=T.document;if(V.has(r))throw new d("CONFLICT","Content is already mounted in this container");let f=p.record(p.string(),O).parse(t.inputs??{});if(Object.keys(f).length>40)throw new d("INVALID_REQUEST","Too many content inputs");for(let[e,s]of Object.entries(f))z.parse({[e]:s});if(Object.keys(f).some(e=>!Object.hasOwn(o.contract.inputs,e)))throw new d("INVALID_REQUEST","Undeclared content input");for(let[e,s]of Object.entries(o.contract.inputs))if(Object.hasOwn(f,e))Q(s).parse(f[e]);else if(s.required)throw new d("INVALID_REQUEST",`Missing content input ${e}`);for(let e of Object.keys(o.contract.outputs))if(typeof t.actions[e]!="function")throw new d("INVALID_REQUEST",`Missing host handler for ${e}`);let $=N.parse(t.bindings??[]),a=r.ownerDocument,L,k=o.kind==="popup",n=k?a.createElement("dialog"):null,i=a.createElement("div");if(i.dataset.indianaContent=o.kind,i.setAttribute("aria-label",o.name),i.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",o.name);let e=o.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${P[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",n.append(i),r.append(n)}else r.append(i);let c=!1,C=!1,g=!1;w&&!n&&(i.style.width=`${r.getBoundingClientRect().width||a.defaultView?.innerWidth||800}px`);let B=w?_(n??i):()=>{},H,x,A=new Promise((e,s)=>{H=e,x=s});A.catch(()=>{});let l=null,E=structuredClone(o.screen);E.actions=E.actions.map(e=>e.type==="event"?{...e,close:!1}:e);let b;function m(){c||(c=!0,t.signal?.removeEventListener("abort",m),x(new Error("Content preparation cancelled")),b?.destroy(),n?.close(),n?.remove(),i.remove(),V.delete(r),n&&L?.())}let S=()=>{g&&(m(),v(t.onDismiss))};if(n){let e=a.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),e.style.cssText="position:absolute;right:8px;top:8px;width:30px;height:30px;z-index:1",e.addEventListener("click",S),n.prepend(e)}n?.addEventListener("cancel",e=>{e.preventDefault(),S()});async function D(){if(c||!g||C||!l)return;let e=l;C=!0,i.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),l=null}catch(s){v(t.onError,s)}finally{C=!1,c||i.removeAttribute("aria-busy")}}function R(){if(c)throw new d("CONFLICT","Content host has been destroyed");g||(L=q(a),B(),w&&!n&&(i.style.width="100%"),n?.showModal(),g=!0)}try{w||R(),b=F(i,{mode:"live",title:o.name,viewportHeight:o.kind==="page"?r.clientHeight||a.defaultView?.innerHeight||800:void 0,onRendered:H,onError:u=>{let I=new Error(u);x(I),v(t.onError,I)},onEscape:k?S:void 0,onAction:(u,I,J)=>{if(c||!g||C||l)return;let h=o.screen.actions.find(y=>y.id===u),j=o.contract.outputs[u];if(!(h?.type!=="event"||!j))try{let y=Q(j).parse(Object.hasOwn(h.properties,"value")?h.properties.value:h.properties);l={requestId:crypto.randomUUID(),contentVersionId:T.id,actionId:u,event:h.event,value:y,selection:I??{},answers:J??{},requestedClose:h.close},D()}catch(y){v(t.onError,y)}}});let e={destroy:m,show:R,get pendingAction(){return l?structuredClone(l):null},retryAction:D,updateCapabilities:u=>b?.updateCapabilities(u)};V.set(r,e),t.signal?.addEventListener("abort",m,{once:!0}),t.signal?.aborted&&(m(),t.signal.throwIfAborted());let s=M(E,[t.locale,...a.defaultView?.navigator.languages??[]]);if(b.update(E,s,{capabilities:t.capabilities,serverInput:{bindings:$,answers:{},values:f}}),await Promise.race([b.ready,A]),w&&await A,c)throw new Error("Content preparation cancelled");return e}catch(e){throw m(),e}}export{ne as mountContent,re as prepareContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as a}from"./chunk-ZPZVSC4J.js";import"./chunk-SBPTOOYB.js";import"./chunk-2HFA34QO.js";import"./chunk-ACF2FBUB.js";import"./chunk-EARSGITJ.js";import"./chunk-HOW7NIIR.js";import"./chunk-DSPLGTQI.js";import"./chunk-G56XGVMS.js";import"./chunk-MRN4HP4W.js";import"./chunk-7DXL3LHT.js";import"./chunk-XSVQHPQT.js";export{a as showFunnelRun};
|
package/dist/paywall-EJCNWDHK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as Z}from"./chunk-SSLZKIIU.js";import{M as B}from"./chunk-2HFA34QO.js";import{L as V,i as G,ma as W,oa as X,qa as w}from"./chunk-ACF2FBUB.js";import{a as j}from"./chunk-DSPLGTQI.js";import"./chunk-G56XGVMS.js";import"./chunk-MRN4HP4W.js";import"./chunk-7DXL3LHT.js";import"./chunk-XSVQHPQT.js";async function ee(b,n,y){if(n.status!=="complete")throw new w("INVALID_RESPONSE","A verified completed purchase is required");if(await y.onComplete?.(n),!b||!y.check)return;let R=V.parse(await y.check());if(R.internal_feature_id!==b.internal_feature_id||R.quantity!==b.quantity)throw new w("INVALID_RESPONSE","The access requirement changed");R.allowed&&await y.onAccessGranted?.(R)}async function fe(b,n){let y=n.check?V.parse(await n.check()):null;if(y?.allowed)return await n.onAccessGranted?.(y),{check:y,host:null};let R=Z(b.ownerDocument),r=await n.start(),E=r.view??await r.refresh();if(!E)throw new w("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:te}=await import("./screen-renderer-JMHV4GPP.js"),c=b.ownerDocument,_=new AbortController,C=c.createElement("section"),K=c.createElement("div"),D=c.createElement("div"),g=c.createElement("p"),u=c.createElement("button"),M=c.createElement("button"),d=c.createElement("dialog"),i=E.document.screen.strings.defaultLocale.startsWith("zh");C.dataset.indianaPaywall="",C.setAttribute("aria-label",E.document.name),C.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",D.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",g.setAttribute("role","status"),M.textContent=i?"\u5173\u95ED":"Close",u.textContent=i?"\u91CD\u8BD5":"Retry",u.hidden=!0,D.append(g,u,M),C.append(K,D);let L=E.document.presentation,O,p=!1,$=!1,f=null,Y=!1,m=()=>!Y&&n.canInteract?.()!==!1,q=!1,a=null,U=null,Q=new Map;async function H(e){if(!(!m()||!e.checkoutUrl||Q.get(e.operationId)===e.checkoutUrl)){Q.set(e.operationId,e.checkoutUrl);try{n.onCheckoutUrl?await n.onCheckoutUrl(e.checkoutUrl):c.defaultView?.location.assign(e.checkoutUrl)}catch(o){throw Q.delete(e.operationId),o}}}let N=e=>{g.textContent=e instanceof Error?e.message:i?"\u8BF7\u6C42\u5931\u8D25":"Request failed",j(n.onError,e),u.hidden=a===null};async function k(e){if(!($||p||!m())){$=!0,u.hidden=!0,g.textContent="";try{await e()}catch(o){p||N(o)}finally{$=!1}}}async function ne(e){await ee(y,e,n)}async function v(e){if(p)return;if(!m()){a=async()=>v(await r.read()),u.hidden=!1;return}if(g.textContent=e.status,e.problem){let t=e.problem;a=T,u.textContent=i?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",N(new w(t.code,t.reason==="RESULT_UNKNOWN"?i?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":t.phase==="fulfillment"?i?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":t.code==="CAPABILITY_UNAVAILABLE"?i?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":t.code==="NOT_CONFIGURED"?i?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":i?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,t));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(g.textContent=i?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){a=null,await ne(e);return}if(e.status!=="pending"){if(r.canReselect===!1){g.textContent=i?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",u.textContent=i?"\u67E5\u8BE2\u7ED3\u679C":"Check result",a=async()=>v(await r.read()),u.hidden=!1;return}u.textContent=i?"\u91CD\u8BD5":"Retry",a=null,f=null;return}await H(e);let o=Date.now()+6e5,l=2e3;for(;!p&&Date.now()<o;){if(await new Promise(h=>{let P=()=>{clearTimeout(I),h()},I=setTimeout(()=>{_.signal.removeEventListener("abort",P),h()},l);_.signal.addEventListener("abort",P,{once:!0})}),p)return;if(!m()){a=async()=>v(await r.read()),u.hidden=!1;return}let t=await r.read();if(!t.problem&&t.status==="pending"&&await H(t),t.status!=="pending"||t.problem){await v(t);return}l=Math.min(l*1.5,3e4)}a=async()=>v(await r.read()),u.hidden=!1}async function T(){U?.remove(),U=null,a=T;let e=await r.confirm();if(!m()){a=T,u.hidden=!1;return}if(e.problem){await v(e);return}if(e.status==="pending"){if(e.checkoutUrl)await H(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!n.onPurchase)throw new w("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await n.onPurchase({operation:e,signal:_.signal})}}a=async()=>v(await r.read()),await v(e)}function re(e){U?.remove();let o=c.createElement("div"),l=c.createElement("button"),t=c.createElement("button"),h=c.createElement("p");h.textContent=e.lines.map(s=>s.productName).join(", ")+" \xB7 "+G(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),l.textContent=i?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",t.textContent=i?"\u53D6\u6D88":"Cancel",l.onclick=()=>{k(T)};let P=async()=>{let s=await r.cancel();p||(o.remove(),U=null,await v(s))};t.onclick=()=>{a=P,k(P)};let I=c.createElement("div");for(let s of e.lines){let J=c.createElement("p");J.textContent=`${s.productName} \xB7 ${G(s.catalogAmountMinor,e.currency)}${W(s.interval,i?"zh-CN":"en",s.intervalCount??1)}`,I.append(J);for(let x of s.prepaid??[]){let F=c.createElement("p"),A=r.view?.capabilities.plans[s.productVersionId]?.prepaid?.find(ae=>ae.internalFeatureId===x.internal_feature_id);F.textContent=`${A?.name??x.internal_feature_id} \xB7 ${x.quantity} ${i?"\u4EFD":"packs"} \xD7 ${x.terms.units}`,A&&(F.textContent+=W(A.reset==="week"||A.reset==="month"||A.reset==="year"?A.reset:"one_time",i?"zh-CN":"en",A.resetCount)),I.append(F)}if(s.trial){let x=c.createElement("p");x.textContent=i?`\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"}`,I.append(x)}}if(!e.charge){let s=c.createElement("p");s.textContent=i?"\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.",I.append(s)}o.append(h,I,l,t),D.prepend(o),U=o,a=null}async function z(){if(!f)return;if(a=z,!q){let o=r.view,l=o?.document.buttons[f.actionId],t=o&&l?.type==="checkout"?B(l.product,f.selection,o.capabilities):null;if(!t)throw new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let h=await n.resolveOfferId?.({actionId:f.actionId,productVersionId:t});if(p)return;h!==void 0&&(f.offerId=h),q=!0}if(!m()){u.hidden=!1;return}let e=await r.preview(f);p||re(e)}function S(e="destroy"){p||(p=!0,_.abort(),O?.destroy(),r.destroy(),d.open&&d.close(),d.remove(),C.remove(),R(),e==="dismiss"&&j(n.onDismiss))}M.onclick=()=>{m()&&S("dismiss")},d.addEventListener("cancel",e=>{e.preventDefault(),m()&&S("dismiss")}),u.onclick=()=>{a&&k(a)};try{if(L.type==="inline")b.append(C);else{let e={sm:420,md:640,lg:900};d.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in L?e[L.size]+"px":"100vw"}`,d.setAttribute("aria-label",E.document.name),d.append(C),b.append(d),m()&&d.showModal()}O=te(K,{mode:"live",rendererUrl:r.webViewUrl,title:E.document.name,onAction(e,o={}){if(!m())return;let l=r.view,t=l?.document.buttons[e];if(!t)return;if(t.type==="close"){k(async()=>{await n.onAction?.(e),S(n.onAction?"action":"dismiss")});return}if(t.type==="action"){a=async()=>{if(t.action.type==="event"){if(!n.onEvent)throw new w("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(t.action.event)}else n.onOpenUrl?await n.onOpenUrl(t.action.url):c.defaultView?.location.assign(t.action.url);await n.onAction?.(e),a=null},k(a);return}if((r.quote||f)&&r.canReselect===!1){a=r.quote?async()=>v(await r.read()):z,k(a);return}let h=l&&B(t.product,o,l.capabilities);if(!l||!h){N(new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(n.onPurchaseIntent){a=null,k(async()=>{let P={actionId:e,productVersionId:h,selection:structuredClone(o),featureQuantities:X(l.document.screen,h,o,l.capabilities)};await n.onPurchaseIntent(P)});return}if(f&&f.actionId!==e){N(new w("COMMAND_PENDING","Finish the current purchase"));return}f||(f={requestId:crypto.randomUUID(),actionId:e,selection:o},q=!1),k(z)},onEscape:()=>{m()&&S("dismiss")},onError:e=>N(new Error(e))}),O.update(E.document.screen,E.document.screen.strings.defaultLocale,{capabilities:E.capabilities,serverInput:{bindings:[],answers:{}}}),await O.ready}catch(e){throw S(),e}return{check:y,host:{setSuspended(e){Y=e,C.hidden=e,e&&d.open?d.close():!e&&!p&&L.type!=="inline"&&!d.open&&d.showModal()},destroy:S,refresh:async()=>{if(!m()){if(r.view)return r.view;throw new w("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return p||O?.updateCapabilities(e.capabilities),e}}}}export{fe as showPaywall};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,g as f,h as g,i as h,j as i}from"./chunk-X6BCUINI.js";import"./chunk-SSLZKIIU.js";import"./chunk-ACF2FBUB.js";import"./chunk-DSPLGTQI.js";import"./chunk-7DXL3LHT.js";import"./chunk-XSVQHPQT.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
|