@streamiq/shared

v1.1.0

Published

Tiny dependency-free utilities shared by Streamq adapters.

Readme

@streamiq/shared

Tiny dependency-free utilities shared by Streamq format adapters (@streamiq/hls, @streamiq/dash).

Stable 1.0.x. Installed transitively with hls/dash. Application code should prefer @streamiq/core APIs — do not treat shared as a general utility dump.

Install

npm install @streamiq/shared
# Usually installed automatically with @streamiq/hls or @streamiq/dash

Architecture

@streamiq/shared/src
├── constants/
│   └── package-name.ts            STREAMQ_SHARED_PACKAGE
│
├── helpers/
│   └── assert.ts                  assertDefined
│
├── utils/
│   ├── clamp.ts                   Clamp number to [min, max]
│   └── raceAbort.ts               Promise vs AbortSignal race
│
├── low-latency/                   Shared LL-HLS / LL-DASH contract
│   ├── index.ts
│   ├── lowLatencyPolicy.ts        DEFAULT_LOW_LATENCY_PLAYBACK_POLICY
│   ├── validateLowLatencyPolicy.ts
│   ├── latencyBudget.ts           createLatencyBudgetFromPolicy, evaluateLiveLatencySeconds
│   ├── bufferTuningReport.ts      buildLowLatencyBufferTuningReport
│   ├── parseLlManifestHints.ts    HLS + DASH manifest sniffers
│   ├── cmafPackagerHints.ts       Packager hint types
│   ├── validateCmafCompatibility.ts
│   ├── platformMatrix.ts          PLATFORM_LOW_LATENCY_MATRIX (Safari / Android / TV)
│   └── validation.types.ts        Shared issue / result types
│
├── offline/                       Metadata-only types
│   ├── index.ts
│   └── types.ts                   OfflineContentId, OfflineManifestRef, OfflineSegmentRef,
│                                  OfflineDrmKeyRef, OfflineManifestKind
│
└── types/
    └── index.ts                   StreamqSharedPlaceholder

Design rules

| Rule | Detail | |------|--------| | No playback orchestration | Adapters only — not for app business logic | | No @streamiq/* deps | Stays dependency-free (boundary checker enforced) | | Tiny surface | Prefer duplicating 5-line helpers over widening this package |


Exports

Utilities

| Export | Purpose | |--------|---------| | clamp | Clamp number to [min, max] | | raceAbort | Race promise against AbortSignal | | assertDefined | Type-narrowing assertion | | STREAMQ_SHARED_PACKAGE | Package identifier constant |

Low-latency streaming

Shared between HLS and DASH LL adapters.

| Export | Purpose | |--------|---------| | DEFAULT_LOW_LATENCY_PLAYBACK_POLICY | Default LL tuning object | | LowLatencyPlaybackPolicy | Policy type | | LiveEdgeSyncMode | Live edge sync enum | | validateLowLatencyPlaybackPolicy | Validate policy object | | validateCmafPackagerAgainstPolicy | CMAF packager hint check | | mergeValidationResults | Merge validation issues | | parseHlsLowLatencyManifestHints | Sniff LL-HLS tags (no full parser) | | parseDashLowLatencyMpdHints | Sniff LL-DASH MPD attributes | | createLatencyBudgetFromPolicy | Derive latency budget | | evaluateLiveLatencySeconds | Compare actual vs target latency | | buildLowLatencyBufferTuningReport | Derive hls.js / Shaka buffer knobs | | PLATFORM_LOW_LATENCY_MATRIX | Safari / Android / TV validation notes | | LowLatencyValidationIssue, LowLatencyValidationResult | Result types | | LowLatencyBufferTuningReport, LowLatencyLatencyBudget, LiveLatencyEvaluation | Report types | | LowLatencyPlatformCapability, LowLatencyPlatformId, CmafPackagerHints | Platform types |

Offline types (metadata only)

Types for app-owned offline download metadata — no download engine.

| Type | Purpose | |------|---------| | OfflineContentId | Content identifier | | OfflineManifestRef | Cached manifest reference | | OfflineSegmentRef | Segment file reference | | OfflineDrmKeyRef | Offline DRM key reference | | OfflineManifestKind | Manifest format kind |


Usage (adapters)

import {
  DEFAULT_LOW_LATENCY_PLAYBACK_POLICY,
  parseHlsLowLatencyManifestHints,
} from '@streamiq/shared';
// Used internally by @streamiq/hls and @streamiq/dash —
// apps typically use adapter factories instead.

Bundle size

| Budget | Limit | |--------|-------| | Full bundle | 1.2 kB gzipped | | { clamp } only | 150 B |


Dependencies

None.

License

MIT