@tinkerlandai/indiana-sdk 0.6.2 → 0.6.3
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 +5 -1
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/chunk-4K25DELJ.js +1 -0
- package/dist/chunk-CB63JLGT.js +1 -0
- package/dist/{chunk-N6UIDDAX.js → chunk-D7YHFS6B.js} +2 -2
- package/dist/chunk-FF3LWJ26.js +11 -0
- package/dist/chunk-FVUPV6YE.js +1 -0
- package/dist/chunk-ISUXYPYL.js +1 -0
- package/dist/{chunk-M3DG6ZCT.js → chunk-QG4GM4RI.js} +1 -1
- package/dist/chunk-U6S6AZM6.js +1 -0
- package/dist/chunk-VVSQKVE7.js +1 -0
- package/dist/chunk-YAMBRNJ2.js +1 -0
- package/dist/client-OYRHOMUQ.js +1 -0
- package/dist/{configuration-sync-Bnu8s4pc.d.ts → configuration-sync-C2mytNwU.d.ts} +18 -0
- package/dist/funnel-runtime-host-KPYLOYYN.js +1 -0
- package/dist/{funnel-runtime-start-Zbd5ro5r.d.ts → funnel-runtime-start-CVb2YonU.d.ts} +40 -3
- package/dist/iam.d.ts +131 -0
- package/dist/iam.js +1 -0
- package/dist/index.d.ts +40 -4
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-5WU6PX5C.js +1 -0
- package/dist/popup.d.ts +2 -5
- package/dist/popup.js +3 -14
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/src-U7PBAUBN.js +1 -0
- package/dist/visual.d.ts +10 -1
- package/dist/visual.js +2 -1
- package/package.json +8 -2
- package/dist/chunk-BIFEEVQO.js +0 -1
- package/dist/chunk-ET4NANGB.js +0 -1
- package/dist/chunk-J7M7UH74.js +0 -1
- package/dist/chunk-OHDY27EI.js +0 -1
- package/dist/chunk-VMLGV5OS.js +0 -11
- package/dist/funnel-runtime-host-3STQUS6F.js +0 -1
- package/dist/paywall-LBDMGVWZ.js +0 -1
- package/dist/src-X6KT6WIH.js +0 -1
- package/dist/visual-editor-agent-WW65CMKW.js +0 -1
package/dist/iam.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as zod_mini from 'zod/mini';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const captureSnapshotSchema: zod_mini.ZodMiniObject<{
|
|
5
|
+
format: z.ZodLiteral<"indiana-runtime-snapshot">;
|
|
6
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
7
|
+
collector: zod_mini.ZodMiniObject<{
|
|
8
|
+
name: z.ZodLiteral<"indiana-bounded-dom">;
|
|
9
|
+
version: z.ZodLiteral<2>;
|
|
10
|
+
buildSha256: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
sourceVersionId: z.ZodUUID;
|
|
13
|
+
manifestDigest: z.ZodString;
|
|
14
|
+
pageKey: z.ZodString;
|
|
15
|
+
routeTemplate: z.ZodString;
|
|
16
|
+
sequence: z.ZodNumber;
|
|
17
|
+
label: z.ZodString;
|
|
18
|
+
viewport: zod_mini.ZodMiniObject<{
|
|
19
|
+
width: z.ZodNumber;
|
|
20
|
+
height: z.ZodNumber;
|
|
21
|
+
dpr: z.ZodNumber;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
privacy: z.ZodLiteral<"masked-default-v2">;
|
|
24
|
+
contentHash: z.ZodString;
|
|
25
|
+
previousContentHash: z.ZodNullable<z.ZodString>;
|
|
26
|
+
document: zod_mini.ZodMiniObject<{
|
|
27
|
+
nodes: z.ZodArray<zod_mini.ZodMiniObject<{
|
|
28
|
+
id: z.ZodNumber;
|
|
29
|
+
parentId: z.ZodNullable<z.ZodNumber>;
|
|
30
|
+
kind: z.ZodEnum<{
|
|
31
|
+
text: "text";
|
|
32
|
+
element: "element";
|
|
33
|
+
}>;
|
|
34
|
+
tag: z.ZodNullable<z.ZodString>;
|
|
35
|
+
text: z.ZodNullable<z.ZodString>;
|
|
36
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
37
|
+
shadow: z.ZodBoolean;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
css: z.ZodString;
|
|
40
|
+
shadowCss: z.ZodArray<zod_mini.ZodMiniObject<{
|
|
41
|
+
hostId: z.ZodNumber;
|
|
42
|
+
css: z.ZodString;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
scroll: zod_mini.ZodMiniObject<{
|
|
45
|
+
x: z.ZodNumber;
|
|
46
|
+
y: z.ZodNumber;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
gaps: z.ZodArray<z.ZodString>;
|
|
50
|
+
metrics: zod_mini.ZodMiniObject<{
|
|
51
|
+
maxSliceMs: z.ZodNumber;
|
|
52
|
+
totalWorkMs: z.ZodNumber;
|
|
53
|
+
elapsedMs: z.ZodNumber;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
type CaptureSnapshot = z.infer<typeof captureSnapshotSchema>;
|
|
57
|
+
|
|
58
|
+
declare class CaptureRefusal extends Error {
|
|
59
|
+
code: string;
|
|
60
|
+
metrics?: {
|
|
61
|
+
maxSliceMs: number;
|
|
62
|
+
totalWorkMs: number;
|
|
63
|
+
elapsedMs: number;
|
|
64
|
+
phase: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
constructor(code: string, metrics?: {
|
|
67
|
+
maxSliceMs: number;
|
|
68
|
+
totalWorkMs: number;
|
|
69
|
+
elapsedMs: number;
|
|
70
|
+
phase: string;
|
|
71
|
+
} | undefined);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type Metrics = NonNullable<CaptureRefusal["metrics"]>;
|
|
75
|
+
type CaptureOptions = {
|
|
76
|
+
/** Trusted merchant configuration, never copied from the incoming capability. */
|
|
77
|
+
environmentId: string;
|
|
78
|
+
grant: string;
|
|
79
|
+
baseUrl: string;
|
|
80
|
+
document?: Document;
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
onStatus?: (status: {
|
|
83
|
+
state: "idle" | "capturing" | "uploading" | "waiting" | "paused" | "stopped";
|
|
84
|
+
reason?: string;
|
|
85
|
+
snapshots: number;
|
|
86
|
+
pending: number;
|
|
87
|
+
metrics?: Metrics;
|
|
88
|
+
expiresAt?: number;
|
|
89
|
+
}) => void;
|
|
90
|
+
/** A reviewed local transport must honor cancellation. The default uses capability-only HTTP. */
|
|
91
|
+
transport?: (snapshot: CaptureSnapshot, bytes: Uint8Array, signal: AbortSignal, requestId: string) => Promise<void>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
declare function installCaptureActivation(options: {
|
|
95
|
+
baseUrl: string;
|
|
96
|
+
environmentId: string;
|
|
97
|
+
controls?: boolean;
|
|
98
|
+
nonce?: string;
|
|
99
|
+
document?: Document;
|
|
100
|
+
prepare?: () => Promise<void>;
|
|
101
|
+
onStatus?: (status: {
|
|
102
|
+
state: string;
|
|
103
|
+
reason?: string;
|
|
104
|
+
snapshots: number;
|
|
105
|
+
}) => void;
|
|
106
|
+
onAuthoringChange?: (active: boolean) => void;
|
|
107
|
+
}): {
|
|
108
|
+
destroy(): void;
|
|
109
|
+
checkpoint(_label?: string): void;
|
|
110
|
+
retry(): void;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Optional post-build release descriptor. Keeps bundler CSS output out of a digest/rebuild cycle. */
|
|
114
|
+
declare function loadAppManifestRelease(path: string, document: Document, signal: AbortSignal): Promise<string>;
|
|
115
|
+
|
|
116
|
+
declare function installAppManifestRelease(release: string, target?: Document): {
|
|
117
|
+
attributes: {
|
|
118
|
+
indianaAppManifestRelease: string;
|
|
119
|
+
};
|
|
120
|
+
destroy(): void;
|
|
121
|
+
};
|
|
122
|
+
/** Lazy, explicitly authorized runtime collection; ordinary visitors do not load the recorder. */
|
|
123
|
+
declare function startAppManifestCapture(options: CaptureOptions): Promise<{
|
|
124
|
+
checkpoint(nextLabel?: string): void;
|
|
125
|
+
retry(): void;
|
|
126
|
+
destroy: (reason?: string) => void;
|
|
127
|
+
readonly paused: boolean;
|
|
128
|
+
readonly snapshots: number;
|
|
129
|
+
}>;
|
|
130
|
+
|
|
131
|
+
export { type CaptureOptions, installAppManifestRelease, installCaptureActivation, loadAppManifestRelease, startAppManifestCapture };
|
package/dist/iam.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-VVSQKVE7.js";import"./chunk-4K25DELJ.js";export{c as installAppManifestRelease,a as installCaptureActivation,b as loadAppManifestRelease,d as startAppManifestCapture};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { F as FunnelRuntimeResponse, a as FunnelRunView, b as FunnelCommand, c as FunnelPurchaseRecovery, d as FunnelDataQueries, I as IndianaOptions, P as PaywallSession, S as SubscriptionOperation, e as FeatureClientOptions, f as FunnelCommandStorage, g as FunnelStartInput, R as RemoteFeatureResult } from './funnel-runtime-start-
|
|
4
|
-
export { h as FeatureClient, i as FunnelNodeEvaluationContext, j as FunnelPendingEntry, k as IndianaError, L as LocalFunnelClient, l as LocalFunnelClientOptions, m as PaywallPurchaseInput, n as PaywallStartInput, o as createFeatureClient, p as createLocalFunnelClient, q as createPaywallSession, r as evaluateFunnelNode } from './funnel-runtime-start-
|
|
3
|
+
import { F as FunnelRuntimeResponse, a as FunnelRunView, b as FunnelCommand, c as FunnelPurchaseRecovery, d as FunnelDataQueries, I as IndianaOptions, P as PaywallSession, S as SubscriptionOperation, e as FeatureClientOptions, f as FunnelCommandStorage, g as FunnelStartInput, R as RemoteFeatureResult } from './funnel-runtime-start-CVb2YonU.js';
|
|
4
|
+
export { h as FeatureClient, i as FunnelNodeEvaluationContext, j as FunnelPendingEntry, k as IndianaError, L as LocalFunnelClient, l as LocalFunnelClientOptions, m as PaywallPurchaseInput, n as PaywallStartInput, o as createFeatureClient, p as createLocalFunnelClient, q as createPaywallSession, r as evaluateFunnelNode } from './funnel-runtime-start-CVb2YonU.js';
|
|
5
5
|
import { C as CouponInput, a as CustomerDataIntent, O as Offer } from './customer-page-B4FGCVpt.js';
|
|
6
6
|
export { b as OfferUnavailableReason } from './customer-page-B4FGCVpt.js';
|
|
7
7
|
import { O as OfferingItem, I as InvoiceModeParams, A as ApiInput } from './ai-usage-B4W5m4Ie.js';
|
|
8
8
|
import { S as StackNode } from './screen-16d-xADb.js';
|
|
9
|
-
import { C as ConfigurationSync } from './configuration-sync-
|
|
10
|
-
export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-
|
|
9
|
+
import { C as ConfigurationSync } from './configuration-sync-C2mytNwU.js';
|
|
10
|
+
export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-C2mytNwU.js';
|
|
11
11
|
import { J as JsonValue, F as FeatureResult } from './growth-rules-B4YYy64R.js';
|
|
12
12
|
import '@ai-sdk/provider';
|
|
13
13
|
import 'zod/v4';
|
|
@@ -746,6 +746,24 @@ declare function createFunnelRunController(options: IndianaOptions & {
|
|
|
746
746
|
failed: string;
|
|
747
747
|
id: string;
|
|
748
748
|
name: string;
|
|
749
|
+
appManifest?: {
|
|
750
|
+
versionId: string;
|
|
751
|
+
manifestDigest: string;
|
|
752
|
+
sourceGraphDigest: string;
|
|
753
|
+
pageKey: string;
|
|
754
|
+
stateKey: string;
|
|
755
|
+
documentKey: string;
|
|
756
|
+
documentHash: string;
|
|
757
|
+
elementKey?: string | undefined;
|
|
758
|
+
nodeId?: string | undefined;
|
|
759
|
+
contentHash?: string | undefined;
|
|
760
|
+
renderKey?: string | undefined;
|
|
761
|
+
observed?: {
|
|
762
|
+
versionId: string;
|
|
763
|
+
sha256: string;
|
|
764
|
+
contentHash: string;
|
|
765
|
+
} | undefined;
|
|
766
|
+
} | undefined;
|
|
749
767
|
position?: {
|
|
750
768
|
x: number;
|
|
751
769
|
y: number;
|
|
@@ -8553,6 +8571,24 @@ declare function createFunnelClient(options: IndianaOptions & {
|
|
|
8553
8571
|
failed: string;
|
|
8554
8572
|
id: string;
|
|
8555
8573
|
name: string;
|
|
8574
|
+
appManifest?: {
|
|
8575
|
+
versionId: string;
|
|
8576
|
+
manifestDigest: string;
|
|
8577
|
+
sourceGraphDigest: string;
|
|
8578
|
+
pageKey: string;
|
|
8579
|
+
stateKey: string;
|
|
8580
|
+
documentKey: string;
|
|
8581
|
+
documentHash: string;
|
|
8582
|
+
elementKey?: string | undefined;
|
|
8583
|
+
nodeId?: string | undefined;
|
|
8584
|
+
contentHash?: string | undefined;
|
|
8585
|
+
renderKey?: string | undefined;
|
|
8586
|
+
observed?: {
|
|
8587
|
+
versionId: string;
|
|
8588
|
+
sha256: string;
|
|
8589
|
+
contentHash: string;
|
|
8590
|
+
} | undefined;
|
|
8591
|
+
} | undefined;
|
|
8556
8592
|
position?: {
|
|
8557
8593
|
x: number;
|
|
8558
8594
|
y: number;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _,e as X,h as ee,i as V,j as te,k as re,l as j,m as ne}from"./chunk-J7M7UH74.js";import{a as B}from"./chunk-ET4NANGB.js";import{a as s}from"./chunk-5TEZEOHX.js";import"./chunk-S5TVMQRC.js";import{Vf as n,W as Z,X as $,Y as W,wf as L}from"./chunk-VMLGV5OS.js";import"./chunk-RMJJOSVZ.js";import"./chunk-OHDY27EI.js";import"./chunk-S2MSIA57.js";var z=o=>new TextEncoder().encode(JSON.stringify(o)).length,Q=16384;function H(o,f,r,i){if(i&&r&&(i.scope.projectId!==r.projectId||i.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let p=0,I,c=m=>{I={config:structuredClone(m),until:Date.now()+3e4}},t=[],e=null,a,l=new Set;function E(){if(!f())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function P(){a||!t.length||(a=setTimeout(()=>{a=void 0,N().catch(()=>{}).finally(P)},5e3),typeof a=="object"&&"unref"in a&&a.unref())}function x(m,v={}){if(E(),I&&Date.now()<I.until&&!L(I.config,m))return;k();let h=n.trackEvents.request.parse({events:[{eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),name:m,properties:v}]}).events[0];if(z({events:[h]})>Q)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(t.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");t.push(structuredClone(h)),P()}async function N(m=!1){if(E(),e)return e;let v=p,h=(async()=>{let O={inserted:0,duplicates:0,rejected:0,skipped:0},C=t.length;for(;C&&v===p;){let A=[];for(let F of t.slice(0,Math.min(C,100))){if(A.length&&z({events:[...A,F]})>Q)break;A.push(F)}let g=n.trackEvents,w=g.response.parse(await o(g.path,g.request.parse({events:A}),g.method,{keepalive:m}));if(v!==p)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==A.length)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement");c(w.analyticsConfig),t.splice(0,A.length),C-=A.length,O.inserted+=w.inserted,O.duplicates+=w.duplicates,O.rejected+=w.rejected,O.skipped+=w.skipped}return O})();e=h;try{return await h}finally{e===h&&(e=null)}}async function J(m={}){i||E();let v=p,h=!1,O=async()=>{if(h||v!==p)throw new s("IDENTITY_CHANGED","Feature identity changed");let y=n.getFeatures,d=i?{scope:{projectId:i.scope.projectId,environment:i.scope.environment},payload:await i.features()}:y.response.parse(await o(y.path,y.request.parse({}),y.method));if(v!==p)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(d.scope.projectId!==r.projectId||d.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return c(d.payload.analyticsConfig),d},C=await O(),A=!0,g,w=y=>{try{m.onError?.(y)}catch{}},F=(y,d)=>{try{x(y,d)}catch(S){w(S)}},R=_({assertUsable:i?.assertFeatures,scope:C.scope,attributes:m.attributes,onError:m.onError,load:async()=>A?(A=!1,C.payload):(await O()).payload,evaluateRemote:async y=>{if(v!==p)throw new s("IDENTITY_CHANGED","Feature identity changed");let d=n.evaluateFeatures,S=d.response.parse(await o(d.path,d.request.parse(y),d.method));if(S.scope.projectId!==C.scope.projectId||S.scope.environment!==C.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:S.generation,evaluatedAt:S.evaluatedAt,expiresAt:S.expiresAt,features:S.features}},onExperimentViewed:(y,d)=>F("Experiment Viewed",{experimentId:y.key,variationId:d.key}),onFeatureUsage:(y,d)=>F("Feature Evaluated",{feature:y,value:d.value,source:d.source,ruleId:d.ruleId,...d.experimentResult?{variationId:d.experimentResult.key}:{}})}),M=R.refresh;function D(){clearTimeout(g),!i&&(h||v!==p||!R.expiresAt||(g=setTimeout(()=>{b().catch(w)},Math.min(2147483647,Math.max(1e3,Date.parse(R.expiresAt)-Date.now()))),typeof g=="object"&&"unref"in g&&g.unref()))}async function b(){try{return await M()}finally{D()}}let U=()=>{h||b().catch(w)},Y=R.subscribe(D),K=i?.subscribe(()=>{!h&&i.fresh&&b().catch(w)});function q(){h||(h=!0,clearTimeout(g),typeof window<"u"&&window.removeEventListener("focus",U),Y(),K?.(),R.reset(),l.delete(q))}l.add(q);try{await R.init()}catch(y){throw q(),y}return D(),!i&&typeof window<"u"&&window.addEventListener("focus",U),Object.assign(R,{refresh:b,destroy:q})}let T;function k(){if(T||typeof document>"u")return;let m=()=>{document.visibilityState==="hidden"&&f()&&t.length&&N(!0).catch(()=>{})};document.addEventListener("visibilitychange",m),T=()=>document.removeEventListener("visibilitychange",m)}return{features:J,track(m,v){return k(),x(m,v)},flush:N,reset(){p++,I=void 0,clearTimeout(a),a=void 0,t=[],e=null;for(let m of l)m();T?.(),T=void 0}}}function G(o,f){let r="source"in f?{funnelId:f.source.id,funnelVersionId:f.source.versionId}:"versionId"in f?{funnelId:f.funnelId,funnelVersionId:f.versionId}:f,i=n.grantOffer.request.pick({funnelId:!0,funnelVersionId:!0}).required({funnelId:!0}).safeParse(r);if(!i.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let p=Object.freeze(i.data);function I(c){if("customerId"in c)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in c&&c.funnelId!==void 0&&c.funnelId!==p.funnelId||"funnelVersionId"in c&&c.funnelVersionId!==void 0&&c.funnelVersionId!==p.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...c,...p}}return{async claimCoupon(c,t=crypto.randomUUID()){let e=n.grantOffer,a=e.response.parse(await o(e.path,e.request.parse(I({couponId:c,requestId:t}))));return{offer:a.offer,reason:a.reason}},async resolveOffering(c){let t=n.resolveOffering;return t.response.parse(await o(t.path,t.request.parse(I(c))))},async resolvePaywall(c){let t=n.resolvePaywall;return t.response.parse(await o(t.path,t.request.parse(I(c))))},async previewAttach(c){let t=n.previewAttach;return t.response.parse(await o(t.path,t.request.parse(I(c))))}}}function se(o){if(!/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(o.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!o.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let f=j({...o,scope:o.scope,apiKey:o.customerToken});return{async start(r){let i=await f.start(r),p=V({...o,runToken:i.runToken});p.identify(o.customerToken);let I=i.run.instruction?.type==="evaluate"?await p.get():i;return{...i,...I,controller:p}}}}function u(o){if(o!==null&&typeof o=="object"&&"customerId"in o)throw new s("INVALID_REQUEST","Customer requests use the verified session identity")}function ge(o){let f=B(o),r=f.request,i=!1,p=H(r,()=>i,o.scope,o.configuration),I=new Set,c=t=>{for(let e of I)try{e(t)}catch{}};return{forFunnel(t){return G(r,t)},async features(t={}){return p.features(t)},track(t,e){return p.track(t,e)},flush(){return p.flush()},async setupPayment(t){u(t);let e=n.setupPayment;return e.response.parse(await r(e.path,e.request.parse(t)))},async readPaymentSetup(t){u(t);let e=n.readPaymentSetup;return e.response.parse(await r(e.path,e.request.parse(t)))},async previewUpdate(t){u(t);let e=n.previewUpdate;return e.response.parse(await r(e.path,e.request.parse(t)))},async update(t){u(t);let e=n.update;return e.response.parse(await r(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){u(t);let e=n.readSubscriptionUpdate;return e.response.parse(await r(e.path,e.request.parse(t)))},async restoreNativePurchase(t){u(t);let e=n.restoreNativePurchase;return e.response.parse(await r(e.path,e.request.parse(t)))},async previewAttach(t){u(t);let e=n.previewAttach;return e.response.parse(await r(e.path,e.request.parse(t)))},async attach(t){u(t);let e=n.attach;return e.response.parse(await r(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){u(t);let e=n.readSubscriptionOperation;return e.response.parse(await r(e.path,e.request.parse(t)))},async checkEntitlement(t){u(t);let e=n.checkEntitlement;return e.response.parse(await r(e.path,e.request.parse(t)))},async resolvePaywall(t){u(t);let e=n.resolvePaywall;return e.response.parse(await r(e.path,e.request.parse(t)))},async resolveOffering(t){u(t);let e=n.resolveOffering;return e.response.parse(await r(e.path,e.request.parse(t)))},async readHoldings(t={}){let e=n.readHoldings;return e.response.parse(await r(e.path,e.request.omit({customerId:!0}).parse(t)))},async readLedger(t){let e=n.readLedger;return e.response.parse(await r(e.path,e.request.parse({query:t})))},async readBillingInvoice(t){u(t);let e=n.readBillingInvoice;return e.response.parse(await r(e.path,e.request.parse(t)))},async readCreditStatement(t){u(t);let e=n.readCreditStatement;return e.response.parse(await r(e.path,e.request.parse(t)))},async quoteBalance(t){u(t);let e=n.quoteBalance;return e.response.parse(await r(e.path,e.request.parse({command:t})))},async readBillingControls(t={}){u(t);let e=n.readBillingControls;return e.response.parse(await r(e.path,e.request.parse(t)))},async prepareBillingAuthorization(t){u(t);let e=n.prepareBillingAuthorization;return e.response.parse(await r(e.path,e.request.parse(t)))},async confirmBillingAuthorization(t){u(t);let e=n.confirmBillingAuthorization;return e.response.parse(await r(e.path,e.request.parse(t)))},async setBillingCoupons(t){u(t);let e=n.setBillingCoupons,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid billing coupon list");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid billing coupon receipt");return l.data},async revokeBillingAuthorization(t){u(t);let e=n.revokeBillingAuthorization;return e.response.parse(await r(e.path,e.request.parse(t)))},async listBillingInvoices(t={after:null,limit:25}){u(t);let e=n.listBillingInvoices;return e.response.parse(await r(e.path,e.request.parse(t)))},async confirmBillingAdjustment(t){u(t);let e=n.confirmBillingAdjustment;return e.response.parse(await r(e.path,e.request.parse(t)))},subscribeIdentity(t){return I.add(t),()=>{I.delete(t)}},identify(t){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(t))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");p.reset(),f.identify(t),i=!0,c(!0)},reset(){i=!1,p.reset(),f.reset(),c(!1)},async redeemReward(t){u(t);let e=n.redeemReward,a=e.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!a.success)throw new s("INVALID_REQUEST","Invalid reward redemption");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid reward receipt");return l.data.redemption},async claimRewardProduct(t){u(t);let e=n.claimRewardProduct,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid reward product claim");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid reward product checkout");return l.data.checkout},async createReferralCode(t){u(t);let e=n.createReferralCode,a=e.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!a.success)throw new s("INVALID_REQUEST","Invalid referral program");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid referral code");return l.data.referralCode},async redeemCoupon(t,e=crypto.randomUUID()){let a=n.redeemCoupon,l=a.request.safeParse({code:t,requestId:e});if(!l.success)throw new s("INVALID_REQUEST","Invalid coupon code");let E=a.response.safeParse(await r(a.path,l.data));if(!E.success)throw new s("INVALID_RESPONSE","Invalid Coupon receipt");let P=E.data;return{offer:P.offer,reason:P.reason}},async claimCoupon(t,e=crypto.randomUUID()){let a=n.grantOffer,l=a.request.safeParse({couponId:t,requestId:e});if(!l.success)throw new s("INVALID_REQUEST","Invalid Coupon claim");let E=a.response.safeParse(await r(a.path,l.data));if(!E.success)throw new s("INVALID_RESPONSE","Invalid Coupon receipt");return{offer:E.data.offer,reason:E.data.reason}},async listOffers(){let t=n.listOffers.response.safeParse(await r("offers",{},"GET"));if(!t.success)throw new s("INVALID_RESPONSE","Invalid offers response");return t.data.offers}}}async function Ee(...o){return(await import("./paywall-LBDMGVWZ.js")).showPaywall(...o)}async function Ae(...o){return(await import("./funnel-runtime-host-3STQUS6F.js")).showFunnelRun(...o)}export{s as IndianaError,ee as createBrowserFunnelCommandStorage,re as createConfigurationSync,_ as createFeatureClient,se as createFunnelClient,V as createFunnelRunController,ge as createIndiana,ne as createLocalFunnelClient,te as createPaywallSession,X as evaluateFunnelNode,$ as formatCouponDiscount,Z as formatCouponMoney,W as formatCouponTerms,Ae as showFunnelRun,Ee as showPaywall};
|
|
1
|
+
import{a as _,g as X,h as V,i as ee,j as te,k as re,l as j,m as ne}from"./chunk-YAMBRNJ2.js";import{a as B}from"./chunk-FVUPV6YE.js";import{Vf as n,W as Z,X as $,Y as W,wf as L}from"./chunk-FF3LWJ26.js";import{a as s}from"./chunk-5TEZEOHX.js";import"./chunk-RMJJOSVZ.js";import"./chunk-S5TVMQRC.js";import"./chunk-ISUXYPYL.js";import"./chunk-U6S6AZM6.js";import"./chunk-4K25DELJ.js";import"./chunk-S2MSIA57.js";var z=o=>new TextEncoder().encode(JSON.stringify(o)).length,Q=16384;function H(o,f,r,i){if(i&&r&&(i.scope.projectId!==r.projectId||i.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let p=0,I,c=m=>{I={config:structuredClone(m),until:Date.now()+3e4}},t=[],e=null,a,l=new Set;function E(){if(!f())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function P(){a||!t.length||(a=setTimeout(()=>{a=void 0,N().catch(()=>{}).finally(P)},5e3),typeof a=="object"&&"unref"in a&&a.unref())}function x(m,v={}){if(E(),I&&Date.now()<I.until&&!L(I.config,m))return;k();let h=n.trackEvents.request.parse({events:[{eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),name:m,properties:v}]}).events[0];if(z({events:[h]})>Q)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(t.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");t.push(structuredClone(h)),P()}async function N(m=!1){if(E(),e)return e;let v=p,h=(async()=>{let O={inserted:0,duplicates:0,rejected:0,skipped:0},C=t.length;for(;C&&v===p;){let A=[];for(let F of t.slice(0,Math.min(C,100))){if(A.length&&z({events:[...A,F]})>Q)break;A.push(F)}let g=n.trackEvents,w=g.response.parse(await o(g.path,g.request.parse({events:A}),g.method,{keepalive:m}));if(v!==p)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==A.length)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement");c(w.analyticsConfig),t.splice(0,A.length),C-=A.length,O.inserted+=w.inserted,O.duplicates+=w.duplicates,O.rejected+=w.rejected,O.skipped+=w.skipped}return O})();e=h;try{return await h}finally{e===h&&(e=null)}}async function J(m={}){i||E();let v=p,h=!1,O=async()=>{if(h||v!==p)throw new s("IDENTITY_CHANGED","Feature identity changed");let y=n.getFeatures,d=i?{scope:{projectId:i.scope.projectId,environment:i.scope.environment},payload:await i.features()}:y.response.parse(await o(y.path,y.request.parse({}),y.method));if(v!==p)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(d.scope.projectId!==r.projectId||d.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return c(d.payload.analyticsConfig),d},C=await O(),A=!0,g,w=y=>{try{m.onError?.(y)}catch{}},F=(y,d)=>{try{x(y,d)}catch(S){w(S)}},R=_({assertUsable:i?.assertFeatures,scope:C.scope,attributes:m.attributes,onError:m.onError,load:async()=>A?(A=!1,C.payload):(await O()).payload,evaluateRemote:async y=>{if(v!==p)throw new s("IDENTITY_CHANGED","Feature identity changed");let d=n.evaluateFeatures,S=d.response.parse(await o(d.path,d.request.parse(y),d.method));if(S.scope.projectId!==C.scope.projectId||S.scope.environment!==C.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:S.generation,evaluatedAt:S.evaluatedAt,expiresAt:S.expiresAt,features:S.features}},onExperimentViewed:(y,d)=>F("Experiment Viewed",{experimentId:y.key,variationId:d.key}),onFeatureUsage:(y,d)=>F("Feature Evaluated",{feature:y,value:d.value,source:d.source,ruleId:d.ruleId,...d.experimentResult?{variationId:d.experimentResult.key}:{}})}),M=R.refresh;function D(){clearTimeout(g),!i&&(h||v!==p||!R.expiresAt||(g=setTimeout(()=>{b().catch(w)},Math.min(2147483647,Math.max(1e3,Date.parse(R.expiresAt)-Date.now()))),typeof g=="object"&&"unref"in g&&g.unref()))}async function b(){try{return await M()}finally{D()}}let U=()=>{h||b().catch(w)},Y=R.subscribe(D),K=i?.subscribe(()=>{!h&&i.fresh&&b().catch(w)});function q(){h||(h=!0,clearTimeout(g),typeof window<"u"&&window.removeEventListener("focus",U),Y(),K?.(),R.reset(),l.delete(q))}l.add(q);try{await R.init()}catch(y){throw q(),y}return D(),!i&&typeof window<"u"&&window.addEventListener("focus",U),Object.assign(R,{refresh:b,destroy:q})}let T;function k(){if(T||typeof document>"u")return;let m=()=>{document.visibilityState==="hidden"&&f()&&t.length&&N(!0).catch(()=>{})};document.addEventListener("visibilitychange",m),T=()=>document.removeEventListener("visibilitychange",m)}return{features:J,track(m,v){return k(),x(m,v)},flush:N,reset(){p++,I=void 0,clearTimeout(a),a=void 0,t=[],e=null;for(let m of l)m();T?.(),T=void 0}}}function G(o,f){let r="source"in f?{funnelId:f.source.id,funnelVersionId:f.source.versionId}:"versionId"in f?{funnelId:f.funnelId,funnelVersionId:f.versionId}:f,i=n.grantOffer.request.pick({funnelId:!0,funnelVersionId:!0}).required({funnelId:!0}).safeParse(r);if(!i.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let p=Object.freeze(i.data);function I(c){if("customerId"in c)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in c&&c.funnelId!==void 0&&c.funnelId!==p.funnelId||"funnelVersionId"in c&&c.funnelVersionId!==void 0&&c.funnelVersionId!==p.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...c,...p}}return{async claimCoupon(c,t=crypto.randomUUID()){let e=n.grantOffer,a=e.response.parse(await o(e.path,e.request.parse(I({couponId:c,requestId:t}))));return{offer:a.offer,reason:a.reason}},async resolveOffering(c){let t=n.resolveOffering;return t.response.parse(await o(t.path,t.request.parse(I(c))))},async resolvePaywall(c){let t=n.resolvePaywall;return t.response.parse(await o(t.path,t.request.parse(I(c))))},async previewAttach(c){let t=n.previewAttach;return t.response.parse(await o(t.path,t.request.parse(I(c))))}}}function se(o){if(!/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(o.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!o.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let f=j({...o,scope:o.scope,apiKey:o.customerToken});return{async start(r){let i=await f.start(r),p=V({...o,runToken:i.runToken});p.identify(o.customerToken);let I=i.run.instruction?.type==="evaluate"?await p.get():i;return{...i,...I,controller:p}}}}function u(o){if(o!==null&&typeof o=="object"&&"customerId"in o)throw new s("INVALID_REQUEST","Customer requests use the verified session identity")}function ge(o){let f=B(o),r=f.request,i=!1,p=H(r,()=>i,o.scope,o.configuration),I=new Set,c=t=>{for(let e of I)try{e(t)}catch{}};return{forFunnel(t){return G(r,t)},async features(t={}){return p.features(t)},track(t,e){return p.track(t,e)},flush(){return p.flush()},async setupPayment(t){u(t);let e=n.setupPayment;return e.response.parse(await r(e.path,e.request.parse(t)))},async readPaymentSetup(t){u(t);let e=n.readPaymentSetup;return e.response.parse(await r(e.path,e.request.parse(t)))},async previewUpdate(t){u(t);let e=n.previewUpdate;return e.response.parse(await r(e.path,e.request.parse(t)))},async update(t){u(t);let e=n.update;return e.response.parse(await r(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){u(t);let e=n.readSubscriptionUpdate;return e.response.parse(await r(e.path,e.request.parse(t)))},async restoreNativePurchase(t){u(t);let e=n.restoreNativePurchase;return e.response.parse(await r(e.path,e.request.parse(t)))},async previewAttach(t){u(t);let e=n.previewAttach;return e.response.parse(await r(e.path,e.request.parse(t)))},async attach(t){u(t);let e=n.attach;return e.response.parse(await r(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){u(t);let e=n.readSubscriptionOperation;return e.response.parse(await r(e.path,e.request.parse(t)))},async checkEntitlement(t){u(t);let e=n.checkEntitlement;return e.response.parse(await r(e.path,e.request.parse(t)))},async resolvePaywall(t){u(t);let e=n.resolvePaywall;return e.response.parse(await r(e.path,e.request.parse(t)))},async resolveOffering(t){u(t);let e=n.resolveOffering;return e.response.parse(await r(e.path,e.request.parse(t)))},async readHoldings(t={}){let e=n.readHoldings;return e.response.parse(await r(e.path,e.request.omit({customerId:!0}).parse(t)))},async readLedger(t){let e=n.readLedger;return e.response.parse(await r(e.path,e.request.parse({query:t})))},async readBillingInvoice(t){u(t);let e=n.readBillingInvoice;return e.response.parse(await r(e.path,e.request.parse(t)))},async readCreditStatement(t){u(t);let e=n.readCreditStatement;return e.response.parse(await r(e.path,e.request.parse(t)))},async quoteBalance(t){u(t);let e=n.quoteBalance;return e.response.parse(await r(e.path,e.request.parse({command:t})))},async readBillingControls(t={}){u(t);let e=n.readBillingControls;return e.response.parse(await r(e.path,e.request.parse(t)))},async prepareBillingAuthorization(t){u(t);let e=n.prepareBillingAuthorization;return e.response.parse(await r(e.path,e.request.parse(t)))},async confirmBillingAuthorization(t){u(t);let e=n.confirmBillingAuthorization;return e.response.parse(await r(e.path,e.request.parse(t)))},async setBillingCoupons(t){u(t);let e=n.setBillingCoupons,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid billing coupon list");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid billing coupon receipt");return l.data},async revokeBillingAuthorization(t){u(t);let e=n.revokeBillingAuthorization;return e.response.parse(await r(e.path,e.request.parse(t)))},async listBillingInvoices(t={after:null,limit:25}){u(t);let e=n.listBillingInvoices;return e.response.parse(await r(e.path,e.request.parse(t)))},async confirmBillingAdjustment(t){u(t);let e=n.confirmBillingAdjustment;return e.response.parse(await r(e.path,e.request.parse(t)))},subscribeIdentity(t){return I.add(t),()=>{I.delete(t)}},identify(t){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(t))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");p.reset(),f.identify(t),i=!0,c(!0)},reset(){i=!1,p.reset(),f.reset(),c(!1)},async redeemReward(t){u(t);let e=n.redeemReward,a=e.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!a.success)throw new s("INVALID_REQUEST","Invalid reward redemption");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid reward receipt");return l.data.redemption},async claimRewardProduct(t){u(t);let e=n.claimRewardProduct,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid reward product claim");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid reward product checkout");return l.data.checkout},async createReferralCode(t){u(t);let e=n.createReferralCode,a=e.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!a.success)throw new s("INVALID_REQUEST","Invalid referral program");let l=e.response.safeParse(await r(e.path,a.data));if(!l.success)throw new s("INVALID_RESPONSE","Invalid referral code");return l.data.referralCode},async redeemCoupon(t,e=crypto.randomUUID()){let a=n.redeemCoupon,l=a.request.safeParse({code:t,requestId:e});if(!l.success)throw new s("INVALID_REQUEST","Invalid coupon code");let E=a.response.safeParse(await r(a.path,l.data));if(!E.success)throw new s("INVALID_RESPONSE","Invalid Coupon receipt");let P=E.data;return{offer:P.offer,reason:P.reason}},async claimCoupon(t,e=crypto.randomUUID()){let a=n.grantOffer,l=a.request.safeParse({couponId:t,requestId:e});if(!l.success)throw new s("INVALID_REQUEST","Invalid Coupon claim");let E=a.response.safeParse(await r(a.path,l.data));if(!E.success)throw new s("INVALID_RESPONSE","Invalid Coupon receipt");return{offer:E.data.offer,reason:E.data.reason}},async listOffers(){let t=n.listOffers.response.safeParse(await r("offers",{},"GET"));if(!t.success)throw new s("INVALID_RESPONSE","Invalid offers response");return t.data.offers}}}async function Ee(...o){return(await import("./paywall-5WU6PX5C.js")).showPaywall(...o)}async function Ae(...o){return(await import("./funnel-runtime-host-KPYLOYYN.js")).showFunnelRun(...o)}export{s as IndianaError,X as createBrowserFunnelCommandStorage,te as createConfigurationSync,_ as createFeatureClient,se as createFunnelClient,V as createFunnelRunController,ge as createIndiana,ne as createLocalFunnelClient,ee as createPaywallSession,re as evaluateFunnelNode,$ as formatCouponDiscount,Z as formatCouponMoney,W as formatCouponTerms,Ae as showFunnelRun,Ee as showPaywall};
|