@ranx729/ducktape-assets 1.0.0 → 1.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/AGENTS.md CHANGED
@@ -10,8 +10,18 @@ Generated. Use these rules; do not edit this file by hand.
10
10
  ## Using an asset
11
11
 
12
12
  1. **Paste a URL.** Any HTML, CSS or Markdown references one file on jsDelivr, for example `https://cdn.jsdelivr.net/npm/@ranx729/ducktape-assets-walters-w102@1.2.0/webp/rabbit-church-bells-512.webp`. Only that file is transferred. `catalog.json` lists the exact URL of every width and format, so nothing has to be guessed.
13
- 2. **Pick and copy.** Keep a small `ducktape.json` listing the asset ids you want, with optional widths, formats and `masters: true`. `npx @ranx729/ducktape-assets copy` fetches exactly those files into the project (default `src/assets/ducktape/`), verifies every SHA-256 against the manifest, and writes `ducktape.manifest.json` beside them with dimensions, thumbhash, licence and attribution per asset. Re-running is idempotent.
14
- 3. **Resolve in code.** `npm i @ranx729/ducktape-assets` installs metadata and a resolver, zero images. `assets.image(id, { width })` returns `src`, `srcset`, `sizes`, width, height, thumbhash and licence. Bytes come from the CDN at request time, or from flow 2 when `base` points at the copied directory.
13
+ 2. **Pick and copy.** Keep a small `ducktape.json` listing the asset ids you want, with optional widths, formats and `masters: true`. `npx @ranx729/ducktape-assets copy` fetches exactly those files into the project (default `src/assets/ducktape/`), verifies every SHA-256 against the manifest, and writes `ducktape.manifest.json` beside them with type, dimensions (native and of the capped master), transparency, render geometry (tile axis, frame slice), thumbhash, licence and attribution per asset. `masters: true` alone copies only the lossless master (for apps that encode their own images); add `formats`, `widths` or `max` to copy ladder files as well. Re-running is idempotent.
14
+ 3. **Resolve in code.** `npm i @ranx729/ducktape-assets` installs metadata and a resolver, zero images. `assets.image(id, { width })` returns `src`, `srcset`, `sizes`, width, height, thumbhash, licence, `attribution`, and `file` / `files` (path, bytes and sha256 of every referenced rung, for scripts that record or verify what they use). Bytes come from the CDN at request time, or from flow 2 when `base` points at the copied directory.
15
+
16
+ Build-time recipe in Node, offline, no network:
17
+
18
+ ```js
19
+ import { createNodeResolver } from '@ranx729/ducktape-assets/node';
20
+ const assets = await createNodeResolver({ formats: ['webp'] });
21
+ const img = await assets.image('walters-w102/rabbit-church-bells', { width: 256, dpr: 1 });
22
+ // img.src is the smallest rung at or above 256 px (never upscaled); img.file.sha256 and img.file.bytes are the publisher's.
23
+ // For an exact 2x pick ask for width 512 with dpr 1; the default dpr 3 returns the whole range for a srcset.
24
+ ```
15
25
 
16
26
  Prefer flow 2 for anything that must survive unattended: copied files do not depend on any host.
17
27
 
package/README.md CHANGED
@@ -5,8 +5,18 @@ Find an asset here, use it in under a minute. This package is metadata and a bui
5
5
  ## Three ways to use an asset
6
6
 
7
7
  1. **Paste a URL.** Any HTML, CSS or Markdown references one file on jsDelivr, for example `https://cdn.jsdelivr.net/npm/@ranx729/ducktape-assets-walters-w102@1.2.0/webp/rabbit-church-bells-512.webp`. Only that file is transferred. `catalog.json` lists the exact URL of every width and format, so nothing has to be guessed.
8
- 2. **Pick and copy.** Keep a small `ducktape.json` listing the asset ids you want, with optional widths, formats and `masters: true`. `npx @ranx729/ducktape-assets copy` fetches exactly those files into the project (default `src/assets/ducktape/`), verifies every SHA-256 against the manifest, and writes `ducktape.manifest.json` beside them with dimensions, thumbhash, licence and attribution per asset. Re-running is idempotent.
9
- 3. **Resolve in code.** `npm i @ranx729/ducktape-assets` installs metadata and a resolver, zero images. `assets.image(id, { width })` returns `src`, `srcset`, `sizes`, width, height, thumbhash and licence. Bytes come from the CDN at request time, or from flow 2 when `base` points at the copied directory.
8
+ 2. **Pick and copy.** Keep a small `ducktape.json` listing the asset ids you want, with optional widths, formats and `masters: true`. `npx @ranx729/ducktape-assets copy` fetches exactly those files into the project (default `src/assets/ducktape/`), verifies every SHA-256 against the manifest, and writes `ducktape.manifest.json` beside them with type, dimensions (native and of the capped master), transparency, render geometry (tile axis, frame slice), thumbhash, licence and attribution per asset. `masters: true` alone copies only the lossless master (for apps that encode their own images); add `formats`, `widths` or `max` to copy ladder files as well. Re-running is idempotent.
9
+ 3. **Resolve in code.** `npm i @ranx729/ducktape-assets` installs metadata and a resolver, zero images. `assets.image(id, { width })` returns `src`, `srcset`, `sizes`, width, height, thumbhash, licence, `attribution`, and `file` / `files` (path, bytes and sha256 of every referenced rung, for scripts that record or verify what they use). Bytes come from the CDN at request time, or from flow 2 when `base` points at the copied directory.
10
+
11
+ Build-time recipe in Node, offline, no network:
12
+
13
+ ```js
14
+ import { createNodeResolver } from '@ranx729/ducktape-assets/node';
15
+ const assets = await createNodeResolver({ formats: ['webp'] });
16
+ const img = await assets.image('walters-w102/rabbit-church-bells', { width: 256, dpr: 1 });
17
+ // img.src is the smallest rung at or above 256 px (never upscaled); img.file.sha256 and img.file.bytes are the publisher's.
18
+ // For an exact 2x pick ask for width 512 with dpr 1; the default dpr 3 returns the whole range for a srcset.
19
+ ```
10
20
 
11
21
  `ducktape.json`:
12
22