@uln/manage 0.0.0-stage → 0.5.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/CHANGELOG.md ADDED
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ `@uln/manage` on npm. Each release has a `## <version> — <YYYY-MM-DD>` section here: the Release SDK workflow
4
+ publishes only a version that has one, and uses it as the GitHub release notes.
5
+
6
+ ## 0.5.0 — 2026-12-05
7
+
8
+ Photos load faster on client sites, and sites can optimize the media in their own repository.
9
+
10
+ - `PublicPhoto.placeholder` (a ~16px blurred WebP `data:` URL) and `PublicPhoto.color` (the photo's average colour,
11
+ `#rrggbb`), to show until the photo arrives. Manage makes them in the background, so older photos gain them shortly
12
+ after their first read.
13
+ - `PublicPhoto.srcset` and `PublicFilm.posterSrcset`: the requested width variants as a ready `<img srcset>` string.
14
+ - `ulnMedia()` from `@uln/manage/vite`: `?uln` imports of a site's own images (AVIF/WebP/JPEG at several widths, with a
15
+ placeholder and colour; needs `sharp`) and videos (AV1 and H.264 MP4s with a poster; needs ffmpeg), cached in the
16
+ site's committed `.uln-media/`. Types: `/// <reference types="@uln/manage/media" />`.
17
+
18
+ ## 0.4.0 — 2026-11-11
19
+
20
+ Manage can now keep a site's films on **Mux** as well as Cloudflare Stream. Sites don't change how they read content:
21
+ `playbackUrl`, `posterUrl`/`posterVariants`, `previewUrl` and `previewPlaybackUrl` are signed URLs from whichever
22
+ backend holds the film, and nothing in a record says which. `@uln/hls` plays both.
23
+
24
+ - `mediaOrigins()`: the hosts Manage's media can come from (Stream, Mux's `stream.mux.com`, `image.mux.com` and
25
+ `*.mux.com` chunk hosts, and the Images account), for a site's CSP and preconnects. Sites that pinned their CSP to the
26
+ Stream customer host must switch to it before their first film on Mux, or the browser will block it.
27
+ - The package no longer depends on `@uln/hls`. The preview schemas it re-exported types from now live in Manage.
28
+
29
+ ## 0.3.1 — 2026-11-11
30
+
31
+ First release on npm (`pnpm add @uln/manage`).
32
+
33
+ - Renamed from `@uln/management`, the name of the bootstrap tarballs. To switch, `pnpm remove @uln/management`,
34
+ `pnpm add @uln/manage`, and change imports from `@uln/management`, `@uln/management/rpc` and
35
+ `@uln/management/vite` to `@uln/manage`, `@uln/manage/rpc` and `@uln/manage/vite`. Nothing else changes.
36
+ - The published types work under every TypeScript module resolution. Before, a site using `"moduleResolution":
37
+ "NodeNext"` (or `Node16`) got errors from the package's declarations, because their relative imports had no file
38
+ extension. `Bundler` resolution was unaffected.
39
+ - The package includes this changelog.
40
+
41
+ Contents, unchanged from 0.3.0:
42
+
43
+ - `createManagementClient(binding)` for a same-account service binding and `createHttpManagementClient({ apiKey })`
44
+ for a Worker in another account: `films()`, `film(id)`, `shoots()`, `shoot(id)`, `contacts()`, with optional
45
+ `sizes` for signed variants.
46
+ - `managementUrl(site)`, a link to the site in Manage.
47
+ - `@uln/manage/rpc`: the `PublicCatalogRpc` binding type.
48
+ - `@uln/manage/vite`: `ulnPackages()`, which writes `/.well-known/uln-packages.json` for Manage's SDK versions page.
package/README.md CHANGED
@@ -1,3 +1,194 @@
1
- # Temporary Holding Version
1
+ # @uln/manage
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Content for ULN websites, supplied by Manage. Framework independent; no React, Workers runtime imports,
4
+ credentials, media transport or player code in the package. Keep using `@uln/auth` for authentication.
5
+
6
+ ```sh
7
+ pnpm add @uln/manage
8
+ ```
9
+
10
+ Bind your website Worker to Manage in the same account. Auth's directory supplies the permanent site id;
11
+ the binding fixes it so calls cannot request another site's content.
12
+
13
+ ```jsonc
14
+ "services": [{
15
+ "binding": "CATALOG", "service": "manage", "entrypoint": "PublicCatalog",
16
+ "props": { "site": "simwize", "origin": "https://simwize.uln.industries" }
17
+ }]
18
+ ```
19
+
20
+ ```ts
21
+ import { createManagementClient, managementUrl, type PublicCatalogRpc } from "@uln/manage";
22
+
23
+ // In server code, per request. Do not pass bindings or credentials to the browser.
24
+ const management = createManagementClient(env.CATALOG as PublicCatalogRpc);
25
+ const films = await management.films();
26
+ const shoots = await management.shoots({ photoWidths: [640, 1280, 1920] }); // the widths your layout shows
27
+ const film = await management.film("film-id");
28
+ const shoot = await management.shoot("shoot-id");
29
+ const contacts = await management.contacts();
30
+ const editUrl = managementUrl("simwize");
31
+
32
+ // No envelopes or metadata/media joins:
33
+ // films[0].title, films[0].playbackUrl, films[0].posterUrl, films[0].previewUrl
34
+ // shoot?.photos[0].url, shoot?.photos[0].variants?.["1280"], shoot?.photos[0].srcset, shoot?.photos[0].width,
35
+ // shoot?.photos[0].alt, shoot?.photos[0].placeholder (blurred data: URL), shoot?.photos[0].color (#rrggbb)
36
+ ```
37
+
38
+ Every media URL is signed and points straight at whichever backend holds the video (Cloudflare Stream or Mux) or the
39
+ still (Cloudflare Images). A site never learns which: it passes the URLs to `@uln/hls` and its image components as
40
+ supplied. For its Content-Security-Policy and preconnects it asks the package where Manage's media can come from:
41
+
42
+ ```ts
43
+ import { mediaOrigins } from "@uln/manage";
44
+
45
+ const { media, images, preconnect } = mediaOrigins();
46
+ // `media-src 'self' blob: ${media.join(" ")}`, `connect-src 'self' ${media.join(" ")}` (HLS fetches segments),
47
+ // `img-src 'self' data: ${images.join(" ")}`; <link rel="preconnect"> to each of `preconnect`.
48
+ ```
49
+
50
+ A backend Manage adds later brings its hosts with an SDK release; nothing else in the site changes.
51
+
52
+ Lists and individual records use the same ready-to-display shapes:
53
+
54
+ - `films()` — film metadata, `playbackUrl`, `posterUrl`, optional `previewUrl` (MP4), `previewPlaybackUrl` (the same preview as adaptive HLS) and `posterVariants`, and `expiresAt`.
55
+ - `film(id)` — one complete public film, or `undefined` when missing or hidden.
56
+ - `shoots()` — ordered public shoots, each with its ordered `photos` (URL, dimensions, alt text and expiry), plus a
57
+ blurred `placeholder` and average `color` to show while each loads (absent for a moment after an upload).
58
+ - Every content method takes optional `sizes` (`photoWidths`, `posterWidths`): one signed URL per width comes back
59
+ in `photo.variants` / `film.posterVariants`, and as ready `srcset` strings in `photo.srcset` / `film.posterSrcset`.
60
+ Manage holds no size preferences; each site asks for its own.
61
+ - `shoot(id)` — one complete public shoot with its photos, or `undefined` when missing or hidden.
62
+ - `contacts()` — ordered `{ id, label, email }` contact lines.
63
+
64
+ Pass URLs to your existing image/video components; media comes straight from the provider. Preview start
65
+ is the prepared clip's source start. Storage keys, encoding/workflow state and RPC envelopes stay behind the SDK.
66
+ The binding type is available from `@uln/manage/rpc`; existing RPC methods remain compatible but are not
67
+ part of the website client.
68
+
69
+ Access uses a same-account Cloudflare service binding, not a public HTTP content endpoint. A website whose Worker
70
+ runs in another Cloudflare account uses `createHttpManagementClient({ apiKey })` instead: the same client over
71
+ `https://manage.uln.industries/api/content/v1` (OpenAPI at `/api/content/v1/openapi.json`), with a per-site key an
72
+ admin creates in Manage and the site keeps in a server secret. The key fixes the site. The website client
73
+ runs on the server. Its fixed binding `site` **and** `origin` must match the same entry in auth’s site directory;
74
+ unknown sites, missing origins and mismatched origins are rejected. These deployment props are not browser
75
+ headers and callers cannot override them in an SDK method. Visitors do not need to sign in to view published
76
+ content. Editing still requires `@uln/auth` and site access.
77
+
78
+ CORS does not authenticate server-to-server RPC. Binding/deployment permissions are the trust boundary: an
79
+ operator who can configure bindings in this account is trusted. Provider-side allowed-origin/referrer settings
80
+ and R2 CORS must separately use auth’s registered origins. Signed URLs are transferable until expiry; origin
81
+ checks are not DRM. Metadata-only legacy RPC methods retain their existing site-registration checks for
82
+ compatibility; the SDK uses the origin-checked content methods, including `contactsContent()`.
83
+
84
+ All content methods are public projections: hidden films, hidden categories, encoding films, hidden shoots and
85
+ empty shoots are excluded. Editing and previewing unpublished content belong in Manage behind `@uln/auth`.
86
+ The client has no write methods and `managementUrl()` does not authorize access.
87
+
88
+ Signed URLs are bearer capabilities. `expiresAt` is Unix milliseconds; refresh content before that time, and
89
+ never cache a page or data response beyond the earliest URL expiry. Leave room for playback duration and cache
90
+ staleness. Manage currently issues six-hour provider links; do not hardcode that duration in consumers. Long-lived
91
+ pages must renew their content. Existing external HTTPS sources are explicitly represented with a null expiry;
92
+ new private providers need a server-side signing adapter before being supported. Never rewrite or strip signing
93
+ query parameters. Stream signs HLS and poster URLs, Images signs image URLs, R2 signs preview object GET URLs.
94
+
95
+ Consumers own layout, category navigation, slugs, languages and playback through `@uln/hls`. Neither Manage nor
96
+ this SDK proxies images, previews or video streams to client websites.
97
+
98
+ ## Reporting your @uln packages
99
+
100
+ Add `ulnPackages()` to the site's Vite config so admins can see, on Manage's **SDK versions** page, which `@uln/*`
101
+ packages the live site was built with and which need upgrading:
102
+
103
+ ```ts
104
+ // vite.config.ts
105
+ import { ulnPackages } from "@uln/manage/vite";
106
+
107
+ export default defineConfig({ plugins: [ulnPackages() /* , … */] });
108
+ ```
109
+
110
+ The build writes `/.well-known/uln-packages.json` into the client output (the dev server answers it too): each
111
+ `@uln/*` package in the site's `package.json`, the version installed, its range and dependency section, and the
112
+ site's `packageManager`. It is a static file, served like any other asset; it names package versions only. Server code
113
+ can import the same report: `import { report } from "virtual:uln-packages"`. The contract is `src/package-report.ts`.
114
+
115
+ ## Optimizing the site's own images and videos
116
+
117
+ `ulnMedia()` optimizes the media committed in the site's repository (heroes, logos, background loops) at build time.
118
+ Content edited in Manage doesn't go through it: that keeps coming from its providers.
119
+
120
+ ```sh
121
+ pnpm add -D sharp # images; videos also need ffmpeg on the machine that first encodes them
122
+ ```
123
+
124
+ ```ts
125
+ // vite.config.ts
126
+ import { ulnMedia, ulnPackages } from "@uln/manage/vite";
127
+
128
+ export default defineConfig({ plugins: [ulnMedia(), ulnPackages() /* , … */] });
129
+ ```
130
+
131
+ ```ts
132
+ // vite-env.d.ts (or any .d.ts the site includes)
133
+ /// <reference types="@uln/manage/media" />
134
+ ```
135
+
136
+ Import a file with `?uln`:
137
+
138
+ ```tsx
139
+ import hero from "./hero.jpg?uln";
140
+ import loop from "./loop.mov?uln&poster=2.5"; // poster frame at 2.5s (default 0)
141
+
142
+ <picture>
143
+ {hero.sources.map((s) => <source key={s.type} type={s.type} srcSet={s.srcset} sizes="100vw" />)}
144
+ <img src={hero.src} srcSet={hero.srcset} sizes="100vw" width={hero.width} height={hero.height} alt=""
145
+ style={{ background: `${hero.color} url(${hero.placeholder}) center / cover` }} />
146
+ </picture>
147
+
148
+ <video autoPlay muted loop playsInline poster={loop.poster.src} width={loop.width} height={loop.height}>
149
+ {loop.sources.map((s) => <source key={s.src} src={s.src} type={s.type} />)}
150
+ </video>
151
+ ```
152
+
153
+ - **Images** (`jpg`, `png`, `webp`, `avif`, `tiff`, `heic`): AVIF, WebP and a JPEG fallback (PNG when the image has
154
+ transparency) at 480–2560px wide, never wider than the original; EXIF orientation applied, metadata stripped. You
155
+ get `src`, `srcset`, `sources` (best first, for `<picture>`), `width`/`height`, a ~200-byte blurred `placeholder`
156
+ (`data:` URL) and the dominant `color`.
157
+ - **Videos** (`mp4`, `mov`, `m4v`, `webm`, `mkv`): AV1 and H.264 MP4s (AAC sound, `faststart`), at most 1920px wide,
158
+ each `type` with its exact `codecs` so a browser takes the first it can decode, plus `poster` (an optimized image as
159
+ above), `width`/`height`, `duration` and `audio`.
160
+
161
+ **Commit `.uln-media/`.** Every encode is cached there, keyed by the file's bytes and the settings, and built from as
162
+ ordinary hashed assets. Workers Builds has no ffmpeg, so a video must already be encoded there: run `pnpm dev` (or a
163
+ build) once where ffmpeg is installed (`brew install ffmpeg`) and commit the folder with the video. A build that meets
164
+ an unencoded video without ffmpeg fails and says so. Images encode anywhere sharp installs, Workers Builds included,
165
+ but committing them too keeps builds fast. A changed file or setting gets a new entry; delete entries no longer
166
+ imported. For large videos consider Git LFS (`git lfs track ".uln-media/**/*.mp4"`; Workers Builds has `git-lfs`).
167
+
168
+ Options, all optional: `ulnMedia({ widths, maxWidth, quality: { avif, webp, jpeg }, video: { maxWidth, formats:
169
+ ["av1", "h264"], audio, posterTime }, cacheDir, ffmpeg, ffprobe })`. `video: { audio: false }` strips the sound (e.g.
170
+ for background loops); `formats: ["h264"]` skips the slower AV1 encode.
171
+
172
+ ## Developing and publishing
173
+
174
+ The package is built from this repository: `sdk/` holds its entry points, and its types come from Manage's
175
+ canonical contract in `src/` (`src/rpc-types.ts`, `src/schema.ts`, `src/public-content.ts`). The tarball has
176
+ compiled ESM and declarations only, with no UI, database code, signer or credentials.
177
+
178
+ - `pnpm build:sdk` builds `sdk/dist`.
179
+ - `pnpm check:sdk` builds and packs the tarball, installs it in a throwaway consumer and checks it as a site
180
+ would use it: the tarball's contents, strict typechecking under NodeNext and Bundler resolution, and every entry
181
+ point loading under Node. CI runs it on every push.
182
+ - Every relative import reachable from the SDK's entry points keeps its `.ts` extension (the SDK build uses NodeNext
183
+ resolution and fails without one). Without it, the published declarations break for NodeNext sites.
184
+
185
+ To release:
186
+
187
+ 1. Bump `version` in `sdk/package.json` and `SDK_VERSION` in `sdk/version.ts` together (a test checks they match),
188
+ and add a `## <version> — <YYYY-MM-DD>` section at the top of `sdk/CHANGELOG.md` saying what changed for sites.
189
+ Pre-1.0, a breaking change is a minor bump, though the contract only grows.
190
+ 2. Once that's on `main`, run the **Release SDK** workflow (`.github/workflows/release-sdk.yml`) on `main`. It
191
+ runs every check, publishes `@uln/manage@<version>` to npm with Trusted Publishing (no npm token), tags
192
+ `sdk-v<version>` and creates a GitHub release from the changelog section. Re-running is safe.
193
+
194
+ Never run `npm publish` by hand. Publishing doesn't deploy Manage, and deploying Manage doesn't publish the SDK.
package/dist/index.js ADDED
@@ -0,0 +1,165 @@
1
+ function e(e) {
2
+ let t = new URLSearchParams();
3
+ e?.photoWidths?.length && t.set("photoWidths", e.photoWidths.join(",")), e?.posterWidths?.length && t.set("posterWidths", e.posterWidths.join(","));
4
+ let n = t.toString();
5
+ return n ? `?${n}` : "";
6
+ }
7
+ // src/content-api-spec.ts
8
+ var t = (e, t) => ({
9
+ name: e,
10
+ in: "query",
11
+ required: !1,
12
+ schema: {
13
+ type: "string",
14
+ pattern: "^\\d+(,\\d+)*$"
15
+ },
16
+ description: `${t} Comma-separated whole pixels from 1 to 8192, at most 12.`
17
+ });
18
+ t("photoWidths", "Photo widths the site displays; each comes back in `variants`."), t("posterWidths", "Poster widths the site displays; each comes back in `posterVariants`.");
19
+ // src/public-content.ts
20
+ function n(e, t) {
21
+ let n = t !== void 0 && t > 1 ? Math.round(t) : Infinity, r = /* @__PURE__ */ new Map(), i = Object.entries(e).sort(([e], [t]) => Number(e) - Number(t));
22
+ for (let [e, t] of i) {
23
+ let i = Math.min(Number(e), n);
24
+ Number.isFinite(i) && i > 0 && !r.has(i) && r.set(i, t);
25
+ }
26
+ return [...r].map(([e, t]) => `${t} ${e}w`).join(", ");
27
+ }
28
+ function r({ film: e, playback: t, poster: n, posterVariants: r, preview: i, previewPlayback: o }) {
29
+ let s = [
30
+ t.expiresAt,
31
+ n.expiresAt,
32
+ i?.expiresAt,
33
+ o?.expiresAt
34
+ ].filter((e) => typeof e == "number"), c = s.length ? Math.min(...s) : null, { previewAsset: l, previewPreparation: u, frameImages: d, cachedFrames: f, processing: p, hidden: m, videoProvider: h, videoPlaybackId: g, ..._ } = e;
35
+ return {
36
+ ..._,
37
+ playbackUrl: t.url,
38
+ posterUrl: n.url,
39
+ ...r ? a(r) : {},
40
+ ...i ? {
41
+ previewUrl: i.url,
42
+ previewStart: l?.sourceStart ?? e.previewStart ?? 0,
43
+ ...l?.size ? { previewBytes: l.size } : {}
44
+ } : {},
45
+ ...o ? {
46
+ previewPlaybackUrl: o.url,
47
+ ...i ? {} : { previewStart: l?.sourceStart ?? e.previewStart ?? 0 }
48
+ } : {},
49
+ expiresAt: c
50
+ };
51
+ }
52
+ function i(e) {
53
+ return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.url]));
54
+ }
55
+ function a(e) {
56
+ let t = i(e);
57
+ return {
58
+ posterVariants: t,
59
+ posterSrcset: n(t)
60
+ };
61
+ }
62
+ function o({ shoot: e, photos: t }) {
63
+ let { photos: r, hidden: a, ...o } = e;
64
+ return {
65
+ ...o,
66
+ photos: t.map(({ photo: e, image: t, variants: r, preview: a }) => {
67
+ let o = r ? i(r) : void 0;
68
+ return {
69
+ ...e,
70
+ url: t.url,
71
+ ...o ? {
72
+ variants: o,
73
+ srcset: n(o, e.width)
74
+ } : {},
75
+ ...a ? {
76
+ placeholder: a.placeholder,
77
+ color: a.color
78
+ } : {},
79
+ expiresAt: t.expiresAt
80
+ };
81
+ })
82
+ };
83
+ }
84
+ // src/media-origins.ts
85
+ var s = {
86
+ streamCustomerCode: "nuayb0iz1dy4986k",
87
+ imagesAccountHash: "SSUBLwYw6Bk_Rd7fv37_lw"
88
+ }, c = {
89
+ stream: "https://stream.mux.com",
90
+ hosts: "https://*.mux.com",
91
+ image: "https://image.mux.com"
92
+ };
93
+ function l(e = s) {
94
+ if (!/^[a-z0-9]{8,64}$/.test(e.streamCustomerCode)) throw Error("Expected a Stream customer code");
95
+ if (!/^[A-Za-z0-9_-]{8,64}$/.test(e.imagesAccountHash)) throw Error("Expected an Images account hash");
96
+ let t = `https://customer-${e.streamCustomerCode}.cloudflarestream.com`;
97
+ return {
98
+ media: [
99
+ t,
100
+ c.stream,
101
+ c.hosts
102
+ ],
103
+ images: [
104
+ `https://imagedelivery.net/${e.imagesAccountHash}/`,
105
+ t,
106
+ c.image
107
+ ],
108
+ preconnect: [
109
+ t,
110
+ c.stream,
111
+ c.image
112
+ ]
113
+ };
114
+ }
115
+ // sdk/index.ts
116
+ function u(e) {
117
+ return {
118
+ async films(t) {
119
+ return (await e.filmsContent(t)).films.map(r);
120
+ },
121
+ async film(t, n) {
122
+ let i = await e.filmContent(t, n);
123
+ return i ? r(i) : void 0;
124
+ },
125
+ async shoots(t) {
126
+ return (await e.stillsContent(t)).shoots.map(o);
127
+ },
128
+ async shoot(t, n) {
129
+ let r = await e.shootContent(t, n);
130
+ return r ? o(r) : void 0;
131
+ },
132
+ contacts: () => e.contactsContent()
133
+ };
134
+ }
135
+ function d(t) {
136
+ let n = `${new URL(t.origin ?? "https://manage.uln.industries").origin}/api/content/v1`, r = t.fetch ?? ((e, t) => fetch(e, t));
137
+ async function i(e, i, a = !1) {
138
+ let o = await r(`${n}${e}`, { headers: {
139
+ Authorization: `Bearer ${t.apiKey}`,
140
+ Accept: "application/json"
141
+ } });
142
+ if (a && o.status === 404) return;
143
+ if (!o.ok) {
144
+ let t = await o.json().catch(() => null), n = typeof t?.error == "string" ? t.error : o.statusText;
145
+ throw Error(`Manage content API ${e}: ${o.status} ${n}`);
146
+ }
147
+ let s = await o.json();
148
+ if (!(i in s)) throw Error(`Manage content API ${e}: response has no "${i}"`);
149
+ return s[i];
150
+ }
151
+ return {
152
+ films: (t) => i(`/films${e(t)}`, "films"),
153
+ film: (t, n) => i(`/films/${encodeURIComponent(t)}${e(n)}`, "film", !0),
154
+ shoots: (t) => i(`/shoots${e(t)}`, "shoots"),
155
+ shoot: (t, n) => i(`/shoots/${encodeURIComponent(t)}${e(n)}`, "shoot", !0),
156
+ contacts: () => i("/contacts", "contacts")
157
+ };
158
+ }
159
+ function f(e, t = "https://manage.uln.industries") {
160
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(e)) throw Error("Invalid site id");
161
+ let n = new URL(t);
162
+ if (n.protocol !== "https:" && (n.protocol !== "http:" || n.hostname !== "localhost")) throw Error("Manage requires HTTPS (or localhost)");
163
+ return n.pathname = `/sites/${e}`, n.search = "", n.hash = "", n.toString();
164
+ }
165
+ export { s as MANAGE_MEDIA_ACCOUNT, d as createHttpManagementClient, u as createManagementClient, f as managementUrl, l as mediaOrigins };
package/dist/rpc.js ADDED
File without changes
@@ -0,0 +1,39 @@
1
+ import { type MediaSizes } from "../src/media-sizes.ts";
2
+ import { type PublicFilm, type PublicShoot } from "../src/public-content.ts";
3
+ import type { PublicCatalogRpc } from "../src/rpc-types.ts";
4
+ import type { SiteContact } from "../src/schema.ts";
5
+ export { MANAGE_MEDIA_ACCOUNT, type MediaOrigins, mediaOrigins } from "../src/media-origins.ts";
6
+ export type { MediaSizes } from "../src/media-sizes.ts";
7
+ export type { PublicFilm, PublicPhoto, PublicShoot } from "../src/public-content.ts";
8
+ export type { PublicCatalogProps, PublicCatalogRpc } from "../src/rpc-types.ts";
9
+ export type { Credit, SiteContact } from "../src/schema.ts";
10
+ /**
11
+ * `sizes` names the widths the site's layout needs: each photo's `variants` and each film's `posterVariants` hold
12
+ * one signed URL per requested width. Ask for a small, stable set; Manage keeps no size preferences of its own.
13
+ */
14
+ export interface ManagementClient {
15
+ films(sizes?: MediaSizes): Promise<PublicFilm[]>;
16
+ film(id: string, sizes?: MediaSizes): Promise<PublicFilm | undefined>;
17
+ shoots(sizes?: MediaSizes): Promise<PublicShoot[]>;
18
+ shoot(id: string, sizes?: MediaSizes): Promise<PublicShoot | undefined>;
19
+ contacts(): Promise<SiteContact[]>;
20
+ }
21
+ type ContentBinding = Pick<PublicCatalogRpc, "filmsContent" | "filmContent" | "stillsContent" | "shootContent" | "contactsContent">;
22
+ /** Public lists only. The binding fixes the site and keeps its receiver; callers never pass a site id. */
23
+ export declare function createManagementClient(binding: ContentBinding): ManagementClient;
24
+ export interface HttpManagementClientOptions {
25
+ /** The site's Manage API key (`mk_<site>_…`), created by an admin on the site's API page in Manage. Server-only. */
26
+ apiKey: string;
27
+ /** Manage's origin. */
28
+ origin?: string;
29
+ /** Override for tests or instrumentation; defaults to the global `fetch`. */
30
+ fetch?: typeof fetch;
31
+ }
32
+ /**
33
+ * The same client over HTTP (`/api/content/v1`), for a website whose Worker can't bind Manage because it runs in
34
+ * another Cloudflare account. The key fixes the site. Call it from server code only: never ship the key to a browser.
35
+ * Missing or unpublished details return undefined; any other failure (bad key, Manage unavailable) rejects.
36
+ */
37
+ export declare function createHttpManagementClient(options: HttpManagementClientOptions): ManagementClient;
38
+ /** A navigation link, never an authorization decision. Manage checks access against auth. */
39
+ export declare function managementUrl(site: string, origin?: string): string;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Types for `?uln` media imports (`ulnMedia()` from `@uln/manage/vite`). Reference it once in the site, e.g. in
3
+ * `vite-env.d.ts`: `/// <reference types="@uln/manage/media" />`.
4
+ */
5
+ declare module "*.jpg?uln" {
6
+ const image: import("./media-types.ts").UlnImage;
7
+ export default image;
8
+ }
9
+ declare module "*.jpeg?uln" {
10
+ const image: import("./media-types.ts").UlnImage;
11
+ export default image;
12
+ }
13
+ declare module "*.png?uln" {
14
+ const image: import("./media-types.ts").UlnImage;
15
+ export default image;
16
+ }
17
+ declare module "*.webp?uln" {
18
+ const image: import("./media-types.ts").UlnImage;
19
+ export default image;
20
+ }
21
+ declare module "*.avif?uln" {
22
+ const image: import("./media-types.ts").UlnImage;
23
+ export default image;
24
+ }
25
+ declare module "*.tif?uln" {
26
+ const image: import("./media-types.ts").UlnImage;
27
+ export default image;
28
+ }
29
+ declare module "*.tiff?uln" {
30
+ const image: import("./media-types.ts").UlnImage;
31
+ export default image;
32
+ }
33
+ declare module "*.heic?uln" {
34
+ const image: import("./media-types.ts").UlnImage;
35
+ export default image;
36
+ }
37
+ declare module "*.heif?uln" {
38
+ const image: import("./media-types.ts").UlnImage;
39
+ export default image;
40
+ }
41
+ declare module "*.mp4?uln" {
42
+ const video: import("./media-types.ts").UlnVideo;
43
+ export default video;
44
+ }
45
+ declare module "*.mov?uln" {
46
+ const video: import("./media-types.ts").UlnVideo;
47
+ export default video;
48
+ }
49
+ declare module "*.m4v?uln" {
50
+ const video: import("./media-types.ts").UlnVideo;
51
+ export default video;
52
+ }
53
+ declare module "*.webm?uln" {
54
+ const video: import("./media-types.ts").UlnVideo;
55
+ export default video;
56
+ }
57
+ declare module "*.mkv?uln" {
58
+ const video: import("./media-types.ts").UlnVideo;
59
+ export default video;
60
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * What a `?uln` media import gives a site's code (`ulnMedia()` in `@uln/manage/vite`). Plain data, no runtime:
3
+ * every URL is a hashed asset in the site's own build.
4
+ */
5
+ /** One encoding of an image or video, newest format first in `sources`: browsers take the first they support. */
6
+ export interface UlnImageSource {
7
+ /** MIME type for `<source type>`, e.g. `image/avif`. */
8
+ type: string;
9
+ /** Width-descriptor `srcset`: `/assets/hero-640.avif 640w, …`. */
10
+ srcset: string;
11
+ }
12
+ export interface UlnImage {
13
+ /** The largest fallback-format file (JPEG, or PNG for images with transparency): `<img src>`. */
14
+ src: string;
15
+ /** Every width in the fallback format: `<img srcset>`. */
16
+ srcset: string;
17
+ /** Modern formats for `<picture><source>`, best first (AVIF, then WebP). */
18
+ sources: UlnImageSource[];
19
+ /** The intrinsic size of the largest file: set both on `<img>` so the page doesn't shift when it loads. */
20
+ width: number;
21
+ height: number;
22
+ /** A tiny blurred preview as a `data:` URL (a few hundred bytes): a background until the image arrives. */
23
+ placeholder: string;
24
+ /** The image's dominant colour as `#rrggbb`, for an even cheaper placeholder. */
25
+ color: string;
26
+ }
27
+ export interface UlnVideoSource {
28
+ src: string;
29
+ /** MIME type with codecs, e.g. `video/mp4; codecs="av01.0.08M.08"`, so browsers skip what they can't decode. */
30
+ type: string;
31
+ }
32
+ export interface UlnVideo {
33
+ /** For `<video><source>`, best first: AV1, then H.264 that every browser plays. */
34
+ sources: UlnVideoSource[];
35
+ /** A frame of the video as an optimized image: `<video poster={poster.src}>`, or a `<picture>` before playback. */
36
+ poster: UlnImage;
37
+ width: number;
38
+ height: number;
39
+ /** Seconds. */
40
+ duration: number;
41
+ /** Whether the encodes have sound. A silent video can autoplay muted without a mute control. */
42
+ audio: boolean;
43
+ }
@@ -0,0 +1,45 @@
1
+ import type { Plugin } from "vite";
2
+ export type { UlnImage, UlnImageSource, UlnVideo, UlnVideoSource } from "./media-types.ts";
3
+ export declare const MEDIA_QUERY = "uln";
4
+ export declare const IMAGE_EXTENSIONS: string[];
5
+ export declare const VIDEO_EXTENSIONS: string[];
6
+ export type VideoFormat = "av1" | "h264";
7
+ export interface UlnMediaOptions {
8
+ /** Where encodes are kept, relative to Vite's `root`. Commit it. Default `.uln-media`. */
9
+ cacheDir?: string;
10
+ /** Image widths to offer, in pixels; widths above the image's own (or `maxWidth`) are dropped. */
11
+ widths?: number[];
12
+ /** The widest image file produced. Default 2560. */
13
+ maxWidth?: number;
14
+ /** Encoder quality, 1–100. Defaults: AVIF 50, WebP 75, JPEG 80. */
15
+ quality?: {
16
+ avif?: number;
17
+ webp?: number;
18
+ jpeg?: number;
19
+ };
20
+ video?: {
21
+ /** The widest video produced. Default 1920. */
22
+ maxWidth?: number;
23
+ /** Encodes to produce, best first. Default `["av1", "h264"]`; keep `h264` last as the one every browser plays. */
24
+ formats?: VideoFormat[];
25
+ /** Keep the soundtrack (AAC). Default true; false strips it, e.g. for background loops. */
26
+ audio?: boolean;
27
+ /** Seconds into the video for the poster frame. Default 0; per file with `?uln&poster=2.5`. */
28
+ posterTime?: number;
29
+ };
30
+ /** The ffmpeg and ffprobe commands. Default `ffmpeg` and `ffprobe` on the PATH. */
31
+ ffmpeg?: string;
32
+ ffprobe?: string;
33
+ }
34
+ /** `hero.jpg?uln&poster=2` → the file and its params, or null when the import isn't ours. */
35
+ export declare function parseMediaId(id: string): {
36
+ file: string;
37
+ kind: "image" | "video";
38
+ params: URLSearchParams;
39
+ } | null;
40
+ /** The `codecs` parameter for an encode, from what ffprobe reads back out of it. */
41
+ export declare function codecsOf(video: {
42
+ codec_name?: string | undefined;
43
+ level?: number | undefined;
44
+ }, audio: boolean): string;
45
+ export declare function ulnMedia(options?: UlnMediaOptions): Plugin;
@@ -0,0 +1 @@
1
+ export type { PublicCatalogProps, PublicCatalogRpc } from "../src/rpc-types.ts";
@@ -0,0 +1,13 @@
1
+ import type { Plugin } from "vite";
2
+ import { type PackageReport } from "../src/package-report.ts";
3
+ export { PACKAGE_REPORT_PATH, type PackageReport } from "../src/package-report.ts";
4
+ export interface UlnPackagesOptions {
5
+ /** The directory whose `package.json` names the site's dependencies. Defaults to Vite's `root`. */
6
+ root?: string;
7
+ }
8
+ /** The report for the site whose `package.json` is in `root`. Throws when there is no `package.json` there. */
9
+ export declare function packageReport(root: string, now?: Date): PackageReport;
10
+ /** The report as a module of the site's own code: `import { report } from "virtual:uln-packages"`. */
11
+ export declare const VIRTUAL_MODULE = "virtual:uln-packages";
12
+ export declare function ulnPackages(options?: UlnPackagesOptions): Plugin;
13
+ export { type UlnImage, type UlnImageSource, type UlnMediaOptions, type UlnVideo, type UlnVideoSource, ulnMedia, } from "./media.ts";