visualci-gallery 0.0.0-stage → 0.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/dist/model.js ADDED
@@ -0,0 +1,234 @@
1
+ // The manifest, grouped and paired: the step every renderer shares (contract/SPEC.md, "The model"). Pure: no DOM, no
2
+ // network, so it runs in the browser, at build time and in tests alike.
3
+ export const DEFAULT_TITLE = "Screenshots";
4
+ const SIZES = ["desktop", "phone"];
5
+ const THEMES = ["light", "dark"];
6
+ // Whole-string matches, ASCII digits only and "any character" including line breaks, so every language's regex
7
+ // engine agrees (contract/SPEC.md, "A shot's name").
8
+ const EXTENSION = /\.(?:[pP][nN][gG]|[jJ][pP][eE]?[gG]|[wW][eE][bB][pP])$/;
9
+ const WIDTH_THEME = /^([0-9]+)-(light|dark)(-2x)?$/;
10
+ const SCREEN_THEME = /^([\s\S]+?)-(light|dark)(?:-([0-9]+))?(-2x)?$/;
11
+ export const SEE_ALL_TEXT = "See all screenshots";
12
+ /** How a manifest name pairs: `<screen>-<theme>[-<width>][-2x]`, or `<screen>/<width>-<theme>[-2x]`. A name in
13
+ * neither shape is a screen of its own, in both themes. Under 768 wide is a phone; with no width, a portrait image
14
+ * is a phone and a landscape one a desktop, unless `size` says. */
15
+ export function parseShot(name, width, height, size) {
16
+ const parts = name.replace(EXTENSION, "").split("/");
17
+ const last = parts.pop();
18
+ const folder = parts.join("/");
19
+ const sized = (w) => w !== undefined ? (Number(w) < 768 ? "phone" : "desktop") : (size ?? (height > width ? "phone" : "desktop"));
20
+ const css = (w) => (w !== undefined ? Number(w) : null);
21
+ let m = WIDTH_THEME.exec(last);
22
+ if (m && folder) {
23
+ return { key: folder, theme: m[2], size: sized(m[1]), x2: !!m[3], cssWidth: css(m[1]) };
24
+ }
25
+ m = SCREEN_THEME.exec(last);
26
+ if (m) {
27
+ const key = folder ? `${folder}/${m[1]}` : m[1];
28
+ return { key, theme: m[2], size: sized(m[3]), x2: !!m[4], cssWidth: css(m[3]) };
29
+ }
30
+ return { key: folder ? `${folder}/${last}` : last, theme: null, size: sized(undefined), x2: false, cssWidth: null };
31
+ }
32
+ /** `billing/free` → "Billing, free". */
33
+ export function humanize(segments) {
34
+ const text = segments.map((s) => s.replace(/[-_]+/g, " ").replace(/^ +| +$/g, "")).join(", ");
35
+ const first = text.codePointAt(0);
36
+ if (first === undefined)
37
+ return text;
38
+ const head = String.fromCodePoint(first);
39
+ return head.toUpperCase() + text.slice(head.length);
40
+ }
41
+ /** A group's name as an id: ASCII lower case, runs of anything else as one hyphen. */
42
+ export function slugify(name) {
43
+ return name.replace(/[A-Z]/g, (c) => c.toLowerCase()).replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "group";
44
+ }
45
+ function commonFolder(keys) {
46
+ const folders = keys.map((k) => k.split("/").slice(0, -1));
47
+ if (folders.length === 0)
48
+ return [];
49
+ let common = folders[0];
50
+ for (const f of folders.slice(1)) {
51
+ let i = 0;
52
+ while (i < common.length && i < f.length && common[i] === f[i])
53
+ i++;
54
+ common = common.slice(0, i);
55
+ }
56
+ return common;
57
+ }
58
+ function rankBy(order) {
59
+ const list = order ?? [];
60
+ return (key) => {
61
+ const i = list.indexOf(key);
62
+ return i === -1 ? list.length : i;
63
+ };
64
+ }
65
+ /** By code point, as Ruby, Python and Rust compare strings (JavaScript's < compares UTF-16 units). */
66
+ function compare(a, b) {
67
+ const x = Array.from(a, (c) => c.codePointAt(0));
68
+ const y = Array.from(b, (c) => c.codePointAt(0));
69
+ for (let i = 0; i < Math.min(x.length, y.length); i++)
70
+ if (x[i] !== y[i])
71
+ return x[i] - y[i];
72
+ return x.length - y.length;
73
+ }
74
+ /** A URL a page may link to or load: http or https, with no spaces or control characters (which browsers strip,
75
+ * so `java\tscript:` would still run). */
76
+ const ABSOLUTE = /^[hH][tT][tT][pP][sS]?:\/\/[^\x00-\x20\x7f]+$/;
77
+ /** A link that's absolute (as above) or relative: no scheme, no spaces or control characters. */
78
+ function safeHref(value) {
79
+ return ABSOLUTE.test(value) || (value !== "" && !/[\x00-\x20\x7f]/.test(value) && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(value));
80
+ }
81
+ const ID = /^[A-Za-z][A-Za-z0-9_-]*$/;
82
+ function fail(message) {
83
+ throw new Error(message);
84
+ }
85
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
86
+ /** A width or height: a whole number from 1 to MAX_SIZE, so the density maths stays exact in every language. */
87
+ export const MAX_SIZE = 1_000_000;
88
+ const isSize = (v) => typeof v === "number" && Number.isInteger(v) && v > 0 && v <= MAX_SIZE;
89
+ /** An option's value, with null meaning absent. */
90
+ function opt(value, check, what) {
91
+ if (value === null || value === undefined)
92
+ return undefined;
93
+ if (!check(value))
94
+ fail(`gallery option ${what} is invalid`);
95
+ return value;
96
+ }
97
+ const isString = (v) => typeof v === "string";
98
+ const isStrings = (v) => Array.isArray(v) && v.every(isString);
99
+ const isTexts = (keys) => (v) => isObject(v) &&
100
+ Object.values(v).every((entry) => isObject(entry) && Object.entries(entry).every(([k, x]) => keys.includes(k) && (x === null || isString(x))));
101
+ /** The manifest's shape (contract/SPEC.md, "Validation"): anything else is refused. */
102
+ function checkManifest(manifest) {
103
+ if (!isObject(manifest) || !Array.isArray(manifest.groups))
104
+ fail("not a gallery manifest: it has no groups");
105
+ manifest.groups.forEach((g, i) => {
106
+ if (!isObject(g) || typeof g.name !== "string" || g.name === "")
107
+ fail(`gallery manifest group ${i} has no name`);
108
+ if (g.title !== undefined && g.title !== null && typeof g.title !== "string")
109
+ fail(`gallery manifest group ${g.name}: its title isn't a string`);
110
+ if (!Array.isArray(g.items))
111
+ fail(`gallery manifest group ${g.name} has no items`);
112
+ g.items.forEach((item, j) => {
113
+ const where = `gallery manifest group ${g.name}, item ${j}`;
114
+ if (!isObject(item) || typeof item.name !== "string" || item.name === "")
115
+ fail(`${where} has no name`);
116
+ if (typeof item.url !== "string" || !ABSOLUTE.test(item.url))
117
+ fail(`${where} (${item.name}): its url isn't an http(s) URL`);
118
+ if (!isSize(item.width) || !isSize(item.height))
119
+ fail(`${where} (${item.name}): its width and height aren't whole numbers from 1 to 1000000`);
120
+ });
121
+ });
122
+ }
123
+ /** The manifest as the gallery shows it (contract/SPEC.md). Throws when it or the options are invalid, or nothing in
124
+ * it can be shown. */
125
+ export function buildModel(manifest, options = {}) {
126
+ checkManifest(manifest);
127
+ if (!isObject(options))
128
+ fail("gallery options must be an object");
129
+ const o = options;
130
+ const level = opt(o.headingLevel, (v) => Number.isInteger(v), "headingLevel") ?? 2;
131
+ const headingLevel = Math.min(Math.max(level, 1), 4);
132
+ const title = o.title === undefined ? DEFAULT_TITLE : opt(o.title, isString, "title") ?? null;
133
+ const id = opt(o.id, (v) => isString(v) && ID.test(v), "id") ?? "vg";
134
+ const screensOpt = opt(o.screens, isTexts(["title", "caption"]), "screens") ?? {};
135
+ const groupsOpt = opt(o.groups, (v) => isObject(v) &&
136
+ Object.values(v).every((entry) => isObject(entry) &&
137
+ Object.entries(entry).every(([k, x]) => (k === "title" && (x === null || isString(x))) ||
138
+ (k === "size" && (x === null || SIZES.includes(x))) ||
139
+ (k === "fit" && (x === null || x === "cover" || x === "contain")))), "groups") ?? {};
140
+ const order = opt(o.order, isStrings, "order");
141
+ const groupOrder = opt(o.groupOrder, isStrings, "groupOrder");
142
+ const credit = opt(o.credit, (v) => typeof v === "boolean", "credit") ?? true;
143
+ const themeSwitchOpt = opt(o.themeSwitch, (v) => typeof v === "boolean", "themeSwitch") ?? true;
144
+ const layout = opt(o.layout, (v) => v === "grid" || v === "strip", "layout") ?? "grid";
145
+ const seeAllOpt = opt(o.seeAll, (v) => isObject(v) && isString(v.href) && safeHref(v.href) && (v.text === undefined || v.text === null || isString(v.text)), "seeAll");
146
+ const slugs = new Set();
147
+ const groups = [];
148
+ for (const g of manifest.groups) {
149
+ const groupSet = Object.prototype.hasOwnProperty.call(groupsOpt, g.name) ? groupsOpt[g.name] : undefined;
150
+ const screens = new Map();
151
+ for (const item of g.items) {
152
+ const shot = parseShot(item.name, item.width, item.height, groupSet?.size ?? undefined);
153
+ const variants = screens.get(shot.key) ?? new Map();
154
+ screens.set(shot.key, variants);
155
+ for (const theme of shot.theme ? [shot.theme] : THEMES) {
156
+ const vid = `${shot.size}-${theme}`;
157
+ const v = variants.get(vid) ?? { size: shot.size, theme, url: "", url2x: null, width: 0, height: 0 };
158
+ if (shot.x2) {
159
+ if (v.url2x === null)
160
+ v.url2x = item.url;
161
+ }
162
+ else if (v.url === "") {
163
+ // An image wider than the width its name gives was taken at a higher density: shown at the name's width,
164
+ // its height rounded half up in integers (the same in every language).
165
+ const scaled = shot.cssWidth !== null && item.width > shot.cssWidth;
166
+ const width = scaled ? shot.cssWidth : item.width;
167
+ const height = scaled ? Math.floor((2 * item.height * shot.cssWidth + item.width) / (2 * item.width)) : item.height;
168
+ Object.assign(v, { url: item.url, width, height });
169
+ }
170
+ variants.set(vid, v);
171
+ }
172
+ }
173
+ // The screens that have something to show; titles are made from these keys only.
174
+ const kept = [...screens]
175
+ .map(([key, variants]) => ({
176
+ key,
177
+ variants: [...variants.values()]
178
+ .filter((v) => v.url !== "")
179
+ .sort((a, b) => SIZES.indexOf(a.size) - SIZES.indexOf(b.size) || THEMES.indexOf(a.theme) - THEMES.indexOf(b.theme)),
180
+ }))
181
+ .filter((sc) => sc.variants.length > 0);
182
+ // A screen shows both themes at each of its sizes: one theme's image never stands in for the other's.
183
+ for (const sc of kept) {
184
+ for (const v of sc.variants) {
185
+ if (!sc.variants.some((o) => o.size === v.size && o.theme !== v.theme)) {
186
+ fail(`gallery screen ${sc.key} in group ${g.name} has a ${v.theme} ${v.size} screenshot but no ${v.theme === "light" ? "dark" : "light"} one`);
187
+ }
188
+ }
189
+ }
190
+ if (kept.length === 0)
191
+ continue;
192
+ const prefix = commonFolder(kept.map((sc) => sc.key)).length;
193
+ const rank = rankBy(order);
194
+ const list = kept
195
+ .map(({ key, variants }) => {
196
+ const set = Object.prototype.hasOwnProperty.call(screensOpt, key) ? screensOpt[key] : undefined;
197
+ return {
198
+ key,
199
+ title: set?.title ?? humanize(key.split("/").slice(prefix)),
200
+ caption: set?.caption ?? null,
201
+ variants,
202
+ };
203
+ })
204
+ .sort((a, b) => rank(a.key) - rank(b.key) || compare(a.key, b.key));
205
+ let slug = slugify(g.name);
206
+ for (let n = 2; slugs.has(slug); n++)
207
+ slug = `${slugify(g.name)}-${n}`;
208
+ slugs.add(slug);
209
+ groups.push({
210
+ name: g.name,
211
+ title: groupSet?.title ?? g.title ?? g.name,
212
+ slug,
213
+ fit: groupSet?.fit ?? "cover",
214
+ sizes: SIZES.filter((sz) => list.some((sc) => sc.variants.some((v) => v.size === sz))),
215
+ screens: list,
216
+ });
217
+ }
218
+ if (groups.length === 0)
219
+ fail("the gallery manifest has no screenshots to show");
220
+ // Named groups first; the rest keep the manifest's order (the sort is stable).
221
+ const groupRank = rankBy(groupOrder);
222
+ groups.sort((a, b) => groupRank(a.name) - groupRank(b.name));
223
+ return {
224
+ layout,
225
+ themeSwitch: layout === "grid" && themeSwitchOpt,
226
+ seeAll: seeAllOpt ? { href: seeAllOpt.href, text: seeAllOpt.text ?? SEE_ALL_TEXT } : null,
227
+ title,
228
+ label: title ?? DEFAULT_TITLE,
229
+ headingLevel,
230
+ id,
231
+ credit,
232
+ groups,
233
+ };
234
+ }
@@ -0,0 +1,4 @@
1
+ export { buildModel, parseShot, humanize, slugify, DEFAULT_TITLE } from "./model.js";
2
+ export type { Manifest, ManifestGroup, ManifestItem, Model, Group, Screen, Variant, Options, Size, Theme } from "./model.js";
3
+ export { render, escapeHtml } from "./render.js";
4
+ export { load, type LoadOptions } from "./load.js";
@@ -0,0 +1,4 @@
1
+ // The server-safe half of the library: the model and the markup, with no DOM code, for rendering at build time.
2
+ export { buildModel, parseShot, humanize, slugify, DEFAULT_TITLE } from "./model.js";
3
+ export { render, escapeHtml } from "./render.js";
4
+ export { load } from "./load.js";
@@ -0,0 +1,5 @@
1
+ import type { Model } from "./model.js";
2
+ /** & < > " ' as entities: the only escaping the contract allows, so every language's output is the same. */
3
+ export declare function escapeHtml(s: string): string;
4
+ /** The gallery's markup: one line per block, no indentation, "\n" after each line. */
5
+ export declare function render(model: Model): string;
package/dist/render.js ADDED
@@ -0,0 +1,142 @@
1
+ // The gallery's HTML from its model: the markup every renderer emits byte for byte (contract/SPEC.md, "The markup"),
2
+ // and that hydrate() brings to life. Pure string building, so it runs at build time with no DOM.
3
+ /** & < > " ' as entities: the only escaping the contract allows, so every language's output is the same. */
4
+ export function escapeHtml(s) {
5
+ return s
6
+ .replace(/&/g, "&amp;")
7
+ .replace(/</g, "&lt;")
8
+ .replace(/>/g, "&gt;")
9
+ .replace(/"/g, "&quot;")
10
+ .replace(/'/g, "&#39;");
11
+ }
12
+ const SIZE_LABEL = { desktop: "Desktop", phone: "Phone" };
13
+ function themeSwitch() {
14
+ return ('<div class="vg-seg" role="group" aria-label="Theme">' +
15
+ '<button type="button" data-vg-set-theme="light" aria-pressed="false">Light</button>' +
16
+ '<button type="button" data-vg-set-theme="dark" aria-pressed="false">Dark</button>' +
17
+ "</div>");
18
+ }
19
+ function sizeSwitch(sizes, extra = "") {
20
+ return (`<div class="vg-seg${extra}" role="group" aria-label="Screen size">` +
21
+ sizes.map((s) => `<button type="button" data-vg-set-size="${s}" aria-pressed="false">${SIZE_LABEL[s]}</button>`).join("") +
22
+ "</div>");
23
+ }
24
+ /** An image, shown for `themes`, which its alt text names. */
25
+ function image(title, v, themes) {
26
+ const alt = `${title}, ${SIZE_LABEL[v.size].toLowerCase()}, ${themes.join(" and ")}`;
27
+ return (`<img class="vg-img" data-vg-size="${v.size}" data-vg-theme="${themes.join(" ")}" src="${escapeHtml(v.url)}"` +
28
+ (v.url2x ? ` data-src-2x="${escapeHtml(v.url2x)}"` : "") +
29
+ ` width="${v.width}" height="${v.height}" alt="${escapeHtml(alt)}" loading="lazy" decoding="async">`);
30
+ }
31
+ /** One card: a link to its first image (which hydrate() turns into the full-size view), every variant at the given
32
+ * sizes, its title and caption. */
33
+ function card(sc, sizes, heading, caption, fit) {
34
+ const imgs = [];
35
+ const shown = [];
36
+ let first = null;
37
+ for (const size of sizes) {
38
+ const at = sc.variants.filter((v) => v.size === size);
39
+ if (at.length === 0)
40
+ continue;
41
+ shown.push(size);
42
+ first ??= at[0];
43
+ // Every size has both themes (the model refuses a screen without); the same image for both is shown once.
44
+ if (at[0].url === at[1].url && at[0].url2x === at[1].url2x) {
45
+ imgs.push(image(sc.title, at[0], ["light", "dark"]));
46
+ }
47
+ else
48
+ for (const v of at)
49
+ imgs.push(image(sc.title, v, [v.theme]));
50
+ }
51
+ return (`<li class="vg-card" data-vg-screen="${escapeHtml(sc.key)}" data-vg-sizes="${shown.join(" ")}"` +
52
+ (fit === "contain" ? ' data-vg-fit="contain"' : "") +
53
+ ">" +
54
+ `<a class="vg-thumb" href="${escapeHtml(first.url)}" data-vg-open aria-label="${escapeHtml(sc.title)}: view full size">` +
55
+ imgs.join("") +
56
+ "</a>" +
57
+ `<${heading} class="vg-card-title">${escapeHtml(sc.title)}</${heading}>` +
58
+ (caption && sc.caption !== null ? `<p class="vg-caption">${escapeHtml(sc.caption)}</p>` : "") +
59
+ "</li>");
60
+ }
61
+ /** The gallery's markup: one line per block, no indentation, "\n" after each line. */
62
+ export function render(model) {
63
+ const id = escapeHtml(model.id);
64
+ const h = (offset) => `h${Math.min(model.headingLevel + offset, 6)}`;
65
+ const below = model.title === null ? 0 : 1;
66
+ const out = [];
67
+ // The size shown before the script runs: the first panel's (only it shows without the script).
68
+ const size = model.layout === "strip" ? stripSize(model) : model.groups[0].sizes[0];
69
+ out.push(`<section class="vg" data-vg data-vg-layout="${model.layout}" aria-label="${escapeHtml(model.label)}" data-vg-size="${size}"` +
70
+ (model.themeSwitch ? "" : ' data-vg-theme-source="page"') +
71
+ ">");
72
+ if (model.title !== null)
73
+ out.push(`<${h(0)} class="vg-title">${escapeHtml(model.title)}</${h(0)}>`);
74
+ if (model.layout === "strip")
75
+ strip(model, id, h(below), out);
76
+ else
77
+ grid(model, id, h(below), h(below + 1), out);
78
+ if (model.seeAll) {
79
+ out.push(`<p class="vg-see-all"><a href="${escapeHtml(model.seeAll.href)}">${escapeHtml(model.seeAll.text)}</a></p>`);
80
+ }
81
+ if (model.credit) {
82
+ out.push('<p class="vg-credit">Screenshots by <a href="https://visualci.com">VisualCI</a></p>');
83
+ }
84
+ out.push(`<dialog class="vg-box" aria-labelledby="${id}-box-title">`);
85
+ out.push(`<div class="vg-box-bar"><${h(below)} class="vg-box-title" id="${id}-box-title"></${h(below)}>` +
86
+ '<div class="vg-controls">' +
87
+ (model.themeSwitch ? themeSwitch() : "") +
88
+ (model.layout === "grid" ? sizeSwitch(["desktop", "phone"], " vg-box-sizes") : "") +
89
+ '<button type="button" class="vg-icon" data-vg-step="-1" aria-label="Previous screen">‹</button>' +
90
+ '<button type="button" class="vg-icon" data-vg-step="1" aria-label="Next screen">›</button>' +
91
+ "</div>" +
92
+ '<button type="button" class="vg-icon" data-vg-close aria-label="Close">×</button>' +
93
+ "</div>");
94
+ out.push('<div class="vg-box-view"></div>');
95
+ out.push("</dialog>");
96
+ out.push("</section>");
97
+ return out.join("\n") + "\n";
98
+ }
99
+ function grid(model, id, gh, ch, out) {
100
+ const tabs = model.groups.length > 1;
101
+ if (tabs) {
102
+ out.push(`<div class="vg-tabs" role="tablist" aria-label="${escapeHtml(model.label)}">`);
103
+ model.groups.forEach((g, i) => {
104
+ out.push(`<button type="button" role="tab" id="${id}-tab-${g.slug}" aria-controls="${id}-panel-${g.slug}"` +
105
+ ` aria-selected="${i === 0}" tabindex="${i === 0 ? 0 : -1}">${escapeHtml(g.name)}</button>`);
106
+ });
107
+ out.push("</div>");
108
+ }
109
+ model.groups.forEach((g, i) => {
110
+ out.push(`<div class="vg-panel" id="${id}-panel-${g.slug}" data-vg-sizes="${g.sizes.join(" ")}"` +
111
+ (tabs ? ` role="tabpanel" aria-labelledby="${id}-tab-${g.slug}"` : "") +
112
+ (i > 0 ? " hidden" : "") +
113
+ ">");
114
+ const controls = (model.themeSwitch ? themeSwitch() : "") + (g.sizes.length > 1 ? sizeSwitch(g.sizes) : "");
115
+ out.push(`<div class="vg-bar"><${gh} class="vg-group-title">${escapeHtml(g.title)}</${gh}>` +
116
+ (controls ? `<div class="vg-controls">${controls}</div>` : "") +
117
+ "</div>");
118
+ out.push('<ul class="vg-grid">');
119
+ for (const sc of g.screens)
120
+ out.push(card(sc, g.sizes, ch, true, g.fit));
121
+ out.push("</ul>");
122
+ out.push("</div>");
123
+ });
124
+ }
125
+ /** Every screen of every group at one size (desktop when any group has it) in one row. */
126
+ function stripSize(model) {
127
+ return model.groups.some((g) => g.sizes.includes("desktop")) ? "desktop" : "phone";
128
+ }
129
+ function strip(model, id, ch, out) {
130
+ const size = stripSize(model);
131
+ out.push(`<div class="vg-panel" id="${id}-strip" data-vg-sizes="${size}">`);
132
+ out.push('<div class="vg-strip"><button type="button" class="vg-icon vg-strip-prev" data-vg-scroll="-1" aria-label="Scroll back">‹</button>');
133
+ out.push('<ul class="vg-grid vg-track">');
134
+ for (const g of model.groups) {
135
+ for (const sc of g.screens)
136
+ if (sc.variants.some((v) => v.size === size))
137
+ out.push(card(sc, [size], ch, false, g.fit));
138
+ }
139
+ out.push("</ul>");
140
+ out.push('<button type="button" class="vg-icon vg-strip-next" data-vg-scroll="1" aria-label="Scroll forward">›</button></div>');
141
+ out.push("</div>");
142
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "visualci-gallery",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "A screenshots page from VisualCI's public gallery: render it into an empty element, or hydrate markup a server rendered.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://visualci.com/docs/gallery/",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/DocSpring/visualci.git",
10
+ "directory": "clients/gallery/js"
11
+ },
12
+ "type": "module",
13
+ "sideEffects": [
14
+ "*.css"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./render": {
22
+ "types": "./dist/render-entry.d.ts",
23
+ "default": "./dist/render-entry.js"
24
+ },
25
+ "./gallery.css": "./dist/gallery.css",
26
+ "./iife": "./dist/gallery.iife.js"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md"
31
+ ],
32
+ "devDependencies": {
33
+ "@types/jsdom": "^30.0.0",
34
+ "@types/node": "^24.19.4",
35
+ "acorn": "^8.19.0",
36
+ "esbuild": "^0.28.2",
37
+ "jsdom": "^27.4.0",
38
+ "typescript": "^5",
39
+ "vitest": "^4.1.12"
40
+ },
41
+ "scripts": {
42
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/gallery.css dist/ && node scripts/iife.mjs",
43
+ "typecheck": "tsc --noEmit",
44
+ "test": "vitest run"
45
+ }
6
46
  }