@symbiote-native/image 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +260 -2
- package/build/angular/image/index.d.ts +20 -0
- package/build/angular/image/index.js +113 -0
- package/build/angular/image-background/index.d.ts +14 -0
- package/build/angular/image-background/index.js +109 -0
- package/build/angular/index.d.ts +4 -0
- package/build/angular/index.js +6 -0
- package/build/angular/inject-image.d.ts +8 -0
- package/build/angular/inject-image.js +20 -0
- package/build/core/constants.d.ts +3 -0
- package/build/core/constants.js +4 -0
- package/build/core/hash-strings.d.ts +5 -0
- package/build/core/hash-strings.js +22 -0
- package/build/core/image-api.d.ts +18 -0
- package/build/core/image-api.js +30 -0
- package/build/core/image-background.d.ts +11 -0
- package/build/core/image-background.js +29 -0
- package/build/core/image-loader.d.ts +20 -0
- package/build/core/image-loader.js +42 -0
- package/build/core/image-ref-loader.d.ts +4 -0
- package/build/core/image-ref-loader.js +10 -0
- package/build/core/image-view-events.d.ts +9 -0
- package/build/core/image-view-events.js +34 -0
- package/build/core/image-view.d.ts +14 -0
- package/build/core/image-view.js +113 -0
- package/build/core/index.d.ts +10 -0
- package/build/core/index.js +7 -0
- package/build/core/native-module.d.ts +27 -0
- package/build/core/native-module.js +3 -0
- package/build/core/native-style.d.ts +19 -0
- package/build/core/native-style.js +65 -0
- package/build/core/props.d.ts +11 -0
- package/build/core/props.js +87 -0
- package/build/core/sources.d.ts +8 -0
- package/build/core/sources.js +61 -0
- package/build/core/types.d.ts +186 -0
- package/build/core/types.js +1 -0
- package/build/react/image-background.d.ts +7 -0
- package/build/react/image-background.js +7 -0
- package/build/react/image.d.ts +8 -0
- package/build/react/image.js +6 -0
- package/build/react/index.d.ts +6 -0
- package/build/react/index.js +5 -0
- package/build/react/use-image.d.ts +8 -0
- package/build/react/use-image.js +20 -0
- package/build/solid/image-background.d.ts +7 -0
- package/build/solid/image-background.js +4 -0
- package/build/solid/image.d.ts +45 -0
- package/build/solid/image.js +4 -0
- package/build/solid/index.d.ts +5 -0
- package/build/solid/index.js +5 -0
- package/build/solid/use-image.d.ts +8 -0
- package/build/solid/use-image.js +16 -0
- package/build/svelte/image-background-props.d.ts +5 -0
- package/build/svelte/image-background-props.js +1 -0
- package/build/svelte/image-background.svelte +10 -0
- package/build/svelte/image-background.svelte.d.ts +4 -0
- package/build/svelte/image.svelte +26 -0
- package/build/svelte/image.svelte.d.ts +10 -0
- package/build/svelte/index.d.ts +6 -0
- package/build/svelte/index.js +5 -0
- package/build/svelte/use-image.svelte.d.ts +10 -0
- package/build/svelte/use-image.svelte.js +26 -0
- package/build/vue/image-background.d.ts +3 -0
- package/build/vue/image-background.js +12 -0
- package/build/vue/image.d.ts +2 -0
- package/build/vue/image.js +4 -0
- package/build/vue/index.d.ts +4 -0
- package/build/vue/index.js +5 -0
- package/build/vue/use-image.d.ts +8 -0
- package/build/vue/use-image.js +18 -0
- package/build-ngc/angular/image/index.d.ts +23 -0
- package/build-ngc/angular/image/index.js +72 -0
- package/build-ngc/angular/image/index.js.map +1 -0
- package/build-ngc/angular/image-background/index.d.ts +17 -0
- package/build-ngc/angular/image-background/index.js +70 -0
- package/build-ngc/angular/image-background/index.js.map +1 -0
- package/build-ngc/angular/index.d.ts +4 -0
- package/build-ngc/angular/index.js +7 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/angular/inject-image.d.ts +8 -0
- package/build-ngc/angular/inject-image.js +23 -0
- package/build-ngc/angular/inject-image.js.map +1 -0
- package/build-ngc/core/constants.d.ts +3 -0
- package/build-ngc/core/constants.js +5 -0
- package/build-ngc/core/constants.js.map +1 -0
- package/build-ngc/core/hash-strings.d.ts +5 -0
- package/build-ngc/core/hash-strings.js +23 -0
- package/build-ngc/core/hash-strings.js.map +1 -0
- package/build-ngc/core/image-api.d.ts +18 -0
- package/build-ngc/core/image-api.js +31 -0
- package/build-ngc/core/image-api.js.map +1 -0
- package/build-ngc/core/image-background.d.ts +11 -0
- package/build-ngc/core/image-background.js +30 -0
- package/build-ngc/core/image-background.js.map +1 -0
- package/build-ngc/core/image-loader.d.ts +20 -0
- package/build-ngc/core/image-loader.js +43 -0
- package/build-ngc/core/image-loader.js.map +1 -0
- package/build-ngc/core/image-ref-loader.d.ts +4 -0
- package/build-ngc/core/image-ref-loader.js +11 -0
- package/build-ngc/core/image-ref-loader.js.map +1 -0
- package/build-ngc/core/image-view-events.d.ts +9 -0
- package/build-ngc/core/image-view-events.js +35 -0
- package/build-ngc/core/image-view-events.js.map +1 -0
- package/build-ngc/core/image-view.d.ts +14 -0
- package/build-ngc/core/image-view.js +114 -0
- package/build-ngc/core/image-view.js.map +1 -0
- package/build-ngc/core/index.d.ts +10 -0
- package/build-ngc/core/index.js +8 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/native-module.d.ts +27 -0
- package/build-ngc/core/native-module.js +4 -0
- package/build-ngc/core/native-module.js.map +1 -0
- package/build-ngc/core/native-style.d.ts +19 -0
- package/build-ngc/core/native-style.js +66 -0
- package/build-ngc/core/native-style.js.map +1 -0
- package/build-ngc/core/props.d.ts +11 -0
- package/build-ngc/core/props.js +88 -0
- package/build-ngc/core/props.js.map +1 -0
- package/build-ngc/core/sources.d.ts +8 -0
- package/build-ngc/core/sources.js +62 -0
- package/build-ngc/core/sources.js.map +1 -0
- package/build-ngc/core/types.d.ts +186 -0
- package/build-ngc/core/types.js +2 -0
- package/build-ngc/core/types.js.map +1 -0
- package/native-link.json +13 -0
- package/package.json +145 -3
- package/src/angular/image/index.ts +79 -0
- package/src/angular/image-background/index.ts +72 -0
- package/src/angular/index.ts +7 -0
- package/src/angular/inject-image.ts +29 -0
- package/src/core/constants.ts +6 -0
- package/src/core/hash-strings.ts +29 -0
- package/src/core/image-api.ts +77 -0
- package/src/core/image-background.ts +47 -0
- package/src/core/image-loader.ts +72 -0
- package/src/core/image-ref-loader.ts +16 -0
- package/src/core/image-view-events.ts +47 -0
- package/src/core/image-view.ts +173 -0
- package/src/core/index.ts +50 -0
- package/src/core/native-module.ts +44 -0
- package/src/core/native-style.ts +96 -0
- package/src/core/props.ts +123 -0
- package/src/core/sources.ts +75 -0
- package/src/core/types.ts +275 -0
- package/src/react/image-background.ts +16 -0
- package/src/react/image.ts +17 -0
- package/src/react/index.ts +8 -0
- package/src/react/use-image.ts +29 -0
- package/src/solid/image-background.ts +12 -0
- package/src/solid/image.ts +9 -0
- package/src/solid/index.ts +7 -0
- package/src/solid/use-image.ts +30 -0
- package/src/svelte/image-background-props.ts +6 -0
- package/src/svelte/image-background.svelte +10 -0
- package/src/svelte/image.svelte +26 -0
- package/src/svelte/index.ts +8 -0
- package/src/svelte/svelte-ambient.d.ts +3 -0
- package/src/svelte/svelte-compile.test-helper.ts +6 -0
- package/src/svelte/use-image.svelte.ts +38 -0
- package/src/vue/image-background.ts +17 -0
- package/src/vue/image.ts +5 -0
- package/src/vue/index.ts +6 -0
- package/src/vue/use-image.ts +38 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { DescriptorOutlet, NativeViewBase } from '@symbiote-native/angular';
|
|
3
|
+
import { createImageView } from '../../core';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
// One list is the inputs of the component and the props it hands to the native view
|
|
6
|
+
const IMAGE_INPUTS = [
|
|
7
|
+
'source',
|
|
8
|
+
'placeholder',
|
|
9
|
+
'contentFit',
|
|
10
|
+
'placeholderContentFit',
|
|
11
|
+
'contentPosition',
|
|
12
|
+
'transition',
|
|
13
|
+
'blurRadius',
|
|
14
|
+
'tintColor',
|
|
15
|
+
'priority',
|
|
16
|
+
'loading',
|
|
17
|
+
'cachePolicy',
|
|
18
|
+
'responsivePolicy',
|
|
19
|
+
'recyclingKey',
|
|
20
|
+
'autoplay',
|
|
21
|
+
'sfEffect',
|
|
22
|
+
'onLoadStart',
|
|
23
|
+
'onLoad',
|
|
24
|
+
'onProgress',
|
|
25
|
+
'onError',
|
|
26
|
+
'onLoadEnd',
|
|
27
|
+
'onDisplay',
|
|
28
|
+
'defaultSource',
|
|
29
|
+
'loadingIndicatorSource',
|
|
30
|
+
'resizeMode',
|
|
31
|
+
'fadeDuration',
|
|
32
|
+
'alt',
|
|
33
|
+
'enableLiveTextInteraction',
|
|
34
|
+
'allowDownscaling',
|
|
35
|
+
'decodeFormat',
|
|
36
|
+
'useAppleWebpCodec',
|
|
37
|
+
'enforceEarlyResizing',
|
|
38
|
+
'preferHighDynamicRange',
|
|
39
|
+
'draggable',
|
|
40
|
+
];
|
|
41
|
+
/** Angular twin of `expo-image`'s `Image`, `Image` itself is a primitive tag of the adapter */
|
|
42
|
+
export class ExpoImage extends NativeViewBase {
|
|
43
|
+
view = createImageView(() => this.hostNode());
|
|
44
|
+
// The functions of the view are members of the component, a `@ViewChild` reaches them
|
|
45
|
+
startAnimating = this.view.handle.startAnimating;
|
|
46
|
+
stopAnimating = this.view.handle.stopAnimating;
|
|
47
|
+
lockResourceAsync = this.view.handle.lockResourceAsync;
|
|
48
|
+
unlockResourceAsync = this.view.handle.unlockResourceAsync;
|
|
49
|
+
reloadAsync = this.view.handle.reloadAsync;
|
|
50
|
+
propNames = IMAGE_INPUTS;
|
|
51
|
+
renderView(props) {
|
|
52
|
+
return this.view.render(props);
|
|
53
|
+
}
|
|
54
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ExpoImage, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
55
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: ExpoImage, isStandalone: true, selector: "ExpoImage", inputs: { source: "source", placeholder: "placeholder", contentFit: "contentFit", placeholderContentFit: "placeholderContentFit", contentPosition: "contentPosition", transition: "transition", blurRadius: "blurRadius", tintColor: "tintColor", priority: "priority", loading: "loading", cachePolicy: "cachePolicy", responsivePolicy: "responsivePolicy", recyclingKey: "recyclingKey", autoplay: "autoplay", sfEffect: "sfEffect", onLoadStart: "onLoadStart", onLoad: "onLoad", onProgress: "onProgress", onError: "onError", onLoadEnd: "onLoadEnd", onDisplay: "onDisplay", defaultSource: "defaultSource", loadingIndicatorSource: "loadingIndicatorSource", resizeMode: "resizeMode", fadeDuration: "fadeDuration", alt: "alt", enableLiveTextInteraction: "enableLiveTextInteraction", allowDownscaling: "allowDownscaling", decodeFormat: "decodeFormat", useAppleWebpCodec: "useAppleWebpCodec", enforceEarlyResizing: "enforceEarlyResizing", preferHighDynamicRange: "preferHighDynamicRange", draggable: "draggable" }, usesInheritance: true, ngImport: i0, template: `@if (descriptor; as node) {
|
|
56
|
+
<symbiote-descriptor-outlet [node]="node" />
|
|
57
|
+
}`, isInline: true, dependencies: [{ kind: "component", type: DescriptorOutlet, selector: "symbiote-descriptor-outlet", inputs: ["node"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
58
|
+
}
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ExpoImage, decorators: [{
|
|
60
|
+
type: Component,
|
|
61
|
+
args: [{
|
|
62
|
+
selector: 'ExpoImage',
|
|
63
|
+
standalone: true,
|
|
64
|
+
imports: [DescriptorOutlet],
|
|
65
|
+
inputs: [...IMAGE_INPUTS],
|
|
66
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
67
|
+
template: `@if (descriptor; as node) {
|
|
68
|
+
<symbiote-descriptor-outlet [node]="node" />
|
|
69
|
+
}`,
|
|
70
|
+
}]
|
|
71
|
+
}] });
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/angular/image/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,gBAAg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2FAOf,SAAS;kBAVrB,SAAS;mBAAC;oBACT,QAAQ,EAAE,WAAW;oBACrB,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,CAAC,gBAAgB,CAAC;oBAC3B,MAAM,EAAE,CAAC,GAAG,YAAY,CAAC;oBACzB,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,QAAQ,EAAE;;IAER;iBACH"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NativeViewBase } from '@symbiote-native/angular';
|
|
2
|
+
import type { IDescriptor } from '@symbiote-native/components';
|
|
3
|
+
import type { IStyleProp } from '@symbiote-native/engine';
|
|
4
|
+
import type { IImageBackgroundProps, IImageStyle } from '../../core';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
declare const IMAGE_BACKGROUND_INPUTS: readonly ["source", "placeholder", "contentFit", "placeholderContentFit", "contentPosition", "transition", "blurRadius", "tintColor", "priority", "loading", "cachePolicy", "responsivePolicy", "recyclingKey", "autoplay", "sfEffect", "onLoadStart", "onLoad", "onProgress", "onError", "onLoadEnd", "onDisplay", "defaultSource", "loadingIndicatorSource", "resizeMode", "fadeDuration", "alt", "enableLiveTextInteraction", "allowDownscaling", "decodeFormat", "useAppleWebpCodec", "enforceEarlyResizing", "preferHighDynamicRange", "draggable", "imageStyle"];
|
|
7
|
+
export interface ExpoImageBackground extends Partial<Pick<IImageBackgroundProps, (typeof IMAGE_BACKGROUND_INPUTS)[number]>> {
|
|
8
|
+
}
|
|
9
|
+
/** Angular twin of `expo-image`'s `ImageBackground`, the content paints over the image */
|
|
10
|
+
export declare class ExpoImageBackground extends NativeViewBase {
|
|
11
|
+
style?: IStyleProp<IImageStyle>;
|
|
12
|
+
protected readonly propNames: readonly ["source", "placeholder", "contentFit", "placeholderContentFit", "contentPosition", "transition", "blurRadius", "tintColor", "priority", "loading", "cachePolicy", "responsivePolicy", "recyclingKey", "autoplay", "sfEffect", "onLoadStart", "onLoad", "onProgress", "onError", "onLoadEnd", "onDisplay", "defaultSource", "loadingIndicatorSource", "resizeMode", "fadeDuration", "alt", "enableLiveTextInteraction", "allowDownscaling", "decodeFormat", "useAppleWebpCodec", "enforceEarlyResizing", "preferHighDynamicRange", "draggable", "imageStyle"];
|
|
13
|
+
protected renderView(props: object): IDescriptor;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ExpoImageBackground, never>;
|
|
15
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ExpoImageBackground, "ExpoImageBackground", never, { "source": { "alias": "source"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "contentFit": { "alias": "contentFit"; "required": false; }; "placeholderContentFit": { "alias": "placeholderContentFit"; "required": false; }; "contentPosition": { "alias": "contentPosition"; "required": false; }; "transition": { "alias": "transition"; "required": false; }; "blurRadius": { "alias": "blurRadius"; "required": false; }; "tintColor": { "alias": "tintColor"; "required": false; }; "priority": { "alias": "priority"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "cachePolicy": { "alias": "cachePolicy"; "required": false; }; "responsivePolicy": { "alias": "responsivePolicy"; "required": false; }; "recyclingKey": { "alias": "recyclingKey"; "required": false; }; "autoplay": { "alias": "autoplay"; "required": false; }; "sfEffect": { "alias": "sfEffect"; "required": false; }; "onLoadStart": { "alias": "onLoadStart"; "required": false; }; "onLoad": { "alias": "onLoad"; "required": false; }; "onProgress": { "alias": "onProgress"; "required": false; }; "onError": { "alias": "onError"; "required": false; }; "onLoadEnd": { "alias": "onLoadEnd"; "required": false; }; "onDisplay": { "alias": "onDisplay"; "required": false; }; "defaultSource": { "alias": "defaultSource"; "required": false; }; "loadingIndicatorSource": { "alias": "loadingIndicatorSource"; "required": false; }; "resizeMode": { "alias": "resizeMode"; "required": false; }; "fadeDuration": { "alias": "fadeDuration"; "required": false; }; "alt": { "alias": "alt"; "required": false; }; "enableLiveTextInteraction": { "alias": "enableLiveTextInteraction"; "required": false; }; "allowDownscaling": { "alias": "allowDownscaling"; "required": false; }; "decodeFormat": { "alias": "decodeFormat"; "required": false; }; "useAppleWebpCodec": { "alias": "useAppleWebpCodec"; "required": false; }; "enforceEarlyResizing": { "alias": "enforceEarlyResizing"; "required": false; }; "preferHighDynamicRange": { "alias": "preferHighDynamicRange"; "required": false; }; "draggable": { "alias": "draggable"; "required": false; }; "imageStyle": { "alias": "imageStyle"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { DescriptorHost, NativeViewBase } from '@symbiote-native/angular';
|
|
3
|
+
import { renderImageBackground } from '../../core';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
// One list is the inputs of the component and the props it hands to the image
|
|
6
|
+
const IMAGE_BACKGROUND_INPUTS = [
|
|
7
|
+
'source',
|
|
8
|
+
'placeholder',
|
|
9
|
+
'contentFit',
|
|
10
|
+
'placeholderContentFit',
|
|
11
|
+
'contentPosition',
|
|
12
|
+
'transition',
|
|
13
|
+
'blurRadius',
|
|
14
|
+
'tintColor',
|
|
15
|
+
'priority',
|
|
16
|
+
'loading',
|
|
17
|
+
'cachePolicy',
|
|
18
|
+
'responsivePolicy',
|
|
19
|
+
'recyclingKey',
|
|
20
|
+
'autoplay',
|
|
21
|
+
'sfEffect',
|
|
22
|
+
'onLoadStart',
|
|
23
|
+
'onLoad',
|
|
24
|
+
'onProgress',
|
|
25
|
+
'onError',
|
|
26
|
+
'onLoadEnd',
|
|
27
|
+
'onDisplay',
|
|
28
|
+
'defaultSource',
|
|
29
|
+
'loadingIndicatorSource',
|
|
30
|
+
'resizeMode',
|
|
31
|
+
'fadeDuration',
|
|
32
|
+
'alt',
|
|
33
|
+
'enableLiveTextInteraction',
|
|
34
|
+
'allowDownscaling',
|
|
35
|
+
'decodeFormat',
|
|
36
|
+
'useAppleWebpCodec',
|
|
37
|
+
'enforceEarlyResizing',
|
|
38
|
+
'preferHighDynamicRange',
|
|
39
|
+
'draggable',
|
|
40
|
+
'imageStyle',
|
|
41
|
+
];
|
|
42
|
+
/** Angular twin of `expo-image`'s `ImageBackground`, the content paints over the image */
|
|
43
|
+
export class ExpoImageBackground extends NativeViewBase {
|
|
44
|
+
propNames = IMAGE_BACKGROUND_INPUTS;
|
|
45
|
+
renderView(props) {
|
|
46
|
+
return renderImageBackground(props);
|
|
47
|
+
}
|
|
48
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ExpoImageBackground, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
49
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: ExpoImageBackground, isStandalone: true, selector: "ExpoImageBackground", inputs: { source: "source", placeholder: "placeholder", contentFit: "contentFit", placeholderContentFit: "placeholderContentFit", contentPosition: "contentPosition", transition: "transition", blurRadius: "blurRadius", tintColor: "tintColor", priority: "priority", loading: "loading", cachePolicy: "cachePolicy", responsivePolicy: "responsivePolicy", recyclingKey: "recyclingKey", autoplay: "autoplay", sfEffect: "sfEffect", onLoadStart: "onLoadStart", onLoad: "onLoad", onProgress: "onProgress", onError: "onError", onLoadEnd: "onLoadEnd", onDisplay: "onDisplay", defaultSource: "defaultSource", loadingIndicatorSource: "loadingIndicatorSource", resizeMode: "resizeMode", fadeDuration: "fadeDuration", alt: "alt", enableLiveTextInteraction: "enableLiveTextInteraction", allowDownscaling: "allowDownscaling", decodeFormat: "decodeFormat", useAppleWebpCodec: "useAppleWebpCodec", enforceEarlyResizing: "enforceEarlyResizing", preferHighDynamicRange: "preferHighDynamicRange", draggable: "draggable", imageStyle: "imageStyle" }, usesInheritance: true, ngImport: i0, template: `@if (descriptor; as node) {
|
|
50
|
+
<symbiote-descriptor-host [node]="node"
|
|
51
|
+
><ng-content
|
|
52
|
+
/></symbiote-descriptor-host>
|
|
53
|
+
}`, isInline: true, dependencies: [{ kind: "component", type: DescriptorHost, selector: "symbiote-descriptor-host", inputs: ["node"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
54
|
+
}
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ExpoImageBackground, decorators: [{
|
|
56
|
+
type: Component,
|
|
57
|
+
args: [{
|
|
58
|
+
selector: 'ExpoImageBackground',
|
|
59
|
+
standalone: true,
|
|
60
|
+
imports: [DescriptorHost],
|
|
61
|
+
inputs: [...IMAGE_BACKGROUND_INPUTS],
|
|
62
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
63
|
+
template: `@if (descriptor; as node) {
|
|
64
|
+
<symbiote-descriptor-host [node]="node"
|
|
65
|
+
><ng-content
|
|
66
|
+
/></symbiote-descriptor-host>
|
|
67
|
+
}`,
|
|
68
|
+
}]
|
|
69
|
+
}] });
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/angular/image-background/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;;AAInD,8EAA8E;AAC9E,MAAM,uBAAuB,GAAG;IAC9B,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,uBAAuB;IACvB,iBAAiB;IACjB,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,UAAU;IACV,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,cAAc;IACd,UAAU;IACV,UAAU;IACV,aAAa;IACb,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,WAAW;IACX,WAAW;IACX,eAAe;IACf,wBAAwB;IACxB,YAAY;IACZ,cAAc;IACd,KAAK;IACL,2BAA2B;IAC3B,kBAAkB;IAClB,cAAc;IACd,mBAAmB;IACnB,sBAAsB;IACtB,wBAAwB;IACxB,WAAW;IACX,YAAY;CACJ,CAAC;AAMX,0FAA0F;AAa1F,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IAIzB,SAAS,GAAG,uBAAuB,CAAC;IAE7C,UAAU,CAAC,KAAa;QACzC,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;uGARU,mBAAmB;2FAAnB,mBAAmB,wmCANpB;;;;IAIR,4DAPQ,cAAc;;2FASb,mBAAmB;kBAZ/B,SAAS;mBAAC;oBACT,QAAQ,EAAE,qBAAqB;oBAC/B,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,CAAC,cAAc,CAAC;oBACzB,MAAM,EAAE,CAAC,GAAG,uBAAuB,CAAC;oBACpC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,QAAQ,EAAE;;;;IAIR;iBACH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @symbiote-native/image/angular: the image view, its cache and hash functions on a shared core
|
|
2
|
+
// The selectors are `ExpoImage*`, `Image` and `ImageBackground` are tags of the adapter
|
|
3
|
+
export { ExpoImage } from './image';
|
|
4
|
+
export { ExpoImageBackground } from './image-background';
|
|
5
|
+
export { injectImage } from './inject-image';
|
|
6
|
+
export * from '../core';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,wFAAwF;AAExF,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Signal } from '@angular/core';
|
|
2
|
+
import type { IImageLoadOptions, IImageSource, ImageRef } from '../core';
|
|
3
|
+
/**
|
|
4
|
+
* Angular twin of `useImage`, `null` until the first image has loaded
|
|
5
|
+
*
|
|
6
|
+
* It loads again when the uri of the source or a signal read by `dependencies` changes
|
|
7
|
+
*/
|
|
8
|
+
export declare function injectImage(source: () => IImageSource | string | number, options?: () => IImageLoadOptions, dependencies?: () => unknown[]): Signal<ImageRef | null>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { computed, effect, signal, untracked } from '@angular/core';
|
|
2
|
+
import { createImageRefLoader, resolveSource } from '../core';
|
|
3
|
+
/**
|
|
4
|
+
* Angular twin of `useImage`, `null` until the first image has loaded
|
|
5
|
+
*
|
|
6
|
+
* It loads again when the uri of the source or a signal read by `dependencies` changes
|
|
7
|
+
*/
|
|
8
|
+
export function injectImage(source, options = () => ({}), dependencies = () => []) {
|
|
9
|
+
const image = signal(null, /* @ts-ignore */
|
|
10
|
+
...(ngDevMode ? [{ debugName: "image" }] : /* istanbul ignore next */ []));
|
|
11
|
+
const key = computed(() => resolveSource(source())?.uri, /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
|
|
13
|
+
effect(onCleanup => {
|
|
14
|
+
// Read so the effect tracks them, the source itself is not a trigger
|
|
15
|
+
key();
|
|
16
|
+
dependencies();
|
|
17
|
+
const loader = createImageRefLoader(loaded => image.set(loaded), options);
|
|
18
|
+
untracked(() => loader.load(source()));
|
|
19
|
+
onCleanup(loader.cancel);
|
|
20
|
+
});
|
|
21
|
+
return image.asReadonly();
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=inject-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-image.js","sourceRoot":"","sources":["../../src/angular/inject-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG9D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,MAA4C,EAC5C,UAAmC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAC7C,eAAgC,GAAG,EAAE,CAAC,EAAE;IAExC,MAAM,KAAK,GAAG,MAAM,CAAkB,IAAI;8EAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG;4EAAC,CAAC;IAEzD,MAAM,CAAC,SAAS,CAAC,EAAE;QACjB,qEAAqE;QACrE,GAAG,EAAE,CAAC;QACN,YAAY,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QAC1E,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACvC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Apart from `native-module`, which resolves the module on import: the view needs the name too
|
|
2
|
+
export const IMAGE_MODULE_NAME = 'ExpoImage';
|
|
3
|
+
/** `sf:name` in a source string, the native side reads `sf:/name` */
|
|
4
|
+
export const SF_SYMBOL_PREFIX = 'sf:';
|
|
5
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -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,23 @@
|
|
|
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
|
|
9
|
+
.replace(/^blurhash:\//, '')
|
|
10
|
+
.split('/');
|
|
11
|
+
return {
|
|
12
|
+
uri: hashToUri('blurhash', hash),
|
|
13
|
+
width: parseInt(width, 10) || DEFAULT_HASH_SIZE,
|
|
14
|
+
height: parseInt(height, 10) || DEFAULT_HASH_SIZE,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** `thumbhash:/<hash>` or `<hash>` */
|
|
18
|
+
export function resolveThumbhashString(str) {
|
|
19
|
+
// A slash at the start of the hash would break the uri path
|
|
20
|
+
const hash = str.replace(/^thumbhash:\//, '').replace(/\//g, '\\');
|
|
21
|
+
return { uri: hashToUri('thumbhash', hash) };
|
|
22
|
+
}
|
|
23
|
+
//# 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;SAC7C,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,KAAK,CAAC,GAAG,CAAC,CAAC;IACd,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,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-api.js","sourceRoot":"","sources":["../../src/core/image-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAS1C,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAK3C,2EAA2E;AAC3E,MAAM,UAAU,cAAc,CAC5B,IAAuB,EACvB,OAA0B;IAE1B,MAAM,EAAE,WAAW,GAAG,oBAAoB,EAAE,OAAO,EAAE,GACnD,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC3E,OAAO,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vC,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,30 @@
|
|
|
1
|
+
import { el } from '@symbiote-native/components';
|
|
2
|
+
import { createImageView } from './image-view';
|
|
3
|
+
const CLASS_KEYS = new Set([
|
|
4
|
+
'className',
|
|
5
|
+
'class',
|
|
6
|
+
]);
|
|
7
|
+
function isClassEntry([key]) {
|
|
8
|
+
return CLASS_KEYS.has(key);
|
|
9
|
+
}
|
|
10
|
+
const ABSOLUTE_FILL = {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
top: 0,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
};
|
|
17
|
+
// The background image has no handle, so nobody asks it for a host node
|
|
18
|
+
const backgroundImage = createImageView(() => null);
|
|
19
|
+
/** A view with an image filling it, the children of the app go after this descriptor */
|
|
20
|
+
export function renderImageBackground(props) {
|
|
21
|
+
const { style, imageStyle, ...rest } = props;
|
|
22
|
+
const entries = Object.entries(rest);
|
|
23
|
+
const image = backgroundImage.render({
|
|
24
|
+
...Object.fromEntries(entries.filter(entry => !isClassEntry(entry))),
|
|
25
|
+
style: [ABSOLUTE_FILL, imageStyle],
|
|
26
|
+
});
|
|
27
|
+
const viewClass = Object.fromEntries(entries.filter(isClassEntry));
|
|
28
|
+
return el('view', { style, ...viewClass }, image ? [image] : []);
|
|
29
|
+
}
|
|
30
|
+
//# 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;IACzD,WAAW;IACX,OAAO;CACR,CAAC,CAAC;AAEH,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,CACnC,KAA4B;IAE5B,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":"AAoBA,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,CACX,MAAsC,EACt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ImageLoadOptions, 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,35 @@
|
|
|
1
|
+
function field(value, key) {
|
|
2
|
+
return Reflect.get(Object(value), key);
|
|
3
|
+
}
|
|
4
|
+
function isLoad(value) {
|
|
5
|
+
return (typeof field(value, 'cacheType') === 'string' &&
|
|
6
|
+
typeof field(value, 'source') === 'object');
|
|
7
|
+
}
|
|
8
|
+
function isProgress(value) {
|
|
9
|
+
return (typeof field(value, 'loaded') === 'number' &&
|
|
10
|
+
typeof field(value, 'total') === 'number');
|
|
11
|
+
}
|
|
12
|
+
function isError(value) {
|
|
13
|
+
return typeof field(value, 'error') === 'string';
|
|
14
|
+
}
|
|
15
|
+
/** The native payload sits in `nativeEvent`, callbacks get it as the event itself */
|
|
16
|
+
export function toImageEvents(props) {
|
|
17
|
+
return {
|
|
18
|
+
onLoadStart: () => props.onLoadStart?.(),
|
|
19
|
+
onLoad: (event) => {
|
|
20
|
+
if (isLoad(event.nativeEvent))
|
|
21
|
+
props.onLoad?.(event.nativeEvent);
|
|
22
|
+
props.onLoadEnd?.();
|
|
23
|
+
},
|
|
24
|
+
onProgress: (event) => {
|
|
25
|
+
if (isProgress(event.nativeEvent))
|
|
26
|
+
props.onProgress?.(event.nativeEvent);
|
|
27
|
+
},
|
|
28
|
+
onError: (event) => {
|
|
29
|
+
if (isError(event.nativeEvent))
|
|
30
|
+
props.onError?.(event.nativeEvent);
|
|
31
|
+
props.onLoadEnd?.();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# 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,C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
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 {};
|