@tinkerlandai/longplay-sdk 0.10.8 → 0.10.13
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 +28 -0
- package/README.md +40 -4
- package/README.zh-CN.md +3 -1
- package/dist/{ai-usage-Btwg1nD7.d.ts → ai-usage-C-OZBxgW.d.ts} +1 -1
- package/dist/{api-5gAz4-Sb.d.ts → api-Bf_aRlXs.d.ts} +82 -0
- package/dist/chunk-33FQUT3Z.js +179 -0
- package/dist/chunk-3JDJD4NY.js +1 -0
- package/dist/chunk-ADSQZ7T3.js +1 -0
- package/dist/chunk-AHDMDMHB.js +1 -0
- package/dist/chunk-AY3DAC2V.js +4 -0
- package/dist/chunk-KQ4MS4LR.js +6 -0
- package/dist/chunk-OBZSDWLC.js +1 -0
- package/dist/chunk-OZZMZH7X.js +1 -0
- package/dist/chunk-RGWFBLW4.js +1 -0
- package/dist/chunk-RK6UEQF2.js +1 -0
- package/dist/chunk-VQBQAKJD.js +1 -0
- package/dist/chunk-VSJOHWDL.js +17 -0
- package/dist/chunk-VSMITXQD.js +1 -0
- package/dist/chunk-YT7TSF3I.js +1 -0
- package/dist/{configuration-sync-CywDxRkX.d.ts → configuration-sync-D2n_gGj6.d.ts} +1 -0
- package/dist/content-6JUK2IAJ.js +1 -0
- package/dist/{funnel-local-client-B4Z3dvNf.d.ts → funnel-local-client-DJq2K7an.d.ts} +8869 -93
- package/dist/{funnel-node-evaluation-P5B4fPfJ.d.ts → funnel-node-evaluation-CJSkUkbv.d.ts} +36 -0
- package/dist/{funnel-resource-client-BhbXsB2q.d.ts → funnel-process-client-C_UhTH8g.d.ts} +5132 -41
- package/dist/funnel-runtime-host-X5AMUCP2.js +1 -0
- package/dist/index.d.ts +102 -77
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-KSTKKKEA.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +109 -106
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-NHJ6OQTF.js +1 -0
- package/dist/server.d.ts +10677 -25
- package/dist/server.js +1 -1
- package/dist/{visual-dom-OIXANRP3.js → visual-dom-7IF7ITAK.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-5JJZSH23.js +0 -179
- package/dist/chunk-5ZS3TNC4.js +0 -1
- package/dist/chunk-7DXL3LHT.js +0 -1
- package/dist/chunk-7XVAFQEE.js +0 -1
- package/dist/chunk-ACF2FBUB.js +0 -1
- package/dist/chunk-CBVZUTNH.js +0 -1
- package/dist/chunk-DCV6IS2Z.js +0 -4
- package/dist/chunk-EI2VRDYJ.js +0 -1
- package/dist/chunk-G56XGVMS.js +0 -1
- package/dist/chunk-GJRXHH6G.js +0 -1
- package/dist/chunk-R26BYN3U.js +0 -1
- package/dist/chunk-RP2P3FU4.js +0 -1
- package/dist/chunk-SBPTOOYB.js +0 -1
- package/dist/chunk-U4UEOR5W.js +0 -6
- package/dist/chunk-XSVQHPQT.js +0 -17
- package/dist/content-XXVHMKKL.js +0 -1
- package/dist/funnel-runtime-host-PBJ63LOE.js +0 -1
- package/dist/paywall-CDR4GZMX.js +0 -1
- package/dist/screen-renderer-NLB3FAQJ.js +0 -1
- /package/dist/{chunk-AK3IJ6FZ.js → chunk-OJM6ORHE.js} +0 -0
package/dist/openrouter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenRouter } from '@openrouter/sdk';
|
|
2
2
|
import { ChatUsage } from '@openrouter/sdk/models';
|
|
3
|
-
import { F as FoundationApi } from './api-
|
|
4
|
-
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-
|
|
3
|
+
import { F as FoundationApi } from './api-Bf_aRlXs.js';
|
|
4
|
+
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-C-OZBxgW.js';
|
|
5
5
|
import './screen-D81zCpfi.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-AHDMDMHB.js";import"./chunk-OBZSDWLC.js";import{a as i}from"./chunk-OZZMZH7X.js";import"./chunk-KQ4MS4LR.js";import"./chunk-VSJOHWDL.js";import{z as k}from"zod";var c=k.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: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,f as trackOpenRouterUsage};
|
package/dist/page.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ConfigurationSync } from './configuration-sync-
|
|
1
|
+
import { a as ConfigurationSync } from './configuration-sync-D2n_gGj6.js';
|
|
2
2
|
import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import './screen-D81zCpfi.js';
|
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-AY3DAC2V.js";import"./chunk-RGWFBLW4.js";import"./chunk-DSPLGTQI.js";import"./chunk-RK6UEQF2.js";import"./chunk-KQ4MS4LR.js";import"./chunk-VSJOHWDL.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as ae}from"./chunk-SSLZKIIU.js";import{a as re}from"./chunk-MOWYD2TV.js";import"./chunk-OBZSDWLC.js";import{a as v}from"./chunk-OZZMZH7X.js";import{a as Y}from"./chunk-DSPLGTQI.js";import{R as M}from"./chunk-KQ4MS4LR.js";import{Aa as K,Ca as ne,Z as $,i as W,la as te}from"./chunk-VSJOHWDL.js";async function ie(y,a,l){if(a.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");if(await l.onComplete?.(a),!y||!l.check)return;let k=$.parse(await l.check());if(k.internal_feature_id!==y.internal_feature_id||k.quantity!==y.quantity)throw new v("INVALID_RESPONSE","The access requirement changed");k.allowed&&await l.onAccessGranted?.(k)}function J(y,a){let l=structuredClone(y.capabilities),k=new Set(Object.entries(y.document.buttons).filter(([,t])=>t.type==="checkout"&&t.product.type==="fixed"&&!M(t.product,{},l)).map(([t])=>t));if(!k.size)return l;let V=t=>{let d=a.createElement("template");d.innerHTML=t;let r=!1;for(let f of d.content.querySelectorAll("button[data-grow-action]"))k.has(f.getAttribute("data-grow-action"))&&(f.disabled=!0,r=!0);return r?d.innerHTML:t};return te(y.document.screen,t=>{if(t.type==="custom_html"){let f=l.nodes[t.id],w=f?.base.html??t.html[y.document.screen.strings.defaultLocale]??"",U=V(w),R=f?.byPlan&&Object.fromEntries(Object.entries(f.byPlan).map(([g,c])=>[g,c.html===void 0?c:{...c,html:V(c.html)}]));(U!==w||R)&&(l.nodes[t.id]={...f,base:{...f?.base,...U!==w?{html:U}:{}},...R?{byPlan:R}:{}});return}let d=t.type==="button"?t.action:t.type==="stack"?t.purchaseAction:void 0;if(!d||!k.has(d))return;let r=l.nodes[t.id];l.nodes[t.id]={...r,base:{...r?.base,unavailable:!0},...r?.byPlan?{byPlan:Object.fromEntries(Object.entries(r.byPlan).map(([f,w])=>[f,{...w,unavailable:!0}]))}:{}}}),l}async function ve(y,a){let l=a.check?$.parse(await a.check()):null;if(l?.allowed)return await a.onAccessGranted?.(l),{check:l,host:null};let k=ae(y.ownerDocument),{mountScreenPreview:V}=await import("./screen-renderer-NHJ6OQTF.js"),t=await a.start(),d;try{let e=t.view??await t.refresh();if(!e)throw new v("INVALID_RESPONSE","Paywall presentation is missing");d=e}catch(e){throw t.destroy(),k(),e}let r=y.ownerDocument,f=new AbortController,w=r.createElement("section"),U=r.createElement("div"),R=r.createElement("div"),g=r.createElement("p"),c=r.createElement("button"),q=r.createElement("button"),h=r.createElement("dialog"),s=d.document.screen.strings.defaultLocale.startsWith("zh");w.dataset.indianaPaywall="",w.setAttribute("aria-label",d.document.name),w.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",R.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",g.setAttribute("role","status"),q.textContent=s?"\u5173\u95ED":"Close",c.textContent=s?"\u91CD\u8BD5":"Retry",c.hidden=!0,R.append(g,c,q),w.append(U,R);let _=d.document.presentation,D,b=!1,Q=!1,P=null,X=!1,E=()=>!X&&a.canInteract?.()!==!1,z=!1,o=null,L=null;function Z(e){t.quote||t.operation||(g.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":s?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let j=new Map;async function B(e){if(!(!E()||!e.checkoutUrl||j.get(e.operationId)===e.checkoutUrl)){j.set(e.operationId,e.checkoutUrl);try{a.onCheckoutUrl?await a.onCheckoutUrl(e.checkoutUrl):r.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw j.delete(e.operationId),n}}}let T=e=>{g.textContent=e instanceof Error?e.message:s?"\u8BF7\u6C42\u5931\u8D25":"Request failed",Y(a.onError,e),c.hidden=o===null};async function x(e){if(!(Q||b||!E())){Q=!0,c.hidden=!0,g.textContent="";try{await e()}catch(n){b||T(n)}finally{Q=!1}}}async function oe(e){await ie(l,e,a)}async function C(e){if(b)return;if(!E()){o=async()=>C(await t.read()),c.hidden=!1;return}if(g.textContent=e.status,e.problem){let i=e.problem;o=H,c.textContent=s?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",T(new v(i.code,i.reason==="RESULT_UNKNOWN"?s?"\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"?s?"\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"?s?"\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"?s?"\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.":s?"\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)&&(g.textContent=s?"\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"){o=null,await oe(e);return}if(e.status!=="pending"){if(t.canReselect===!1){g.textContent=s?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",c.textContent=s?"\u67E5\u8BE2\u7ED3\u679C":"Check result",o=async()=>C(await t.read()),c.hidden=!1;return}c.textContent=s?"\u91CD\u8BD5":"Retry",o=null,P=null;return}await B(e);let n=Date.now()+6e5,m=2e3;for(;!b&&Date.now()<n;){if(await new Promise(p=>{let I=()=>{clearTimeout(A),p()},A=setTimeout(()=>{f.signal.removeEventListener("abort",I),p()},m);f.signal.addEventListener("abort",I,{once:!0})}),b)return;if(!E()){o=async()=>C(await t.read()),c.hidden=!1;return}let i=await t.read();if(!i.problem&&i.status==="pending"&&await B(i),i.status!=="pending"||i.problem){await C(i);return}m=Math.min(m*1.5,3e4)}o=async()=>C(await t.read()),c.hidden=!1}async function H(){L?.remove(),L=null,o=H;let e=await t.confirm();if(!E()){o=H,c.hidden=!1;return}if(e.problem){await C(e);return}if(e.status==="pending"){if(e.checkoutUrl)await B(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!a.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:e,signal:f.signal})}}o=async()=>C(await t.read()),await C(e)}function se(e){L?.remove();let n=r.createElement("div"),m=r.createElement("button"),i=r.createElement("button"),p=r.createElement("p");p.textContent=e.lines.map(u=>u.productName).join(", ")+" \xB7 "+W(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),m.textContent=s?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",i.textContent=s?"\u53D6\u6D88":"Cancel",m.onclick=()=>{x(H)};let I=async()=>{let u=await t.cancel();b||(n.remove(),L=null,await C(u))};i.onclick=()=>{o=I,x(I)};let A=r.createElement("div");for(let u of e.lines){let ee=r.createElement("p");ee.textContent=`${u.productName} \xB7 ${W(u.catalogAmountMinor,e.currency)}${K(u.interval,s?"zh-CN":"en",u.intervalCount??1)}`,A.append(ee);for(let S of u.prepaid??[]){let G=r.createElement("p"),O=t.view?.capabilities.plans[u.productVersionId]?.prepaid?.find(ce=>ce.internalFeatureId===S.internal_feature_id);G.textContent=`${O?.name??S.internal_feature_id} \xB7 ${S.quantity} ${s?"\u4EFD":"packs"} \xD7 ${S.terms.units}`,O&&(G.textContent+=K(O.reset==="week"||O.reset==="month"||O.reset==="year"?O.reset:"one_time",s?"zh-CN":"en",O.resetCount)),A.append(G)}if(u.trial){let S=r.createElement("p");S.textContent=s?`\u8BD5\u7528 ${u.trial.days} \u5929\uFF1B${u.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${u.trial.days}; ${u.trial.cardRequired?"a payment method is required":"no payment method is required"}`,A.append(S)}}if(!e.charge){let u=r.createElement("p");u.textContent=s?"\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.",A.append(u)}n.append(p,A,m,i),R.prepend(n),n.scrollIntoView?.({block:"nearest"}),m.focus({preventScroll:!0}),L=n,o=null}async function F(){if(!P)return;if(o=F,!z){let n=t.view,m=n?.document.buttons[P.actionId],i=n&&m?.type==="checkout"?M(m.product,P.selection,n.capabilities):null;if(!i)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let p=await a.resolveOfferId?.({actionId:P.actionId,productVersionId:i});if(b)return;p!==void 0&&(P.offerId=p),z=!0}if(!E()){c.hidden=!1;return}let e=await t.preview(P);b||se(e)}function N(e="destroy"){b||(b=!0,f.abort(),D?.destroy(),t.destroy(),h.open&&h.close(),h.remove(),w.remove(),k(),e==="dismiss"&&Y(a.onDismiss))}q.onclick=()=>{E()&&N("dismiss")},h.addEventListener("cancel",e=>{e.preventDefault(),E()&&N("dismiss")}),c.onclick=()=>{o&&x(o)};try{if(_.type==="inline")y.append(w);else{let n={sm:420,md:640,lg:900};h.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in _?n[_.size]+"px":"100vw"}`,h.setAttribute("aria-label",d.document.name),h.append(w),y.append(h),E()&&(h.showModal(),re(h,_.type))}D=V(U,{mode:"live",rendererUrl:t.webViewUrl,title:d.document.name,onAction(n,m={}){if(!E())return;let i=t.view,p=i?.document.buttons[n];if(!p)return;if(p.type==="close"){x(async()=>{await a.onAction?.(n),N(a.onAction?"action":"dismiss")});return}if(p.type==="action"){o=async()=>{if(p.action.type==="event"){if(!a.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(p.action.event)}else a.onOpenUrl?await a.onOpenUrl(p.action.url):r.defaultView?.location.assign(p.action.url);await a.onAction?.(n),o=null},x(o);return}if((t.quote||P)&&t.canReselect===!1){o=t.quote?async()=>C(await t.read()):F,x(o);return}let I=i&&M(p.product,m,i.capabilities);if(!i||!I){T(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){o=null,x(async()=>{let A={actionId:n,productVersionId:I,selection:structuredClone(m),featureQuantities:ne(i.document.screen,I,m,i.capabilities)};await a.onPurchaseIntent(A)});return}if(P&&P.actionId!==n){T(new v("COMMAND_PENDING","Finish the current purchase"));return}P||(P={requestId:crypto.randomUUID(),actionId:n,selection:m},z=!1),x(F)},onEscape:()=>{E()&&N("dismiss")},onError:n=>T(new Error(n)),onRendered:n=>{n&&h.setAttribute("aria-label",n)}}),D.update(d.document.screen,d.document.screen.strings.defaultLocale,{capabilities:J(d,r),serverInput:{bindings:[],answers:{}}}),await D.ready,Z(d);let e=t.operation;e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete")&&(o=async()=>C(await t.read()),x(o))}catch(e){throw N(),e}return{check:l,host:{setSuspended(e){X=e,w.hidden=e,e&&h.open?h.close():!e&&!b&&_.type!=="inline"&&!h.open&&h.showModal()},destroy:N,refresh:async()=>{if(!E()){if(t.view)return t.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await t.refresh();return b||(D?.updateCapabilities(J(e,r)),Z(e)),e}}}}export{ve as showPaywall};
|
package/dist/popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,g as p,h as t,i as x,j as a}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,g as p,h as t,i as x,j as a}from"./chunk-33FQUT3Z.js";import"./chunk-SSLZKIIU.js";import"./chunk-MOWYD2TV.js";import"./chunk-OZZMZH7X.js";import"./chunk-DSPLGTQI.js";import"./chunk-VSJOHWDL.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};
|