@flighthq/loader 0.4.0-next.1920.b93ad0f → 0.4.0-next.1932.1ef883a

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 (3) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +9 -29
  3. package/package.json +3 -3
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2013-2026 Joshua Granick and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,37 +1,17 @@
1
1
  # @flighthq/loader
2
2
 
3
- ## Progress: three currencies, one contract
3
+ Group resource loading with progress and completion signals
4
4
 
5
- A load can be measured three ways, and they answer different questions. Asking for the wrong one is how a progress bar and a counter end up disagreeing on the same batch.
5
+ ## Install
6
6
 
7
- **`getResourceLoadProgress(loader)` — the 0..1 weighted fraction.** This is _the_ progress number, and `onProgress` emits exactly it, so the signal and the accessor can never diverge. Each item counts for its `weight` (default `1`), so an unweighted batch is simply the item fraction.
8
-
9
- **`getResourceLoadCounts(loader)` — how many items, and where they are.** `settledItems`, `inFlightItems`, `queuedItems`, `totalItems`. In-flight and queued are separate numbers because a concurrency limit makes them differ: "loading 4 of 200" is the in-flight count, not the queue depth. Use these for a literal "3 of 12 files" readout.
10
-
11
- **`getResourceLoadBytes(loader)` — what the load knows about its byte volume.** `bytesLoaded` is summed, monotonic, and always valid. `bytesTotalKnown` and `itemsWithKnownBytes` are labeled _known_ on purpose: `bytesHint` is optional per item, so the known total is a floor that grows as more items declare a size. Compare `itemsWithKnownBytes` against `totalItems` to judge whether it covers enough of the batch to divide by.
12
-
13
- ### The principle
14
-
15
- **The contract currency must be knowable before the work starts.** Weight qualifies because the caller supplies it: progress starts at a truthful 0 and never rescales. Bytes do not — a byte denominator grows as headers arrive, so a bar driven by it slides backwards as the loader discovers more work. That is why weight is the contract and bytes are reporting.
16
-
17
- ### Recipe: a byte-accurate progress bar
18
-
19
- When you know each item's size, pass those sizes _as weights_ and the weighted fraction becomes byte progress, with no second aggregate and no moving denominator:
20
-
21
- ```ts
22
- for (const asset of manifest) {
23
- queueResourceLoad(loader, {
24
- bytesHint: asset.size,
25
- weight: asset.size, // weight in bytes -> getResourceLoadProgress is byte progress
26
- load: (signal, reportBytes) => fetchAsset(asset, signal, reportBytes),
27
- });
28
- }
7
+ ```sh
8
+ npm install @flighthq/loader
29
9
  ```
30
10
 
31
- Partial size knowledge is deliberately not smoothed over in core: there is no byte-total estimator, because calibrating bytes-per-weight only works when weights are already byte-proportional — in which case the caller knows the total from its own hints anyway.
11
+ Import the supported application-facing API from `@flighthq/loader`. The `@flighthq/loader/contract` export is the wider package-to-package contract used to compose Flight itself.
32
12
 
33
- ### Edge cases
13
+ This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
34
14
 
35
- - An empty loader reports progress `1`. A batch of nothing is complete, which keeps `await` semantics consistent, and counts report zeros.
36
- - No query returns `NaN`. Every division is guarded by the zero check in front of it.
37
- - A batch whose items are _all_ explicitly `weight: 0` falls back to the item fraction, since the weighted fraction is undefined for it.
15
+ - [Flight project](https://github.com/flighthq/flight)
16
+ - [Source for @flighthq/loader@0.4.0-next.1932.1ef883a](https://github.com/flighthq/flight/tree/1ef883a866729a9bc6f461111970f6377de1499f/packages/loader)
17
+ - [License](https://github.com/flighthq/flight/blob/1ef883a866729a9bc6f461111970f6377de1499f/LICENSE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/loader",
3
- "version": "0.4.0-next.1920.b93ad0f",
3
+ "version": "0.4.0-next.1932.1ef883a",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/signals": "0.4.0-next.1920.b93ad0f",
42
- "@flighthq/types": "0.4.0-next.1920.b93ad0f"
41
+ "@flighthq/signals": "0.4.0-next.1932.1ef883a",
42
+ "@flighthq/types": "0.4.0-next.1932.1ef883a"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.3.0"