basalt-core 0.0.0-rc5 → 0.1.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.
Files changed (143) hide show
  1. package/dist/cli/basalt.d.ts.map +1 -1
  2. package/dist/cli/basalt.js +18 -1
  3. package/dist/cli/basalt.js.map +1 -1
  4. package/dist/cli/bundle-cli.js +0 -0
  5. package/dist/cli/packageApp.d.ts.map +1 -1
  6. package/dist/cli/packageApp.js +7 -1
  7. package/dist/cli/packageApp.js.map +1 -1
  8. package/dist/metro-config.d.ts.map +1 -1
  9. package/dist/metro-config.js +53 -5
  10. package/dist/metro-config.js.map +1 -1
  11. package/dist/src/KeyHandler.d.ts +1 -1
  12. package/dist/src/KeyHandler.d.ts.map +1 -1
  13. package/dist/src/KeyHandler.js.map +1 -1
  14. package/dist/src/index.d.ts +5 -0
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/overrides/Alert.d.ts +1 -1
  17. package/dist/src/overrides/Alert.js +1 -1
  18. package/dist/src/overrides/BaseViewConfig.d.ts +10 -3
  19. package/dist/src/overrides/BaseViewConfig.d.ts.map +1 -1
  20. package/dist/src/overrides/BaseViewConfig.js +21 -3
  21. package/dist/src/overrides/BaseViewConfig.js.map +1 -1
  22. package/dist/src/overrides/Button.d.ts +81 -0
  23. package/dist/src/overrides/Button.d.ts.map +1 -0
  24. package/dist/src/overrides/Button.js +109 -0
  25. package/dist/src/overrides/Button.js.map +1 -0
  26. package/dist/src/overrides/ScrollView.d.ts +25 -2
  27. package/dist/src/overrides/ScrollView.d.ts.map +1 -1
  28. package/dist/src/overrides/ScrollView.js +64 -7
  29. package/dist/src/overrides/ScrollView.js.map +1 -1
  30. package/dist/src/overrides/Settings.d.ts +81 -0
  31. package/dist/src/overrides/Settings.d.ts.map +1 -0
  32. package/dist/src/overrides/Settings.js +120 -0
  33. package/dist/src/overrides/Settings.js.map +1 -0
  34. package/dist/src/overrides/processDecelerationRate.d.ts +20 -0
  35. package/dist/src/overrides/processDecelerationRate.d.ts.map +1 -0
  36. package/dist/src/overrides/processDecelerationRate.js +31 -0
  37. package/dist/src/overrides/processDecelerationRate.js.map +1 -0
  38. package/dist/src/useContextMenu.d.ts +57 -6
  39. package/dist/src/useContextMenu.d.ts.map +1 -1
  40. package/dist/src/useContextMenu.js +34 -1
  41. package/dist/src/useContextMenu.js.map +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/native/CMakeLists.txt +51 -0
  44. package/native/core/ActionSheet.cpp +75 -0
  45. package/native/core/ActionSheet.h +90 -0
  46. package/native/core/AppStateHost.cpp +76 -0
  47. package/native/core/AppStateHost.h +68 -0
  48. package/native/core/BackgroundLayers.h +282 -0
  49. package/native/core/BlendModes.h +67 -0
  50. package/native/core/CoreModules.cpp +380 -11
  51. package/native/core/CoreModules.h +140 -4
  52. package/native/core/CrashHandler.cpp +246 -0
  53. package/native/core/CrashHandler.h +65 -0
  54. package/native/core/CursorNames.h +110 -0
  55. package/native/core/DevMenu.cpp +6 -5
  56. package/native/core/DeviceMetrics.cpp +87 -0
  57. package/native/core/DeviceMetrics.h +80 -0
  58. package/native/core/Filters.h +336 -0
  59. package/native/core/FontFitting.h +183 -0
  60. package/native/core/FontScaling.h +153 -0
  61. package/native/core/FontVariants.h +148 -0
  62. package/native/core/Gradients.h +523 -0
  63. package/native/core/ImageAnimation.h +109 -0
  64. package/native/core/ImageBytes.cpp +28 -1
  65. package/native/core/ImageBytes.h +17 -1
  66. package/native/core/ImageProgress.h +85 -0
  67. package/native/core/LabelRegistry.h +189 -0
  68. package/native/core/LegacyShadow.h +90 -0
  69. package/native/core/LiveRegions.h +114 -0
  70. package/native/core/MenuModule.cpp +35 -4
  71. package/native/core/MountingWalk.h +125 -2
  72. package/native/core/PlatformServices.h +187 -3
  73. package/native/core/SafeAreaComponent.cpp +115 -0
  74. package/native/core/SafeAreaComponent.h +105 -0
  75. package/native/core/ScreensComponent.cpp +201 -0
  76. package/native/core/ScreensComponent.h +216 -0
  77. package/native/core/ScrollBounds.cpp +8 -0
  78. package/native/core/ScrollBounds.h +14 -0
  79. package/native/core/ScrollIndicator.h +67 -0
  80. package/native/core/ScrollMomentum.cpp +24 -0
  81. package/native/core/ScrollMomentum.h +14 -0
  82. package/native/core/ScrollSnap.cpp +121 -12
  83. package/native/core/ScrollSnap.h +45 -0
  84. package/native/core/ScrollVisiblePosition.cpp +68 -0
  85. package/native/core/ScrollVisiblePosition.h +101 -0
  86. package/native/core/SettingsStore.cpp +199 -0
  87. package/native/core/SettingsStore.h +127 -0
  88. package/native/core/ShadowShape.h +38 -0
  89. package/native/core/SystemLocale.cpp +103 -0
  90. package/native/core/SystemLocale.h +86 -0
  91. package/native/core/TestDialog.cpp +45 -6
  92. package/native/core/TestDialog.h +15 -0
  93. package/native/core/TextAlignments.h +240 -0
  94. package/native/core/TextChecking.h +133 -0
  95. package/native/core/TextColors.h +83 -0
  96. package/native/core/TextDecorations.h +101 -0
  97. package/native/core/TextDirection.cpp +242 -0
  98. package/native/core/TextDirection.h +88 -0
  99. package/native/core/TextHighlight.h +30 -0
  100. package/native/core/TextSelection.cpp +97 -0
  101. package/native/core/TextSelection.h +161 -0
  102. package/native/core/TextShadows.h +96 -0
  103. package/native/core/TextVerticalAlign.h +33 -0
  104. package/native/core/UIManagerAccess.cpp +36 -0
  105. package/native/core/UIManagerAccess.h +28 -0
  106. package/native/core/WindowBoundsCache.cpp +58 -1
  107. package/native/core/WindowControl.h +24 -0
  108. package/native/core/WritingDirections.h +52 -0
  109. package/native/core/portability_probe.cpp +7 -0
  110. package/native/tests/RenamedFontFile.h +161 -0
  111. package/native/tests/TestHarness.cpp +18 -0
  112. package/native/tests/test_action_sheet.cpp +157 -0
  113. package/native/tests/test_app_state.cpp +60 -0
  114. package/native/tests/test_background_layers.cpp +281 -0
  115. package/native/tests/test_blend_modes.cpp +79 -0
  116. package/native/tests/test_blobs.cpp +1 -1
  117. package/native/tests/test_device_metrics.cpp +126 -0
  118. package/native/tests/test_filters.cpp +271 -0
  119. package/native/tests/test_font_fitting.cpp +172 -0
  120. package/native/tests/test_font_scaling.cpp +127 -0
  121. package/native/tests/test_font_variants.cpp +84 -0
  122. package/native/tests/test_gradients.cpp +390 -0
  123. package/native/tests/test_image_animation.cpp +105 -0
  124. package/native/tests/test_image_progress.cpp +94 -0
  125. package/native/tests/test_label_registry.cpp +262 -0
  126. package/native/tests/test_legacy_shadow.cpp +165 -0
  127. package/native/tests/test_live_regions.cpp +108 -0
  128. package/native/tests/test_menu_entries.cpp +192 -0
  129. package/native/tests/test_momentum.cpp +45 -0
  130. package/native/tests/test_scroll_bounds.cpp +42 -0
  131. package/native/tests/test_scroll_indicator.cpp +61 -0
  132. package/native/tests/test_scroll_snap.cpp +129 -0
  133. package/native/tests/test_scroll_visible_position.cpp +121 -0
  134. package/native/tests/test_settings_store.cpp +257 -0
  135. package/native/tests/test_shadow_shape.cpp +47 -0
  136. package/native/tests/test_system_locale.cpp +36 -0
  137. package/native/tests/test_text_alignment.cpp +299 -0
  138. package/native/tests/test_text_checking.cpp +31 -0
  139. package/native/tests/test_text_colors.cpp +92 -0
  140. package/native/tests/test_text_decorations.cpp +100 -0
  141. package/native/tests/test_text_selection.cpp +168 -0
  142. package/native/tests/test_text_shadows.cpp +132 -0
  143. package/package.json +4 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/overrides/Button.tsx"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,sGAA8E;AAC9E,oFAA4D;AAC5D,4HAAoG;AACpG,+FAAuE;AAmCvE,SAAS,MAAM,CAAC,KAAkB;IAChC,MAAM,EACJ,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,KAAK,EACL,yBAAyB,EACzB,qBAAqB,EACrB,OAAO,EACP,MAAM,EACN,KAA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  * Importing the module this file replaces resolves to the original rather than
23
- * looping: `metro-config.js` skips the override when the request comes from the
24
- * override itself. That guard was written for exactly this case.
23
+ * looping: a `basalt-core/upstream/...` specifier means React Native's own file
24
+ * and is never answered with an override. See docs/DECISIONS.md for what that
25
+ * rule used to be and what it cost.
26
+ *
27
+ * ## `pagingEnabled`, which never reached a desktop at all
28
+ *
29
+ * The second thing this wrapper puts back, and a different failure from the
30
+ * first: `ScrollView.render` computes the native `pagingEnabled` prop with
31
+ * `Platform.select({ios, android})` and no `default`, so on `linux`, `macos`
32
+ * or `windows` it is `undefined`, `BaseScrollViewProps` keeps its own `false`,
33
+ * and a paged list simply scrolls freely. All three hosts implement paging --
34
+ * `core/ScrollSnap.h` has it, and reads `props->pagingEnabled` to turn it on --
35
+ * so the only thing missing was the prop.
36
+ *
37
+ * It is translated rather than forced, because `ScrollView.js` is two thousand
38
+ * lines and the value is computed inside its render: a paged list is given
39
+ * `snapToInterval` of its own viewport and `disableIntervalMomentum`, which is
40
+ * what `core/ScrollSnap.h` says paging *is* -- snap points a screenful apart,
41
+ * and one page per flick however hard it was thrown. Only when the app set
42
+ * neither `snapToInterval` nor `snapToOffsets`, which is the same precedence
43
+ * upstream's iOS branch applies.
44
+ *
45
+ * The viewport comes from `onLayout`, so a paged list snaps from its second
46
+ * frame rather than its first, and follows a window that is resized. The app's
47
+ * own `onLayout` still fires.
25
48
  *
26
49
  * @format
27
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../../src/overrides/ScrollView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,qBAAqB,GAAG;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAG3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,iBAAS,gBAAgB,CAAC,EACxB,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAa5C;kBAjBQ,gBAAgB;;;AAmCzB,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../../src/overrides/ScrollView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAKH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,KAAK,qBAAqB,GAAG;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAG3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AA8DF,iBAAS,gBAAgB,CAAC,EACxB,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAW5C;kBAfQ,gBAAgB;;;AAiCzB,eAAe,gBAAgB,CAAC"}
@@ -20,8 +20,31 @@
20
20
  * first child and everything else is React Native's.
21
21
  *
22
22
  * Importing the module this file replaces resolves to the original rather than
23
- * looping: `metro-config.js` skips the override when the request comes from the
24
- * override itself. That guard was written for exactly this case.
23
+ * looping: a `basalt-core/upstream/...` specifier means React Native's own file
24
+ * and is never answered with an override. See docs/DECISIONS.md for what that
25
+ * rule used to be and what it cost.
26
+ *
27
+ * ## `pagingEnabled`, which never reached a desktop at all
28
+ *
29
+ * The second thing this wrapper puts back, and a different failure from the
30
+ * first: `ScrollView.render` computes the native `pagingEnabled` prop with
31
+ * `Platform.select({ios, android})` and no `default`, so on `linux`, `macos`
32
+ * or `windows` it is `undefined`, `BaseScrollViewProps` keeps its own `false`,
33
+ * and a paged list simply scrolls freely. All three hosts implement paging --
34
+ * `core/ScrollSnap.h` has it, and reads `props->pagingEnabled` to turn it on --
35
+ * so the only thing missing was the prop.
36
+ *
37
+ * It is translated rather than forced, because `ScrollView.js` is two thousand
38
+ * lines and the value is computed inside its render: a paged list is given
39
+ * `snapToInterval` of its own viewport and `disableIntervalMomentum`, which is
40
+ * what `core/ScrollSnap.h` says paging *is* -- snap points a screenful apart,
41
+ * and one page per flick however hard it was thrown. Only when the app set
42
+ * neither `snapToInterval` nor `snapToOffsets`, which is the same precedence
43
+ * upstream's iOS branch applies.
44
+ *
45
+ * The viewport comes from `onLayout`, so a paged list snaps from its second
46
+ * frame rather than its first, and follows a window that is resized. The app's
47
+ * own `onLayout` still fires.
25
48
  *
26
49
  * @format
27
50
  */
@@ -32,14 +55,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
32
55
  Object.defineProperty(exports, "__esModule", { value: true });
33
56
  const jsx_runtime_1 = require("react/jsx-runtime");
34
57
  const ScrollView_1 = __importDefault(require("basalt-core/upstream/Libraries/Components/ScrollView/ScrollView"));
35
- function BasaltScrollView({ refreshControl, children, ...props }) {
36
- if (refreshControl == null) {
37
- return (0, jsx_runtime_1.jsx)(ScrollView_1.default, { ...props, children: children });
38
- }
58
+ const react_1 = require("react");
59
+ /** The children in the order this platform mounts them: see the header. */
60
+ function withRefreshControl(refreshControl, children) {
39
61
  // First, so it takes the row at the top of the content: on a phone the
40
62
  // spinner lives in the rubber band above the list, and a desktop scroll view
41
63
  // has none. See the header of RefreshControl.js beside this file.
42
- return ((0, jsx_runtime_1.jsxs)(ScrollView_1.default, { ...props, children: [refreshControl, children] }));
64
+ return refreshControl == null ? children : [refreshControl, children];
65
+ }
66
+ /** Whether this list asked for paging and nothing more specific. */
67
+ function wantsPaging(props) {
68
+ return (props.pagingEnabled === true &&
69
+ props.snapToInterval == null &&
70
+ props.snapToOffsets == null);
71
+ }
72
+ /**
73
+ * A paged list, which has to measure itself: the page is the viewport, and
74
+ * nothing knows how big that is until it has been laid out.
75
+ *
76
+ * A second component rather than a branch, for the reason View.tsx beside this
77
+ * file has two: hooks cannot be conditional, and a scroll view that re-renders
78
+ * on every layout is not a cost to impose on the lists that are not paged.
79
+ */
80
+ function PagedScrollView({ refreshControl, children, ...props }) {
81
+ const [viewport, setViewport] = (0, react_1.useState)(0);
82
+ const appOnLayout = props.onLayout;
83
+ const horizontal = props.horizontal === true;
84
+ const onLayout = (0, react_1.useCallback)((event) => {
85
+ const { width, height } = event.nativeEvent.layout;
86
+ setViewport(horizontal ? width : height);
87
+ appOnLayout?.(event);
88
+ }, [appOnLayout, horizontal]);
89
+ return ((0, jsx_runtime_1.jsx)(ScrollView_1.default, { ...props, onLayout: onLayout,
90
+ // Zero until the first layout, which `ScrollSnapConfig` reads as "unused"
91
+ // -- so a paged list snaps from its second frame. A page cannot be known
92
+ // before the viewport is.
93
+ snapToInterval: viewport, disableIntervalMomentum: true, children: withRefreshControl(refreshControl, children) }));
94
+ }
95
+ function BasaltScrollView({ refreshControl, children, ...props }) {
96
+ if (wantsPaging(props)) {
97
+ return ((0, jsx_runtime_1.jsx)(PagedScrollView, { refreshControl: refreshControl, ...props, children: children }));
98
+ }
99
+ return ((0, jsx_runtime_1.jsx)(ScrollView_1.default, { ...props, children: withRefreshControl(refreshControl, children) }));
43
100
  }
44
101
  BasaltScrollView.displayName = 'ScrollView';
45
102
  // `ScrollView.Context` is read by VirtualizedList and by `ScrollView`'s own
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollView.js","sourceRoot":"","sources":["../../../src/overrides/ScrollView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,YAAY,CAAC;;;;;;AAEb,iHAAyF;AAWzF,SAAS,gBAAgB,CAAC,EACxB,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACc;IACtB,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,uBAAC,oBAAU,OAAK,KAAK,YA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B,CAAC,cAAc,EAAE,QAAQ,CAAC,GAAc,CACnF,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,WAAW,GAAG,YAAY,CAAC;AAE5C,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,uEAAuE;AACvE,MAAM,OAAO,GAAG,gBAAsD,CAAC;AACvE,MAAM,eAAe,GAAG,oBAAgD,CAAC;AACzE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;IAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;AAE1C,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * `Settings`, for a platform React Native's own copy has no branch for.
3
+ *
4
+ * The third of these, and found by the native-module audit rather than by an
5
+ * app: `docs/platform-modules.json` recorded `SettingsManager` as a module that
6
+ * *throws* here, which was wrong in the app's favour and wrong in a way that
7
+ * mattered. `Settings.js` reads
8
+ *
9
+ * if (Platform.OS === 'ios') {
10
+ * Settings = require('./Settings').default;
11
+ * } else {
12
+ * Settings = require('./SettingsFallback').default;
13
+ * }
14
+ *
15
+ * and `SettingsFallback` is four methods that `console.warn` and answer null.
16
+ * So nothing threw, nothing was stored, and nothing said why beyond a warning
17
+ * that reads like a platform limitation rather than a missing module. The
18
+ * native module was never reached, exactly as with `Share` and `Alert`.
19
+ *
20
+ * ## What this file is
21
+ *
22
+ * React Native's own `Settings.ios.js`, kept as close to the original as the
23
+ * conversion to TypeScript allows, because its behaviour is the contract: an
24
+ * app written against iOS reads `Settings.get` synchronously, and that only
25
+ * works because the whole store arrives once in `getConstants()` and is cached
26
+ * in `_settings` here. A rewrite that asked the native side per key would be a
27
+ * different API with the same name.
28
+ *
29
+ * Importing the iOS file instead was the other option and is worse: the file
30
+ * would still resolve through `./NativeSettingsManager`, and a platform would
31
+ * depend on a `.ios` suffix meaning "iOS or anything like it", which is the
32
+ * assumption this whole override table exists to undo.
33
+ *
34
+ * ## watchKeys
35
+ *
36
+ * Registered and never fired, and that is iOS's shape rather than a stub.
37
+ * `Settings.set` merges into `_settings` before calling the module, so
38
+ * `_sendObservations` sees no change for the app's own write -- which is why
39
+ * `RCTSettingsManager` sets `_ignoringUpdates` around `setValues` instead of
40
+ * emitting. What fires a watcher on iOS is a change from *outside* the process,
41
+ * which on a desktop means watching the settings file; see
42
+ * docs/backlog/modules.md for the three calls that would do it. The listener is
43
+ * here so that the day a host emits `settingsUpdated`, this half already works.
44
+ *
45
+ * @format
46
+ */
47
+ /**
48
+ * A persistent key-value store. On iOS this wraps `NSUserDefaults`; here it is
49
+ * a JSON file under the per-user configuration directory, which is what
50
+ * core/SettingsStore.h argues for.
51
+ *
52
+ * @see https://reactnative.dev/docs/settings
53
+ */
54
+ declare const Settings: {
55
+ _settings: {
56
+ [key: string]: unknown;
57
+ };
58
+ /**
59
+ * The current value for `key`, or undefined when it has never been set.
60
+ */
61
+ get(key: string): unknown;
62
+ /**
63
+ * Merges `settings` into the store, one key deep. A key set to null is
64
+ * forgotten rather than stored as null, which is what iOS does.
65
+ */
66
+ set(settings: {
67
+ [key: string]: unknown;
68
+ }): void;
69
+ /**
70
+ * Calls `callback` whenever one of `keys` changes, and answers a watch id for
71
+ * `clearWatch`. Nothing emits the change event on this platform yet; see the
72
+ * header.
73
+ */
74
+ watchKeys(keys: string | Array<string>, callback: () => void): number;
75
+ clearWatch(watchId: number): void;
76
+ _sendObservations(body: {
77
+ [key: string]: unknown;
78
+ }): void;
79
+ };
80
+ export default Settings;
81
+ //# sourceMappingURL=Settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Settings.d.ts","sourceRoot":"","sources":["../../../src/overrides/Settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAqBH;;;;;;GAMG;AACH,QAAA,MAAM,QAAQ;eACgD;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC;IAEpF;;OAEG;aACM,MAAM,GAAG,OAAO;IAIzB;;;OAGG;kBACW;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,GAAG,IAAI;IAK7C;;;;OAIG;oBACa,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,MAAM,IAAI,GAAG,MAAM;wBAYjD,MAAM,GAAG,IAAI;4BAMT;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,GAAG,IAAI;CAexD,CAAC;AAIF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * `Settings`, for a platform React Native's own copy has no branch for.
3
+ *
4
+ * The third of these, and found by the native-module audit rather than by an
5
+ * app: `docs/platform-modules.json` recorded `SettingsManager` as a module that
6
+ * *throws* here, which was wrong in the app's favour and wrong in a way that
7
+ * mattered. `Settings.js` reads
8
+ *
9
+ * if (Platform.OS === 'ios') {
10
+ * Settings = require('./Settings').default;
11
+ * } else {
12
+ * Settings = require('./SettingsFallback').default;
13
+ * }
14
+ *
15
+ * and `SettingsFallback` is four methods that `console.warn` and answer null.
16
+ * So nothing threw, nothing was stored, and nothing said why beyond a warning
17
+ * that reads like a platform limitation rather than a missing module. The
18
+ * native module was never reached, exactly as with `Share` and `Alert`.
19
+ *
20
+ * ## What this file is
21
+ *
22
+ * React Native's own `Settings.ios.js`, kept as close to the original as the
23
+ * conversion to TypeScript allows, because its behaviour is the contract: an
24
+ * app written against iOS reads `Settings.get` synchronously, and that only
25
+ * works because the whole store arrives once in `getConstants()` and is cached
26
+ * in `_settings` here. A rewrite that asked the native side per key would be a
27
+ * different API with the same name.
28
+ *
29
+ * Importing the iOS file instead was the other option and is worse: the file
30
+ * would still resolve through `./NativeSettingsManager`, and a platform would
31
+ * depend on a `.ios` suffix meaning "iOS or anything like it", which is the
32
+ * assumption this whole override table exists to undo.
33
+ *
34
+ * ## watchKeys
35
+ *
36
+ * Registered and never fired, and that is iOS's shape rather than a stub.
37
+ * `Settings.set` merges into `_settings` before calling the module, so
38
+ * `_sendObservations` sees no change for the app's own write -- which is why
39
+ * `RCTSettingsManager` sets `_ignoringUpdates` around `setValues` instead of
40
+ * emitting. What fires a watcher on iOS is a change from *outside* the process,
41
+ * which on a desktop means watching the settings file; see
42
+ * docs/backlog/modules.md for the three calls that would do it. The listener is
43
+ * here so that the day a host emits `settingsUpdated`, this half already works.
44
+ *
45
+ * @format
46
+ */
47
+ 'use strict';
48
+ var __importDefault = (this && this.__importDefault) || function (mod) {
49
+ return (mod && mod.__esModule) ? mod : { "default": mod };
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ // `NativeSettingsManager`, which is a `getEnforcing` lookup: if a host has not
53
+ // registered `SettingsManager`, importing this throws and names the module,
54
+ // which is a better failure than the silent null the fallback gave.
55
+ const NativeSettingsManager_1 = __importDefault(require("basalt-core/upstream/Libraries/Settings/NativeSettingsManager"));
56
+ // The device event emitter, which is where a `settingsUpdated` event would
57
+ // arrive. React Native's own file subscribes at import and so does this one.
58
+ const RCTDeviceEventEmitter_1 = __importDefault(require("basalt-core/upstream/Libraries/EventEmitter/RCTDeviceEventEmitter"));
59
+ const invariant = require('invariant');
60
+ const subscriptions = [];
61
+ /**
62
+ * A persistent key-value store. On iOS this wraps `NSUserDefaults`; here it is
63
+ * a JSON file under the per-user configuration directory, which is what
64
+ * core/SettingsStore.h argues for.
65
+ *
66
+ * @see https://reactnative.dev/docs/settings
67
+ */
68
+ const Settings = {
69
+ _settings: NativeSettingsManager_1.default.getConstants().settings,
70
+ /**
71
+ * The current value for `key`, or undefined when it has never been set.
72
+ */
73
+ get(key) {
74
+ return this._settings[key];
75
+ },
76
+ /**
77
+ * Merges `settings` into the store, one key deep. A key set to null is
78
+ * forgotten rather than stored as null, which is what iOS does.
79
+ */
80
+ set(settings) {
81
+ this._settings = Object.assign(this._settings, settings);
82
+ NativeSettingsManager_1.default.setValues(settings);
83
+ },
84
+ /**
85
+ * Calls `callback` whenever one of `keys` changes, and answers a watch id for
86
+ * `clearWatch`. Nothing emits the change event on this platform yet; see the
87
+ * header.
88
+ */
89
+ watchKeys(keys, callback) {
90
+ if (typeof keys === 'string') {
91
+ keys = [keys];
92
+ }
93
+ invariant(Array.isArray(keys), 'keys should be a string or array of strings');
94
+ const sid = subscriptions.length;
95
+ subscriptions.push({ keys, callback });
96
+ return sid;
97
+ },
98
+ clearWatch(watchId) {
99
+ if (watchId < subscriptions.length) {
100
+ subscriptions[watchId] = { keys: [], callback: null };
101
+ }
102
+ },
103
+ _sendObservations(body) {
104
+ Object.keys(body).forEach(key => {
105
+ const newValue = body[key];
106
+ const didChange = this._settings[key] !== newValue;
107
+ this._settings[key] = newValue;
108
+ if (didChange) {
109
+ subscriptions.forEach(sub => {
110
+ if (sub.keys.indexOf(key) !== -1 && sub.callback) {
111
+ sub.callback();
112
+ }
113
+ });
114
+ }
115
+ });
116
+ },
117
+ };
118
+ RCTDeviceEventEmitter_1.default.addListener('settingsUpdated', Settings._sendObservations.bind(Settings));
119
+ exports.default = Settings;
120
+ //# sourceMappingURL=Settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../../src/overrides/Settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,YAAY,CAAC;;;;;AAEb,+EAA+E;AAC/E,4EAA4E;AAC5E,oEAAoE;AACpE,0HAAkG;AAClG,2EAA2E;AAC3E,6EAA6E;AAC7E,8HAAsG;AAEtG,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAOvC,MAAM,aAAa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,CAAC,KAAK,QAAQ,CAAC;YACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;YAE/B,IAAI,SAAS,EAAE,CAAC;gBACd,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;oBAC1B,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;wBACjD,GAAG,CAAC,QAAQ,EAAE,CAAC;oBACjB,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,+BAAqB,CAAC,WAAW,CAAC,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEhG,kBAAe,QAAQ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `decelerationRate`, for a desktop React Native platform.
3
+ *
4
+ * Not a shim, and the same failure as `<Button>`'s: React Native's own file is
5
+ * two `Platform.select({ios, android})` tables with no `default`, so on
6
+ * `linux`, `macos` or `windows` both of the prop's documented spellings --
7
+ * `'normal'` and `'fast'` -- resolve to `undefined`. `BaseScrollViewProps`
8
+ * then keeps its own default of 0.998, so `decelerationRate="fast"` scrolled
9
+ * at the normal rate and nothing said otherwise. Only a raw number worked.
10
+ *
11
+ * iOS's pair, because they are the pair this platform's own fling already
12
+ * uses: `core/ScrollMomentum.h` names 0.998 and 0.99 as what `'normal'` and
13
+ * `'fast'` mean, and a per-millisecond friction factor is the same model
14
+ * UIScrollView and every browser use. Android's 0.985 and 0.9 are a different
15
+ * curve's constants and would make a fling stop in a third of the distance.
16
+ *
17
+ * @format
18
+ */
19
+ export default function processDecelerationRate(decelerationRate: number | 'normal' | 'fast'): number;
20
+ //# sourceMappingURL=processDecelerationRate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processDecelerationRate.d.ts","sourceRoot":"","sources":["../../../src/overrides/processDecelerationRate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,gBAAgB,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAC3C,MAAM,CAQR"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * `decelerationRate`, for a desktop React Native platform.
4
+ *
5
+ * Not a shim, and the same failure as `<Button>`'s: React Native's own file is
6
+ * two `Platform.select({ios, android})` tables with no `default`, so on
7
+ * `linux`, `macos` or `windows` both of the prop's documented spellings --
8
+ * `'normal'` and `'fast'` -- resolve to `undefined`. `BaseScrollViewProps`
9
+ * then keeps its own default of 0.998, so `decelerationRate="fast"` scrolled
10
+ * at the normal rate and nothing said otherwise. Only a raw number worked.
11
+ *
12
+ * iOS's pair, because they are the pair this platform's own fling already
13
+ * uses: `core/ScrollMomentum.h` names 0.998 and 0.99 as what `'normal'` and
14
+ * `'fast'` mean, and a per-millisecond friction factor is the same model
15
+ * UIScrollView and every browser use. Android's 0.985 and 0.9 are a different
16
+ * curve's constants and would make a fling stop in a third of the distance.
17
+ *
18
+ * @format
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.default = processDecelerationRate;
22
+ function processDecelerationRate(decelerationRate) {
23
+ if (decelerationRate === 'normal') {
24
+ return 0.998;
25
+ }
26
+ if (decelerationRate === 'fast') {
27
+ return 0.99;
28
+ }
29
+ return decelerationRate;
30
+ }
31
+ //# sourceMappingURL=processDecelerationRate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processDecelerationRate.js","sourceRoot":"","sources":["../../../src/overrides/processDecelerationRate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,0CAUC;AAVD,SAAwB,uBAAuB,CAC7C,gBAA4C;IAE5C,IAAI,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -63,20 +63,71 @@
63
63
  * @format
64
64
  */
65
65
  /**
66
- * One item in a context menu, as `native/core/MenuModel.h` reads it, plus the
67
- * handler this file calls.
66
+ * One item in a context menu: the four fields `entriesFrom` in
67
+ * `native/core/MenuModule.cpp` reads into a `MenuEntry`, plus the handler this
68
+ * file calls.
69
+ *
70
+ * A popup menu is a flat list on all three desktops, so there is no `submenu`
71
+ * and no `role` here -- nesting and the platform roles are what a menu *bar*
72
+ * is for, and `<Menu.Item>` is where they live.
68
73
  *
69
74
  * `onSelect` is the only field the native side does not see: the promise
70
75
  * carries the index back, and this calls the handler before settling it.
71
76
  */
72
77
  export type ContextMenuItem = {
73
78
  label?: string;
74
- /** One of the platform roles; see native/core/MenuModel.h. */
75
- role?: string;
76
- /** "CmdOrCtrl+O", in Electron's spelling. Ignored for a role. */
77
- accelerator?: string;
79
+ /**
80
+ * Drawn beside the label -- "Cmd+C", "Del". Decoration only: nothing here
81
+ * binds a key. Note the menu *bar* spells the same idea `accelerator`,
82
+ * because there it really does bind one.
83
+ */
84
+ shortcut?: string;
78
85
  enabled?: boolean;
79
86
  separator?: boolean;
87
+ /**
88
+ * One of the platform roles, in Electron's spelling: `about`, `quit`, `undo`,
89
+ * `redo`, `cut`, `copy`, `paste`, `delete`, `selectAll`, `minimize`, `zoom`,
90
+ * `close`, `togglefullscreen`. The platform performs it -- the Copy that
91
+ * actually copies the field the person was in -- and `onSelect` still runs, so
92
+ * an app can both get the behaviour and hear about it.
93
+ *
94
+ * **A role this desktop cannot perform is left out of the menu**, rather than
95
+ * shown doing nothing. It keeps its index though: what comes back is an index
96
+ * into the list you passed, so adding a role that one platform lacks does not
97
+ * renumber the items after it.
98
+ *
99
+ * The three do not agree. macOS has all thirteen; Linux and Windows have
100
+ * twelve, both missing `about`, neither having a platform about panel to ask
101
+ * for -- that window is an app's own to show, and an ordinary item with an
102
+ * `onSelect` is how to open it.
103
+ */
104
+ role?: string;
105
+ /**
106
+ * A tick or a radio mark beside the label.
107
+ *
108
+ * `checked` on its own means a checkbox, so the common case is one word. The
109
+ * kind is a separate field because it has to be: a GMenu item carries no
110
+ * checked attribute, and GTK picks a tick or a circle from the shape of the
111
+ * action behind it, which a boolean cannot express.
112
+ *
113
+ * `'radio'` is a drawing hint, not a capability. Windows draws a bullet and
114
+ * Linux a circle; macOS draws a tick, `NSMenu` having no radio item and a tick
115
+ * being what Apple's guidance prescribes for a chosen member of a group.
116
+ *
117
+ * A group is a run of adjacent `'radio'` items, ended by a separator or by any
118
+ * other kind of item. There is no group name to pass. Exclusivity is yours:
119
+ * the menu is built fresh each time it opens, so it draws the marks you give
120
+ * it and keeping one member checked is the caller's.
121
+ */
122
+ type?: 'checkbox' | 'radio';
123
+ checked?: boolean;
124
+ /**
125
+ * Nested items. The parent is not choosable: it opens its children.
126
+ *
127
+ * Both a `submenu` and a `role` on one item is a mistake, and the submenu
128
+ * wins. A parent whose children are all roles this desktop cannot perform is
129
+ * left out with them, an empty submenu being a dead end rather than an item.
130
+ */
80
131
  submenu?: ReadonlyArray<ContextMenuItem>;
81
132
  onSelect?: () => void;
82
133
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useContextMenu.d.ts","sourceRoot":"","sources":["../../src/useContextMenu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAKH;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB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,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAYF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAsC,CAAC;AAE/D,iBAAe,IAAI,CACjB,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EACrC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAC9B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoBxB;AAyCD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;EAAqC,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C,wBAAgB,cAAc,IAAI,WAAW,CAK5C"}
@@ -92,9 +92,42 @@ async function show(items, where) {
92
92
  }
93
93
  // Called before the promise settles, so that an app which only wants
94
94
  // `onSelect` never has to await anything.
95
- items[index]?.onSelect?.();
95
+ itemAt(items, index)?.onSelect?.();
96
96
  return index;
97
97
  }
98
+ /**
99
+ * The item an index names, which is its position in a pre-order walk of the
100
+ * whole menu: an item, then its children, then the next item, counting
101
+ * separators and parents.
102
+ *
103
+ * For a flat list that is the position in the array, which is what this answered
104
+ * when a popup could only be flat, so an index means what it has always meant.
105
+ * The native side numbers its items the same way; see `walkMenuEntries` in
106
+ * core/PlatformServices.h, which is the other half of this contract.
107
+ *
108
+ * An item the platform left out still counts, which is what lets both sides
109
+ * agree without this knowing which roles the platform has: the native side
110
+ * numbers every entry it was given and draws only the ones it can. See
111
+ * `menuEntryShown` beside it.
112
+ */
113
+ function itemAt(items, index) {
114
+ let next = 0;
115
+ const walk = (level) => {
116
+ for (const item of level) {
117
+ if (next++ === index) {
118
+ return item;
119
+ }
120
+ if (item.submenu != null && item.submenu.length > 0) {
121
+ const found = walk(item.submenu);
122
+ if (found != null) {
123
+ return found;
124
+ }
125
+ }
126
+ }
127
+ return undefined;
128
+ };
129
+ return walk(items);
130
+ }
98
131
  /**
99
132
  * The imperative half, usable outside a component -- the same arrangement
100
133
  * `useDialog()` and `windowControl` have.
@@ -1 +1 @@
1
- {"version":3,"file":"useContextMenu.js","sourceRoot":"","sources":["../../src/useContextMenu.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;;;AAuFH,wCAKC;AAzFD,+CAAiD;AAyCjD,MAAM,UAAU,GAAG,kCAAmB,CAAC,GAAG,CAAmB,YAAY,CAAC,CAAC;AAE3E;;;;;GAKG;AACU,QAAA,WAAW,GAAG,UAAU,EAAE,eAAe,IAAI,IAAI,CAAC;AAE/D,KAAK,UAAU,IAAI,CACjB,KAAqC,EACrC,KAA+B;IAE/B,IAAI,CAAC,mBAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,4EAA4E;IAC5E,6EAA6E;IAC7E,2CAA2C;IAC3C,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IAEzC,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAM,KAAK,GAAG,MAAM,UAAW,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7D,IAAI,K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/keyhandler.tsx","../src/menu.tsx","../src/titlebar.tsx","../src/window.tsx","../src/closerequest.ts","../src/globals.d.ts","../src/index.ts","../src/quitrequest.ts","../src/resourcepath.ts","../src/responsebody.ts","../src/responseheaders.ts","../src/titlebarstate.ts","../src/usecontextmenu.ts","../src/usedialog.ts","../src/usedisplays.ts","../src/usehandledkeys.ts","../src/usewindow.ts","../src/overrides/alert.ts","../src/overrides/baseviewconfig.ts","../src/overrides/platform.d.ts","../src/overrides/platform.linux.ts","../src/overrides/platform.macos.ts","../src/overrides/platform.windows.ts","../src/overrides/reactdevtoolssettingsmanager.ts","../src/overrides/refreshcontrol.tsx","../src/overrides/scrollview.tsx","../src/overrides/share.ts","../src/overrides/textinput.tsx","../src/overrides/view.tsx","../src/overrides/createplatform.ts","../src/overrides/setupdevelopertools.ts","../src/overrides/setupxhr.ts","../src/overrides/upstream.d.ts","../cli/basalt.ts","../cli/bundle-cli.ts","../cli/bundlewithassets.ts","../cli/desktop.ts","../cli/doctor.ts","../cli/init.ts","../cli/metro.ts","../cli/packageapp.ts","../cli/steps.ts","../react-native.config.js"],"version":"6.0.3"}
1
+ {"root":["../src/DragSource.tsx","../src/DropTarget.tsx","../src/KeyHandler.tsx","../src/Menu.tsx","../src/TitleBar.tsx","../src/Window.tsx","../src/closeRequest.ts","../src/globals.d.ts","../src/index.ts","../src/quitRequest.ts","../src/resourcePath.ts","../src/responseBody.ts","../src/responseHeaders.ts","../src/titleBarState.ts","../src/useContextMenu.ts","../src/useDialog.ts","../src/useDisplays.ts","../src/useHandledKeys.ts","../src/useWindow.ts","../src/overrides/Alert.ts","../src/overrides/BaseViewConfig.ts","../src/overrides/Button.tsx","../src/overrides/Platform.d.ts","../src/overrides/Platform.linux.ts","../src/overrides/Platform.macos.ts","../src/overrides/Platform.windows.ts","../src/overrides/ReactDevToolsSettingsManager.ts","../src/overrides/RefreshControl.tsx","../src/overrides/ScrollView.tsx","../src/overrides/Settings.ts","../src/overrides/Share.ts","../src/overrides/TextInput.tsx","../src/overrides/View.tsx","../src/overrides/createPlatform.ts","../src/overrides/processDecelerationRate.ts","../src/overrides/setUpDeveloperTools.ts","../src/overrides/setUpXHR.ts","../src/overrides/upstream.d.ts","../cli/basalt.ts","../cli/bundle-cli.ts","../cli/bundleWithAssets.ts","../cli/desktop.ts","../cli/doctor.ts","../cli/init.ts","../cli/metro.ts","../cli/packageApp.ts","../cli/steps.ts","../react-native.config.js"],"version":"6.0.3"}