@hraness/slopcamera 3.3.6 → 3.4.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/README.md +6 -4
- package/apps/desktop/application/operation.ts +1 -1
- package/apps/desktop/cli/capability-manifest.ts +13 -0
- package/apps/desktop/cli/commands.ts +1 -1
- package/apps/desktop/cli/help.ts +12 -1
- package/apps/desktop/cli/html-overlay-renderer.ts +16 -0
- package/apps/desktop/cli/portable-surface.ts +2 -0
- package/apps/desktop/code/public.ts +1 -0
- package/apps/desktop/core/visual-style-look.ts +34 -0
- package/apps/desktop/dist/cli/main.js +132 -108
- package/apps/desktop/html-overlay/runtime.ts +15 -0
- package/dist/cli.js +6 -2
- package/dist/{index-10bz03js.js → index-abnk4h9c.js} +3 -2
- package/dist/index.js +1 -1
- package/docs/README.md +1 -0
- package/examples/style-portfolio/ANIMATION-STUDIES.md +34 -0
- package/examples/style-portfolio/FILM-PLATE.md +19 -0
- package/examples/style-portfolio/README.md +137 -0
- package/examples/style-portfolio/animation-studies.html +597 -0
- package/examples/style-portfolio/assets/instrument-serif-OFL.txt +93 -0
- package/examples/style-portfolio/assets/instrument-serif-latin-400.woff2 +0 -0
- package/examples/style-portfolio/build-gallery.ts +403 -0
- package/examples/style-portfolio/film-plate.html +76 -0
- package/examples/style-portfolio/finish-film.ts +152 -0
- package/examples/style-portfolio/market-street/README.md +43 -0
- package/examples/style-portfolio/market-street/mesh.py +145 -0
- package/examples/style-portfolio/market-street/scene.py +760 -0
- package/examples/style-portfolio/market-street/source.json +1 -0
- package/examples/style-portfolio/market-street/street_data.py +72 -0
- package/examples/style-portfolio/render-film-plate.ts +128 -0
- package/examples/style-portfolio/render.ts +89 -0
- package/examples/style-portfolio/verify-animation-source.mjs +94 -0
- package/package.json +11 -2
- package/skills/slopcamera/SKILL.md +9 -0
- package/skills/slopcamera/references/gateway-media.md +5 -0
- package/skills/slopcamera/references/install.md +1 -1
- package/skills/slopcamera/references/music-video.md +5 -0
- package/skills/slopcamera/references/native-studio.md +4 -0
- package/skills/slopcamera/references/visual-style-direction.md +143 -0
- package/src/cli.ts +28 -0
- package/src/index.ts +1 -0
- package/src/version.ts +1 -1
- package/src/visual-style.ts +375 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2022 The Instrument Serif Project Authors (https://github.com/Instrument/instrument-serif)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/** Assemble an offline portfolio from explicitly selected, retained media. */
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { constants, createReadStream } from "node:fs";
|
|
4
|
+
import { copyFile, mkdir, readFile, realpath, stat, writeFile } from "node:fs/promises";
|
|
5
|
+
import { basename, dirname, extname, isAbsolute, relative, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
export interface GallerySourceFile {
|
|
9
|
+
path: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface GalleryStudy {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
style: string;
|
|
17
|
+
description: string;
|
|
18
|
+
/** Describe the actual production method, including simulation limits. */
|
|
19
|
+
method: string;
|
|
20
|
+
video: string;
|
|
21
|
+
poster: string;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
durationSeconds: number;
|
|
25
|
+
frameRate?: number;
|
|
26
|
+
receipt: string;
|
|
27
|
+
sourceFiles?: GallerySourceFile[];
|
|
28
|
+
limitations?: string[];
|
|
29
|
+
captions?: string;
|
|
30
|
+
captionLanguage?: string;
|
|
31
|
+
brief?: string;
|
|
32
|
+
reviewPoints?: { label: string; timeSeconds: number }[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface GalleryManifest {
|
|
36
|
+
schemaVersion: 1;
|
|
37
|
+
title: string;
|
|
38
|
+
intro?: string;
|
|
39
|
+
/** The ID of a study shown in the opening composition. Defaults to first. */
|
|
40
|
+
hero?: string;
|
|
41
|
+
reel?: GalleryStudy;
|
|
42
|
+
studies: GalleryStudy[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface SelectedFile {
|
|
46
|
+
input: string;
|
|
47
|
+
output: string;
|
|
48
|
+
sha256: string;
|
|
49
|
+
bytes: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface PreparedStudy {
|
|
53
|
+
study: GalleryStudy;
|
|
54
|
+
video: SelectedFile;
|
|
55
|
+
poster: SelectedFile;
|
|
56
|
+
receipt: SelectedFile;
|
|
57
|
+
sources: { label: string; file: SelectedFile }[];
|
|
58
|
+
captions: SelectedFile | undefined;
|
|
59
|
+
facts: { source: "ffprobe" | "supplied-manifest"; width: number; height: number; durationSeconds: number; frameRate: number | undefined };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
63
|
+
const maxManifestBytes = 1024 * 1024;
|
|
64
|
+
const maxTotalBytes = 3 * 1024 * 1024 * 1024;
|
|
65
|
+
const sourceExtensions = new Set([".ts", ".tsx", ".js", ".mjs", ".json", ".py", ".html", ".css", ".md", ".txt", ".png", ".jpg", ".jpeg", ".webp"]);
|
|
66
|
+
|
|
67
|
+
function record(value: unknown, label: string): Record<string, unknown> {
|
|
68
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object.`);
|
|
69
|
+
return value as Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function string(value: unknown, label: string, max = 1200): string {
|
|
73
|
+
if (typeof value !== "string" || value.trim().length === 0 || value.length > max || value.includes("\0")) {
|
|
74
|
+
throw new Error(`${label} must be nonempty text of at most ${max} characters.`);
|
|
75
|
+
}
|
|
76
|
+
return value.trim();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function number(value: unknown, label: string, min: number, max: number, integer = false): number {
|
|
80
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < min || value > max || (integer && !Number.isInteger(value))) {
|
|
81
|
+
throw new Error(`${label} must be ${integer ? "an integer" : "a number"} between ${min} and ${max}.`);
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function optionalString(value: unknown, label: string, max = 1200): string | undefined {
|
|
87
|
+
return value === undefined ? undefined : string(value, label, max);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function parseStudy(value: unknown, label: string): GalleryStudy {
|
|
91
|
+
const item = record(value, label);
|
|
92
|
+
const id = string(item.id, `${label}.id`, 64);
|
|
93
|
+
if (!/^[a-z0-9][a-z0-9-]*$/u.test(id)) throw new Error(`${label}.id must be a lowercase filename token.`);
|
|
94
|
+
const sourceFiles = item.sourceFiles;
|
|
95
|
+
if (sourceFiles !== undefined && (!Array.isArray(sourceFiles) || sourceFiles.length > 24)) throw new Error(`${label}.sourceFiles must contain at most 24 explicit files.`);
|
|
96
|
+
const limitations = item.limitations;
|
|
97
|
+
if (limitations !== undefined && (!Array.isArray(limitations) || limitations.length > 12)) throw new Error(`${label}.limitations must contain at most 12 entries.`);
|
|
98
|
+
const frameRate = item.frameRate === undefined ? undefined : number(item.frameRate, `${label}.frameRate`, .1, 240);
|
|
99
|
+
const captions = optionalString(item.captions, `${label}.captions`);
|
|
100
|
+
const captionLanguage = optionalString(item.captionLanguage, `${label}.captionLanguage`, 32);
|
|
101
|
+
if (captionLanguage !== undefined && !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(captionLanguage)) throw new Error(`${label}.captionLanguage must be a language tag.`);
|
|
102
|
+
if (captionLanguage && !captions) throw new Error(`${label}.captionLanguage requires captions.`);
|
|
103
|
+
const brief = optionalString(item.brief, `${label}.brief`, 1600);
|
|
104
|
+
const durationSeconds = number(item.durationSeconds, `${label}.durationSeconds`, .01, 600);
|
|
105
|
+
if (item.reviewPoints !== undefined && (!Array.isArray(item.reviewPoints) || item.reviewPoints.length > 6)) throw new Error(`${label}.reviewPoints must contain at most six points.`);
|
|
106
|
+
const reviewPoints = item.reviewPoints === undefined ? undefined : (item.reviewPoints as unknown[]).map((value, index) => {
|
|
107
|
+
const point = record(value, `${label}.reviewPoints[${index}]`);
|
|
108
|
+
return { label: string(point.label, "Review point label", 60), timeSeconds: number(point.timeSeconds, "Review time", 0, durationSeconds) };
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
id, title: string(item.title, `${label}.title`, 160), style: string(item.style, `${label}.style`, 100),
|
|
112
|
+
description: string(item.description, `${label}.description`), method: string(item.method, `${label}.method`, 240),
|
|
113
|
+
video: string(item.video, `${label}.video`), poster: string(item.poster, `${label}.poster`),
|
|
114
|
+
width: number(item.width, `${label}.width`, 16, 8192, true),
|
|
115
|
+
height: number(item.height, `${label}.height`, 16, 8192, true),
|
|
116
|
+
durationSeconds,
|
|
117
|
+
receipt: string(item.receipt, `${label}.receipt`),
|
|
118
|
+
...(frameRate === undefined ? {} : { frameRate }),
|
|
119
|
+
...(captions === undefined ? {} : { captions }),
|
|
120
|
+
...(captionLanguage === undefined ? {} : { captionLanguage }),
|
|
121
|
+
...(brief === undefined ? {} : { brief }),
|
|
122
|
+
...(reviewPoints === undefined ? {} : { reviewPoints }),
|
|
123
|
+
...(sourceFiles === undefined ? {} : { sourceFiles: sourceFiles.map((source, index) => {
|
|
124
|
+
const file = record(source, `${label}.sourceFiles[${index}]`);
|
|
125
|
+
const sourceLabel = optionalString(file.label, `${label}.sourceFiles[${index}].label`, 160);
|
|
126
|
+
return { path: string(file.path, `${label}.sourceFiles[${index}].path`), ...(sourceLabel ? { label: sourceLabel } : {}) };
|
|
127
|
+
}) }),
|
|
128
|
+
...(limitations === undefined ? {} : { limitations: limitations.map((text, index) => string(text, `${label}.limitations[${index}]`, 500)) }),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function parseManifest(value: unknown): GalleryManifest {
|
|
133
|
+
const input = record(value, "Manifest");
|
|
134
|
+
if (input.schemaVersion !== 1) throw new Error("Manifest.schemaVersion must be 1.");
|
|
135
|
+
if (!Array.isArray(input.studies) || input.studies.length < 1 || input.studies.length > 64) throw new Error("Manifest.studies must contain 1–64 studies.");
|
|
136
|
+
const studies = input.studies.map((study, index) => parseStudy(study, `studies[${index}]`));
|
|
137
|
+
const ids = new Set(studies.map(study => study.id));
|
|
138
|
+
if (ids.size !== studies.length) throw new Error("Study IDs must be unique.");
|
|
139
|
+
const hero = optionalString(input.hero, "Manifest.hero", 64);
|
|
140
|
+
if (hero !== undefined && !ids.has(hero)) throw new Error("Manifest.hero must name a study ID.");
|
|
141
|
+
const reel = input.reel === undefined ? undefined : parseStudy(input.reel, "Manifest.reel");
|
|
142
|
+
if (reel && ids.has(reel.id)) throw new Error("The reel ID must differ from study IDs.");
|
|
143
|
+
const intro = optionalString(input.intro, "Manifest.intro", 800);
|
|
144
|
+
return { schemaVersion: 1, title: string(input.title, "Manifest.title", 160), studies,
|
|
145
|
+
...(hero === undefined ? {} : { hero }), ...(reel === undefined ? {} : { reel }), ...(intro === undefined ? {} : { intro }) };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function within(parent: string, path: string): boolean {
|
|
149
|
+
const rel = relative(parent, path);
|
|
150
|
+
return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith("../"));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function sha256(path: string): Promise<string> {
|
|
154
|
+
const digest = createHash("sha256");
|
|
155
|
+
for await (const chunk of createReadStream(path)) digest.update(chunk);
|
|
156
|
+
return digest.digest("hex");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function html(value: string): string {
|
|
160
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function url(path: string): string {
|
|
164
|
+
return path.split("/").map(encodeURIComponent).join("/");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function seconds(value: number): string {
|
|
168
|
+
return `${Number(value.toFixed(2))} s`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function rate(value: unknown): number | undefined {
|
|
172
|
+
if (typeof value !== "string" || !/^\d+(?:\/\d+)?$/u.test(value)) return undefined;
|
|
173
|
+
const [top, bottom = "1"] = value.split("/");
|
|
174
|
+
const result = Number(top) / Number(bottom);
|
|
175
|
+
return Number.isFinite(result) && result > 0 ? result : undefined;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function probeVideo(path: string): Promise<PreparedStudy["facts"]> {
|
|
179
|
+
const child = Bun.spawn(["ffprobe", "-v", "error", "-show_entries", "stream=codec_type,width,height,avg_frame_rate:format=duration", "-of", "json", path],
|
|
180
|
+
{ cwd: root, stdout: "pipe", stderr: "pipe" });
|
|
181
|
+
const timer = setTimeout(() => child.kill(), 30_000);
|
|
182
|
+
try {
|
|
183
|
+
const [status, output, error] = await Promise.all([child.exited, new Response(child.stdout).text(), new Response(child.stderr).text()]);
|
|
184
|
+
if (status !== 0) throw new Error(`ffprobe failed (${status}): ${error.slice(-1600)}`);
|
|
185
|
+
const result = record(JSON.parse(output) as unknown, "ffprobe result");
|
|
186
|
+
if (!Array.isArray(result.streams)) throw new Error("ffprobe returned no streams.");
|
|
187
|
+
const streams = result.streams.map((stream, i) => record(stream, `ffprobe stream ${i}`));
|
|
188
|
+
const videos = streams.filter(stream => stream.codec_type === "video");
|
|
189
|
+
if (videos.length !== 1) throw new Error("Each selected film must have one video stream.");
|
|
190
|
+
const stream = videos[0]!;
|
|
191
|
+
const format = record(result.format, "ffprobe format");
|
|
192
|
+
return { source: "ffprobe", width: number(stream.width, "Video width", 16, 8192, true),
|
|
193
|
+
height: number(stream.height, "Video height", 16, 8192, true),
|
|
194
|
+
durationSeconds: number(Number(format.duration), "Video duration", .01, 600), frameRate: rate(stream.avg_frame_rate) };
|
|
195
|
+
} finally { clearTimeout(timer); }
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function media(item: PreparedStudy, className = ""): string {
|
|
199
|
+
const { study, video, poster } = item;
|
|
200
|
+
const type = extname(video.output) === ".webm" ? "video/webm" : "video/mp4";
|
|
201
|
+
const caption = item.captions ? `<track kind="captions" src="${url(item.captions.output)}" srclang="${html(study.captionLanguage ?? "en")}" label="Captions" default>` : "";
|
|
202
|
+
return `<div class="picture ${className}" style="--frame:${study.width} / ${study.height}">
|
|
203
|
+
<video id="film-${study.id}" controls loop playsinline preload="none" poster="${url(poster.output)}" width="${study.width}" height="${study.height}" aria-labelledby="title-${study.id}" aria-describedby="description-${study.id}">
|
|
204
|
+
<source src="${url(video.output)}" type="${type}">${caption}
|
|
205
|
+
<p>Your browser cannot play this film. <a href="${url(video.output)}">Open ${html(study.title)}</a>.</p>
|
|
206
|
+
</video>
|
|
207
|
+
</div>`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function details(item: PreparedStudy): string {
|
|
211
|
+
const { study, facts } = item;
|
|
212
|
+
const dimensions = `${facts.width} × ${facts.height}`;
|
|
213
|
+
const source = facts.source === "ffprobe" ? "Dimensions and duration read with ffprobe." : "Dimensions and duration supplied in the selected manifest.";
|
|
214
|
+
const sources = item.sources.length ? `<ul class="source-list">${item.sources.map(({ file, label }) => `<li><a href="${url(file.output)}" download>${html(label)}</a></li>`).join("")}</ul>` : "";
|
|
215
|
+
const limitations = study.limitations?.length ? `<ul>${study.limitations.map(text => `<li>${html(text)}</li>`).join("")}</ul>` : "";
|
|
216
|
+
return `<details><summary>Source & render details</summary><div class="detail-body">
|
|
217
|
+
<p>${html(study.method)}. ${html(source)}</p>
|
|
218
|
+
<dl><div><dt>Style</dt><dd>${html(study.style)}</dd></div><div><dt>Film</dt><dd>${dimensions} · ${seconds(facts.durationSeconds)}${facts.frameRate ? ` · ${Number(facts.frameRate.toFixed(3))} fps` : ""}</dd></div></dl>
|
|
219
|
+
${limitations}<p><a href="${url(item.receipt.output)}" download>Execution receipt</a> <span aria-hidden="true">·</span> <a href="metadata/${study.id}.json">File metadata</a></p>${sources}
|
|
220
|
+
</div></details>`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function caption(item: PreparedStudy, level: "h1" | "h2" | "h3"): string {
|
|
224
|
+
const { study, facts } = item;
|
|
225
|
+
return `<div class="caption"><${level} id="title-${study.id}">${html(study.title)}</${level}>
|
|
226
|
+
<p id="description-${study.id}" class="description">${html(study.description)}</p>
|
|
227
|
+
<p class="method">${html(study.method)}</p>
|
|
228
|
+
<p class="media-facts">${facts.width} × ${facts.height} <span aria-hidden="true">·</span> ${seconds(facts.durationSeconds)} <span aria-hidden="true">·</span> <a href="${url(item.video.output)}" download>Download film</a></p>
|
|
229
|
+
<p class="media-facts"><a href="${url(item.poster.output)}" download>Download still</a></p>
|
|
230
|
+
${study.reviewPoints?.length ? `<div class="review-points" aria-label="Inspect a moment in ${html(study.title)}">${study.reviewPoints.map(point => `<button type="button" data-study="${study.id}" data-time="${point.timeSeconds}">${html(point.label)} <span>${seconds(point.timeSeconds)}</span></button>`).join("")}</div>` : ""}
|
|
231
|
+
${study.brief ? `<details><summary>Make a variation</summary><div class="detail-body"><p>${html(study.brief)}</p><p>For a revision, name the time, the change, and what must remain unchanged. Keep the editable source with its media.</p></div></details>` : ""}
|
|
232
|
+
${details(item)}</div>`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function document(manifest: GalleryManifest, prepared: PreparedStudy[], reel: PreparedStudy | undefined, font: SelectedFile): string {
|
|
236
|
+
const hero = prepared.find(item => item.study.id === manifest.hero) ?? prepared[0]!;
|
|
237
|
+
const remaining = prepared.filter(item => item !== hero);
|
|
238
|
+
return `<!doctype html>
|
|
239
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
240
|
+
<meta name="color-scheme" content="light"><meta name="description" content="${html(manifest.intro ?? manifest.title)}">
|
|
241
|
+
<title>${html(manifest.title)} · Slopcamera</title>
|
|
242
|
+
<style>
|
|
243
|
+
@font-face{font-family:Portfolio Serif;src:url('${url(font.output)}') format('woff2');font-weight:400;font-style:normal;font-display:swap}
|
|
244
|
+
:root{--paper:#faf8f3;--ink:#171612;--muted:#625d54;--line:#d9d4c9;--accent:#754900;--space:clamp(1.2rem,3.6vw,3.5rem);--serif:'Portfolio Serif',Georgia,serif;--sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color-scheme:light}
|
|
245
|
+
*{box-sizing:border-box}html{scroll-behavior:smooth;scroll-padding-top:2rem}body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--sans);font-size:15px;line-height:1.6}::selection{background:#ded1b5;color:var(--ink)}a{color:inherit;text-underline-offset:.23em;text-decoration-thickness:1px}a:hover{color:var(--accent)}a:focus-visible,summary:focus-visible,video:focus-visible{outline:2px solid var(--accent);outline-offset:5px}p{margin:0}h1,h2,h3{font-family:var(--serif);font-weight:400;line-height:1.06;letter-spacing:-.012em;text-wrap:balance;margin:0}h1{font-size:clamp(2.1rem,3.6vw,3.8rem)}h2{font-size:clamp(2rem,3.5vw,3.6rem)}h3{font-size:clamp(1.7rem,2.1vw,2.3rem)}.skip{position:absolute;left:var(--space);top:-6rem;padding:.7rem;background:var(--paper);z-index:2}.skip:focus{top:1rem}.shell{max-width:1540px;margin-inline:auto;padding-inline:var(--space)}.masthead{min-height:76px;display:flex;align-items:center;justify-content:space-between;gap:1.5rem;padding-block:1rem}.wordmark{font-size:19px;font-weight:650;letter-spacing:-.035em;text-decoration:none}.masthead nav{display:flex;gap:1.4rem;font-size:13px}.opening{display:grid;grid-template-columns:minmax(0,3.2fr) minmax(225px,1fr);gap:clamp(1.5rem,3vw,3.4rem);align-items:end;padding-block:.7rem 4rem}.picture{background:#171612;aspect-ratio:var(--frame);overflow:hidden}.picture video{display:block;width:100%;height:100%;object-fit:contain}.caption{min-width:0}.caption .description{margin-top:.9rem;max-width:60ch;font-size:15px;line-height:1.6}.method{margin-top:1.2rem;color:var(--muted);font-size:12px;line-height:1.5}.media-facts{margin-top:.35rem;color:var(--muted);font-size:12px;line-height:1.8;font-variant-numeric:tabular-nums}.media-facts span{margin-inline:.3rem}.collection-heading{display:flex;align-items:baseline;justify-content:space-between;gap:2rem;margin:3rem 0 2.1rem;padding-top:2rem;border-top:1px solid var(--line)}.collection-heading p{max-width:49ch;color:var(--muted);font-size:14px}.studies{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:clamp(1.3rem,3.5vw,3.7rem);row-gap:4.2rem}.study .caption{margin-top:1.1rem}.study .description{max-width:58ch}.study .method{margin-top:.75rem}details{margin-top:1rem;color:var(--muted);font-size:12px;line-height:1.65}summary{cursor:pointer;width:fit-content;text-decoration:underline;text-underline-offset:.23em;padding:.2rem 0;list-style:disclosure-closed}details[open] summary{list-style:disclosure-open}.detail-body{padding-top:.6rem;max-width:66ch;overflow-wrap:anywhere}.detail-body p+p{margin-top:.7rem}.detail-body dl{margin:.75rem 0}.detail-body dl>div{display:grid;grid-template-columns:3.5rem minmax(0,1fr);gap:.75rem}.detail-body dd{margin:0}.detail-body ul{padding-left:1.1rem}.source-list{margin:.6rem 0 0}.reel{margin-top:5.5rem;padding-top:2rem;border-top:1px solid var(--line)}.reel-layout{display:grid;grid-template-columns:minmax(0,2.7fr) minmax(220px,1fr);align-items:end;gap:2rem;margin-top:1.7rem}.site-footer{margin-top:5.5rem;padding-block:1.8rem 2.6rem;border-top:1px solid var(--line);display:flex;justify-content:space-between;gap:2rem;font-size:12px;color:var(--muted)}.site-footer p{max-width:65ch}.footer-links{display:flex;gap:1.3rem;align-items:baseline;flex-wrap:wrap}body{scrollbar-color:#aaa18f var(--paper);scrollbar-width:thin}
|
|
246
|
+
.review-points{display:flex;gap:.5rem 1rem;flex-wrap:wrap;margin-top:.8rem}.review-points button{font:inherit;font-size:12px;background:none;border:0;border-bottom:1px solid var(--line);color:var(--ink);padding:.2rem 0;cursor:pointer}.review-points button span{color:var(--muted);margin-left:.25rem;font-variant-numeric:tabular-nums}.review-points button:hover{border-color:var(--accent);color:var(--accent)}.review-points button:focus-visible{outline:2px solid var(--accent);outline-offset:4px}
|
|
247
|
+
@media(max-width:1000px){.opening{grid-template-columns:minmax(0,2fr) minmax(220px,1fr)}.masthead{min-height:64px}.reel-layout{grid-template-columns:1fr}.opening .caption .description{font-size:14px}}
|
|
248
|
+
@media(max-width:720px){.opening{display:flex;flex-direction:column;align-items:stretch;gap:1.25rem;padding-bottom:1rem}.opening .caption{display:block}.opening .caption h1{font-size:2.8rem}.masthead{font-size:12px;gap:1rem}.masthead nav{gap:1rem}.studies{grid-template-columns:1fr;row-gap:3rem}.collection-heading{display:block;margin-top:2.6rem}.collection-heading p{margin-top:.9rem}.study .caption{margin-top:1rem}.site-footer{flex-direction:column;gap:1rem;margin-top:3.5rem}.reel{margin-top:3.5rem}}
|
|
249
|
+
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
|
|
250
|
+
@media(forced-colors:active){.picture{border:1px solid CanvasText}a:focus-visible,summary:focus-visible,video:focus-visible{outline-color:Highlight}}
|
|
251
|
+
</style></head><body id="top"><a class="skip" href="#collection">Skip to the collection</a>
|
|
252
|
+
<div class="shell"><header class="masthead"><a class="wordmark" href="#top">Slopcamera</a><nav aria-label="Portfolio"><a href="#collection">The studies</a>${reel ? '<a href="#reel">Watch the reel</a>' : ""}</nav></header>
|
|
253
|
+
<main><section class="opening" aria-labelledby="title-${hero.study.id}">${media(hero)}${caption(hero, "h1")}</section>
|
|
254
|
+
<section id="collection" aria-labelledby="collection-title"><div class="collection-heading"><h2 id="collection-title">${html(manifest.title)}</h2><p>${html(manifest.intro ?? "Original scenes in different visual languages. Play a film to see its timing; open its source to see how it was made.")}</p></div>
|
|
255
|
+
<div class="studies">${remaining.map(item => `<article class="study" aria-labelledby="title-${item.study.id}">${media(item)}${caption(item, "h3")}</article>`).join("\n")}</div></section>
|
|
256
|
+
${reel ? `<section class="reel" id="reel" aria-labelledby="reel-heading"><h2 id="reel-heading">The collection in motion</h2><div class="reel-layout">${media(reel)}${caption(reel, "h3")}</div></section>` : ""}
|
|
257
|
+
</main><footer class="site-footer"><p>Authored studies made with Slopcamera. Each film retains its production method, source files, and execution evidence.</p><div class="footer-links"><a href="manifest.json">Selected works</a><a href="gallery-receipt.json">Assembly record</a><a href="font-license.txt">Type license</a><a href="#top">Back to top</a></div></footer></div>
|
|
258
|
+
<script>
|
|
259
|
+
// User-initiated playback only. One film owns motion and audio at a time.
|
|
260
|
+
const films = Array.from(document.querySelectorAll('video'));
|
|
261
|
+
for (const film of films) film.addEventListener('play', () => { for (const other of films) if (other !== film) other.pause(); });
|
|
262
|
+
for (const button of document.querySelectorAll('[data-study][data-time]')) button.addEventListener('click', () => {
|
|
263
|
+
const film = document.getElementById('film-' + button.dataset.study);
|
|
264
|
+
film.pause();
|
|
265
|
+
const seek = () => { film.currentTime = Number(button.dataset.time); film.focus(); };
|
|
266
|
+
if (film.readyState >= 1) seek();
|
|
267
|
+
else { film.addEventListener('loadedmetadata', seek, { once: true }); film.preload = 'metadata'; film.load(); }
|
|
268
|
+
});
|
|
269
|
+
document.addEventListener('visibilitychange', () => { if (document.hidden) for (const film of films) film.pause(); });
|
|
270
|
+
</script></body></html>\n`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async function main(): Promise<void> {
|
|
274
|
+
const args = process.argv.slice(2);
|
|
275
|
+
const positional: string[] = [];
|
|
276
|
+
let trustManifest = false;
|
|
277
|
+
for (const arg of args) {
|
|
278
|
+
if (arg === "--trust-manifest" && !trustManifest) trustManifest = true;
|
|
279
|
+
else if (arg.startsWith("--")) throw new Error(`Unknown or duplicate flag: ${arg}`);
|
|
280
|
+
else positional.push(arg);
|
|
281
|
+
}
|
|
282
|
+
if (positional.length < 1 || positional.length > 2) throw new Error("Usage: bun examples/style-portfolio/build-gallery.ts <manifest.json> [new-artifacts-directory] [--trust-manifest]");
|
|
283
|
+
const canonicalRoot = await realpath(root);
|
|
284
|
+
const manifestPath = await realpath(resolve(positional[0]!));
|
|
285
|
+
const manifestStat = await stat(manifestPath);
|
|
286
|
+
if (!manifestStat.isFile() || manifestStat.size > maxManifestBytes) throw new Error("Manifest must be a regular file no larger than 1 MiB.");
|
|
287
|
+
const manifestBytes = await readFile(manifestPath);
|
|
288
|
+
const manifest = parseManifest(JSON.parse(manifestBytes.toString("utf8")) as unknown);
|
|
289
|
+
const base = dirname(manifestPath);
|
|
290
|
+
const output = resolve(positional[1] ?? resolve(root, "artifacts/style-portfolio/gallery"));
|
|
291
|
+
const artifactsRoot = resolve(canonicalRoot, "artifacts");
|
|
292
|
+
if (output === artifactsRoot || !within(artifactsRoot, output)) throw new Error("Choose a new output directory strictly inside this repository's artifacts directory.");
|
|
293
|
+
const selected = new Map<string, SelectedFile>();
|
|
294
|
+
let totalBytes = 0;
|
|
295
|
+
|
|
296
|
+
async function select(path: string, folder: string, extensions: ReadonlySet<string>, maxBytes: number): Promise<SelectedFile> {
|
|
297
|
+
const input = await realpath(resolve(base, path));
|
|
298
|
+
if (!within(canonicalRoot, input)) throw new Error(`Selected input is outside this worktree: ${path}`);
|
|
299
|
+
if (within(resolve(canonicalRoot, "artifacts/style-portfolio/reference"), input)) throw new Error(`Reference material is not a portfolio deliverable: ${path}`);
|
|
300
|
+
if (relative(canonicalRoot, input).split("/").some(part => part.startsWith("."))) throw new Error(`Hidden input paths are not admitted: ${path}`);
|
|
301
|
+
const extension = extname(input).toLowerCase();
|
|
302
|
+
if (!extensions.has(extension)) throw new Error(`Unsupported ${folder} extension for ${path}.`);
|
|
303
|
+
const info = await stat(input);
|
|
304
|
+
if (!info.isFile() || info.size < 1 || info.size > maxBytes) throw new Error(`Selected ${folder} file has an unsupported size: ${path}`);
|
|
305
|
+
const existing = selected.get(input);
|
|
306
|
+
if (existing) return existing;
|
|
307
|
+
totalBytes += info.size;
|
|
308
|
+
if (totalBytes > maxTotalBytes || selected.size >= 512) throw new Error("Selection exceeds 3 GiB or 512 unique files.");
|
|
309
|
+
const hash = await sha256(input);
|
|
310
|
+
const stem = basename(input, extname(input)).toLowerCase().replace(/[^a-z0-9-]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 55) || "file";
|
|
311
|
+
const file = { input, output: `${folder}/${stem}-${hash.slice(0, 16)}${extension}`, sha256: hash, bytes: info.size };
|
|
312
|
+
selected.set(input, file);
|
|
313
|
+
return file;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
async function prepare(study: GalleryStudy): Promise<PreparedStudy> {
|
|
317
|
+
const video = await select(study.video, "films", new Set([".mp4", ".m4v", ".webm"]), 512 * 1024 * 1024);
|
|
318
|
+
const poster = await select(study.poster, "posters", new Set([".png", ".jpg", ".jpeg", ".webp"]), 32 * 1024 * 1024);
|
|
319
|
+
const receipt = await select(study.receipt, "receipts", new Set([".json"]), 4 * 1024 * 1024);
|
|
320
|
+
// Validate JSON without interpreting or following any embedded paths.
|
|
321
|
+
JSON.parse(await readFile(receipt.input, "utf8")) as unknown;
|
|
322
|
+
const facts: PreparedStudy["facts"] = trustManifest
|
|
323
|
+
? { source: "supplied-manifest", width: study.width, height: study.height, durationSeconds: study.durationSeconds, frameRate: study.frameRate }
|
|
324
|
+
: await probeVideo(video.input);
|
|
325
|
+
if (facts.width !== study.width || facts.height !== study.height || Math.abs(facts.durationSeconds - study.durationSeconds) > .15
|
|
326
|
+
|| (study.frameRate !== undefined && (facts.frameRate === undefined || Math.abs(facts.frameRate - study.frameRate) > .05))) {
|
|
327
|
+
throw new Error(`Media facts differ from the manifest for ${study.id}. Inspect the selected file and correct the manifest.`);
|
|
328
|
+
}
|
|
329
|
+
const sources: PreparedStudy["sources"] = [];
|
|
330
|
+
for (const source of study.sourceFiles ?? []) {
|
|
331
|
+
const file = await select(source.path, "sources", sourceExtensions, 8 * 1024 * 1024);
|
|
332
|
+
sources.push({ label: source.label ?? basename(source.path), file });
|
|
333
|
+
}
|
|
334
|
+
const captions = study.captions ? await select(study.captions, "captions", new Set([".vtt"]), 1024 * 1024) : undefined;
|
|
335
|
+
return { study, video, poster, receipt, sources, captions, facts };
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const prepared: PreparedStudy[] = [];
|
|
339
|
+
for (const study of manifest.studies) prepared.push(await prepare(study));
|
|
340
|
+
const reel = manifest.reel ? await prepare(manifest.reel) : undefined;
|
|
341
|
+
const font = await select(resolve(root, "examples/style-portfolio/assets/instrument-serif-latin-400.woff2"), "fonts", new Set([".woff2"]), 1024 * 1024);
|
|
342
|
+
const license = await select(resolve(root, "examples/style-portfolio/assets/instrument-serif-OFL.txt"), "licenses", new Set([".txt"]), 1024 * 1024);
|
|
343
|
+
// Validate the existing ancestor before creating anything. A new output
|
|
344
|
+
// directory is the claim; an existing or incomplete gallery is never reused.
|
|
345
|
+
let ancestor = dirname(output);
|
|
346
|
+
for (;;) {
|
|
347
|
+
try {
|
|
348
|
+
if (await realpath(ancestor) !== ancestor) throw new Error("Output ancestors must not be symlinks.");
|
|
349
|
+
break;
|
|
350
|
+
} catch (error) {
|
|
351
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
352
|
+
ancestor = dirname(ancestor);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
await mkdir(dirname(output), { recursive: true });
|
|
356
|
+
if (await realpath(dirname(output)) !== dirname(output)) throw new Error("Output parents must not be symlinks.");
|
|
357
|
+
await mkdir(output);
|
|
358
|
+
await writeFile(resolve(output, "assembly-intent.json"), JSON.stringify({ kind: "slopcamera.style-gallery-intent", schemaVersion: 1,
|
|
359
|
+
selectionSha256: createHash("sha256").update(manifestBytes).digest("hex"), selectedFiles: selected.size, bytes: totalBytes,
|
|
360
|
+
metadataSource: trustManifest ? "supplied-manifest" : "ffprobe", state: "assembly-started" }, null, 2) + "\n", { flag: "wx" });
|
|
361
|
+
const copied = new Set<string>();
|
|
362
|
+
for (const file of selected.values()) {
|
|
363
|
+
if (copied.has(file.output)) continue;
|
|
364
|
+
const destination = resolve(output, file.output);
|
|
365
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
366
|
+
await copyFile(file.input, destination, constants.COPYFILE_EXCL);
|
|
367
|
+
if (await sha256(destination) !== file.sha256) throw new Error(`Selected source changed during copying: ${file.input}. Retain this incomplete assembly for inspection.`);
|
|
368
|
+
copied.add(file.output);
|
|
369
|
+
}
|
|
370
|
+
await copyFile(resolve(output, license.output), resolve(output, "font-license.txt"), constants.COPYFILE_EXCL);
|
|
371
|
+
await mkdir(resolve(output, "metadata"));
|
|
372
|
+
function portable(item: PreparedStudy) {
|
|
373
|
+
const { study } = item;
|
|
374
|
+
return { id: study.id, title: study.title, style: study.style, description: study.description, method: study.method,
|
|
375
|
+
video: item.video.output, poster: item.poster.output, width: item.facts.width, height: item.facts.height,
|
|
376
|
+
durationSeconds: item.facts.durationSeconds, ...(item.facts.frameRate ? { frameRate: item.facts.frameRate } : {}),
|
|
377
|
+
receipt: item.receipt.output, sourceFiles: item.sources.map(({ file, label }) => ({ path: file.output, label })),
|
|
378
|
+
...(study.limitations ? { limitations: study.limitations } : {}),
|
|
379
|
+
...(study.brief ? { brief: study.brief } : {}),
|
|
380
|
+
...(study.reviewPoints ? { reviewPoints: study.reviewPoints } : {}),
|
|
381
|
+
...(item.captions ? { captions: item.captions.output, captionLanguage: study.captionLanguage ?? "en" } : {}) };
|
|
382
|
+
}
|
|
383
|
+
for (const item of [...prepared, ...(reel ? [reel] : [])]) {
|
|
384
|
+
await writeFile(resolve(output, "metadata", `${item.study.id}.json`), JSON.stringify({ kind: "slopcamera.style-gallery-study", schemaVersion: 1,
|
|
385
|
+
...portable(item), facts: item.facts, files: [item.video, item.poster, item.receipt, ...item.sources.map(source => source.file), ...(item.captions ? [item.captions] : [])]
|
|
386
|
+
.map(file => ({ path: file.output, bytes: file.bytes, sha256: file.sha256 })) }, null, 2) + "\n", { flag: "wx" });
|
|
387
|
+
}
|
|
388
|
+
const portableManifest = { schemaVersion: 1, title: manifest.title, ...(manifest.intro ? { intro: manifest.intro } : {}),
|
|
389
|
+
hero: manifest.hero ?? prepared[0]!.study.id, studies: prepared.map(portable), ...(reel ? { reel: portable(reel) } : {}) };
|
|
390
|
+
await writeFile(resolve(output, "manifest.json"), JSON.stringify(portableManifest, null, 2) + "\n", { flag: "wx" });
|
|
391
|
+
await writeFile(resolve(output, "gallery-receipt.json"), JSON.stringify({ kind: "slopcamera.style-gallery-receipt", schemaVersion: 1,
|
|
392
|
+
selectionSha256: createHash("sha256").update(manifestBytes).digest("hex"), studyCount: prepared.length,
|
|
393
|
+
hasReel: Boolean(reel), metadataSource: trustManifest ? "supplied-manifest" : "ffprobe",
|
|
394
|
+
files: [...selected.values()].map(file => ({ path: file.output, bytes: file.bytes, sha256: file.sha256 })),
|
|
395
|
+
limitations: ["File hashes establish copied bytes; they do not establish visual quality or historical accuracy.",
|
|
396
|
+
"Execution receipts are preserved as selected and may refer to original workspace paths. Embedded receipt paths are not followed."] }, null, 2) + "\n", { flag: "wx" });
|
|
397
|
+
// The entrypoint is written last, after every selected asset and record.
|
|
398
|
+
await writeFile(resolve(output, "index.html"), document(manifest, prepared, reel, font), { flag: "wx" });
|
|
399
|
+
console.log(JSON.stringify({ output, entrypoint: resolve(output, "index.html"), studies: prepared.length, files: copied.size,
|
|
400
|
+
bytes: totalBytes, metadataSource: trustManifest ? "supplied-manifest" : "ffprobe" }));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (import.meta.main) await main();
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<meta charset="utf-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5
|
+
<title>Single-image film-transfer study</title>
|
|
6
|
+
<style>html,body{width:100%;height:100%;margin:0;overflow:hidden;background:#000}canvas{display:block;width:100%;height:100%}</style>
|
|
7
|
+
<canvas id="plate" aria-label="A single photographic plate with restrained optical movement"></canvas>
|
|
8
|
+
<script>
|
|
9
|
+
(() => {
|
|
10
|
+
'use strict';
|
|
11
|
+
if (!window.SlopcameraOverlay) throw new Error('Film plate requires the Slopcamera host and a declared local plate asset.');
|
|
12
|
+
const fail = message => { throw new TypeError(`Film plate: ${message}`); };
|
|
13
|
+
const integer = (value, min, max, name) => {
|
|
14
|
+
if (!Number.isInteger(value) || value < min || value > max) fail(`${name} must be an integer in [${min}, ${max}].`);
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
const parameters = SlopcameraOverlay.parameters;
|
|
18
|
+
if (!parameters || typeof parameters !== 'object' || Array.isArray(parameters)) fail('parameters must be an object.');
|
|
19
|
+
const keys = ['kind', 'sourceWidth', 'sourceHeight', 'sourceSha256'];
|
|
20
|
+
if (Object.keys(parameters).length !== keys.length || Object.keys(parameters).some(key => !keys.includes(key))) fail('parameters must declare only kind, sourceWidth, sourceHeight, and sourceSha256.');
|
|
21
|
+
if (parameters.kind !== 'single-image-film-transfer') fail('This source is a single-image film-transfer study.');
|
|
22
|
+
const sourceWidth = integer(parameters.sourceWidth, 16, 33_000_000, 'sourceWidth');
|
|
23
|
+
const sourceHeight = integer(parameters.sourceHeight, 16, 33_000_000, 'sourceHeight');
|
|
24
|
+
if (sourceWidth * sourceHeight > 33_000_000) fail('The plate exceeds 33 megapixels.');
|
|
25
|
+
if (typeof parameters.sourceSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(parameters.sourceSha256)) fail('sourceSha256 must identify the retained local input.');
|
|
26
|
+
const width = integer(SlopcameraOverlay.width, 2, 8192, 'width');
|
|
27
|
+
const height = integer(SlopcameraOverlay.height, 2, 8192, 'height');
|
|
28
|
+
if (width % 2 || height % 2 || width * height > 33_000_000) fail('Use bounded even output dimensions.');
|
|
29
|
+
if (width > sourceWidth || height > sourceHeight) fail('Delivery dimensions cannot exceed the photographic source.');
|
|
30
|
+
// Even raster rounding may trim at most two source-proportional output pixels.
|
|
31
|
+
if (Math.abs(width - height * sourceWidth / sourceHeight) > Math.max(2, 2 * sourceWidth / sourceHeight)) fail('The output must preserve the plate aspect ratio.');
|
|
32
|
+
if (SlopcameraOverlay.fps !== 16 || SlopcameraOverlay.durationMs !== 6000) fail('This study requires six seconds at 16 fps.');
|
|
33
|
+
if (window.innerWidth !== width || window.innerHeight !== height || window.devicePixelRatio !== 1) fail('Use the declared CSS dimensions and device scale 1.');
|
|
34
|
+
const canvas = document.getElementById('plate');
|
|
35
|
+
canvas.width = width;
|
|
36
|
+
canvas.height = height;
|
|
37
|
+
const context = canvas.getContext('2d', { alpha: false });
|
|
38
|
+
if (!context) fail('Canvas2D is unavailable.');
|
|
39
|
+
const plate = new Image();
|
|
40
|
+
plate.decoding = 'sync';
|
|
41
|
+
plate.src = SlopcameraOverlay.asset('plate');
|
|
42
|
+
let decoded = false;
|
|
43
|
+
SlopcameraOverlay.ready(plate.decode().then(() => {
|
|
44
|
+
if (plate.naturalWidth !== sourceWidth || plate.naturalHeight !== sourceHeight) fail('Decoded plate dimensions differ from the inspected source.');
|
|
45
|
+
decoded = true;
|
|
46
|
+
}));
|
|
47
|
+
const TAU = Math.PI * 2;
|
|
48
|
+
SlopcameraOverlay.onFrame(({ timeMs }) => {
|
|
49
|
+
if (!decoded) fail('The plate must decode before any frame is drawn.');
|
|
50
|
+
if (typeof timeMs !== 'number' || !Number.isFinite(timeMs) || timeMs < 0 || timeMs > 6000) fail('timeMs must be in [0, 6000].');
|
|
51
|
+
const seconds = timeMs / 1000;
|
|
52
|
+
const progress = timeMs / 6000;
|
|
53
|
+
const eased = progress * progress * (3 - 2 * progress);
|
|
54
|
+
// The 0.4% initial overscan hides registration motion; the push adds 1.2%.
|
|
55
|
+
// No subject geometry is invented or animated inside the photographic plate.
|
|
56
|
+
const zoom = 1.004 + 0.012 * eased;
|
|
57
|
+
const scale = Math.max(width / sourceWidth, height / sourceHeight) * zoom;
|
|
58
|
+
const drawWidth = sourceWidth * scale;
|
|
59
|
+
const drawHeight = sourceHeight * scale;
|
|
60
|
+
const unit = Math.min(height / 1080, width / 1440);
|
|
61
|
+
const weaveX = (0.28 * Math.sin(TAU * 1.7 * seconds + 0.4) + 0.17 * Math.sin(TAU * 3.13 * seconds + 2.1)) * unit;
|
|
62
|
+
const weaveY = (0.28 * Math.sin(TAU * 1.3 * seconds + 0.9) + 0.17 * Math.sin(TAU * 2.7 * seconds + 1.4)) * unit;
|
|
63
|
+
const exposure = 1 + 0.004 * Math.sin(TAU * seconds / 4.3) + 0.002 * Math.sin(TAU * seconds / 1.7 + 0.42);
|
|
64
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
65
|
+
context.filter = 'none';
|
|
66
|
+
context.fillStyle = '#000';
|
|
67
|
+
context.fillRect(0, 0, width, height);
|
|
68
|
+
context.imageSmoothingEnabled = true;
|
|
69
|
+
context.imageSmoothingQuality = 'high';
|
|
70
|
+
context.filter = `brightness(${exposure})`;
|
|
71
|
+
context.drawImage(plate, (width - drawWidth) / 2 + weaveX, (height - drawHeight) / 2 + weaveY, drawWidth, drawHeight);
|
|
72
|
+
context.filter = 'none';
|
|
73
|
+
});
|
|
74
|
+
})();
|
|
75
|
+
</script>
|
|
76
|
+
</html>
|