@tinkerlandai/indiana-sdk 0.9.2 → 0.9.5

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +60 -4
  3. package/README.zh-CN.md +26 -3
  4. package/dist/{ai-usage-DMNKvCiq.d.ts → ai-usage-CUTIHAU0.d.ts} +5 -5
  5. package/dist/{api--Zf0gxfj.d.ts → api-BXu6TAoB.d.ts} +274 -127
  6. package/dist/{chunk-65TBYVCS.js → chunk-4C3HUZ3B.js} +1 -1
  7. package/dist/chunk-5ZWSFE2C.js +1 -0
  8. package/dist/chunk-6ZZUNGNE.js +1 -0
  9. package/dist/chunk-AOGPGUWE.js +1 -0
  10. package/dist/chunk-BOCKPUCM.js +2 -0
  11. package/dist/chunk-CLXORAOK.js +1 -0
  12. package/dist/chunk-HEGNIATD.js +1 -0
  13. package/dist/{chunk-WSVH6IQA.js → chunk-LMO3FXRT.js} +1 -1
  14. package/dist/chunk-M7JWCLYX.js +173 -0
  15. package/dist/chunk-MKV726FV.js +1 -0
  16. package/dist/chunk-QYECMZJJ.js +1 -0
  17. package/dist/chunk-UBMPFTGE.js +1 -0
  18. package/dist/chunk-UWFYBRM2.js +6 -0
  19. package/dist/chunk-XRXI3DMZ.js +1 -0
  20. package/dist/chunk-XSOEA4A5.js +4 -0
  21. package/dist/{configuration-sync-E98CqVwh.d.ts → configuration-sync-DuJl4SbM.d.ts} +64 -11
  22. package/dist/content-PQJYLAGQ.js +1 -0
  23. package/dist/coupon-fA1QujHt.d.ts +184 -0
  24. package/dist/{customer-page-9B97Qdt_.d.ts → customer-page-km5f1PJZ.d.ts} +86 -182
  25. package/dist/{funnel-local-client-BjPwXlQb.d.ts → funnel-local-client-BhHdi5_V.d.ts} +2843 -1187
  26. package/dist/funnel-node-evaluation-DuPmqIo1.d.ts +998 -0
  27. package/dist/funnel-resource-client-BoIhL_my.d.ts +9674 -0
  28. package/dist/funnel-runtime-host-3YUGXD3Y.js +1 -0
  29. package/dist/index.d.ts +1292 -9349
  30. package/dist/index.js +1 -1
  31. package/dist/native-shell.js +1 -1
  32. package/dist/openrouter.d.ts +3 -3
  33. package/dist/openrouter.js +1 -1
  34. package/dist/page.d.ts +3 -3
  35. package/dist/page.js +1 -1
  36. package/dist/paywall-CSAGKPCP.js +1 -0
  37. package/dist/popup.d.ts +7 -5
  38. package/dist/popup.js +1 -1
  39. package/dist/react-native.d.ts +23680 -173
  40. package/dist/react-native.js +1 -1
  41. package/dist/{screen-BITZ11jn.d.ts → screen-CvfI_L41.d.ts} +157 -4
  42. package/dist/{screen-renderer-A6VYE2QL.js → screen-renderer-VAMWY7ID.js} +1 -1
  43. package/dist/server.d.ts +355 -95
  44. package/dist/server.js +1 -1
  45. package/dist/visual-dom-OFB7BFFB.js +1 -0
  46. package/dist/visual.d.ts +1 -1
  47. package/dist/visual.js +1 -1
  48. package/package.json +1 -1
  49. package/dist/chunk-5O667MKA.js +0 -1
  50. package/dist/chunk-67A7I6MB.js +0 -1
  51. package/dist/chunk-CCQHYQ4P.js +0 -1
  52. package/dist/chunk-CPLLMISZ.js +0 -1
  53. package/dist/chunk-G23YNWWI.js +0 -1
  54. package/dist/chunk-L7LKE3MG.js +0 -173
  55. package/dist/chunk-NH2PTTNK.js +0 -2
  56. package/dist/chunk-PK5HYUHD.js +0 -1
  57. package/dist/chunk-SEW4YVR7.js +0 -1
  58. package/dist/chunk-UYSOTMY3.js +0 -1
  59. package/dist/chunk-YZSQDZXW.js +0 -4
  60. package/dist/content-3LOJVYQO.js +0 -1
  61. package/dist/errors-0TSUIbUi.d.ts +0 -115
  62. package/dist/funnel-runtime-host-NYHKQT6T.js +0 -1
  63. package/dist/paywall-ISCYOGPZ.js +0 -1
@@ -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--Zf0gxfj.js';
4
- import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-DMNKvCiq.js';
5
- import './screen-BITZ11jn.js';
3
+ import { F as FoundationApi } from './api-BXu6TAoB.js';
4
+ import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-CUTIHAU0.js';
5
+ import './screen-CvfI_L41.js';
6
6
  import 'zod';
7
7
  import 'zod/v4';
8
8
  import '@ai-sdk/provider';
@@ -1 +1 @@
1
- import"./chunk-67A7I6MB.js";import"./chunk-PK5HYUHD.js";import{fa as i}from"./chunk-G23YNWWI.js";import"./chunk-G56XGVMS.js";import"./chunk-WSVH6IQA.js";import"./chunk-7DXL3LHT.js";import"./chunk-3PZ4Y6UD.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};
1
+ import"./chunk-MKV726FV.js";import"./chunk-UWFYBRM2.js";import{oa as i}from"./chunk-HEGNIATD.js";import"./chunk-G56XGVMS.js";import"./chunk-LMO3FXRT.js";import"./chunk-7DXL3LHT.js";import"./chunk-3PZ4Y6UD.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 { C as ConfigurationSync } from './configuration-sync-E98CqVwh.js';
1
+ import { a as ConfigurationSync } from './configuration-sync-DuJl4SbM.js';
2
2
  import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
3
3
  import { z } from 'zod';
4
- import './screen-BITZ11jn.js';
4
+ import './screen-CvfI_L41.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<{
@@ -10,13 +10,13 @@ declare const pageExperimentPayloadSchema: z.ZodObject<{
10
10
  generation: z.ZodString;
11
11
  experiments: z.ZodArray<z.ZodObject<{
12
12
  name: z.ZodOptional<z.ZodString>;
13
+ key: z.ZodString;
13
14
  filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
14
15
  attribute: z.ZodOptional<z.ZodString>;
15
16
  seed: z.ZodString;
16
17
  hashVersion: z.ZodLiteral<2>;
17
18
  ranges: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
18
19
  }, z.core.$strict>>>;
19
- key: z.ZodString;
20
20
  condition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
21
21
  force: z.ZodOptional<z.ZodNumber>;
22
22
  hashAttribute: z.ZodOptional<z.ZodString>;
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{d as o,e as r,f as e,g as f}from"./chunk-YZSQDZXW.js";import"./chunk-65TBYVCS.js";import"./chunk-DSPLGTQI.js";import"./chunk-WSVH6IQA.js";import"./chunk-3PZ4Y6UD.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
1
+ import{d as o,e as r,f as e,g as f}from"./chunk-XSOEA4A5.js";import"./chunk-4C3HUZ3B.js";import"./chunk-DSPLGTQI.js";import"./chunk-LMO3FXRT.js";import"./chunk-3PZ4Y6UD.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{b as X}from"./chunk-SSLZKIIU.js";import{I as F}from"./chunk-UWFYBRM2.js";import{J as T,g as z,ka as G,ma as K,oa as h}from"./chunk-HEGNIATD.js";import{a as B}from"./chunk-DSPLGTQI.js";import"./chunk-G56XGVMS.js";import"./chunk-LMO3FXRT.js";import"./chunk-7DXL3LHT.js";import"./chunk-3PZ4Y6UD.js";async function Y(P,t,y){if(t.status!=="complete")throw new h("INVALID_RESPONSE","A verified completed purchase is required");if(await y.onComplete?.(t),!P||!y.check)return;let A=T.parse(await y.check());if(A.internal_feature_id!==P.internal_feature_id||A.quantity!==P.quantity)throw new h("INVALID_RESPONSE","The access requirement changed");A.allowed&&await y.onAccessGranted?.(A)}async function de(P,t){let y=t.check?T.parse(await t.check()):null;if(y?.allowed)return await t.onAccessGranted?.(y),{check:y,host:null};let A=X(P.ownerDocument),n=await t.start(),v=n.view??await n.refresh();if(!v)throw new h("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:Z}=await import("./screen-renderer-VAMWY7ID.js"),a=P.ownerDocument,D=new AbortController,C=a.createElement("section"),j=a.createElement("div"),N=a.createElement("div"),R=a.createElement("p"),l=a.createElement("button"),V=a.createElement("button"),u=a.createElement("dialog"),d=v.document.screen.strings.defaultLocale.startsWith("zh");C.dataset.indianaPaywall="",C.setAttribute("aria-label",v.document.name),C.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",N.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",R.setAttribute("role","status"),V.textContent=d?"\u5173\u95ED":"Close",l.textContent=d?"\u91CD\u8BD5":"Retry",l.hidden=!0,N.append(R,l,V),C.append(j,N);let U=v.document.presentation,O,p=!1,M=!1,f=null,W=!1,w=()=>!W&&t.canInteract?.()!==!1,$=!1,r=null,_=null,L=e=>{R.textContent=e instanceof Error?e.message:d?"\u8BF7\u6C42\u5931\u8D25":"Request failed",B(t.onError,e),l.hidden=r===null};async function k(e){if(!(M||p||!w())){M=!0,l.hidden=!0,R.textContent="";try{await e()}catch(s){p||L(s)}finally{M=!1}}}async function ee(e){await Y(y,e,t)}async function E(e){if(p)return;if(!w()){r=async()=>E(await n.read()),l.hidden=!1;return}if(R.textContent=e.status,e.status==="complete"){r=null,await ee(e);return}if(e.status!=="pending"){if(n.canReselect===!1){R.textContent=d?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",l.textContent=d?"\u67E5\u8BE2\u7ED3\u679C":"Check result",r=async()=>E(await n.read()),l.hidden=!1;return}l.textContent=d?"\u91CD\u8BD5":"Retry",r=null,f=null;return}let s=Date.now()+6e5,c=2e3;for(;!p&&Date.now()<s;){if(await new Promise(m=>{let b=()=>{clearTimeout(g),m()},g=setTimeout(()=>{D.signal.removeEventListener("abort",b),m()},c);D.signal.addEventListener("abort",b,{once:!0})}),p)return;if(!w()){r=async()=>E(await n.read()),l.hidden=!1;return}let i=await n.read();if(i.status!=="pending"){await E(i);return}c=Math.min(c*1.5,3e4)}r=async()=>E(await n.read()),l.hidden=!1}async function Q(){_?.remove(),_=null,r=Q;let e=await n.confirm();if(!w()){r=Q,l.hidden=!1;return}if(e.status==="pending"){if(e.checkoutUrl)t.onCheckoutUrl?await t.onCheckoutUrl(e.checkoutUrl):a.defaultView?.location.assign(e.checkoutUrl);else if(e.execution||e.nativePurchase){if(!t.onPurchase)throw new h("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await t.onPurchase({operation:e,signal:D.signal})}}r=async()=>E(await n.read()),await E(e)}function te(e){_?.remove();let s=a.createElement("div"),c=a.createElement("button"),i=a.createElement("button"),m=a.createElement("p");m.textContent=e.lines.map(o=>o.productName).join(", ")+" \xB7 "+z(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),c.textContent=d?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",i.textContent=d?"\u53D6\u6D88":"Cancel",c.onclick=()=>{k(Q)};let b=async()=>{let o=await n.cancel();p||(s.remove(),_=null,await E(o))};i.onclick=()=>{r=b,k(b)};let g=a.createElement("div");for(let o of e.lines){let J=a.createElement("p");J.textContent=`${o.productName} \xB7 ${z(o.catalogAmountMinor,e.currency)}${G(o.interval,d?"zh-CN":"en",o.intervalCount??1)}`,g.append(J);for(let I of o.prepaid??[]){let H=a.createElement("p"),x=n.view?.capabilities.plans[o.productVersionId]?.prepaid?.find(ne=>ne.internalFeatureId===I.internal_feature_id);H.textContent=`${x?.name??I.internal_feature_id} \xB7 ${I.quantity} ${d?"\u4EFD":"packs"} \xD7 ${I.terms.units}`,x&&(H.textContent+=G(x.reset==="week"||x.reset==="month"||x.reset==="year"?x.reset:"one_time",d?"zh-CN":"en",x.resetCount)),g.append(H)}if(o.trial){let I=a.createElement("p");I.textContent=d?`\u8BD5\u7528 ${o.trial.days} \u5929\uFF1B${o.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${o.trial.days}; ${o.trial.cardRequired?"a payment method is required":"no payment method is required"}`,g.append(I)}}if(!e.charge){let o=a.createElement("p");o.textContent=d?"\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.",g.append(o)}s.append(m,g,c,i),N.prepend(s),_=s,r=null}async function q(){if(!f)return;if(r=q,!$){let s=n.view,c=s?.document.buttons[f.actionId],i=s&&c?.type==="checkout"?F(c.product,f.selection,s.capabilities):null;if(!i)throw new h("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await t.resolveOfferId?.({actionId:f.actionId,productVersionId:i});if(p)return;m!==void 0&&(f.offerId=m),$=!0}if(!w()){l.hidden=!1;return}let e=await n.preview(f);p||te(e)}function S(e="destroy"){p||(p=!0,D.abort(),O?.destroy(),n.destroy(),u.open&&u.close(),u.remove(),C.remove(),A(),e==="dismiss"&&B(t.onDismiss))}V.onclick=()=>{w()&&S("dismiss")},u.addEventListener("cancel",e=>{e.preventDefault(),w()&&S("dismiss")}),l.onclick=()=>{r&&k(r)};try{if(U.type==="inline")P.append(C);else{let e={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 U?e[U.size]+"px":"100vw"}`,u.setAttribute("aria-label",v.document.name),u.append(C),P.append(u),w()&&u.showModal()}O=Z(j,{mode:"live",rendererUrl:n.webViewUrl,title:v.document.name,onAction(e,s={}){if(!w())return;let c=n.view,i=c?.document.buttons[e];if(!i)return;if(i.type==="close"){k(async()=>{await t.onAction?.(e),S(t.onAction?"action":"dismiss")});return}if(i.type==="action"){r=async()=>{if(i.action.type==="event"){if(!t.onEvent)throw new h("EVENT_HANDLER_REQUIRED","Provide the event handler");await t.onEvent(i.action.event)}else t.onOpenUrl?await t.onOpenUrl(i.action.url):a.defaultView?.location.assign(i.action.url);await t.onAction?.(e),r=null},k(r);return}if((n.quote||f)&&n.canReselect===!1){r=n.quote?async()=>E(await n.read()):q,k(r);return}let m=c&&F(i.product,s,c.capabilities);if(!c||!m){L(new h("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(t.onPurchaseIntent){r=null,k(async()=>{let b={actionId:e,productVersionId:m,selection:structuredClone(s),featureQuantities:K(c.document.screen,m,s,c.capabilities)};await t.onPurchaseIntent(b)});return}if(f&&f.actionId!==e){L(new h("COMMAND_PENDING","Finish the current purchase"));return}f||(f={requestId:crypto.randomUUID(),actionId:e,selection:s},$=!1),k(q)},onEscape:()=>{w()&&S("dismiss")},onError:e=>L(new Error(e))}),O.update(v.document.screen,v.document.screen.strings.defaultLocale,{capabilities:v.capabilities,serverInput:{bindings:[],answers:{}}}),await O.ready}catch(e){throw S(),e}return{check:y,host:{setSuspended(e){W=e,C.hidden=e,e&&u.open?u.close():!e&&!p&&U.type!=="inline"&&!u.open&&u.showModal()},destroy:S,refresh:async()=>{if(!w()){if(n.view)return n.view;throw new h("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await n.refresh();return p||O?.updateCapabilities(e.capabilities),e}}}}export{de as showPaywall};
package/dist/popup.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { a as ScreenAction, b as ScreenNode, c as ScreenDocument } from './screen-BITZ11jn.js';
2
- import { O as Offer, c as OfferUnavailableReason, d as CustomerPageData, a as SurfaceData, e as ScreenParameters, f as ScreenRendererInput, S as ScreenAnswers, b as CustomerDataIntent } from './customer-page-9B97Qdt_.js';
1
+ import { b as ScreenAction, c as ScreenNode, d as ScreenDocument } from './screen-CvfI_L41.js';
2
+ import { O as Offer, a as OfferUnavailableReason } from './coupon-fA1QujHt.js';
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';
3
4
  import { WindowLike } from 'dompurify';
4
5
  import 'zod';
5
6
 
@@ -12,7 +13,7 @@ type PopupEvent = {
12
13
  name: string;
13
14
  properties: ScreenAction["properties"];
14
15
  /** Presentation-only choices; validate actual prices and entitlements on the server. */
15
- selection?: Record<string, string | boolean>;
16
+ selection?: Record<string, string | boolean | number>;
16
17
  } | {
17
18
  type: "closed";
18
19
  reason: "close_button" | "escape" | "action" | "destroy" | "timeout";
@@ -135,7 +136,7 @@ type ScreenPreviewHandle = {
135
136
  capabilities?: SurfaceData;
136
137
  customerData?: CustomerPageData;
137
138
  serverInput?: ScreenRendererInput;
138
- selection?: Record<string, string | boolean>;
139
+ selection?: Record<string, string | boolean | number>;
139
140
  /** Explicitly restart a live page even when its design and input are unchanged. */
140
141
  reset?: boolean;
141
142
  }): void;
@@ -163,7 +164,8 @@ declare function mountScreenPreview(container: HTMLElement, options?: {
163
164
  onHover?: (id: string | null) => void;
164
165
  onSelect?: (id: string | null) => void;
165
166
  onEdit?: (id: string) => void;
166
- onAction?: (actionId: string, selection?: Record<string, string | boolean>, answers?: ScreenAnswers) => void;
167
+ onAction?: (actionId: string, selection?: Record<string, string | boolean | number>, answers?: ScreenAnswers) => void;
168
+ onSelection?: (selection: Record<string, string | boolean | number>) => void;
167
169
  onAnswers?: (answers: ScreenAnswers) => void;
168
170
  onRendered?: () => void;
169
171
  /** Live previews report the page actually rendered, when the current screen is rendered. */
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-L7LKE3MG.js";import"./chunk-SSLZKIIU.js";import"./chunk-G23YNWWI.js";import"./chunk-DSPLGTQI.js";import"./chunk-7DXL3LHT.js";import"./chunk-3PZ4Y6UD.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};
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-M7JWCLYX.js";import"./chunk-SSLZKIIU.js";import"./chunk-HEGNIATD.js";import"./chunk-DSPLGTQI.js";import"./chunk-7DXL3LHT.js";import"./chunk-3PZ4Y6UD.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};