Skip to content

PendingSelection — @gj-kit/expo-media

A public interface from @gj-kit/expo-media/core. The signature below is taken directly from the 0.6.1 release declaration.

import { PendingSelection } from '@gj-kit/expo-media/core';
interface PendingSelection {
/** The configured cap. */
readonly max: number;
/**
* Stable identity of an item: `asset:<assetId>` (falling back to the URI when the picker gave
* no asset id) for picked items, `binary:<name>:<size>:<lastModified>` for binaries.
*/
keyOf(item: PendingMediaItem): string;
/**
* Stage items. Duplicates (by `keyOf`, including duplicates within `items`) are rejected before
* the cap is checked, so a re-selected photo reports `duplicate` even when the selection is full.
* Nothing is revoked here; pass the result's `releasable` to `release`. Neither `state` nor
* `items` is mutated, and the result object and its arrays are frozen.
*/
add(state: PendingSelectionState, items: readonly PendingMediaItem[]): PendingAddResult;
/**
* Drop every item whose `keyOf` equals `key`, calling `revoke` on removed binaries. Returns the
* same reference when no item matched.
*/
remove(state: PendingSelectionState, key: string): PendingSelectionState;
/** Drop every item, calling `revoke` on each binary that still holds a preview resource. */
clear(state: PendingSelectionState): PendingSelectionState;
/**
* Call `revoke` on binaries that are not staged — typically `PendingAddResult.releasable`.
* Idempotent per item object; picked items and binaries without `revoke` are ignored. Passing an
* item that is still staged kills its live preview, which is why `rejected` is not the input here.
*/
release(items: readonly PendingMediaItem[]): void;
/** Picked assets in selection order — the input of `uploadPickedAsset` / device resolve paths. */
toPickedAssets(state: PendingSelectionState): readonly PickedAsset[];
/** Binary sources in selection order — the input of `uploadBinary` / `uploadDropped`. */
toBinarySources(state: PendingSelectionState): readonly NamedBinarySource[];
/**
* URI the host can render, or `null`. Picked assets always preview through their own URI. A binary
* previews only when it has a `previewUri` **and** is not HEIC/HEIF — browsers cannot decode those,
* and an `<img>` that never loads looks like a broken upload.
*/
previewUriOf(item: PendingMediaItem): string | null;
/** `previewUriOf(item) !== null`. */
canPreview(item: PendingMediaItem): boolean;
/**
* Capture time as an ISO string, or `null`. Picked items read the picker EXIF dictionary; binaries
* parse the JPEG APP1 segment from bytes (the same parsers the upload path uses). Never throws.
*/
capturedAtOf(item: PendingMediaItem): Promise<string | null>;
}

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/expo-media
  • Version: 0.6.1
  • Public entry: ./core
  • Source: GitHub