create-expo 3.3.1 → 3.3.2

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.
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ exports.id = 162;
3
+ exports.ids = [162];
4
+ exports.modules = {
5
+
6
+ /***/ 3162:
7
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
+
9
+ // ESM COMPAT FLAG
10
+ __webpack_require__.r(__webpack_exports__);
11
+
12
+ // EXPORTS
13
+ __webpack_require__.d(__webpack_exports__, {
14
+ "AnalyticsEventPhases": () => (/* binding */ AnalyticsEventPhases),
15
+ "AnalyticsEventTypes": () => (/* binding */ AnalyticsEventTypes),
16
+ "_resetGlobals": () => (/* binding */ _resetGlobals),
17
+ "flushAsync": () => (/* binding */ flushAsync),
18
+ "identify": () => (/* binding */ identify),
19
+ "initializeAnalyticsIdentityAsync": () => (/* binding */ initializeAnalyticsIdentityAsync),
20
+ "track": () => (/* binding */ track)
21
+ });
22
+
23
+ // EXTERNAL MODULE: ../@expo/json-file/build/JsonFile.js
24
+ var JsonFile = __webpack_require__(6282);
25
+ var JsonFile_default = /*#__PURE__*/__webpack_require__.n(JsonFile);
26
+ // EXTERNAL MODULE: external "crypto"
27
+ var external_crypto_ = __webpack_require__(6113);
28
+ var external_crypto_default = /*#__PURE__*/__webpack_require__.n(external_crypto_);
29
+ // EXTERNAL MODULE: external "fs"
30
+ var external_fs_ = __webpack_require__(7147);
31
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
32
+ // EXTERNAL MODULE: external "os"
33
+ var external_os_ = __webpack_require__(2037);
34
+ var external_os_default = /*#__PURE__*/__webpack_require__.n(external_os_);
35
+ // EXTERNAL MODULE: external "path"
36
+ var external_path_ = __webpack_require__(1017);
37
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
38
+ ;// CONCATENATED MODULE: ./src/paths.ts
39
+
40
+
41
+ // The ~/.expo directory is used to store authentication sessions,
42
+ // which are shared between EAS CLI and Expo CLI.
43
+ function dotExpoHomeDirectory() {
44
+ const home = external_os_default().homedir();
45
+ if (!home) {
46
+ throw new Error("Can't determine your home directory; make sure your $HOME environment variable is set.");
47
+ }
48
+ let dirPath;
49
+ if (process.env.EXPO_STAGING) {
50
+ dirPath = external_path_default().join(home, '.expo-staging');
51
+ }
52
+ else if (process.env.EXPO_LOCAL) {
53
+ dirPath = external_path_default().join(home, '.expo-local');
54
+ }
55
+ else {
56
+ dirPath = external_path_default().join(home, '.expo');
57
+ }
58
+ return dirPath;
59
+ }
60
+ const getStateJsonPath = () => external_path_default().join(dotExpoHomeDirectory(), 'state.json');
61
+
62
+ ;// CONCATENATED MODULE: ./src/sessionStorage.ts
63
+
64
+
65
+ function getSession() {
66
+ try {
67
+ return JsonFile_default().read(getStateJsonPath())?.auth ?? null;
68
+ }
69
+ catch (error) {
70
+ if (error.code === 'ENOENT') {
71
+ return null;
72
+ }
73
+ throw error;
74
+ }
75
+ }
76
+
77
+ // EXTERNAL MODULE: ./src/utils/env.ts
78
+ var env = __webpack_require__(7943);
79
+ ;// CONCATENATED MODULE: ./src/telemetry.ts
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ const packageJSON = __webpack_require__(4147);
88
+ const xdlUnifiedWriteKey = '1wabJGd5IiuF9Q8SGlcI90v8WTs';
89
+ const analyticsEndpoint = 'https://cdp.expo.dev/v1/batch';
90
+ const version = '1.0.0';
91
+ const library = packageJSON.name;
92
+ const messageBatch = [];
93
+ let analyticsIdentity = null;
94
+ // jest does not clear global variables inbetween tests so we need this helper
95
+ function _resetGlobals() {
96
+ if (env.env.EXPO_NO_TELEMETRY)
97
+ return;
98
+ analyticsIdentity = null;
99
+ messageBatch.splice(0, messageBatch.length);
100
+ }
101
+ // call before tracking any analytics events.
102
+ // if track/identify are called before this method they will be dropped
103
+ async function initializeAnalyticsIdentityAsync() {
104
+ if (env.env.EXPO_NO_TELEMETRY)
105
+ return;
106
+ if (analyticsIdentity) {
107
+ return;
108
+ }
109
+ analyticsIdentity = await getAnalyticsIdentityAsync();
110
+ }
111
+ function identify() {
112
+ if (env.env.EXPO_NO_TELEMETRY)
113
+ return;
114
+ enqueue('identify', {});
115
+ }
116
+ function track(message) {
117
+ if (env.env.EXPO_NO_TELEMETRY)
118
+ return;
119
+ enqueue('track', { ...message, context: getAnalyticsContext() });
120
+ }
121
+ function enqueue(type, message) {
122
+ if (!analyticsIdentity) {
123
+ // do not send messages without identities to our backend
124
+ return;
125
+ }
126
+ message = { ...message, ...analyticsIdentity };
127
+ message.type = type;
128
+ if (message.type === 'identify') {
129
+ message.traits ??= {};
130
+ message.context ??= {};
131
+ message.context.traits = message.traits;
132
+ }
133
+ message.context = {
134
+ library: {
135
+ name: library,
136
+ version,
137
+ },
138
+ ...message.context,
139
+ };
140
+ message._metadata = {
141
+ nodeVersion: process.versions.node,
142
+ ...message._metadata,
143
+ };
144
+ if (!message.originalTimestamp) {
145
+ message.originalTimestamp = new Date();
146
+ }
147
+ if (!message.messageId) {
148
+ // We md5 the messaage to add more randomness. This is primarily meant
149
+ // for use in the browser where the uuid package falls back to Math.random()
150
+ // which is not a great source of randomness.
151
+ // Borrowed from analytics.js (https://github.com/segment-integrations/analytics.js-integration-segmentio/blob/a20d2a2d222aeb3ab2a8c7e72280f1df2618440e/lib/index.js#L255-L256).
152
+ message.messageId = `node-${external_crypto_default().createHash('md5')
153
+ .update(JSON.stringify(message))
154
+ .digest('hex')}-${uuidv4()}`;
155
+ }
156
+ messageBatch.push(message);
157
+ }
158
+ // very barebones implemention...
159
+ // does not support multiple concurrent flushes or large numbers of messages
160
+ async function flushAsync() {
161
+ if (env.env.EXPO_NO_TELEMETRY)
162
+ return;
163
+ if (!messageBatch.length) {
164
+ return;
165
+ }
166
+ const request = {
167
+ method: 'POST',
168
+ headers: {
169
+ accept: 'application/json, text/plain, */*',
170
+ 'content-type': 'application/json;charset=utf-8',
171
+ 'user-agent': `${library}/${version}`,
172
+ authorization: 'Basic ' + Buffer.from(`${xdlUnifiedWriteKey}:`).toString('base64'),
173
+ },
174
+ body: JSON.stringify({
175
+ batch: messageBatch.map((message) => ({ ...message, sentAt: new Date() })),
176
+ sentAt: new Date(),
177
+ }),
178
+ };
179
+ try {
180
+ // Note(cedric): try to use the global fetch instance, but silently fail if its disabled in Node 18
181
+ await fetch(analyticsEndpoint, request);
182
+ }
183
+ catch {
184
+ // supress errors - likely due to network connectivity or endpoint health
185
+ }
186
+ // clear array so we don't resend events in subsequent flushes
187
+ messageBatch.splice(0, messageBatch.length);
188
+ }
189
+ //#endregion
190
+ //#region copied from eas cli https://github.com/expo/eas-cli/blob/f0c958e58bc7aa90ee8f822e075d40703563708e/packages/eas-cli/src/analytics/rudderstackClient.ts#L9-L13
191
+ const PLATFORM_TO_ANALYTICS_PLATFORM = {
192
+ darwin: 'Mac',
193
+ win32: 'Windows',
194
+ linux: 'Linux',
195
+ };
196
+ function getAnalyticsContext() {
197
+ const platform = PLATFORM_TO_ANALYTICS_PLATFORM[external_os_default().platform()] || external_os_default().platform();
198
+ return {
199
+ os: { name: platform, version: external_os_default().release() },
200
+ device: { type: platform, model: platform },
201
+ app: { name: library, version: packageJSON.version },
202
+ };
203
+ }
204
+ //#endregion
205
+ function uuidv4() {
206
+ try {
207
+ // available on node 14+
208
+ // https://github.com/denoland/deno/issues/12754
209
+ return external_crypto_default().randomUUID();
210
+ }
211
+ catch {
212
+ // supress errors due to node 13 or less not having randomUUID
213
+ return null;
214
+ }
215
+ }
216
+ var AnalyticsEventTypes;
217
+ (function (AnalyticsEventTypes) {
218
+ AnalyticsEventTypes["CREATE_EXPO_APP"] = "create expo app";
219
+ })(AnalyticsEventTypes || (AnalyticsEventTypes = {}));
220
+ var AnalyticsEventPhases;
221
+ (function (AnalyticsEventPhases) {
222
+ AnalyticsEventPhases["ATTEMPT"] = "attempt";
223
+ AnalyticsEventPhases["SUCCESS"] = "success";
224
+ AnalyticsEventPhases["FAIL"] = "fail";
225
+ })(AnalyticsEventPhases || (AnalyticsEventPhases = {}));
226
+ async function getAnalyticsIdentityAsync() {
227
+ if (!external_fs_default().existsSync(dotExpoHomeDirectory())) {
228
+ external_fs_default().mkdirSync(dotExpoHomeDirectory(), { recursive: true });
229
+ }
230
+ if (!external_fs_default().existsSync(getStateJsonPath())) {
231
+ external_fs_default().writeFileSync(getStateJsonPath(), JSON.stringify({}));
232
+ }
233
+ const savedDeviceId = await JsonFile_default().getAsync(getStateJsonPath(), 'analyticsDeviceId', null);
234
+ const deviceId = savedDeviceId ?? uuidv4();
235
+ if (!deviceId) {
236
+ // unable to generate an id or load one from disk
237
+ return null;
238
+ }
239
+ if (!savedDeviceId) {
240
+ await JsonFile_default().setAsync(getStateJsonPath(), 'analyticsDeviceId', deviceId);
241
+ }
242
+ const userId = getSession()?.userId ?? null;
243
+ return userId ? { anonymousId: deviceId, userId } : { anonymousId: deviceId };
244
+ }
245
+
246
+
247
+ /***/ })
248
+
249
+ };
250
+ ;