@superwall/runtime 1.2.0 → 1.3.0-beta.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/README.md +65 -49
- package/dist/bridge/base64.d.ts +0 -6
- package/dist/bridge/base64.js +5 -25
- package/dist/bridge/index.d.ts +2 -30
- package/dist/bridge/index.js +2 -49
- package/dist/bridge/transport.d.ts +2 -9
- package/dist/bridge/transport.js +9 -30
- package/dist/config/background.d.ts +16 -0
- package/dist/config/background.js +13 -0
- package/dist/config/checkout.d.ts +26 -0
- package/dist/config/checkout.js +2 -0
- package/dist/config/index.d.ts +66 -0
- package/dist/config/index.js +4 -0
- package/dist/config/localization.d.ts +13 -0
- package/dist/config/localization.js +1 -0
- package/dist/config/notifications.d.ts +40 -0
- package/dist/config/notifications.js +1 -0
- package/dist/config/platforms.d.ts +3 -0
- package/dist/config/platforms.js +5 -0
- package/dist/config/presentation.d.ts +22 -0
- package/dist/config/presentation.js +1 -0
- package/dist/config/products.d.ts +23 -0
- package/dist/config/products.js +10 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.js +1 -6
- package/dist/localization/catalog.d.ts +8 -0
- package/dist/localization/catalog.js +21 -0
- package/dist/localization/index.d.ts +3 -24
- package/dist/localization/index.js +3 -71
- package/dist/localization/locale.d.ts +2 -0
- package/dist/localization/locale.js +22 -0
- package/dist/localization/periods.d.ts +1 -0
- package/dist/localization/periods.js +13 -5
- package/dist/products/derive.d.ts +4 -0
- package/dist/products/derive.js +45 -0
- package/dist/{products.d.ts → products/index.d.ts} +6 -14
- package/dist/products/index.js +15 -0
- package/dist/products/merge.d.ts +5 -0
- package/dist/products/merge.js +51 -0
- package/dist/session/incoming.d.ts +3 -0
- package/dist/session/incoming.js +47 -0
- package/dist/session/index.d.ts +7 -102
- package/dist/session/index.js +232 -695
- package/dist/session/outgoing.d.ts +42 -0
- package/dist/session/outgoing.js +70 -0
- package/dist/session/purchases.d.ts +18 -0
- package/dist/session/purchases.js +44 -0
- package/dist/session/reminders.d.ts +11 -0
- package/dist/session/reminders.js +41 -0
- package/dist/session/requests.d.ts +19 -0
- package/dist/session/requests.js +56 -0
- package/dist/session/state.d.ts +3 -3
- package/dist/session/state.js +14 -39
- package/dist/session/types.d.ts +49 -29
- package/dist/session/variables.d.ts +3 -7
- package/package.json +3 -2
- package/src/bridge/base64.ts +10 -46
- package/src/bridge/index.ts +7 -77
- package/src/bridge/transport.ts +11 -46
- package/src/config/background.ts +24 -0
- package/src/config/checkout.ts +32 -0
- package/src/config/index.ts +102 -0
- package/src/config/localization.ts +12 -0
- package/src/config/notifications.ts +49 -0
- package/src/config/platforms.ts +8 -0
- package/src/config/presentation.ts +22 -0
- package/src/config/products.ts +39 -0
- package/src/index.ts +2 -43
- package/src/localization/catalog.ts +45 -0
- package/src/localization/index.ts +7 -110
- package/src/localization/locale.ts +25 -0
- package/src/localization/periods.ts +23 -8
- package/src/products/derive.ts +65 -0
- package/src/products/index.ts +87 -0
- package/src/products/merge.ts +78 -0
- package/src/session/incoming.ts +53 -0
- package/src/session/index.ts +275 -986
- package/src/session/outgoing.ts +132 -0
- package/src/session/purchases.ts +66 -0
- package/src/session/reminders.ts +56 -0
- package/src/session/requests.ts +87 -0
- package/src/session/state.ts +19 -59
- package/src/session/types.ts +68 -30
- package/src/session/variables.ts +3 -7
- package/dist/config.d.ts +0 -237
- package/dist/config.js +0 -138
- package/dist/mock.d.ts +0 -74
- package/dist/mock.js +0 -206
- package/dist/products.js +0 -105
- package/src/config.ts +0 -408
- package/src/mock.ts +0 -333
- package/src/products.ts +0 -221
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SuperwallLocalizationConfig } from "../config/localization";
|
|
2
|
+
|
|
3
|
+
const localeCandidates = (locale: string): string[] => {
|
|
4
|
+
const [language, region] = locale.replace(/_/g, "-").split("-");
|
|
5
|
+
const candidates: string[] = [];
|
|
6
|
+
if (language && region) candidates.push(`${language.toLowerCase()}-${region.toUpperCase()}`);
|
|
7
|
+
if (language) candidates.push(language.toLowerCase());
|
|
8
|
+
return candidates;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const resolveLocale = (
|
|
12
|
+
requested: string | undefined,
|
|
13
|
+
localization: SuperwallLocalizationConfig | undefined,
|
|
14
|
+
): string => {
|
|
15
|
+
const defaultLocale = localization?.defaultLocale ?? "en";
|
|
16
|
+
const messages = localization?.messages;
|
|
17
|
+
if (!requested || !messages) return defaultLocale;
|
|
18
|
+
|
|
19
|
+
const available = new Map(Object.keys(messages).map((locale) => [locale.toLowerCase(), locale]));
|
|
20
|
+
for (const candidate of localeCandidates(requested)) {
|
|
21
|
+
const match = available.get(candidate.toLowerCase());
|
|
22
|
+
if (match) return match;
|
|
23
|
+
}
|
|
24
|
+
return defaultLocale;
|
|
25
|
+
};
|
|
@@ -676,18 +676,21 @@ const periodTranslations: Record<string, Record<PeriodKey, string>> = {
|
|
|
676
676
|
},
|
|
677
677
|
};
|
|
678
678
|
|
|
679
|
-
const
|
|
679
|
+
const DYNAMIC_UNITS = ["day", "week", "month", "year"] as const;
|
|
680
|
+
|
|
681
|
+
type DynamicUnit = (typeof DYNAMIC_UNITS)[number];
|
|
682
|
+
|
|
683
|
+
const formatDynamicPeriod = (count: number, unit: DynamicUnit, locale: string): string => {
|
|
680
684
|
try {
|
|
681
685
|
return new Intl.NumberFormat(locale.replace(/_/g, "-"), {
|
|
682
686
|
style: "unit",
|
|
683
|
-
unit
|
|
687
|
+
unit,
|
|
684
688
|
unitDisplay: "long",
|
|
685
689
|
})
|
|
686
690
|
.format(count)
|
|
687
691
|
.replace(/\u00a0/g, " ");
|
|
688
692
|
} catch {
|
|
689
|
-
|
|
690
|
-
return `${count} ${count === 1 ? singularUnit : `${singularUnit}s`}`;
|
|
693
|
+
return `${count} ${count === 1 ? unit : `${unit}s`}`;
|
|
691
694
|
}
|
|
692
695
|
};
|
|
693
696
|
|
|
@@ -716,12 +719,16 @@ const getDynamicPeriodlyFormatter = (locale: string): DynamicPeriodlyFormatter |
|
|
|
716
719
|
);
|
|
717
720
|
};
|
|
718
721
|
|
|
719
|
-
const formatDynamicLocalizedValue = (
|
|
722
|
+
const formatDynamicLocalizedValue = (
|
|
723
|
+
count: number,
|
|
724
|
+
unit: DynamicUnit,
|
|
725
|
+
languages: string[],
|
|
726
|
+
): string => {
|
|
720
727
|
const preferredLocale = languages.find((language) => language.trim());
|
|
721
728
|
return formatDynamicPeriod(count, unit, preferredLocale || "en");
|
|
722
729
|
};
|
|
723
730
|
|
|
724
|
-
const formatDynamicPeriodly = (count: number, unit:
|
|
731
|
+
const formatDynamicPeriodly = (count: number, unit: DynamicUnit, languages: string[]): string => {
|
|
725
732
|
for (const language of languages) {
|
|
726
733
|
const formatter = getDynamicPeriodlyFormatter(language);
|
|
727
734
|
if (!formatter) {
|
|
@@ -746,9 +753,10 @@ const getDynamicLocalizedPeriod = (value: string, languages: string[]): string |
|
|
|
746
753
|
|
|
747
754
|
const count = Number.parseInt(match[1]!, 10);
|
|
748
755
|
const rawUnit = match[2]!;
|
|
749
|
-
const
|
|
756
|
+
const singular = rawUnit.endsWith("s") ? rawUnit.slice(0, -1) : rawUnit;
|
|
757
|
+
const unit = DYNAMIC_UNITS.find((candidate) => candidate === singular);
|
|
750
758
|
|
|
751
|
-
if (!
|
|
759
|
+
if (!unit) {
|
|
752
760
|
return null;
|
|
753
761
|
}
|
|
754
762
|
|
|
@@ -759,6 +767,13 @@ const getDynamicLocalizedPeriod = (value: string, languages: string[]): string |
|
|
|
759
767
|
return formatDynamicLocalizedValue(count, unit, languages);
|
|
760
768
|
};
|
|
761
769
|
|
|
770
|
+
export const languageCandidates = (locale: string | undefined): string[] => {
|
|
771
|
+
if (!locale) return ["en"];
|
|
772
|
+
const normalized = locale.replace(/-/g, "_");
|
|
773
|
+
const [language] = normalized.split("_");
|
|
774
|
+
return language && language !== normalized ? [normalized, language.toLowerCase()] : [normalized];
|
|
775
|
+
};
|
|
776
|
+
|
|
762
777
|
export function getLocalizedPeriod(value: string, languages: string[]): string {
|
|
763
778
|
for (const lang of languages) {
|
|
764
779
|
const translations = periodTranslations[lang];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getLocalizedPeriod } from "../localization/periods";
|
|
2
|
+
import type { SuperwallProduct } from "./index";
|
|
3
|
+
|
|
4
|
+
export const trialPeriodEndDate = (
|
|
5
|
+
trialPeriodDays: unknown,
|
|
6
|
+
language: string | undefined,
|
|
7
|
+
): string | undefined => {
|
|
8
|
+
const days = typeof trialPeriodDays === "number" ? trialPeriodDays : Number(trialPeriodDays);
|
|
9
|
+
if (!Number.isFinite(days) || days <= 0) return undefined;
|
|
10
|
+
|
|
11
|
+
const endDate = new Date();
|
|
12
|
+
endDate.setDate(endDate.getDate() + Math.trunc(days));
|
|
13
|
+
|
|
14
|
+
let month: string;
|
|
15
|
+
try {
|
|
16
|
+
month = endDate.toLocaleString(language?.replace(/_/g, "-") ?? "default", { month: "short" });
|
|
17
|
+
} catch {
|
|
18
|
+
month = endDate.toLocaleString("default", { month: "short" });
|
|
19
|
+
}
|
|
20
|
+
return `${month} ${endDate.getDate()}, ${endDate.getFullYear()}`;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const localizeProduct = (
|
|
24
|
+
product: SuperwallProduct,
|
|
25
|
+
languages: readonly string[],
|
|
26
|
+
): SuperwallProduct => {
|
|
27
|
+
const { period, periodly, trialPeriodDays, trialPeriodEndDate: endDate } = product.variables;
|
|
28
|
+
const derivedEndDate =
|
|
29
|
+
endDate === undefined ? trialPeriodEndDate(trialPeriodDays, languages[0]) : undefined;
|
|
30
|
+
|
|
31
|
+
if (typeof period !== "string" && typeof periodly !== "string" && derivedEndDate === undefined) {
|
|
32
|
+
return product;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
...product,
|
|
37
|
+
variables: {
|
|
38
|
+
...product.variables,
|
|
39
|
+
...(typeof period === "string" ? { period: getLocalizedPeriod(period, [...languages]) } : {}),
|
|
40
|
+
...(typeof periodly === "string"
|
|
41
|
+
? { periodly: getLocalizedPeriod(periodly, [...languages]) }
|
|
42
|
+
: {}),
|
|
43
|
+
...(derivedEndDate === undefined ? {} : { trialPeriodEndDate: derivedEndDate }),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ProductDeriver = (
|
|
49
|
+
raw: readonly SuperwallProduct[],
|
|
50
|
+
languages: readonly string[],
|
|
51
|
+
) => readonly SuperwallProduct[];
|
|
52
|
+
|
|
53
|
+
export const createProductDeriver = (): ProductDeriver => {
|
|
54
|
+
let last:
|
|
55
|
+
| { raw: readonly SuperwallProduct[]; key: string; products: readonly SuperwallProduct[] }
|
|
56
|
+
| undefined;
|
|
57
|
+
|
|
58
|
+
return (raw, languages) => {
|
|
59
|
+
const key = languages.join(",");
|
|
60
|
+
if (last && last.raw === raw && last.key === key) return last.products;
|
|
61
|
+
const products = raw.map((product) => localizeProduct(product, languages));
|
|
62
|
+
last = { raw, key, products };
|
|
63
|
+
return products;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type SuperwallKnownProductVariables = {
|
|
2
|
+
identifier?: string;
|
|
3
|
+
price?: string;
|
|
4
|
+
rawPrice?: string | number;
|
|
5
|
+
period?: string;
|
|
6
|
+
periodAlt?: string;
|
|
7
|
+
localizedPeriod?: string;
|
|
8
|
+
periodly?: string;
|
|
9
|
+
periodDays?: string | number;
|
|
10
|
+
periodWeeks?: string | number;
|
|
11
|
+
periodMonths?: string | number;
|
|
12
|
+
periodYears?: string | number;
|
|
13
|
+
dailyPrice?: string;
|
|
14
|
+
weeklyPrice?: string;
|
|
15
|
+
monthlyPrice?: string;
|
|
16
|
+
yearlyPrice?: string;
|
|
17
|
+
trialPeriodPrice?: string;
|
|
18
|
+
rawTrialPeriodPrice?: string | number;
|
|
19
|
+
trialPeriodDailyPrice?: string;
|
|
20
|
+
trialPeriodWeeklyPrice?: string;
|
|
21
|
+
trialPeriodMonthlyPrice?: string;
|
|
22
|
+
trialPeriodYearlyPrice?: string;
|
|
23
|
+
trialPeriodDays?: string | number;
|
|
24
|
+
trialPeriodWeeks?: string | number;
|
|
25
|
+
trialPeriodMonths?: string | number;
|
|
26
|
+
trialPeriodYears?: string | number;
|
|
27
|
+
trialPeriodText?: string;
|
|
28
|
+
trialPeriodEndDate?: string;
|
|
29
|
+
currencyCode?: string;
|
|
30
|
+
currencySymbol?: string;
|
|
31
|
+
locale?: string;
|
|
32
|
+
languageCode?: string;
|
|
33
|
+
isSubscribed?: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type SuperwallProductVariables = SuperwallKnownProductVariables;
|
|
37
|
+
|
|
38
|
+
export type SuperwallProductSource = "sdk" | "inline" | "unknown";
|
|
39
|
+
|
|
40
|
+
export type SuperwallProduct<
|
|
41
|
+
TVariables extends SuperwallProductVariables = SuperwallProductVariables,
|
|
42
|
+
> = {
|
|
43
|
+
reference: string;
|
|
44
|
+
productId?: string;
|
|
45
|
+
variables: TVariables;
|
|
46
|
+
source: SuperwallProductSource;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type SuperwallProductInput =
|
|
50
|
+
| string
|
|
51
|
+
| {
|
|
52
|
+
reference: string;
|
|
53
|
+
productId?: string;
|
|
54
|
+
variables?: SuperwallProductVariables;
|
|
55
|
+
source?: SuperwallProductSource;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const createSuperwallProduct = (input: SuperwallProductInput): SuperwallProduct => {
|
|
59
|
+
if (typeof input === "string") return { reference: input, variables: {}, source: "unknown" };
|
|
60
|
+
return {
|
|
61
|
+
reference: input.reference,
|
|
62
|
+
...(input.productId === undefined ? {} : { productId: input.productId }),
|
|
63
|
+
variables: input.variables ?? {},
|
|
64
|
+
source: input.source ?? "unknown",
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const productReferenceFromInput = (input: SuperwallProductInput): string =>
|
|
69
|
+
typeof input === "string" ? input : input.reference;
|
|
70
|
+
|
|
71
|
+
export const productsByReference = <TProduct extends SuperwallProduct>(
|
|
72
|
+
products: readonly TProduct[],
|
|
73
|
+
): Readonly<Record<string, TProduct>> =>
|
|
74
|
+
Object.fromEntries(products.map((product) => [product.reference, product]));
|
|
75
|
+
|
|
76
|
+
export const findProductByStoreId = <TProduct extends SuperwallProduct>(
|
|
77
|
+
products: readonly TProduct[],
|
|
78
|
+
productId: string | undefined,
|
|
79
|
+
): TProduct | undefined =>
|
|
80
|
+
productId === undefined ? undefined : products.find((product) => product.productId === productId);
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
mergeIncomingProducts,
|
|
84
|
+
mergeProductVariables,
|
|
85
|
+
productVariablesFromTemplateVariables,
|
|
86
|
+
} from "./merge";
|
|
87
|
+
export { createProductDeriver, trialPeriodEndDate } from "./derive";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProductIdentifierAndType,
|
|
3
|
+
TIncomingMessageTemplateVariables,
|
|
4
|
+
} from "@superwall/protocol";
|
|
5
|
+
import {
|
|
6
|
+
createSuperwallProduct,
|
|
7
|
+
type SuperwallProduct,
|
|
8
|
+
type SuperwallProductVariables,
|
|
9
|
+
} from "./index";
|
|
10
|
+
|
|
11
|
+
const LEGACY_REFERENCES = ["primary", "secondary", "tertiary"] as const;
|
|
12
|
+
|
|
13
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
14
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* SDK-delivered variable records are trusted, not validated: the declared
|
|
18
|
+
* shapes are the SDK's side of the protocol contract. Numeric-looking fields
|
|
19
|
+
* arrive as strings ("59.99", "7"), which is why they are typed
|
|
20
|
+
* `string | number` — coerce with `Number()` before doing arithmetic.
|
|
21
|
+
*/
|
|
22
|
+
const asProductVariables = (record: Record<string, unknown>): SuperwallProductVariables =>
|
|
23
|
+
record as SuperwallProductVariables;
|
|
24
|
+
|
|
25
|
+
export const productVariablesFromTemplateVariables = (
|
|
26
|
+
variables: TIncomingMessageTemplateVariables["variables"],
|
|
27
|
+
): Map<string, SuperwallProductVariables> => {
|
|
28
|
+
const result = new Map<string, SuperwallProductVariables>();
|
|
29
|
+
|
|
30
|
+
if (Array.isArray(variables.products)) {
|
|
31
|
+
for (const entry of variables.products) {
|
|
32
|
+
if (!isRecord(entry)) continue;
|
|
33
|
+
for (const [reference, productVariables] of Object.entries(entry)) {
|
|
34
|
+
if (isRecord(productVariables)) result.set(reference, asProductVariables(productVariables));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const reference of LEGACY_REFERENCES) {
|
|
40
|
+
const productVariables = variables[reference];
|
|
41
|
+
if (isRecord(productVariables) && !result.has(reference)) {
|
|
42
|
+
result.set(reference, asProductVariables(productVariables));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const indexed = (products: readonly SuperwallProduct[]): Map<string, SuperwallProduct> =>
|
|
50
|
+
new Map(products.map((product) => [product.reference, product]));
|
|
51
|
+
|
|
52
|
+
export const mergeIncomingProducts = (
|
|
53
|
+
current: readonly SuperwallProduct[],
|
|
54
|
+
incoming: readonly ProductIdentifierAndType[],
|
|
55
|
+
): SuperwallProduct[] => {
|
|
56
|
+
const next = indexed(current);
|
|
57
|
+
for (const { product: reference, productId } of incoming) {
|
|
58
|
+
next.set(reference, {
|
|
59
|
+
reference,
|
|
60
|
+
productId,
|
|
61
|
+
variables: next.get(reference)?.variables ?? {},
|
|
62
|
+
source: "sdk",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return Array.from(next.values());
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const mergeProductVariables = (
|
|
69
|
+
current: readonly SuperwallProduct[],
|
|
70
|
+
variables: ReadonlyMap<string, SuperwallProductVariables>,
|
|
71
|
+
): SuperwallProduct[] => {
|
|
72
|
+
const next = indexed(current);
|
|
73
|
+
for (const [reference, productVariables] of variables) {
|
|
74
|
+
const existing = next.get(reference) ?? createSuperwallProduct({ reference, source: "sdk" });
|
|
75
|
+
next.set(reference, { ...existing, variables: productVariables });
|
|
76
|
+
}
|
|
77
|
+
return Array.from(next.values());
|
|
78
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { TIncomingMessage } from "@superwall/protocol";
|
|
2
|
+
import { permissionStateName } from "./requests";
|
|
3
|
+
import type { SuperwallRuntimeSnapshot } from "./types";
|
|
4
|
+
import { recordFromVariables } from "./variables";
|
|
5
|
+
|
|
6
|
+
export const snapshotPatchFor = (
|
|
7
|
+
snapshot: SuperwallRuntimeSnapshot,
|
|
8
|
+
message: TIncomingMessage,
|
|
9
|
+
): Partial<SuperwallRuntimeSnapshot> | undefined => {
|
|
10
|
+
switch (message.event_name) {
|
|
11
|
+
case "paywall_open":
|
|
12
|
+
return {
|
|
13
|
+
paywall: { id: message.paywall_id, identifier: message.paywall_identifier },
|
|
14
|
+
pendingPurchase: undefined,
|
|
15
|
+
lastTransaction: undefined,
|
|
16
|
+
lastPurchaseFailure: undefined,
|
|
17
|
+
};
|
|
18
|
+
case "template_variables":
|
|
19
|
+
return {
|
|
20
|
+
variables: message.variables,
|
|
21
|
+
device: recordFromVariables(message.variables, "device"),
|
|
22
|
+
user: recordFromVariables(message.variables, "user"),
|
|
23
|
+
params: recordFromVariables(message.variables, "params"),
|
|
24
|
+
};
|
|
25
|
+
case "template_substitutions_prefix":
|
|
26
|
+
return { introductoryOffer: { eligible: message.prefix === "freeTrial" } };
|
|
27
|
+
case "experiment":
|
|
28
|
+
return {
|
|
29
|
+
experiment: {
|
|
30
|
+
experimentId: message.experimentId,
|
|
31
|
+
variantId: message.variantId,
|
|
32
|
+
campaignId: message.campaignId,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
case "restore_start":
|
|
36
|
+
return { restore: { status: "started" } };
|
|
37
|
+
case "restore_complete":
|
|
38
|
+
return { restore: { status: "completed" } };
|
|
39
|
+
case "restore_fail":
|
|
40
|
+
return { restore: { status: "failed" } };
|
|
41
|
+
case "event_tracking_behavior":
|
|
42
|
+
return { eventTrackingBehavior: message.behavior };
|
|
43
|
+
case "permission_result":
|
|
44
|
+
return {
|
|
45
|
+
permissionStatuses: {
|
|
46
|
+
...snapshot.permissionStatuses,
|
|
47
|
+
[permissionStateName(message.permission_type)]: message.status,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
default:
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
};
|