@oxyhq/bloom 0.67.0 → 0.69.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 (134) hide show
  1. package/lib/commonjs/animated-check/AnimatedCheck.js +22 -93
  2. package/lib/commonjs/animated-check/AnimatedCheck.js.map +1 -1
  3. package/lib/commonjs/avatar/Avatar.js +6 -24
  4. package/lib/commonjs/avatar/Avatar.js.map +1 -1
  5. package/lib/commonjs/avatar/AvatarRing.js +14 -30
  6. package/lib/commonjs/avatar/AvatarRing.js.map +1 -1
  7. package/lib/commonjs/bottom-sheet/index.js +9 -4
  8. package/lib/commonjs/bottom-sheet/index.js.map +1 -1
  9. package/lib/commonjs/connection-status/index.js +16 -7
  10. package/lib/commonjs/connection-status/index.js.map +1 -1
  11. package/lib/commonjs/connection-status/netinfo.js +119 -0
  12. package/lib/commonjs/connection-status/netinfo.js.map +1 -0
  13. package/lib/commonjs/hooks/haptics-module.js +109 -0
  14. package/lib/commonjs/hooks/haptics-module.js.map +1 -0
  15. package/lib/commonjs/hooks/useHaptics.js +6 -8
  16. package/lib/commonjs/hooks/useHaptics.js.map +1 -1
  17. package/lib/commonjs/loading/SpinnerIcon.js +22 -55
  18. package/lib/commonjs/loading/SpinnerIcon.js.map +1 -1
  19. package/lib/commonjs/theme/adaptive-colors.js +20 -4
  20. package/lib/commonjs/theme/adaptive-colors.js.map +1 -1
  21. package/lib/commonjs/theme/color-scope/style-builder.js +107 -6
  22. package/lib/commonjs/theme/color-scope/style-builder.js.map +1 -1
  23. package/lib/commonjs/theme/init-css-interop.js +13 -11
  24. package/lib/commonjs/theme/init-css-interop.js.map +1 -1
  25. package/lib/commonjs/toast/Toaster.js +5 -0
  26. package/lib/commonjs/toast/Toaster.js.map +1 -1
  27. package/lib/commonjs/toast/use-single-outlet-guard.js +72 -0
  28. package/lib/commonjs/toast/use-single-outlet-guard.js.map +1 -0
  29. package/lib/module/animated-check/AnimatedCheck.js +22 -91
  30. package/lib/module/animated-check/AnimatedCheck.js.map +1 -1
  31. package/lib/module/avatar/Avatar.js +1 -19
  32. package/lib/module/avatar/Avatar.js.map +1 -1
  33. package/lib/module/avatar/AvatarRing.js +7 -23
  34. package/lib/module/avatar/AvatarRing.js.map +1 -1
  35. package/lib/module/bottom-sheet/index.js +9 -4
  36. package/lib/module/bottom-sheet/index.js.map +1 -1
  37. package/lib/module/connection-status/index.js +16 -6
  38. package/lib/module/connection-status/index.js.map +1 -1
  39. package/lib/module/connection-status/netinfo.js +114 -0
  40. package/lib/module/connection-status/netinfo.js.map +1 -0
  41. package/lib/module/hooks/haptics-module.js +104 -0
  42. package/lib/module/hooks/haptics-module.js.map +1 -0
  43. package/lib/module/hooks/useHaptics.js +7 -11
  44. package/lib/module/hooks/useHaptics.js.map +1 -1
  45. package/lib/module/loading/SpinnerIcon.js +13 -46
  46. package/lib/module/loading/SpinnerIcon.js.map +1 -1
  47. package/lib/module/loading/index.web.js +2 -2
  48. package/lib/module/theme/adaptive-colors.js +20 -4
  49. package/lib/module/theme/adaptive-colors.js.map +1 -1
  50. package/lib/module/theme/color-scope/style-builder.js +107 -6
  51. package/lib/module/theme/color-scope/style-builder.js.map +1 -1
  52. package/lib/module/theme/init-css-interop.js +13 -11
  53. package/lib/module/theme/init-css-interop.js.map +1 -1
  54. package/lib/module/toast/Toaster.js +5 -0
  55. package/lib/module/toast/Toaster.js.map +1 -1
  56. package/lib/module/toast/use-single-outlet-guard.js +65 -0
  57. package/lib/module/toast/use-single-outlet-guard.js.map +1 -0
  58. package/lib/typescript/commonjs/animated-check/AnimatedCheck.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/avatar/AvatarRing.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/bottom-sheet/index.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/connection-status/index.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/connection-status/netinfo.d.ts +69 -0
  64. package/lib/typescript/commonjs/connection-status/netinfo.d.ts.map +1 -0
  65. package/lib/typescript/commonjs/hooks/haptics-module.d.ts +58 -0
  66. package/lib/typescript/commonjs/hooks/haptics-module.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/hooks/useHaptics.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/loading/SpinnerIcon.d.ts +9 -2
  69. package/lib/typescript/commonjs/loading/SpinnerIcon.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/theme/adaptive-colors.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/theme/color-scope/style-builder.d.ts.map +1 -1
  72. package/lib/typescript/commonjs/theme/init-css-interop.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/toast/Toaster.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/toast/use-single-outlet-guard.d.ts +9 -0
  75. package/lib/typescript/commonjs/toast/use-single-outlet-guard.d.ts.map +1 -0
  76. package/lib/typescript/module/animated-check/AnimatedCheck.d.ts.map +1 -1
  77. package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
  78. package/lib/typescript/module/avatar/AvatarRing.d.ts.map +1 -1
  79. package/lib/typescript/module/bottom-sheet/index.d.ts.map +1 -1
  80. package/lib/typescript/module/connection-status/index.d.ts.map +1 -1
  81. package/lib/typescript/module/connection-status/netinfo.d.ts +69 -0
  82. package/lib/typescript/module/connection-status/netinfo.d.ts.map +1 -0
  83. package/lib/typescript/module/hooks/haptics-module.d.ts +58 -0
  84. package/lib/typescript/module/hooks/haptics-module.d.ts.map +1 -0
  85. package/lib/typescript/module/hooks/useHaptics.d.ts.map +1 -1
  86. package/lib/typescript/module/loading/SpinnerIcon.d.ts +9 -2
  87. package/lib/typescript/module/loading/SpinnerIcon.d.ts.map +1 -1
  88. package/lib/typescript/module/theme/adaptive-colors.d.ts.map +1 -1
  89. package/lib/typescript/module/theme/color-scope/style-builder.d.ts.map +1 -1
  90. package/lib/typescript/module/theme/init-css-interop.d.ts.map +1 -1
  91. package/lib/typescript/module/toast/Toaster.d.ts.map +1 -1
  92. package/lib/typescript/module/toast/use-single-outlet-guard.d.ts +9 -0
  93. package/lib/typescript/module/toast/use-single-outlet-guard.d.ts.map +1 -0
  94. package/package.json +348 -88
  95. package/src/__tests__/color-scope-nativewind.test.ts +135 -0
  96. package/src/__tests__/connection-status-netinfo.test.tsx +203 -0
  97. package/src/__tests__/exports-map-contract.test.ts +112 -0
  98. package/src/__tests__/optional-peer-imports.test.ts +406 -0
  99. package/src/__tests__/svg-required-peer.test.tsx +75 -0
  100. package/src/__tests__/toast-single-outlet-guard.test.tsx +176 -0
  101. package/src/__tests__/useHaptics.test.tsx +203 -16
  102. package/src/animated-check/AnimatedCheck.tsx +19 -86
  103. package/src/avatar/Avatar.tsx +1 -11
  104. package/src/avatar/AvatarRing.tsx +7 -15
  105. package/src/bottom-sheet/index.tsx +9 -4
  106. package/src/connection-status/index.tsx +16 -6
  107. package/src/connection-status/netinfo.ts +131 -0
  108. package/src/hooks/haptics-module.ts +118 -0
  109. package/src/hooks/useHaptics.tsx +6 -9
  110. package/src/loading/SpinnerIcon.tsx +13 -52
  111. package/src/loading/index.web.ts +2 -2
  112. package/src/theme/adaptive-colors.ts +20 -4
  113. package/src/theme/color-scope/style-builder.ts +118 -6
  114. package/src/theme/init-css-interop.ts +13 -11
  115. package/src/toast/Toaster.tsx +6 -0
  116. package/src/toast/use-single-outlet-guard.ts +72 -0
  117. package/lib/commonjs/avatar/svg-module.js +0 -15
  118. package/lib/commonjs/avatar/svg-module.js.map +0 -1
  119. package/lib/commonjs/utils/lazy-require.js +0 -37
  120. package/lib/commonjs/utils/lazy-require.js.map +0 -1
  121. package/lib/module/avatar/svg-module.js +0 -11
  122. package/lib/module/avatar/svg-module.js.map +0 -1
  123. package/lib/module/utils/lazy-require.js +0 -33
  124. package/lib/module/utils/lazy-require.js.map +0 -1
  125. package/lib/typescript/commonjs/avatar/svg-module.d.ts +0 -8
  126. package/lib/typescript/commonjs/avatar/svg-module.d.ts.map +0 -1
  127. package/lib/typescript/commonjs/utils/lazy-require.d.ts +0 -15
  128. package/lib/typescript/commonjs/utils/lazy-require.d.ts.map +0 -1
  129. package/lib/typescript/module/avatar/svg-module.d.ts +0 -8
  130. package/lib/typescript/module/avatar/svg-module.d.ts.map +0 -1
  131. package/lib/typescript/module/utils/lazy-require.d.ts +0 -15
  132. package/lib/typescript/module/utils/lazy-require.d.ts.map +0 -1
  133. package/src/avatar/svg-module.ts +0 -11
  134. package/src/utils/lazy-require.ts +0 -31
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Bloom-original — the dev-only guard against a SECOND toast outlet.
3
+ *
4
+ * Every `Toaster` subscribes to the ONE module-level `toastStore`, which has no
5
+ * notion of an owning outlet, so N mounted outlets each render the full row set:
6
+ * a toast appears N times. Nothing in the engine can dedupe that — the outlets
7
+ * are legitimate, independent subscribers — so the contract is "mount exactly
8
+ * one" and this is what enforces it.
9
+ *
10
+ * WHY A WARNING IS WORTH ITS WEIGHT: the copies are not visually separated, so
11
+ * the defect does not look like duplication. Two bare outlets take identical
12
+ * defaults and land pixel-identical; two outlets whose `offset` differs by a
13
+ * point land 1px apart. Only counting the rendered rows reveals it, which is not
14
+ * something anyone thinks to do — the reports this guard comes from all read as
15
+ * "the toast looks wrong", never as "there are two of them". Stacking is on by
16
+ * default, so a duplicate outlet now doubles the rows INSIDE a stack.
17
+ *
18
+ * The counter is decremented on unmount, so a remount, a route change that moves
19
+ * the outlet, Fast Refresh and React's StrictMode double-invoke (setup, cleanup,
20
+ * setup) all pass through a count of 1 and stay silent. The latch keeps the
21
+ * warning to exactly one per module lifetime rather than one per extra outlet,
22
+ * and — because StrictMode replays the setups — one per app, not two.
23
+ *
24
+ * Gated on `process.env.NODE_ENV`, the same mechanism as
25
+ * `content-panel/nesting-context.ts`: Metro and Vite/Rolldown both fold it
26
+ * statically, so production keeps the counter, the branch and the message out of
27
+ * the bundle entirely. Deliberately NOT `__DEV__`, which is a Metro global that a
28
+ * plain web bundler does not define. It only ever warns — a duplicate outlet
29
+ * renders a redundant toast, it does not break the app, so it must never throw.
30
+ */
31
+ import * as React from 'react';
32
+
33
+ let mountedOutlets = 0;
34
+ let hasWarned = false;
35
+
36
+ export function useSingleOutletGuard(): void {
37
+ React.useEffect(() => {
38
+ if (process.env.NODE_ENV === 'production') {
39
+ return;
40
+ }
41
+
42
+ mountedOutlets += 1;
43
+ if (mountedOutlets > 1 && !hasWarned) {
44
+ hasWarned = true;
45
+ // Internal Bloom diagnostic: the consumer's tree is the only place this
46
+ // can be fixed, so it names the usual cause rather than just the symptom.
47
+ // eslint-disable-next-line no-console
48
+ console.warn(
49
+ `[Bloom] Toaster: ${mountedOutlets} toast outlets are mounted, so every ` +
50
+ 'toast renders once per outlet. The copies overlap almost exactly, so ' +
51
+ 'this reads as a rendering glitch rather than as duplicate rows. Mount ' +
52
+ "exactly one: @oxyhq/services' OxyProvider already renders a " +
53
+ 'ToastOutlet, so an app that uses it must not render its own.',
54
+ );
55
+ }
56
+
57
+ return () => {
58
+ mountedOutlets -= 1;
59
+ };
60
+ }, []);
61
+ }
62
+
63
+ /**
64
+ * Test-only reset: both the counter and the one-shot latch are module state that
65
+ * outlives a render tree, so without this the first suite to mount two outlets
66
+ * would latch the warning and leave every later suite asserting against a guard
67
+ * that can no longer fire — passing whatever the implementation did.
68
+ */
69
+ export function resetSingleOutletGuardForTests(): void {
70
+ mountedOutlets = 0;
71
+ hasWarned = false;
72
+ }
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSvgModule = void 0;
7
- var _lazyRequire = require("../utils/lazy-require.js");
8
- /**
9
- * Lazily loads `react-native-svg`, returning `null` when it is not installed
10
- * (e.g. a web bundle that does not ship the optional peer). Shared by the
11
- * squircle avatar image clip in `Avatar.tsx` and the `AvatarRing` so there is a
12
- * single loader rather than one per call site.
13
- */
14
- const getSvgModule = exports.getSvgModule = (0, _lazyRequire.lazyRequire)('react-native-svg');
15
- //# sourceMappingURL=svg-module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_lazyRequire","require","getSvgModule","exports","lazyRequire"],"sourceRoot":"../../../src","sources":["avatar/svg-module.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAAE,wBAAW,EAAgB,kBAAkB,CAAC","ignoreList":[]}
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.lazyRequire = lazyRequire;
7
- /**
8
- * Creates a lazy-loaded module getter that caches the result.
9
- *
10
- * Safely handles environments where `require` is not defined (e.g. Vite/browser ESM)
11
- * and returns `null` when the module is not installed. The result is cached after the
12
- * first call so subsequent calls are zero-cost.
13
- *
14
- * @example
15
- * ```ts
16
- * const getSvg = lazyRequire<typeof import('react-native-svg')>('react-native-svg');
17
- * const svg = getSvg(); // SvgModuleType | null
18
- * ```
19
- */
20
- function lazyRequire(moduleName) {
21
- let module = null;
22
- let resolved = false;
23
- return () => {
24
- if (!resolved) {
25
- resolved = true;
26
- try {
27
- if (typeof require !== 'undefined') {
28
- module = require(moduleName);
29
- }
30
- } catch {
31
- module = null;
32
- }
33
- }
34
- return module;
35
- };
36
- }
37
- //# sourceMappingURL=lazy-require.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["lazyRequire","moduleName","module","resolved","require"],"sourceRoot":"../../../src","sources":["utils/lazy-require.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAIC,UAAkB,EAAkB;EACjE,IAAIC,MAAgB,GAAG,IAAI;EAC3B,IAAIC,QAAQ,GAAG,KAAK;EAEpB,OAAO,MAAgB;IACrB,IAAI,CAACA,QAAQ,EAAE;MACbA,QAAQ,GAAG,IAAI;MACf,IAAI;QACF,IAAI,OAAOC,OAAO,KAAK,WAAW,EAAE;UAClCF,MAAM,GAAGE,OAAO,CAACH,UAAU,CAAC;QAC9B;MACF,CAAC,CAAC,MAAM;QACNC,MAAM,GAAG,IAAI;MACf;IACF;IACA,OAAOA,MAAM;EACf,CAAC;AACH","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- import { lazyRequire } from "../utils/lazy-require.js";
4
- /**
5
- * Lazily loads `react-native-svg`, returning `null` when it is not installed
6
- * (e.g. a web bundle that does not ship the optional peer). Shared by the
7
- * squircle avatar image clip in `Avatar.tsx` and the `AvatarRing` so there is a
8
- * single loader rather than one per call site.
9
- */
10
- export const getSvgModule = lazyRequire('react-native-svg');
11
- //# sourceMappingURL=svg-module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["lazyRequire","getSvgModule"],"sourceRoot":"../../../src","sources":["avatar/svg-module.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,0BAAuB;AAInD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGD,WAAW,CAAgB,kBAAkB,CAAC","ignoreList":[]}
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Creates a lazy-loaded module getter that caches the result.
5
- *
6
- * Safely handles environments where `require` is not defined (e.g. Vite/browser ESM)
7
- * and returns `null` when the module is not installed. The result is cached after the
8
- * first call so subsequent calls are zero-cost.
9
- *
10
- * @example
11
- * ```ts
12
- * const getSvg = lazyRequire<typeof import('react-native-svg')>('react-native-svg');
13
- * const svg = getSvg(); // SvgModuleType | null
14
- * ```
15
- */
16
- export function lazyRequire(moduleName) {
17
- let module = null;
18
- let resolved = false;
19
- return () => {
20
- if (!resolved) {
21
- resolved = true;
22
- try {
23
- if (typeof require !== 'undefined') {
24
- module = require(moduleName);
25
- }
26
- } catch {
27
- module = null;
28
- }
29
- }
30
- return module;
31
- };
32
- }
33
- //# sourceMappingURL=lazy-require.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["lazyRequire","moduleName","module","resolved","require"],"sourceRoot":"../../../src","sources":["utils/lazy-require.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAAIC,UAAkB,EAAkB;EACjE,IAAIC,MAAgB,GAAG,IAAI;EAC3B,IAAIC,QAAQ,GAAG,KAAK;EAEpB,OAAO,MAAgB;IACrB,IAAI,CAACA,QAAQ,EAAE;MACbA,QAAQ,GAAG,IAAI;MACf,IAAI;QACF,IAAI,OAAOC,OAAO,KAAK,WAAW,EAAE;UAClCF,MAAM,GAAGE,OAAO,CAACH,UAAU,CAAC;QAC9B;MACF,CAAC,CAAC,MAAM;QACNC,MAAM,GAAG,IAAI;MACf;IACF;IACA,OAAOA,MAAM;EACf,CAAC;AACH","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- /**
2
- * Lazily loads `react-native-svg`, returning `null` when it is not installed
3
- * (e.g. a web bundle that does not ship the optional peer). Shared by the
4
- * squircle avatar image clip in `Avatar.tsx` and the `AvatarRing` so there is a
5
- * single loader rather than one per call site.
6
- */
7
- export declare const getSvgModule: () => typeof import("react-native-svg") | null;
8
- //# sourceMappingURL=svg-module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg-module.d.ts","sourceRoot":"","sources":["../../../../src/avatar/svg-module.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,gDAAiD,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Creates a lazy-loaded module getter that caches the result.
3
- *
4
- * Safely handles environments where `require` is not defined (e.g. Vite/browser ESM)
5
- * and returns `null` when the module is not installed. The result is cached after the
6
- * first call so subsequent calls are zero-cost.
7
- *
8
- * @example
9
- * ```ts
10
- * const getSvg = lazyRequire<typeof import('react-native-svg')>('react-native-svg');
11
- * const svg = getSvg(); // SvgModuleType | null
12
- * ```
13
- */
14
- export declare function lazyRequire<T>(moduleName: string): () => T | null;
15
- //# sourceMappingURL=lazy-require.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy-require.d.ts","sourceRoot":"","sources":["../../../../src/utils/lazy-require.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAiBjE"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Lazily loads `react-native-svg`, returning `null` when it is not installed
3
- * (e.g. a web bundle that does not ship the optional peer). Shared by the
4
- * squircle avatar image clip in `Avatar.tsx` and the `AvatarRing` so there is a
5
- * single loader rather than one per call site.
6
- */
7
- export declare const getSvgModule: () => typeof import("react-native-svg") | null;
8
- //# sourceMappingURL=svg-module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg-module.d.ts","sourceRoot":"","sources":["../../../../src/avatar/svg-module.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,gDAAiD,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Creates a lazy-loaded module getter that caches the result.
3
- *
4
- * Safely handles environments where `require` is not defined (e.g. Vite/browser ESM)
5
- * and returns `null` when the module is not installed. The result is cached after the
6
- * first call so subsequent calls are zero-cost.
7
- *
8
- * @example
9
- * ```ts
10
- * const getSvg = lazyRequire<typeof import('react-native-svg')>('react-native-svg');
11
- * const svg = getSvg(); // SvgModuleType | null
12
- * ```
13
- */
14
- export declare function lazyRequire<T>(moduleName: string): () => T | null;
15
- //# sourceMappingURL=lazy-require.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy-require.d.ts","sourceRoot":"","sources":["../../../../src/utils/lazy-require.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAiBjE"}
@@ -1,11 +0,0 @@
1
- import { lazyRequire } from '../utils/lazy-require';
2
-
3
- type SvgModuleType = typeof import('react-native-svg');
4
-
5
- /**
6
- * Lazily loads `react-native-svg`, returning `null` when it is not installed
7
- * (e.g. a web bundle that does not ship the optional peer). Shared by the
8
- * squircle avatar image clip in `Avatar.tsx` and the `AvatarRing` so there is a
9
- * single loader rather than one per call site.
10
- */
11
- export const getSvgModule = lazyRequire<SvgModuleType>('react-native-svg');
@@ -1,31 +0,0 @@
1
- /**
2
- * Creates a lazy-loaded module getter that caches the result.
3
- *
4
- * Safely handles environments where `require` is not defined (e.g. Vite/browser ESM)
5
- * and returns `null` when the module is not installed. The result is cached after the
6
- * first call so subsequent calls are zero-cost.
7
- *
8
- * @example
9
- * ```ts
10
- * const getSvg = lazyRequire<typeof import('react-native-svg')>('react-native-svg');
11
- * const svg = getSvg(); // SvgModuleType | null
12
- * ```
13
- */
14
- export function lazyRequire<T>(moduleName: string): () => T | null {
15
- let module: T | null = null;
16
- let resolved = false;
17
-
18
- return (): T | null => {
19
- if (!resolved) {
20
- resolved = true;
21
- try {
22
- if (typeof require !== 'undefined') {
23
- module = require(moduleName);
24
- }
25
- } catch {
26
- module = null;
27
- }
28
- }
29
- return module;
30
- };
31
- }