@oxyhq/bloom 1.8.0 → 1.9.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/docs/getting-started.mdx +50 -17
- package/docs/media-flight.mdx +19 -9
- package/lib/commonjs/connection-status/index.js +7 -0
- package/lib/commonjs/connection-status/index.js.map +1 -1
- package/lib/commonjs/connection-status/index.web.js +7 -0
- package/lib/commonjs/connection-status/index.web.js.map +1 -1
- package/lib/commonjs/connection-status/netinfo.js +41 -0
- package/lib/commonjs/connection-status/netinfo.js.map +1 -1
- package/lib/commonjs/theme/adaptive-colors.js +30 -4
- package/lib/commonjs/theme/adaptive-colors.js.map +1 -1
- package/lib/module/connection-status/index.js +3 -0
- package/lib/module/connection-status/index.js.map +1 -1
- package/lib/module/connection-status/index.web.js +3 -0
- package/lib/module/connection-status/index.web.js.map +1 -1
- package/lib/module/connection-status/netinfo.js +40 -0
- package/lib/module/connection-status/netinfo.js.map +1 -1
- package/lib/module/theme/adaptive-colors.js +30 -4
- package/lib/module/theme/adaptive-colors.js.map +1 -1
- package/lib/typescript/commonjs/connection-status/index.d.ts +1 -0
- package/lib/typescript/commonjs/connection-status/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/connection-status/index.web.d.ts +1 -0
- package/lib/typescript/commonjs/connection-status/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/connection-status/netinfo.d.ts +32 -0
- package/lib/typescript/commonjs/connection-status/netinfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/adaptive-colors.d.ts.map +1 -1
- package/lib/typescript/module/connection-status/index.d.ts +1 -0
- package/lib/typescript/module/connection-status/index.d.ts.map +1 -1
- package/lib/typescript/module/connection-status/index.web.d.ts +1 -0
- package/lib/typescript/module/connection-status/index.web.d.ts.map +1 -1
- package/lib/typescript/module/connection-status/netinfo.d.ts +32 -0
- package/lib/typescript/module/connection-status/netinfo.d.ts.map +1 -1
- package/lib/typescript/module/theme/adaptive-colors.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connection-status/index.ts +3 -0
- package/src/connection-status/index.web.ts +3 -0
- package/src/connection-status/netinfo.ts +40 -0
- package/src/theme/adaptive-colors.ts +37 -4
package/docs/getting-started.mdx
CHANGED
|
@@ -67,18 +67,54 @@ export function Hello() {
|
|
|
67
67
|
## If you build with Vite (or any ESM web bundler)
|
|
68
68
|
|
|
69
69
|
Bloom reaches its **optional** peers through a `require()` that Metro marks
|
|
70
|
-
optional.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
optional. Off Metro that load does not deliver the package **even when it is
|
|
71
|
+
installed** — and the reason depends on your bundler, which is why this defect
|
|
72
|
+
keeps being diagnosed wrongly:
|
|
73
|
+
|
|
74
|
+
| bundler | what the guard sees | what happens |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| Rollup / Vite (classic) | no `require` | the guard degrades |
|
|
77
|
+
| esbuild | a shim that THROWS | the guard passes, the call fails inside the `try` |
|
|
78
|
+
| Vite 8 / Rolldown | `__require`, a Proxy-backed **function** | the guard passes, the call throws `Calling 'require' for "…" in an environment that doesn't expose the 'require' function` |
|
|
79
|
+
|
|
80
|
+
**Do not test this with `typeof require` in your console.** Measured in a real
|
|
81
|
+
Rolldown app: the console answers `"undefined"` while the COMPILED guard is
|
|
82
|
+
consulting an imported `__require` that is a function — so the one-line check
|
|
83
|
+
reports the first row while the bundle is in the third. It does not distinguish
|
|
84
|
+
the cases, it confuses them. Read the dev warning's `Reason:` instead; it is the
|
|
85
|
+
bundler's own message.
|
|
86
|
+
|
|
87
|
+
Metro is unaffected.
|
|
88
|
+
|
|
89
|
+
**On web you lose one thing: `expo-video`.** `MediaSurface` loads it on every
|
|
90
|
+
platform, so a web app that flies video without handing it over gets the poster.
|
|
91
|
+
That is what `provideExpoVideo` below is for.
|
|
92
|
+
|
|
93
|
+
**The connection toasts are NOT affected**, though this guide said they were
|
|
94
|
+
until it was checked: `./connection-status` ships a web implementation
|
|
95
|
+
(`ConnectionStatusToasts.web.tsx`) built on `navigator.onLine` and the
|
|
96
|
+
`online`/`offline` events, so `loadNetInfo` is never called in a browser and
|
|
97
|
+
netinfo need not be installed at all.
|
|
98
|
+
|
|
99
|
+
**The other optional peers are NOT affected on web**, because their callers
|
|
100
|
+
return before the `require` is ever reached:
|
|
101
|
+
|
|
102
|
+
| peer | why web never reaches it |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| `@react-native-community/netinfo` | the family has a WEB FORK that uses `navigator.onLine` (`connection-status/index.web.ts` → `ConnectionStatusToasts.web.tsx`) |
|
|
105
|
+
| `expo-router` (adaptive colours) | `getAdaptiveColors` returns `null` unless `Platform.OS` is `android`/`ios` (`theme/adaptive-colors.ts:143-145`) |
|
|
106
|
+
| `nativewind` (scoped presets) | both callers `return` on web (`theme/color-scope/style-builder.ts:159, :192`) |
|
|
107
|
+
| `expo-haptics` | `useHaptics` returns on web (`hooks/use-haptics.tsx:47`) |
|
|
108
|
+
|
|
109
|
+
Note the two different reasons: a platform guard inside the file, and a whole
|
|
110
|
+
`.web` fork of the family. Checking only the first is how this guide came to
|
|
111
|
+
name the connection toasts.
|
|
112
|
+
|
|
113
|
+
If scoped NativeWind presets are wrong in your web app, this is not the cause —
|
|
114
|
+
look at the CSS-variable pipeline instead.
|
|
115
|
+
|
|
116
|
+
The one that matters on web is handed over in a line, and it works on any
|
|
117
|
+
bundler:
|
|
82
118
|
|
|
83
119
|
```ts
|
|
84
120
|
import * as ExpoVideo from 'expo-video';
|
|
@@ -87,11 +123,8 @@ import { provideExpoVideo } from '@oxyhq/bloom/media-flight';
|
|
|
87
123
|
provideExpoVideo(ExpoVideo); // otherwise video silently shows only its poster
|
|
88
124
|
```
|
|
89
125
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
connection toasts. Most of them say so in the dev console — the warning ends
|
|
93
|
-
`Reason: this bundle has no CommonJS require` — with the exception noted in
|
|
94
|
-
`theme/adaptive-colors.ts`, which degrades silently.
|
|
126
|
+
`provideNetInfo` exists in `@oxyhq/bloom/connection-status` for the same
|
|
127
|
+
purpose, but a browser does not need it — see above.
|
|
95
128
|
|
|
96
129
|
## Recommended layout
|
|
97
130
|
|
package/docs/media-flight.mdx
CHANGED
|
@@ -583,13 +583,24 @@ flies video without it gets the poster plus a single dev warning naming the
|
|
|
583
583
|
package.
|
|
584
584
|
|
|
585
585
|
<Callout variant="warning" title="On Vite (or any ESM web bundler) you must hand expo-video over">
|
|
586
|
-
Bloom loads optional peers through a `require()` that Metro marks optional.
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
poster **even when `expo-video` is installed**. Metro has a real `require` and
|
|
590
|
-
is unaffected, which is why this only shows up off Metro.
|
|
586
|
+
Bloom loads optional peers through a `require()` that Metro marks optional. Off
|
|
587
|
+
Metro that load does not deliver the package **even when `expo-video` is
|
|
588
|
+
installed**, and video degrades to its poster.
|
|
591
589
|
|
|
592
|
-
|
|
590
|
+
**Do not test for this with `typeof require`.** The cause depends on the
|
|
591
|
+
bundler and the symptom does not:
|
|
592
|
+
|
|
593
|
+
| bundler | what the guard sees | what happens |
|
|
594
|
+
| --- | --- | --- |
|
|
595
|
+
| Rollup / Vite (classic) | no `require` | the guard degrades |
|
|
596
|
+
| esbuild | a shim that THROWS | the guard passes, the call fails inside the `try` |
|
|
597
|
+
| Vite 8 / Rolldown | `__require`, a Proxy-backed **function** | the guard passes, the call throws |
|
|
598
|
+
|
|
599
|
+
And `typeof require` in your console does NOT tell you which one you are in: in
|
|
600
|
+
a real Rolldown app it answers `"undefined"` while the compiled guard consults
|
|
601
|
+
an imported `__require` that is a function.
|
|
602
|
+
|
|
603
|
+
One line at startup fixes it, on any bundler:
|
|
593
604
|
|
|
594
605
|
```ts
|
|
595
606
|
import * as ExpoVideo from 'expo-video';
|
|
@@ -598,9 +609,8 @@ import { provideExpoVideo } from '@oxyhq/bloom/media-flight';
|
|
|
598
609
|
provideExpoVideo(ExpoVideo);
|
|
599
610
|
```
|
|
600
611
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
so directly — the warning ends `Reason: this bundle has no CommonJS require`.
|
|
612
|
+
The dev console says so too, and the `Reason:` it prints is the bundler's own
|
|
613
|
+
message rather than a fixed string.
|
|
604
614
|
</Callout>
|
|
605
615
|
|
|
606
616
|
## What a jest run can and cannot see
|
|
@@ -9,5 +9,12 @@ Object.defineProperty(exports, "ConnectionStatusToasts", {
|
|
|
9
9
|
return _ConnectionStatusToasts.ConnectionStatusToasts;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "provideNetInfo", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _netinfo.provideNetInfo;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _netinfo = require("./netinfo.js");
|
|
12
19
|
var _ConnectionStatusToasts = require("./ConnectionStatusToasts");
|
|
13
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_netinfo","require","_ConnectionStatusToasts"],"sourceRoot":"../../../src","sources":["connection-status/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -9,5 +9,12 @@ Object.defineProperty(exports, "ConnectionStatusToasts", {
|
|
|
9
9
|
return _ConnectionStatusToastsWeb.ConnectionStatusToasts;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "provideNetInfo", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _netinfo.provideNetInfo;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _netinfo = require("./netinfo.js");
|
|
12
19
|
var _ConnectionStatusToastsWeb = require("./ConnectionStatusToasts.web.js");
|
|
13
20
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_netinfo","require","_ConnectionStatusToastsWeb"],"sourceRoot":"../../../src","sources":["connection-status/index.web.ts"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.loadNetInfo = loadNetInfo;
|
|
7
|
+
exports.provideNetInfo = provideNetInfo;
|
|
7
8
|
exports.warnNetInfoUnavailable = warnNetInfoUnavailable;
|
|
8
9
|
/**
|
|
9
10
|
* The optional-peer boundary for `@react-native-community/netinfo`.
|
|
@@ -68,12 +69,52 @@ exports.warnNetInfoUnavailable = warnNetInfoUnavailable;
|
|
|
68
69
|
|
|
69
70
|
/** `undefined` until the first load attempt, then the module or `null`. */
|
|
70
71
|
let netInfoModule;
|
|
72
|
+
/** Handed in by a consumer, which is the only thing that works in an ESM bundle. */
|
|
73
|
+
let providedModule = null;
|
|
71
74
|
/** Why the load failed, quoted verbatim in the dev warning. */
|
|
72
75
|
let unavailableReason = '';
|
|
73
76
|
let hasWarned = false;
|
|
74
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Hand Bloom the netinfo module, from a consumer that has it.
|
|
80
|
+
*
|
|
81
|
+
* THIS IS NOT A TEST HOOK. It is the only mechanism that works in an ESM
|
|
82
|
+
* bundle: the consumer, who knows it has the peer and which entry of it its own
|
|
83
|
+
* bundler resolved, hands the module in.
|
|
84
|
+
*
|
|
85
|
+
* A BROWSER DOES NOT NEED IT. `connection-status/index.web.ts` resolves to
|
|
86
|
+
* `ConnectionStatusToasts.web.tsx`, which uses `navigator.onLine` and the
|
|
87
|
+
* `online`/`offline` events and never calls `loadNetInfo` — measured in a real
|
|
88
|
+
* Vite/Rolldown app, where netinfo was installed, unused, and absent from every
|
|
89
|
+
* chunk. This hatch is for a NON-Metro bundle that still takes the native path:
|
|
90
|
+
* an SSR pass, a test runner, a future non-Metro native bundler.
|
|
91
|
+
*
|
|
92
|
+
* The `require` below cannot be relied on off Metro, and the reason is worth
|
|
93
|
+
* knowing because the symptom is identical while the cause is not:
|
|
94
|
+
*
|
|
95
|
+
* - Rollup / Vite ESM output: `require` is undefined, the guard catches it,
|
|
96
|
+
* and the boundary degrades.
|
|
97
|
+
* - esbuild ESM output: `require` EXISTS as a shim that throws
|
|
98
|
+
* (`Dynamic require of "…" is not supported`), so the guard PASSES and the
|
|
99
|
+
* call throws inside the try. Measured with the peer installed on disk:
|
|
100
|
+
* `platform=node` and `platform=browser` both degraded.
|
|
101
|
+
*
|
|
102
|
+
* So a fix aimed at the `typeof require` check would have changed nothing under
|
|
103
|
+
* esbuild. And there is no synchronous, bundler-agnostic alternative: `import()`
|
|
104
|
+
* is asynchronous AND resolved at build time, so an absent package fails the
|
|
105
|
+
* BUILD — which is what this boundary exists to prevent.
|
|
106
|
+
*
|
|
107
|
+
* Metro is unaffected either way and needs no binding.
|
|
108
|
+
*/
|
|
109
|
+
function provideNetInfo(module) {
|
|
110
|
+
providedModule = module;
|
|
111
|
+
netInfoModule = undefined;
|
|
112
|
+
hasWarned = false;
|
|
113
|
+
}
|
|
114
|
+
|
|
75
115
|
/** The netinfo module, or `null` when the optional peer is not installed. */
|
|
76
116
|
function loadNetInfo() {
|
|
117
|
+
if (providedModule !== null) return providedModule;
|
|
77
118
|
if (netInfoModule !== undefined) return netInfoModule;
|
|
78
119
|
netInfoModule = null;
|
|
79
120
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["netInfoModule","unavailableReason","hasWarned","
|
|
1
|
+
{"version":3,"names":["netInfoModule","providedModule","unavailableReason","hasWarned","provideNetInfo","module","undefined","loadNetInfo","require","loaded","resolved","addEventListener","default","error","Error","message","String","warnNetInfoUnavailable","process","env","NODE_ENV","console","warn"],"sourceRoot":"../../../src","sources":["connection-status/netinfo.ts"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAGA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,IAAIA,aAA6C;AACjD;AACA,IAAIC,cAAkC,GAAG,IAAI;AAC7C;AACA,IAAIC,iBAAiB,GAAG,EAAE;AAC1B,IAAIC,SAAS,GAAG,KAAK;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,MAA0B,EAAQ;EAC/DJ,cAAc,GAAGI,MAAM;EACvBL,aAAa,GAAGM,SAAS;EACzBH,SAAS,GAAG,KAAK;AACnB;;AAEA;AACO,SAASI,WAAWA,CAAA,EAAuB;EAChD,IAAIN,cAAc,KAAK,IAAI,EAAE,OAAOA,cAAc;EAClD,IAAID,aAAa,KAAKM,SAAS,EAAE,OAAON,aAAa;EACrDA,aAAa,GAAG,IAAI;;EAEpB;EACA;EACA;EACA;EACA,IAAI,OAAOQ,OAAO,KAAK,WAAW,EAAE;IAClCN,iBAAiB,GAAG,uCAAuC;IAC3D,OAAOF,aAAa;EACtB;EAEA,IAAI;IACF;IACA;IACA;IACA,MAAMS,MAAM,GAAGD,OAAO,CAAC,iCAAiC,CAG3C;IACb,MAAME,QAAQ,GAAG,OAAOD,MAAM,EAAEE,gBAAgB,KAAK,UAAU,GAAGF,MAAM,GAAGA,MAAM,EAAEG,OAAO;IAE1F,IAAI,OAAOF,QAAQ,EAAEC,gBAAgB,KAAK,UAAU,EAAE;MACpDX,aAAa,GAAGU,QAAuB;IACzC,CAAC,MAAM;MACLR,iBAAiB,GAAG,0DAA0D;IAChF;EACF,CAAC,CAAC,OAAOW,KAAK,EAAE;IACdX,iBAAiB,GAAGW,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC;EAC5E;EAEA,OAAOb,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,sBAAsBA,CAAA,EAAS;EAC7C,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIjB,SAAS,EAAE;EACxDA,SAAS,GAAG,IAAI;EAChB;EACA;EACA;EACAkB,OAAO,CAACC,IAAI,CACV,6DAA6D,GAC3D,+EAA+E,GAC/E,8EAA8E,GAC9E,6EAA6E,GAC7E,oDAAoDpB,iBAAiB,EACzE,CAAC;AACH","ignoreList":[]}
|
|
@@ -41,9 +41,30 @@ var _reactNative = require("react-native");
|
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
43
|
const c = v => v;
|
|
44
|
+
let hasWarned = false;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* SAY SO. This boundary degraded in complete silence, which is the worst of the
|
|
48
|
+
* six: an app simply gets the preset palette instead of the platform's, and
|
|
49
|
+
* nothing anywhere says the platform read failed.
|
|
50
|
+
*
|
|
51
|
+
* It is only reachable on Android and iOS — `getAdaptiveColors` returns `null`
|
|
52
|
+
* on web before touching `require` — so an ESM bundle never gets here. That is
|
|
53
|
+
* an argument for warning, not against it: a failure that cannot happen in the
|
|
54
|
+
* environment you test in is exactly the one that goes unnoticed when it does.
|
|
55
|
+
*/
|
|
56
|
+
function warnAdaptiveColorsUnavailable(reason) {
|
|
57
|
+
if (process.env.NODE_ENV === 'production' || hasWarned) return;
|
|
58
|
+
hasWarned = true;
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.warn('[Bloom] The adaptive palette fell back to the preset one: `expo-router`’s ' + '`Color` proxy could not be read, so platform colours (Material You, iOS ' + 'dynamic) are not in use. Install the optional peer ' + '(`npx expo install expo-router`) if you want them. ' + `Reason: ${reason}`);
|
|
61
|
+
}
|
|
44
62
|
function getAndroidColors() {
|
|
45
63
|
try {
|
|
46
|
-
if (typeof require === 'undefined')
|
|
64
|
+
if (typeof require === 'undefined') {
|
|
65
|
+
warnAdaptiveColorsUnavailable('this bundle has no CommonJS `require`');
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
47
68
|
const {
|
|
48
69
|
Color
|
|
49
70
|
} = require('expo-router');
|
|
@@ -83,13 +104,17 @@ function getAndroidColors() {
|
|
|
83
104
|
shadow: 'rgba(0, 0, 0, 0.2)',
|
|
84
105
|
overlay: 'rgba(0, 0, 0, 0.5)'
|
|
85
106
|
};
|
|
86
|
-
} catch {
|
|
107
|
+
} catch (error) {
|
|
108
|
+
warnAdaptiveColorsUnavailable(error instanceof Error ? error.message : String(error));
|
|
87
109
|
return null;
|
|
88
110
|
}
|
|
89
111
|
}
|
|
90
112
|
function getIOSColors() {
|
|
91
113
|
try {
|
|
92
|
-
if (typeof require === 'undefined')
|
|
114
|
+
if (typeof require === 'undefined') {
|
|
115
|
+
warnAdaptiveColorsUnavailable('this bundle has no CommonJS `require`');
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
93
118
|
const {
|
|
94
119
|
Color
|
|
95
120
|
} = require('expo-router');
|
|
@@ -129,7 +154,8 @@ function getIOSColors() {
|
|
|
129
154
|
shadow: 'rgba(0, 0, 0, 0.15)',
|
|
130
155
|
overlay: 'rgba(0, 0, 0, 0.5)'
|
|
131
156
|
};
|
|
132
|
-
} catch {
|
|
157
|
+
} catch (error) {
|
|
158
|
+
warnAdaptiveColorsUnavailable(error instanceof Error ? error.message : String(error));
|
|
133
159
|
return null;
|
|
134
160
|
}
|
|
135
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","c","v","getAndroidColors","Color","d","android","dynamic","background","surface","backgroundSecondary","surfaceContainerLow","backgroundTertiary","surfaceContainer","text","onSurface","textSecondary","onSurfaceVariant","textTertiary","outline","border","outlineVariant","borderLight","primary","primaryForeground","onPrimary","primaryLight","primaryContainer","primaryDark","onPrimaryContainer","secondary","secondaryForeground","onSecondary","tertiary","tertiaryForeground","onTertiary","tint","icon","iconActive","success","error","warning","info","primarySubtle","primarySubtleForeground","negative","negativeForeground","negativeSubtle","errorContainer","negativeSubtleForeground","onErrorContainer","contrast50","card","shadow","overlay","getIOSColors","i","ios","systemBackground","secondarySystemBackground","tertiarySystemBackground","label","secondaryLabel","tertiaryLabel","separator","opaqueSeparator","systemBlue","systemGray6","systemPurple","systemTeal","systemGreen","systemRed","systemOrange","getAdaptiveColors","Platform","OS"],"sourceRoot":"../../../src","sources":["theme/adaptive-colors.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,MAAMC,CAAC,GAAIC,CAAU,IAAaA,CAAW;AAE7C,SAASC,gBAAgBA,CAAA,EAA0B;EACjD,IAAI;IACF,IAAI,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","c","v","hasWarned","warnAdaptiveColorsUnavailable","reason","process","env","NODE_ENV","console","warn","getAndroidColors","Color","d","android","dynamic","background","surface","backgroundSecondary","surfaceContainerLow","backgroundTertiary","surfaceContainer","text","onSurface","textSecondary","onSurfaceVariant","textTertiary","outline","border","outlineVariant","borderLight","primary","primaryForeground","onPrimary","primaryLight","primaryContainer","primaryDark","onPrimaryContainer","secondary","secondaryForeground","onSecondary","tertiary","tertiaryForeground","onTertiary","tint","icon","iconActive","success","error","warning","info","primarySubtle","primarySubtleForeground","negative","negativeForeground","negativeSubtle","errorContainer","negativeSubtleForeground","onErrorContainer","contrast50","card","shadow","overlay","Error","message","String","getIOSColors","i","ios","systemBackground","secondarySystemBackground","tertiarySystemBackground","label","secondaryLabel","tertiaryLabel","separator","opaqueSeparator","systemBlue","systemGray6","systemPurple","systemTeal","systemGreen","systemRed","systemOrange","getAdaptiveColors","Platform","OS"],"sourceRoot":"../../../src","sources":["theme/adaptive-colors.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,MAAMC,CAAC,GAAIC,CAAU,IAAaA,CAAW;AAE7C,IAAIC,SAAS,GAAG,KAAK;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAACC,MAAc,EAAQ;EAC3D,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIL,SAAS,EAAE;EACxDA,SAAS,GAAG,IAAI;EAChB;EACAM,OAAO,CAACC,IAAI,CACV,4EAA4E,GAC1E,0EAA0E,GAC1E,qDAAqD,GACrD,qDAAqD,GACrD,WAAWL,MAAM,EACrB,CAAC;AACH;AAEA,SAASM,gBAAgBA,CAAA,EAA0B;EACjD,IAAI;IACF,IAAI,OAAOX,OAAO,KAAK,WAAW,EAAE;MAClCI,6BAA6B,CAAC,uCAAuC,CAAC;MACtE,OAAO,IAAI;IACb;IACA,MAAM;MAAEQ;IAAM,CAAC,GAAGZ,OAAO,CAAC,aAAa,CAAC;IACxC,MAAMa,CAAC,GAAGD,KAAK,CAACE,OAAO,CA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B5B,kBAAkB,EAAE,SAAS;MAC7BC,cAAc,EAAEtD,CAAC,CAACkE,CAAC,CAACW,WAAW,CAAC;MAChCrB,wBAAwB,EAAExD,CAAC,CAACkE,CAAC,CAACe,SAAS,CAAC;MACxCvB,UAAU,EAAE1D,CAAC,CAACkE,CAAC,CAACW,WAAW,CAAC;MAC5BlB,IAAI,EAAE3D,CAAC,CAACkE,CAAC,CAACG,yBAAyB,CAAC;MACpCT,MAAM,EAAE,qBAAqB;MAC7BC,OAAO,EAAE;IACX,CAAC;EACH,CAAC,CAAC,OAAOd,KAAK,EAAE;IACd5C,6BAA6B,CAAC4C,KAAK,YAAYe,KAAK,GAAGf,KAAK,CAACgB,OAAO,GAAGC,MAAM,CAACjB,KAAK,CAAC,CAAC;IACrF,OAAO,IAAI;EACb;AACF;AAEO,SAASoC,iBAAiBA,CAAA,EAA0B;EACzD,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE,OAAO3E,gBAAgB,CAAC,CAAC;EACxD,IAAI0E,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE,OAAOpB,YAAY,CAAC,CAAC;EAChD,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// The hatch a consumer needs off Metro, where the optional `require` does not
|
|
4
|
+
// deliver the peer even when it is installed. See `netinfo.ts`.
|
|
5
|
+
export { provideNetInfo } from "./netinfo.js";
|
|
3
6
|
export { ConnectionStatusToasts } from './ConnectionStatusToasts';
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConnectionStatusToasts"],"sourceRoot":"../../../src","sources":["connection-status/index.ts"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"names":["provideNetInfo","ConnectionStatusToasts"],"sourceRoot":"../../../src","sources":["connection-status/index.ts"],"mappings":";;AACA;AACA;AACA,SAASA,cAAc,QAA0B,cAAW;AAC5D,SACEC,sBAAsB,QACjB,0BAA0B","ignoreList":[]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// The hatch a consumer needs off Metro, where the optional `require` does not
|
|
4
|
+
// deliver the peer even when it is installed. See `netinfo.ts`.
|
|
5
|
+
export { provideNetInfo } from "./netinfo.js";
|
|
3
6
|
export { ConnectionStatusToasts } from "./ConnectionStatusToasts.web.js";
|
|
4
7
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConnectionStatusToasts"],"sourceRoot":"../../../src","sources":["connection-status/index.web.ts"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"names":["provideNetInfo","ConnectionStatusToasts"],"sourceRoot":"../../../src","sources":["connection-status/index.web.ts"],"mappings":";;AACA;AACA;AACA,SAASA,cAAc,QAA0B,cAAW;AAC5D,SACEC,sBAAsB,QACjB,iCAA8B","ignoreList":[]}
|
|
@@ -63,12 +63,52 @@
|
|
|
63
63
|
|
|
64
64
|
/** `undefined` until the first load attempt, then the module or `null`. */
|
|
65
65
|
let netInfoModule;
|
|
66
|
+
/** Handed in by a consumer, which is the only thing that works in an ESM bundle. */
|
|
67
|
+
let providedModule = null;
|
|
66
68
|
/** Why the load failed, quoted verbatim in the dev warning. */
|
|
67
69
|
let unavailableReason = '';
|
|
68
70
|
let hasWarned = false;
|
|
69
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Hand Bloom the netinfo module, from a consumer that has it.
|
|
74
|
+
*
|
|
75
|
+
* THIS IS NOT A TEST HOOK. It is the only mechanism that works in an ESM
|
|
76
|
+
* bundle: the consumer, who knows it has the peer and which entry of it its own
|
|
77
|
+
* bundler resolved, hands the module in.
|
|
78
|
+
*
|
|
79
|
+
* A BROWSER DOES NOT NEED IT. `connection-status/index.web.ts` resolves to
|
|
80
|
+
* `ConnectionStatusToasts.web.tsx`, which uses `navigator.onLine` and the
|
|
81
|
+
* `online`/`offline` events and never calls `loadNetInfo` — measured in a real
|
|
82
|
+
* Vite/Rolldown app, where netinfo was installed, unused, and absent from every
|
|
83
|
+
* chunk. This hatch is for a NON-Metro bundle that still takes the native path:
|
|
84
|
+
* an SSR pass, a test runner, a future non-Metro native bundler.
|
|
85
|
+
*
|
|
86
|
+
* The `require` below cannot be relied on off Metro, and the reason is worth
|
|
87
|
+
* knowing because the symptom is identical while the cause is not:
|
|
88
|
+
*
|
|
89
|
+
* - Rollup / Vite ESM output: `require` is undefined, the guard catches it,
|
|
90
|
+
* and the boundary degrades.
|
|
91
|
+
* - esbuild ESM output: `require` EXISTS as a shim that throws
|
|
92
|
+
* (`Dynamic require of "…" is not supported`), so the guard PASSES and the
|
|
93
|
+
* call throws inside the try. Measured with the peer installed on disk:
|
|
94
|
+
* `platform=node` and `platform=browser` both degraded.
|
|
95
|
+
*
|
|
96
|
+
* So a fix aimed at the `typeof require` check would have changed nothing under
|
|
97
|
+
* esbuild. And there is no synchronous, bundler-agnostic alternative: `import()`
|
|
98
|
+
* is asynchronous AND resolved at build time, so an absent package fails the
|
|
99
|
+
* BUILD — which is what this boundary exists to prevent.
|
|
100
|
+
*
|
|
101
|
+
* Metro is unaffected either way and needs no binding.
|
|
102
|
+
*/
|
|
103
|
+
export function provideNetInfo(module) {
|
|
104
|
+
providedModule = module;
|
|
105
|
+
netInfoModule = undefined;
|
|
106
|
+
hasWarned = false;
|
|
107
|
+
}
|
|
108
|
+
|
|
70
109
|
/** The netinfo module, or `null` when the optional peer is not installed. */
|
|
71
110
|
export function loadNetInfo() {
|
|
111
|
+
if (providedModule !== null) return providedModule;
|
|
72
112
|
if (netInfoModule !== undefined) return netInfoModule;
|
|
73
113
|
netInfoModule = null;
|
|
74
114
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["netInfoModule","unavailableReason","hasWarned","
|
|
1
|
+
{"version":3,"names":["netInfoModule","providedModule","unavailableReason","hasWarned","provideNetInfo","module","undefined","loadNetInfo","require","loaded","resolved","addEventListener","default","error","Error","message","String","warnNetInfoUnavailable","process","env","NODE_ENV","console","warn"],"sourceRoot":"../../../src","sources":["connection-status/netinfo.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAGA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,IAAIA,aAA6C;AACjD;AACA,IAAIC,cAAkC,GAAG,IAAI;AAC7C;AACA,IAAIC,iBAAiB,GAAG,EAAE;AAC1B,IAAIC,SAAS,GAAG,KAAK;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,MAA0B,EAAQ;EAC/DJ,cAAc,GAAGI,MAAM;EACvBL,aAAa,GAAGM,SAAS;EACzBH,SAAS,GAAG,KAAK;AACnB;;AAEA;AACA,OAAO,SAASI,WAAWA,CAAA,EAAuB;EAChD,IAAIN,cAAc,KAAK,IAAI,EAAE,OAAOA,cAAc;EAClD,IAAID,aAAa,KAAKM,SAAS,EAAE,OAAON,aAAa;EACrDA,aAAa,GAAG,IAAI;;EAEpB;EACA;EACA;EACA;EACA,IAAI,OAAOQ,OAAO,KAAK,WAAW,EAAE;IAClCN,iBAAiB,GAAG,uCAAuC;IAC3D,OAAOF,aAAa;EACtB;EAEA,IAAI;IACF;IACA;IACA;IACA,MAAMS,MAAM,GAAGD,OAAO,CAAC,iCAAiC,CAG3C;IACb,MAAME,QAAQ,GAAG,OAAOD,MAAM,EAAEE,gBAAgB,KAAK,UAAU,GAAGF,MAAM,GAAGA,MAAM,EAAEG,OAAO;IAE1F,IAAI,OAAOF,QAAQ,EAAEC,gBAAgB,KAAK,UAAU,EAAE;MACpDX,aAAa,GAAGU,QAAuB;IACzC,CAAC,MAAM;MACLR,iBAAiB,GAAG,0DAA0D;IAChF;EACF,CAAC,CAAC,OAAOW,KAAK,EAAE;IACdX,iBAAiB,GAAGW,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC;EAC5E;EAEA,OAAOb,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiB,sBAAsBA,CAAA,EAAS;EAC7C,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIjB,SAAS,EAAE;EACxDA,SAAS,GAAG,IAAI;EAChB;EACA;EACA;EACAkB,OAAO,CAACC,IAAI,CACV,6DAA6D,GAC3D,+EAA+E,GAC/E,8EAA8E,GAC9E,6EAA6E,GAC7E,oDAAoDpB,iBAAiB,EACzE,CAAC;AACH","ignoreList":[]}
|
|
@@ -38,9 +38,30 @@ import { Platform } from 'react-native';
|
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
const c = v => v;
|
|
41
|
+
let hasWarned = false;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* SAY SO. This boundary degraded in complete silence, which is the worst of the
|
|
45
|
+
* six: an app simply gets the preset palette instead of the platform's, and
|
|
46
|
+
* nothing anywhere says the platform read failed.
|
|
47
|
+
*
|
|
48
|
+
* It is only reachable on Android and iOS — `getAdaptiveColors` returns `null`
|
|
49
|
+
* on web before touching `require` — so an ESM bundle never gets here. That is
|
|
50
|
+
* an argument for warning, not against it: a failure that cannot happen in the
|
|
51
|
+
* environment you test in is exactly the one that goes unnoticed when it does.
|
|
52
|
+
*/
|
|
53
|
+
function warnAdaptiveColorsUnavailable(reason) {
|
|
54
|
+
if (process.env.NODE_ENV === 'production' || hasWarned) return;
|
|
55
|
+
hasWarned = true;
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.warn('[Bloom] The adaptive palette fell back to the preset one: `expo-router`’s ' + '`Color` proxy could not be read, so platform colours (Material You, iOS ' + 'dynamic) are not in use. Install the optional peer ' + '(`npx expo install expo-router`) if you want them. ' + `Reason: ${reason}`);
|
|
58
|
+
}
|
|
41
59
|
function getAndroidColors() {
|
|
42
60
|
try {
|
|
43
|
-
if (typeof require === 'undefined')
|
|
61
|
+
if (typeof require === 'undefined') {
|
|
62
|
+
warnAdaptiveColorsUnavailable('this bundle has no CommonJS `require`');
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
44
65
|
const {
|
|
45
66
|
Color
|
|
46
67
|
} = require('expo-router');
|
|
@@ -80,13 +101,17 @@ function getAndroidColors() {
|
|
|
80
101
|
shadow: 'rgba(0, 0, 0, 0.2)',
|
|
81
102
|
overlay: 'rgba(0, 0, 0, 0.5)'
|
|
82
103
|
};
|
|
83
|
-
} catch {
|
|
104
|
+
} catch (error) {
|
|
105
|
+
warnAdaptiveColorsUnavailable(error instanceof Error ? error.message : String(error));
|
|
84
106
|
return null;
|
|
85
107
|
}
|
|
86
108
|
}
|
|
87
109
|
function getIOSColors() {
|
|
88
110
|
try {
|
|
89
|
-
if (typeof require === 'undefined')
|
|
111
|
+
if (typeof require === 'undefined') {
|
|
112
|
+
warnAdaptiveColorsUnavailable('this bundle has no CommonJS `require`');
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
90
115
|
const {
|
|
91
116
|
Color
|
|
92
117
|
} = require('expo-router');
|
|
@@ -126,7 +151,8 @@ function getIOSColors() {
|
|
|
126
151
|
shadow: 'rgba(0, 0, 0, 0.15)',
|
|
127
152
|
overlay: 'rgba(0, 0, 0, 0.5)'
|
|
128
153
|
};
|
|
129
|
-
} catch {
|
|
154
|
+
} catch (error) {
|
|
155
|
+
warnAdaptiveColorsUnavailable(error instanceof Error ? error.message : String(error));
|
|
130
156
|
return null;
|
|
131
157
|
}
|
|
132
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","c","v","getAndroidColors","require","Color","d","android","dynamic","background","surface","backgroundSecondary","surfaceContainerLow","backgroundTertiary","surfaceContainer","text","onSurface","textSecondary","onSurfaceVariant","textTertiary","outline","border","outlineVariant","borderLight","primary","primaryForeground","onPrimary","primaryLight","primaryContainer","primaryDark","onPrimaryContainer","secondary","secondaryForeground","onSecondary","tertiary","tertiaryForeground","onTertiary","tint","icon","iconActive","success","error","warning","info","primarySubtle","primarySubtleForeground","negative","negativeForeground","negativeSubtle","errorContainer","negativeSubtleForeground","onErrorContainer","contrast50","card","shadow","overlay","getIOSColors","i","ios","systemBackground","secondarySystemBackground","tertiarySystemBackground","label","secondaryLabel","tertiaryLabel","separator","opaqueSeparator","systemBlue","systemGray6","systemPurple","systemTeal","systemGreen","systemRed","systemOrange","getAdaptiveColors","OS"],"sourceRoot":"../../../src","sources":["theme/adaptive-colors.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;;AAGvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,MAAMC,CAAC,GAAIC,CAAU,IAAaA,CAAW;AAE7C,SAASC,gBAAgBA,CAAA,EAA0B;EACjD,IAAI;IACF,IAAI,OAAOC,OAAO,KAAK,WAAW,EAAE,OAAO,IAAI;
|
|
1
|
+
{"version":3,"names":["Platform","c","v","hasWarned","warnAdaptiveColorsUnavailable","reason","process","env","NODE_ENV","console","warn","getAndroidColors","require","Color","d","android","dynamic","background","surface","backgroundSecondary","surfaceContainerLow","backgroundTertiary","surfaceContainer","text","onSurface","textSecondary","onSurfaceVariant","textTertiary","outline","border","outlineVariant","borderLight","primary","primaryForeground","onPrimary","primaryLight","primaryContainer","primaryDark","onPrimaryContainer","secondary","secondaryForeground","onSecondary","tertiary","tertiaryForeground","onTertiary","tint","icon","iconActive","success","error","warning","info","primarySubtle","primarySubtleForeground","negative","negativeForeground","negativeSubtle","errorContainer","negativeSubtleForeground","onErrorContainer","contrast50","card","shadow","overlay","Error","message","String","getIOSColors","i","ios","systemBackground","secondarySystemBackground","tertiarySystemBackground","label","secondaryLabel","tertiaryLabel","separator","opaqueSeparator","systemBlue","systemGray6","systemPurple","systemTeal","systemGreen","systemRed","systemOrange","getAdaptiveColors","OS"],"sourceRoot":"../../../src","sources":["theme/adaptive-colors.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;;AAGvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,MAAMC,CAAC,GAAIC,CAAU,IAAaA,CAAW;AAE7C,IAAIC,SAAS,GAAG,KAAK;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAACC,MAAc,EAAQ;EAC3D,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIL,SAAS,EAAE;EACxDA,SAAS,GAAG,IAAI;EAChB;EACAM,OAAO,CAACC,IAAI,CACV,4EAA4E,GAC1E,0EAA0E,GAC1E,qDAAqD,GACrD,qDAAqD,GACrD,WAAWL,MAAM,EACrB,CAAC;AACH;AAEA,SAASM,gBAAgBA,CAAA,EAA0B;EACjD,IAAI;IACF,IAAI,OAAOC,OAAO,KAAK,WAAW,EAAE;MAClCR,6BAA6B,CAAC,uCAAuC,CAAC;MACtE,OAAO,IAAI;IACb;IACA,MAAM;MAAES;IAAM,CAAC,GAAGD,OAAO,CAAC,aAAa,CAAC;IACxC,MAAME,CAAC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,CAAC,CAACe,SAAS,CAAC;MACxB5B,kBAAkB,EAAE,SAAS;MAC7BC,cAAc,EAAEvD,CAAC,CAACmE,CAAC,CAACW,WAAW,CAAC;MAChCrB,wBAAwB,EAAEzD,CAAC,CAACmE,CAAC,CAACe,SAAS,CAAC;MACxCvB,UAAU,EAAE3D,CAAC,CAACmE,CAAC,CAACW,WAAW,CAAC;MAC5BlB,IAAI,EAAE5D,CAAC,CAACmE,CAAC,CAACG,yBAAyB,CAAC;MACpCT,MAAM,EAAE,qBAAqB;MAC7BC,OAAO,EAAE;IACX,CAAC;EACH,CAAC,CAAC,OAAOd,KAAK,EAAE;IACd7C,6BAA6B,CAAC6C,KAAK,YAAYe,KAAK,GAAGf,KAAK,CAACgB,OAAO,GAAGC,MAAM,CAACjB,KAAK,CAAC,CAAC;IACrF,OAAO,IAAI;EACb;AACF;AAEA,OAAO,SAASoC,iBAAiBA,CAAA,EAA0B;EACzD,IAAIrF,QAAQ,CAACsF,EAAE,KAAK,SAAS,EAAE,OAAO3E,gBAAgB,CAAC,CAAC;EACxD,IAAIX,QAAQ,CAACsF,EAAE,KAAK,KAAK,EAAE,OAAOnB,YAAY,CAAC,CAAC;EAChD,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,sBAAsB,GACvB,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.web.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.web.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,sBAAsB,GACvB,MAAM,8BAA8B,CAAC"}
|
|
@@ -57,6 +57,38 @@ export interface NetInfoStateLike {
|
|
|
57
57
|
export interface NetInfoLike {
|
|
58
58
|
addEventListener: (listener: (state: NetInfoStateLike) => void) => () => void;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Hand Bloom the netinfo module, from a consumer that has it.
|
|
62
|
+
*
|
|
63
|
+
* THIS IS NOT A TEST HOOK. It is the only mechanism that works in an ESM
|
|
64
|
+
* bundle: the consumer, who knows it has the peer and which entry of it its own
|
|
65
|
+
* bundler resolved, hands the module in.
|
|
66
|
+
*
|
|
67
|
+
* A BROWSER DOES NOT NEED IT. `connection-status/index.web.ts` resolves to
|
|
68
|
+
* `ConnectionStatusToasts.web.tsx`, which uses `navigator.onLine` and the
|
|
69
|
+
* `online`/`offline` events and never calls `loadNetInfo` — measured in a real
|
|
70
|
+
* Vite/Rolldown app, where netinfo was installed, unused, and absent from every
|
|
71
|
+
* chunk. This hatch is for a NON-Metro bundle that still takes the native path:
|
|
72
|
+
* an SSR pass, a test runner, a future non-Metro native bundler.
|
|
73
|
+
*
|
|
74
|
+
* The `require` below cannot be relied on off Metro, and the reason is worth
|
|
75
|
+
* knowing because the symptom is identical while the cause is not:
|
|
76
|
+
*
|
|
77
|
+
* - Rollup / Vite ESM output: `require` is undefined, the guard catches it,
|
|
78
|
+
* and the boundary degrades.
|
|
79
|
+
* - esbuild ESM output: `require` EXISTS as a shim that throws
|
|
80
|
+
* (`Dynamic require of "…" is not supported`), so the guard PASSES and the
|
|
81
|
+
* call throws inside the try. Measured with the peer installed on disk:
|
|
82
|
+
* `platform=node` and `platform=browser` both degraded.
|
|
83
|
+
*
|
|
84
|
+
* So a fix aimed at the `typeof require` check would have changed nothing under
|
|
85
|
+
* esbuild. And there is no synchronous, bundler-agnostic alternative: `import()`
|
|
86
|
+
* is asynchronous AND resolved at build time, so an absent package fails the
|
|
87
|
+
* BUILD — which is what this boundary exists to prevent.
|
|
88
|
+
*
|
|
89
|
+
* Metro is unaffected either way and needs no binding.
|
|
90
|
+
*/
|
|
91
|
+
export declare function provideNetInfo(module: NetInfoLike | null): void;
|
|
60
92
|
/** The netinfo module, or `null` when the optional peer is not installed. */
|
|
61
93
|
export declare function loadNetInfo(): NetInfoLike | null;
|
|
62
94
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netinfo.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/netinfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AASH,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/E;
|
|
1
|
+
{"version":3,"file":"netinfo.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/netinfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AASH,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/E;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAI/D;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,WAAW,GAAG,IAAI,CAkChD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAa7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptive-colors.d.ts","sourceRoot":"","sources":["../../../../src/theme/adaptive-colors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,WAAW,EACT,eAAe,GACf,yBAAyB,GACzB,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,yBAAyB,GACzB,YAAY,GACZ,sBAAsB,CACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"adaptive-colors.d.ts","sourceRoot":"","sources":["../../../../src/theme/adaptive-colors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,WAAW,EACT,eAAe,GACf,yBAAyB,GACzB,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,yBAAyB,GACzB,YAAY,GACZ,sBAAsB,CACzB,CAAC;AA+HF,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAIzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,sBAAsB,GACvB,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.web.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/index.web.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,sBAAsB,GACvB,MAAM,8BAA8B,CAAC"}
|
|
@@ -57,6 +57,38 @@ export interface NetInfoStateLike {
|
|
|
57
57
|
export interface NetInfoLike {
|
|
58
58
|
addEventListener: (listener: (state: NetInfoStateLike) => void) => () => void;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Hand Bloom the netinfo module, from a consumer that has it.
|
|
62
|
+
*
|
|
63
|
+
* THIS IS NOT A TEST HOOK. It is the only mechanism that works in an ESM
|
|
64
|
+
* bundle: the consumer, who knows it has the peer and which entry of it its own
|
|
65
|
+
* bundler resolved, hands the module in.
|
|
66
|
+
*
|
|
67
|
+
* A BROWSER DOES NOT NEED IT. `connection-status/index.web.ts` resolves to
|
|
68
|
+
* `ConnectionStatusToasts.web.tsx`, which uses `navigator.onLine` and the
|
|
69
|
+
* `online`/`offline` events and never calls `loadNetInfo` — measured in a real
|
|
70
|
+
* Vite/Rolldown app, where netinfo was installed, unused, and absent from every
|
|
71
|
+
* chunk. This hatch is for a NON-Metro bundle that still takes the native path:
|
|
72
|
+
* an SSR pass, a test runner, a future non-Metro native bundler.
|
|
73
|
+
*
|
|
74
|
+
* The `require` below cannot be relied on off Metro, and the reason is worth
|
|
75
|
+
* knowing because the symptom is identical while the cause is not:
|
|
76
|
+
*
|
|
77
|
+
* - Rollup / Vite ESM output: `require` is undefined, the guard catches it,
|
|
78
|
+
* and the boundary degrades.
|
|
79
|
+
* - esbuild ESM output: `require` EXISTS as a shim that throws
|
|
80
|
+
* (`Dynamic require of "…" is not supported`), so the guard PASSES and the
|
|
81
|
+
* call throws inside the try. Measured with the peer installed on disk:
|
|
82
|
+
* `platform=node` and `platform=browser` both degraded.
|
|
83
|
+
*
|
|
84
|
+
* So a fix aimed at the `typeof require` check would have changed nothing under
|
|
85
|
+
* esbuild. And there is no synchronous, bundler-agnostic alternative: `import()`
|
|
86
|
+
* is asynchronous AND resolved at build time, so an absent package fails the
|
|
87
|
+
* BUILD — which is what this boundary exists to prevent.
|
|
88
|
+
*
|
|
89
|
+
* Metro is unaffected either way and needs no binding.
|
|
90
|
+
*/
|
|
91
|
+
export declare function provideNetInfo(module: NetInfoLike | null): void;
|
|
60
92
|
/** The netinfo module, or `null` when the optional peer is not installed. */
|
|
61
93
|
export declare function loadNetInfo(): NetInfoLike | null;
|
|
62
94
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netinfo.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/netinfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AASH,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/E;
|
|
1
|
+
{"version":3,"file":"netinfo.d.ts","sourceRoot":"","sources":["../../../../src/connection-status/netinfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AASH,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/E;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAI/D;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,WAAW,GAAG,IAAI,CAkChD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAa7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptive-colors.d.ts","sourceRoot":"","sources":["../../../../src/theme/adaptive-colors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,WAAW,EACT,eAAe,GACf,yBAAyB,GACzB,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,yBAAyB,GACzB,YAAY,GACZ,sBAAsB,CACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"adaptive-colors.d.ts","sourceRoot":"","sources":["../../../../src/theme/adaptive-colors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,WAAW,EACT,eAAe,GACf,yBAAyB,GACzB,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,yBAAyB,GACzB,YAAY,GACZ,sBAAsB,CACzB,CAAC;AA+HF,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAIzD"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export type { ConnectionStatusToastsProps } from './shared';
|
|
2
|
+
// The hatch a consumer needs off Metro, where the optional `require` does not
|
|
3
|
+
// deliver the peer even when it is installed. See `netinfo.ts`.
|
|
4
|
+
export { provideNetInfo, type NetInfoLike } from './netinfo';
|
|
2
5
|
export {
|
|
3
6
|
ConnectionStatusToasts,
|
|
4
7
|
} from './ConnectionStatusToasts';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export type { ConnectionStatusToastsProps } from './shared';
|
|
2
|
+
// The hatch a consumer needs off Metro, where the optional `require` does not
|
|
3
|
+
// deliver the peer even when it is installed. See `netinfo.ts`.
|
|
4
|
+
export { provideNetInfo, type NetInfoLike } from './netinfo';
|
|
2
5
|
export {
|
|
3
6
|
ConnectionStatusToasts,
|
|
4
7
|
} from './ConnectionStatusToasts.web';
|
|
@@ -69,12 +69,52 @@ export interface NetInfoLike {
|
|
|
69
69
|
|
|
70
70
|
/** `undefined` until the first load attempt, then the module or `null`. */
|
|
71
71
|
let netInfoModule: NetInfoLike | null | undefined;
|
|
72
|
+
/** Handed in by a consumer, which is the only thing that works in an ESM bundle. */
|
|
73
|
+
let providedModule: NetInfoLike | null = null;
|
|
72
74
|
/** Why the load failed, quoted verbatim in the dev warning. */
|
|
73
75
|
let unavailableReason = '';
|
|
74
76
|
let hasWarned = false;
|
|
75
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Hand Bloom the netinfo module, from a consumer that has it.
|
|
80
|
+
*
|
|
81
|
+
* THIS IS NOT A TEST HOOK. It is the only mechanism that works in an ESM
|
|
82
|
+
* bundle: the consumer, who knows it has the peer and which entry of it its own
|
|
83
|
+
* bundler resolved, hands the module in.
|
|
84
|
+
*
|
|
85
|
+
* A BROWSER DOES NOT NEED IT. `connection-status/index.web.ts` resolves to
|
|
86
|
+
* `ConnectionStatusToasts.web.tsx`, which uses `navigator.onLine` and the
|
|
87
|
+
* `online`/`offline` events and never calls `loadNetInfo` — measured in a real
|
|
88
|
+
* Vite/Rolldown app, where netinfo was installed, unused, and absent from every
|
|
89
|
+
* chunk. This hatch is for a NON-Metro bundle that still takes the native path:
|
|
90
|
+
* an SSR pass, a test runner, a future non-Metro native bundler.
|
|
91
|
+
*
|
|
92
|
+
* The `require` below cannot be relied on off Metro, and the reason is worth
|
|
93
|
+
* knowing because the symptom is identical while the cause is not:
|
|
94
|
+
*
|
|
95
|
+
* - Rollup / Vite ESM output: `require` is undefined, the guard catches it,
|
|
96
|
+
* and the boundary degrades.
|
|
97
|
+
* - esbuild ESM output: `require` EXISTS as a shim that throws
|
|
98
|
+
* (`Dynamic require of "…" is not supported`), so the guard PASSES and the
|
|
99
|
+
* call throws inside the try. Measured with the peer installed on disk:
|
|
100
|
+
* `platform=node` and `platform=browser` both degraded.
|
|
101
|
+
*
|
|
102
|
+
* So a fix aimed at the `typeof require` check would have changed nothing under
|
|
103
|
+
* esbuild. And there is no synchronous, bundler-agnostic alternative: `import()`
|
|
104
|
+
* is asynchronous AND resolved at build time, so an absent package fails the
|
|
105
|
+
* BUILD — which is what this boundary exists to prevent.
|
|
106
|
+
*
|
|
107
|
+
* Metro is unaffected either way and needs no binding.
|
|
108
|
+
*/
|
|
109
|
+
export function provideNetInfo(module: NetInfoLike | null): void {
|
|
110
|
+
providedModule = module;
|
|
111
|
+
netInfoModule = undefined;
|
|
112
|
+
hasWarned = false;
|
|
113
|
+
}
|
|
114
|
+
|
|
76
115
|
/** The netinfo module, or `null` when the optional peer is not installed. */
|
|
77
116
|
export function loadNetInfo(): NetInfoLike | null {
|
|
117
|
+
if (providedModule !== null) return providedModule;
|
|
78
118
|
if (netInfoModule !== undefined) return netInfoModule;
|
|
79
119
|
netInfoModule = null;
|
|
80
120
|
|
|
@@ -49,9 +49,37 @@ export type AdaptiveColors = Omit<
|
|
|
49
49
|
|
|
50
50
|
const c = (v: unknown): string => v as string;
|
|
51
51
|
|
|
52
|
+
let hasWarned = false;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* SAY SO. This boundary degraded in complete silence, which is the worst of the
|
|
56
|
+
* six: an app simply gets the preset palette instead of the platform's, and
|
|
57
|
+
* nothing anywhere says the platform read failed.
|
|
58
|
+
*
|
|
59
|
+
* It is only reachable on Android and iOS — `getAdaptiveColors` returns `null`
|
|
60
|
+
* on web before touching `require` — so an ESM bundle never gets here. That is
|
|
61
|
+
* an argument for warning, not against it: a failure that cannot happen in the
|
|
62
|
+
* environment you test in is exactly the one that goes unnoticed when it does.
|
|
63
|
+
*/
|
|
64
|
+
function warnAdaptiveColorsUnavailable(reason: string): void {
|
|
65
|
+
if (process.env.NODE_ENV === 'production' || hasWarned) return;
|
|
66
|
+
hasWarned = true;
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.warn(
|
|
69
|
+
'[Bloom] The adaptive palette fell back to the preset one: `expo-router`’s ' +
|
|
70
|
+
'`Color` proxy could not be read, so platform colours (Material You, iOS ' +
|
|
71
|
+
'dynamic) are not in use. Install the optional peer ' +
|
|
72
|
+
'(`npx expo install expo-router`) if you want them. ' +
|
|
73
|
+
`Reason: ${reason}`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
52
77
|
function getAndroidColors(): AdaptiveColors | null {
|
|
53
78
|
try {
|
|
54
|
-
if (typeof require === 'undefined')
|
|
79
|
+
if (typeof require === 'undefined') {
|
|
80
|
+
warnAdaptiveColorsUnavailable('this bundle has no CommonJS `require`');
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
55
83
|
const { Color } = require('expo-router');
|
|
56
84
|
const d = Color.android.dynamic;
|
|
57
85
|
return {
|
|
@@ -89,14 +117,18 @@ function getAndroidColors(): AdaptiveColors | null {
|
|
|
89
117
|
shadow: 'rgba(0, 0, 0, 0.2)',
|
|
90
118
|
overlay: 'rgba(0, 0, 0, 0.5)',
|
|
91
119
|
};
|
|
92
|
-
} catch {
|
|
120
|
+
} catch (error) {
|
|
121
|
+
warnAdaptiveColorsUnavailable(error instanceof Error ? error.message : String(error));
|
|
93
122
|
return null;
|
|
94
123
|
}
|
|
95
124
|
}
|
|
96
125
|
|
|
97
126
|
function getIOSColors(): AdaptiveColors | null {
|
|
98
127
|
try {
|
|
99
|
-
if (typeof require === 'undefined')
|
|
128
|
+
if (typeof require === 'undefined') {
|
|
129
|
+
warnAdaptiveColorsUnavailable('this bundle has no CommonJS `require`');
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
100
132
|
const { Color } = require('expo-router');
|
|
101
133
|
const i = Color.ios;
|
|
102
134
|
return {
|
|
@@ -134,7 +166,8 @@ function getIOSColors(): AdaptiveColors | null {
|
|
|
134
166
|
shadow: 'rgba(0, 0, 0, 0.15)',
|
|
135
167
|
overlay: 'rgba(0, 0, 0, 0.5)',
|
|
136
168
|
};
|
|
137
|
-
} catch {
|
|
169
|
+
} catch (error) {
|
|
170
|
+
warnAdaptiveColorsUnavailable(error instanceof Error ? error.message : String(error));
|
|
138
171
|
return null;
|
|
139
172
|
}
|
|
140
173
|
}
|