@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,6 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { IImageBackgroundProps } from '../core';
3
+
4
+ export type IImageBackgroundSvelteProps = IImageBackgroundProps & {
5
+ children?: Snippet;
6
+ };
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import DescriptorHost from '@symbiote-native/svelte/descriptor-host';
3
+ import { renderImageBackground } from '../core';
4
+ import type { IImageBackgroundSvelteProps } from './image-background-props';
5
+
6
+ const { children, ...rest }: IImageBackgroundSvelteProps = $props();
7
+ const descriptor = $derived(renderImageBackground({ ...rest }));
8
+ </script>
9
+
10
+ <DescriptorHost {descriptor} {children} />
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ // The native view name is mixed-case, which a literal tag would parse as a component reference,
3
+ // so the tag is dynamic
4
+ import { hostProps } from '@symbiote-native/svelte/native-view-bridge';
5
+ import { useNativeViewController } from '@symbiote-native/svelte/runes/use-native-view-controller';
6
+ import { createImageView } from '../core';
7
+ import type { IImageViewProps } from '../core';
8
+
9
+ const props: IImageViewProps = $props();
10
+ const view = useNativeViewController(createImageView, () => ({ ...props }));
11
+
12
+ // The functions of the view are instance members, `bind:this` reaches them
13
+ export const startAnimating = view.handle.startAnimating;
14
+ export const stopAnimating = view.handle.stopAnimating;
15
+ export const lockResourceAsync = view.handle.lockResourceAsync;
16
+ export const unlockResourceAsync = view.handle.unlockResourceAsync;
17
+ export const reloadAsync = view.handle.reloadAsync;
18
+ </script>
19
+
20
+ {#if view.descriptor}
21
+ <svelte:element
22
+ this={view.descriptor.type}
23
+ {@attach view.attachHost}
24
+ {@attach hostProps(view.descriptor.props)}
25
+ />
26
+ {/if}
@@ -0,0 +1,8 @@
1
+ // @symbiote-native/image/svelte: the image view, its cache and hash functions on a shared core
2
+
3
+ export { default as Image } from './image.svelte';
4
+ export { default as ImageBackground } from './image-background.svelte';
5
+ export type { IImageBackgroundSvelteProps } from './image-background-props';
6
+ export { useImage } from './use-image.svelte';
7
+ export type { IUseImageResult } from './use-image.svelte';
8
+ export * from '../core';
@@ -0,0 +1,3 @@
1
+ // Pulls in svelte's ambient globals ($state/$effect/...) for this package's tsc program
2
+ // This package has no value import from 'svelte', so a triple-slash reference does it explicitly
3
+ /// <reference types="svelte" />
@@ -0,0 +1,6 @@
1
+ // Re-exports the existing harness instead of another copy
2
+ export {
3
+ createSvelteHarness,
4
+ loadComponent,
5
+ type ISvelteHarness,
6
+ } from '../../../sqlite/src/svelte/svelte-compile.test-helper';
@@ -0,0 +1,38 @@
1
+ import { untrack } from 'svelte';
2
+ import { createImageRefLoader, resolveSource } from '../core';
3
+ import type { IImageLoadOptions, IImageSource, ImageRef } from '../core';
4
+
5
+ export type IUseImageResult = {
6
+ readonly current: ImageRef | null;
7
+ };
8
+
9
+ /**
10
+ * Svelte twin of `expo-image`'s `useImage`, boxed getter shape of the other hooks
11
+ *
12
+ * It loads again when the uri of the source or a value read by `getDependencies` changes
13
+ */
14
+ export function useImage(
15
+ getSource: () => IImageSource | string | number,
16
+ getOptions: () => IImageLoadOptions = () => ({}),
17
+ getDependencies: () => unknown[] = () => [],
18
+ ): IUseImageResult {
19
+ let image = $state.raw<ImageRef | null>(null);
20
+ const key = $derived(resolveSource(getSource())?.uri);
21
+
22
+ $effect(() => {
23
+ // Read so the effect tracks them, the source itself is not a trigger
24
+ key;
25
+ getDependencies();
26
+ const loader = createImageRefLoader(loaded => {
27
+ image = loaded;
28
+ }, getOptions);
29
+ untrack(() => loader.load(getSource()));
30
+ return loader.cancel;
31
+ });
32
+
33
+ return {
34
+ get current(): ImageRef | null {
35
+ return image;
36
+ },
37
+ };
38
+ }
@@ -0,0 +1,17 @@
1
+ import { defineComponent, type VNode } from '@vue/runtime-core';
2
+ import { descriptorToVue, normalizeVueAttrs } from '@symbiote-native/vue';
3
+ import { renderImageBackground } from '../core';
4
+
5
+ /** Vue twin of `expo-image`'s `ImageBackground`, the default slot paints over the image */
6
+ export const ImageBackground = defineComponent({
7
+ name: 'ImageBackground',
8
+ // Every attribute is a prop of the image or the view, nothing leaks onto the wrapper
9
+ inheritAttrs: false,
10
+ setup(_props, { attrs, slots }) {
11
+ return (): VNode =>
12
+ descriptorToVue(
13
+ renderImageBackground(normalizeVueAttrs(attrs)),
14
+ slots.default?.() ?? [],
15
+ );
16
+ },
17
+ });
@@ -0,0 +1,5 @@
1
+ import { defineNativeViewComponent } from '@symbiote-native/vue';
2
+ import { createImageView } from '../core';
3
+
4
+ /** Vue twin of `expo-image`'s `Image`, `ref` gets the handle of the view */
5
+ export const Image = defineNativeViewComponent('Image', createImageView);
@@ -0,0 +1,6 @@
1
+ // @symbiote-native/image/vue: the image view, its cache and hash functions on a shared core
2
+
3
+ export { Image } from './image';
4
+ export { ImageBackground } from './image-background';
5
+ export { useImage } from './use-image';
6
+ export * from '../core';
@@ -0,0 +1,34 @@
1
+ import { shallowRef, toValue, watch } from '@vue/runtime-core';
2
+ import type { MaybeRefOrGetter, ShallowRef, WatchSource } from '@vue/runtime-core';
3
+ import { createImageRefLoader, resolveSource } from '../core';
4
+ import type { IImageLoadOptions, IImageSource, ImageRef } from '../core';
5
+
6
+ /**
7
+ * Vue twin of `expo-image`'s `useImage`, `null` until the first image has loaded
8
+ *
9
+ * It loads again when the uri of the source or a watched `dependencies` source changes
10
+ */
11
+ export function useImage(
12
+ source: MaybeRefOrGetter<IImageSource | string | number>,
13
+ options: MaybeRefOrGetter<IImageLoadOptions> = {},
14
+ dependencies: WatchSource[] = [],
15
+ ): Readonly<ShallowRef<ImageRef | null>> {
16
+ const image = shallowRef<ImageRef | null>(null);
17
+
18
+ watch(
19
+ [() => resolveSource(toValue(source))?.uri, ...dependencies],
20
+ (_next, _previous, onCleanup) => {
21
+ const loader = createImageRefLoader(
22
+ loaded => {
23
+ image.value = loaded;
24
+ },
25
+ () => toValue(options),
26
+ );
27
+ loader.load(toValue(source));
28
+ onCleanup(loader.cancel);
29
+ },
30
+ { immediate: true },
31
+ );
32
+
33
+ return image;
34
+ }