@octane-xplat/image 0.0.1 → 0.11.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 +124 -0
- package/dist/native/Image.tsrx.js +264 -0
- package/dist/native/cache.js +64 -0
- package/dist/native/hash-image.js +285 -0
- package/dist/native/image-binding.js +103 -0
- package/dist/native/image-content.js +207 -0
- package/dist/native/index.js +3 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/prefetch-batch.js +27 -0
- package/dist/web/Image.web.tsrx.js +123 -0
- package/dist/web/cache.web.js +35 -0
- package/dist/web/hash-image.js +285 -0
- package/dist/web/image-content.js +134 -0
- package/dist/web/index.js +3 -0
- package/dist/web/octane-client-build.json +8 -0
- package/dist/web/prefetch-batch.js +27 -0
- package/package.json +84 -4
- package/src/Image.macos.tsrx +24 -0
- package/src/Image.tsrx +269 -0
- package/src/Image.web.tsrx +176 -0
- package/src/cache.macos.ts +31 -0
- package/src/cache.ts +93 -0
- package/src/cache.web.ts +49 -0
- package/src/hash-image.ts +313 -0
- package/src/image-binding.ts +170 -0
- package/src/image-content.ts +310 -0
- package/src/index.macos.ts +26 -0
- package/src/index.ts +28 -0
- package/src/index.web.ts +28 -0
- package/src/native-elements.d.ts +8 -0
- package/src/prefetch-batch.ts +50 -0
- package/src/prefetch.web.test.ts +105 -0
- package/src/props.ts +119 -0
- package/types/generated/.tsrx-typegen-manifest.json +16 -0
- package/types/generated/Image.d.ts +16 -0
- package/types/generated/Image.web.d.ts +12 -0
- package/types/generated/cache.d.ts +28 -0
- package/types/generated/cache.web.d.ts +16 -0
- package/types/generated/hash-image.d.ts +14 -0
- package/types/generated/image-binding.d.ts +40 -0
- package/types/generated/image-content.d.ts +57 -0
- package/types/generated/index.d.ts +3 -0
- package/types/generated/index.web.d.ts +3 -0
- package/types/generated/prefetch-batch.d.ts +10 -0
- package/types/generated/props.d.ts +99 -0
- package/types/index.macos.d.ts +28 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ImageProps } from './props.js';
|
|
2
|
+
/** Image — ui-image `Img` (Glide/SDWebImage). Mirrors the core contract:
|
|
3
|
+
* `src` takes the Img grammar (remote URL, res://name, ~/bundle path, file
|
|
4
|
+
* path, data: URI) plus a resolution-qualified `ImageSourceLike[]` (closest
|
|
5
|
+
* pixel count wins once the view has a real layout — the srcset model).
|
|
6
|
+
* `contentFit` maps to stretch for the centered contain/cover/fill cases;
|
|
7
|
+
* 'none'/'scale-down'/positioned content take the computed path — the host
|
|
8
|
+
* box is measured, the content rect computed, and a fill-stretched `Img`
|
|
9
|
+
* laid out inside a clipped absolutelayout (same structure core uses).
|
|
10
|
+
* `src` never goes through JSX: the binding holds it until first layout,
|
|
11
|
+
* writes decodeWidth/decodeHeight in device px, then assigns — an eager src
|
|
12
|
+
* decodes at full source resolution. SVG is unsupported — keep core `Image`
|
|
13
|
+
* for those. `alt` maps to accessibilityLabel. `decoding` accepts the shared
|
|
14
|
+
* vocabulary but 'sync' degrades to async with a warning — the engines have
|
|
15
|
+
* no synchronous decode mode (see props.ts). */
|
|
16
|
+
export declare function Image(props: ImageProps): unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ImageProps } from './props.js';
|
|
2
|
+
/** Image — a plain <img>, mirroring the core contract: a source array becomes
|
|
3
|
+
* a real `srcset` (browser owns selection); `contentFit`/`contentPosition`
|
|
4
|
+
* map 1:1 to object-fit/object-position with 'cover'/'50% 50%' defaults;
|
|
5
|
+
* `placeholder` rides the same element — the img keeps its last decoded
|
|
6
|
+
* image while a hidden prefetch warms the final src, so placeholder → final
|
|
7
|
+
* swaps in one view without a blank frame. Engine-only props (cachePolicy,
|
|
8
|
+
* failureImage, headers, decodeWidth/decodeHeight, progressive,
|
|
9
|
+
* fadeDuration) have no <img> equivalent and are ignored. onLoad fires
|
|
10
|
+
* without `source` — the browser does not report which cache satisfied the
|
|
11
|
+
* request. */
|
|
12
|
+
export declare function Image(props: ImageProps): import("octane/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ImageCacheConfig, ImageCacheQueryOptions, ImageCacheState, PrefetchOptions } from './props.js';
|
|
2
|
+
/** Apply engine-level cache configuration. Call from the app entry before the
|
|
3
|
+
* first <Image> renders — the plugin initializes Glide lazily, so sizing must
|
|
4
|
+
* arrive before the first view creates the engine. A later call is a no-op
|
|
5
|
+
* (the plugin guards on its own `initialized` flag). Native only. */
|
|
6
|
+
export declare function initializeImageCache(config?: ImageCacheConfig): void;
|
|
7
|
+
/** Warm the disk cache without decoding — bytes are fetched and stored, decode
|
|
8
|
+
* cost stays at display time. One URL or an array; resolves `true` when all
|
|
9
|
+
* warmed, `false` if any URL fails or the pipeline is not up yet (e.g. called
|
|
10
|
+
* before app launch). Same contract as `@octane-xplat/gif`'s `prefetch`.
|
|
11
|
+
*
|
|
12
|
+
* `options.headers` is forwarded on Android and iOS (via the framework
|
|
13
|
+
* patch). `options.concurrency` caps parallel fetches. */
|
|
14
|
+
export declare function prefetch(srcs: string | string[], options?: PrefetchOptions): Promise<boolean>;
|
|
15
|
+
/** Remove `src` from memory and disk caches. */
|
|
16
|
+
export declare function evictImage(src: string): Promise<boolean>;
|
|
17
|
+
/** Drop every cached image (memory + disk). */
|
|
18
|
+
export declare function clearImageCaches(): Promise<void>;
|
|
19
|
+
/** Report which cache level currently holds each `src` — 'memory', 'disk',
|
|
20
|
+
* or 'none' (not cached / unknown). Accepts a single URL or a list; the
|
|
21
|
+
* result is always a `Record` keyed by URL (the RN `queryCache` shape).
|
|
22
|
+
* `options` repeats the display load's decode bounds: on iOS the cache key
|
|
23
|
+
* includes the transform context, so an image displayed with
|
|
24
|
+
* decodeWidth/decodeHeight only reports its level when the probe passes
|
|
25
|
+
* the same values. Android caveat: the plugin's probe cannot see Glide's
|
|
26
|
+
* active resources, so a bitmap still on screen may report 'none' —
|
|
27
|
+
* treat 'none' as "not provably cached", not "absent". */
|
|
28
|
+
export declare function isImageCached(srcs: string | readonly string[], options?: ImageCacheQueryOptions): Promise<Record<string, ImageCacheState>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ImageCacheConfig, ImageCacheQueryOptions, ImageCacheState, PrefetchOptions } from './props.js';
|
|
2
|
+
/** No-op — the browser owns its HTTP cache; there is no sizing API. */
|
|
3
|
+
export declare function initializeImageCache(_config?: ImageCacheConfig): void;
|
|
4
|
+
/** Warm the browser HTTP cache by loading each `src` through a throwaway
|
|
5
|
+
* <img> — the response must land (`load`/`error` awaited) before the promise
|
|
6
|
+
* resolves. Decode still happens at display, matching the native
|
|
7
|
+
* disk-prefetch contract. `options.headers` is ignored — an <img> request
|
|
8
|
+
* cannot carry custom headers. Resolves `false` when any URL fails. */
|
|
9
|
+
export declare function prefetch(srcs: string | string[], options?: PrefetchOptions): Promise<boolean>;
|
|
10
|
+
/** No-op — browsers expose no per-URL cache eviction for <img>. */
|
|
11
|
+
export declare function evictImage(_src: string): Promise<boolean>;
|
|
12
|
+
/** No-op — browsers expose no cache clearing for <img>. */
|
|
13
|
+
export declare function clearImageCaches(): Promise<void>;
|
|
14
|
+
/** Always 'none' — the browser cache is not queryable. Returns the same
|
|
15
|
+
* `Record` shape as native, keyed by each requested URL. */
|
|
16
|
+
export declare function isImageCached(srcs: string | readonly string[], _options?: ImageCacheQueryOptions): Promise<Record<string, ImageCacheState>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** VENDORED from packages/ui/src/hash-image.ts — keep in sync.
|
|
2
|
+
* Placeholder-hash decoders shared by the Image leaves: `blurhash:` and
|
|
3
|
+
* `thumbhash:` URIs decode to a PNG in pure JS so a placeholder is a real
|
|
4
|
+
* image on every platform — ImageSource.fromBase64Sync on native, a
|
|
5
|
+
* data:image/png URL on web. Decode sizes stay small (~32px); the view's
|
|
6
|
+
* own fit/stretch scales the result, same as the final image.
|
|
7
|
+
*
|
|
8
|
+
* blurhash decode is a port of the Wolt reference decoder (MIT);
|
|
9
|
+
* thumbHashToRGBA and rgbaToPng are ports of Evan Wallace's thumbhash.js
|
|
10
|
+
* (MIT), with the data-URL/btoa tail replaced by byte output so this file
|
|
11
|
+
* carries no DOM or platform APIs. */
|
|
12
|
+
export declare function isHashPlaceholder(src: string): boolean;
|
|
13
|
+
/** `blurhash:<hash>` / `thumbhash:<base64>` → PNG bytes as base64, or null. */
|
|
14
|
+
export declare function hashToPngBase64(src: string): string | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ImageContentFit, ImageContentPositionObject, ImageSourceLike } from './props.js';
|
|
2
|
+
/** View-sized decode + srcset selection + content-rect layout for the
|
|
3
|
+
* ui-image `Img` leaf. Mirrors the core Image binding semantics
|
|
4
|
+
* (packages/ui/src/image-sizing.ts + image-content-binding.ts):
|
|
5
|
+
*
|
|
6
|
+
* `src` never goes through JSX — the binding holds it until the view's
|
|
7
|
+
* first real layout, writes decodeWidth/decodeHeight in device pixels,
|
|
8
|
+
* then assigns it. Without that hold the engine decodes at full source
|
|
9
|
+
* resolution (the 5 MB-cache jank this package exists to fix is half
|
|
10
|
+
* cache size and half oversized decodes — study L1+L2). A later resize
|
|
11
|
+
* re-issues at the new size, except 'fill'/'none' fits where the decode
|
|
12
|
+
* can't improve. 'none' never downsamples — its contract is source pixels.
|
|
13
|
+
*
|
|
14
|
+
* `update` must be idempotent: ref callbacks re-fire on every render, and
|
|
15
|
+
* same view + same src + same size is a no-op. */
|
|
16
|
+
export declare function createImageBinding(options: {
|
|
17
|
+
getFit: () => ImageContentFit;
|
|
18
|
+
getPosition: () => ImageContentPositionObject;
|
|
19
|
+
getSrc: () => {
|
|
20
|
+
source: any;
|
|
21
|
+
sources: ImageSourceLike[] | null;
|
|
22
|
+
};
|
|
23
|
+
/** Explicit decode bounds — the caller's decodeWidth/decodeHeight props;
|
|
24
|
+
* when set they win over the measured view size. */
|
|
25
|
+
getDecodeBounds: () => {
|
|
26
|
+
width?: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Device-pixel scale (Screen.mainScreen.scale) — injected so this
|
|
30
|
+
* module stays platform-free. */
|
|
31
|
+
screenScale: () => number;
|
|
32
|
+
}): {
|
|
33
|
+
/** Called from the ref callbacks — image view first, then the computed
|
|
34
|
+
* path's wrapper host. Refreshes the pending src from props and
|
|
35
|
+
* evaluates; idempotent. */
|
|
36
|
+
update(imageView: any, hostView: any): void;
|
|
37
|
+
/** Engine set the final bitmap — record intrinsic size for the
|
|
38
|
+
* content-rect path. */
|
|
39
|
+
setIntrinsic(widthPx: number, heightPx: number): void;
|
|
40
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ImageContentFit, ImageContentPosition, ImageContentPositionObject, ImageContentPositionValue, ImageSourceLike } from './props.js';
|
|
2
|
+
/** VENDORED from packages/ui/src/image-content.ts — keep in sync.
|
|
3
|
+
* Shared `contentFit`/`contentPosition` + multi-source math for `Image` —
|
|
4
|
+
* pure functions used by every leaf (docs/notes/expo-image-study.md L7/L8).
|
|
5
|
+
* Semantics mirror CSS `object-fit`/`object-position`, which is also
|
|
6
|
+
* expo-image's contract: the leaves compute the drawn-content rect
|
|
7
|
+
* themselves instead of delegating to platform scaleType/contentMode,
|
|
8
|
+
* so all platforms get the same answer.
|
|
9
|
+
*
|
|
10
|
+
* The default fit is 'cover' everywhere (the expo/RN default). Today's
|
|
11
|
+
* platform defaults disagree — web <img> is 'fill' and NS stretch is
|
|
12
|
+
* 'aspectFit' — so an un-propped Image was silently divergent. */
|
|
13
|
+
export declare const DEFAULT_CONTENT_FIT: ImageContentFit;
|
|
14
|
+
export declare function resolveContentFit(fit?: ImageContentFit): ImageContentFit;
|
|
15
|
+
export declare function resolveContentPosition(position?: ImageContentPosition): ImageContentPositionObject;
|
|
16
|
+
/** Offset of the drawn content's start edge inside the view along one axis.
|
|
17
|
+
* expo-image `calcTranslation`: percentages run over the free space
|
|
18
|
+
* (view − content), absolute dips measure from the named edge, and the
|
|
19
|
+
* reverse edge (right/bottom) counts back from the far side. */
|
|
20
|
+
export declare function contentAxisOffset(viewSize: number, contentSize: number, start: ImageContentPositionValue | undefined, end: ImageContentPositionValue | undefined): number;
|
|
21
|
+
export declare function isCenteredContentPosition(position: ImageContentPositionObject): boolean;
|
|
22
|
+
/** The rect the bitmap occupies inside the view box, in the same units the
|
|
23
|
+
* caller measures with (native: dips; web: CSS px via object-fit anyway —
|
|
24
|
+
* only the native leaf calls this). Every length unit is dips except the
|
|
25
|
+
* intrinsic size, which the leaf must supply in dips too. */
|
|
26
|
+
export declare function contentRect(fit: ImageContentFit, position: ImageContentPositionObject, viewWidth: number, viewHeight: number, imageWidth: number, imageHeight: number): {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
/** True when no platform stretch/scaleType can express the request and the
|
|
33
|
+
* leaf must measure + lay out the image itself: 'none' (iOS maps NS
|
|
34
|
+
* stretch='none' to TopLeft, not CSS centered), 'scale-down' (needs the
|
|
35
|
+
* intrinsic-vs-view compare), or any non-center position. 'fill' is
|
|
36
|
+
* exempt — its rect is always the whole box, so position can't matter. */
|
|
37
|
+
export declare function needsContentRect(fit: ImageContentFit, position: ImageContentPositionObject): boolean;
|
|
38
|
+
/** NS `stretch` for the fast path — only reached for fits the platform
|
|
39
|
+
* vocabulary expresses identically (contain/cover/fill centered). */
|
|
40
|
+
export declare function contentFitToStretch(fit: ImageContentFit): 'aspectFit' | 'aspectFill' | 'fill';
|
|
41
|
+
/** L8 — expo `getBestSource`: the source whose declared pixel count
|
|
42
|
+
* (`width·height·scale²`, dips × density) is closest to the view's pixel
|
|
43
|
+
* count. Needs a real measured size; one source or no size picks nothing
|
|
44
|
+
* to decide. Unsized sources score worst and are skipped when any sized
|
|
45
|
+
* candidate exists. */
|
|
46
|
+
export declare function bestImageSource(sources: readonly ImageSourceLike[], viewWidth: number, viewHeight: number, screenScale: number): ImageSourceLike | null;
|
|
47
|
+
/** Browser `object-position` for a resolved position — mirrors expo-image
|
|
48
|
+
* web's `getObjectPositionFromContentPositionObject`. */
|
|
49
|
+
export declare function objectPositionCSSValue(position: ImageContentPositionObject): string;
|
|
50
|
+
/** Browser `srcset` candidates for a source array: `w` descriptors (real
|
|
51
|
+
* file px = width·scale) when every source is sized, `x` descriptors when
|
|
52
|
+
* every source only carries density. `src` falls back to the largest
|
|
53
|
+
* declared pixel count — guaranteed coverage where srcset is ignored. */
|
|
54
|
+
export declare function imageSrcSet(sources: readonly ImageSourceLike[]): {
|
|
55
|
+
src: string;
|
|
56
|
+
srcSet?: string;
|
|
57
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Image } from './Image.js';
|
|
2
|
+
export { clearImageCaches, evictImage, initializeImageCache, isImageCached, prefetch, } from './cache.js';
|
|
3
|
+
export type { ImageCacheConfig, ImageCachePolicy, ImageCacheQueryOptions, ImageCacheState, ImageContentFit, ImageContentPosition, ImageContentPositionObject, ImageContentPositionString, ImageContentPositionValue, ImageDecoding, ImageErrorEvent, ImageLoadEvent, ImageProps, PrefetchOptions, ImageSourceLike, } from './props.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Image } from './Image.web.js';
|
|
2
|
+
export { clearImageCaches, evictImage, initializeImageCache, isImageCached, prefetch, } from './cache.web.js';
|
|
3
|
+
export type { ImageCacheConfig, ImageCachePolicy, ImageCacheQueryOptions, ImageCacheState, ImageContentFit, ImageContentPosition, ImageContentPositionObject, ImageContentPositionString, ImageContentPositionValue, ImageDecoding, ImageErrorEvent, ImageLoadEvent, ImageProps, PrefetchOptions, ImageSourceLike, } from './props.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** VENDORED — identical copy in packages/gif/src/prefetch-batch.ts; keep in
|
|
2
|
+
* sync.
|
|
3
|
+
*
|
|
4
|
+
* Shared batch driver for the image-engine leaves' `prefetch` contract:
|
|
5
|
+
* normalizes `string | string[]`, caps in-flight requests JS-side, and
|
|
6
|
+
* resolves `true` only when every URL warms — `false` on the first failure
|
|
7
|
+
* (in-flight requests settle on their own; the result is already decided). */
|
|
8
|
+
/** Matches the `maxRequests = 5` ceiling NS core's ImageCache used. */
|
|
9
|
+
export declare const DEFAULT_PREFETCH_CONCURRENCY = 5;
|
|
10
|
+
export declare function prefetchBatch(srcs: string | string[], concurrency: number | undefined, warm: (url: string) => Promise<boolean>): Promise<boolean>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ImageProps as CoreImageProps } from '@octane-xplat/ui';
|
|
2
|
+
export type { ImageContentFit, ImageContentPosition, ImageContentPositionObject, ImageContentPositionString, ImageContentPositionValue, ImageDecoding, ImageSourceLike, } from '@octane-xplat/ui';
|
|
3
|
+
/** How the engine's caches participate in a load. The plugin exposes a single
|
|
4
|
+
* all-off switch (`noCache` → Glide `skipMemoryCache` + `DiskCacheStrategy.NONE`
|
|
5
|
+
* on Android, `SDWebImageOptions.FromLoaderOnly` on iOS), so the only honest
|
|
6
|
+
* non-default value is 'none'. 'memory'/'disk' splits are not representable
|
|
7
|
+
* through the plugin's request options today. Ignored on web — browsers own
|
|
8
|
+
* their HTTP cache. */
|
|
9
|
+
export type ImageCachePolicy = 'memory-disk' | 'none';
|
|
10
|
+
export interface ImageLoadEvent {
|
|
11
|
+
/** Decoded bitmap size in pixels. */
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
/** Where the engine served the image from. Absent on web — the browser
|
|
15
|
+
* does not report which cache (if any) satisfied an <img>. */
|
|
16
|
+
source?: 'network' | 'memory' | 'disk' | 'local';
|
|
17
|
+
}
|
|
18
|
+
export interface ImageErrorEvent {
|
|
19
|
+
error: Error;
|
|
20
|
+
}
|
|
21
|
+
/** Cache sizing/eviction applied through `initializeImageCache`. Native only —
|
|
22
|
+
* the web engine (browser HTTP cache) offers no equivalent knobs. */
|
|
23
|
+
export interface ImageCacheConfig {
|
|
24
|
+
/** In-memory bitmap cache size in bytes (Android Glide). */
|
|
25
|
+
memoryCacheSize?: number;
|
|
26
|
+
/** Size the memory cache as N fullscreen bitmaps (Android Glide). */
|
|
27
|
+
memoryCacheScreens?: number;
|
|
28
|
+
/** Persist the cache-key registry across launches so evictions stay
|
|
29
|
+
* consistent (Android SharedPreferences store). */
|
|
30
|
+
persistentCacheKeys?: boolean;
|
|
31
|
+
/** Bump to invalidate every cached entry — Glide `ObjectKey` signature. */
|
|
32
|
+
globalSignatureKey?: string;
|
|
33
|
+
/** iOS: track transformed cache keys for eviction. Needed when decodeWidth/
|
|
34
|
+
* decodeHeight (or other transforms) are used alongside evictImage —
|
|
35
|
+
* transformed images key differently than the raw URL. */
|
|
36
|
+
iosComplexCacheEviction?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Result of `isImageCached`. 'none' also covers "unknown" — on web the
|
|
39
|
+
* browser cache is not queryable, so web always reports 'none'. */
|
|
40
|
+
export type ImageCacheState = 'memory' | 'disk' | 'none';
|
|
41
|
+
/** Options for `prefetch` — the same contract `@octane-xplat/gif`'s
|
|
42
|
+
* `prefetch` carries. */
|
|
43
|
+
export interface PrefetchOptions {
|
|
44
|
+
/** Request headers forwarded on Android and iOS (the framework patch
|
|
45
|
+
* restores iOS request modifiers). Ignored on web — a plain <img>
|
|
46
|
+
* cannot send custom headers. */
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
/** Max URLs fetched in parallel (JS-side cap). Default 5 — the same
|
|
49
|
+
* ceiling NS core's ImageCache used. */
|
|
50
|
+
concurrency?: number;
|
|
51
|
+
}
|
|
52
|
+
/** Display-load context for `isImageCached`. On iOS the engine folds the
|
|
53
|
+
* transform a load used into the cache key — decode bounds are the common
|
|
54
|
+
* one, and the leaf always decodes to a size (explicit props or the view's
|
|
55
|
+
* measured size), so a bare probe misses entries a display load wrote.
|
|
56
|
+
* Repeat the same decode bounds here to probe the key a display load hits.
|
|
57
|
+
* Android keys probes on the URL alone and ignores these — but the plugin
|
|
58
|
+
* cannot see Glide's active resources there, so a bitmap still on screen
|
|
59
|
+
* may report 'none'. Web reports 'none' regardless. */
|
|
60
|
+
export interface ImageCacheQueryOptions {
|
|
61
|
+
/** Device-pixel decode bounds — same meaning as the `Image` props. */
|
|
62
|
+
decodeWidth?: number;
|
|
63
|
+
decodeHeight?: number;
|
|
64
|
+
}
|
|
65
|
+
/** Image — drop-in alternative to `@octane-xplat/ui`'s Image backed by a real
|
|
66
|
+
* image engine (Glide on Android, SDWebImage on iOS via
|
|
67
|
+
* `@nativescript-community/ui-image`): sized in-memory bitmap cache, disk
|
|
68
|
+
* cache, decode-to-view-size, placeholders and transitions. Web renders a
|
|
69
|
+
* plain <img>. Every `@octane-xplat/ui` Image prop is accepted with the same
|
|
70
|
+
* meaning — the members below are engine extensions with no core equivalent;
|
|
71
|
+
* they are ignored on web. SVG `src` is the one behavioral gap — keep core
|
|
72
|
+
* `Image` for those. One asymmetry: `decoding='sync'` is not honorably
|
|
73
|
+
* supported — Glide/SDWebImage have no synchronous decode mode (the plugin's
|
|
74
|
+
* `loadMode` prop is registered but never read), so 'sync' degrades to
|
|
75
|
+
* async on native with a console warning rather than a fake. */
|
|
76
|
+
export interface ImageProps extends CoreImageProps {
|
|
77
|
+
/** Native only — 'none' bypasses memory and disk caches for this image.
|
|
78
|
+
* Default 'memory-disk' leaves both caches active. */
|
|
79
|
+
cachePolicy?: ImageCachePolicy;
|
|
80
|
+
/** Native only — image shown when `src` fails (`failureImageUri`). */
|
|
81
|
+
failureImage?: string;
|
|
82
|
+
/** Native only — extra HTTP headers for the request (authenticated URLs). */
|
|
83
|
+
headers?: Record<string, string>;
|
|
84
|
+
/** Native only — explicit decode bounds in device pixels. Default is the
|
|
85
|
+
* view's laid-out size (the src is held until first layout so the engine
|
|
86
|
+
* never decodes at full source resolution). */
|
|
87
|
+
decodeWidth?: number;
|
|
88
|
+
decodeHeight?: number;
|
|
89
|
+
/** Native only — progressive/interlaced rendering while bytes stream. */
|
|
90
|
+
progressive?: boolean;
|
|
91
|
+
/** Native only — crossfade duration in ms when the image lands (0
|
|
92
|
+
* disables; engine default applies when unset). */
|
|
93
|
+
fadeDuration?: number;
|
|
94
|
+
/** Fired when the final image is set. `source` reports which cache level
|
|
95
|
+
* served the bitmap — native only; web fires without `source`. */
|
|
96
|
+
onLoad?: (event: ImageLoadEvent) => void;
|
|
97
|
+
/** Fired when the load fails. */
|
|
98
|
+
onError?: (event: ImageErrorEvent) => void;
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ImageProps } from './generated/props.js'
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
ImageCacheConfig,
|
|
5
|
+
ImageCachePolicy,
|
|
6
|
+
ImageCacheQueryOptions,
|
|
7
|
+
ImageCacheState,
|
|
8
|
+
ImageContentFit,
|
|
9
|
+
ImageContentPosition,
|
|
10
|
+
ImageContentPositionObject,
|
|
11
|
+
ImageContentPositionString,
|
|
12
|
+
ImageContentPositionValue,
|
|
13
|
+
ImageErrorEvent,
|
|
14
|
+
ImageLoadEvent,
|
|
15
|
+
ImageProps,
|
|
16
|
+
ImageSourceLike,
|
|
17
|
+
PrefetchOptions,
|
|
18
|
+
} from './generated/props.js'
|
|
19
|
+
|
|
20
|
+
export declare function Image(props: ImageProps): unknown
|
|
21
|
+
export declare function initializeImageCache(config?: import('./generated/props.js').ImageCacheConfig): void
|
|
22
|
+
export declare function prefetch(srcs: string | string[], options?: PrefetchOptions): Promise<boolean>
|
|
23
|
+
export declare function evictImage(src: string): Promise<boolean>
|
|
24
|
+
export declare function clearImageCaches(): Promise<void>
|
|
25
|
+
export declare function isImageCached(
|
|
26
|
+
srcs: string | readonly string[],
|
|
27
|
+
options?: import('./generated/props.js').ImageCacheQueryOptions,
|
|
28
|
+
): Promise<Record<string, import('./generated/props.js').ImageCacheState>>
|