expo 58.0.1 → 58.0.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.
Files changed (33) hide show
  1. package/android/build.gradle +2 -2
  2. package/build/winter/runtime.native.js +0 -2
  3. package/build/winter/runtime.native.js.map +1 -1
  4. package/bundledNativeModules.json +77 -77
  5. package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
  6. package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
  7. package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
  8. package/package.json +17 -18
  9. package/scripts/spm/__tests__/app-target.test.js +105 -1
  10. package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
  11. package/scripts/spm/__tests__/classify.test.js +17 -19
  12. package/scripts/spm/__tests__/diagnostics.test.js +705 -132
  13. package/scripts/spm/__tests__/manifests.test.js +1086 -75
  14. package/scripts/spm/__tests__/metadata.test.js +120 -0
  15. package/scripts/spm/__tests__/plugin.test.js +2549 -346
  16. package/scripts/spm/app-target.js +44 -1
  17. package/scripts/spm/autolink-gate.js +40 -0
  18. package/scripts/spm/classify.js +54 -77
  19. package/scripts/spm/diagnostics.js +540 -147
  20. package/scripts/spm/flavored-frameworks.js +80 -125
  21. package/scripts/spm/manifests.js +523 -205
  22. package/scripts/spm/metadata.js +152 -0
  23. package/scripts/spm/plugin.js +592 -277
  24. package/scripts/spm/podspec.js +56 -19
  25. package/src/async-require/__tests__/loadBundle.test.ios.ts +2 -2
  26. package/src/winter/__tests__/{TextDecoderStream.test.ios.ts → TextDecoderStream.test.native.ts} +23 -2
  27. package/src/winter/runtime.native.ts +0 -2
  28. package/template.tgz +0 -0
  29. package/build/winter/TextDecoder.d.ts +0 -13
  30. package/build/winter/TextDecoder.js +0 -357
  31. package/build/winter/TextDecoder.js.map +0 -1
  32. package/src/winter/TextDecoder.ts +0 -427
  33. package/src/winter/__tests__/TextDecoder.test.native.ts +0 -549
@@ -1,427 +0,0 @@
1
- // UTF-8-only TextDecoder fallback for runtimes that do not provide one.
2
-
3
- const EMPTY_BYTES = new Uint8Array(0);
4
-
5
- interface TextDecoderState {
6
- ignoreBOM: boolean;
7
- fatal: boolean;
8
- bomSeen: boolean;
9
- pending: Uint8Array;
10
- streaming: boolean;
11
- }
12
-
13
- function assertValidUTF8Label(label: unknown): void {
14
- const normalizedLabel = String(label).trim().toLowerCase();
15
- switch (normalizedLabel) {
16
- case 'unicode-1-1-utf-8':
17
- case 'unicode11utf8':
18
- case 'unicode20utf8':
19
- case 'utf-8':
20
- case 'utf8':
21
- case 'x-unicode20utf8':
22
- return;
23
- default:
24
- throw new RangeError(`Unknown encoding: ${label} (normalized: ${normalizedLabel})`);
25
- }
26
- }
27
-
28
- function normalizeBytes(input: ArrayBuffer | ArrayBufferView | undefined): Uint8Array {
29
- if (input === undefined) {
30
- return EMPTY_BYTES;
31
- } else if (input instanceof Uint8Array) {
32
- return input;
33
- } else if (ArrayBuffer.isView(input)) {
34
- return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
35
- } else if (
36
- (input[Symbol.toStringTag] as string) === 'ArrayBuffer' ||
37
- (input[Symbol.toStringTag] as string) === 'SharedArrayBuffer'
38
- ) {
39
- return new Uint8Array(input as ArrayBuffer);
40
- } else {
41
- throw new TypeError('The input must be an ArrayBuffer or ArrayBufferView');
42
- }
43
- }
44
-
45
- function decoderError(state: TextDecoderState): string {
46
- if (state.fatal) {
47
- throw new TypeError('Decoder error');
48
- }
49
- return '\ufffd';
50
- }
51
-
52
- function appendASCII(output: string, bytes: Uint8Array, start: number, end: number): string {
53
- // NOTE(@kitten): For longer strings, direct `apply` + `subarray` conversion w/o byte-for-byte copy or spreads is
54
- // the most efficient by far (3x), leaning on native conversion below the variadic limit
55
- const HERMES_VARIADIC_ARGUMENT_LIMIT = 4096;
56
- while (start < end) {
57
- output += String.fromCharCode.apply(
58
- null,
59
- bytes.subarray(
60
- start,
61
- Math.min(start + HERMES_VARIADIC_ARGUMENT_LIMIT, end)
62
- ) as unknown as number[]
63
- );
64
- start += HERMES_VARIADIC_ARGUMENT_LIMIT;
65
- }
66
- return output;
67
- }
68
-
69
- interface DecodeFallback {
70
- output: string;
71
- index: number;
72
- }
73
-
74
- function fallback(output: string, index: number): DecodeFallback {
75
- return { output, index };
76
- }
77
-
78
- function decodeUTF8Fast(bytes: Uint8Array, start: number): string | DecodeFallback {
79
- let output = '';
80
- let i = start;
81
- const length = bytes.length;
82
- while (i < length) {
83
- const b0 = bytes[i]!;
84
- if (b0 < 0x80) {
85
- // NOTE(@kitten): For ASCII text, it's fastest to process the first 32 chars directly
86
- // After, `appendASCII`'s variadic apply wins out
87
- const directEnd = Math.min(i + 32, length);
88
- do {
89
- output += String.fromCharCode(bytes[i++]!);
90
- } while (i < directEnd && bytes[i]! < 0x80);
91
- if (i === directEnd && i < length && bytes[i]! < 0x80) {
92
- const asciiStart = i;
93
- do {
94
- i++;
95
- } while (i < length && bytes[i]! < 0x80);
96
- output = appendASCII(output, bytes, asciiStart, i);
97
- }
98
- } else if (b0 >= 0xc2 && b0 <= 0xdf) {
99
- if (i + 1 >= length) return fallback(output, i);
100
- const b1 = bytes[i + 1]!;
101
- if ((b1 & 0xc0) !== 0x80) return fallback(output, i);
102
- output += String.fromCharCode(((b0 & 0x1f) << 6) | (b1 & 0x3f));
103
- i += 2;
104
- } else if (b0 >= 0xe0 && b0 <= 0xef) {
105
- if (i + 2 >= length) return fallback(output, i);
106
- const b1 = bytes[i + 1]!;
107
- const b2 = bytes[i + 2]!;
108
- if (
109
- b1 < (b0 === 0xe0 ? 0xa0 : 0x80) ||
110
- b1 > (b0 === 0xed ? 0x9f : 0xbf) ||
111
- (b2 & 0xc0) !== 0x80
112
- ) {
113
- return fallback(output, i);
114
- }
115
- output += String.fromCharCode(((b0 & 0x0f) << 12) | ((b1 & 0x3f) << 6) | (b2 & 0x3f));
116
- i += 3;
117
- } else if (b0 >= 0xf0 && b0 <= 0xf4) {
118
- if (i + 3 >= length) return fallback(output, i);
119
- const b1 = bytes[i + 1]!;
120
- const b2 = bytes[i + 2]!;
121
- const b3 = bytes[i + 3]!;
122
- if (
123
- b1 < (b0 === 0xf0 ? 0x90 : 0x80) ||
124
- b1 > (b0 === 0xf4 ? 0x8f : 0xbf) ||
125
- (b2 & 0xc0) !== 0x80 ||
126
- (b3 & 0xc0) !== 0x80
127
- ) {
128
- return fallback(output, i);
129
- }
130
- const codePoint =
131
- (((b0 & 0x07) << 18) | ((b1 & 0x3f) << 12) | ((b2 & 0x3f) << 6) | (b3 & 0x3f)) - 0x10000;
132
- output += String.fromCharCode((codePoint >> 10) + 0xd800, (codePoint & 0x3ff) + 0xdc00);
133
- i += 4;
134
- } else {
135
- return fallback(output, i);
136
- }
137
- }
138
-
139
- return output;
140
- }
141
-
142
- function decodeUTF8General(
143
- bytes: Uint8Array,
144
- state: TextDecoderState,
145
- stream: boolean,
146
- output = '',
147
- start = 0
148
- ): string {
149
- const { ignoreBOM } = state;
150
- let { pending, bomSeen } = state;
151
- let i = start;
152
- const length = bytes.length;
153
-
154
- if (pending.length > 0) {
155
- const b0 = pending[0]!;
156
- const bytesNeeded = b0 <= 0xdf ? 1 : b0 <= 0xef ? 2 : 3;
157
- let codePoint = b0 & (bytesNeeded === 1 ? 0x1f : bytesNeeded === 2 ? 0x0f : 0x07);
158
- let bytesSeen = 0;
159
-
160
- for (let p = 1; p < pending.length; p++) {
161
- codePoint = (codePoint << 6) | (pending[p]! & 0x3f);
162
- bytesSeen++;
163
- }
164
-
165
- while (bytesSeen < bytesNeeded && i < length) {
166
- const byte = bytes[i]!;
167
- if (
168
- (byte & 0xc0) !== 0x80 ||
169
- (bytesSeen === 0 &&
170
- ((b0 === 0xe0 && byte < 0xa0) ||
171
- (b0 === 0xed && byte > 0x9f) ||
172
- (b0 === 0xf0 && byte < 0x90) ||
173
- (b0 === 0xf4 && byte > 0x8f)))
174
- ) {
175
- pending = EMPTY_BYTES;
176
- output += decoderError(state);
177
- bomSeen = true;
178
- break;
179
- }
180
- codePoint = (codePoint << 6) | (byte & 0x3f);
181
- bytesSeen++;
182
- i++;
183
- }
184
-
185
- if (bytesSeen === bytesNeeded) {
186
- pending = EMPTY_BYTES;
187
- if (bomSeen || ignoreBOM || codePoint !== 0xfeff) {
188
- if (codePoint <= 0xffff) {
189
- output += String.fromCharCode(codePoint);
190
- } else {
191
- codePoint -= 0x10000;
192
- output += String.fromCharCode((codePoint >> 10) + 0xd800, (codePoint & 0x3ff) + 0xdc00);
193
- }
194
- }
195
- bomSeen = true;
196
- } else if (i === length) {
197
- if (stream && i > 0) {
198
- const nextPending = new Uint8Array(pending.length + i);
199
- nextPending.set(pending);
200
- nextPending.set(bytes.subarray(0, i), pending.length);
201
- pending = nextPending;
202
- } else if (!stream) {
203
- pending = EMPTY_BYTES;
204
- output += decoderError(state);
205
- bomSeen = true;
206
- }
207
- }
208
-
209
- if (pending.length > 0) {
210
- state.pending = pending;
211
- state.bomSeen = bomSeen;
212
- return output;
213
- }
214
- }
215
-
216
- while (i < length) {
217
- const b0 = bytes[i]!;
218
- if (b0 < 0x80) {
219
- bomSeen = true;
220
- const directEnd = Math.min(i + 32, length);
221
- do {
222
- output += String.fromCharCode(bytes[i++]!);
223
- } while (i < directEnd && bytes[i]! < 0x80);
224
- if (i === directEnd && i < length && bytes[i]! < 0x80) {
225
- const asciiStart = i;
226
- do {
227
- i++;
228
- } while (i < length && bytes[i]! < 0x80);
229
- output = appendASCII(output, bytes, asciiStart, i);
230
- }
231
- continue;
232
- }
233
-
234
- let codePoint: number;
235
- const remaining = length - i;
236
- if (b0 >= 0xc2 && b0 <= 0xdf) {
237
- if (remaining < 2) {
238
- if (stream) {
239
- pending = bytes.slice(i);
240
- } else {
241
- output += decoderError(state);
242
- }
243
- break;
244
- }
245
- const b1 = bytes[i + 1]!;
246
- if ((b1 & 0xc0) !== 0x80) {
247
- output += decoderError(state);
248
- bomSeen = true;
249
- i++;
250
- continue;
251
- }
252
- codePoint = ((b0 & 0x1f) << 6) | (b1 & 0x3f);
253
- i += 2;
254
- } else if (b0 >= 0xe0 && b0 <= 0xef) {
255
- if (remaining < 2) {
256
- if (stream) {
257
- pending = bytes.slice(i);
258
- } else {
259
- output += decoderError(state);
260
- }
261
- break;
262
- }
263
- const b1 = bytes[i + 1]!;
264
- if ((b1 & 0xc0) !== 0x80 || (b0 === 0xe0 && b1 < 0xa0) || (b0 === 0xed && b1 > 0x9f)) {
265
- output += decoderError(state);
266
- bomSeen = true;
267
- i++;
268
- continue;
269
- } else if (remaining < 3) {
270
- if (stream) {
271
- pending = bytes.slice(i);
272
- } else {
273
- output += decoderError(state);
274
- }
275
- break;
276
- }
277
- const b2 = bytes[i + 2]!;
278
- if ((b2 & 0xc0) !== 0x80) {
279
- output += decoderError(state);
280
- bomSeen = true;
281
- i += 2;
282
- continue;
283
- }
284
- codePoint = ((b0 & 0x0f) << 12) | ((b1 & 0x3f) << 6) | (b2 & 0x3f);
285
- i += 3;
286
- } else if (b0 >= 0xf0 && b0 <= 0xf4) {
287
- if (remaining < 2) {
288
- if (stream) {
289
- pending = bytes.slice(i);
290
- } else {
291
- output += decoderError(state);
292
- }
293
- break;
294
- }
295
- const b1 = bytes[i + 1]!;
296
- if ((b1 & 0xc0) !== 0x80 || (b0 === 0xf0 && b1 < 0x90) || (b0 === 0xf4 && b1 > 0x8f)) {
297
- output += decoderError(state);
298
- bomSeen = true;
299
- i++;
300
- continue;
301
- } else if (remaining < 3) {
302
- if (stream) {
303
- pending = bytes.slice(i);
304
- } else {
305
- output += decoderError(state);
306
- }
307
- break;
308
- }
309
- const b2 = bytes[i + 2]!;
310
- if ((b2 & 0xc0) !== 0x80) {
311
- output += decoderError(state);
312
- bomSeen = true;
313
- i += 2;
314
- continue;
315
- } else if (remaining < 4) {
316
- if (stream) {
317
- pending = bytes.slice(i);
318
- } else {
319
- output += decoderError(state);
320
- }
321
- break;
322
- }
323
- const b3 = bytes[i + 3]!;
324
- if ((b3 & 0xc0) !== 0x80) {
325
- output += decoderError(state);
326
- bomSeen = true;
327
- i += 3;
328
- continue;
329
- }
330
- codePoint = ((b0 & 0x07) << 18) | ((b1 & 0x3f) << 12) | ((b2 & 0x3f) << 6) | (b3 & 0x3f);
331
- i += 4;
332
- } else {
333
- output += decoderError(state);
334
- bomSeen = true;
335
- i++;
336
- continue;
337
- }
338
-
339
- if (bomSeen || ignoreBOM || codePoint !== 0xfeff) {
340
- if (codePoint <= 0xffff) {
341
- output += String.fromCharCode(codePoint);
342
- } else {
343
- codePoint -= 0x10000;
344
- output += String.fromCharCode((codePoint >> 10) + 0xd800, (codePoint & 0x3ff) + 0xdc00);
345
- }
346
- }
347
- bomSeen = true;
348
- }
349
-
350
- state.pending = pending;
351
- state.bomSeen = bomSeen;
352
- return output;
353
- }
354
-
355
- function decodeUTF8(bytes: Uint8Array, state: TextDecoderState, stream: boolean): string {
356
- if (state.pending.length === 0) {
357
- if (!stream && !state.bomSeen) {
358
- const skipBOM =
359
- !state.ignoreBOM && bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf ? 3 : 0;
360
- const result = decodeUTF8Fast(bytes, skipBOM);
361
- if (typeof result === 'string') {
362
- state.bomSeen = bytes.length > 0;
363
- return result;
364
- }
365
- state.bomSeen = skipBOM > 0 || result.index > skipBOM;
366
- return decodeUTF8General(bytes, state, false, result.output, result.index);
367
- }
368
- }
369
-
370
- return decodeUTF8General(bytes, state, stream);
371
- }
372
-
373
- // @docsMissing
374
- export class TextDecoder {
375
- private readonly _state: TextDecoderState;
376
-
377
- constructor(label: string = 'utf-8', options: { fatal?: boolean; ignoreBOM?: boolean } = {}) {
378
- if (options == null || (typeof options !== 'object' && typeof options !== 'function')) {
379
- throw new TypeError(
380
- 'Second argument of TextDecoder must be undefined or an object, e.g. { fatal: true }'
381
- );
382
- }
383
- assertValidUTF8Label(label);
384
- this._state = {
385
- fatal: Boolean(options.fatal),
386
- ignoreBOM: Boolean(options.ignoreBOM),
387
- bomSeen: false,
388
- pending: EMPTY_BYTES,
389
- streaming: false,
390
- };
391
- }
392
-
393
- get encoding(): string {
394
- return 'utf-8';
395
- }
396
-
397
- get fatal(): boolean {
398
- return this._state.fatal;
399
- }
400
-
401
- get ignoreBOM(): boolean {
402
- return this._state.ignoreBOM;
403
- }
404
-
405
- decode(input?: ArrayBuffer | ArrayBufferView, options: { stream?: boolean } = {}): string {
406
- if (options == null || (typeof options !== 'object' && typeof options !== 'function')) {
407
- throw new TypeError('The options argument must be undefined or an object');
408
- }
409
- const bytes = normalizeBytes(input);
410
- const stream = Boolean(options.stream);
411
- const state = this._state;
412
- if (!state.streaming) {
413
- state.bomSeen = false;
414
- state.pending = EMPTY_BYTES;
415
- }
416
-
417
- try {
418
- const output = decodeUTF8(bytes, state, stream);
419
- state.streaming = stream;
420
- return output;
421
- } catch (error) {
422
- state.pending = EMPTY_BYTES;
423
- state.streaming = false;
424
- throw error;
425
- }
426
- }
427
- }