@tinkerlandai/indiana-sdk 0.6.4 → 0.8.0
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 +15 -5
- package/README.md +11 -10
- package/README.zh-CN.md +16 -11
- package/dist/{ai-usage-B4W5m4Ie.d.ts → ai-usage-Bigjb8MS.d.ts} +570 -560
- package/dist/chunk-2A6UYUFA.js +1 -0
- package/dist/chunk-3BQFJANQ.js +1 -0
- package/dist/chunk-3ENVRJE6.js +350 -0
- package/dist/chunk-A3N4ZZTM.js +7 -0
- package/dist/chunk-AE4CUTUE.js +1 -0
- package/dist/chunk-CXYOZSOF.js +1 -0
- package/dist/{chunk-2EJSV6BA.js → chunk-G2R56FKU.js} +1 -1
- package/dist/chunk-KQCTDXVD.js +17 -0
- package/dist/{chunk-5TEZEOHX.js → chunk-OVMNCZYC.js} +1 -1
- package/dist/chunk-RRII2DMC.js +1 -0
- package/dist/chunk-YAFMBXIE.js +4 -0
- package/dist/{configuration-sync-C2mytNwU.d.ts → configuration-sync-VFbY1pCN.d.ts} +356 -49
- package/dist/content-K2HCZVC2.js +1 -0
- package/dist/{customer-page-B4FGCVpt.d.ts → customer-page-BrCZxcaQ.d.ts} +278 -5
- package/dist/funnel-runtime-host-HNZ47TZW.js +1 -0
- package/dist/{funnel-runtime-start-sZ8ZCNlq.d.ts → funnel-runtime-start-DKcTCRrd.d.ts} +6930 -3327
- package/dist/index.d.ts +17432 -14987
- 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 +17 -17
- package/dist/page.js +1 -1
- package/dist/paywall-PD62B2AY.js +1 -0
- package/dist/popup.d.ts +7 -282
- package/dist/popup.js +1 -350
- package/dist/react-native.d.ts +15 -15
- package/dist/react-native.js +1 -1
- package/dist/{screen-16d-xADb.d.ts → screen-BazUOjwM.d.ts} +163 -160
- package/dist/server.d.ts +5 -5
- package/dist/server.js +1 -1
- package/dist/src-4MRSESVS.js +1 -0
- package/dist/visual.d.ts +5 -2
- package/dist/visual.js +2 -2
- package/package.json +1 -7
- package/dist/chunk-4K25DELJ.js +0 -1
- package/dist/chunk-63BWE27V.js +0 -1
- package/dist/chunk-CB63JLGT.js +0 -1
- package/dist/chunk-D7YHFS6B.js +0 -4
- package/dist/chunk-HTRQPMJO.js +0 -11
- package/dist/chunk-ISUXYPYL.js +0 -1
- package/dist/chunk-QG3WUJG5.js +0 -1
- package/dist/chunk-RMJJOSVZ.js +0 -1
- package/dist/chunk-S2MSIA57.js +0 -17
- package/dist/chunk-U6S6AZM6.js +0 -1
- package/dist/chunk-VVSQKVE7.js +0 -1
- package/dist/client-OYRHOMUQ.js +0 -1
- package/dist/funnel-runtime-host-NWS3URFA.js +0 -1
- package/dist/iam.d.ts +0 -131
- package/dist/iam.js +0 -1
- package/dist/paywall-4XZ6NDMY.js +0 -1
- package/dist/src-WV6GZYWA.js +0 -1
- package/dist/{errors-DrdTlPwf.d.ts → errors-BpCmukJr.d.ts} +1 -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 { c as createAiPricing, F as FoundationApi, a as AiUsageContext, b as AiTokenUsage, d as AiTokenQuote } from './ai-usage-
|
|
3
|
+
import { c as createAiPricing, F as FoundationApi, a as AiUsageContext, b as AiTokenUsage, d as AiTokenQuote } from './ai-usage-Bigjb8MS.js';
|
|
4
4
|
import '@ai-sdk/provider';
|
|
5
|
-
import './screen-
|
|
5
|
+
import './screen-BazUOjwM.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
|
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-G2R56FKU.js";import"./chunk-CXYOZSOF.js";import"./chunk-A3N4ZZTM.js";import{a as i}from"./chunk-OVMNCZYC.js";import"./chunk-3BQFJANQ.js";import"./chunk-AE4CUTUE.js";import"./chunk-S5TVMQRC.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.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 h(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 h({...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,h as trackOpenRouterUsage};
|
package/dist/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as ConfigurationSync } from './configuration-sync-
|
|
1
|
+
import { C as ConfigurationSync } from './configuration-sync-VFbY1pCN.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-BazUOjwM.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,22 @@ 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
|
-
|
|
13
|
+
meta: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
14
|
+
key: z.ZodOptional<z.ZodString>;
|
|
15
|
+
name: z.ZodOptional<z.ZodString>;
|
|
16
|
+
passthrough: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
}, z.core.$strict>>>;
|
|
14
18
|
key: z.ZodString;
|
|
15
|
-
|
|
19
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
attribute: z.ZodOptional<z.ZodString>;
|
|
21
|
+
seed: z.ZodString;
|
|
22
|
+
hashVersion: z.ZodLiteral<2>;
|
|
23
|
+
ranges: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
24
|
+
}, z.core.$strict>>>;
|
|
16
25
|
seed: z.ZodOptional<z.ZodString>;
|
|
17
26
|
hashVersion: z.ZodOptional<z.ZodLiteral<2>>;
|
|
18
27
|
ranges: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
19
|
-
|
|
28
|
+
condition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
20
29
|
urlPatterns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
30
|
include: z.ZodBoolean;
|
|
22
31
|
type: z.ZodEnum<{
|
|
@@ -25,30 +34,21 @@ declare const pageExperimentPayloadSchema: z.ZodObject<{
|
|
|
25
34
|
}>;
|
|
26
35
|
pattern: z.ZodString;
|
|
27
36
|
}, z.core.$strict>>>;
|
|
37
|
+
force: z.ZodOptional<z.ZodNumber>;
|
|
28
38
|
persistQueryString: z.ZodOptional<z.ZodBoolean>;
|
|
29
39
|
hashAttribute: z.ZodOptional<z.ZodString>;
|
|
30
|
-
phase: z.ZodOptional<z.ZodString>;
|
|
31
|
-
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
|
-
attribute: z.ZodOptional<z.ZodString>;
|
|
33
|
-
seed: z.ZodString;
|
|
34
|
-
hashVersion: z.ZodLiteral<2>;
|
|
35
|
-
ranges: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
36
|
-
}, z.core.$strict>>>;
|
|
37
40
|
parentConditions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
41
|
id: z.ZodString;
|
|
39
42
|
condition: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
40
43
|
gate: z.ZodOptional<z.ZodBoolean>;
|
|
41
44
|
}, z.core.$strict>>>;
|
|
42
45
|
weights: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
46
|
+
coverage: z.ZodOptional<z.ZodNumber>;
|
|
43
47
|
fallbackAttribute: z.ZodOptional<z.ZodString>;
|
|
44
48
|
disableStickyBucketing: z.ZodOptional<z.ZodBoolean>;
|
|
45
49
|
bucketVersion: z.ZodOptional<z.ZodNumber>;
|
|
46
50
|
minBucketVersion: z.ZodOptional<z.ZodNumber>;
|
|
47
|
-
|
|
48
|
-
key: z.ZodOptional<z.ZodString>;
|
|
49
|
-
name: z.ZodOptional<z.ZodString>;
|
|
50
|
-
passthrough: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
-
}, z.core.$strict>>>;
|
|
51
|
+
phase: z.ZodOptional<z.ZodString>;
|
|
52
52
|
changeId: z.ZodString;
|
|
53
53
|
variations: z.ZodArray<z.ZodObject<{
|
|
54
54
|
urlRedirect: z.ZodString;
|
package/dist/page.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a,f as b,g as c,h as d}from"./chunk-
|
|
1
|
+
import{e as a,f as b,g as c,h as d}from"./chunk-YAFMBXIE.js";import"./chunk-S5TVMQRC.js";import"./chunk-KQCTDXVD.js";export{d as createPageExperiments,a as mergeQueryStrings,b as pageAttributes,c as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as z}from"./chunk-6X42DWOM.js";import"./chunk-CXYOZSOF.js";import{Qd as q,kj as j}from"./chunk-A3N4ZZTM.js";import{a as w}from"./chunk-OVMNCZYC.js";import{ka as N,v as $}from"./chunk-3BQFJANQ.js";import"./chunk-AE4CUTUE.js";import"./chunk-S5TVMQRC.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";async function W(b,n,h){if(n.status!=="complete")throw new w("INVALID_RESPONSE","A verified completed purchase is required");if(await h.onComplete?.(n),!b||!h.check)return;let t=N.parse(await h.check());if(t.internal_feature_id!==b.internal_feature_id||t.quantity!==b.quantity)throw new w("INVALID_RESPONSE","The access requirement changed");t.allowed&&await h.onAccessGranted?.(t)}async function ie(b,n){let h=n.check?N.parse(await n.check()):null;if(h?.allowed)return await n.onAccessGranted?.(h),{check:h,host:null};let t=await n.start(),y=t.view??await t.refresh();if(!y)throw new w("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:J}=await import("./popup.js"),a=b.ownerDocument,S=new AbortController,v=a.createElement("section"),Q=a.createElement("div"),O=a.createElement("div"),P=a.createElement("p"),c=a.createElement("button"),L=a.createElement("button"),u=a.createElement("dialog"),_=a.activeElement,p=y.document.screen.strings.defaultLocale.startsWith("zh");v.dataset.indianaPaywall="",v.setAttribute("aria-label",y.document.name),v.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",O.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",P.setAttribute("role","status"),L.textContent=p?"\u5173\u95ED":"Close",c.textContent=p?"\u91CD\u8BD5":"Retry",c.hidden=!0,O.append(P,c,L),v.append(Q,O);let D=y.document.presentation,A,d=!1,T=!1,f=null,G=!1,m=()=>!G&&n.canInteract?.()!==!1,M=!1,r=null,I=null,U=e=>{P.textContent=e instanceof Error?e.message:p?"\u8BF7\u6C42\u5931\u8D25":"Request failed",z(n.onError,e),c.hidden=r===null};async function k(e){if(!(T||d||!m())){T=!0,c.hidden=!0,P.textContent="";try{await e()}catch(s){d||U(s)}finally{T=!1}}}async function K(e){await W(h,e,n)}async function E(e){if(d)return;if(!m()){r=async()=>E(await t.read()),c.hidden=!1;return}if(P.textContent=e.status,e.status==="complete"){r=null,await K(e);return}if(e.status!=="pending"){if(t.canReselect===!1){P.textContent=p?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",c.textContent=p?"\u67E5\u8BE2\u7ED3\u679C":"Check result",r=async()=>E(await t.read()),c.hidden=!1;return}c.textContent=p?"\u91CD\u8BD5":"Retry",r=null,f=null;return}let s=Date.now()+6e5,l=2e3;for(;!d&&Date.now()<s;){if(await new Promise(C=>{let R=()=>{clearTimeout(x),C()},x=setTimeout(()=>{S.signal.removeEventListener("abort",R),C()},l);S.signal.addEventListener("abort",R,{once:!0})}),d)return;if(!m()){r=async()=>E(await t.read()),c.hidden=!1;return}let i=await t.read();if(i.status!=="pending"){await E(i);return}l=Math.min(l*1.5,3e4)}r=async()=>E(await t.read()),c.hidden=!1}async function V(){I?.remove(),I=null,r=V;let e=await t.confirm();if(!m()){r=V,c.hidden=!1;return}if(e.status==="pending"){if(e.checkoutUrl)n.onCheckoutUrl?await n.onCheckoutUrl(e.checkoutUrl):a.defaultView?.location.assign(e.checkoutUrl);else if(e.execution||e.nativePurchase){if(!n.onPurchase)throw new w("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await n.onPurchase({operation:e,signal:S.signal})}}r=async()=>E(await t.read()),await E(e)}function X(e){I?.remove();let s=a.createElement("div"),l=a.createElement("button"),i=a.createElement("button"),C=a.createElement("p");C.textContent=e.lines.map(o=>o.productName).join(", ")+" \xB7 "+$(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),l.textContent=p?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",i.textContent=p?"\u53D6\u6D88":"Cancel",l.onclick=()=>{k(V)};let R=async()=>{let o=await t.cancel();d||(s.remove(),I=null,await E(o))};i.onclick=()=>{r=R,k(R)};let x=a.createElement("div");for(let o of e.lines){let B=a.createElement("p");if(B.textContent=`${o.productName} \xB7 ${$(o.catalogAmountMinor,e.currency)}${j(o.interval,p?"zh-CN":"en",o.intervalCount??1)}`,x.append(B),o.trial){let F=a.createElement("p");F.textContent=p?`\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"}`,x.append(F)}}if(!e.charge){let o=a.createElement("p");o.textContent=p?"\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.",x.append(o)}s.append(C,x,l,i),O.prepend(s),I=s,r=null}async function H(){if(!f)return;if(r=H,!M){let s=t.view,l=s?.document.buttons[f.actionId],i=s&&l?.type==="checkout"?q(l.product,f.selection,s.capabilities):null;if(!i)throw new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let C=await n.resolveOfferId?.({actionId:f.actionId,productVersionId:i});if(d)return;C!==void 0&&(f.offerId=C),M=!0}if(!m()){c.hidden=!1;return}let e=await t.preview(f);d||X(e)}function g(e="destroy"){d||(d=!0,S.abort(),A?.destroy(),t.destroy(),u.open&&u.close(),u.remove(),v.remove(),_ instanceof HTMLElement&&_.isConnected&&_.focus(),e==="dismiss"&&z(n.onDismiss))}L.onclick=()=>{m()&&g("dismiss")},u.addEventListener("cancel",e=>{e.preventDefault(),m()&&g("dismiss")}),c.onclick=()=>{r&&k(r)};try{if(D.type==="inline")b.append(v);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 D?e[D.size]+"px":"100vw"}`,u.setAttribute("aria-label",y.document.name),u.append(v),b.append(u),m()&&u.showModal()}A=J(Q,{mode:"live",rendererUrl:t.webViewUrl,title:y.document.name,onAction(e,s={}){if(!m())return;let l=t.view,i=l?.document.buttons[e];if(i){if(i.type==="close"){k(async()=>{await n.onAction?.(e),g(n.onAction?"action":"dismiss")});return}if(i.type==="action"){r=async()=>{if(i.action.type==="event"){if(!n.onEvent)throw new w("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(i.action.event)}else n.onOpenUrl?await n.onOpenUrl(i.action.url):a.defaultView?.location.assign(i.action.url);await n.onAction?.(e),r=null},k(r);return}if((t.quote||f)&&t.canReselect===!1){r=t.quote?async()=>E(await t.read()):H,k(r);return}if(!l||!q(i.product,s,l.capabilities)){U(new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(f&&f.actionId!==e){U(new w("COMMAND_PENDING","Finish the current purchase"));return}f||(f={requestId:crypto.randomUUID(),actionId:e,selection:s},M=!1),k(H)}},onEscape:()=>{m()&&g("dismiss")},onError:e=>U(new Error(e))}),A.update(y.document.screen,y.document.screen.strings.defaultLocale,{capabilities:y.capabilities,serverInput:{bindings:[],answers:{}}}),await A.ready}catch(e){throw g(),e}return{check:h,host:{setSuspended(e){G=e,v.hidden=e,e&&u.open?u.close():!e&&!d&&D.type!=="inline"&&!u.open&&u.showModal()},destroy:g,refresh:async()=>{if(!m()){if(t.view)return t.view;throw new w("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await t.refresh();return d||A?.updateCapabilities(e.capabilities),e}}}}export{ie as showPaywall};
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,260 +1,7 @@
|
|
|
1
|
-
import { a as ScreenAction, b as ScreenNode, c as ScreenDocument } from './screen-
|
|
2
|
-
import { O as Offer,
|
|
3
|
-
import { z } from 'zod';
|
|
1
|
+
import { a as ScreenAction, b as ScreenNode, c as ScreenDocument } from './screen-BazUOjwM.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-BrCZxcaQ.js';
|
|
4
3
|
import { WindowLike } from 'dompurify';
|
|
5
|
-
|
|
6
|
-
declare const surfaceDataSchema: z.ZodObject<{
|
|
7
|
-
paywall: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
internal_feature_id: z.ZodString;
|
|
9
|
-
name: z.ZodString;
|
|
10
|
-
kind: z.ZodEnum<{
|
|
11
|
-
access: "access";
|
|
12
|
-
metered: "metered";
|
|
13
|
-
credit: "credit";
|
|
14
|
-
}>;
|
|
15
|
-
quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
16
|
-
allowed: z.ZodBoolean;
|
|
17
|
-
reason: z.ZodNullable<z.ZodEnum<{
|
|
18
|
-
unavailable: "unavailable";
|
|
19
|
-
insufficient_balance: "insufficient_balance";
|
|
20
|
-
limit_exceeded: "limit_exceeded";
|
|
21
|
-
awaiting_topup: "awaiting_topup";
|
|
22
|
-
authorization_required: "authorization_required";
|
|
23
|
-
payment_blocked: "payment_blocked";
|
|
24
|
-
cash_budget_exceeded: "cash_budget_exceeded";
|
|
25
|
-
not_entitled: "not_entitled";
|
|
26
|
-
capacity_exceeded: "capacity_exceeded";
|
|
27
|
-
authentication_required: "authentication_required";
|
|
28
|
-
}>>;
|
|
29
|
-
preview: z.ZodNullable<z.ZodObject<{
|
|
30
|
-
scenario: z.ZodEnum<{
|
|
31
|
-
feature_flag: "feature_flag";
|
|
32
|
-
usage_limit: "usage_limit";
|
|
33
|
-
}>;
|
|
34
|
-
candidates: z.ZodArray<z.ZodObject<{
|
|
35
|
-
productId: z.ZodString;
|
|
36
|
-
productVersionId: z.ZodString;
|
|
37
|
-
name: z.ZodString;
|
|
38
|
-
action: z.ZodEnum<{
|
|
39
|
-
purchase: "purchase";
|
|
40
|
-
upgrade: "upgrade";
|
|
41
|
-
addon: "addon";
|
|
42
|
-
topup: "topup";
|
|
43
|
-
}>;
|
|
44
|
-
membershipId: z.ZodNullable<z.ZodString>;
|
|
45
|
-
currency: z.ZodEnum<{
|
|
46
|
-
USD: "USD";
|
|
47
|
-
EUR: "EUR";
|
|
48
|
-
CNY: "CNY";
|
|
49
|
-
GBP: "GBP";
|
|
50
|
-
JPY: "JPY";
|
|
51
|
-
CAD: "CAD";
|
|
52
|
-
AUD: "AUD";
|
|
53
|
-
NZD: "NZD";
|
|
54
|
-
CHF: "CHF";
|
|
55
|
-
HKD: "HKD";
|
|
56
|
-
SGD: "SGD";
|
|
57
|
-
KRW: "KRW";
|
|
58
|
-
INR: "INR";
|
|
59
|
-
BRL: "BRL";
|
|
60
|
-
MXN: "MXN";
|
|
61
|
-
TWD: "TWD";
|
|
62
|
-
THB: "THB";
|
|
63
|
-
IDR: "IDR";
|
|
64
|
-
MYR: "MYR";
|
|
65
|
-
PHP: "PHP";
|
|
66
|
-
VND: "VND";
|
|
67
|
-
ZAR: "ZAR";
|
|
68
|
-
AED: "AED";
|
|
69
|
-
SAR: "SAR";
|
|
70
|
-
SEK: "SEK";
|
|
71
|
-
NOK: "NOK";
|
|
72
|
-
DKK: "DKK";
|
|
73
|
-
PLN: "PLN";
|
|
74
|
-
CZK: "CZK";
|
|
75
|
-
HUF: "HUF";
|
|
76
|
-
ILS: "ILS";
|
|
77
|
-
TRY: "TRY";
|
|
78
|
-
RON: "RON";
|
|
79
|
-
}>;
|
|
80
|
-
amountMinor: z.ZodString;
|
|
81
|
-
interval: z.ZodEnum<{
|
|
82
|
-
week: "week";
|
|
83
|
-
month: "month";
|
|
84
|
-
year: "year";
|
|
85
|
-
free: "free";
|
|
86
|
-
one_time: "one_time";
|
|
87
|
-
}>;
|
|
88
|
-
intervalCount: z.ZodNumber;
|
|
89
|
-
}, z.core.$strict>>;
|
|
90
|
-
}, z.core.$strict>>;
|
|
91
|
-
}, z.core.$strict>>;
|
|
92
|
-
nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
93
|
-
base: z.ZodObject<{
|
|
94
|
-
text: z.ZodOptional<z.ZodString>;
|
|
95
|
-
label: z.ZodOptional<z.ZodString>;
|
|
96
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
97
|
-
html: z.ZodOptional<z.ZodString>;
|
|
98
|
-
price: z.ZodOptional<z.ZodObject<{
|
|
99
|
-
current: z.ZodString;
|
|
100
|
-
original: z.ZodNullable<z.ZodString>;
|
|
101
|
-
period: z.ZodString;
|
|
102
|
-
}, z.core.$strip>>;
|
|
103
|
-
code: z.ZodOptional<z.ZodString>;
|
|
104
|
-
countdownAt: z.ZodOptional<z.ZodISODateTime>;
|
|
105
|
-
planId: z.ZodOptional<z.ZodString>;
|
|
106
|
-
planVersionId: z.ZodOptional<z.ZodString>;
|
|
107
|
-
currency: z.ZodOptional<z.ZodEnum<{
|
|
108
|
-
USD: "USD";
|
|
109
|
-
EUR: "EUR";
|
|
110
|
-
CNY: "CNY";
|
|
111
|
-
GBP: "GBP";
|
|
112
|
-
JPY: "JPY";
|
|
113
|
-
CAD: "CAD";
|
|
114
|
-
AUD: "AUD";
|
|
115
|
-
NZD: "NZD";
|
|
116
|
-
CHF: "CHF";
|
|
117
|
-
HKD: "HKD";
|
|
118
|
-
SGD: "SGD";
|
|
119
|
-
KRW: "KRW";
|
|
120
|
-
INR: "INR";
|
|
121
|
-
BRL: "BRL";
|
|
122
|
-
MXN: "MXN";
|
|
123
|
-
TWD: "TWD";
|
|
124
|
-
THB: "THB";
|
|
125
|
-
IDR: "IDR";
|
|
126
|
-
MYR: "MYR";
|
|
127
|
-
PHP: "PHP";
|
|
128
|
-
VND: "VND";
|
|
129
|
-
ZAR: "ZAR";
|
|
130
|
-
AED: "AED";
|
|
131
|
-
SAR: "SAR";
|
|
132
|
-
SEK: "SEK";
|
|
133
|
-
NOK: "NOK";
|
|
134
|
-
DKK: "DKK";
|
|
135
|
-
PLN: "PLN";
|
|
136
|
-
CZK: "CZK";
|
|
137
|
-
HUF: "HUF";
|
|
138
|
-
ILS: "ILS";
|
|
139
|
-
TRY: "TRY";
|
|
140
|
-
RON: "RON";
|
|
141
|
-
}>>;
|
|
142
|
-
couponId: z.ZodOptional<z.ZodUUID>;
|
|
143
|
-
offerId: z.ZodOptional<z.ZodUUID>;
|
|
144
|
-
unavailable: z.ZodOptional<z.ZodBoolean>;
|
|
145
|
-
unavailableReason: z.ZodOptional<z.ZodString>;
|
|
146
|
-
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
147
|
-
}, z.core.$strict>;
|
|
148
|
-
picker: z.ZodOptional<z.ZodString>;
|
|
149
|
-
byPlan: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
150
|
-
text: z.ZodOptional<z.ZodString>;
|
|
151
|
-
label: z.ZodOptional<z.ZodString>;
|
|
152
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
153
|
-
html: z.ZodOptional<z.ZodString>;
|
|
154
|
-
price: z.ZodOptional<z.ZodObject<{
|
|
155
|
-
current: z.ZodString;
|
|
156
|
-
original: z.ZodNullable<z.ZodString>;
|
|
157
|
-
period: z.ZodString;
|
|
158
|
-
}, z.core.$strip>>;
|
|
159
|
-
code: z.ZodOptional<z.ZodString>;
|
|
160
|
-
countdownAt: z.ZodOptional<z.ZodISODateTime>;
|
|
161
|
-
planId: z.ZodOptional<z.ZodString>;
|
|
162
|
-
planVersionId: z.ZodOptional<z.ZodString>;
|
|
163
|
-
currency: z.ZodOptional<z.ZodEnum<{
|
|
164
|
-
USD: "USD";
|
|
165
|
-
EUR: "EUR";
|
|
166
|
-
CNY: "CNY";
|
|
167
|
-
GBP: "GBP";
|
|
168
|
-
JPY: "JPY";
|
|
169
|
-
CAD: "CAD";
|
|
170
|
-
AUD: "AUD";
|
|
171
|
-
NZD: "NZD";
|
|
172
|
-
CHF: "CHF";
|
|
173
|
-
HKD: "HKD";
|
|
174
|
-
SGD: "SGD";
|
|
175
|
-
KRW: "KRW";
|
|
176
|
-
INR: "INR";
|
|
177
|
-
BRL: "BRL";
|
|
178
|
-
MXN: "MXN";
|
|
179
|
-
TWD: "TWD";
|
|
180
|
-
THB: "THB";
|
|
181
|
-
IDR: "IDR";
|
|
182
|
-
MYR: "MYR";
|
|
183
|
-
PHP: "PHP";
|
|
184
|
-
VND: "VND";
|
|
185
|
-
ZAR: "ZAR";
|
|
186
|
-
AED: "AED";
|
|
187
|
-
SAR: "SAR";
|
|
188
|
-
SEK: "SEK";
|
|
189
|
-
NOK: "NOK";
|
|
190
|
-
DKK: "DKK";
|
|
191
|
-
PLN: "PLN";
|
|
192
|
-
CZK: "CZK";
|
|
193
|
-
HUF: "HUF";
|
|
194
|
-
ILS: "ILS";
|
|
195
|
-
TRY: "TRY";
|
|
196
|
-
RON: "RON";
|
|
197
|
-
}>>;
|
|
198
|
-
couponId: z.ZodOptional<z.ZodUUID>;
|
|
199
|
-
offerId: z.ZodOptional<z.ZodUUID>;
|
|
200
|
-
unavailable: z.ZodOptional<z.ZodBoolean>;
|
|
201
|
-
unavailableReason: z.ZodOptional<z.ZodString>;
|
|
202
|
-
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
203
|
-
}, z.core.$strict>>>;
|
|
204
|
-
}, z.core.$strict>>;
|
|
205
|
-
plans: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
206
|
-
id: z.ZodString;
|
|
207
|
-
versionId: z.ZodString;
|
|
208
|
-
available: z.ZodBoolean;
|
|
209
|
-
name: z.ZodString;
|
|
210
|
-
price: z.ZodString;
|
|
211
|
-
period: z.ZodString;
|
|
212
|
-
currency: z.ZodOptional<z.ZodEnum<{
|
|
213
|
-
USD: "USD";
|
|
214
|
-
EUR: "EUR";
|
|
215
|
-
CNY: "CNY";
|
|
216
|
-
GBP: "GBP";
|
|
217
|
-
JPY: "JPY";
|
|
218
|
-
CAD: "CAD";
|
|
219
|
-
AUD: "AUD";
|
|
220
|
-
NZD: "NZD";
|
|
221
|
-
CHF: "CHF";
|
|
222
|
-
HKD: "HKD";
|
|
223
|
-
SGD: "SGD";
|
|
224
|
-
KRW: "KRW";
|
|
225
|
-
INR: "INR";
|
|
226
|
-
BRL: "BRL";
|
|
227
|
-
MXN: "MXN";
|
|
228
|
-
TWD: "TWD";
|
|
229
|
-
THB: "THB";
|
|
230
|
-
IDR: "IDR";
|
|
231
|
-
MYR: "MYR";
|
|
232
|
-
PHP: "PHP";
|
|
233
|
-
VND: "VND";
|
|
234
|
-
ZAR: "ZAR";
|
|
235
|
-
AED: "AED";
|
|
236
|
-
SAR: "SAR";
|
|
237
|
-
SEK: "SEK";
|
|
238
|
-
NOK: "NOK";
|
|
239
|
-
DKK: "DKK";
|
|
240
|
-
PLN: "PLN";
|
|
241
|
-
CZK: "CZK";
|
|
242
|
-
HUF: "HUF";
|
|
243
|
-
ILS: "ILS";
|
|
244
|
-
TRY: "TRY";
|
|
245
|
-
RON: "RON";
|
|
246
|
-
}>>;
|
|
247
|
-
}, z.core.$strict>>;
|
|
248
|
-
pickers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
249
|
-
options: z.ZodArray<z.ZodString>;
|
|
250
|
-
selected: z.ZodNullable<z.ZodString>;
|
|
251
|
-
}, z.core.$strict>>;
|
|
252
|
-
diagnostics: z.ZodArray<z.ZodObject<{
|
|
253
|
-
nodeId: z.ZodString;
|
|
254
|
-
message: z.ZodString;
|
|
255
|
-
}, z.core.$strict>>;
|
|
256
|
-
}, z.core.$strict>;
|
|
257
|
-
type SurfaceData = z.infer<typeof surfaceDataSchema>;
|
|
4
|
+
import 'zod';
|
|
258
5
|
|
|
259
6
|
type PopupEvent = {
|
|
260
7
|
type: "shown";
|
|
@@ -277,21 +24,6 @@ type PopupEvent = {
|
|
|
277
24
|
reason: OfferUnavailableReason | "error" | null;
|
|
278
25
|
};
|
|
279
26
|
|
|
280
|
-
declare const screenAnswersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
281
|
-
declare const screenParametersSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
282
|
-
type ScreenParameters = z.infer<typeof screenParametersSchema>;
|
|
283
|
-
type ScreenAnswers = z.infer<typeof screenAnswersSchema>;
|
|
284
|
-
declare const screenRendererInputSchema: z.ZodObject<{
|
|
285
|
-
bindings: z.ZodArray<z.ZodObject<{
|
|
286
|
-
variable: z.ZodString;
|
|
287
|
-
componentId: z.ZodString;
|
|
288
|
-
required: z.ZodBoolean;
|
|
289
|
-
}, z.core.$strict>>;
|
|
290
|
-
answers: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
291
|
-
values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
292
|
-
}, z.core.$strict>;
|
|
293
|
-
type ScreenRendererInput = z.infer<typeof screenRendererInputSchema>;
|
|
294
|
-
|
|
295
27
|
/**
|
|
296
28
|
* Render the current ScreenDocument 4 into DOM.
|
|
297
29
|
*
|
|
@@ -363,8 +95,6 @@ declare const hostedRendererShell: {
|
|
|
363
95
|
|
|
364
96
|
/** The bootstrap the shell's CSP hash authorizes. */
|
|
365
97
|
declare function hostedRendererScript(): string;
|
|
366
|
-
/** Published screen bootstrap; the same bytes in every server bundle, so its CSP hash and address agree. */
|
|
367
|
-
declare function hostedScreenScript(): string;
|
|
368
98
|
|
|
369
99
|
type PopupHandle = {
|
|
370
100
|
destroy: () => void;
|
|
@@ -385,13 +115,10 @@ declare function showPopup(input: ScreenDocument, options?: {
|
|
|
385
115
|
type ScreenPreviewHandle = {
|
|
386
116
|
/** Rejects if the renderer cannot start; this does not grant customer authorization. */
|
|
387
117
|
ready: Promise<void>;
|
|
388
|
-
/** The
|
|
118
|
+
/** The document of the last update. */
|
|
389
119
|
readonly document: ScreenDocument | null;
|
|
390
|
-
/**
|
|
391
|
-
|
|
392
|
-
* A published screen render passes null: its document arrives with the frame.
|
|
393
|
-
*/
|
|
394
|
-
update(doc: ScreenDocument | null, locale: string,
|
|
120
|
+
/** 重新渲染(完整文档 + 当前编辑的语言;缺失的文案用默认语言淡显)。 */
|
|
121
|
+
update(doc: ScreenDocument, locale: string,
|
|
395
122
|
/** Current single-screen presentation and server-owned input bindings. */
|
|
396
123
|
options?: {
|
|
397
124
|
parameters?: ScreenParameters;
|
|
@@ -418,8 +145,6 @@ type ScreenPreviewHandle = {
|
|
|
418
145
|
declare function mountScreenPreview(container: HTMLElement, options?: {
|
|
419
146
|
mode?: RendererMode;
|
|
420
147
|
rendererUrl?: string;
|
|
421
|
-
/** Public cached render of one published screen; its document comes from the frame. */
|
|
422
|
-
screenUrl?: string;
|
|
423
148
|
title?: string;
|
|
424
149
|
/** Translate editor controls without changing authored text or the content locale. */
|
|
425
150
|
editorMessages?: RendererEditorMessages;
|
|
@@ -451,4 +176,4 @@ type CustomerPageHandle = {
|
|
|
451
176
|
destroy(): void;
|
|
452
177
|
};
|
|
453
178
|
|
|
454
|
-
export { type CustomerPageHandle, type HtmlCodeDiagnostic, type PopupEvent, type PopupHandle, type RendererEditorKey, type RendererEditorMessages, ScreenDocument, type ScreenNodeRect, type ScreenPreviewHandle, formatCustomerDecimal, hostedRendererScript, hostedRendererShell,
|
|
179
|
+
export { type CustomerPageHandle, type HtmlCodeDiagnostic, type PopupEvent, type PopupHandle, type RendererEditorKey, type RendererEditorMessages, ScreenDocument, type ScreenNodeRect, type ScreenPreviewHandle, formatCustomerDecimal, hostedRendererScript, hostedRendererShell, inspectCustomHtml, mountScreenPreview, prepareScreen, sanitizeCustomHtml, showPopup };
|