@symbiote-native/image 0.0.0-stage → 0.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 (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/build/angular/image/index.d.ts +20 -0
  4. package/build/angular/image/index.js +113 -0
  5. package/build/angular/image-background/index.d.ts +14 -0
  6. package/build/angular/image-background/index.js +107 -0
  7. package/build/angular/index.d.ts +4 -0
  8. package/build/angular/index.js +6 -0
  9. package/build/angular/inject-image.d.ts +8 -0
  10. package/build/angular/inject-image.js +20 -0
  11. package/build/core/constants.d.ts +3 -0
  12. package/build/core/constants.js +4 -0
  13. package/build/core/hash-strings.d.ts +5 -0
  14. package/build/core/hash-strings.js +20 -0
  15. package/build/core/image-api.d.ts +18 -0
  16. package/build/core/image-api.js +30 -0
  17. package/build/core/image-background.d.ts +11 -0
  18. package/build/core/image-background.js +26 -0
  19. package/build/core/image-loader.d.ts +20 -0
  20. package/build/core/image-loader.js +42 -0
  21. package/build/core/image-ref-loader.d.ts +4 -0
  22. package/build/core/image-ref-loader.js +10 -0
  23. package/build/core/image-view-events.d.ts +9 -0
  24. package/build/core/image-view-events.js +32 -0
  25. package/build/core/image-view.d.ts +14 -0
  26. package/build/core/image-view.js +111 -0
  27. package/build/core/index.d.ts +10 -0
  28. package/build/core/index.js +7 -0
  29. package/build/core/native-module.d.ts +27 -0
  30. package/build/core/native-module.js +3 -0
  31. package/build/core/native-style.d.ts +19 -0
  32. package/build/core/native-style.js +62 -0
  33. package/build/core/props.d.ts +11 -0
  34. package/build/core/props.js +87 -0
  35. package/build/core/sources.d.ts +8 -0
  36. package/build/core/sources.js +59 -0
  37. package/build/core/types.d.ts +186 -0
  38. package/build/core/types.js +1 -0
  39. package/build/react/image-background.d.ts +7 -0
  40. package/build/react/image-background.js +7 -0
  41. package/build/react/image.d.ts +8 -0
  42. package/build/react/image.js +6 -0
  43. package/build/react/index.d.ts +6 -0
  44. package/build/react/index.js +5 -0
  45. package/build/react/use-image.d.ts +8 -0
  46. package/build/react/use-image.js +20 -0
  47. package/build/solid/image-background.d.ts +7 -0
  48. package/build/solid/image-background.js +4 -0
  49. package/build/solid/image.d.ts +45 -0
  50. package/build/solid/image.js +4 -0
  51. package/build/solid/index.d.ts +5 -0
  52. package/build/solid/index.js +5 -0
  53. package/build/solid/use-image.d.ts +8 -0
  54. package/build/solid/use-image.js +16 -0
  55. package/build/svelte/image-background-props.d.ts +5 -0
  56. package/build/svelte/image-background-props.js +1 -0
  57. package/build/svelte/image-background.svelte +10 -0
  58. package/build/svelte/image-background.svelte.d.ts +4 -0
  59. package/build/svelte/image.svelte +26 -0
  60. package/build/svelte/image.svelte.d.ts +10 -0
  61. package/build/svelte/index.d.ts +6 -0
  62. package/build/svelte/index.js +5 -0
  63. package/build/svelte/use-image.svelte.d.ts +10 -0
  64. package/build/svelte/use-image.svelte.js +26 -0
  65. package/build/vue/image-background.d.ts +3 -0
  66. package/build/vue/image-background.js +12 -0
  67. package/build/vue/image.d.ts +2 -0
  68. package/build/vue/image.js +4 -0
  69. package/build/vue/index.d.ts +4 -0
  70. package/build/vue/index.js +5 -0
  71. package/build/vue/use-image.d.ts +8 -0
  72. package/build/vue/use-image.js +18 -0
  73. package/build-ngc/angular/image/index.d.ts +23 -0
  74. package/build-ngc/angular/image/index.js +72 -0
  75. package/build-ngc/angular/image/index.js.map +1 -0
  76. package/build-ngc/angular/image-background/index.d.ts +17 -0
  77. package/build-ngc/angular/image-background/index.js +66 -0
  78. package/build-ngc/angular/image-background/index.js.map +1 -0
  79. package/build-ngc/angular/index.d.ts +4 -0
  80. package/build-ngc/angular/index.js +7 -0
  81. package/build-ngc/angular/index.js.map +1 -0
  82. package/build-ngc/angular/inject-image.d.ts +8 -0
  83. package/build-ngc/angular/inject-image.js +23 -0
  84. package/build-ngc/angular/inject-image.js.map +1 -0
  85. package/build-ngc/core/constants.d.ts +3 -0
  86. package/build-ngc/core/constants.js +5 -0
  87. package/build-ngc/core/constants.js.map +1 -0
  88. package/build-ngc/core/hash-strings.d.ts +5 -0
  89. package/build-ngc/core/hash-strings.js +21 -0
  90. package/build-ngc/core/hash-strings.js.map +1 -0
  91. package/build-ngc/core/image-api.d.ts +18 -0
  92. package/build-ngc/core/image-api.js +31 -0
  93. package/build-ngc/core/image-api.js.map +1 -0
  94. package/build-ngc/core/image-background.d.ts +11 -0
  95. package/build-ngc/core/image-background.js +27 -0
  96. package/build-ngc/core/image-background.js.map +1 -0
  97. package/build-ngc/core/image-loader.d.ts +20 -0
  98. package/build-ngc/core/image-loader.js +43 -0
  99. package/build-ngc/core/image-loader.js.map +1 -0
  100. package/build-ngc/core/image-ref-loader.d.ts +4 -0
  101. package/build-ngc/core/image-ref-loader.js +11 -0
  102. package/build-ngc/core/image-ref-loader.js.map +1 -0
  103. package/build-ngc/core/image-view-events.d.ts +9 -0
  104. package/build-ngc/core/image-view-events.js +33 -0
  105. package/build-ngc/core/image-view-events.js.map +1 -0
  106. package/build-ngc/core/image-view.d.ts +14 -0
  107. package/build-ngc/core/image-view.js +112 -0
  108. package/build-ngc/core/image-view.js.map +1 -0
  109. package/build-ngc/core/index.d.ts +10 -0
  110. package/build-ngc/core/index.js +8 -0
  111. package/build-ngc/core/index.js.map +1 -0
  112. package/build-ngc/core/native-module.d.ts +27 -0
  113. package/build-ngc/core/native-module.js +4 -0
  114. package/build-ngc/core/native-module.js.map +1 -0
  115. package/build-ngc/core/native-style.d.ts +19 -0
  116. package/build-ngc/core/native-style.js +63 -0
  117. package/build-ngc/core/native-style.js.map +1 -0
  118. package/build-ngc/core/props.d.ts +11 -0
  119. package/build-ngc/core/props.js +88 -0
  120. package/build-ngc/core/props.js.map +1 -0
  121. package/build-ngc/core/sources.d.ts +8 -0
  122. package/build-ngc/core/sources.js +60 -0
  123. package/build-ngc/core/sources.js.map +1 -0
  124. package/build-ngc/core/types.d.ts +186 -0
  125. package/build-ngc/core/types.js +2 -0
  126. package/build-ngc/core/types.js.map +1 -0
  127. package/native-link.json +13 -0
  128. package/package.json +145 -3
  129. package/src/angular/image/index.ts +78 -0
  130. package/src/angular/image-background/index.ts +69 -0
  131. package/src/angular/index.ts +7 -0
  132. package/src/angular/inject-image.ts +29 -0
  133. package/src/core/constants.ts +6 -0
  134. package/src/core/hash-strings.ts +27 -0
  135. package/src/core/image-api.ts +67 -0
  136. package/src/core/image-background.ts +42 -0
  137. package/src/core/image-loader.ts +65 -0
  138. package/src/core/image-ref-loader.ts +16 -0
  139. package/src/core/image-view-events.ts +41 -0
  140. package/src/core/image-view.ts +156 -0
  141. package/src/core/index.ts +50 -0
  142. package/src/core/native-module.ts +45 -0
  143. package/src/core/native-style.ts +89 -0
  144. package/src/core/props.ts +118 -0
  145. package/src/core/sources.ts +70 -0
  146. package/src/core/types.ts +278 -0
  147. package/src/react/image-background.ts +14 -0
  148. package/src/react/image.ts +14 -0
  149. package/src/react/index.ts +8 -0
  150. package/src/react/use-image.ts +29 -0
  151. package/src/solid/image-background.ts +13 -0
  152. package/src/solid/image.ts +8 -0
  153. package/src/solid/index.ts +7 -0
  154. package/src/solid/use-image.ts +30 -0
  155. package/src/svelte/image-background-props.ts +6 -0
  156. package/src/svelte/image-background.svelte +10 -0
  157. package/src/svelte/image.svelte +26 -0
  158. package/src/svelte/index.ts +8 -0
  159. package/src/svelte/svelte-ambient.d.ts +3 -0
  160. package/src/svelte/svelte-compile.test-helper.ts +6 -0
  161. package/src/svelte/use-image.svelte.ts +38 -0
  162. package/src/vue/image-background.ts +17 -0
  163. package/src/vue/image.ts +5 -0
  164. package/src/vue/index.ts +6 -0
  165. package/src/vue/use-image.ts +34 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAE/F,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAE7C,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { IImageSource } from './types';
2
+ /** `blurhash:/<hash>/<width>/<height>` or `<hash>/<width>/<height>` */
3
+ export declare function resolveBlurhashString(str: string): IImageSource;
4
+ /** `thumbhash:/<hash>` or `<hash>` */
5
+ export declare function resolveThumbhashString(str: string): IImageSource;
@@ -0,0 +1,21 @@
1
+ const DEFAULT_HASH_SIZE = 16;
2
+ function hashToUri(type, hash) {
3
+ const encoded = encodeURI(hash).replace(/#/g, '%23').replace(/\?/g, '%3F');
4
+ return `${type}:/${encoded}`;
5
+ }
6
+ /** `blurhash:/<hash>/<width>/<height>` or `<hash>/<width>/<height>` */
7
+ export function resolveBlurhashString(str) {
8
+ const [hash = '', width = '', height = ''] = str.replace(/^blurhash:\//, '').split('/');
9
+ return {
10
+ uri: hashToUri('blurhash', hash),
11
+ width: parseInt(width, 10) || DEFAULT_HASH_SIZE,
12
+ height: parseInt(height, 10) || DEFAULT_HASH_SIZE,
13
+ };
14
+ }
15
+ /** `thumbhash:/<hash>` or `<hash>` */
16
+ export function resolveThumbhashString(str) {
17
+ // A slash at the start of the hash would break the uri path
18
+ const hash = str.replace(/^thumbhash:\//, '').replace(/\//g, '\\');
19
+ return { uri: hashToUri('thumbhash', hash) };
20
+ }
21
+ //# sourceMappingURL=hash-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-strings.js","sourceRoot":"","sources":["../../src/core/hash-strings.ts"],"names":[],"mappings":"AAIA,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,SAAS,SAAS,CAAC,IAAoB,EAAE,IAAY;IACnD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3E,OAAO,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC;AAC/B,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxF,OAAO;QACL,GAAG,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC;QAChC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,iBAAiB;QAC/C,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB;KAClD,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,4DAA4D;IAC5D,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACnE,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { IImageCacheConfig, IImageLoadOptions, IImagePrefetchOptions, IImageSource, ImageRef } from './types';
2
+ type IPrefetchOptions = IImagePrefetchOptions['cachePolicy'] | IImagePrefetchOptions;
3
+ /** The caching policy as a string, or with request headers as an object */
4
+ export declare function prefetchImages(urls: string | string[], options?: IPrefetchOptions): Promise<boolean>;
5
+ export declare const clearMemoryCache: () => Promise<boolean>;
6
+ export declare const clearDiskCache: () => Promise<boolean>;
7
+ export declare const getCachePathAsync: (cacheKey: string) => Promise<string | null>;
8
+ export declare const writeToCacheAsync: (source: string | ImageRef, cacheKey: string) => Promise<void>;
9
+ export declare const readFromCacheAsync: (cacheKey: string) => Promise<ImageRef | null>;
10
+ export declare const configureCache: (config: IImageCacheConfig) => void;
11
+ export declare const generateBlurhashAsync: (source: string | ImageRef, numberOfComponents: [number, number] | {
12
+ width: number;
13
+ height: number;
14
+ }) => Promise<string | null>;
15
+ export declare const generateThumbhashAsync: (source: string | ImageRef) => Promise<string>;
16
+ /** Loads the image into a native `ImageRef`, the caller releases it */
17
+ export declare function loadImageAsync(source: IImageSource | string | number, options?: IImageLoadOptions): Promise<ImageRef>;
18
+ export {};
@@ -0,0 +1,31 @@
1
+ import { toNativeColor } from './native-style';
2
+ import { expoImage } from './native-module';
3
+ import { resolveSource } from './sources';
4
+ const DEFAULT_CACHE_POLICY = 'memory-disk';
5
+ /** The caching policy as a string, or with request headers as an object */
6
+ export function prefetchImages(urls, options) {
7
+ const { cachePolicy = DEFAULT_CACHE_POLICY, headers } = typeof options === 'string' ? { cachePolicy: options } : (options ?? {});
8
+ return expoImage.prefetch(Array.isArray(urls) ? urls : [urls], cachePolicy, headers);
9
+ }
10
+ export const clearMemoryCache = () => expoImage.clearMemoryCache();
11
+ export const clearDiskCache = () => expoImage.clearDiskCache();
12
+ export const getCachePathAsync = (cacheKey) => expoImage.getCachePathAsync(cacheKey);
13
+ export const writeToCacheAsync = (source, cacheKey) => expoImage.writeToCacheAsync(source, cacheKey);
14
+ export const readFromCacheAsync = (cacheKey) => expoImage.readFromCacheAsync(cacheKey);
15
+ export const configureCache = (config) => expoImage.configureCache(config);
16
+ export const generateBlurhashAsync = (source, numberOfComponents) => expoImage.generateBlurhashAsync(source, numberOfComponents);
17
+ export const generateThumbhashAsync = (source) => expoImage.generateThumbhashAsync(source);
18
+ /** Loads the image into a native `ImageRef`, the caller releases it */
19
+ export async function loadImageAsync(source, options = {}) {
20
+ const resolved = resolveSource(source);
21
+ if (!resolved) {
22
+ throw new Error('[expo-image]: the image source could not be resolved');
23
+ }
24
+ const { maxWidth, maxHeight, tintColor } = options;
25
+ return expoImage.loadAsync(resolved, {
26
+ maxWidth,
27
+ maxHeight,
28
+ tintColor: toNativeColor(tintColor),
29
+ });
30
+ }
31
+ //# sourceMappingURL=image-api.js.map
@@ -0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,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAyB,EAAQ,EAAE,CAChE,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,MAAyB,EACzB,kBAAwE,EAChD,EAAE,CAAC,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAEzF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAyB,EAAmB,EAAE,CACnF,SAAS,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAE3C,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAsC,EACtC,UAA6B,EAAE;IAE/B,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACnD,OAAO,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnC,QAAQ;QACR,SAAS;QACT,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC;KACpC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { IDescriptor } from '@symbiote-native/components';
2
+ import type { IStyleProp } from '@symbiote-native/engine';
3
+ import type { IImageStyle, IImageViewProps } from './types';
4
+ export type IImageBackgroundProps = IImageViewProps & {
5
+ /** Style of the image itself, `style` goes to the wrapping view */
6
+ imageStyle?: IStyleProp<IImageStyle>;
7
+ /** Goes to the wrapping view, as `style` does */
8
+ className?: string;
9
+ };
10
+ /** A view with an image filling it, the children of the app go after this descriptor */
11
+ export declare function renderImageBackground(props: IImageBackgroundProps): IDescriptor;
@@ -0,0 +1,27 @@
1
+ import { el } from '@symbiote-native/components';
2
+ import { createImageView } from './image-view';
3
+ const CLASS_KEYS = new Set(['className', 'class']);
4
+ function isClassEntry([key]) {
5
+ return CLASS_KEYS.has(key);
6
+ }
7
+ const ABSOLUTE_FILL = {
8
+ position: 'absolute',
9
+ left: 0,
10
+ right: 0,
11
+ top: 0,
12
+ bottom: 0,
13
+ };
14
+ // The background image has no handle, so nobody asks it for a host node
15
+ const backgroundImage = createImageView(() => null);
16
+ /** A view with an image filling it, the children of the app go after this descriptor */
17
+ export function renderImageBackground(props) {
18
+ const { style, imageStyle, ...rest } = props;
19
+ const entries = Object.entries(rest);
20
+ const image = backgroundImage.render({
21
+ ...Object.fromEntries(entries.filter(entry => !isClassEntry(entry))),
22
+ style: [ABSOLUTE_FILL, imageStyle],
23
+ });
24
+ const viewClass = Object.fromEntries(entries.filter(isClassEntry));
25
+ return el('view', { style, ...viewClass }, image ? [image] : []);
26
+ }
27
+ //# sourceMappingURL=image-background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-background.js","sourceRoot":"","sources":["../../src/core/image-background.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAC;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAW/C,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAEnF,SAAS,YAAY,CAAC,CAAC,GAAG,CAAoB;IAC5C,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,aAAa,GAAG;IACpB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;CACqB,CAAC;AAEjC,wEAAwE;AACxE,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AAEpD,wFAAwF;AACxF,MAAM,UAAU,qBAAqB,CAAC,KAA4B;IAChE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC;QACnC,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QACpE,KAAK,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC;KACnC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACnE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { IImageLoadOptions, IImageSource } from './types';
2
+ export type IImageLoaderConfig<TImage extends {
3
+ release(): void;
4
+ }> = {
5
+ load(source: IImageSource | string | number, options: IImageLoadOptions): Promise<TImage>;
6
+ /** Called with each image that finished loading */
7
+ onImage(image: TImage): void;
8
+ /** Read at the time of a failure, so the latest callback wins */
9
+ getOptions(): IImageLoadOptions;
10
+ };
11
+ export type IImageLoader = {
12
+ /** Starts a load and drops the result of the one before */
13
+ load(source: IImageSource | string | number): void;
14
+ /** Drops a load in flight and releases the image loaded last */
15
+ cancel(): void;
16
+ };
17
+ /** What a `useImage` hook drives with its own lifecycle */
18
+ export declare function createImageLoader<TImage extends {
19
+ release(): void;
20
+ }>(config: IImageLoaderConfig<TImage>): IImageLoader;
@@ -0,0 +1,43 @@
1
+ /** What a `useImage` hook drives with its own lifecycle */
2
+ export function createImageLoader(config) {
3
+ let token = 0;
4
+ let loaded = null;
5
+ function release() {
6
+ loaded?.release();
7
+ loaded = null;
8
+ }
9
+ function fail(source, error, retry) {
10
+ const { onError } = config.getOptions();
11
+ if (onError) {
12
+ onError(error instanceof Error ? error : new Error(String(error)), retry);
13
+ return;
14
+ }
15
+ console.error(`Loading an image from '${JSON.stringify(source)}' failed, use 'onError' to handle errors`);
16
+ console.error(error);
17
+ }
18
+ function load(source) {
19
+ release();
20
+ token += 1;
21
+ const mine = token;
22
+ config
23
+ .load(source, config.getOptions())
24
+ .then(image => {
25
+ if (mine !== token)
26
+ return;
27
+ loaded = image;
28
+ config.onImage(image);
29
+ })
30
+ .catch((error) => {
31
+ if (mine === token)
32
+ fail(source, error, () => load(source));
33
+ });
34
+ }
35
+ return {
36
+ load,
37
+ cancel: () => {
38
+ token += 1;
39
+ release();
40
+ },
41
+ };
42
+ }
43
+ //# sourceMappingURL=image-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-loader.js","sourceRoot":"","sources":["../../src/core/image-loader.ts"],"names":[],"mappings":"AAiBA,2DAA2D;AAC3D,MAAM,UAAU,iBAAiB,CAC/B,MAAkC;IAElC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,GAAkB,IAAI,CAAC;IAEjC,SAAS,OAAO;QACd,MAAM,EAAE,OAAO,EAAE,CAAC;QAClB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IAED,SAAS,IAAI,CAAC,MAAsC,EAAE,KAAc,EAAE,KAAiB;QACrF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACxC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QACD,OAAO,CAAC,KAAK,CACX,0BAA0B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,0CAA0C,CAC3F,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,SAAS,IAAI,CAAC,MAAsC;QAClD,OAAO,EAAE,CAAC;QACV,KAAK,IAAI,CAAC,CAAC;QACX,MAAM,IAAI,GAAG,KAAK,CAAC;QACnB,MAAM;aACH,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;aACjC,IAAI,CAAC,KAAK,CAAC,EAAE;YACZ,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO;YAC3B,MAAM,GAAG,KAAK,CAAC;YACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,IAAI,IAAI,KAAK,KAAK;gBAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,GAAG,EAAE;YACX,KAAK,IAAI,CAAC,CAAC;YACX,OAAO,EAAE,CAAC;QACZ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IImageLoader } from './image-loader';
2
+ import type { IImageLoadOptions, ImageRef } from './types';
3
+ /** The loader every `useImage` hook drives, `getOptions` is read at each load and failure */
4
+ export declare function createImageRefLoader(onImage: (image: ImageRef) => void, getOptions: () => IImageLoadOptions): IImageLoader;
@@ -0,0 +1,11 @@
1
+ import { loadImageAsync } from './image-api';
2
+ import { createImageLoader } from './image-loader';
3
+ /** The loader every `useImage` hook drives, `getOptions` is read at each load and failure */
4
+ export function createImageRefLoader(onImage, getOptions) {
5
+ return createImageLoader({
6
+ load: loadImageAsync,
7
+ onImage,
8
+ getOptions,
9
+ });
10
+ }
11
+ //# sourceMappingURL=image-ref-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-ref-loader.js","sourceRoot":"","sources":["../../src/core/image-ref-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAInD,6FAA6F;AAC7F,MAAM,UAAU,oBAAoB,CAClC,OAAkC,EAClC,UAAmC;IAEnC,OAAO,iBAAiB,CAAW;QACjC,IAAI,EAAE,cAAc;QACpB,OAAO;QACP,UAAU;KACX,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ISymbioteEvent } from '@symbiote-native/engine';
2
+ import type { IImageViewProps } from './types';
3
+ /** The native payload sits in `nativeEvent`, callbacks get it as the event itself */
4
+ export declare function toImageEvents(props: IImageViewProps): {
5
+ onLoadStart: () => void | undefined;
6
+ onLoad: (event: ISymbioteEvent) => void;
7
+ onProgress: (event: ISymbioteEvent) => void;
8
+ onError: (event: ISymbioteEvent) => void;
9
+ };
@@ -0,0 +1,33 @@
1
+ function field(value, key) {
2
+ return Reflect.get(Object(value), key);
3
+ }
4
+ function isLoad(value) {
5
+ return typeof field(value, 'cacheType') === 'string' && typeof field(value, 'source') === 'object';
6
+ }
7
+ function isProgress(value) {
8
+ return typeof field(value, 'loaded') === 'number' && typeof field(value, 'total') === 'number';
9
+ }
10
+ function isError(value) {
11
+ return typeof field(value, 'error') === 'string';
12
+ }
13
+ /** The native payload sits in `nativeEvent`, callbacks get it as the event itself */
14
+ export function toImageEvents(props) {
15
+ return {
16
+ onLoadStart: () => props.onLoadStart?.(),
17
+ onLoad: (event) => {
18
+ if (isLoad(event.nativeEvent))
19
+ props.onLoad?.(event.nativeEvent);
20
+ props.onLoadEnd?.();
21
+ },
22
+ onProgress: (event) => {
23
+ if (isProgress(event.nativeEvent))
24
+ props.onProgress?.(event.nativeEvent);
25
+ },
26
+ onError: (event) => {
27
+ if (isError(event.nativeEvent))
28
+ props.onError?.(event.nativeEvent);
29
+ props.onLoadEnd?.();
30
+ },
31
+ };
32
+ }
33
+ //# sourceMappingURL=image-view-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-view-events.js","sourceRoot":"","sources":["../../src/core/image-view-events.ts"],"names":[],"mappings":"AAQA,SAAS,KAAK,CAAC,KAAc,EAAE,GAAW;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,QAAQ,CAAC;AACrG,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,QAAQ,CAAC;AACjG,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,QAAQ,CAAC;AACnD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,OAAO;QACL,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE;QACxC,MAAM,EAAE,CAAC,KAAqB,EAAE,EAAE;YAChC,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;gBAAE,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACjE,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACtB,CAAC;QACD,UAAU,EAAE,CAAC,KAAqB,EAAE,EAAE;YACpC,IAAI,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC;gBAAE,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,EAAE,CAAC,KAAqB,EAAE,EAAE;YACjC,IAAI,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC;gBAAE,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACnE,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { IDescriptor } from '@symbiote-native/components';
2
+ import type { ISymbioteNode } from '@symbiote-native/engine';
3
+ import type { IImageViewHandle, IImageViewProps } from './types';
4
+ export declare const imageViewName: () => string;
5
+ export declare const ensureImageViewRegistered: () => boolean;
6
+ export type IImageView = {
7
+ handle: IImageViewHandle;
8
+ /** `null` means the view cannot register and the caller renders nothing */
9
+ render(props: IImageViewProps): IDescriptor | null;
10
+ };
11
+ type IGetNode = () => ISymbioteNode | null | undefined;
12
+ /** One per mounted view, `getNode` answers the host node once it exists */
13
+ export declare function createImageView(getNode: IGetNode): IImageView;
14
+ export {};
@@ -0,0 +1,112 @@
1
+ import { requireNativeModule, requireNativeViewManager } from 'expo-modules-core';
2
+ import { el } from '@symbiote-native/components';
3
+ import { defineExpoNativeView, defineExpoViewMethods, getNativeTag, isDevBuild, styleOfProps, } from '@symbiote-native/engine';
4
+ import { IMAGE_MODULE_NAME, SF_SYMBOL_PREFIX } from './constants';
5
+ import { toImageEvents } from './image-view-events';
6
+ import { nativeColorProps, platformStyle, splitImageStyle, toNativeColor, } from './native-style';
7
+ import { resolveContentFit, resolveContentPosition, resolveSfEffect, resolveTransition, warnOnce, } from './props';
8
+ import { resolveSources } from './sources';
9
+ // Registered on render: a barrel side effect is lost in a release build
10
+ const imageView = defineExpoNativeView(requireNativeViewManager, IMAGE_MODULE_NAME);
11
+ const callViewFunction = defineExpoViewMethods(requireNativeModule, IMAGE_MODULE_NAME);
12
+ export const imageViewName = imageView.name;
13
+ export const ensureImageViewRegistered = imageView.ensureRegistered;
14
+ // Props the view reads itself and native has no use for
15
+ const OWN_PROPS = [
16
+ 'style',
17
+ 'source',
18
+ 'placeholder',
19
+ 'contentFit',
20
+ 'contentPosition',
21
+ 'transition',
22
+ 'fadeDuration',
23
+ 'resizeMode',
24
+ 'defaultSource',
25
+ 'loadingIndicatorSource',
26
+ 'sfEffect',
27
+ 'alt',
28
+ ];
29
+ function hasSfSymbol(sources) {
30
+ return (Array.isArray(sources) &&
31
+ sources.some(source => source.uri?.startsWith(`${SF_SYMBOL_PREFIX}/`)));
32
+ }
33
+ function withoutOwnProps(props) {
34
+ const own = OWN_PROPS;
35
+ return Object.fromEntries(Object.entries(props).filter(([key]) => !own.includes(key)));
36
+ }
37
+ function placeholderOf(props) {
38
+ const { defaultSource, loadingIndicatorSource } = props;
39
+ if (defaultSource || loadingIndicatorSource) {
40
+ warnOnce('`defaultSource` and `loadingIndicatorSource` props are deprecated, use `placeholder`');
41
+ }
42
+ return resolveSources(props.placeholder ?? defaultSource ?? loadingIndicatorSource);
43
+ }
44
+ // For an SF Symbol `fontSize` sizes both the symbol and its container
45
+ function symbolProps(parts, isSfSymbol) {
46
+ if (!isSfSymbol)
47
+ return { symbolWeight: null, symbolSize: null };
48
+ const { fontWeight, fontSize } = parts;
49
+ return {
50
+ symbolWeight: fontWeight === undefined ? null : String(fontWeight),
51
+ symbolSize: fontSize || null,
52
+ };
53
+ }
54
+ function sizedStyle(parts, isSfSymbol) {
55
+ const { fontSize, rest } = parts;
56
+ return isSfSymbol && fontSize ? { width: fontSize, height: fontSize, ...rest } : rest;
57
+ }
58
+ function nativeProps(props) {
59
+ const parts = splitImageStyle(styleOfProps(props));
60
+ const source = resolveSources(props.source);
61
+ const isSfSymbol = hasSfSymbol(source);
62
+ const sized = sizedStyle(parts, isSfSymbol);
63
+ const style = platformStyle(sized);
64
+ const symbolColor = isSfSymbol ? parts.color : undefined;
65
+ return {
66
+ ...withoutOwnProps(props),
67
+ ...style,
68
+ accessibilityLabel: props.accessibilityLabel ?? props.alt,
69
+ style,
70
+ source,
71
+ placeholder: placeholderOf(props),
72
+ contentFit: resolveContentFit(props.contentFit, props.resizeMode ?? parts.resizeMode, isSfSymbol),
73
+ contentPosition: resolveContentPosition(props.contentPosition),
74
+ transition: resolveTransition(props.transition, props.fadeDuration),
75
+ sfEffect: resolveSfEffect(props.sfEffect),
76
+ ...symbolProps(parts, isSfSymbol),
77
+ ...nativeColorProps(sized),
78
+ tintColor: toNativeColor(props.tintColor || symbolColor || style.tintColor),
79
+ ...toImageEvents(props),
80
+ };
81
+ }
82
+ function createImageViewHandle(getNode) {
83
+ // Like upstream's `ref.current?.`, a view that has not committed yet answers nothing
84
+ async function call(method) {
85
+ const node = getNode();
86
+ if (!node || getNativeTag(node) === undefined)
87
+ return;
88
+ await callViewFunction(node, method, []);
89
+ }
90
+ return {
91
+ startAnimating: () => call('startAnimating'),
92
+ stopAnimating: () => call('stopAnimating'),
93
+ lockResourceAsync: () => call('lockResourceAsync'),
94
+ unlockResourceAsync: () => call('unlockResourceAsync'),
95
+ reloadAsync: () => call('reloadAsync'),
96
+ };
97
+ }
98
+ /** One per mounted view, `getNode` answers the host node once it exists */
99
+ export function createImageView(getNode) {
100
+ return {
101
+ handle: createImageViewHandle(getNode),
102
+ render: props => {
103
+ if (!ensureImageViewRegistered()) {
104
+ if (isDevBuild())
105
+ console.warn("'Image' is not available.");
106
+ return null;
107
+ }
108
+ return el(imageViewName(), nativeProps(props));
109
+ },
110
+ };
111
+ }
112
+ //# sourceMappingURL=image-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-view.js","sourceRoot":"","sources":["../../src/core/image-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,m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AAK,UAAU,IAAI,CAAC,MAAc;QAChC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO;QACtD,MAAM,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO;QACL,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAC5C,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC;QAC1C,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC;QAClD,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC;QACtD,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,eAAe,CAAC,OAAiB;IAC/C,OAAO;QACL,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC;QACtC,MAAM,EAAE,KAAK,CAAC,EAAE;YACd,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC;gBACjC,IAAI,UAAU,EAAE;oBAAE,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;gBAC5D,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,EAAE,CAAC,aAAa,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { IMAGE_MODULE_NAME } from './constants';
2
+ export { clearDiskCache, clearMemoryCache, configureCache, generateBlurhashAsync, generateThumbhashAsync, getCachePathAsync, loadImageAsync, prefetchImages, readFromCacheAsync, writeToCacheAsync, } from './image-api';
3
+ export { renderImageBackground } from './image-background';
4
+ export type { IImageBackgroundProps } from './image-background';
5
+ export { createImageRefLoader } from './image-ref-loader';
6
+ export { createImageLoader } from './image-loader';
7
+ export type { IImageLoader, IImageLoaderConfig } from './image-loader';
8
+ export { createImageView, ensureImageViewRegistered, imageViewName, type IImageView, } from './image-view';
9
+ export { isImageRef, resolveSource, resolveSources } from './sources';
10
+ export type { IImageCacheConfig, IImageContentFit, IImageContentPosition, IImageContentPositionObject, IImageContentPositionString, IImageContentPositionValue, IImageDecodeFormat, IImageErrorEventData, IImageLoadEventData, IImageLoadOptions, IImagePrefetchOptions, IImageProgressEventData, IImageResizeMode, IImageSource, IImageSources, IImageStyle, IImageTransition, IImageViewHandle, IImageViewProps, ISfSymbolEffect, ISfSymbolEffectObject, ISfSymbolEffectType, ImageRef, } from './types';
@@ -0,0 +1,8 @@
1
+ export { IMAGE_MODULE_NAME } from './constants';
2
+ export { clearDiskCache, clearMemoryCache, configureCache, generateBlurhashAsync, generateThumbhashAsync, getCachePathAsync, loadImageAsync, prefetchImages, readFromCacheAsync, writeToCacheAsync, } from './image-api';
3
+ export { renderImageBackground } from './image-background';
4
+ export { createImageRefLoader } from './image-ref-loader';
5
+ export { createImageLoader } from './image-loader';
6
+ export { createImageView, ensureImageViewRegistered, imageViewName, } from './image-view';
7
+ export { isImageRef, resolveSource, resolveSources } from './sources';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,aAAa,GAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { EventSubscription } from 'expo-modules-core';
2
+ import type { IImageCacheConfig, IImageLoadOptions, IImagePrefetchOptions, IImageSource, ImageRef } from './types';
3
+ export type INativeImageModule = {
4
+ Image: typeof ImageRef;
5
+ loadAsync(source: IImageSource, options?: Omit<IImageLoadOptions, 'onError' | 'tintColor'> & {
6
+ /** What `processColor` answers */
7
+ tintColor?: unknown;
8
+ }): Promise<ImageRef>;
9
+ prefetch(urls: string[], cachePolicy: IImagePrefetchOptions['cachePolicy'], headers?: Record<string, string>): Promise<boolean>;
10
+ clearMemoryCache(): Promise<boolean>;
11
+ clearDiskCache(): Promise<boolean>;
12
+ configureCache(config: IImageCacheConfig): void;
13
+ getCachePathAsync(cacheKey: string): Promise<string | null>;
14
+ writeToCacheAsync(source: string | ImageRef, cacheKey: string): Promise<void>;
15
+ readFromCacheAsync(cacheKey: string): Promise<ImageRef | null>;
16
+ generateBlurhashAsync(source: string | ImageRef, numberOfComponents: [number, number] | {
17
+ width: number;
18
+ height: number;
19
+ }): Promise<string | null>;
20
+ generateThumbhashAsync(source: string | ImageRef): Promise<string>;
21
+ addListener(eventName: string, listener: (event: {
22
+ url: string;
23
+ width: number;
24
+ height: number;
25
+ }) => void): EventSubscription;
26
+ };
27
+ export declare const expoImage: INativeImageModule;
@@ -0,0 +1,4 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ import { IMAGE_MODULE_NAME } from './constants';
3
+ export const expoImage = requireNativeModule(IMAGE_MODULE_NAME);
4
+ //# sourceMappingURL=native-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwChD,MAAM,CAAC,MAAM,SAAS,GAAG,mBAAmB,CAC1C,iBAAiB,CAClB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { IImageResizeMode } from './types';
2
+ type IStyleBag = Record<string, unknown>;
3
+ export type IImageStyleParts = {
4
+ resizeMode?: IImageResizeMode;
5
+ fontWeight?: string | number;
6
+ fontSize?: number;
7
+ color?: unknown;
8
+ /** What is left once the text-like keys are taken out */
9
+ rest: IStyleBag;
10
+ };
11
+ /** An Expo view has no attribute processor for colors, so they go through here */
12
+ export declare function toNativeColor(value: unknown): unknown;
13
+ /** `resizeMode` and the SF Symbol keys are props to native, not style */
14
+ export declare function splitImageStyle(style: unknown): IImageStyleParts;
15
+ /** Android shadows by `elevation` and paints the background itself, iOS by `shadow*` */
16
+ export declare function platformStyle(style: IStyleBag): IStyleBag;
17
+ /** `backgroundColor` and the border colors in the form native reads */
18
+ export declare function nativeColorProps(style: IStyleBag): IStyleBag;
19
+ export {};
@@ -0,0 +1,63 @@
1
+ import { Platform } from 'expo-modules-core';
2
+ import { flattenStyle, processColor } from '@symbiote-native/engine';
3
+ const SHADOW_KEYS = [
4
+ 'shadowColor',
5
+ 'shadowOffset',
6
+ 'shadowOpacity',
7
+ 'shadowRadius',
8
+ ];
9
+ const BORDER_COLOR_KEYS = [
10
+ 'borderColor',
11
+ 'borderStartColor',
12
+ 'borderEndColor',
13
+ 'borderLeftColor',
14
+ 'borderRightColor',
15
+ 'borderTopColor',
16
+ 'borderBottomColor',
17
+ ];
18
+ const RESIZE_MODES = new Set([
19
+ 'cover',
20
+ 'contain',
21
+ 'stretch',
22
+ 'repeat',
23
+ 'center',
24
+ ]);
25
+ function isResizeMode(value) {
26
+ return RESIZE_MODES.has(value);
27
+ }
28
+ function isColorValue(value) {
29
+ return (typeof value === 'string' ||
30
+ typeof value === 'number' ||
31
+ (typeof value === 'object' && value !== null));
32
+ }
33
+ /** An Expo view has no attribute processor for colors, so they go through here */
34
+ export function toNativeColor(value) {
35
+ return isColorValue(value) ? processColor(value) : undefined;
36
+ }
37
+ /** `resizeMode` and the SF Symbol keys are props to native, not style */
38
+ export function splitImageStyle(style) {
39
+ const { resizeMode, fontWeight, fontSize, color, ...rest } = flattenStyle(style);
40
+ const isWeight = typeof fontWeight === 'string' || typeof fontWeight === 'number';
41
+ return {
42
+ resizeMode: isResizeMode(resizeMode) ? resizeMode : undefined,
43
+ fontWeight: isWeight ? fontWeight : undefined,
44
+ fontSize: typeof fontSize === 'number' ? fontSize : undefined,
45
+ color,
46
+ rest,
47
+ };
48
+ }
49
+ function without(bag, keys) {
50
+ return Object.fromEntries(Object.entries(bag).filter(([key]) => !keys.includes(key)));
51
+ }
52
+ /** Android shadows by `elevation` and paints the background itself, iOS by `shadow*` */
53
+ export function platformStyle(style) {
54
+ return Platform.select({
55
+ android: without(style, [...SHADOW_KEYS, 'backgroundColor']),
56
+ default: without(style, ['elevation']),
57
+ });
58
+ }
59
+ /** `backgroundColor` and the border colors in the form native reads */
60
+ export function nativeColorProps(style) {
61
+ return Object.fromEntries(['backgroundColor', ...BORDER_COLOR_KEYS].map(key => [key, toNativeColor(style[key])]));
62
+ }
63
+ //# sourceMappingURL=native-style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-style.js","sourceRoot":"","sources":["../../src/core/native-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAMrE,MAAM,WAAW,GAAG;IAClB,aAAa;IACb,cAAc;IACd,eAAe;IACf,cAAc;CACkC,CAAC;AAEnD,MAAM,iBAAiB,GAAG;IACxB,aAAa;IACb,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB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c,EAAE,IAAuB;IACtD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAAC,KAAgB;IAC5C,OAAO,QAAQ,CAAC,MAAM,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,EAAE,iBAAiB,CAAC,CAAC;QAC5D,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC;KACvC,CAAC,CAAC;AACL,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,KAAgB;IAC/C,OAAO,MAAM,CAAC,WAAW,CACvB,CAAC,iBAAiB,EAAE,GAAG,iBAAiB,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACvF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { IImageContentFit, IImageContentPosition, IImageContentPositionObject, IImageResizeMode, IImageTransition, IImageViewProps, ISfSymbolEffectObject } from './types';
2
+ export declare function warnOnce(message: string): void;
3
+ export declare function resetDeprecationWarnings(): void;
4
+ /** An SF Symbol defaults to `contain` to keep its aspect ratio */
5
+ export declare function resolveContentFit(contentFit?: IImageContentFit, resizeMode?: IImageResizeMode, isSfSymbol?: boolean): IImageContentFit;
6
+ /** Native reads only the two-edge object form */
7
+ export declare function resolveContentPosition(contentPosition?: IImageContentPosition): IImageContentPositionObject;
8
+ /** Every form of `sfEffect` becomes a list of effect objects */
9
+ export declare function resolveSfEffect(sfEffect: IImageViewProps['sfEffect']): ISfSymbolEffectObject[] | null;
10
+ /** A number is the duration of a cross dissolve */
11
+ export declare function resolveTransition(transition?: IImageViewProps['transition'], fadeDuration?: IImageViewProps['fadeDuration']): IImageTransition | null;