@tinkerlandai/longplay-sdk 0.10.32 → 0.10.34
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 +8 -0
- package/README.md +10 -6
- package/README.zh-CN.md +2 -0
- package/dist/chunk-3JJYWRA3.js +1 -0
- package/dist/chunk-4WZVC4TM.js +1 -0
- package/dist/chunk-5JWMP4YD.js +1 -0
- package/dist/{chunk-XH7RJPBV.js → chunk-6T575JKD.js} +1 -1
- package/dist/{chunk-EMVWUEW4.js → chunk-7NELM6EH.js} +1 -1
- package/dist/{chunk-KHM6IHPJ.js → chunk-7VRZYSTR.js} +1 -1
- package/dist/{chunk-P5K67CKS.js → chunk-ERJP2GBD.js} +1 -1
- package/dist/{chunk-4XC34JBS.js → chunk-I6TSQQ5N.js} +1 -1
- package/dist/{chunk-SP5AQION.js → chunk-ITGERPCJ.js} +1 -1
- package/dist/{chunk-EUVLXS2V.js → chunk-QBA3B4YK.js} +1 -1
- package/dist/chunk-RKPAIF6U.js +1 -0
- package/dist/chunk-TDSATEGE.js +10 -0
- package/dist/{chunk-GLQXJMKL.js → chunk-TYY3MUTF.js} +1 -1
- package/dist/chunk-U6UHASIB.js +1 -0
- package/dist/{chunk-CZ2RY6RG.js → chunk-WKIR2EQG.js} +1 -1
- package/dist/{chunk-ZIQENZDI.js → chunk-WTVLNUMS.js} +1 -1
- package/dist/{content-YRQSNKN7.js → content-ORU4ODJQ.js} +1 -1
- package/dist/funnel-host-purchase-BEFE3N3E.js +1 -0
- package/dist/{funnel-runtime-host-J2PQHVSO.js → funnel-runtime-host-V6TYIDX3.js} +1 -1
- package/dist/index.d.ts +8 -3
- 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-HO4PS472.js +1 -0
- package/dist/{paywall-session-PPECL5XK.js → paywall-session-MZXFOPTR.js} +1 -1
- package/dist/popup.d.ts +6 -2
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-iSaRiDP2.d.ts → presentation-loading-CFSiS0VX.d.ts} +502 -3
- package/dist/react-native.js +1 -1
- package/dist/{screen-renderer-NHLIJDCW.js → screen-renderer-W7ZGBFIR.js} +1 -1
- package/dist/server.d.ts +30 -0
- package/dist/server.js +3 -3
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5UFRIIGC.js +0 -1
- package/dist/chunk-6KBCR7JJ.js +0 -10
- package/dist/chunk-EMYZUBWL.js +0 -1
- package/dist/chunk-HQPP76BS.js +0 -1
- package/dist/chunk-UESDHJRB.js +0 -1
- package/dist/chunk-Y3MQLWGD.js +0 -1
- package/dist/funnel-host-purchase-SWYFJOVN.js +0 -1
- package/dist/paywall-RQ66UZLW.js +0 -1
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-HQITRRHF.js";import"./chunk-5HJYR6Z4.js";import"./chunk-
|
|
1
|
+
import"./chunk-HQITRRHF.js";import"./chunk-5HJYR6Z4.js";import"./chunk-WTVLNUMS.js";import"./chunk-VYFSRHXM.js";import{a as i}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-WKIR2EQG.js";import{b as A}from"./chunk-VF6QMMEA.js";import"./chunk-WOT6VMZA.js";var c=A.number().int().min(0).max(1e9);function R(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 f(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):R(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 f({...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:k}=await w.read();if(k){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,f as trackOpenRouterUsage};
|
package/dist/page.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as o,e as r,f as e,g as f}from"./chunk-
|
|
1
|
+
import{d as o,e as r,f as e,g as f}from"./chunk-TYY3MUTF.js";import"./chunk-6T575JKD.js";import"./chunk-3VUPVXAV.js";import"./chunk-WKIR2EQG.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as at,c as ot,d as De,f as st,h as ct,i as lt}from"./chunk-4WZVC4TM.js";import{d as Xe,e as Ze,f as et,h as tt,i as fe,j as nt,k as rt,l as it}from"./chunk-U6UHASIB.js";import{a as Ge,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-EHDHWYVJ.js";import{b as ee}from"./chunk-BXPXJARS.js";import"./chunk-WTVLNUMS.js";import"./chunk-VYFSRHXM.js";import{c as Z,o as ne,oa as re,qa as pe}from"./chunk-N7YXDSQL.js";import{c as Oe}from"./chunk-MIBRUDIS.js";import{a as k}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-WKIR2EQG.js";import"./chunk-VF6QMMEA.js";import{a as z}from"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";async function ut(T,r,N){if(r.status!=="complete")throw new k("INVALID_RESPONSE","A verified completed purchase is required");let O=T?ne.parse(T):null;if(await N.onComplete?.(r),!O||!N.check)return;let S=ne.parse(await N.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Oe(S.observation.subject)!==Oe(O.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");S.allowed&&await N.onAccessGranted?.(S)}function Ne(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!ee(r.product,{},T.capabilities)).map(([r])=>r)}async function Yt(T,r,N){let O=tt(T.ownerDocument),S=()=>{P.finish("dismissed"),O()},B=()=>S(),P=nt(T,r,"paywall",()=>{S(),z(r.onDismiss)},at);r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let G=null,_,h,Le;try{if(P.start(!0,r.loadingDocument?.screen.strings.defaultLocale,r.loadingDocument??null),P.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(G=r.check?ne.parse(await P.wait(r.check(),fe)):null,G?.allowed)return P.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(G),{check:G,host:null};let[e,t]=await Promise.allSettled([P.wait(import("./screen-renderer-W7ZGBFIR.js")),P.wait(r.start().then(s=>(P.cancelled&&s.destroy(),s)),fe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await P.wait(_.refresh(),fe);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw P.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let a=_,{mountScreenPreview:dt}=Le,d=T.ownerDocument,me=new AbortController,A=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),w=d.createElement("button"),g=d.createElement("dialog"),o=h.document.screen.strings.defaultLocale.startsWith("zh"),pt=o?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",ft=o?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",E=ot(h.document.screen.theme);A.dataset.indianaPaywall="",A.setAttribute("aria-label",h.document.name),A.style.cssText=E.root,U.style.cssText=E.controls,u.style.cssText=E.message,u.setAttribute("role","status"),w.style.cssText=E.link,w.textContent=o?"\u5173\u95ED":"Close",y.style.cssText=E.secondary,y.textContent=o?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,w),A.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===w?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?E.controls.replace(/padding:[^;]+/,"padding:0"):n?`${E.controls};${E.pinned}`:E.controls,be()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(A,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let ie=h.document.presentation,mt=Object.entries(h.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),F,Ue,he=!1,$e=JSON.stringify(h.capabilities),qe=e=>J?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):Ne(e);function ye(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),yt(e)}let b,we=0;function be(){let e=d.defaultView;if(!b?.responsive||!e)return;let t=H??U,n=e.innerHeight-(b.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",we=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(we,e.innerWidth)}let p=!1,J=!1,v=null,ae=!1,Ve=!1,Q=!1,ge,ve=!1,$,H;function ht(){return J||p||$||ve?{type:"recover",operationId:a.operation?.operationId??a.quote?.operationId??null,requestId:null}:Se(a)}let R=()=>!p&&!ae&&!$&&r.canInteract?.()!==!1,oe=!1,l=null,q=null;function yt(e){J||v||a.quote||a.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let Ce=new Map,Pe=!1;function wt(e,t,n,s){let i=e.lines.length===1?e.lines[0]:void 0,m=ee(n,s,t.capabilities);if(!i||!m||i.productVersionId!==m)return!1;let x;try{x=pe(t.document.screen,m,s,t.capabilities)}catch{return!1}let I=Object.fromEntries((i.prepaid??[]).map(W=>[W.internal_feature_id,W.quantity]));return[...new Set([...Object.keys(x),...Object.keys(I)])].every(W=>(x[W]??0)===(I[W]??0))}let se=e=>Ge({quote:a.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:a.canReselect});async function Ee(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&se(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||Ce.get(e.operationId)===e.checkoutUrl)){Ce.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw Ce.delete(e.operationId),n}}}let j=(e,t=!1)=>{if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=null,u.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):a.canReselect===!0&&!v?u.textContent=o?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=o?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=o?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?st(e,o):e instanceof k?e.message:o?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!b?.responsive&&u.scrollIntoView?.({block:"nearest"}),z(t&&N?.quoteError?N.quoteError:r.onError,e)},ce=new WeakMap;function le(e){J=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of q?.querySelectorAll("button")??[])e?(ce.set(t,t.disabled),t.disabled=!0):ce.has(t)&&(t.disabled=ce.get(t),ce.delete(t)),De(t)}function xe(){u.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function bt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function V(e){if(J||p)return;if(!R()){xe();return}let t=e===ue,n=t?ft:pt;le(!0),y.hidden=!0,u.textContent=n;try{if(await bt(e),p)return;if(!R()){l=e,y.hidden=!1,xe();return}await e()}catch(s){p||j(s,t)}finally{le(!1),u.textContent===n&&(u.textContent="")}}async function gt(e){await ut(G,e,r)}function He(e){return Se(a).type==="recording"||se(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),i=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?Z(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):Z(s,e.currency)+(i?re(i.interval,o?"zh-CN":"en",i.intervalCount??1):""),x=e.lines.map(I=>I.productName).join(", ");return{label:x?`${x} \xB7 ${m}`:m,recurring:i}}async function D(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>D(await a.read()),y.hidden=!1;return}if(u.textContent=lt(e.status,o),He(e)){let i=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=i?o?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>D(await a.read()),y.hidden=!1;return}if(e.problem){let i=e.problem;l=te,y.textContent=o?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",j(new k(i.code,i.reason==="RESULT_UNKNOWN"?o?"\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.":i.phase==="fulfillment"?o?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":i.code==="CAPABILITY_UNAVAILABLE"?o?"\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.":i.code==="NOT_CONFIGURED"?o?"\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.":o?"\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,i));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=o?"\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"){l=null,await gt(e);return}if(e.status!=="pending"){if(a.canReselect===!1){u.textContent=o?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=o?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>D(await a.read()),y.hidden=!1;return}e.status==="cancelled"?u.textContent=o?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=o?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),y.textContent=o?"\u91CD\u8BD5":"Retry",l=null,v=null;return}if(!t&&se(e).type==="checkout"){let i=a.quote,m=i?.operationId===e.operationId?Be(i).label:"";u.textContent=Pe?m?o?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} is still unpaid. Choose it again to continue paying.`:o?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Pe=!1,l=null;return}await Ee(e);let n=Date.now()+6e5,s=2e3;he=!0,z(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await ct(s,d,me.signal),p)return;if(!R()){l=async()=>D(await a.read()),y.hidden=!1;return}let i=await a.read();if(!t&&se(i).type==="checkout"){await D(i,!1);return}if(!i.problem&&i.status==="pending"&&await Ee(i),i.status!=="pending"||i.problem||He(i)){await D(i);return}s=Math.min(s*1.5,3e4)}}finally{he=!1,z(r.onObservationChange,!1)}l=async()=>D(await a.read()),y.hidden=!1}async function ke(e=!1){let t=await a.read();if(p)return;if(!R()){l=()=>ke(e),y.hidden=!1;return}let n=a.quote;if(n&&Je(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!a.pendingCancellation){Fe(n);return}await D(t,e||void 0)}async function te(){q?.remove(),q=null,l=te;let e=await a.confirm();if(!R()){l=te,y.hidden=!1;return}if(e.problem){await D(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Ee(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:me.signal})}}l=async()=>D(await a.read()),await D(e,!0)}function Fe(e){q?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?o?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),s=d.createElement("button"),i=d.createElement("button"),m=d.createElement("div"),x=d.createElement("p"),I=e.merchantTerms,de=o?"zh-CN":"en",W=I?.subscriptionTerms?.items??[],Te=I?I.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,X=Te===void 0?null:I?I.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,Qe=(c,f)=>o?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:vt,recurring:je}=Be(e),Ct=e.lines.map(c=>c.productName).join(", "),We=X===null?"":`${o?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${Z(X,e.currency)}`;x.textContent=We?[Ct,We].filter(Boolean).join(" \xB7 "):vt,s.textContent=o?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,i.textContent=o?"\u53D6\u6D88":"Cancel",n.style.cssText=E.panel,x.style.cssText=E.summary,m.style.cssText=E.actions,s.style.cssText=E.primary,i.style.cssText=E.secondary,De(s),s.onclick=()=>{V(te)};let ze=async()=>{let c=await a.cancel();p||(n.remove(),q=null,await D(c))};i.onclick=()=>{l=ze,V(ze)};let L=d.createElement("div");if(L.style.cssText=E.terms,I){for(let f of W){if(X===null&&f===je)continue;let C=d.createElement("p"),M=Z(f.amountMinor,e.currency)+re(f.interval,de,f.intervalCount);C.textContent=X!==null&&Te!==void 0?Qe(M,Te):M,L.append(C)}let c=I.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=o?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...I.expectedEffects.map(C=>C.description),...I.requiredConsents.map(C=>C.summary)]){let C=d.createElement("p");C.textContent=f,L.append(C)}}else{for(let c of e.lines){if(X!==null||c!==je){let f=d.createElement("p"),C=`${Z(c.catalogAmountMinor,e.currency)}${re(c.interval,de,c.intervalCount??1)}`;f.textContent=X!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+Qe(C,c.trial.days):`${c.productName} \xB7 ${C}`,L.append(f)}for(let f of c.prepaid??[]){let C=d.createElement("p"),M=a.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(Pt=>Pt.internalFeatureId===f.internal_feature_id);C.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${o?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(C.textContent+=re(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",de,M.resetCount)),L.append(C)}if(c.trial){let f=d.createElement("p");f.textContent=o?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.textContent=o?"\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.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,i),n.append(x,...L.childElementCount?[L]:[],m),U.prepend(n),b?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),q=n,l=null}async function ue(){if(!v)return;if(l=ue,!oe){let n=a.view,s=n?.document.buttons[v.actionId],i=n&&s?.type==="checkout"?ee(s.product,v.selection,n.capabilities):null;if(!n||!i)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:v.actionId,productVersionId:i,featureQuantities:pe(n.document.screen,i,v.selection,n.capabilities)});if(p)return;m!==void 0&&(v.offerId=m),oe=!0}if(!R()){y.hidden=!1;return}let e;try{e=await a.preview(v)}catch(n){throw a.canReselect===!0&&(v=null,oe=!1,l=null),n}if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=o?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await te()}catch(s){p||j(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function K(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),a.signal?.removeEventListener("abort",B),P.finish("dismissed"),Ue?.(),me.abort(),_e?.disconnect(),b?.destroy(),F?.destroy(),a.destroy(),g.open&&g.close(),g.remove(),A.remove(),O(),e==="dismiss"&&z(r.onDismiss))}S=K;async function Ie(){if(!Q||p||ae||$==="closing"||!$&&!R())return;if(!N){K("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=o?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),w.hidden=!1,H.replaceChildren(e,w),$="closing",w.setAttribute("aria-disabled","true"),w.focus({preventScroll:!0});try{await N.dismiss()}catch(t){p||z(r.onError,t)}p||($="retry",e.textContent=o?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",w.textContent=o?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",w.removeAttribute("aria-label"),w.removeAttribute("aria-disabled"))}w.onclick=()=>{Ie()},g.addEventListener("cancel",e=>{e.preventDefault(),Ie()}),y.onclick=()=>{l&&V(l)};function Ae(e){P.finish("error",e),K()}function Re(){if(!(!Ve||Q||p||ae||b&&!R()))try{let e=t=>{ge?.(),b&&(g.showModal(),b.responsive&&g.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(g,b.type,b.responsive)),Q=!0};N?N.present(()=>P.present(()=>e(!0))):P.present(e)}catch(e){Ae(e),j(e)}}try{ie.type==="inline"?(Me(),ge=it(A,T),T.append(A)):(g.setAttribute("aria-label",h.document.name),w.textContent="\xD7",w.setAttribute("aria-label",o?"\u5173\u95ED":"Close"),et(w,h.document.screen.theme),w.hidden=Ke(h.document),g.append(w,A),T.append(g),b=Xe(g,{...h.document.screen,presentation:ie},be),b.latch(),b.responsive&&(A.style.display="flex",A.style.flexDirection="column",A.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),ge=rt(g)),F=dt(Y,{mode:"live",rendererUrl:a.webViewUrl,title:h.document.name,closeActions:mt,onAuthoredClose(t){$||p||(w.hidden=t)},hostPresentation:()=>b?.type??ie.type,reportContentHeight:b?.responsive,onResize:t=>{if(!b?.responsive)return;let n=Math.min(t,we);Y.style.height=`${n}px`,b.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!Q||p||$)return;if(!R()){xe();return}let s=a.view,i=s?.document.buttons[t];if(!i)return;if(i.type==="close"){V(async()=>{await r.onAction?.(t),K(r.onAction?"action":"dismiss")});return}if(i.type==="action"){l=async()=>{if(i.action.type==="event"){if(!r.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(i.action.event)}else r.onOpenUrl?await r.onOpenUrl(i.action.url):d.defaultView?.location.assign(i.action.url);await r.onAction?.(t),l=null},V(l);return}if(q&&a.canReselect===!1){u.textContent=o?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",b?.responsive||q.scrollIntoView?.({block:"nearest"}),q.querySelector("button")?.focus({preventScroll:!0});return}if((a.quote||v)&&a.canReselect===!1){let x=!!s&&!!a.quote&&wt(a.quote,s,i.product,n);Pe=!!a.quote&&!x,l=a.quote?()=>ke(x):ue,V(l);return}let m=s&&ee(i.product,n,s.capabilities);if(!s||!m){j(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,V(async()=>{let x={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:pe(s.document.screen,m,n,s.capabilities)};ve=!0,await r.onPurchaseIntent(x)});return}if(v&&v.actionId!==t){j(new k("COMMAND_PENDING","Finish the current purchase"));return}v||(v={requestId:crypto.randomUUID(),actionId:t,selection:structuredClone(n)},oe=!1),V(ue)},onEscape:()=>{Ie()},onError:t=>{let n=new Error(t);!Q&&!p&&Ae(n),j(n)},onRendered:t=>{t&&g.setAttribute("aria-label",t),Ve=!0,Re()}}),be(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:Ne(h),serverInput:{bindings:[],answers:{}}}),Ue=a.subscribe?.(ye),ye(a.view??h),await P.wait(F.ready);let e=a.operation;(a.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>ke(),V(l))}catch(e){throw Ae(e),e}return{check:G,host:{get observing(){return he},get recovery(){return ht()},async prepareFallback(){if(J||p||$||ve)return{type:"recover",operationId:a.operation?.operationId??a.quote?.operationId??null,requestId:null};le(!0);try{let e=await Ye(a);return e.type==="native"&&K(),e}finally{le(!1)}},setSuspended(e){ae=e,A.hidden=e,e&&g.open?g.close():!e&&!Q?Re():!e&&!p&&Q&&ie.type!=="inline"&&!g.open&&g.showModal()},destroy:K,refresh:async()=>{if(!R()){if(a.view)return a.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await a.refresh();return ye(e),Re(),e}}}}export{Yt as showPaywall};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-ERJP2GBD.js";import"./chunk-ILEDKSRQ.js";import"./chunk-EQPEUPMG.js";import"./chunk-FYQXSGRT.js";import"./chunk-7MNJH5GB.js";import"./chunk-ITGERPCJ.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import"./chunk-SCC3O2RD.js";import"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-EHDHWYVJ.js";import"./chunk-BXPXJARS.js";import"./chunk-5HJYR6Z4.js";import"./chunk-WTVLNUMS.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-3VUPVXAV.js";import"./chunk-WKIR2EQG.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as ScreenAction, c as ScreenNode, d as ScreenInteractivity, e as ScreenDocument } from './screen-CGCJ46b1.js';
|
|
2
2
|
import { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { e as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, f as ScreenParameters, g as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-CFSiS0VX.js';
|
|
4
|
+
export { d as PresentationState } from './presentation-loading-CFSiS0VX.js';
|
|
5
5
|
import { WindowLike } from 'dompurify';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
@@ -160,6 +160,8 @@ declare function mountScreenPreview(container: HTMLElement, options?: {
|
|
|
160
160
|
mode?: RendererMode;
|
|
161
161
|
rendererUrl?: string;
|
|
162
162
|
title?: string;
|
|
163
|
+
/** Renders layout with inert, masked content in the packaged shell. */
|
|
164
|
+
skeleton?: boolean;
|
|
163
165
|
/** Translate editor controls without changing authored text or the content locale. */
|
|
164
166
|
editorMessages?: RendererEditorMessages;
|
|
165
167
|
/** 固定模拟浏览器的高度;全屏铺满,其他展示方式在该视口内滚动。 */
|
|
@@ -176,6 +178,8 @@ declare function mountScreenPreview(container: HTMLElement, options?: {
|
|
|
176
178
|
onAnswers?: (answers: ScreenAnswers) => void;
|
|
177
179
|
/** Receives the screen's first visible heading, its accessible name. */
|
|
178
180
|
onRendered?: (label?: string) => void;
|
|
181
|
+
closeActions?: readonly string[];
|
|
182
|
+
onAuthoredClose?: (visible: boolean) => void;
|
|
179
183
|
/** Live previews report the page actually rendered, when the current screen is rendered. */
|
|
180
184
|
onPageChange?: (pageId: string) => void;
|
|
181
185
|
onEscape?: () => void;
|
package/dist/popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-TDSATEGE.js";import"./chunk-U6UHASIB.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
|