@niccolofanton/corkboard 0.1.0 → 0.2.1

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.
@@ -0,0 +1,253 @@
1
+ const p = {
2
+ youtube: "YouTube",
3
+ vimeo: "Vimeo",
4
+ spotify: "Spotify",
5
+ codepen: "CodePen",
6
+ figma: "Figma",
7
+ generic: "Web page"
8
+ }, v = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
9
+ function w(r) {
10
+ let e;
11
+ try {
12
+ e = new URL(r.trim());
13
+ } catch {
14
+ return null;
15
+ }
16
+ return e.protocol === "http:" && !v.has(e.hostname) && e.port === "" && (e.protocol = "https:"), e.protocol !== "https:" && e.protocol !== "http:" || e.username !== "" || e.password !== "" ? null : e.toString();
17
+ }
18
+ const S = (r) => r.replace(/^www\./, "");
19
+ function y(r) {
20
+ if (!r) return null;
21
+ if (/^\d+$/.test(r)) return Number(r);
22
+ const e = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(r);
23
+ return !e || e[1] === void 0 && e[2] === void 0 && e[3] === void 0 ? null : Number(e[1] ?? 0) * 3600 + Number(e[2] ?? 0) * 60 + Number(e[3] ?? 0);
24
+ }
25
+ const g = /^[\w-]{11}$/, d = /* @__PURE__ */ new Set(["videoseries", "live_stream"]), $ = /^[\w-]+$/, A = /* @__PURE__ */ new Set([
26
+ "youtube.com",
27
+ "m.youtube.com",
28
+ "music.youtube.com",
29
+ "youtube-nocookie.com",
30
+ "youtu.be"
31
+ ]), m = (r, e) => {
32
+ const t = r.searchParams.get(e);
33
+ return t !== null && $.test(t) ? t : null;
34
+ }, f = (r, e) => {
35
+ const t = new URLSearchParams(e).toString();
36
+ return `https://www.youtube-nocookie.com/embed/${r}` + (t ? `?${t}` : "");
37
+ };
38
+ function L(r, e) {
39
+ if (!A.has(e)) return null;
40
+ const t = r.pathname.split("/").filter(Boolean);
41
+ if (e !== "youtu.be" && t[0] === "embed" && d.has(t[1] ?? "")) {
42
+ const c = t[1] === "videoseries", a = m(r, c ? "list" : "channel");
43
+ return a === null ? null : {
44
+ provider: "youtube",
45
+ iframeSrc: f(t[1], c ? { list: a } : { channel: a }),
46
+ aspect: 9 / 16,
47
+ posters: []
48
+ };
49
+ }
50
+ let o = null;
51
+ if (e === "youtu.be" ? o = t[0] ?? null : t[0] === "watch" ? o = r.searchParams.get("v") : ["embed", "shorts", "live", "v"].includes(t[0] ?? "") && (o = t[1] ?? null), o === null || !g.test(o) || d.has(o)) return null;
52
+ const s = y(r.searchParams.get("t") ?? r.searchParams.get("start")), n = m(r, "list"), i = {};
53
+ return n !== null && (i.list = n), s && (i.start = String(s)), {
54
+ provider: "youtube",
55
+ iframeSrc: f(o, i),
56
+ aspect: 9 / 16,
57
+ // maxresdefault (1280x720) is missing on some videos; mqdefault (320x180) is always there and, unlike
58
+ // hqdefault, has no letterbox bars.
59
+ posters: [
60
+ `https://i.ytimg.com/vi/${o}/maxresdefault.jpg`,
61
+ `https://i.ytimg.com/vi/${o}/mqdefault.jpg`
62
+ ]
63
+ };
64
+ }
65
+ const E = /* @__PURE__ */ new Set(["showcase", "album", "event"]);
66
+ function T(r, e) {
67
+ if (e !== "vimeo.com" && e !== "player.vimeo.com") return null;
68
+ const t = r.pathname.split("/").filter(Boolean), o = (l) => l !== void 0 && /^\d+$/.test(l), s = t.findIndex((l) => l === "video" || l === "videos");
69
+ let n = -1;
70
+ if (s >= 0 ? n = o(t[s + 1]) ? s + 1 : -1 : E.has(t[0] ?? "") || (n = t.findIndex(o)), n < 0) return null;
71
+ const i = t[n], c = t[n + 1], a = r.searchParams.get("h"), u = a !== null && /^[0-9a-f]+$/i.test(a) ? a : c && /^[0-9a-f]{8,}$/i.test(c) ? c : null;
72
+ return {
73
+ provider: "vimeo",
74
+ iframeSrc: `https://player.vimeo.com/video/${i}` + (u ? `?${new URLSearchParams({ h: u }).toString()}` : ""),
75
+ aspect: 9 / 16,
76
+ posters: []
77
+ };
78
+ }
79
+ const P = /* @__PURE__ */ new Set(["track", "album", "playlist", "episode", "show", "artist"]);
80
+ function _(r, e) {
81
+ if (e !== "open.spotify.com") return null;
82
+ let t = r.pathname.split("/").filter(Boolean);
83
+ t[0]?.startsWith("intl-") && (t = t.slice(1)), t[0] === "embed" && (t = t.slice(1));
84
+ const [o, s] = t;
85
+ if (!o || !P.has(o) || !s || !/^[A-Za-z0-9]{22}$/.test(s)) return null;
86
+ const n = o === "track" || o === "episode";
87
+ return {
88
+ provider: "spotify",
89
+ iframeSrc: `https://open.spotify.com/embed/${o}/${s}`,
90
+ // The player is 152 px (compact) or 352 px tall at any width; 400 px is the card's default width.
91
+ aspect: n ? 152 / 400 : 352 / 400,
92
+ posters: []
93
+ };
94
+ }
95
+ function I(r, e) {
96
+ if (e !== "codepen.io") return null;
97
+ let t = r.pathname.split("/").filter(Boolean), o = "";
98
+ t[0] === "team" && (o = "team/", t = t.slice(1));
99
+ const [s, n, i] = t;
100
+ return !s || !i || !["pen", "full", "details", "embed", "debug"].includes(n ?? "") || !/^[A-Za-z0-9]+$/.test(i) ? null : {
101
+ provider: "codepen",
102
+ iframeSrc: `https://codepen.io/${o}${s}/embed/${i}?default-tab=result`,
103
+ aspect: 5 / 8,
104
+ posters: []
105
+ };
106
+ }
107
+ function R(r, e) {
108
+ if (e !== "figma.com" || r.pathname === "/embed") return null;
109
+ const t = r.pathname.split("/").filter(Boolean)[0];
110
+ return !t || !["file", "design", "proto", "board", "slides", "deck"].includes(t) ? null : {
111
+ provider: "figma",
112
+ iframeSrc: `https://www.figma.com/embed?embed_host=corkboard&url=${encodeURIComponent(r.toString())}`,
113
+ aspect: 3 / 4,
114
+ posters: []
115
+ };
116
+ }
117
+ const k = [L, T, _, I, R];
118
+ function C(r) {
119
+ const e = w(r);
120
+ if (e === null) return null;
121
+ const t = new URL(e), o = S(t.hostname);
122
+ for (const s of k) {
123
+ const n = s(t, o);
124
+ if (n) return { ...n, url: e, host: o, label: p[n.provider] };
125
+ }
126
+ return {
127
+ url: e,
128
+ host: o,
129
+ provider: "generic",
130
+ iframeSrc: e,
131
+ posters: [],
132
+ label: p.generic
133
+ };
134
+ }
135
+ const U = [
136
+ { host: "www.youtube-nocookie.com", path: /^\/embed\//, provider: "youtube" },
137
+ { host: "player.vimeo.com", path: /^\/video\//, provider: "vimeo" },
138
+ { host: "open.spotify.com", path: /^\/embed\//, provider: "spotify" },
139
+ { host: "codepen.io", path: /^\/(?:team\/)?[^/]+\/embed\//, provider: "codepen" },
140
+ { host: "www.figma.com", path: /^\/embed$/, provider: "figma" }
141
+ ];
142
+ function x(r) {
143
+ try {
144
+ const e = new URL(r);
145
+ return e.protocol !== "https:" ? "generic" : U.find((t) => t.host === e.hostname && t.path.test(e.pathname))?.provider ?? "generic";
146
+ } catch {
147
+ return "generic";
148
+ }
149
+ }
150
+ function D(r, e) {
151
+ if (r !== "youtube" && r !== "vimeo") return e;
152
+ let t;
153
+ try {
154
+ t = new URL(e);
155
+ } catch {
156
+ return e;
157
+ }
158
+ const o = t.searchParams;
159
+ if (r === "vimeo")
160
+ o.set("autoplay", "1"), o.set("muted", "1"), o.set("loop", "1");
161
+ else {
162
+ const s = t.pathname.split("/")[2] ?? "";
163
+ o.set("autoplay", "1"), o.set("mute", "1"), o.set("playsinline", "1"), s !== "live_stream" && o.set("loop", "1"), s !== "videoseries" && s !== "live_stream" && !o.has("list") && o.set("playlist", s);
164
+ }
165
+ return t.toString();
166
+ }
167
+ function H(r, e, t) {
168
+ if (r !== "youtube") return e;
169
+ let o;
170
+ try {
171
+ o = new URL(e);
172
+ } catch {
173
+ return e;
174
+ }
175
+ return o.searchParams.set("enablejsapi", "1"), t !== void 0 && /^https?:\/\//.test(t) && o.searchParams.set("origin", t), o.toString();
176
+ }
177
+ const O = (r) => r !== "generic";
178
+ class W extends Error {
179
+ /** Why it was thrown; branch on this. */
180
+ code;
181
+ constructor(e, t, o) {
182
+ super(t, o), this.name = "CorkboardError", this.code = e;
183
+ }
184
+ }
185
+ const h = 15874666, b = 14032735;
186
+ function Y(r) {
187
+ return r.guide ?? (r.dark ? h : b);
188
+ }
189
+ const B = {
190
+ dark: !0,
191
+ canvas: 986895,
192
+ dot: 16777215,
193
+ dotAlpha: 0.0805,
194
+ border: 16777215,
195
+ borderAlpha: 0.1,
196
+ accent: 6989567,
197
+ well: 1842204,
198
+ guide: h,
199
+ onGuide: 16777215
200
+ }, G = {
201
+ dark: !1,
202
+ canvas: 16053490,
203
+ dot: 0,
204
+ dotAlpha: 0.1035,
205
+ border: 0,
206
+ borderAlpha: 0.1,
207
+ accent: 3107839,
208
+ well: 15263972,
209
+ guide: b,
210
+ onGuide: 16777215
211
+ };
212
+ function M(r) {
213
+ const e = /^#([0-9a-f]{6})$/i.exec(r);
214
+ return e ? parseInt(e[1], 16) : null;
215
+ }
216
+ const N = (r) => `#${r.toString(16).padStart(6, "0")}`, q = {
217
+ /** Width of an image or video card. */
218
+ cardWidth: 248,
219
+ /** Height / width of an image card whose picture has no known aspect. */
220
+ cardAspect: 1.25,
221
+ /** Height / width of a video card with no known aspect. */
222
+ videoAspect: 9 / 16,
223
+ /** Height / width of an embed card whose provider has no shape of its own. */
224
+ embedAspect: 9 / 16,
225
+ /** Width of an embed card. */
226
+ embedWidth: 400,
227
+ /** Corner radius. */
228
+ cardRadius: 8,
229
+ /** Narrowest a resize gesture makes a card. */
230
+ minCardW: 40,
231
+ /** Widest a resize gesture makes a card. */
232
+ maxCardW: 1600
233
+ }, F = 0.05, V = 4;
234
+ export {
235
+ W as C,
236
+ B as D,
237
+ G as L,
238
+ F as M,
239
+ p as P,
240
+ q as a,
241
+ V as b,
242
+ y as c,
243
+ x as d,
244
+ N as e,
245
+ D as f,
246
+ Y as g,
247
+ M as h,
248
+ O as i,
249
+ w as n,
250
+ C as p,
251
+ H as w
252
+ };
253
+ //# sourceMappingURL=chunk-values-D2mwqJ9D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-values-D2mwqJ9D.js","sources":["../src/embed/providers.ts","../src/errors.ts","../src/render/theme.ts","../src/types.ts"],"sourcesContent":["// URL parsing and provider recognition for `embed` cards. Pure: no DOM, no network.\n//\n// A pasted URL becomes a `ParsedEmbed`: the iframe URL to load live (`youtube.com/watch?v=x` ->\n// `youtube-nocookie.com/embed/x`), the poster candidates that need no server, and the shape of the card.\n// What cannot be known here (oEmbed titles, og:image, `X-Frame-Options`) belongs to the host's `resolve`\n// option, on a server (see EmbedResolver in resolve.ts).\n\n/** Providers recognised from a URL. They get a nocookie / embed URL, a natural card shape and a poster that needs no server; any other URL is `'generic'`. */\nexport type EmbedProvider = 'youtube' | 'vimeo' | 'spotify' | 'codepen' | 'figma' | 'generic';\n\n/** What a URL says about an embed card, without a network request. */\nexport interface ParsedEmbed {\n /** The URL as the card keeps it: https, no credentials. */\n url: string;\n /** Host without `www.`, for the generated tile. */\n host: string;\n /** Which provider the URL belongs to. */\n provider: EmbedProvider;\n /** What the iframe loads when the card goes live. */\n iframeSrc: string;\n /** `aspect`: height / width of the card for this provider, when it has a natural one. */\n aspect?: number;\n /** Poster URLs that need no server, best first (each must be CORS-readable; the layer probes them). */\n posters: string[];\n /** A human label for the tile (\"YouTube\"). */\n label: string;\n}\n\n/** The human label of each provider, as shown on a tile. */\nexport const PROVIDER_LABEL: Record<EmbedProvider, string> = {\n youtube: 'YouTube',\n vimeo: 'Vimeo',\n spotify: 'Spotify',\n codepen: 'CodePen',\n figma: 'Figma',\n generic: 'Web page',\n};\n\nconst LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);\n\n/**\n * Cleans a URL for an embed card: only http(s) URLs without credentials. `http:` is upgraded to `https:` except on\n * localhost (dev) and on an explicit port (a LAN or dev server there has no TLS). `javascript:`, `data:`, `file:`,\n * `blob:` and the rest are refused.\n *\n * @returns The normalised URL, or `null` when it cannot be an embed.\n */\nexport function normalizeEmbedUrl(raw: string): string | null {\n let u: URL;\n try {\n u = new URL(raw.trim());\n } catch {\n return null;\n }\n if (u.protocol === 'http:' && !LOCAL_HOSTS.has(u.hostname) && u.port === '') u.protocol = 'https:';\n if (u.protocol !== 'https:' && u.protocol !== 'http:') return null;\n if (u.username !== '' || u.password !== '') return null;\n return u.toString();\n}\n\nconst stripWww = (h: string): string => h.replace(/^www\\./, '');\n\n/** `90`, `90s`, `1m30s`, `1h2m3s` -> seconds. */\nexport function parseTimestamp(t: string | null): number | null {\n if (!t) return null;\n if (/^\\d+$/.test(t)) return Number(t);\n const m = /^(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?$/.exec(t);\n if (!m || (m[1] === undefined && m[2] === undefined && m[3] === undefined)) return null;\n return Number(m[1] ?? 0) * 3600 + Number(m[2] ?? 0) * 60 + Number(m[3] ?? 0);\n}\n\nconst YT_ID = /^[\\w-]{11}$/;\n// Path words that are 11 word characters long, so they look like a video id.\nconst YT_PATH_WORDS = new Set(['videoseries', 'live_stream']);\n// A playlist or channel id: word characters and dashes only, so it is safe in the iframe URL.\nconst YT_LIST = /^[\\w-]+$/;\nconst YT_HOSTS = new Set([\n 'youtube.com',\n 'm.youtube.com',\n 'music.youtube.com',\n 'youtube-nocookie.com',\n 'youtu.be',\n]);\n\nconst ytParam = (u: URL, name: string): string | null => {\n const v = u.searchParams.get(name);\n return v !== null && YT_LIST.test(v) ? v : null;\n};\n\nconst ytEmbed = (path: string, params: Record<string, string>): string => {\n const q = new URLSearchParams(params).toString();\n return `https://www.youtube-nocookie.com/embed/${path}` + (q ? `?${q}` : '');\n};\n\nfunction parseYouTube(u: URL, host: string): Omit<ParsedEmbed, 'url' | 'host' | 'label'> | null {\n if (!YT_HOSTS.has(host)) return null;\n const parts = u.pathname.split('/').filter(Boolean);\n // A playlist or a live stream has no video id: `embed/videoseries?list=` and `embed/live_stream?channel=`.\n // No ytimg poster either (there is no id to ask for): the card gets the generated tile.\n if (host !== 'youtu.be' && parts[0] === 'embed' && YT_PATH_WORDS.has(parts[1] ?? '')) {\n const series = parts[1] === 'videoseries';\n const value = ytParam(u, series ? 'list' : 'channel');\n if (value === null) return null;\n return {\n provider: 'youtube',\n iframeSrc: ytEmbed(parts[1], series ? { list: value } : { channel: value }),\n aspect: 9 / 16,\n posters: [],\n };\n }\n let id: string | null = null;\n if (host === 'youtu.be') id = parts[0] ?? null;\n else if (parts[0] === 'watch') id = u.searchParams.get('v');\n else if (['embed', 'shorts', 'live', 'v'].includes(parts[0] ?? '')) id = parts[1] ?? null;\n if (id === null || !YT_ID.test(id) || YT_PATH_WORDS.has(id)) return null;\n const start = parseTimestamp(u.searchParams.get('t') ?? u.searchParams.get('start'));\n // A video watched inside a playlist keeps the playlist.\n const list = ytParam(u, 'list');\n const params: Record<string, string> = {};\n if (list !== null) params.list = list;\n if (start) params.start = String(start);\n return {\n provider: 'youtube',\n iframeSrc: ytEmbed(id, params),\n aspect: 9 / 16,\n // maxresdefault (1280x720) is missing on some videos; mqdefault (320x180) is always there and, unlike\n // hqdefault, has no letterbox bars.\n posters: [\n `https://i.ytimg.com/vi/${id}/maxresdefault.jpg`,\n `https://i.ytimg.com/vi/${id}/mqdefault.jpg`,\n ],\n };\n}\n\n// Pages that list videos: a bare one (no `video` segment) is not a video.\nconst VIMEO_LISTS = new Set(['showcase', 'album', 'event']);\n\nfunction parseVimeo(u: URL, host: string): Omit<ParsedEmbed, 'url' | 'host' | 'label'> | null {\n if (host !== 'vimeo.com' && host !== 'player.vimeo.com') return null;\n const parts = u.pathname.split('/').filter(Boolean);\n const isId = (p: string | undefined): boolean => p !== undefined && /^\\d+$/.test(p);\n // The digits after `video` / `videos` (`showcase/987/video/123`, `player.vimeo.com/video/123`), else the\n // first number (`123`, `channels/staffpicks/123`) unless the page is a showcase, album or event.\n const v = parts.findIndex((p) => p === 'video' || p === 'videos');\n let i = -1;\n if (v >= 0) i = isId(parts[v + 1]) ? v + 1 : -1;\n else if (!VIMEO_LISTS.has(parts[0] ?? '')) i = parts.findIndex(isId);\n if (i < 0) return null;\n const id = parts[i];\n // An unlisted video carries a hash: `vimeo.com/ID/HASH` or `?h=HASH`.\n const next = parts[i + 1];\n // Only hex goes into the iframe URL: `?h=abc&autoplay=1` or anything else a link carries is dropped.\n const q = u.searchParams.get('h');\n const hash = q !== null && /^[0-9a-f]+$/i.test(q) ? q : next && /^[0-9a-f]{8,}$/i.test(next) ? next : null;\n return {\n provider: 'vimeo',\n iframeSrc:\n `https://player.vimeo.com/video/${id}` + (hash ? `?${new URLSearchParams({ h: hash }).toString()}` : ''),\n aspect: 9 / 16,\n posters: [],\n };\n}\n\nconst SPOTIFY_TYPES = new Set(['track', 'album', 'playlist', 'episode', 'show', 'artist']);\n\nfunction parseSpotify(u: URL, host: string): Omit<ParsedEmbed, 'url' | 'host' | 'label'> | null {\n if (host !== 'open.spotify.com') return null;\n let parts = u.pathname.split('/').filter(Boolean);\n // `/intl-it/track/ID` and `/embed/track/ID`.\n if (parts[0]?.startsWith('intl-')) parts = parts.slice(1);\n if (parts[0] === 'embed') parts = parts.slice(1);\n const [type, id] = parts;\n if (!type || !SPOTIFY_TYPES.has(type) || !id || !/^[A-Za-z0-9]{22}$/.test(id)) return null;\n const compact = type === 'track' || type === 'episode';\n return {\n provider: 'spotify',\n iframeSrc: `https://open.spotify.com/embed/${type}/${id}`,\n // The player is 152 px (compact) or 352 px tall at any width; 400 px is the card's default width.\n aspect: compact ? 152 / 400 : 352 / 400,\n posters: [],\n };\n}\n\nfunction parseCodePen(u: URL, host: string): Omit<ParsedEmbed, 'url' | 'host' | 'label'> | null {\n if (host !== 'codepen.io') return null;\n let parts = u.pathname.split('/').filter(Boolean);\n let team = '';\n if (parts[0] === 'team') {\n team = 'team/';\n parts = parts.slice(1);\n }\n const [user, kind, id] = parts;\n if (!user || !id || !['pen', 'full', 'details', 'embed', 'debug'].includes(kind ?? '')) return null;\n if (!/^[A-Za-z0-9]+$/.test(id)) return null;\n return {\n provider: 'codepen',\n iframeSrc: `https://codepen.io/${team}${user}/embed/${id}?default-tab=result`,\n aspect: 5 / 8,\n posters: [],\n };\n}\n\nfunction parseFigma(u: URL, host: string): Omit<ParsedEmbed, 'url' | 'host' | 'label'> | null {\n if (host !== 'figma.com') return null;\n if (u.pathname === '/embed') return null;\n const kind = u.pathname.split('/').filter(Boolean)[0];\n if (!kind || !['file', 'design', 'proto', 'board', 'slides', 'deck'].includes(kind)) return null;\n return {\n provider: 'figma',\n iframeSrc: `https://www.figma.com/embed?embed_host=corkboard&url=${encodeURIComponent(u.toString())}`,\n aspect: 3 / 4,\n posters: [],\n };\n}\n\nconst PARSERS = [parseYouTube, parseVimeo, parseSpotify, parseCodePen, parseFigma];\n\n/**\n * Parses a pasted URL into what an embed card needs: provider, iframe URL (`youtube.com/watch?v=x` becomes\n * `youtube-nocookie.com/embed/x`), poster candidates and the card's shape. Use it to validate input before it\n * becomes a card. Any other http(s) URL parses as `generic` (loaded as is, with the stricter sandbox).\n *\n * @returns `null` when the URL is not http(s).\n */\nexport function parseEmbedUrl(raw: string): ParsedEmbed | null {\n const url = normalizeEmbedUrl(raw);\n if (url === null) return null;\n const u = new URL(url);\n const host = stripWww(u.hostname);\n for (const parse of PARSERS) {\n const hit = parse(u, host);\n if (hit) return { ...hit, url, host, label: PROVIDER_LABEL[hit.provider] };\n }\n return {\n url,\n host,\n provider: 'generic',\n iframeSrc: url,\n posters: [],\n label: PROVIDER_LABEL.generic,\n };\n}\n\n// The provider that SERVES an iframe URL, by its host and path. The sandbox profile follows this and never\n// what a card claims, so a resolver (or a tampered board) cannot name an arbitrary page \"youtube\". Only the\n// embed URLs the parsers above emit are listed: the same host's other paths (`youtube.com/redirect?q=...`)\n// are arbitrary pages.\nconst ALLOWLIST: readonly { host: string; path: RegExp; provider: EmbedProvider }[] = [\n { host: 'www.youtube-nocookie.com', path: /^\\/embed\\//, provider: 'youtube' },\n { host: 'player.vimeo.com', path: /^\\/video\\//, provider: 'vimeo' },\n { host: 'open.spotify.com', path: /^\\/embed\\//, provider: 'spotify' },\n { host: 'codepen.io', path: /^\\/(?:team\\/)?[^/]+\\/embed\\//, provider: 'codepen' },\n { host: 'www.figma.com', path: /^\\/embed$/, provider: 'figma' },\n];\n\n/** The provider an iframe URL belongs to. */\nexport function providerOfIframeSrc(src: string): EmbedProvider {\n try {\n const u = new URL(src);\n if (u.protocol !== 'https:') return 'generic';\n return ALLOWLIST.find((r) => r.host === u.hostname && r.path.test(u.pathname))?.provider ?? 'generic';\n } catch {\n return 'generic';\n }\n}\n\n/**\n * The iframe URL of a video provider, set to start playing on its own and muted (browsers only let a muted\n * page autoplay), inline on iOS and looping. YouTube needs `playlist=<id>` to loop a single video; a\n * `list` the URL already carries is kept instead. Vimeo keeps its unlisted-video `h` hash. Any other\n * provider (or a URL that does not parse) comes back as is. Pure; the stored embed info is never touched.\n */\nexport function withAutoplay(provider: EmbedProvider, src: string): string {\n if (provider !== 'youtube' && provider !== 'vimeo') return src;\n let u: URL;\n try {\n u = new URL(src);\n } catch {\n return src;\n }\n const q = u.searchParams;\n if (provider === 'vimeo') {\n q.set('autoplay', '1');\n q.set('muted', '1');\n q.set('loop', '1');\n } else {\n const word = u.pathname.split('/')[2] ?? '';\n q.set('autoplay', '1');\n q.set('mute', '1');\n q.set('playsinline', '1');\n // A live stream has nothing to loop.\n if (word !== 'live_stream') q.set('loop', '1');\n if (word !== 'videoseries' && word !== 'live_stream' && !q.has('list')) q.set('playlist', word);\n }\n return u.toString();\n}\n\n/**\n * A YouTube iframe URL with its postMessage API on (`enablejsapi=1`, plus `origin` when the page's is an\n * http(s) one: the player ignores commands from a page it cannot match). The layer pauses and resumes the\n * player with it. Vimeo's player takes its commands without a flag; any other provider (or a URL that does\n * not parse) comes back as is. Pure; the stored embed info is never touched.\n */\nexport function withJsApi(provider: EmbedProvider, src: string, origin?: string): string {\n if (provider !== 'youtube') return src;\n let u: URL;\n try {\n u = new URL(src);\n } catch {\n return src;\n }\n u.searchParams.set('enablejsapi', '1');\n if (origin !== undefined && /^https?:\\/\\//.test(origin)) u.searchParams.set('origin', origin);\n return u.toString();\n}\n\n/** Whether a provider is one the library knows (its pages get the sandbox of a provider). */\nexport const isAllowlisted = (p: EmbedProvider): boolean => p !== 'generic';\n","// Errors the board throws and reports.\nimport type { CardId } from './types';\n\n/** Why a {@link CorkboardError} was thrown. */\nexport type CorkboardErrorCode =\n /** A method was called after `dispose()`. */\n | 'disposed'\n /** The browser cannot run the board (no WebGL2, or Pixi picked another renderer). */\n | 'unsupported'\n /**\n * A call or an option got a value it cannot use: `add` / `update` / `loadSnapshot` / `applyChange` a card value\n * (NaN, a size <= 0, a duplicate id...), or any method an id list of the wrong type, a NaN or out-of-range\n * number, an unknown enum value or a bad option. Nothing was changed.\n */\n | 'invalid';\n\n/** The one error class the board throws: `instanceof CorkboardError`, then branch on `code`. */\nexport class CorkboardError extends Error {\n /** Why it was thrown; branch on this. */\n readonly code: CorkboardErrorCode;\n\n constructor(code: CorkboardErrorCode, message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'CorkboardError';\n this.code = code;\n }\n}\n\n/**\n * A failure at runtime that did not throw: a picture that did not decode, a worker that died, a video or an\n * embed that failed. Reported through the board's `error` event; the card falls back to its placeholder.\n */\nexport interface BoardErrorEvent {\n /** What failed. */\n kind: 'texture' | 'worker' | 'video' | 'embed' | 'context';\n /** The card it concerns, if any. */\n id?: CardId;\n /** The URL that failed, if any. */\n url?: string;\n /** The underlying error (an Error, a DOM event, or a message). */\n cause: unknown;\n}\n","// Canvas colours. Pass a `Theme` to `Corkboard.create` / `board.setTheme`; `DARK_THEME` and `LIGHT_THEME`\n// are ready-made.\n\n/** Canvas colours, as 0xRRGGBB numbers. Pass one to `Corkboard.create` / `board.setTheme`; `DARK_THEME` and `LIGHT_THEME` are ready-made. */\nexport interface Theme {\n /** A dark canvas: picks the default guide colour and the contrast of the UI drawn on the canvas. */\n dark: boolean;\n /** Canvas background (also the WebGL clear colour). */\n canvas: number;\n /** Background dots and their opacity (kept low: the grid is a quiet guide, not a pattern). */\n dot: number;\n /** Opacity of the background dots. */\n dotAlpha?: number;\n /** Hairline around a card: baked into the textures, so a theme change rebuilds them. */\n border: number;\n /** Opacity of the hairline. */\n borderAlpha: number;\n /** Selection outline, handles and marquee. */\n accent: number;\n /** Placeholder of a card whose picture has not landed yet and that has no ThumbHash or `color`. */\n well: number;\n /**\n * Smart guides (alignment lines, spacing and size measures) and the label on their pills. Their own\n * warm hue, apart from the accent of the selection, tuned for contrast on each canvas; the mode's\n * default when absent.\n */\n guide?: number;\n /** Colour of the text on the guide pills. */\n onGuide?: number;\n}\n\n// Rose on the dark canvas (#0f0f0f, contrast 5.1:1), a deeper magenta on the light one (#f4f4f2,\n// 4.5:1): a hairline in either reads at a glance, and the white semibold pill labels stay legible.\nexport const GUIDE_DARK = 0xf23a6a;\nexport const GUIDE_LIGHT = 0xd61f5f;\n\nexport function guideColor(theme: Theme): number {\n return theme.guide ?? (theme.dark ? GUIDE_DARK : GUIDE_LIGHT);\n}\n\n/** The ready-made dark theme. */\nexport const DARK_THEME: Theme = {\n dark: true,\n canvas: 0x0f0f0f,\n dot: 0xffffff,\n dotAlpha: 0.0805,\n border: 0xffffff,\n borderAlpha: 0.1,\n accent: 0x6aa6ff,\n well: 0x1c1c1c,\n guide: GUIDE_DARK,\n onGuide: 0xffffff,\n};\n\n/** The ready-made light theme. */\nexport const LIGHT_THEME: Theme = {\n dark: false,\n canvas: 0xf4f4f2,\n dot: 0x000000,\n dotAlpha: 0.1035,\n border: 0x000000,\n borderAlpha: 0.1,\n accent: 0x2f6bff,\n well: 0xe8e8e4,\n guide: GUIDE_LIGHT,\n onGuide: 0xffffff,\n};\n\nexport function parseHex(s: string): number | null {\n const m = /^#([0-9a-f]{6})$/i.exec(s);\n return m ? parseInt(m[1], 16) : null;\n}\n\nexport const cssHex = (n: number): string => `#${n.toString(16).padStart(6, '0')}`;\n","// Public data model of a corkboard. Pure types and constants: no Pixi, no DOM.\n//\n// Coordinates are world px at zoom 1. `rot` is DEGREES clockwise about the element's centre.\n// (Adding an element kind is one view in src/render/views/registry.ts plus, when it needs DOM, one overlay\n// (src/overlay.ts) or a layer like the video and embed ones (src/video, src/embed).)\n\n/** What a card shows: a picture, a video (a DOM `<video>` over its poster) or a live web page / HTML snippet. */\nexport type CardKind = 'image' | 'video' | 'embed';\n\n/** The id of a card: a string, unique on the board. */\nexport type CardId = string;\n\n/**\n * The virtual screen a live iframe is laid out at, then scaled onto the card.\n * - `'720p'`: the page is laid out with its short side at 720 CSS px (a 16:9 card is a 1280 x 720 page).\n * - `'1080p'`: the same at 1080 (1920 x 1080).\n * - a number: that short side, in CSS px.\n * - `'native'`: the card's world size (a 400 px card is a 400 px wide page: mobile layouts, big text).\n */\nexport type EmbedResolution = '720p' | '1080p' | 'native' | number;\n\n/**\n * What an `embed` card shows live: a page (`url`) or a snippet of HTML (`html`), in a sandboxed iframe. Exactly\n * one of the two. The sandbox profile is derived from this and the provider at render time and is never stored.\n */\nexport type EmbedSource = (\n | { url: string; html?: undefined }\n | { html: string; url?: undefined }\n) & {\n /** Shown on the generated tile and in the iframe's `title`. */\n title?: string;\n /** Overrides the board's `embeds.resolution` for this card. */\n resolution?: EmbedResolution;\n};\n\n/** Where a card's pixels come from. */\nexport interface CardMediaInput {\n /**\n * The picture: an image URL, or the poster of a video or an embed. Must be fetchable with CORS (the\n * decode worker reads it with `fetch`, then uploads it to WebGL). Required for `image` and `video`\n * cards. An `embed` card may leave it out: the embed layer fills it with a poster it resolves (a\n * provider thumbnail, the `resolve` option's, or a generated tile).\n */\n src?: string;\n /** The video file, for a `video` card. Played in a DOM `<video>` laid over the card. */\n video?: string;\n /** The content of an `embed` card. Makes the card an `embed` unless `kind` says otherwise. */\n embed?: EmbedSource;\n /**\n * Optional smaller / larger renditions of `src`. The texture pipeline picks the level that matches\n * the card's size on screen: `small` fills an atlas cell (~160 px long side), `medium` is the sharp\n * texture of a card at normal zoom (~480 px), `large` is for close zoom (~1600 px). A missing\n * rendition falls back to `src`, which the decode worker then downsamples itself.\n */\n sizes?: { small?: string; medium?: string; large?: string };\n /**\n * `aspect`: height / width of the picture (the inverse of CSS `aspect-ratio`). Optional: with no `h` on the\n * element it sizes the card; a card whose size is known never needs it.\n */\n aspect?: number;\n /**\n * ThumbHash (https://evanw.github.io/thumbhash/) of the picture, <= 25 bytes, as bytes or base64.\n * The blurred first paint of a card; without it the card shows a flat `color` until its picture lands.\n * The board stores it as base64 (see {@link CardMedia}), so a card and its `change` payloads are JSON-safe.\n */\n thumbhash?: Uint8Array | string;\n /** Flat placeholder colour, \"#rrggbb\". */\n color?: string;\n}\n\n/**\n * The `media` of a stored card: a {@link CardMediaInput} as the board keeps it. A copy of what was passed to\n * `add` / `update` (later changes to the caller's object do not reach the card), with the thumbhash always a\n * base64 string, so a card, a `change` payload and a snapshot are plain JSON.\n */\nexport interface CardMedia extends Omit<CardMediaInput, 'thumbhash'> {\n /** ThumbHash as base64 (a `Uint8Array` given to `add` / `update` is converted). */\n thumbhash?: string;\n}\n\n/** A card as the board holds it. Coordinates are world px at zoom 1. */\nexport interface Card {\n /** Unique on the board. */\n id: CardId;\n /** What the card shows. */\n kind: CardKind;\n /** Left edge, world px (before rotation). */\n x: number;\n /** Top edge, world px (before rotation). */\n y: number;\n /** Width, world px. */\n w: number;\n /** Height, world px. */\n h: number;\n /** Rotation, degrees clockwise about the card's centre. Data only: there is no rotate gesture. */\n rot: number;\n /** A locked card cannot be moved, resized or deleted from the canvas and stays put in auto layout. */\n locked: boolean;\n /** Where the pixels come from. */\n media: CardMedia;\n /** Corner radius, world px. */\n radius: number;\n /** Keep w:h when resized (default true for image and video). */\n aspectLocked: boolean;\n /** Free for the host: carried through unchanged (and into `getSnapshot()`, by reference). */\n data?: unknown;\n}\n\n/** A field of a card that can change (everything but the `id`). */\nexport type CardProp = Exclude<keyof Card, 'id'>;\n\n/**\n * One card in a `change` event's `updated`: the card as it is after the change, as it was before it, and which\n * fields differ. Inside a `batch` the changes to a card fold into one entry from the first `prev` to the last\n * `el`, so a card that ends up as it started is not reported at all.\n */\nexport interface CardUpdate {\n /** The card now. */\n el: Card;\n /** The card as it was before the change (or the batch). */\n prev: Card;\n /**\n * The fields that differ between `prev` and `el`, compared per top-level field with `Object.is`: a `media`\n * that was replaced counts as changed even if its contents are equal (and `data` is compared by reference).\n * Never empty. A field that was cleared (`data` set to `undefined`) is listed too: read `el[prop]`.\n */\n props: readonly CardProp[];\n}\n\n/**\n * What `add` takes. Everything but `media` is optional: a card with no position is placed next to what is on\n * screen (an `x` or `y` it has is kept); a missing size is derived from `w` and the media's aspect (an embed's\n * default width is `DEFAULTS.embedWidth`).\n */\nexport interface CardInit {\n /** Default: a generated unique id. Must not be on the board already. */\n id?: CardId;\n /** Default: `'embed'` when `media.embed` is set, else `'video'` when `media.video` is, else `'image'`. */\n kind?: CardKind;\n /** Left edge, world px. Default: placed. */\n x?: number;\n /** Top edge, world px. Default: placed. */\n y?: number;\n /** Width, world px. Default: `DEFAULTS.cardWidth` (`DEFAULTS.embedWidth` for an embed). */\n w?: number;\n /** Height, world px. Default: `w` times the media's aspect. */\n h?: number;\n /**\n * Rotation, degrees clockwise.\n * @default 0\n */\n rot?: number;\n /**\n * @default false\n */\n locked?: boolean;\n /** Where the pixels come from. */\n media: CardMediaInput;\n /**\n * Corner radius, world px.\n * @default DEFAULTS.cardRadius\n */\n radius?: number;\n /**\n * Keep w:h when resized.\n * @default true\n */\n aspectLocked?: boolean;\n /** Free for the host: carried through unchanged. */\n data?: unknown;\n}\n\n/**\n * What `update` takes: any field of a card but `id`. `kind` changes with `media` unless given. A field left out\n * or set to `undefined` is left as it is - except `data`: an own `data` key set to `undefined` clears it.\n */\nexport type CardPatch = Partial<Omit<Card, 'id' | 'kind' | 'media'>> & {\n kind?: CardKind;\n media?: CardMediaInput;\n};\n\n/**\n * Who made a change: a pointer or keyboard gesture (`'user'`), a call on the board or on `board.layout`\n * (`'api'`), `loadSnapshot()` (`'load'`), `applyChange()` (`'apply'`, or `'undo'` when inverted), or the library\n * itself (`'system'`: an embed card resized to its content, say). A host may pass its own tag to\n * `batch(fn, { source })`, e.g. `'remote'` for edits it replays from a peer.\n *\n * `'system'`, `'undo'` and `'apply'` writes are not new user edits: skip them when recording history and do not\n * broadcast them.\n */\nexport type ChangeSource = 'user' | 'api' | 'load' | 'system' | 'apply' | 'undo' | (string & {});\n\n/**\n * One card whose place in the draw order is part of a {@link Change}. `prevBelow` / `nextBelow` are the card\n * directly BELOW it (drawn just before it) before and after the change; `null` means the bottom of the order\n * (or, in `prevBelow`, that the card did not exist before).\n */\nexport interface OrderMove {\n /** The card. */\n id: CardId;\n /** The card directly below it before the change (`null`: it was at the bottom, or did not exist). */\n prevBelow: CardId | null;\n /** The card directly below it after the change (`null`: it is at the bottom, or it was removed). */\n nextBelow: CardId | null;\n}\n\n/**\n * The draw-order part of a {@link Change}, as anchors instead of whole id lists (so it is O(moved) to store and\n * to replay, and it survives a peer whose order differs elsewhere).\n *\n * `moved` is a minimal set of cards that, taken out and put back, turns the old order into the new one: each is\n * placed directly above its `nextBelow`, bottom first (an undo does the same with `prevBelow`). It holds the\n * cards outside the longest run of cards that kept their relative order; for `bringToFront` / `sendToBack` it is\n * just the ids given. A removed card is in it with its `prevBelow` (and `nextBelow: null`), so undoing a delete\n * restores its depth. A card that was only appended on top (the usual `add`) is not in it: replaying the change\n * on a board where the card is not there yet puts it on top.\n */\nexport interface OrderChange {\n /** The cards to place, bottom of the new order first. */\n moved: readonly OrderMove[];\n}\n\n/**\n * What one `change` event carries: the net difference between the board before and after a call, a gesture\n * commit, a `batch` or a `loadSnapshot`. Plain data: `JSON.stringify` of it (with `media.thumbhash` stored as\n * base64 and a JSON-safe `data`) is what a sync or an undo stack can keep and replay with\n * `board.applyChange` / {@link invertChange}. The elements are the board's own objects: do not mutate them.\n */\nexport interface Change {\n /** Who made it. */\n source: ChangeSource;\n /** Cards that are new. */\n added: readonly Card[];\n /** Cards that are gone, as they were. */\n removed: readonly Card[];\n /** Cards that changed. */\n updated: readonly CardUpdate[];\n /** Present when the draw order changed other than by cards appended on top. */\n order?: OrderChange;\n}\n\n/** The sizes cards take when `add` is given none, and the limits of a resize. World px; aspects are height / width. */\nexport const DEFAULTS = {\n /** Width of an image or video card. */\n cardWidth: 248,\n /** Height / width of an image card whose picture has no known aspect. */\n cardAspect: 1.25,\n /** Height / width of a video card with no known aspect. */\n videoAspect: 9 / 16,\n /** Height / width of an embed card whose provider has no shape of its own. */\n embedAspect: 9 / 16,\n /** Width of an embed card. */\n embedWidth: 400,\n /** Corner radius. */\n cardRadius: 8,\n /** Narrowest a resize gesture makes a card. */\n minCardW: 40,\n /** Widest a resize gesture makes a card. */\n maxCardW: 1600,\n} as const;\n\n/** Lowest default zoom of the camera (`camera.minScale` overrides it). */\nexport const MIN_SCALE = 0.05;\n/** Highest default zoom of the camera (`camera.maxScale` overrides it). */\nexport const MAX_SCALE = 4;\n"],"names":["PROVIDER_LABEL","LOCAL_HOSTS","normalizeEmbedUrl","raw","u","stripWww","h","parseTimestamp","t","m","YT_ID","YT_PATH_WORDS","YT_LIST","YT_HOSTS","ytParam","name","v","ytEmbed","path","params","q","parseYouTube","host","parts","series","value","id","start","list","VIMEO_LISTS","parseVimeo","isId","p","i","next","hash","SPOTIFY_TYPES","parseSpotify","type","compact","parseCodePen","team","user","kind","parseFigma","PARSERS","parseEmbedUrl","url","parse","hit","ALLOWLIST","providerOfIframeSrc","src","r","withAutoplay","provider","word","withJsApi","origin","isAllowlisted","CorkboardError","code","message","options","GUIDE_DARK","GUIDE_LIGHT","guideColor","theme","DARK_THEME","LIGHT_THEME","parseHex","s","cssHex","n","DEFAULTS","MIN_SCALE","MAX_SCALE"],"mappings":"AA6BO,MAAMA,IAAgD;AAAA,EAC3D,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACX,GAEMC,IAAc,oBAAI,IAAI,CAAC,aAAa,aAAa,OAAO,CAAC;AASxD,SAASC,EAAkBC,GAA4B;AAC5D,MAAIC;AACJ,MAAI;AACF,I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