@ankhorage/expo-runtime 4.0.49 → 6.0.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 (177) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +2 -3
  3. package/dist/capabilities/index.d.ts +25 -0
  4. package/dist/capabilities/index.d.ts.map +1 -0
  5. package/dist/capabilities/index.js +25 -0
  6. package/dist/capabilities/index.js.map +1 -0
  7. package/dist/capabilityBridge.d.ts +5 -0
  8. package/dist/capabilityBridge.d.ts.map +1 -0
  9. package/dist/capabilityBridge.js +3 -0
  10. package/dist/capabilityBridge.js.map +1 -0
  11. package/dist/createExpoRuntimeRegistry.d.ts.map +1 -1
  12. package/dist/createExpoRuntimeRegistry.js +0 -5
  13. package/dist/createExpoRuntimeRegistry.js.map +1 -1
  14. package/dist/expoRuntimePlanningMetadata.d.ts +3 -7
  15. package/dist/expoRuntimePlanningMetadata.d.ts.map +1 -1
  16. package/dist/expoRuntimePlanningMetadata.js +2 -6
  17. package/dist/expoRuntimePlanningMetadata.js.map +1 -1
  18. package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.d.ts +4 -0
  19. package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.d.ts.map +1 -0
  20. package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.js +30 -0
  21. package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.js.map +1 -0
  22. package/dist/features/navigation/resolveExpoRuntimeRoutePath.d.ts +4 -0
  23. package/dist/features/navigation/resolveExpoRuntimeRoutePath.d.ts.map +1 -0
  24. package/dist/features/navigation/resolveExpoRuntimeRoutePath.js +17 -0
  25. package/dist/features/navigation/resolveExpoRuntimeRoutePath.js.map +1 -0
  26. package/dist/generatedSources.d.ts +0 -1
  27. package/dist/generatedSources.d.ts.map +1 -1
  28. package/dist/generatedSources.js +0 -8
  29. package/dist/generatedSources.js.map +1 -1
  30. package/dist/index.d.ts +2 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +2 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/planning.d.ts +1 -1
  35. package/dist/planning.d.ts.map +1 -1
  36. package/dist/planning.js +1 -1
  37. package/dist/planning.js.map +1 -1
  38. package/dist/platform.js +8 -8
  39. package/dist/platform.js.map +1 -1
  40. package/dist/types/expoRuntimeCapability.d.ts +16 -0
  41. package/dist/types/expoRuntimeCapability.d.ts.map +1 -0
  42. package/dist/types/expoRuntimeCapability.js +2 -0
  43. package/dist/types/expoRuntimeCapability.js.map +1 -0
  44. package/dist/types/expoRuntimeRoute.d.ts +5 -0
  45. package/dist/types/expoRuntimeRoute.d.ts.map +1 -0
  46. package/dist/types/expoRuntimeRoute.js +2 -0
  47. package/dist/types/expoRuntimeRoute.js.map +1 -0
  48. package/package.json +58 -46
  49. package/src/adapterEntrypoints.test.ts +23 -14
  50. package/src/capabilities/index.test.ts +18 -0
  51. package/src/capabilities/index.ts +26 -0
  52. package/src/capabilityBridge.ts +8 -0
  53. package/src/createExpoRuntimeRegistry.test.tsx +3 -8
  54. package/src/createExpoRuntimeRegistry.tsx +1 -7
  55. package/src/expoCapabilityBridge.test.ts +60 -0
  56. package/src/expoRuntimePlanningMetadata.ts +3 -7
  57. package/src/features/capabilities/executeExpoRuntimeCapabilityAsync.ts +49 -0
  58. package/src/features/navigation/resolveExpoRuntimeRoutePath.ts +31 -0
  59. package/src/generatedSources.test.ts +1 -10
  60. package/src/generatedSources.ts +0 -10
  61. package/src/iconFonts.test.ts +0 -2
  62. package/src/index.ts +9 -15
  63. package/src/planning.ts +1 -4
  64. package/src/platform.test.ts +8 -8
  65. package/src/platform.ts +8 -8
  66. package/src/resolveExpoRuntimePlan.test.ts +5 -20
  67. package/src/types/expoRuntimeCapability.ts +18 -0
  68. package/src/types/expoRuntimeRoute.ts +4 -0
  69. package/dist/actionBridge.d.ts +0 -2
  70. package/dist/actionBridge.d.ts.map +0 -1
  71. package/dist/actionBridge.js +0 -2
  72. package/dist/actionBridge.js.map +0 -1
  73. package/dist/expoActionBridge.d.ts +0 -29
  74. package/dist/expoActionBridge.d.ts.map +0 -1
  75. package/dist/expoActionBridge.js +0 -78
  76. package/dist/expoActionBridge.js.map +0 -1
  77. package/dist/reader/ExpoReaderSurfaceAdapter.d.ts +0 -4
  78. package/dist/reader/ExpoReaderSurfaceAdapter.d.ts.map +0 -1
  79. package/dist/reader/ExpoReaderSurfaceAdapter.js +0 -102
  80. package/dist/reader/ExpoReaderSurfaceAdapter.js.map +0 -1
  81. package/dist/reader/ReaderViewport.d.ts +0 -4
  82. package/dist/reader/ReaderViewport.d.ts.map +0 -1
  83. package/dist/reader/ReaderViewport.js +0 -212
  84. package/dist/reader/ReaderViewport.js.map +0 -1
  85. package/dist/reader/drivers/EpubReaderDriver.d.ts +0 -20
  86. package/dist/reader/drivers/EpubReaderDriver.d.ts.map +0 -1
  87. package/dist/reader/drivers/EpubReaderDriver.js +0 -259
  88. package/dist/reader/drivers/EpubReaderDriver.js.map +0 -1
  89. package/dist/reader/drivers/PdfReaderDriver.d.ts +0 -18
  90. package/dist/reader/drivers/PdfReaderDriver.d.ts.map +0 -1
  91. package/dist/reader/drivers/PdfReaderDriver.js +0 -198
  92. package/dist/reader/drivers/PdfReaderDriver.js.map +0 -1
  93. package/dist/reader/epub/EpubArchive.d.ts +0 -11
  94. package/dist/reader/epub/EpubArchive.d.ts.map +0 -1
  95. package/dist/reader/epub/EpubArchive.js +0 -65
  96. package/dist/reader/epub/EpubArchive.js.map +0 -1
  97. package/dist/reader/epub/EpubArchiveFetcher.d.ts +0 -11
  98. package/dist/reader/epub/EpubArchiveFetcher.d.ts.map +0 -1
  99. package/dist/reader/epub/EpubArchiveFetcher.js +0 -44
  100. package/dist/reader/epub/EpubArchiveFetcher.js.map +0 -1
  101. package/dist/reader/epub/mediaTypes.d.ts +0 -3
  102. package/dist/reader/epub/mediaTypes.d.ts.map +0 -1
  103. package/dist/reader/epub/mediaTypes.js +0 -26
  104. package/dist/reader/epub/mediaTypes.js.map +0 -1
  105. package/dist/reader/epub/parseEpubPackage.d.ts +0 -22
  106. package/dist/reader/epub/parseEpubPackage.d.ts.map +0 -1
  107. package/dist/reader/epub/parseEpubPackage.js +0 -98
  108. package/dist/reader/epub/parseEpubPackage.js.map +0 -1
  109. package/dist/reader/epub/path.d.ts +0 -4
  110. package/dist/reader/epub/path.d.ts.map +0 -1
  111. package/dist/reader/epub/path.js +0 -28
  112. package/dist/reader/epub/path.js.map +0 -1
  113. package/dist/reader/epub/sanitizeEpubDocument.d.ts +0 -3
  114. package/dist/reader/epub/sanitizeEpubDocument.d.ts.map +0 -1
  115. package/dist/reader/epub/sanitizeEpubDocument.js +0 -90
  116. package/dist/reader/epub/sanitizeEpubDocument.js.map +0 -1
  117. package/dist/reader/epub/validateEpubArchiveEntriesAsync.d.ts +0 -4
  118. package/dist/reader/epub/validateEpubArchiveEntriesAsync.d.ts.map +0 -1
  119. package/dist/reader/epub/validateEpubArchiveEntriesAsync.js +0 -50
  120. package/dist/reader/epub/validateEpubArchiveEntriesAsync.js.map +0 -1
  121. package/dist/reader/errors/ReaderDocumentError.d.ts +0 -6
  122. package/dist/reader/errors/ReaderDocumentError.d.ts.map +0 -1
  123. package/dist/reader/errors/ReaderDocumentError.js +0 -9
  124. package/dist/reader/errors/ReaderDocumentError.js.map +0 -1
  125. package/dist/reader/index.d.ts +0 -2
  126. package/dist/reader/index.d.ts.map +0 -1
  127. package/dist/reader/index.js +0 -2
  128. package/dist/reader/index.js.map +0 -1
  129. package/dist/reader/loadReaderSourceAsync.d.ts +0 -2
  130. package/dist/reader/loadReaderSourceAsync.d.ts.map +0 -1
  131. package/dist/reader/loadReaderSourceAsync.js +0 -49
  132. package/dist/reader/loadReaderSourceAsync.js.map +0 -1
  133. package/dist/reader/navigation/resolveReaderKeyboardIntent.d.ts +0 -9
  134. package/dist/reader/navigation/resolveReaderKeyboardIntent.d.ts.map +0 -1
  135. package/dist/reader/navigation/resolveReaderKeyboardIntent.js +0 -19
  136. package/dist/reader/navigation/resolveReaderKeyboardIntent.js.map +0 -1
  137. package/dist/reader/navigation/resolveReaderNavigationIntent.d.ts +0 -11
  138. package/dist/reader/navigation/resolveReaderNavigationIntent.d.ts.map +0 -1
  139. package/dist/reader/navigation/resolveReaderNavigationIntent.js +0 -16
  140. package/dist/reader/navigation/resolveReaderNavigationIntent.js.map +0 -1
  141. package/dist/reader/readerViewportPresentation.d.ts +0 -4
  142. package/dist/reader/readerViewportPresentation.d.ts.map +0 -1
  143. package/dist/reader/readerViewportPresentation.js +0 -26
  144. package/dist/reader/readerViewportPresentation.js.map +0 -1
  145. package/dist/types/reader.d.ts +0 -57
  146. package/dist/types/reader.d.ts.map +0 -1
  147. package/dist/types/reader.js +0 -2
  148. package/dist/types/reader.js.map +0 -1
  149. package/src/actionBridge.test.ts +0 -10
  150. package/src/actionBridge.ts +0 -10
  151. package/src/expoActionBridge.test.ts +0 -54
  152. package/src/expoActionBridge.ts +0 -140
  153. package/src/reader/ExpoReaderSurfaceAdapter.tsx +0 -170
  154. package/src/reader/ReaderViewport.tsx +0 -319
  155. package/src/reader/drivers/EpubReaderDriver.ts +0 -309
  156. package/src/reader/drivers/PdfReaderDriver.ts +0 -253
  157. package/src/reader/epub/EpubArchive.ts +0 -83
  158. package/src/reader/epub/EpubArchiveFetcher.ts +0 -58
  159. package/src/reader/epub/mediaTypes.ts +0 -16
  160. package/src/reader/epub/parseEpubPackage.test.ts +0 -116
  161. package/src/reader/epub/parseEpubPackage.ts +0 -152
  162. package/src/reader/epub/path.test.ts +0 -22
  163. package/src/reader/epub/path.ts +0 -26
  164. package/src/reader/epub/sanitizeEpubDocument.ts +0 -121
  165. package/src/reader/epub/validateEpubArchiveEntriesAsync.ts +0 -75
  166. package/src/reader/errors/ReaderDocumentError.ts +0 -11
  167. package/src/reader/index.ts +0 -1
  168. package/src/reader/loadReaderSourceAsync.test.ts +0 -52
  169. package/src/reader/loadReaderSourceAsync.ts +0 -59
  170. package/src/reader/navigation/resolveReaderKeyboardIntent.test.ts +0 -38
  171. package/src/reader/navigation/resolveReaderKeyboardIntent.ts +0 -20
  172. package/src/reader/navigation/resolveReaderNavigationIntent.test.ts +0 -48
  173. package/src/reader/navigation/resolveReaderNavigationIntent.ts +0 -23
  174. package/src/reader/readerViewportPresentation.ts +0 -28
  175. package/src/reader/rendererPackages.test.ts +0 -24
  176. package/src/reader/validateEpubArchiveEntriesAsync.test.ts +0 -142
  177. package/src/types/reader.ts +0 -61
@@ -1,9 +1,6 @@
1
1
  import { describe, expect, it } from 'bun:test';
2
2
 
3
- import {
4
- getExpoBarcodeScannerViewSource,
5
- getExpoReaderSurfaceViewSource,
6
- } from './generatedSources';
3
+ import { getExpoBarcodeScannerViewSource } from './generatedSources';
7
4
 
8
5
  describe('generated Expo runtime sources', () => {
9
6
  it('emits the barcode scanner view adapter in canonical source format', () => {
@@ -11,10 +8,4 @@ describe('generated Expo runtime sources', () => {
11
8
  "export { ExpoBarcodeScannerAdapter as ExpoBarcodeScannerView } from '@ankhorage/expo-runtime/barcode-scanner';\n",
12
9
  );
13
10
  });
14
-
15
- it('emits the reader surface adapter through its capability-scoped entrypoint', () => {
16
- expect(getExpoReaderSurfaceViewSource()).toBe(
17
- "export { ExpoReaderSurfaceAdapter as ExpoReaderSurfaceView } from '@ankhorage/expo-runtime/reader';\n",
18
- );
19
- });
20
11
  });
@@ -4,16 +4,6 @@ const EXPO_BARCODE_SCANNER_VIEW_SOURCE = [
4
4
  '\n',
5
5
  ] as const;
6
6
 
7
- const EXPO_READER_SURFACE_VIEW_SOURCE = [
8
- 'export { ExpoReaderSurfaceAdapter as ExpoReaderSurfaceView }',
9
- " from '@ankhorage/expo-runtime/reader';",
10
- '\n',
11
- ] as const;
12
-
13
7
  export function getExpoBarcodeScannerViewSource(): string {
14
8
  return EXPO_BARCODE_SCANNER_VIEW_SOURCE.join('');
15
9
  }
16
-
17
- export function getExpoReaderSurfaceViewSource(): string {
18
- return EXPO_READER_SURFACE_VIEW_SOURCE.join('');
19
- }
@@ -13,7 +13,6 @@ test('exports the icon font boundary through its focused subpath', async () => {
13
13
  'browser',
14
14
  'react-native',
15
15
  'types',
16
- 'node',
17
16
  'import',
18
17
  'default',
19
18
  ]);
@@ -21,7 +20,6 @@ test('exports the icon font boundary through its focused subpath', async () => {
21
20
  browser: './src/ExpoZoraIconFontProvider.web.tsx',
22
21
  'react-native': './src/ExpoZoraIconFontProvider.tsx',
23
22
  types: './src/ExpoZoraIconFontProvider.tsx',
24
- node: './src/ExpoZoraIconFontProvider.web.tsx',
25
23
  import: './dist/ExpoZoraIconFontProvider.js',
26
24
  default: './dist/ExpoZoraIconFontProvider.js',
27
25
  });
package/src/index.ts CHANGED
@@ -19,19 +19,17 @@ export {
19
19
  type ExpoBundledMediaValue,
20
20
  resolveExpoBundledMediaAsset,
21
21
  } from './bundledMediaResolver';
22
- export type { ComponentRegistry } from './componentRegistry';
23
- export { createComponentRegistry } from './componentRegistry';
24
- export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
25
22
  export {
26
- executeExpoRuntimeAction,
27
- type ExecuteExpoRuntimeActionArgs,
28
- type ExpoRuntimeActionHandlerArgs,
29
- type ExpoRuntimeActionHandlers,
23
+ type ExecuteExpoRuntimeCapabilityArgs,
24
+ executeExpoRuntimeCapabilityAsync,
25
+ type ExpoRuntimeCapabilityHandler,
26
+ type ExpoRuntimeCapabilityHandlerArgs,
30
27
  type ExpoRuntimeRouteResolution,
31
- type ExpoRuntimeRouterLike,
32
- type ExpoRuntimeThemeMode,
33
28
  resolveExpoRuntimeRoutePath,
34
- } from './expoActionBridge';
29
+ } from './capabilityBridge';
30
+ export type { ComponentRegistry } from './componentRegistry';
31
+ export { createComponentRegistry } from './componentRegistry';
32
+ export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
35
33
  export { ExpoBarcodeScannerAdapter } from './ExpoBarcodeScannerAdapter';
36
34
  export { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';
37
35
  export {
@@ -48,15 +46,11 @@ export {
48
46
  resolveExpoRuntimeGeneratedAppOutput,
49
47
  resolveExpoRuntimeNativeOutput,
50
48
  } from './generatedAppOutput';
51
- export {
52
- getExpoBarcodeScannerViewSource,
53
- getExpoReaderSurfaceViewSource,
54
- } from './generatedSources';
49
+ export { getExpoBarcodeScannerViewSource } from './generatedSources';
55
50
  export {
56
51
  type ExpoRuntimeLayoutIntegrationPlan,
57
52
  resolveExpoRuntimeLayoutIntegration,
58
53
  } from './layoutIntegrationPlanning';
59
- export { ExpoReaderSurfaceAdapter } from './reader/ExpoReaderSurfaceAdapter';
60
54
  export type {
61
55
  ExpoRuntimeAdapterId,
62
56
  ExpoRuntimePlan,
package/src/planning.ts CHANGED
@@ -8,10 +8,7 @@ export {
8
8
  resolveExpoRuntimeGeneratedAppOutput,
9
9
  resolveExpoRuntimeNativeOutput,
10
10
  } from './generatedAppOutput';
11
- export {
12
- getExpoBarcodeScannerViewSource,
13
- getExpoReaderSurfaceViewSource,
14
- } from './generatedSources';
11
+ export { getExpoBarcodeScannerViewSource } from './generatedSources';
15
12
  export {
16
13
  type ExpoRuntimeLayoutIntegrationPlan,
17
14
  resolveExpoRuntimeLayoutIntegration,
@@ -32,17 +32,17 @@ describe('EXPO_PLATFORM', () => {
32
32
  expect(EXPO_PLATFORM.tooling.expoDoctor.name).toBe('expo-doctor');
33
33
  expect(EXPO_PLATFORM.tooling.reactTypes.name).toBe('@types/react');
34
34
  expect(EXPO_PLATFORM.animation.worklets.name).toBe('react-native-worklets');
35
- expect(EXPO_PLATFORM.runtime.expo.version).toBe('57.0.26');
36
- expect(EXPO_PLATFORM.navigation.expoRouter.version).toBe('~57.0.24');
37
- expect(EXPO_PLATFORM.packages.linking.version).toBe('~57.0.11');
35
+ expect(EXPO_PLATFORM.runtime.expo.version).toBe('57.0.27');
36
+ expect(EXPO_PLATFORM.navigation.expoRouter.version).toBe('~57.0.25');
37
+ expect(EXPO_PLATFORM.packages.linking.version).toBe('~57.0.12');
38
38
  expect(EXPO_PLATFORM.packages.metroRuntime.version).toBe('~57.0.16');
39
- expect(EXPO_PLATFORM.packages.constants.version).toBe('~57.0.20');
40
- expect(EXPO_PLATFORM.packages.asset.version).toBe('~57.0.18');
41
- expect(EXPO_PLATFORM.packages.authSession.version).toBe('~57.0.13');
39
+ expect(EXPO_PLATFORM.packages.constants.version).toBe('~57.0.21');
40
+ expect(EXPO_PLATFORM.packages.asset.version).toBe('~57.0.19');
41
+ expect(EXPO_PLATFORM.packages.authSession.version).toBe('~57.0.14');
42
42
  expect(EXPO_PLATFORM.packages.imagePicker.version).toBe('~57.0.20');
43
43
  expect(EXPO_PLATFORM.packages.location.version).toBe('~57.0.20');
44
- expect(EXPO_PLATFORM.packages.notifications.version).toBe('~57.0.21');
45
- expect(EXPO_PLATFORM.packages.updates.version).toBe('~57.0.24');
44
+ expect(EXPO_PLATFORM.packages.notifications.version).toBe('~57.0.22');
45
+ expect(EXPO_PLATFORM.packages.updates.version).toBe('~57.0.25');
46
46
  });
47
47
  });
48
48
 
package/src/platform.ts CHANGED
@@ -18,7 +18,7 @@ export const EXPO_PLATFORM = {
18
18
  sdk: 57,
19
19
  architecture: 'new-architecture-only',
20
20
  runtime: {
21
- expo: definePackage('expo', '57.0.26'),
21
+ expo: definePackage('expo', '57.0.27'),
22
22
  react: definePackage('react', '19.2.3'),
23
23
  reactDom: definePackage('react-dom', '19.2.3'),
24
24
  reactNative: definePackage('react-native', '0.86.3'),
@@ -35,7 +35,7 @@ export const EXPO_PLATFORM = {
35
35
  expoDoctor: definePackage('expo-doctor', '1.20.4'),
36
36
  },
37
37
  navigation: {
38
- expoRouter: definePackage('expo-router', '~57.0.24'),
38
+ expoRouter: definePackage('expo-router', '~57.0.25'),
39
39
  screens: definePackage('react-native-screens', '~4.26.0'),
40
40
  safeArea: definePackage('react-native-safe-area-context', '~5.7.0'),
41
41
  },
@@ -59,11 +59,11 @@ export const EXPO_PLATFORM = {
59
59
  },
60
60
  packages: {
61
61
  metroRuntime: definePackage('@expo/metro-runtime', '~57.0.16'),
62
- asset: definePackage('expo-asset', '~57.0.18'),
62
+ asset: definePackage('expo-asset', '~57.0.19'),
63
63
  audio: definePackage('expo-audio', '~57.0.5'),
64
- authSession: definePackage('expo-auth-session', '~57.0.13'),
64
+ authSession: definePackage('expo-auth-session', '~57.0.14'),
65
65
  camera: definePackage('expo-camera', '~57.0.6'),
66
- constants: definePackage('expo-constants', '~57.0.20'),
66
+ constants: definePackage('expo-constants', '~57.0.21'),
67
67
  crypto: definePackage('expo-crypto', '~57.0.3'),
68
68
  devClient: definePackage('expo-dev-client', '~57.0.19'),
69
69
  documentPicker: definePackage('expo-document-picker', '~57.0.3'),
@@ -71,15 +71,15 @@ export const EXPO_PLATFORM = {
71
71
  font: definePackage('expo-font', '~57.0.4'),
72
72
  imagePicker: definePackage('expo-image-picker', '~57.0.20'),
73
73
  linearGradient: definePackage('expo-linear-gradient', '~57.0.2'),
74
- linking: definePackage('expo-linking', '~57.0.11'),
74
+ linking: definePackage('expo-linking', '~57.0.12'),
75
75
  localization: definePackage('expo-localization', '~57.0.2'),
76
76
  location: definePackage('expo-location', '~57.0.20'),
77
77
  mediaLibrary: definePackage('expo-media-library', '~57.0.5'),
78
- notifications: definePackage('expo-notifications', '~57.0.21'),
78
+ notifications: definePackage('expo-notifications', '~57.0.22'),
79
79
  secureStore: definePackage('expo-secure-store', '~57.0.4'),
80
80
  splashScreen: definePackage('expo-splash-screen', '~57.0.9'),
81
81
  statusBar: definePackage('expo-status-bar', '~57.0.1'),
82
- updates: definePackage('expo-updates', '~57.0.24'),
82
+ updates: definePackage('expo-updates', '~57.0.25'),
83
83
  webBrowser: definePackage('expo-web-browser', '~57.0.3'),
84
84
  },
85
85
  platforms: {
@@ -98,7 +98,7 @@ describe('resolveExpoRuntimePlan barcode capability', () => {
98
98
  });
99
99
 
100
100
  describe('resolveExpoRuntimePlan ebook reader capability', () => {
101
- test('selects the reader adapter and exact renderer packages without permissions', () => {
101
+ test('plans only the published standalone Reader without a custom Expo UI adapter', () => {
102
102
  const plan = resolveExpoRuntimePlan(
103
103
  withFirstScreenRequirements({ capabilities: { ebookReader: true } }),
104
104
  );
@@ -107,27 +107,12 @@ describe('resolveExpoRuntimePlan ebook reader capability', () => {
107
107
  expect(plan.impliedPermissions).toEqual([]);
108
108
  expect(plan.providers).toEqual([]);
109
109
  expect(plan.nativeConfig.plugins).toEqual([]);
110
- expect(plan.runtimeAdapters).toEqual(['ExpoReaderSurfaceAdapter']);
110
+ expect(plan.runtimeAdapters).toEqual([]);
111
+ expect(plan.usesExpoRuntimeRegistry).toBe(false);
111
112
  expect(plan.dependencies.map(({ name, version }) => ({ name, version }))).toEqual([
112
113
  {
113
- name: '@ankhorage/expo-runtime',
114
- version: GENERATED_RUNTIME_DEPENDENCY_VERSIONS['@ankhorage/expo-runtime'],
115
- },
116
- {
117
- name: '@readium/navigator',
118
- version: GENERATED_RUNTIME_DEPENDENCY_VERSIONS['@readium/navigator'],
119
- },
120
- {
121
- name: '@readium/shared',
122
- version: GENERATED_RUNTIME_DEPENDENCY_VERSIONS['@readium/shared'],
123
- },
124
- {
125
- name: '@zip.js/zip.js',
126
- version: GENERATED_RUNTIME_DEPENDENCY_VERSIONS['@zip.js/zip.js'],
127
- },
128
- {
129
- name: 'pdfjs-dist',
130
- version: GENERATED_RUNTIME_DEPENDENCY_VERSIONS['pdfjs-dist'],
114
+ name: '@ankhorage/reader',
115
+ version: GENERATED_RUNTIME_DEPENDENCY_VERSIONS['@ankhorage/reader'],
131
116
  },
132
117
  ]);
133
118
  });
@@ -0,0 +1,18 @@
1
+ import type { Capability } from '@ankhorage/contracts/capabilities';
2
+
3
+ export interface ExpoRuntimeCapabilityHandlerArgs {
4
+ readonly capability: Capability;
5
+ readonly input: unknown;
6
+ }
7
+
8
+ export interface ExpoRuntimeCapabilityHandler {
9
+ readonly capabilityId: Capability['id'];
10
+ readonly execute: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void;
11
+ }
12
+
13
+ export interface ExecuteExpoRuntimeCapabilityArgs {
14
+ readonly capability: unknown;
15
+ readonly input?: unknown;
16
+ readonly capabilityHandlers?: readonly ExpoRuntimeCapabilityHandler[];
17
+ readonly alertImpl?: (message: string) => void;
18
+ }
@@ -0,0 +1,4 @@
1
+ export interface ExpoRuntimeRouteResolution {
2
+ readonly resolvedPath: string;
3
+ readonly unusedParams: Record<string, number | string>;
4
+ }
@@ -1,2 +0,0 @@
1
- export { executeExpoRuntimeAction, type ExecuteExpoRuntimeActionArgs, type ExpoRuntimeActionHandlerArgs, type ExpoRuntimeActionHandlers, type ExpoRuntimeRouteResolution, type ExpoRuntimeRouterLike, type ExpoRuntimeThemeMode, resolveExpoRuntimeRoutePath, } from './expoActionBridge';
2
- //# sourceMappingURL=actionBridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actionBridge.d.ts","sourceRoot":"","sources":["../src/actionBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { executeExpoRuntimeAction, resolveExpoRuntimeRoutePath, } from './expoActionBridge';
2
- //# sourceMappingURL=actionBridge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actionBridge.js","sourceRoot":"","sources":["../src/actionBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAOxB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC","sourcesContent":["export {\n executeExpoRuntimeAction,\n type ExecuteExpoRuntimeActionArgs,\n type ExpoRuntimeActionHandlerArgs,\n type ExpoRuntimeActionHandlers,\n type ExpoRuntimeRouteResolution,\n type ExpoRuntimeRouterLike,\n type ExpoRuntimeThemeMode,\n resolveExpoRuntimeRoutePath,\n} from './expoActionBridge';\n"]}
@@ -1,29 +0,0 @@
1
- import type { Action } from '@ankhorage/contracts';
2
- export type ExpoRuntimeThemeMode = 'dark' | 'light';
3
- export interface ExpoRuntimeRouterLike {
4
- push: (args: {
5
- pathname: string;
6
- params: Record<string, number | string>;
7
- }) => void;
8
- }
9
- export interface ExpoRuntimeActionHandlerArgs {
10
- action: Action;
11
- }
12
- export type ExpoRuntimeActionHandlers = Record<string, (args: ExpoRuntimeActionHandlerArgs) => Promise<void> | void>;
13
- export interface ExecuteExpoRuntimeActionArgs {
14
- action: unknown;
15
- router: ExpoRuntimeRouterLike;
16
- mode: ExpoRuntimeThemeMode;
17
- setMode: (mode: ExpoRuntimeThemeMode) => void;
18
- actionHandlers?: ExpoRuntimeActionHandlers;
19
- requestAnimationFrameImpl?: (callback: () => void) => number | void;
20
- alertImpl?: (message: string) => void;
21
- consoleImpl?: Pick<typeof console, 'log'>;
22
- }
23
- export interface ExpoRuntimeRouteResolution {
24
- resolvedPath: string;
25
- unusedParams: Record<string, number | string>;
26
- }
27
- export declare function resolveExpoRuntimeRoutePath(pathname: string, params?: Record<string, number | string>): ExpoRuntimeRouteResolution;
28
- export declare function executeExpoRuntimeAction(args: ExecuteExpoRuntimeActionArgs): Promise<void>;
29
- //# sourceMappingURL=expoActionBridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expoActionBridge.d.ts","sourceRoot":"","sources":["../src/expoActionBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;CACrF;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAC5C,MAAM,EACN,CAAC,IAAI,EAAE,4BAA4B,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAC7D,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC9C,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C,yBAAyB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC;IACpE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,OAAO,EAAE,KAAK,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC/C;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvC,0BAA0B,CAmB5B;AAUD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CA0EhG"}
@@ -1,78 +0,0 @@
1
- export function resolveExpoRuntimeRoutePath(pathname, params) {
2
- if (!params) {
3
- return { resolvedPath: pathname, unusedParams: {} };
4
- }
5
- let resolvedPath = pathname;
6
- const unusedParams = { ...params };
7
- Object.keys(params).forEach((key) => {
8
- const placeholder = `[${key}]`;
9
- if (!resolvedPath.includes(placeholder)) {
10
- return;
11
- }
12
- resolvedPath = resolvedPath.replace(placeholder, String(params[key]));
13
- delete unusedParams[key];
14
- });
15
- return { resolvedPath, unusedParams };
16
- }
17
- function isAction(value) {
18
- return typeof value === 'object' && value !== null && 'type' in value;
19
- }
20
- function isActionCallback(value) {
21
- return typeof value === 'function';
22
- }
23
- export async function executeExpoRuntimeAction(args) {
24
- const { action, router, mode, setMode, actionHandlers, requestAnimationFrameImpl = (callback) => {
25
- callback();
26
- }, alertImpl, consoleImpl = console, } = args;
27
- if (!action) {
28
- return;
29
- }
30
- if (isActionCallback(action)) {
31
- action();
32
- return;
33
- }
34
- if (!isAction(action)) {
35
- return;
36
- }
37
- if (action.type === 'navigate' && action.payload.route) {
38
- const { route, params } = action.payload;
39
- requestAnimationFrameImpl(() => {
40
- let pathname = route;
41
- if (!pathname.startsWith('/') && !pathname.startsWith('(')) {
42
- pathname = `/${pathname}`;
43
- }
44
- const { resolvedPath, unusedParams } = resolveExpoRuntimeRoutePath(pathname, params);
45
- router.push({
46
- pathname: resolvedPath,
47
- params: unusedParams,
48
- });
49
- });
50
- return;
51
- }
52
- if (action.type === 'toggleDarkMode') {
53
- setMode(mode === 'dark' ? 'light' : 'dark');
54
- return;
55
- }
56
- if (action.type === 'search') {
57
- consoleImpl.log('[Ankh Action] Search:', action.payload);
58
- return;
59
- }
60
- if (action.type === 'filter') {
61
- consoleImpl.log('[Ankh Action] Filter:', action.payload);
62
- return;
63
- }
64
- if (action.type === 'alert') {
65
- const message = action.payload?.message ?? JSON.stringify(action.payload);
66
- alertImpl?.(message);
67
- return;
68
- }
69
- if (action.type === 'console') {
70
- consoleImpl.log('[Ankh Action]', action.payload);
71
- return;
72
- }
73
- const configuredHandler = actionHandlers?.[action.type];
74
- if (configuredHandler) {
75
- await configuredHandler({ action });
76
- }
77
- }
78
- //# sourceMappingURL=expoActionBridge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expoActionBrid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AED,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,WAAW,CAAC,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO;IACT,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1E,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,WAAW,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO;IACT,CAAC;IAED,MAAM,iBAAiB,GAAG,cAAc,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["import type { Action } from '@ankhorage/contracts';\n\nexport type ExpoRuntimeThemeMode = 'dark' | 'light';\n\nexport interface ExpoRuntimeRouterLike {\n push: (args: { pathname: string; params: Record<string, number | string> }) => void;\n}\n\nexport interface ExpoRuntimeActionHandlerArgs {\n action: Action;\n}\n\nexport type ExpoRuntimeActionHandlers = Record<\n string,\n (args: ExpoRuntimeActionHandlerArgs) => Promise<void> | void\n>;\n\nexport interface ExecuteExpoRuntimeActionArgs {\n action: unknown;\n router: ExpoRuntimeRouterLike;\n mode: ExpoRuntimeThemeMode;\n setMode: (mode: ExpoRuntimeThemeMode) => void;\n actionHandlers?: ExpoRuntimeActionHandlers;\n requestAnimationFrameImpl?: (callback: () => void) => number | void;\n alertImpl?: (message: string) => void;\n consoleImpl?: Pick<typeof console, 'log'>;\n}\n\nexport interface ExpoRuntimeRouteResolution {\n resolvedPath: string;\n unusedParams: Record<string, number | string>;\n}\n\nexport function resolveExpoRuntimeRoutePath(\n pathname: string,\n params?: Record<string, number | string>,\n): ExpoRuntimeRouteResolution {\n if (!params) {\n return { resolvedPath: pathname, unusedParams: {} };\n }\n\n let resolvedPath = pathname;\n const unusedParams: Record<string, number | string> = { ...params };\n\n Object.keys(params).forEach((key) => {\n const placeholder = `[${key}]`;\n if (!resolvedPath.includes(placeholder)) {\n return;\n }\n\n resolvedPath = resolvedPath.replace(placeholder, String(params[key]));\n delete unusedParams[key];\n });\n\n return { resolvedPath, unusedParams };\n}\n\nfunction isAction(value: unknown): value is Action {\n return typeof value === 'object' && value !== null && 'type' in value;\n}\n\nfunction isActionCallback(value: unknown): value is () => void {\n return typeof value === 'function';\n}\n\nexport async function executeExpoRuntimeAction(args: ExecuteExpoRuntimeActionArgs): Promise<void> {\n const {\n action,\n router,\n mode,\n setMode,\n actionHandlers,\n requestAnimationFrameImpl = (callback) => {\n callback();\n },\n alertImpl,\n consoleImpl = console,\n } = args;\n\n if (!action) {\n return;\n }\n\n if (isActionCallback(action)) {\n action();\n return;\n }\n\n if (!isAction(action)) {\n return;\n }\n\n if (action.type === 'navigate' && action.payload.route) {\n const { route, params } = action.payload;\n requestAnimationFrameImpl(() => {\n let pathname = route;\n if (!pathname.startsWith('/') && !pathname.startsWith('(')) {\n pathname = `/${pathname}`;\n }\n\n const { resolvedPath, unusedParams } = resolveExpoRuntimeRoutePath(pathname, params);\n router.push({\n pathname: resolvedPath,\n params: unusedParams,\n });\n });\n return;\n }\n\n if (action.type === 'toggleDarkMode') {\n setMode(mode === 'dark' ? 'light' : 'dark');\n return;\n }\n\n if (action.type === 'search') {\n consoleImpl.log('[Ankh Action] Search:', action.payload);\n return;\n }\n\n if (action.type === 'filter') {\n consoleImpl.log('[Ankh Action] Filter:', action.payload);\n return;\n }\n\n if (action.type === 'alert') {\n const message = action.payload?.message ?? JSON.stringify(action.payload);\n alertImpl?.(message);\n return;\n }\n\n if (action.type === 'console') {\n consoleImpl.log('[Ankh Action]', action.payload);\n return;\n }\n\n const configuredHandler = actionHandlers?.[action.type];\n if (configuredHandler) {\n await configuredHandler({ action });\n }\n}\n"]}
@@ -1,4 +0,0 @@
1
- import { type ReaderSurfaceProps } from '@ankhorage/zora';
2
- import React from 'react';
3
- export declare function ExpoReaderSurfaceAdapter(props: ReaderSurfaceProps): React.JSX.Element;
4
- //# sourceMappingURL=ExpoReaderSurfaceAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoReaderSurfaceAdapter.d.ts","sourceRoot":"","sources":["../../src/reader/ExpoReaderSurfaceAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,qBAgCjE"}
@@ -1,102 +0,0 @@
1
- import { ReaderSurface } from '@ankhorage/zora';
2
- import React from 'react';
3
- import { Image, StyleSheet, View } from 'react-native';
4
- import ReaderViewport from './ReaderViewport';
5
- const INITIAL_STATE = {
6
- canGoNext: false,
7
- canGoPrevious: false,
8
- page: 1,
9
- progress: 0,
10
- status: 'loading',
11
- };
12
- export function ExpoReaderSurfaceAdapter(props) {
13
- const sourceUri = resolveReaderSourceUri(props.source);
14
- const controller = useReaderController(props, sourceUri);
15
- const appearance = useReaderAppearance(props);
16
- const viewport = sourceUri ? (<ReaderAdapterViewport appearance={appearance} command={controller.command} format={props.format} initialLocation={props.location} onError={controller.handleError} onOpenExternalLink={controller.handleOpenExternalLink} onStateChange={controller.handleStateChange} sourceUri={sourceUri}/>) : undefined;
17
- return (<ReaderSurface {...props} canGoNext={controller.state.canGoNext} canGoPrevious={controller.state.canGoPrevious} chapterLabel={controller.state.location?.chapterTitle ?? props.chapterLabel} onNextPage={controller.handleNextPage} onPreviousPage={controller.handlePreviousPage} page={controller.state.page} pageCount={controller.state.pageCount} progress={controller.state.progress} status={controller.error ? 'error' : sourceUri ? controller.state.status : 'idle'} viewport={viewport}/>);
18
- }
19
- function ReaderAdapterViewport({ appearance, command, format, initialLocation, onError, onOpenExternalLink, onStateChange, sourceUri, }) {
20
- return (<View style={styles.viewport}>
21
- <ReaderViewport appearance={appearance} command={command} dom={DOM_CONFIGURATION} format={format} initialLocation={initialLocation} key={`${format}:${sourceUri}`} onError={onError} onOpenExternalLink={onOpenExternalLink} onStateChange={onStateChange} sourceUri={sourceUri}/>
22
- </View>);
23
- }
24
- function useReaderController(props, sourceUri) {
25
- const { onLocationChange, onNextPage, onOpenExternalLink, onPreviousPage, onReaderError } = props;
26
- const [state, setState] = React.useState(INITIAL_STATE);
27
- const [error, setError] = React.useState();
28
- const { command, issueCommand } = useReaderCommandState(sourceUri);
29
- const handlePreviousPage = React.useCallback(() => {
30
- issueCommand('previous');
31
- void onPreviousPage?.();
32
- }, [issueCommand, onPreviousPage]);
33
- const handleNextPage = React.useCallback(() => {
34
- issueCommand('next');
35
- void onNextPage?.();
36
- }, [issueCommand, onNextPage]);
37
- const handleStateChange = React.useCallback(async (nextState) => {
38
- setState(nextState);
39
- setError(undefined);
40
- if (nextState.location)
41
- await onLocationChange?.(nextState.location);
42
- }, [onLocationChange]);
43
- const handleError = React.useCallback(async (event) => {
44
- setError(event);
45
- await onReaderError?.(event);
46
- }, [onReaderError]);
47
- const handleOpenExternalLink = React.useCallback(async (event) => onOpenExternalLink?.(event), [onOpenExternalLink]);
48
- return {
49
- command,
50
- error,
51
- handleError,
52
- handleNextPage,
53
- handleOpenExternalLink,
54
- handlePreviousPage,
55
- handleStateChange,
56
- state,
57
- };
58
- }
59
- function useReaderCommandState(sourceUri) {
60
- const [command, setCommand] = React.useState();
61
- const commandIdRef = React.useRef(0);
62
- const issueCommand = React.useCallback((type) => {
63
- if (!sourceUri)
64
- return;
65
- commandIdRef.current += 1;
66
- setCommand({ id: commandIdRef.current, sourceUri, type });
67
- }, [sourceUri]);
68
- return { command, issueCommand };
69
- }
70
- function useReaderAppearance(props) {
71
- const colorScheme = props.readerColorScheme ?? 'system';
72
- const fontScale = props.fontScale ?? 1;
73
- const lineHeight = resolveLineHeight(props.lineHeight ?? 'normal');
74
- return React.useMemo(() => ({ colorScheme, fontScale, lineHeight }), [colorScheme, fontScale, lineHeight]);
75
- }
76
- function resolveReaderSourceUri(source) {
77
- if (typeof source === 'string')
78
- return source;
79
- if (typeof source === 'number')
80
- return Image.resolveAssetSource(source).uri;
81
- return source ? source.uri : undefined;
82
- }
83
- function resolveLineHeight(lineHeight) {
84
- if (lineHeight === 'compact')
85
- return 1.25;
86
- if (lineHeight === 'relaxed')
87
- return 1.75;
88
- return 1.5;
89
- }
90
- const styles = StyleSheet.create({
91
- viewport: { flex: 1, minHeight: 360 },
92
- });
93
- const DOM_CONFIGURATION = {
94
- allowsInlineMediaPlayback: false,
95
- javaScriptCanOpenWindowsAutomatically: false,
96
- mediaPlaybackRequiresUserAction: true,
97
- originWhitelist: ['about:blank', 'blob:*'],
98
- scrollEnabled: false,
99
- style: styles.viewport,
100
- unstable_useExpoModulesBridge: false,
101
- };
102
- //# sourceMappingURL=ExpoReaderSurfaceAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoReaderSurfaceAdapter.js","sourceRoot":"","sources":["../../src/reader/ExpoReaderSurfaceAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAA2B,MAAM,iBAAiB,CAAC;AAChG,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,aAAa,GAAwB;IACzC,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,KAAK;IACpB,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;IACX,MAAM,E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B,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC;IAC5E,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACzC,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAyD;IAClF,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;CACtC,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG;IACxB,yBAAyB,EAAE,KAAK;IAChC,qCAAqC,EAAE,KAAK;IAC5C,+BAA+B,EAAE,IAAI;IACrC,eAAe,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC;IAC1C,aAAa,EAAE,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC,QAAQ;IACtB,6BAA6B,EAAE,KAAK;CACrC,CAAC","sourcesContent":["import { type ReaderErrorEvent, ReaderSurface, type ReaderSurfaceProps } from '@ankhorage/zora';\nimport React from 'react';\nimport { Image, StyleSheet, View } from 'react-native';\n\nimport type { ReaderAppearance, ReaderCommand, ReaderViewportState } from '../types/reader';\nimport ReaderViewport from './ReaderViewport';\n\nconst INITIAL_STATE: ReaderViewportState = {\n canGoNext: false,\n canGoPrevious: false,\n page: 1,\n progress: 0,\n status: 'loading',\n};\n\nexport function ExpoReaderSurfaceAdapter(props: ReaderSurfaceProps) {\n const sourceUri = resolveReaderSourceUri(props.source);\n const controller = useReaderController(props, sourceUri);\n const appearance = useReaderAppearance(props);\n const viewport = sourceUri ? (\n <ReaderAdapterViewport\n appearance={appearance}\n command={controller.command}\n format={props.format}\n initialLocation={props.location}\n onError={controller.handleError}\n onOpenExternalLink={controller.handleOpenExternalLink}\n onStateChange={controller.handleStateChange}\n sourceUri={sourceUri}\n />\n ) : undefined;\n\n return (\n <ReaderSurface\n {...props}\n canGoNext={controller.state.canGoNext}\n canGoPrevious={controller.state.canGoPrevious}\n chapterLabel={controller.state.location?.chapterTitle ?? props.chapterLabel}\n onNextPage={controller.handleNextPage}\n onPreviousPage={controller.handlePreviousPage}\n page={controller.state.page}\n pageCount={controller.state.pageCount}\n progress={controller.state.progress}\n status={controller.error ? 'error' : sourceUri ? controller.state.status : 'idle'}\n viewport={viewport}\n />\n );\n}\n\nfunction ReaderAdapterViewport({\n appearance,\n command,\n format,\n initialLocation,\n onError,\n onOpenExternalLink,\n onStateChange,\n sourceUri,\n}: React.ComponentProps<typeof ReaderViewport>) {\n return (\n <View style={styles.viewport}>\n <ReaderViewport\n appearance={appearance}\n command={command}\n dom={DOM_CONFIGURATION}\n format={format}\n initialLocation={initialLocation}\n key={`${format}:${sourceUri}`}\n onError={onError}\n onOpenExternalLink={onOpenExternalLink}\n onStateChange={onStateChange}\n sourceUri={sourceUri}\n />\n </View>\n );\n}\n\nfunction useReaderController(props: ReaderSurfaceProps, sourceUri: string | undefined) {\n const { onLocationChange, onNextPage, onOpenExternalLink, onPreviousPage, onReaderError } = props;\n const [state, setState] = React.useState<ReaderViewportState>(INITIAL_STATE);\n const [error, setError] = React.useState<ReaderErrorEvent>();\n const { command, issueCommand } = useReaderCommandState(sourceUri);\n const handlePreviousPage = React.useCallback(() => {\n issueCommand('previous');\n void onPreviousPage?.();\n }, [issueCommand, onPreviousPage]);\n const handleNextPage = React.useCallback(() => {\n issueCommand('next');\n void onNextPage?.();\n }, [issueCommand, onNextPage]);\n const handleStateChange = React.useCallback(\n async (nextState: ReaderViewportState) => {\n setState(nextState);\n setError(undefined);\n if (nextState.location) await onLocationChange?.(nextState.location);\n },\n [onLocationChange],\n );\n const handleError = React.useCallback(\n async (event: ReaderErrorEvent) => {\n setError(event);\n await onReaderError?.(event);\n },\n [onReaderError],\n );\n const handleOpenExternalLink = React.useCallback(\n async (event: { readonly url: string }) => onOpenExternalLink?.(event),\n [onOpenExternalLink],\n );\n return {\n command,\n error,\n handleError,\n handleNextPage,\n handleOpenExternalLink,\n handlePreviousPage,\n handleStateChange,\n state,\n };\n}\n\nfunction useReaderCommandState(sourceUri: string | undefined) {\n const [command, setCommand] = React.useState<ReaderCommand>();\n const commandIdRef = React.useRef(0);\n const issueCommand = React.useCallback(\n (type: ReaderCommand['type']) => {\n if (!sourceUri) return;\n commandIdRef.current += 1;\n setCommand({ id: commandIdRef.current, sourceUri, type });\n },\n [sourceUri],\n );\n return { command, issueCommand };\n}\n\nfunction useReaderAppearance(props: ReaderSurfaceProps): ReaderAppearance {\n const colorScheme = props.readerColorScheme ?? 'system';\n const fontScale = props.fontScale ?? 1;\n const lineHeight = resolveLineHeight(props.lineHeight ?? 'normal');\n return React.useMemo(\n () => ({ colorScheme, fontScale, lineHeight }),\n [colorScheme, fontScale, lineHeight],\n );\n}\n\nfunction resolveReaderSourceUri(source: ReaderSurfaceProps['source']): string | undefined {\n if (typeof source === 'string') return source;\n if (typeof source === 'number') return Image.resolveAssetSource(source).uri;\n return source ? source.uri : undefined;\n}\n\nfunction resolveLineHeight(lineHeight: NonNullable<ReaderSurfaceProps['lineHeight']>): number {\n if (lineHeight === 'compact') return 1.25;\n if (lineHeight === 'relaxed') return 1.75;\n return 1.5;\n}\n\nconst styles = StyleSheet.create({\n viewport: { flex: 1, minHeight: 360 },\n});\n\nconst DOM_CONFIGURATION = {\n allowsInlineMediaPlayback: false,\n javaScriptCanOpenWindowsAutomatically: false,\n mediaPlaybackRequiresUserAction: true,\n originWhitelist: ['about:blank', 'blob:*'],\n scrollEnabled: false,\n style: styles.viewport,\n unstable_useExpoModulesBridge: false,\n};\n"]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { ReaderViewportProps } from '../types/reader';
3
- export default function ReaderViewport(props: ReaderViewportProps): React.JSX.Element;
4
- //# sourceMappingURL=ReaderViewport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReaderViewport.d.ts","sourceRoot":"","sources":["../../src/reader/ReaderViewport.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAIV,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AAYzB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAoBhE"}