@builder.io/sdk-react-native 0.0.4 → 0.0.6-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/package.json +4 -1
- package/src/functions/get-block-styles.js +2 -3
- package/src/functions/get-content/ab-testing.js +76 -30
- package/src/functions/get-content/index.js +2 -4
- package/src/functions/sanitize-styles.js +44 -14
- package/src/functions/track.js +10 -7
- package/src/helpers/ab-tests.js +18 -0
- package/src/helpers/cookie.js +33 -35
- package/src/helpers/document-cookie.js +0 -0
- package/src/helpers/sessionId.js +31 -6
- package/src/helpers/storage.js +37 -0
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-native",
|
|
3
3
|
"description": "Builder.io SDK for React Native",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6-0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"release:patch": "npm version patch --no-git-tag-version && npm publish --access public",
|
|
8
8
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@react-native-async-storage/async-storage": "^1.17.10",
|
|
12
|
+
"@react-native-cookies/cookies": "^6.2.1",
|
|
11
13
|
"react-native-render-html": "^6.3.4",
|
|
14
|
+
"react-native-storage": "^1.0.1",
|
|
12
15
|
"react-native-video": "^5.1.1"
|
|
13
16
|
},
|
|
14
17
|
"peerDependencies": {
|
|
@@ -36,9 +36,8 @@ function getBlockStyles(block) {
|
|
|
36
36
|
return {};
|
|
37
37
|
}
|
|
38
38
|
const styles = getStyleForTarget(block.responsiveStyles);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return styles;
|
|
39
|
+
const newStyles = sanitizeBlockStyles(styles);
|
|
40
|
+
return newStyles;
|
|
42
41
|
}
|
|
43
42
|
export {
|
|
44
43
|
getBlockStyles
|
|
@@ -1,38 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
item.testVariationName = variationValue.name;
|
|
9
|
-
} else {
|
|
10
|
-
let n = 0;
|
|
11
|
-
const random = Math.random();
|
|
12
|
-
let set = false;
|
|
13
|
-
for (const id in item.variations) {
|
|
14
|
-
const variation = item.variations[id];
|
|
15
|
-
const testRatio = variation.testRatio;
|
|
16
|
-
n += testRatio;
|
|
17
|
-
if (random < n) {
|
|
18
|
-
const variationName = variation.name || (variation.id === item.id ? "Default variation" : "");
|
|
19
|
-
set = true;
|
|
20
|
-
Object.assign(item, {
|
|
21
|
-
data: variation.data,
|
|
22
|
-
testVariationId: variation.id,
|
|
23
|
-
testVariationName: variationName
|
|
24
|
-
});
|
|
25
|
-
}
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
26
8
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
32
15
|
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import {
|
|
22
|
+
getContentVariationCookie,
|
|
23
|
+
setContentVariationCookie
|
|
24
|
+
} from "../../helpers/ab-tests.js";
|
|
25
|
+
const getRandomTestGroupId = (variations) => {
|
|
26
|
+
let n = 0;
|
|
27
|
+
const random = Math.random();
|
|
28
|
+
for (const id in variations) {
|
|
29
|
+
const testRatio = variations[id].testRatio;
|
|
30
|
+
n += testRatio;
|
|
31
|
+
if (random < n) {
|
|
32
|
+
return id;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
return void 0;
|
|
35
36
|
};
|
|
37
|
+
const getContentVariation = (_0) => __async(void 0, [_0], function* ({
|
|
38
|
+
item,
|
|
39
|
+
orgId
|
|
40
|
+
}) {
|
|
41
|
+
if (!item.id || !item.variations || Object.keys(item.variations).length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const testGroupId = yield getContentVariationCookie({
|
|
45
|
+
canTrack: true,
|
|
46
|
+
contentId: item.id,
|
|
47
|
+
orgId
|
|
48
|
+
});
|
|
49
|
+
console.log("found test group id", testGroupId);
|
|
50
|
+
const variationValue = testGroupId ? item.variations[testGroupId] : void 0;
|
|
51
|
+
if (variationValue) {
|
|
52
|
+
return variationValue;
|
|
53
|
+
} else {
|
|
54
|
+
const randomTestGroupId = getRandomTestGroupId(item.variations);
|
|
55
|
+
if (randomTestGroupId) {
|
|
56
|
+
yield setContentVariationCookie({
|
|
57
|
+
contentId: item.id,
|
|
58
|
+
value: randomTestGroupId,
|
|
59
|
+
canTrack: true,
|
|
60
|
+
orgId
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const randomVariationValue = randomTestGroupId ? item.variations[randomTestGroupId] : void 0;
|
|
64
|
+
return randomVariationValue;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const handleABTesting = (_0) => __async(void 0, [_0], function* ({
|
|
68
|
+
item,
|
|
69
|
+
orgId
|
|
70
|
+
}) {
|
|
71
|
+
const variationValue = yield getContentVariation({ item, orgId });
|
|
72
|
+
const newValues = variationValue ? {
|
|
73
|
+
data: variationValue.data,
|
|
74
|
+
testVariationId: variationValue.id,
|
|
75
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
76
|
+
} : {
|
|
77
|
+
testVariationId: item.id,
|
|
78
|
+
testVariationName: "Default"
|
|
79
|
+
};
|
|
80
|
+
Object.assign(item, newValues);
|
|
81
|
+
});
|
|
36
82
|
export {
|
|
37
83
|
handleABTesting
|
|
38
84
|
};
|
|
@@ -80,10 +80,8 @@ function getAllContent(options) {
|
|
|
80
80
|
const url = generateContentUrl(options);
|
|
81
81
|
const fetch = yield getFetch();
|
|
82
82
|
const content = yield fetch(url.href).then((res) => res.json());
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
handleABTesting(item, options.testGroups);
|
|
86
|
-
}
|
|
83
|
+
for (const item of content.results) {
|
|
84
|
+
yield handleABTesting({ item, orgId: options.apiKey });
|
|
87
85
|
}
|
|
88
86
|
return content;
|
|
89
87
|
});
|
|
@@ -1,31 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
const propertiesThatMustBeNumber = new Set(["lineHeight"]);
|
|
2
21
|
const displayValues = new Set(["flex", "none"]);
|
|
3
22
|
const SHOW_WARNINGS = false;
|
|
23
|
+
const normalizeNumber = (value) => {
|
|
24
|
+
if (Number.isNaN(value)) {
|
|
25
|
+
return void 0;
|
|
26
|
+
} else if (value < 0) {
|
|
27
|
+
return 0;
|
|
28
|
+
} else {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
4
32
|
const sanitizeBlockStyles = (styles) => {
|
|
5
|
-
|
|
33
|
+
return Object.keys(styles).reduce((acc, key) => {
|
|
6
34
|
const propertyValue = styles[key];
|
|
7
35
|
if (key === "display" && !displayValues.has(propertyValue)) {
|
|
8
36
|
if (SHOW_WARNINGS) {
|
|
9
37
|
console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
|
|
10
38
|
}
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (typeof propertyValue === "string" && propertyValue.match(/^-?\d/)) {
|
|
14
|
-
const newValue = parseFloat(propertyValue);
|
|
15
|
-
if (!isNaN(newValue)) {
|
|
16
|
-
styles[key] = newValue;
|
|
17
|
-
}
|
|
18
|
-
if (typeof newValue === "number" && newValue < 0) {
|
|
19
|
-
styles[key] = 0;
|
|
20
|
-
}
|
|
39
|
+
return acc;
|
|
21
40
|
}
|
|
22
|
-
if (propertiesThatMustBeNumber.has(key) && typeof
|
|
41
|
+
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
|
|
23
42
|
if (SHOW_WARNINGS) {
|
|
24
43
|
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
25
44
|
}
|
|
26
|
-
|
|
45
|
+
return acc;
|
|
27
46
|
}
|
|
28
|
-
|
|
47
|
+
if (typeof propertyValue === "string" && propertyValue.match(/^-?(\d*)(\.?)(\d*)*px/)) {
|
|
48
|
+
const newValue = parseFloat(propertyValue);
|
|
49
|
+
const normalizedValue = normalizeNumber(newValue);
|
|
50
|
+
if (normalizedValue) {
|
|
51
|
+
const valueWithUnits = propertyValue.endsWith("%") ? `${normalizedValue}%` : "";
|
|
52
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: valueWithUnits });
|
|
53
|
+
} else {
|
|
54
|
+
return acc;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: propertyValue });
|
|
58
|
+
}, {});
|
|
29
59
|
};
|
|
30
60
|
export {
|
|
31
61
|
sanitizeBlockStyles
|
package/src/functions/track.js
CHANGED
|
@@ -54,18 +54,21 @@ import { getSessionId } from "../helpers/sessionId.js";
|
|
|
54
54
|
import { getVisitorId } from "../helpers/visitorId.js";
|
|
55
55
|
import { isBrowser } from "./is-browser.js";
|
|
56
56
|
import { isEditing } from "./is-editing.js";
|
|
57
|
-
const getTrackingEventData = (
|
|
57
|
+
const getTrackingEventData = (_0) => __async(void 0, [_0], function* ({
|
|
58
|
+
canTrack,
|
|
59
|
+
orgId
|
|
60
|
+
}) {
|
|
58
61
|
if (!canTrack) {
|
|
59
62
|
return { visitorId: void 0, sessionId: void 0 };
|
|
60
63
|
}
|
|
61
|
-
const sessionId = getSessionId({ canTrack });
|
|
64
|
+
const sessionId = yield getSessionId({ canTrack, orgId });
|
|
62
65
|
const visitorId = getVisitorId({ canTrack });
|
|
63
66
|
return {
|
|
64
67
|
sessionId,
|
|
65
68
|
visitorId
|
|
66
69
|
};
|
|
67
|
-
};
|
|
68
|
-
const createEvent = (_a) => {
|
|
70
|
+
});
|
|
71
|
+
const createEvent = (_a) => __async(void 0, null, function* () {
|
|
69
72
|
var _b = _a, {
|
|
70
73
|
type: eventType,
|
|
71
74
|
canTrack,
|
|
@@ -79,12 +82,12 @@ const createEvent = (_a) => {
|
|
|
79
82
|
]);
|
|
80
83
|
return {
|
|
81
84
|
type: eventType,
|
|
82
|
-
data: __spreadProps(__spreadValues(__spreadValues({}, properties), getTrackingEventData({ canTrack })), {
|
|
85
|
+
data: __spreadProps(__spreadValues(__spreadValues({}, properties), yield getTrackingEventData({ canTrack, orgId })), {
|
|
83
86
|
ownerId: orgId,
|
|
84
87
|
contentId
|
|
85
88
|
})
|
|
86
89
|
};
|
|
87
|
-
};
|
|
90
|
+
});
|
|
88
91
|
function track(eventProps) {
|
|
89
92
|
return __async(this, null, function* () {
|
|
90
93
|
if (!eventProps.canTrack) {
|
|
@@ -99,7 +102,7 @@ function track(eventProps) {
|
|
|
99
102
|
return fetch(`https://builder.io/api/v1/track`, {
|
|
100
103
|
method: "POST",
|
|
101
104
|
body: JSON.stringify({
|
|
102
|
-
events: [createEvent(eventProps)]
|
|
105
|
+
events: [yield createEvent(eventProps)]
|
|
103
106
|
}),
|
|
104
107
|
headers: {
|
|
105
108
|
"content-type": "application/json"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getCookie, setCookie } from "./cookie.js";
|
|
2
|
+
const BUILDER_STORE_PREFIX = "builder.tests";
|
|
3
|
+
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
4
|
+
const getContentVariationCookie = ({
|
|
5
|
+
contentId,
|
|
6
|
+
canTrack,
|
|
7
|
+
orgId
|
|
8
|
+
}) => getCookie({ name: getContentTestKey(contentId), canTrack, orgId });
|
|
9
|
+
const setContentVariationCookie = ({
|
|
10
|
+
contentId,
|
|
11
|
+
canTrack,
|
|
12
|
+
value,
|
|
13
|
+
orgId
|
|
14
|
+
}) => setCookie({ name: getContentTestKey(contentId), value, canTrack, orgId });
|
|
15
|
+
export {
|
|
16
|
+
getContentVariationCookie,
|
|
17
|
+
setContentVariationCookie
|
|
18
|
+
};
|
package/src/helpers/cookie.js
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import storage from "./storage";
|
|
22
|
+
const getCookie = (_0) => __async(void 0, [_0], function* ({
|
|
4
23
|
name,
|
|
5
24
|
canTrack
|
|
6
|
-
})
|
|
7
|
-
var _a;
|
|
25
|
+
}) {
|
|
8
26
|
try {
|
|
9
27
|
if (!canTrack) {
|
|
10
28
|
return void 0;
|
|
11
29
|
}
|
|
12
|
-
|
|
30
|
+
const parsedName = name.replace(/_/g, ".");
|
|
31
|
+
const data = yield (yield storage).load(parsedName);
|
|
32
|
+
console.log("data", data);
|
|
33
|
+
return data.value;
|
|
13
34
|
} catch (err) {
|
|
14
35
|
console.debug("[COOKIE] GET error: ", err);
|
|
15
36
|
}
|
|
16
|
-
};
|
|
17
|
-
const
|
|
18
|
-
const SECURE_CONFIG = [
|
|
19
|
-
["secure", ""],
|
|
20
|
-
["SameSite", "None"]
|
|
21
|
-
];
|
|
22
|
-
const createCookieString = ({
|
|
23
|
-
name,
|
|
24
|
-
value,
|
|
25
|
-
expires
|
|
26
|
-
}) => {
|
|
27
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
28
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
29
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
30
|
-
const cookieValue = [
|
|
31
|
-
[name, value],
|
|
32
|
-
...expiresObj,
|
|
33
|
-
["path", "/"],
|
|
34
|
-
["domain", getTopLevelDomain(window.location.hostname)],
|
|
35
|
-
...secureObj
|
|
36
|
-
];
|
|
37
|
-
const cookie = stringifyCookie(cookieValue);
|
|
38
|
-
return cookie;
|
|
39
|
-
};
|
|
40
|
-
const setCookie = ({
|
|
37
|
+
});
|
|
38
|
+
const setCookie = (_0) => __async(void 0, [_0], function* ({
|
|
41
39
|
name,
|
|
42
40
|
value,
|
|
43
41
|
expires,
|
|
44
42
|
canTrack
|
|
45
|
-
})
|
|
43
|
+
}) {
|
|
46
44
|
try {
|
|
47
45
|
if (!canTrack) {
|
|
48
46
|
return void 0;
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
yield (yield storage).save({ key: name, data: { value }, expires });
|
|
49
|
+
console.log("data", yield storage);
|
|
52
50
|
} catch (err) {
|
|
53
51
|
console.warn("[COOKIE] SET error: ", err);
|
|
54
52
|
}
|
|
55
|
-
};
|
|
53
|
+
});
|
|
56
54
|
export {
|
|
57
55
|
getCookie,
|
|
58
56
|
setCookie
|
|
File without changes
|
package/src/helpers/sessionId.js
CHANGED
|
@@ -1,24 +1,49 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
1
21
|
import { getCookie, setCookie } from "./cookie.js";
|
|
2
22
|
import { checkIsDefined } from "./nullable.js";
|
|
3
23
|
import { uuid } from "./uuid.js";
|
|
4
24
|
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
5
|
-
const getSessionId = ({ canTrack })
|
|
25
|
+
const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack, orgId }) {
|
|
6
26
|
if (!canTrack) {
|
|
7
27
|
return void 0;
|
|
8
28
|
}
|
|
9
|
-
const sessionId = getCookie({
|
|
29
|
+
const sessionId = yield getCookie({
|
|
30
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
31
|
+
canTrack,
|
|
32
|
+
orgId
|
|
33
|
+
});
|
|
10
34
|
if (checkIsDefined(sessionId)) {
|
|
11
35
|
return sessionId;
|
|
12
36
|
} else {
|
|
13
37
|
const newSessionId = createSessionId();
|
|
14
|
-
setSessionId({ id: newSessionId, canTrack });
|
|
38
|
+
setSessionId({ id: newSessionId, canTrack, orgId });
|
|
15
39
|
}
|
|
16
|
-
};
|
|
40
|
+
});
|
|
17
41
|
const createSessionId = () => uuid();
|
|
18
42
|
const setSessionId = ({
|
|
19
43
|
id,
|
|
20
|
-
canTrack
|
|
21
|
-
|
|
44
|
+
canTrack,
|
|
45
|
+
orgId
|
|
46
|
+
}) => setCookie({ name: SESSION_LOCAL_STORAGE_KEY, value: id, canTrack, orgId });
|
|
22
47
|
export {
|
|
23
48
|
createSessionId,
|
|
24
49
|
getSessionId,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import Storage from "react-native-storage";
|
|
22
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
23
|
+
const ONE_DAY = 1e3 * 60 * 60 * 24;
|
|
24
|
+
const initStorage = () => __async(void 0, null, function* () {
|
|
25
|
+
const backend = isBrowser() ? window.localStorage : yield import("@react-native-async-storage/async-storage");
|
|
26
|
+
const storage = new Storage({
|
|
27
|
+
size: 1e3,
|
|
28
|
+
storageBackend: backend,
|
|
29
|
+
defaultExpires: ONE_DAY * 30,
|
|
30
|
+
enableCache: true
|
|
31
|
+
});
|
|
32
|
+
return storage;
|
|
33
|
+
});
|
|
34
|
+
var stdin_default = initStorage();
|
|
35
|
+
export {
|
|
36
|
+
stdin_default as default
|
|
37
|
+
};
|