@amabeth/repeating-wheel-picker 1.2.0 → 1.2.1
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 +3 -2
- package/example/node_modules/@expo/cli/static/template/+html.tsx +0 -28
- package/example/node_modules/@expo/cli/static/template/+native-intent.ts +0 -9
- package/example/node_modules/@expo/cli/static/template/[...rsc]+api.ts +0 -16
- package/example/node_modules/ansi-styles/index.d.ts +0 -345
- package/example/node_modules/chalk/index.d.ts +0 -415
- package/example/node_modules/commander/typings/index.d.ts +0 -627
- package/example/node_modules/expo/Expo.podspec +0 -108
- package/example/node_modules/expo/build/Expo.d.ts +0 -8
- package/example/node_modules/expo/build/Expo.fx.d.ts +0 -4
- package/example/node_modules/expo/build/Expo.fx.web.d.ts +0 -3
- package/example/node_modules/expo/build/devtools/DevToolsPluginClient.d.ts +0 -72
- package/example/node_modules/expo/build/devtools/DevToolsPluginClientFactory.d.ts +0 -16
- package/example/node_modules/expo/build/devtools/DevToolsPluginClientImplApp.d.ts +0 -15
- package/example/node_modules/expo/build/devtools/DevToolsPluginClientImplBrowser.d.ts +0 -14
- package/example/node_modules/expo/build/devtools/MessageFramePacker.d.ts +0 -50
- package/example/node_modules/expo/build/devtools/ProtocolVersion.d.ts +0 -7
- package/example/node_modules/expo/build/devtools/WebSocketBackingStore.d.ts +0 -10
- package/example/node_modules/expo/build/devtools/WebSocketWithReconnect.d.ts +0 -81
- package/example/node_modules/expo/build/devtools/devtools.types.d.ts +0 -42
- package/example/node_modules/expo/build/devtools/getConnectionInfo.d.ts +0 -6
- package/example/node_modules/expo/build/devtools/getConnectionInfo.native.d.ts +0 -6
- package/example/node_modules/expo/build/devtools/index.d.ts +0 -12
- package/example/node_modules/expo/build/devtools/logger.d.ts +0 -6
- package/example/node_modules/expo/build/dom/base.d.ts +0 -5
- package/example/node_modules/expo/build/dom/dom-entry.d.ts +0 -3
- package/example/node_modules/expo/build/dom/dom-hooks.d.ts +0 -8
- package/example/node_modules/expo/build/dom/dom.d.ts +0 -5
- package/example/node_modules/expo/build/dom/dom.types.d.ts +0 -34
- package/example/node_modules/expo/build/dom/dom.web.d.ts +0 -3
- package/example/node_modules/expo/build/dom/global-events.d.ts +0 -4
- package/example/node_modules/expo/build/dom/injection.d.ts +0 -9
- package/example/node_modules/expo/build/dom/internal.d.ts +0 -3
- package/example/node_modules/expo/build/dom/internal.web.d.ts +0 -2
- package/example/node_modules/expo/build/dom/marshal.d.ts +0 -4
- package/example/node_modules/expo/build/dom/webview/ExpoDOMWebView.d.ts +0 -6
- package/example/node_modules/expo/build/dom/webview/RNWebView.d.ts +0 -7
- package/example/node_modules/expo/build/dom/webview/useDebugZeroHeight.d.ts +0 -12
- package/example/node_modules/expo/build/dom/webview-wrapper.d.ts +0 -16
- package/example/node_modules/expo/build/environment/DevLoadingView.d.ts +0 -3
- package/example/node_modules/expo/build/environment/DevLoadingView.web.d.ts +0 -3
- package/example/node_modules/expo/build/environment/DevLoadingViewNativeModule.d.ts +0 -9
- package/example/node_modules/expo/build/environment/DevLoadingViewNativeModule.native.d.ts +0 -3
- package/example/node_modules/expo/build/environment/ExpoGo.d.ts +0 -31
- package/example/node_modules/expo/build/environment/ExpoGo.web.d.ts +0 -3
- package/example/node_modules/expo/build/environment/getInitialSafeArea.d.ts +0 -7
- package/example/node_modules/expo/build/environment/getInitialSafeArea.native.d.ts +0 -11
- package/example/node_modules/expo/build/errors/AppEntryNotFound.d.ts +0 -2
- package/example/node_modules/expo/build/errors/ExpoErrorManager.d.ts +0 -8
- package/example/node_modules/expo/build/errors/ExpoErrorManager.native.d.ts +0 -4
- package/example/node_modules/expo/build/hooks/useEvent.d.ts +0 -59
- package/example/node_modules/expo/build/launch/registerRootComponent.d.ts +0 -30
- package/example/node_modules/expo/build/launch/withDevTools.d.ts +0 -3
- package/example/node_modules/expo/build/launch/withDevTools.ios.d.ts +0 -7
- package/example/node_modules/expo/build/launch/withDevTools.web.d.ts +0 -3
- package/example/node_modules/expo/build/timer/polyfillNextTick.d.ts +0 -6
- package/example/node_modules/expo/build/utils/blobUtils.d.ts +0 -9
- package/example/node_modules/expo/build/utils/getBundleUrl.d.ts +0 -2
- package/example/node_modules/expo/build/utils/getBundleUrl.native.d.ts +0 -2
- package/example/node_modules/expo/build/utils/getBundleUrl.web.d.ts +0 -2
- package/example/node_modules/expo/build/winter/FormData.d.ts +0 -49
- package/example/node_modules/expo/build/winter/ImportMetaRegistry.d.ts +0 -9
- package/example/node_modules/expo/build/winter/TextDecoder.d.ts +0 -20
- package/example/node_modules/expo/build/winter/fetch/ExpoFetchModule.d.ts +0 -2
- package/example/node_modules/expo/build/winter/fetch/ExpoFetchModule.web.d.ts +0 -10
- package/example/node_modules/expo/build/winter/fetch/FetchErrors.d.ts +0 -8
- package/example/node_modules/expo/build/winter/fetch/FetchResponse.d.ts +0 -31
- package/example/node_modules/expo/build/winter/fetch/NativeRequest.d.ts +0 -30
- package/example/node_modules/expo/build/winter/fetch/RequestUtils.d.ts +0 -21
- package/example/node_modules/expo/build/winter/fetch/convertFormData.d.ts +0 -19
- package/example/node_modules/expo/build/winter/fetch/fetch.d.ts +0 -4
- package/example/node_modules/expo/build/winter/fetch/fetch.types.d.ts +0 -16
- package/example/node_modules/expo/build/winter/fetch/fetch.web.d.ts +0 -2
- package/example/node_modules/expo/build/winter/fetch/index.d.ts +0 -3
- package/example/node_modules/expo/build/winter/index.d.ts +0 -2
- package/example/node_modules/expo/build/winter/runtime.d.ts +0 -2
- package/example/node_modules/expo/build/winter/runtime.native.d.ts +0 -2
- package/example/node_modules/expo/build/winter/url.d.ts +0 -23
- package/example/node_modules/expo/config-plugins.d.ts +0 -1
- package/example/node_modules/expo/config.d.ts +0 -1
- package/example/node_modules/expo/devtools.d.ts +0 -1
- package/example/node_modules/expo/dom/global.d.ts +0 -1
- package/example/node_modules/expo/dom/index.d.ts +0 -1
- package/example/node_modules/expo/dom/internal.d.ts +0 -1
- package/example/node_modules/expo/fetch.d.ts +0 -1
- package/example/node_modules/expo/fingerprint.d.ts +0 -1
- package/example/node_modules/expo/metro-config.d.ts +0 -1
- package/example/node_modules/expo/react-native.config.js +0 -50
- package/example/node_modules/expo/src/Expo.fx.tsx +0 -53
- package/example/node_modules/expo/src/Expo.fx.web.tsx +0 -21
- package/example/node_modules/expo/src/Expo.ts +0 -30
- package/example/node_modules/expo/src/devtools/DevToolsPluginClient.ts +0 -240
- package/example/node_modules/expo/src/devtools/DevToolsPluginClientFactory.ts +0 -73
- package/example/node_modules/expo/src/devtools/DevToolsPluginClientImplApp.ts +0 -56
- package/example/node_modules/expo/src/devtools/DevToolsPluginClientImplBrowser.ts +0 -38
- package/example/node_modules/expo/src/devtools/MessageFramePacker.ts +0 -235
- package/example/node_modules/expo/src/devtools/ProtocolVersion.ts +0 -6
- package/example/node_modules/expo/src/devtools/WebSocketBackingStore.ts +0 -10
- package/example/node_modules/expo/src/devtools/WebSocketWithReconnect.ts +0 -318
- package/example/node_modules/expo/src/devtools/devtools.types.ts +0 -50
- package/example/node_modules/expo/src/devtools/getConnectionInfo.native.ts +0 -18
- package/example/node_modules/expo/src/devtools/getConnectionInfo.ts +0 -16
- package/example/node_modules/expo/src/devtools/index.ts +0 -53
- package/example/node_modules/expo/src/devtools/logger.ts +0 -29
- package/example/node_modules/expo/src/dom/base.ts +0 -62
- package/example/node_modules/expo/src/dom/dom-entry.tsx +0 -128
- package/example/node_modules/expo/src/dom/dom-hooks.ts +0 -46
- package/example/node_modules/expo/src/dom/dom.ts +0 -8
- package/example/node_modules/expo/src/dom/dom.types.ts +0 -39
- package/example/node_modules/expo/src/dom/dom.web.ts +0 -6
- package/example/node_modules/expo/src/dom/global-events.ts +0 -16
- package/example/node_modules/expo/src/dom/injection.ts +0 -42
- package/example/node_modules/expo/src/dom/internal.ts +0 -5
- package/example/node_modules/expo/src/dom/internal.web.ts +0 -1
- package/example/node_modules/expo/src/dom/marshal.tsx +0 -116
- package/example/node_modules/expo/src/dom/webview/ExpoDOMWebView.ts +0 -10
- package/example/node_modules/expo/src/dom/webview/RNWebView.ts +0 -12
- package/example/node_modules/expo/src/dom/webview/useDebugZeroHeight.ts +0 -62
- package/example/node_modules/expo/src/dom/webview-wrapper.tsx +0 -253
- package/example/node_modules/expo/src/environment/DevLoadingView.tsx +0 -123
- package/example/node_modules/expo/src/environment/DevLoadingView.web.tsx +0 -135
- package/example/node_modules/expo/src/environment/DevLoadingViewNativeModule.native.ts +0 -3
- package/example/node_modules/expo/src/environment/DevLoadingViewNativeModule.ts +0 -7
- package/example/node_modules/expo/src/environment/ExpoGo.ts +0 -53
- package/example/node_modules/expo/src/environment/ExpoGo.web.ts +0 -7
- package/example/node_modules/expo/src/environment/getInitialSafeArea.native.ts +0 -16
- package/example/node_modules/expo/src/environment/getInitialSafeArea.ts +0 -8
- package/example/node_modules/expo/src/errors/AppEntryNotFound.tsx +0 -35
- package/example/node_modules/expo/src/errors/ExpoErrorManager.native.ts +0 -51
- package/example/node_modules/expo/src/errors/ExpoErrorManager.ts +0 -11
- package/example/node_modules/expo/src/hooks/useEvent.ts +0 -112
- package/example/node_modules/expo/src/launch/registerRootComponent.tsx +0 -64
- package/example/node_modules/expo/src/launch/withDevTools.ios.tsx +0 -47
- package/example/node_modules/expo/src/launch/withDevTools.tsx +0 -30
- package/example/node_modules/expo/src/launch/withDevTools.web.tsx +0 -23
- package/example/node_modules/expo/src/timer/polyfillNextTick.ts +0 -10
- package/example/node_modules/expo/src/ts-declarations/console.d.ts +0 -47
- package/example/node_modules/expo/src/ts-declarations/global.d.ts +0 -12
- package/example/node_modules/expo/src/ts-declarations/react-native.d.ts +0 -34
- package/example/node_modules/expo/src/ts-declarations/whatwg-url-without-unicode.d.ts +0 -186
- package/example/node_modules/expo/src/utils/blobUtils.ts +0 -23
- package/example/node_modules/expo/src/utils/getBundleUrl.native.ts +0 -17
- package/example/node_modules/expo/src/utils/getBundleUrl.ts +0 -5
- package/example/node_modules/expo/src/utils/getBundleUrl.web.ts +0 -21
- package/example/node_modules/expo/src/winter/FormData.ts +0 -222
- package/example/node_modules/expo/src/winter/ImportMetaRegistry.ts +0 -14
- package/example/node_modules/expo/src/winter/TextDecoder.ts +0 -429
- package/example/node_modules/expo/src/winter/fetch/ExpoFetchModule.ts +0 -3
- package/example/node_modules/expo/src/winter/fetch/ExpoFetchModule.web.ts +0 -7
- package/example/node_modules/expo/src/winter/fetch/FetchErrors.ts +0 -11
- package/example/node_modules/expo/src/winter/fetch/FetchResponse.ts +0 -146
- package/example/node_modules/expo/src/winter/fetch/NativeRequest.ts +0 -38
- package/example/node_modules/expo/src/winter/fetch/RequestUtils.ts +0 -124
- package/example/node_modules/expo/src/winter/fetch/convertFormData.ts +0 -92
- package/example/node_modules/expo/src/winter/fetch/fetch.ts +0 -59
- package/example/node_modules/expo/src/winter/fetch/fetch.types.ts +0 -17
- package/example/node_modules/expo/src/winter/fetch/fetch.web.ts +0 -1
- package/example/node_modules/expo/src/winter/fetch/index.ts +0 -2
- package/example/node_modules/expo/src/winter/index.ts +0 -1
- package/example/node_modules/expo/src/winter/runtime.native.ts +0 -41
- package/example/node_modules/expo/src/winter/runtime.ts +0 -5
- package/example/node_modules/expo/src/winter/url.ts +0 -116
- package/example/node_modules/expo/types/global.d.ts +0 -38
- package/example/node_modules/expo/types/index.d.ts +0 -3
- package/example/node_modules/expo/types/metro-require.d.ts +0 -52
- package/example/node_modules/expo/types/react-native-web.d.ts +0 -291
- package/example/node_modules/expo-modules-autolinking/build/ExpoModuleConfig.d.ts +0 -85
- package/example/node_modules/expo-modules-autolinking/build/autolinking/findModules.d.ts +0 -5
- package/example/node_modules/expo-modules-autolinking/build/autolinking/generatePackageList.d.ts +0 -11
- package/example/node_modules/expo-modules-autolinking/build/autolinking/getConfiguration.d.ts +0 -2
- package/example/node_modules/expo-modules-autolinking/build/autolinking/index.d.ts +0 -17
- package/example/node_modules/expo-modules-autolinking/build/autolinking/mergeLinkingOptions.d.ts +0 -21
- package/example/node_modules/expo-modules-autolinking/build/autolinking/resolveModules.d.ts +0 -9
- package/example/node_modules/expo-modules-autolinking/build/autolinking/utils.d.ts +0 -6
- package/example/node_modules/expo-modules-autolinking/build/autolinking/verifySearchResults.d.ts +0 -5
- package/example/node_modules/expo-modules-autolinking/build/fileUtils.d.ts +0 -18
- package/example/node_modules/expo-modules-autolinking/build/index.d.ts +0 -1
- package/example/node_modules/expo-modules-autolinking/build/platforms/android.d.ts +0 -38
- package/example/node_modules/expo-modules-autolinking/build/platforms/apple.d.ts +0 -15
- package/example/node_modules/expo-modules-autolinking/build/platforms/devtools.d.ts +0 -3
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/androidResolver.d.ts +0 -20
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/config.d.ts +0 -5
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/index.d.ts +0 -2
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/iosResolver.d.ts +0 -2
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/reactNativeConfig.d.ts +0 -13
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/reactNativeConfig.types.d.ts +0 -95
- package/example/node_modules/expo-modules-autolinking/build/types.d.ts +0 -319
- package/example/node_modules/expo-modules-autolinking/e2e/TestUtils.ts +0 -53
- package/example/node_modules/expo-modules-autolinking/exports.d.ts +0 -1
- package/example/node_modules/expo-modules-autolinking/src/ExpoModuleConfig.ts +0 -181
- package/example/node_modules/expo-modules-autolinking/src/autolinking/findModules.ts +0 -259
- package/example/node_modules/expo-modules-autolinking/src/autolinking/generatePackageList.ts +0 -46
- package/example/node_modules/expo-modules-autolinking/src/autolinking/getConfiguration.ts +0 -7
- package/example/node_modules/expo-modules-autolinking/src/autolinking/index.ts +0 -45
- package/example/node_modules/expo-modules-autolinking/src/autolinking/mergeLinkingOptions.ts +0 -127
- package/example/node_modules/expo-modules-autolinking/src/autolinking/resolveModules.ts +0 -46
- package/example/node_modules/expo-modules-autolinking/src/autolinking/utils.ts +0 -37
- package/example/node_modules/expo-modules-autolinking/src/autolinking/verifySearchResults.ts +0 -33
- package/example/node_modules/expo-modules-autolinking/src/fileUtils.ts +0 -64
- package/example/node_modules/expo-modules-autolinking/src/index.ts +0 -262
- package/example/node_modules/expo-modules-autolinking/src/platforms/android.ts +0 -303
- package/example/node_modules/expo-modules-autolinking/src/platforms/apple.ts +0 -292
- package/example/node_modules/expo-modules-autolinking/src/platforms/devtools.ts +0 -25
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/androidResolver.ts +0 -264
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/config.ts +0 -67
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/index.ts +0 -2
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/iosResolver.ts +0 -37
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/reactNativeConfig.ts +0 -245
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/reactNativeConfig.types.ts +0 -107
- package/example/node_modules/expo-modules-autolinking/src/types.ts +0 -384
- package/example/node_modules/find-up/index.d.ts +0 -138
- package/example/node_modules/glob/dist/commonjs/glob.d.ts +0 -388
- package/example/node_modules/glob/dist/commonjs/has-magic.d.ts +0 -14
- package/example/node_modules/glob/dist/commonjs/ignore.d.ts +0 -24
- package/example/node_modules/glob/dist/commonjs/index.d.ts +0 -97
- package/example/node_modules/glob/dist/commonjs/pattern.d.ts +0 -76
- package/example/node_modules/glob/dist/commonjs/processor.d.ts +0 -59
- package/example/node_modules/glob/dist/commonjs/walker.d.ts +0 -97
- package/example/node_modules/glob/dist/esm/glob.d.ts +0 -388
- package/example/node_modules/glob/dist/esm/has-magic.d.ts +0 -14
- package/example/node_modules/glob/dist/esm/ignore.d.ts +0 -24
- package/example/node_modules/glob/dist/esm/index.d.ts +0 -97
- package/example/node_modules/glob/dist/esm/pattern.d.ts +0 -76
- package/example/node_modules/glob/dist/esm/processor.d.ts +0 -59
- package/example/node_modules/glob/dist/esm/walker.d.ts +0 -97
- package/example/node_modules/locate-path/index.d.ts +0 -83
- package/example/node_modules/log-symbols/node_modules/chalk/types/index.d.ts +0 -97
- package/example/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +0 -2
- package/example/node_modules/minimatch/dist/commonjs/ast.d.ts +0 -20
- package/example/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +0 -8
- package/example/node_modules/minimatch/dist/commonjs/escape.d.ts +0 -12
- package/example/node_modules/minimatch/dist/commonjs/index.d.ts +0 -94
- package/example/node_modules/minimatch/dist/commonjs/unescape.d.ts +0 -17
- package/example/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +0 -2
- package/example/node_modules/minimatch/dist/esm/ast.d.ts +0 -20
- package/example/node_modules/minimatch/dist/esm/brace-expressions.d.ts +0 -8
- package/example/node_modules/minimatch/dist/esm/escape.d.ts +0 -12
- package/example/node_modules/minimatch/dist/esm/index.d.ts +0 -94
- package/example/node_modules/minimatch/dist/esm/unescape.d.ts +0 -17
- package/example/node_modules/ora/index.d.ts +0 -257
- package/example/node_modules/ora/node_modules/chalk/types/index.d.ts +0 -97
- package/example/node_modules/ora/node_modules/strip-ansi/index.d.ts +0 -15
- package/example/node_modules/p-locate/index.d.ts +0 -53
- package/example/node_modules/path-exists/index.d.ts +0 -28
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
// React Native's FormData implementation is missing several methods that are used in React for server actions.
|
|
2
|
-
// https://github.com/facebook/react-native/blob/42dcfdd2cdb59fe545523cb57db6ee32a96b9298/packages/react-native/Libraries/Network/FormData.js#L1
|
|
3
|
-
// https://github.com/facebook/react/blob/985747f81033833dca22f30b0c04704dd4bd3714/packages/react-client/src/ReactFlightReplyClient.js#L212
|
|
4
|
-
|
|
5
|
-
type ReactNativeFormDataInternal = FormData & {
|
|
6
|
-
_parts: [string, string | Blob][];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type ExpoFormDataValue = string | Blob;
|
|
10
|
-
export type ExpoFormDataPart =
|
|
11
|
-
| {
|
|
12
|
-
// WinterCG FormData string
|
|
13
|
-
string: string;
|
|
14
|
-
headers: { [name: string]: string };
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
// WinterCG FormData blob in our wrapped form
|
|
18
|
-
blob: Blob;
|
|
19
|
-
headers: { [name: string]: string };
|
|
20
|
-
name?: string | undefined;
|
|
21
|
-
type?: string | undefined;
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
// React Native proprietary local file
|
|
25
|
-
uri: string;
|
|
26
|
-
headers: { [name: string]: string };
|
|
27
|
-
name?: string | undefined;
|
|
28
|
-
type?: string | undefined;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export declare class ExpoFormData {
|
|
32
|
-
constructor();
|
|
33
|
-
|
|
34
|
-
// React Native proprietary local file
|
|
35
|
-
append(name: string, value: { uri: string; name?: string; type?: string }): void;
|
|
36
|
-
append(name: string, value: string): void;
|
|
37
|
-
append(name: string, value: Blob, filename?: string): void;
|
|
38
|
-
|
|
39
|
-
delete(name: string): void;
|
|
40
|
-
get(name: string): FormDataEntryValue | null;
|
|
41
|
-
getAll(name: string): FormDataEntryValue[];
|
|
42
|
-
has(name: string): boolean;
|
|
43
|
-
|
|
44
|
-
// React Native proprietary local file
|
|
45
|
-
set(name: string, value: { uri: string; name?: string; type?: string }): void;
|
|
46
|
-
set(name: string, value: string): void;
|
|
47
|
-
set(name: string, value: Blob, filename?: string): void;
|
|
48
|
-
|
|
49
|
-
// iterable
|
|
50
|
-
forEach(
|
|
51
|
-
callback: (value: FormDataEntryValue, key: string, iterable: FormData) => void,
|
|
52
|
-
thisArg?: unknown
|
|
53
|
-
): void;
|
|
54
|
-
keys(): IterableIterator<string>;
|
|
55
|
-
values(): IterableIterator<FormDataEntryValue>;
|
|
56
|
-
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
|
57
|
-
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function ensureMinArgCount(name: string, args: any[], expected: number) {
|
|
61
|
-
if (args.length < expected) {
|
|
62
|
-
const argName = expected === 2 ? 'arguments' : 'argument';
|
|
63
|
-
// Matches the errors in Chrome.
|
|
64
|
-
throw new TypeError(
|
|
65
|
-
`Failed to execute '${name}' on 'FormData': ${expected} ${argName} required, but only ${args.length} present.`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function normalizeArgs(
|
|
71
|
-
name: string,
|
|
72
|
-
value: any,
|
|
73
|
-
blobFilename: string | undefined
|
|
74
|
-
): [string, File | string] {
|
|
75
|
-
if (value instanceof Blob) {
|
|
76
|
-
// @ts-expect-error: `Blob.data.blobId` is react-native's proprietary property.
|
|
77
|
-
if (value.data?.blobId != null) {
|
|
78
|
-
// For react-native created Blob objects,
|
|
79
|
-
// we need to keep its original form as-is without breaking functionality.
|
|
80
|
-
// However, we need to pass `name` for our file name handling.
|
|
81
|
-
// @ts-expect-error: Mutating the Blob object to add the `name` property.
|
|
82
|
-
value.name = blobFilename ?? 'blob';
|
|
83
|
-
} else {
|
|
84
|
-
value = { type: value.type, name: blobFilename ?? 'blob', blob: value };
|
|
85
|
-
}
|
|
86
|
-
} else if (typeof value !== 'object') {
|
|
87
|
-
value = String(value);
|
|
88
|
-
}
|
|
89
|
-
return [String(name), value];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function installFormDataPatch(formData: typeof FormData): typeof ExpoFormData {
|
|
93
|
-
formData.prototype.append = function append(this: ReactNativeFormDataInternal, ...props: any[]) {
|
|
94
|
-
ensureMinArgCount('append', props, 2);
|
|
95
|
-
// @ts-ignore: When inferred FormData.append from React Native types, it does not support the 3rd blobFilename argument.
|
|
96
|
-
const [name, value, blobFilename] = props;
|
|
97
|
-
this._parts.push(normalizeArgs(name, value, blobFilename));
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
101
|
-
formData.prototype.set = function set(this: ReactNativeFormDataInternal, ...props: any[]) {
|
|
102
|
-
ensureMinArgCount('set', props, 2);
|
|
103
|
-
const [name, value, blobFilename] = props;
|
|
104
|
-
const args = normalizeArgs(name, value, blobFilename);
|
|
105
|
-
let replaced = false;
|
|
106
|
-
|
|
107
|
-
for (let i = 0; i < this._parts.length; i++) {
|
|
108
|
-
if (this._parts[i][0] === args[0]) {
|
|
109
|
-
if (!replaced) {
|
|
110
|
-
this._parts[i] = args;
|
|
111
|
-
replaced = true;
|
|
112
|
-
} else {
|
|
113
|
-
this._parts.splice(i, 1);
|
|
114
|
-
i--;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!replaced) {
|
|
120
|
-
this._parts.push(args);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
125
|
-
formData.prototype.delete ??= function (this: ReactNativeFormDataInternal, ...props: any[]) {
|
|
126
|
-
ensureMinArgCount('delete', props, 1);
|
|
127
|
-
let [name] = props;
|
|
128
|
-
name = String(name);
|
|
129
|
-
for (let i = 0; i < this._parts.length; i++) {
|
|
130
|
-
if (this._parts[i][0] === name) {
|
|
131
|
-
this._parts.splice(i, 1);
|
|
132
|
-
i--;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
138
|
-
formData.prototype.get ??= function (
|
|
139
|
-
this: ReactNativeFormDataInternal,
|
|
140
|
-
...props: any[]
|
|
141
|
-
): FormDataEntryValue | null {
|
|
142
|
-
ensureMinArgCount('get', props, 1);
|
|
143
|
-
let [name] = props;
|
|
144
|
-
name = String(name);
|
|
145
|
-
for (const part of this._parts) {
|
|
146
|
-
if (part[0] === name) {
|
|
147
|
-
// @ts-expect-error: We don't perform correct normalization when setting the args so the return value will
|
|
148
|
-
// not be a normalized File object.
|
|
149
|
-
return part[1];
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
156
|
-
formData.prototype.has ??= function (this: ReactNativeFormDataInternal, ...props: any[]) {
|
|
157
|
-
ensureMinArgCount('has', props, 1);
|
|
158
|
-
let [name] = props;
|
|
159
|
-
name = String(name);
|
|
160
|
-
for (const part of this._parts) {
|
|
161
|
-
if (part[0] === name) {
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return false;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// Required for RSC: https://github.com/facebook/react/blob/985747f81033833dca22f30b0c04704dd4bd3714/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L1056
|
|
169
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
170
|
-
formData.prototype.forEach ??= function forEach(
|
|
171
|
-
this: ReactNativeFormDataInternal,
|
|
172
|
-
...props: any[]
|
|
173
|
-
) {
|
|
174
|
-
ensureMinArgCount('forEach', props, 1);
|
|
175
|
-
|
|
176
|
-
const [callback, thisArg] = props;
|
|
177
|
-
if (typeof callback !== 'function') {
|
|
178
|
-
throw new TypeError(
|
|
179
|
-
`Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.`
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
for (const part of this._parts) {
|
|
183
|
-
// @ts-ignore: part[1] could throw an error in Node.js runtime because of `File` type mismatch.
|
|
184
|
-
callback.call(thisArg, part[1], part[0], this);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// Required for RSC: https://github.com/facebook/react/blob/985747f81033833dca22f30b0c04704dd4bd3714/packages/react-server/src/ReactFlightServer.js#L2117
|
|
189
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
190
|
-
formData.prototype.entries ??= function* entries(
|
|
191
|
-
this: ReactNativeFormDataInternal
|
|
192
|
-
): IterableIterator<[string, FormDataEntryValue]> {
|
|
193
|
-
for (const part of this._parts) {
|
|
194
|
-
// @ts-expect-error: We don't perform correct normalization when setting the args so the return value will
|
|
195
|
-
// not be a normalized File object.
|
|
196
|
-
yield part;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
201
|
-
formData.prototype.keys ??= function* keys(this: ReactNativeFormDataInternal) {
|
|
202
|
-
for (const part of this._parts) {
|
|
203
|
-
yield part[0];
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
208
|
-
formData.prototype.values ??= function* values(
|
|
209
|
-
this: ReactNativeFormDataInternal
|
|
210
|
-
): IterableIterator<FormDataEntryValue> {
|
|
211
|
-
for (const part of this._parts) {
|
|
212
|
-
// @ts-expect-error: We don't perform correct normalization when setting the args so the return value will
|
|
213
|
-
// not be a normalized File object.
|
|
214
|
-
yield part[1];
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
// @ts-ignore: DOM.iterable is disabled for jest compat
|
|
219
|
-
formData.prototype[Symbol.iterator] = formData.prototype.entries;
|
|
220
|
-
|
|
221
|
-
return formData as unknown as typeof ExpoFormData;
|
|
222
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
import { getBundleUrl } from '../utils/getBundleUrl';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Registry to handle import.meta functionality for React Native environment
|
|
7
|
-
* Similar to how it works in the web, but adapted for the RN context
|
|
8
|
-
* https://github.com/wintercg/import-meta-registry
|
|
9
|
-
*/
|
|
10
|
-
export const ImportMetaRegistry = {
|
|
11
|
-
get url() {
|
|
12
|
-
return getBundleUrl();
|
|
13
|
-
},
|
|
14
|
-
};
|
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
// A fork of text-encoding but with only UTF-8 decoder.
|
|
2
|
-
// `TextEncoder` is in Hermes and we only need utf-8 decoder for React Server Components.
|
|
3
|
-
//
|
|
4
|
-
// https://github.com/inexorabletash/text-encoding/blob/3f330964c0e97e1ed344c2a3e963f4598610a7ad/lib/encoding.js#L1
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Checks if a number is within a specified range.
|
|
8
|
-
* @param a The number to test.
|
|
9
|
-
* @param min The minimum value in the range, inclusive.
|
|
10
|
-
* @param max The maximum value in the range, inclusive.
|
|
11
|
-
* @returns `true` if a passed number is within the specified range.
|
|
12
|
-
*/
|
|
13
|
-
function inRange(a: number, min: number, max: number): boolean {
|
|
14
|
-
return min <= a && a <= max;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Converts an array of code points to a string.
|
|
19
|
-
* @param codePoints Array of code points.
|
|
20
|
-
* @returns The string representation of given array.
|
|
21
|
-
*/
|
|
22
|
-
function codePointsToString(codePoints: number[]): string {
|
|
23
|
-
let s = '';
|
|
24
|
-
for (let i = 0; i < codePoints.length; ++i) {
|
|
25
|
-
let cp = codePoints[i];
|
|
26
|
-
if (cp <= 0xffff) {
|
|
27
|
-
s += String.fromCharCode(cp);
|
|
28
|
-
} else {
|
|
29
|
-
cp -= 0x10000;
|
|
30
|
-
s += String.fromCharCode((cp >> 10) + 0xd800, (cp & 0x3ff) + 0xdc00);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return s;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function normalizeBytes(input?: ArrayBuffer | DataView): Uint8Array {
|
|
37
|
-
if (typeof input === 'object' && input instanceof ArrayBuffer) {
|
|
38
|
-
return new Uint8Array(input);
|
|
39
|
-
} else if (
|
|
40
|
-
typeof input === 'object' &&
|
|
41
|
-
'buffer' in input &&
|
|
42
|
-
input.buffer instanceof ArrayBuffer
|
|
43
|
-
) {
|
|
44
|
-
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
45
|
-
}
|
|
46
|
-
return new Uint8Array(0);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* End-of-stream is a special token that signifies no more tokens
|
|
51
|
-
* are in the stream.
|
|
52
|
-
*/
|
|
53
|
-
const END_OF_STREAM = -1;
|
|
54
|
-
|
|
55
|
-
const FINISHED = -1;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* A stream represents an ordered sequence of tokens.
|
|
59
|
-
*
|
|
60
|
-
* @constructor
|
|
61
|
-
* @param {!(number[]|Uint8Array)} tokens Array of tokens that provide the stream.
|
|
62
|
-
*/
|
|
63
|
-
class Stream {
|
|
64
|
-
private tokens: number[];
|
|
65
|
-
|
|
66
|
-
constructor(tokens: number[] | Uint8Array) {
|
|
67
|
-
this.tokens = Array.prototype.slice.call(tokens);
|
|
68
|
-
// Reversed as push/pop is more efficient than shift/unshift.
|
|
69
|
-
this.tokens.reverse();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @return {boolean} True if end-of-stream has been hit.
|
|
74
|
-
*/
|
|
75
|
-
endOfStream(): boolean {
|
|
76
|
-
return !this.tokens.length;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* When a token is read from a stream, the first token in the
|
|
81
|
-
* stream must be returned and subsequently removed, and
|
|
82
|
-
* end-of-stream must be returned otherwise.
|
|
83
|
-
*
|
|
84
|
-
* @return {number} Get the next token from the stream, or
|
|
85
|
-
* end_of_stream.
|
|
86
|
-
*/
|
|
87
|
-
read(): number {
|
|
88
|
-
if (!this.tokens.length) return END_OF_STREAM;
|
|
89
|
-
return this.tokens.pop()!;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* When one or more tokens are prepended to a stream, those tokens
|
|
94
|
-
* must be inserted, in given order, before the first token in the
|
|
95
|
-
* stream.
|
|
96
|
-
*
|
|
97
|
-
* @param token The token(s) to prepend to the stream.
|
|
98
|
-
*/
|
|
99
|
-
prepend(token: number | number[]): void {
|
|
100
|
-
if (Array.isArray(token)) {
|
|
101
|
-
while (token.length) this.tokens.push(token.pop()!);
|
|
102
|
-
} else {
|
|
103
|
-
this.tokens.push(token);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* When one or more tokens are pushed to a stream, those tokens
|
|
109
|
-
* must be inserted, in given order, after the last token in the
|
|
110
|
-
* stream.
|
|
111
|
-
*
|
|
112
|
-
* @param token The tokens(s) to push to the stream.
|
|
113
|
-
*/
|
|
114
|
-
push(token: number | number[]): void {
|
|
115
|
-
if (Array.isArray(token)) {
|
|
116
|
-
while (token.length) this.tokens.unshift(token.shift()!);
|
|
117
|
-
} else {
|
|
118
|
-
this.tokens.unshift(token);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function decoderError(fatal: boolean, opt_code_point?: number) {
|
|
124
|
-
if (fatal) throw TypeError('Decoder error');
|
|
125
|
-
return opt_code_point || 0xfffd;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
interface Encoding {
|
|
129
|
-
name: string;
|
|
130
|
-
labels: string[];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const LABEL_ENCODING_MAP: { [key: string]: Encoding } = {};
|
|
134
|
-
|
|
135
|
-
function getEncoding(label: string): Encoding | null {
|
|
136
|
-
label = label.trim().toLowerCase();
|
|
137
|
-
if (label in LABEL_ENCODING_MAP) {
|
|
138
|
-
return LABEL_ENCODING_MAP[label];
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** [Encodings table](https://encoding.spec.whatwg.org/encodings.json) (Incomplete as we only need TextDecoder utf8 in Expo RSC. A more complete implementation should be added to Hermes as native code.) */
|
|
144
|
-
const ENCODING_MAP: { heading: string; encodings: Encoding[] }[] = [
|
|
145
|
-
{
|
|
146
|
-
encodings: [
|
|
147
|
-
{
|
|
148
|
-
labels: [
|
|
149
|
-
'unicode-1-1-utf-8',
|
|
150
|
-
'unicode11utf8',
|
|
151
|
-
'unicode20utf8',
|
|
152
|
-
'utf-8',
|
|
153
|
-
'utf8',
|
|
154
|
-
'x-unicode20utf8',
|
|
155
|
-
],
|
|
156
|
-
name: 'UTF-8',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
heading: 'The Encoding',
|
|
160
|
-
},
|
|
161
|
-
];
|
|
162
|
-
|
|
163
|
-
ENCODING_MAP.forEach((category) => {
|
|
164
|
-
category.encodings.forEach((encoding) => {
|
|
165
|
-
encoding.labels.forEach((label) => {
|
|
166
|
-
LABEL_ENCODING_MAP[label] = encoding;
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Registry of of encoder/decoder factories, by encoding name.
|
|
172
|
-
const DECODERS: { [key: string]: (options: { fatal: boolean }) => UTF8Decoder } = {
|
|
173
|
-
'UTF-8': (options) => new UTF8Decoder(options),
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// 9.1.1 utf-8 decoder
|
|
177
|
-
|
|
178
|
-
interface Decoder {
|
|
179
|
-
handler: (stream: Stream, bite: number) => number | number[] | null | -1;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
class UTF8Decoder implements Decoder {
|
|
183
|
-
// utf-8's decoder's has an associated utf-8 code point, utf-8
|
|
184
|
-
// bytes seen, and utf-8 bytes needed (all initially 0), a utf-8
|
|
185
|
-
// lower boundary (initially 0x80), and a utf-8 upper boundary
|
|
186
|
-
// (initially 0xBF).
|
|
187
|
-
private utf8CodePoint = 0;
|
|
188
|
-
private utf8BytesSeen = 0;
|
|
189
|
-
private utf8BytesNeeded = 0;
|
|
190
|
-
private utf8LowerBoundary = 0x80;
|
|
191
|
-
private utf8UpperBoundary = 0xbf;
|
|
192
|
-
constructor(private options: { fatal: boolean }) {}
|
|
193
|
-
/**
|
|
194
|
-
* @param {Stream} stream The stream of bytes being decoded.
|
|
195
|
-
* @param {number} bite The next byte read from the stream.
|
|
196
|
-
* @return {?(number|!Array.<number>)} The next code point(s)
|
|
197
|
-
* decoded, or null if not enough data exists in the input
|
|
198
|
-
* stream to decode a complete code point.
|
|
199
|
-
*/
|
|
200
|
-
handler(stream: Stream, bite: number): number | null | -1 {
|
|
201
|
-
// 1. If byte is end-of-stream and utf-8 bytes needed is not 0,
|
|
202
|
-
// set utf-8 bytes needed to 0 and return error.
|
|
203
|
-
if (bite === END_OF_STREAM && this.utf8BytesNeeded !== 0) {
|
|
204
|
-
this.utf8BytesNeeded = 0;
|
|
205
|
-
return decoderError(this.options.fatal);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 2. If byte is end-of-stream, return finished.
|
|
209
|
-
if (bite === END_OF_STREAM) return FINISHED;
|
|
210
|
-
|
|
211
|
-
// 3. If utf-8 bytes needed is 0, based on byte:
|
|
212
|
-
if (this.utf8BytesNeeded === 0) {
|
|
213
|
-
// 0x00 to 0x7F
|
|
214
|
-
if (inRange(bite, 0x00, 0x7f)) {
|
|
215
|
-
// Return a code point whose value is byte.
|
|
216
|
-
return bite;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// 0xC2 to 0xDF
|
|
220
|
-
else if (inRange(bite, 0xc2, 0xdf)) {
|
|
221
|
-
// 1. Set utf-8 bytes needed to 1.
|
|
222
|
-
this.utf8BytesNeeded = 1;
|
|
223
|
-
|
|
224
|
-
// 2. Set UTF-8 code point to byte & 0x1F.
|
|
225
|
-
this.utf8CodePoint = bite & 0x1f;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// 0xE0 to 0xEF
|
|
229
|
-
else if (inRange(bite, 0xe0, 0xef)) {
|
|
230
|
-
// 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.
|
|
231
|
-
if (bite === 0xe0) this.utf8LowerBoundary = 0xa0;
|
|
232
|
-
// 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.
|
|
233
|
-
if (bite === 0xed) this.utf8UpperBoundary = 0x9f;
|
|
234
|
-
// 3. Set utf-8 bytes needed to 2.
|
|
235
|
-
this.utf8BytesNeeded = 2;
|
|
236
|
-
// 4. Set UTF-8 code point to byte & 0xF.
|
|
237
|
-
this.utf8CodePoint = bite & 0xf;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// 0xF0 to 0xF4
|
|
241
|
-
else if (inRange(bite, 0xf0, 0xf4)) {
|
|
242
|
-
// 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.
|
|
243
|
-
if (bite === 0xf0) this.utf8LowerBoundary = 0x90;
|
|
244
|
-
// 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.
|
|
245
|
-
if (bite === 0xf4) this.utf8UpperBoundary = 0x8f;
|
|
246
|
-
// 3. Set utf-8 bytes needed to 3.
|
|
247
|
-
this.utf8BytesNeeded = 3;
|
|
248
|
-
// 4. Set UTF-8 code point to byte & 0x7.
|
|
249
|
-
this.utf8CodePoint = bite & 0x7;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Otherwise
|
|
253
|
-
else {
|
|
254
|
-
// Return error.
|
|
255
|
-
return decoderError(this.options.fatal);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Return continue.
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// 4. If byte is not in the range utf-8 lower boundary to utf-8
|
|
263
|
-
// upper boundary, inclusive, run these substeps:
|
|
264
|
-
if (!inRange(bite, this.utf8LowerBoundary, this.utf8UpperBoundary)) {
|
|
265
|
-
// 1. Set utf-8 code point, utf-8 bytes needed, and utf-8
|
|
266
|
-
// bytes seen to 0, set utf-8 lower boundary to 0x80, and set
|
|
267
|
-
// utf-8 upper boundary to 0xBF.
|
|
268
|
-
this.utf8CodePoint = 0;
|
|
269
|
-
this.utf8BytesNeeded = 0;
|
|
270
|
-
this.utf8BytesSeen = 0;
|
|
271
|
-
this.utf8LowerBoundary = 0x80;
|
|
272
|
-
this.utf8UpperBoundary = 0xbf;
|
|
273
|
-
|
|
274
|
-
// 2. Prepend byte to stream.
|
|
275
|
-
stream.prepend(bite);
|
|
276
|
-
|
|
277
|
-
// 3. Return error.
|
|
278
|
-
return decoderError(this.options.fatal);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary
|
|
282
|
-
// to 0xBF.
|
|
283
|
-
this.utf8LowerBoundary = 0x80;
|
|
284
|
-
this.utf8UpperBoundary = 0xbf;
|
|
285
|
-
|
|
286
|
-
// 6. Set UTF-8 code point to (UTF-8 code point << 6) | (byte &
|
|
287
|
-
// 0x3F)
|
|
288
|
-
this.utf8CodePoint = (this.utf8CodePoint << 6) | (bite & 0x3f);
|
|
289
|
-
|
|
290
|
-
// 7. Increase utf-8 bytes seen by one.
|
|
291
|
-
this.utf8BytesSeen += 1;
|
|
292
|
-
|
|
293
|
-
// 8. If utf-8 bytes seen is not equal to utf-8 bytes needed,
|
|
294
|
-
// continue.
|
|
295
|
-
if (this.utf8BytesSeen !== this.utf8BytesNeeded) return null;
|
|
296
|
-
|
|
297
|
-
// 9. Let code point be utf-8 code point.
|
|
298
|
-
const code_point = this.utf8CodePoint;
|
|
299
|
-
|
|
300
|
-
// 10. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes
|
|
301
|
-
// seen to 0.
|
|
302
|
-
this.utf8CodePoint = 0;
|
|
303
|
-
this.utf8BytesNeeded = 0;
|
|
304
|
-
this.utf8BytesSeen = 0;
|
|
305
|
-
|
|
306
|
-
// 11. Return a code point whose value is code point.
|
|
307
|
-
return code_point;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// 8.1 Interface TextDecoder
|
|
312
|
-
// @docsMissing
|
|
313
|
-
export class TextDecoder {
|
|
314
|
-
private _encoding: Encoding | null;
|
|
315
|
-
private _ignoreBOM: boolean;
|
|
316
|
-
private _errorMode: string;
|
|
317
|
-
private _BOMseen: boolean = false;
|
|
318
|
-
private _doNotFlush: boolean = false;
|
|
319
|
-
private _decoder: UTF8Decoder | null = null;
|
|
320
|
-
|
|
321
|
-
constructor(
|
|
322
|
-
label: string = 'utf-8',
|
|
323
|
-
options: {
|
|
324
|
-
fatal?: boolean;
|
|
325
|
-
ignoreBOM?: boolean;
|
|
326
|
-
} = {}
|
|
327
|
-
) {
|
|
328
|
-
if (options != null && typeof options !== 'object') {
|
|
329
|
-
throw new TypeError(
|
|
330
|
-
'Second argument of TextDecoder must be undefined or an object, e.g. { fatal: true }'
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const normalizedLabel = String(label).trim().toLowerCase();
|
|
335
|
-
const encoding = getEncoding(normalizedLabel);
|
|
336
|
-
if (encoding === null || encoding.name === 'replacement') {
|
|
337
|
-
throw new RangeError(`Unknown encoding: ${label} (normalized: ${normalizedLabel})`);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (!DECODERS[encoding.name]) {
|
|
341
|
-
throw new Error(`Decoder not present: ${encoding.name}`);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
this._encoding = encoding;
|
|
345
|
-
this._ignoreBOM = !!options.ignoreBOM;
|
|
346
|
-
this._errorMode = options.fatal ? 'fatal' : 'replacement';
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Getter methods for encoding, fatal, and ignoreBOM
|
|
350
|
-
get encoding(): string {
|
|
351
|
-
return this._encoding?.name.toLowerCase() ?? '';
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
get fatal(): boolean {
|
|
355
|
-
return this._errorMode === 'fatal';
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
get ignoreBOM(): boolean {
|
|
359
|
-
return this._ignoreBOM;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
decode(input?: ArrayBuffer | DataView, options: { stream?: boolean } = {}): string {
|
|
363
|
-
const bytes = normalizeBytes(input);
|
|
364
|
-
|
|
365
|
-
// 1. If the do not flush flag is unset, set decoder to a new
|
|
366
|
-
// encoding's decoder, set stream to a new stream, and unset the
|
|
367
|
-
// BOM seen flag.
|
|
368
|
-
if (!this._doNotFlush) {
|
|
369
|
-
this._decoder = DECODERS[this._encoding!.name]({
|
|
370
|
-
fatal: this.fatal,
|
|
371
|
-
});
|
|
372
|
-
this._BOMseen = false;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// 2. If options's stream is true, set the do not flush flag, and
|
|
376
|
-
// unset the do not flush flag otherwise.
|
|
377
|
-
this._doNotFlush = Boolean(options['stream']);
|
|
378
|
-
|
|
379
|
-
// 3. If input is given, push a copy of input to stream.
|
|
380
|
-
// TODO: Align with spec algorithm - maintain stream on instance.
|
|
381
|
-
const input_stream = new Stream(bytes);
|
|
382
|
-
|
|
383
|
-
// 4. Let output be a new stream.
|
|
384
|
-
const output: number[] = [];
|
|
385
|
-
|
|
386
|
-
while (true) {
|
|
387
|
-
const token = input_stream.read();
|
|
388
|
-
|
|
389
|
-
if (token === END_OF_STREAM) break;
|
|
390
|
-
|
|
391
|
-
const result = this._decoder!.handler(input_stream, token);
|
|
392
|
-
|
|
393
|
-
if (result === FINISHED) break;
|
|
394
|
-
|
|
395
|
-
if (result !== null) {
|
|
396
|
-
output.push(result);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (!this._doNotFlush) {
|
|
401
|
-
do {
|
|
402
|
-
const result = this._decoder!.handler(input_stream, input_stream.read());
|
|
403
|
-
if (result === FINISHED) break;
|
|
404
|
-
if (result === null) continue;
|
|
405
|
-
if (Array.isArray(result)) output.push(...result);
|
|
406
|
-
else output.push(result);
|
|
407
|
-
} while (!input_stream.endOfStream());
|
|
408
|
-
this._decoder = null;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return this.serializeStream(output);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// serializeStream method for converting code points to a string
|
|
415
|
-
private serializeStream(stream: number[]): string {
|
|
416
|
-
if (this._encoding!.name === 'UTF-8') {
|
|
417
|
-
if (!this._ignoreBOM && !this._BOMseen && stream[0] === 0xfeff) {
|
|
418
|
-
// If BOM is detected at the start of the stream and we're not ignoring it
|
|
419
|
-
this._BOMseen = true;
|
|
420
|
-
stream.shift(); // Remove the BOM
|
|
421
|
-
} else if (stream.length > 0) {
|
|
422
|
-
this._BOMseen = true;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// Convert the stream of code points to a string
|
|
427
|
-
return codePointsToString(stream);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export class FetchError extends Error {
|
|
2
|
-
constructor(message: string, { cause, stack }: { cause?: unknown; stack?: string } = {}) {
|
|
3
|
-
super(`fetch failed: ${message}`);
|
|
4
|
-
this.cause = cause;
|
|
5
|
-
this.stack = stack;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static createFromError(error: Error): FetchError {
|
|
9
|
-
return new FetchError(error.message, { cause: error.cause, stack: error.stack });
|
|
10
|
-
}
|
|
11
|
-
}
|