@tinkerlandai/longplay-sdk 0.10.15 → 0.10.16
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 +6 -0
- package/README.md +13 -15
- package/README.zh-CN.md +14 -16
- package/dist/{ai-usage-C3dCagmQ.d.ts → ai-usage-DejUdb17.d.ts} +1 -1
- package/dist/{api-Cefn6AaL.d.ts → api-RQUBSSEJ.d.ts} +60 -26
- package/dist/{chunk-OZZMZH7X.js → chunk-26HU2HXU.js} +1 -1
- package/dist/chunk-4IGRIYOQ.js +1 -0
- package/dist/{chunk-V73OHOTK.js → chunk-55MXKW5J.js} +1 -1
- package/dist/{chunk-6RZKX552.js → chunk-67XTOBGE.js} +1 -1
- package/dist/{chunk-RT35MPPD.js → chunk-6MBVIE3H.js} +1 -1
- package/dist/chunk-AC32XJZW.js +1 -0
- package/dist/{chunk-VXY2C4AL.js → chunk-APO7QUBB.js} +1 -1
- package/dist/chunk-EEZLS2YP.js +1 -0
- package/dist/chunk-EFFXE6CX.js +6 -0
- package/dist/chunk-FKBSUKXE.js +1 -0
- package/dist/{chunk-TPAQWTO4.js → chunk-JKLILKI5.js} +1 -1
- package/dist/{chunk-VSMITXQD.js → chunk-LC2VUKYM.js} +1 -1
- package/dist/{chunk-LUIKKMG5.js → chunk-M5HQW67G.js} +1 -1
- package/dist/chunk-ML6EHT43.js +10 -0
- package/dist/chunk-PFHS7HK3.js +17 -0
- package/dist/chunk-T5COWMDA.js +1 -0
- package/dist/{configuration-sync-D2n_gGj6.d.ts → configuration-sync-C2jtm37f.d.ts} +97 -9
- package/dist/{content-WXHCWIUL.js → content-XCLXWNGN.js} +1 -1
- package/dist/{funnel-local-client-9U-_hkEE.d.ts → funnel-local-client-P_R6FHVV.d.ts} +7995 -5523
- package/dist/{funnel-node-evaluation-DSSSmXHX.d.ts → funnel-node-evaluation-BLnJp8vj.d.ts} +11 -13
- package/dist/{funnel-process-client-BaHMeArI.d.ts → funnel-process-client-CY-GQ_SF.d.ts} +5498 -4539
- package/dist/funnel-runtime-host-GFTN7KQK.js +1 -0
- package/dist/index.d.ts +1258 -273
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/paywall-H3KQZEJG.js +1 -0
- package/dist/popup.d.ts +11 -5
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +1541 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-D81zCpfi.d.ts → screen-DRP7nsrQ.d.ts} +613 -357
- package/dist/screen-renderer-IZ3VJGU6.js +1 -0
- package/dist/server.d.ts +717 -9
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-33FQUT3Z.js +0 -179
- package/dist/chunk-E5ECPR6Z.js +0 -1
- package/dist/chunk-LHA6VWP7.js +0 -1
- package/dist/chunk-MOWYD2TV.js +0 -1
- package/dist/chunk-RQZ42NQJ.js +0 -6
- package/dist/chunk-VSJOHWDL.js +0 -17
- package/dist/chunk-XAHWOLRT.js +0 -1
- package/dist/funnel-runtime-host-WQ64FAME.js +0 -1
- package/dist/paywall-H4YN4FTL.js +0 -1
- package/dist/screen-renderer-NHJ6OQTF.js +0 -1
package/dist/openrouter.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
5
|
-
import './screen-
|
|
3
|
+
import { F as FoundationApi } from './api-RQUBSSEJ.js';
|
|
4
|
+
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-DejUdb17.js';
|
|
5
|
+
import './screen-DRP7nsrQ.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@ai-sdk/provider';
|
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-JKLILKI5.js";import"./chunk-APO7QUBB.js";import{a as i}from"./chunk-26HU2HXU.js";import"./chunk-EFFXE6CX.js";import"./chunk-PFHS7HK3.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,7 +1,7 @@
|
|
|
1
|
-
import { a as ConfigurationSync } from './configuration-sync-
|
|
1
|
+
import { a as ConfigurationSync } from './configuration-sync-C2jtm37f.js';
|
|
2
2
|
import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import './screen-
|
|
4
|
+
import './screen-DRP7nsrQ.js';
|
|
5
5
|
|
|
6
6
|
/** GET /api/v1/page-experiments/{environmentId}: page experiments and the saved groups they reference only. */
|
|
7
7
|
declare const pageExperimentPayloadSchema: z.ZodObject<{
|
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-55MXKW5J.js";import"./chunk-67XTOBGE.js";import"./chunk-DSPLGTQI.js";import"./chunk-6MBVIE3H.js";import"./chunk-EFFXE6CX.js";import"./chunk-PFHS7HK3.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as ue}from"./chunk-SSLZKIIU.js";import{b as se,c as le}from"./chunk-T5COWMDA.js";import{a as oe,b as Y,c as ce}from"./chunk-EEZLS2YP.js";import"./chunk-APO7QUBB.js";import{a as v}from"./chunk-26HU2HXU.js";import{a as J}from"./chunk-DSPLGTQI.js";import{R as V}from"./chunk-EFFXE6CX.js";import{Da as K,Fa as ie,Z as $,i as j}from"./chunk-PFHS7HK3.js";async function de(g,r,b){if(r.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");if(await b.onComplete?.(r),!g||!b.check)return;let x=$.parse(await b.check());if(x.internal_feature_id!==g.internal_feature_id||x.quantity!==g.quantity)throw new v("INVALID_RESPONSE","The access requirement changed");x.allowed&&await b.onAccessGranted?.(x)}function X(g){return Object.entries(g.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!V(r.product,{},g.capabilities)).map(([r])=>r)}async function Oe(g,r){let b=r.check?$.parse(await r.check()):null;if(b?.allowed)return await r.onAccessGranted?.(b),{check:b,host:null};let x=ue(g.ownerDocument),{mountScreenPreview:pe}=await import("./screen-renderer-IZ3VJGU6.js"),t=await r.start(),m;try{let e=t.view??await t.refresh();if(!e)throw new v("INVALID_RESPONSE","Paywall presentation is missing");m=e}catch(e){throw t.destroy(),x(),e}let c=g.ownerDocument,q=new AbortController,R=c.createElement("section"),Z=c.createElement("div"),D=c.createElement("div"),C=c.createElement("p"),l=c.createElement("button"),z=c.createElement("button"),u=c.createElement("dialog"),o=m.document.screen.strings.defaultLocale.startsWith("zh");R.dataset.indianaPaywall="",R.setAttribute("aria-label",m.document.name),R.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",C.setAttribute("role","status"),z.textContent=o?"\u5173\u95ED":"Close",l.textContent=o?"\u91CD\u8BD5":"Retry",l.hidden=!0,D.append(C,l,z),R.append(Z,D);let N=m.document.presentation,_,P;function ee(){let e=c.defaultView;P?.responsive&&e&&_?.resizeViewport?.(e.innerHeight,e.innerWidth)}let f=!1,A=!1,h=null,te=!1,H=!1;function fe(){return A||f||H?{type:"recover",operationId:t.operation?.operationId??t.quote?.operationId??null,requestId:null}:Y(t)}let w=()=>!te&&r.canInteract?.()!==!1,Q=!1,i=null,T=null;function ne(e){t.quote||t.operation||(C.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":o?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let F=new Map;async function B(e){if(!(!w()||!e.checkoutUrl||F.get(e.operationId)===e.checkoutUrl)){F.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):c.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw F.delete(e.operationId),n}}}let L=e=>{C.textContent=e instanceof Error?e.message:o?"\u8BF7\u6C42\u5931\u8D25":"Request failed",J(r.onError,e),l.hidden=i===null};async function k(e){if(!(A||f||!w())){A=!0,l.hidden=!0,C.textContent="";try{await e()}catch(n){f||L(n)}finally{A=!1}}}async function me(e){await de(b,e,r)}function re(e){return Y(t).type==="recording"||oe({quote:t.quote,operation:e,requestId:null,pending:!1,destroyed:!1,canReselect:t.canReselect}).type==="recording"}async function y(e){if(f)return;if(!w()){i=async()=>y(await t.read()),l.hidden=!1;return}if(C.textContent=e.status,re(e)){let a=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";C.textContent=a?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.",l.textContent=o?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",i=async()=>y(await t.read()),l.hidden=!1;return}if(e.problem){let a=e.problem;i=M,l.textContent=o?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",L(new v(a.code,a.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.":a.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.":a.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.":a.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,a));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(C.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"){i=null,await me(e);return}if(e.status!=="pending"){if(t.canReselect===!1){C.textContent=o?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",l.textContent=o?"\u67E5\u8BE2\u7ED3\u679C":"Check result",i=async()=>y(await t.read()),l.hidden=!1;return}l.textContent=o?"\u91CD\u8BD5":"Retry",i=null,h=null;return}await B(e);let n=Date.now()+6e5,p=2e3;for(;!f&&Date.now()<n;){if(await new Promise(d=>{let E=()=>{clearTimeout(I),d()},I=setTimeout(()=>{q.signal.removeEventListener("abort",E),d()},p);q.signal.addEventListener("abort",E,{once:!0})}),f)return;if(!w()){i=async()=>y(await t.read()),l.hidden=!1;return}let a=await t.read();if(!a.problem&&a.status==="pending"&&await B(a),a.status!=="pending"||a.problem||re(a)){await y(a);return}p=Math.min(p*1.5,3e4)}i=async()=>y(await t.read()),l.hidden=!1}async function M(){T?.remove(),T=null,i=M;let e=await t.confirm();if(!w()){i=M,l.hidden=!1;return}if(e.problem){await y(e);return}if(e.status==="pending"){if(e.checkoutUrl)await B(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:q.signal})}}i=async()=>y(await t.read()),await y(e)}function he(e){T?.remove();let n=c.createElement("div"),p=c.createElement("button"),a=c.createElement("button"),d=c.createElement("p");d.textContent=e.lines.map(s=>s.productName).join(", ")+" \xB7 "+j(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),p.textContent=o?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",a.textContent=o?"\u53D6\u6D88":"Cancel",p.onclick=()=>{k(M)};let E=async()=>{let s=await t.cancel();f||(n.remove(),T=null,await y(s))};a.onclick=()=>{i=E,k(E)};let I=c.createElement("div");for(let s of e.lines){let ae=c.createElement("p");ae.textContent=`${s.productName} \xB7 ${j(s.catalogAmountMinor,e.currency)}${K(s.interval,o?"zh-CN":"en",s.intervalCount??1)}`,I.append(ae);for(let O of s.prepaid??[]){let W=c.createElement("p"),U=t.view?.capabilities.plans[s.productVersionId]?.prepaid?.find(we=>we.internalFeatureId===O.internal_feature_id);W.textContent=`${U?.name??O.internal_feature_id} \xB7 ${O.quantity} ${o?"\u4EFD":"packs"} \xD7 ${O.terms.units}`,U&&(W.textContent+=K(U.reset==="week"||U.reset==="month"||U.reset==="year"?U.reset:"one_time",o?"zh-CN":"en",U.resetCount)),I.append(W)}if(s.trial){let O=c.createElement("p");O.textContent=o?`\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(O)}}if(!e.charge){let s=c.createElement("p");s.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.",I.append(s)}n.append(d,I,p,a),D.prepend(n),n.scrollIntoView?.({block:"nearest"}),p.focus({preventScroll:!0}),T=n,i=null}async function G(){if(!h)return;if(i=G,!Q){let n=t.view,p=n?.document.buttons[h.actionId],a=n&&p?.type==="checkout"?V(p.product,h.selection,n.capabilities):null;if(!a)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let d=await r.resolveOfferId?.({actionId:h.actionId,productVersionId:a});if(f)return;d!==void 0&&(h.offerId=d),Q=!0}if(!w()){l.hidden=!1;return}let e=await t.preview(h);f||he(e)}function S(e="destroy"){f||(f=!0,q.abort(),P?.destroy(),_?.destroy(),t.destroy(),u.open&&u.close(),u.remove(),R.remove(),x(),e==="dismiss"&&J(r.onDismiss))}z.onclick=()=>{w()&&S("dismiss")},u.addEventListener("cancel",e=>{e.preventDefault(),w()&&S("dismiss")}),l.onclick=()=>{i&&k(i)};try{if(N.type==="inline")g.append(R);else{let n={sm:420,md:640,lg:900};u.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in N?n[N.size]+"px":"100vw"}`,u.setAttribute("aria-label",m.document.name),u.append(R),g.append(u),P=se(u,{...m.document.screen,presentation:N},ee),P.latch(),w()&&(u.showModal(),P.responsive&&u.focus({preventScroll:!0}),le(u,P.type,P.responsive))}_=pe(Z,{mode:"live",rendererUrl:t.webViewUrl,title:m.document.name,hostPresentation:()=>P?.type??N.type,onResize:n=>{P?.responsive&&P.setContentHeight(n+D.getBoundingClientRect().height)},onAction(n,p={}){if(!w())return;let a=t.view,d=a?.document.buttons[n];if(!d)return;if(d.type==="close"){k(async()=>{await r.onAction?.(n),S(r.onAction?"action":"dismiss")});return}if(d.type==="action"){i=async()=>{if(d.action.type==="event"){if(!r.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(d.action.event)}else r.onOpenUrl?await r.onOpenUrl(d.action.url):c.defaultView?.location.assign(d.action.url);await r.onAction?.(n),i=null},k(i);return}if((t.quote||h)&&t.canReselect===!1){i=t.quote?async()=>y(await t.read()):G,k(i);return}let E=a&&V(d.product,p,a.capabilities);if(!a||!E){L(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){i=null,k(async()=>{let I={actionId:n,productVersionId:E,selection:structuredClone(p),featureQuantities:ie(a.document.screen,E,p,a.capabilities)};H=!0,await r.onPurchaseIntent(I)});return}if(h&&h.actionId!==n){L(new v("COMMAND_PENDING","Finish the current purchase"));return}h||(h={requestId:crypto.randomUUID(),actionId:n,selection:p},Q=!1),k(G)},onEscape:()=>{w()&&S("dismiss")},onError:n=>L(new Error(n)),onRendered:n=>{n&&u.setAttribute("aria-label",n)}}),ee(),_.update(m.document.screen,m.document.screen.strings.defaultLocale,{capabilities:m.capabilities,unavailableActions:X(m),serverInput:{bindings:[],answers:{}}}),await _.ready,ne(m);let e=t.operation;e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete")&&(i=async()=>y(await t.read()),k(i))}catch(e){throw S(),e}return{check:b,host:{get recovery(){return fe()},async prepareFallback(){if(A||f||H)return{type:"recover",operationId:t.operation?.operationId??t.quote?.operationId??null,requestId:null};A=!0;try{let e=await ce(t);return e.type==="native"&&S(),e}finally{A=!1}},setSuspended(e){te=e,R.hidden=e,e&&u.open?u.close():!e&&!f&&N.type!=="inline"&&!u.open&&u.showModal()},destroy:S,refresh:async()=>{if(!w()){if(t.view)return t.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await t.refresh();return f||(_?.updateCapabilities(e.capabilities,X(e)),ne(e)),e}}}}export{Oe as showPaywall};
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as ScreenAction, c as ScreenNode, d as ScreenDocument } from './screen-
|
|
1
|
+
import { b as ScreenAction, c as ScreenNode, d as ScreenInteractivity, e as ScreenDocument } from './screen-DRP7nsrQ.js';
|
|
2
2
|
import { O as Offer, a as OfferUnavailableReason } from './coupon-fA1QujHt.js';
|
|
3
3
|
import { b as CustomerPageData, a as SurfaceData, c as ScreenParameters, d as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './customer-page-km5f1PJZ.js';
|
|
4
4
|
import { WindowLike } from 'dompurify';
|
|
@@ -63,7 +63,8 @@ declare function formatCustomerDecimal(value: string, locale: string): string;
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* 自定义 HTML 块的内容策略(服务端发布、控制台预览、SDK 渲染共用):
|
|
66
|
-
*
|
|
66
|
+
* 默认只允许排版和 https 图片;声明 ui 的块可使用有界控件和原生图片策略。
|
|
67
|
+
* 不允许脚本、表单提交、链接、内联样式和事件属性;
|
|
67
68
|
* CSS 不允许外部资源、@import 和未知语法。按钮通过 data-grow-action 绑定文档里的动作。
|
|
68
69
|
* 结果是幂等的:清洗过的内容再清洗一次不变。
|
|
69
70
|
*/
|
|
@@ -79,7 +80,7 @@ type HtmlCodeDiagnostic = {
|
|
|
79
80
|
message: string;
|
|
80
81
|
};
|
|
81
82
|
/** Authoring diagnostics use the exact same sanitizer as publication and delivery. No relaxed preview policy. */
|
|
82
|
-
declare function inspectCustomHtml(html: string, css: string, actionIds: readonly string[], window: WindowLike): {
|
|
83
|
+
declare function inspectCustomHtml(html: string, css: string, actionIds: readonly string[], window: WindowLike, ui?: ScreenInteractivity): {
|
|
83
84
|
html: string;
|
|
84
85
|
css: string;
|
|
85
86
|
diagnostics: HtmlCodeDiagnostic[];
|
|
@@ -137,13 +138,14 @@ type ScreenPreviewHandle = {
|
|
|
137
138
|
customerData?: CustomerPageData;
|
|
138
139
|
serverInput?: ScreenRendererInput;
|
|
139
140
|
selection?: Record<string, string | boolean | number>;
|
|
141
|
+
unavailableActions?: readonly string[];
|
|
140
142
|
/** Explicitly restart a live page even when its design and input are unchanged. */
|
|
141
143
|
reset?: boolean;
|
|
142
144
|
}): void;
|
|
143
145
|
updateCustomerData(data: CustomerPageData): void;
|
|
144
|
-
updateCapabilities(data: SurfaceData): void;
|
|
146
|
+
updateCapabilities(data: SurfaceData, unavailableActions?: readonly string[]): void;
|
|
145
147
|
/** Resize the visible viewport without replacing the document or interaction state. */
|
|
146
|
-
resizeViewport(height: number): void;
|
|
148
|
+
resizeViewport(height: number, width?: number): void;
|
|
147
149
|
/** 编辑模式下的悬停与选中描边。 */
|
|
148
150
|
highlight(hoverId: string | null, selectedId: string | null): void;
|
|
149
151
|
destroy(): void;
|
|
@@ -161,6 +163,10 @@ declare function mountScreenPreview(container: HTMLElement, options?: {
|
|
|
161
163
|
editorMessages?: RendererEditorMessages;
|
|
162
164
|
/** 固定模拟浏览器的高度;全屏铺满,其他展示方式在该视口内滚动。 */
|
|
163
165
|
viewportHeight?: number;
|
|
166
|
+
/** Preserve the host viewport for authored vw units and responsive breakpoints. */
|
|
167
|
+
viewportWidth?: number;
|
|
168
|
+
/** The outer dialog retains the presentation selected when it opened. */
|
|
169
|
+
hostPresentation?: () => ScreenDocument["presentation"]["type"];
|
|
164
170
|
onHover?: (id: string | null) => void;
|
|
165
171
|
onSelect?: (id: string | null) => void;
|
|
166
172
|
onEdit?: (id: string) => 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,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-ML6EHT43.js";import"./chunk-SSLZKIIU.js";import"./chunk-T5COWMDA.js";import"./chunk-26HU2HXU.js";import"./chunk-DSPLGTQI.js";import"./chunk-PFHS7HK3.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};
|