@margoengine/headless 0.1.0 → 1.0.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/null.js CHANGED
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const i=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const i=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { t as e } from "./src-VufTH2fo.js";
5
5
  import { r as t, t as n } from "./errors-CDgOgzCd.js";
6
6
  import { HeadlessStage as r } from "./stage.js";
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const t=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const t=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { t as e } from "./errors-CDgOgzCd.js";
5
5
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
6
6
  //#region src/readback.ts
package/dist/stage.js CHANGED
@@ -1,4 +1,4 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
4
  import { a as e, i as t, r as n, t as r } from "./src-VufTH2fo.js";
@@ -93,7 +93,7 @@ async function p({ width: e, height: t, gpu: n = globalThis.navigator?.gpu, glob
93
93
  ...l,
94
94
  backend: "webgpu"
95
95
  });
96
- return o && (e.onError = o), e.use({coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
96
+ return o && (e.onError = o), e.use({coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
97
97
  name: "margoengine-headless",
98
98
  setup() {},
99
99
  dispose: h
package/dist/tiles.js CHANGED
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const r=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const r=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { i as e } from "./src-VufTH2fo.js";
5
5
  import { n as t, t as n } from "./errors-CDgOgzCd.js";
6
6
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
@@ -0,0 +1,26 @@
1
+ import type { Yuv420Options } from './yuv420.js';
2
+ /** Workers converting RGBA frames to I420 bytes (`i420Bytes(toYuv420(...))`), one frame per worker at a time. */
3
+ export declare class Yuv420Pool {
4
+ #private;
5
+ readonly size: number;
6
+ /** `size` workers; default one fewer than the machine's parallelism, at least one. */
7
+ constructor(size?: number);
8
+ /** The I420 bytes of one RGBA frame. `rgba` is copied, so the caller may reuse it at once. */
9
+ convert(rgba: Uint8Array, width: number, height: number, options?: Yuv420Options): Promise<Uint8Array>;
10
+ /** Stops every worker; pending conversions reject. */
11
+ close(): Promise<void>;
12
+ [Symbol.asyncDispose](): Promise<void>;
13
+ }
14
+ /**
15
+ * The I420 bytes of `frames`, in order, converted `pool.size` at a time ahead of the reader. Each frame's data is
16
+ * copied when it is read, so a producer may reuse its buffer.
17
+ */
18
+ export declare function yuv420Frames(frames: AsyncIterable<{
19
+ width: number;
20
+ height: number;
21
+ data: Uint8Array;
22
+ }> | Iterable<{
23
+ width: number;
24
+ height: number;
25
+ data: Uint8Array;
26
+ }>, pool: Yuv420Pool, options?: Yuv420Options): AsyncGenerator<Uint8Array>;
@@ -0,0 +1,73 @@
1
+ import { n as e } from "./errors-CDgOgzCd.js";
2
+ import { Worker as t } from "node:worker_threads";
3
+ import { availableParallelism as n } from "node:os";
4
+ //#region src/yuv420-pool.ts
5
+ var r = class {
6
+ #e = [];
7
+ #t = [];
8
+ #n = [];
9
+ #r = /* @__PURE__ */ new Map();
10
+ #i = !1;
11
+ constructor(t = Math.max(1, n() - 1)) {
12
+ if (!Number.isInteger(t) || t < 1) throw e(`Yuv420Pool needs a whole number of workers, got ${t}`, "headless");
13
+ this.size = t;
14
+ }
15
+ #a() {
16
+ let e = new URL("./" + ["yuv420", "js"].join("."), import.meta.url).href, n = new t(`const { parentPort } = require('node:worker_threads');
17
+ const ready = import(${JSON.stringify(e)});
18
+ parentPort.on('message', async ({ rgba, width, height, options }) => {
19
+ const { i420Bytes, toYuv420 } = await ready, bytes = i420Bytes(toYuv420(rgba, width, height, options));
20
+ parentPort.postMessage(bytes, [bytes.buffer]);
21
+ });`, { eval: !0 });
22
+ return n.on("message", (e) => this.#o(n, void 0, e)), n.on("error", (e) => this.#o(n, e)), n.unref(), this.#e.push(n), n;
23
+ }
24
+ #o(e, t, n) {
25
+ let r = this.#r.get(e);
26
+ this.#r.delete(e), t === void 0 ? (r?.resolve(n), this.#t.push(e)) : (this.#e = this.#e.filter((t) => t !== e), r?.reject(t)), this.#s();
27
+ }
28
+ #s() {
29
+ for (; this.#n.length && (this.#t.length || this.#e.length < this.size);) {
30
+ let e = this.#t.pop() ?? this.#a(), { message: t, transfer: n, job: r } = this.#n.shift();
31
+ this.#r.set(e, r), e.ref(), e.postMessage(t, n);
32
+ }
33
+ for (let e of this.#t) e.unref();
34
+ }
35
+ convert(t, n, r, i = {}) {
36
+ if (this.#i) return Promise.reject(e("Yuv420Pool is closed", "headless"));
37
+ let a = t.slice();
38
+ return new Promise((e, t) => {
39
+ this.#n.push({
40
+ message: {
41
+ rgba: a,
42
+ width: n,
43
+ height: r,
44
+ options: i
45
+ },
46
+ transfer: [a.buffer],
47
+ job: {
48
+ resolve: e,
49
+ reject: t
50
+ }
51
+ }), this.#s();
52
+ });
53
+ }
54
+ async close() {
55
+ this.#i = !0;
56
+ for (let { job: t } of this.#n.splice(0)) t.reject(e("Yuv420Pool closed", "headless"));
57
+ await Promise.all(this.#e.map((e) => e.terminate())), this.#e = [], this.#t = [];
58
+ }
59
+ async [Symbol.asyncDispose]() {
60
+ await this.close();
61
+ }
62
+ };
63
+ async function* i(e, t, n = {}) {
64
+ let r = [];
65
+ try {
66
+ for await (let i of e) r.push(t.convert(i.data, i.width, i.height, n)), r.length >= t.size * 2 && (yield await r.shift());
67
+ for (; r.length;) yield await r.shift();
68
+ } finally {
69
+ for (let e of r) e.catch(() => {});
70
+ }
71
+ }
72
+ //#endregion
73
+ export { r as Yuv420Pool, i as yuv420Frames };
@@ -0,0 +1,33 @@
1
+ /** Where a chroma sample sits: `'left'` (H.273 type 0, the H.264 default) or `'center'` (type 1). */
2
+ export type ChromaSiting = 'left' | 'center';
3
+ /** Options of {@link toYuv420}. */
4
+ export interface Yuv420Options {
5
+ /** `'sharp'` (default): chroma and luma chosen so the decoded frame matches the source. `'average'`: the plain
6
+ * linear filter (left siting: 1, 2, 1 across and 1, 1 down; centre: the 2 x 2 mean) and each pixel's own luma. */
7
+ chroma?: 'sharp' | 'average';
8
+ /** Chroma siting the stream states and the player reads. Default `'left'`. */
9
+ siting?: ChromaSiting;
10
+ /** Rounds of the sharp search (luma, then chroma). Default 4. */
11
+ rounds?: number;
12
+ }
13
+ /** An 8-bit I420 picture: Y (width x height), then Cb and Cr (each width / 2 x height / 2), limited range. */
14
+ export interface Yuv420 {
15
+ width: number;
16
+ height: number;
17
+ siting: ChromaSiting;
18
+ y: Uint8Array;
19
+ cb: Uint8Array;
20
+ cr: Uint8Array;
21
+ }
22
+ /**
23
+ * The 4:2:0 picture of 8-bit RGB(A) `pixels` (`channels` 4 or 3 per pixel, sRGB-encoded, full range), BT.709 at
24
+ * limited range. Even width and height only (H.264 4:2:0 codes sizes in steps of two). Deterministic.
25
+ */
26
+ export declare function toYuv420(pixels: ArrayLike<number>, width: number, height: number, { chroma, siting, rounds }?: Yuv420Options, channels?: 3 | 4): Yuv420;
27
+ /**
28
+ * The 8-bit RGBA frame a player shows for `picture`: chroma read bilinearly from its siting, BT.709 at limited range
29
+ * to full-range RGB, each channel clamped and rounded.
30
+ */
31
+ export declare function fromYuv420(picture: Yuv420): Uint8ClampedArray;
32
+ /** The I420 bytes ffmpeg's `-f rawvideo -pix_fmt yuv420p` reads: Y, then Cb, then Cr. */
33
+ export declare function i420Bytes(picture: Yuv420): Uint8Array;
package/dist/yuv420.js ADDED
@@ -0,0 +1,186 @@
1
+ import { n as e } from "./errors-CDgOgzCd.js";
2
+ //#region src/yuv420.ts
3
+ var t = 9, n = .2126, r = .0722, i = .7152, a = 1.5748, o = 1.8556, s = r * o / i, c = n * a / i, l = 4096, u = /* @__PURE__ */ new Float32Array(4098);
4
+ for (let e = 0; e <= 4097; e++) {
5
+ let t = Math.min(e / l, 1);
6
+ u[e] = t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
7
+ }
8
+ var d = (e) => {
9
+ let t = e * l, n = t | 0;
10
+ return u[n] + (u[n + 1] - u[n]) * (t - n);
11
+ }, f = (e) => e > 216 / 24389 ? Math.cbrt(e) : 24389 / 27 / 116 * e + 16 / 116, p = (e) => e < 0 ? 0 : e > 1 ? 1 : e;
12
+ function m(e, t, n, r, i) {
13
+ let a = d(e), o = d(t), s = d(n), c = f((.4124564 * a + .3575761 * o + .1804375 * s) / .95047), l = f(.2126729 * a + .7151522 * o + .072175 * s), u = f((.0193339 * a + .119192 * o + .9503041 * s) / 1.08883);
14
+ r[i] = 116 * l - 16, r[i + 1] = 500 * (c - l), r[i + 2] = 200 * (l - u);
15
+ }
16
+ var h = /* @__PURE__ */ new Float64Array(3);
17
+ function g(e, t, n, r, i) {
18
+ let l = (e - 16) / 219, u = (t - 128) / 224, d = (n - 128) / 224;
19
+ m(p(l + a * d), p(l - s * u - c * d), p(l + o * u), h, 0);
20
+ let f = h[0] - r[i], g = h[1] - r[i + 1], _ = h[2] - r[i + 2];
21
+ return f * f + g * g + _ * _;
22
+ }
23
+ function _(e, t, n) {
24
+ let r = new Int32Array(e), i = new Int32Array(e), a = new Float32Array(e);
25
+ for (let o = 0; o < e; o++) {
26
+ let e = Math.min(Math.max((o - n) / 2, 0), t - 1), s = Math.floor(e);
27
+ r[o] = s, i[o] = Math.min(s + 1, t - 1), a[o] = e - s;
28
+ }
29
+ return {
30
+ i0: r,
31
+ i1: i,
32
+ t: a
33
+ };
34
+ }
35
+ function v(t, n, r) {
36
+ if (!Number.isInteger(t) || !Number.isInteger(n) || t < 2 || n < 2 || t % 2 || n % 2) throw e(`${r} needs an even width and height of at least 2, got ${t} x ${n}`, "headless");
37
+ }
38
+ function y(t, s, c, { chroma: l = "sharp", siting: u = "left", rounds: d = 4 } = {}, f = 4) {
39
+ if (v(s, c, "toYuv420"), t.length !== s * c * f) throw e(`toYuv420: ${t.length} values for ${s} x ${c} x ${f}`, "headless");
40
+ if (l !== "sharp" && l !== "average") throw e(`toYuv420: chroma must be 'sharp' or 'average', got ${String(l)}`, "headless");
41
+ if (u !== "left" && u !== "center") throw e(`toYuv420: siting must be 'left' or 'center', got ${String(u)}`, "headless");
42
+ if (!Number.isInteger(d) || d < 0 || d > 64) throw e(`toYuv420: rounds must be a whole number from 0 to 64, got ${d}`, "headless");
43
+ let p = s * c, m = s / 2, h = c / 2, g = new Float32Array(p), _ = new Float32Array(p), y = new Float32Array(p);
44
+ for (let e = 0, s = 0; e < p; e++, s += f) {
45
+ let c = t[s] / 255, l = t[s + 1] / 255, u = t[s + 2] / 255, d = n * c + i * l + r * u;
46
+ g[e] = d, _[e] = (u - d) / o, y[e] = (c - d) / a;
47
+ }
48
+ let w = new Float32Array(m * h), T = new Float32Array(m * h), E = u === "left" ? [
49
+ -1,
50
+ 0,
51
+ 1
52
+ ] : [0, 1], D = u === "left" ? [
53
+ .25,
54
+ .5,
55
+ .25
56
+ ] : [.5, .5];
57
+ for (let e = 0; e < h; e++) for (let t = 0; t < m; t++) {
58
+ let n = 0, r = 0, i = 0;
59
+ for (let a = 0; a < 2; a++) for (let o = 0; o < E.length; o++) {
60
+ let c = 2 * t + E[o], l = 2 * e + a;
61
+ if (c < 0 || c >= s) continue;
62
+ let u = D[o] * .5;
63
+ n += u * _[l * s + c], r += u * y[l * s + c], i += u;
64
+ }
65
+ w[e * m + t] = Math.min(240, Math.max(16, 128 + 224 * n / i)), T[e * m + t] = Math.min(240, Math.max(16, 128 + 224 * r / i));
66
+ }
67
+ let O = new Uint8Array(p);
68
+ for (let e = 0; e < p; e++) O[e] = Math.round(16 + 219 * g[e]);
69
+ l === "sharp" && C(t, f, s, c, u, d, O, w, T);
70
+ let k = new Uint8Array(m * h), A = new Uint8Array(m * h);
71
+ for (let e = 0; e < m * h; e++) k[e] = Math.round(w[e]), A[e] = Math.round(T[e]);
72
+ if (l === "sharp") {
73
+ let e = b(t, f, p), { read: n } = x(s, c, u), r = Float32Array.from(k), i = Float32Array.from(A);
74
+ for (let t = 0; t < p; t++) {
75
+ let [a, o] = n(r, i, t);
76
+ O[t] = S(O[t], a, o, e, t * 3, 2);
77
+ }
78
+ }
79
+ return {
80
+ width: s,
81
+ height: c,
82
+ siting: u,
83
+ y: O,
84
+ cb: k,
85
+ cr: A
86
+ };
87
+ }
88
+ function b(e, t, n) {
89
+ let r = new Float32Array(n * 3);
90
+ for (let i = 0, a = 0; i < n; i++, a += t) m(e[a] / 255, e[a + 1] / 255, e[a + 2] / 255, h, 0), r[i * 3] = h[0], r[i * 3 + 1] = h[1], r[i * 3 + 2] = h[2];
91
+ return r;
92
+ }
93
+ function x(e, t, n) {
94
+ let r = e / 2, i = t / 2, a = _(e, r, n === "left" ? 0 : .5), o = _(t, i, .5), s = [0, 0];
95
+ return {
96
+ read: (t, n, i) => {
97
+ let c = i % e, l = (i - c) / e, u = o.i0[l] * r, d = o.i1[l] * r, f = a.i0[c], p = a.i1[c], m = a.t[c], h = o.t[l];
98
+ return s[0] = (t[u + f] * (1 - m) + t[u + p] * m) * (1 - h) + (t[d + f] * (1 - m) + t[d + p] * m) * h, s[1] = (n[u + f] * (1 - m) + n[u + p] * m) * (1 - h) + (n[d + f] * (1 - m) + n[d + p] * m) * h, s;
99
+ },
100
+ weightOf: (t, n) => {
101
+ let i = n % e, s = (n - i) / e, c = t % r, l = (t - c) / r;
102
+ return ((a.i0[i] === c ? 1 - a.t[i] : 0) + (a.i1[i] === c ? a.t[i] : 0)) * ((o.i0[s] === l ? 1 - o.t[s] : 0) + (o.i1[s] === l ? o.t[s] : 0));
103
+ }
104
+ };
105
+ }
106
+ function S(e, t, n, r, i, a = 16) {
107
+ let o = Math.min(235, Math.max(16, e)), s = g(o, t, n, r, i);
108
+ for (let e = a; e >= 1; e >>= 1) for (let a = !0; a;) {
109
+ a = !1;
110
+ for (let c of [e, -e]) {
111
+ let e = o + c;
112
+ if (e < 16 || e > 235) continue;
113
+ let l = g(e, t, n, r, i);
114
+ l < s && (s = l, o = e, a = !0);
115
+ }
116
+ }
117
+ return o;
118
+ }
119
+ function C(e, n, r, i, l, u, d, f, h) {
120
+ let _ = r * i, v = r / 2, y = i / 2, C = b(e, n, _), { read: w, weightOf: T } = x(r, i, l), E = l === "left" ? 1 : 2, D = (e) => {
121
+ let t = e % v, n = (e - t) / v, a = [];
122
+ for (let o = 2 * n - 1; o <= 2 * n + 2; o++) for (let n = 2 * t + -1; n <= 2 * t + E; n++) n >= 0 && o >= 0 && n < r && o < i && T(e, o * r + n) > 0 && a.push(o * r + n);
123
+ return a;
124
+ }, O = new Uint8Array(v * y);
125
+ for (let e = 0; e < _; e++) {
126
+ let [n, i] = w(f, h, e);
127
+ if (g(d[e], n, i, C, e * 3) <= t) continue;
128
+ let a = e % r, o = (e - a) / r;
129
+ for (let e = Math.max(0, (o >> 1) - 1); e <= Math.min(y - 1, (o >> 1) + 1); e++) for (let t = Math.max(0, (a >> 1) - 1); t <= Math.min(v - 1, (a >> 1) + 1); t++) O[e * v + t] = 1;
130
+ }
131
+ let k = [];
132
+ for (let e = 0; e < v * y; e++) O[e] && k.push(e);
133
+ if (!k.length) return;
134
+ let A = k.map(D), j = new Uint8Array(_), M = [];
135
+ for (let e of A) for (let t of e) j[t] || (j[t] = 1, M.push(t));
136
+ let N = (e) => {
137
+ let t = 0;
138
+ for (let n of e) {
139
+ let [e, r] = w(f, h, n);
140
+ t += Math.sqrt(g(d[n], e, r, C, n * 3));
141
+ }
142
+ return t;
143
+ }, P = .5;
144
+ for (let e = 0; e < u; e++) {
145
+ for (let t of M) {
146
+ let [n, r] = w(f, h, t);
147
+ d[t] = S(d[t], n, r, C, t * 3, e === 0 ? 16 : 4);
148
+ }
149
+ for (let e = 0; e < k.length; e++) {
150
+ let t = k[e], n = A[e], r = 0, i = 0, l = 0, u = 0, g = 0, _ = /* @__PURE__ */ new Float64Array(3), v = /* @__PURE__ */ new Float64Array(3), y = /* @__PURE__ */ new Float64Array(3);
151
+ for (let e of n) {
152
+ let n = T(t, e), [b, x] = w(f, h, e), S = (d[e] - 16) / 219, E = e * 3, D = (e, t, n) => {
153
+ let r = (e - 128) / 224, i = (t - 128) / 224;
154
+ m(p(S + a * i), p(S - s * r - c * i), p(S + o * r), n, 0);
155
+ };
156
+ D(b, x, _), D(b + P, x, v), D(b, x + P, y);
157
+ let O = Math.hypot(_[0] - C[E], _[1] - C[E + 1], _[2] - C[E + 2]), k = 1 / Math.max(O, .5);
158
+ for (let e = 0; e < 3; e++) {
159
+ let t = (_[e] - C[E + e]) * Math.sqrt(k), a = (v[e] - _[e]) / P * n * Math.sqrt(k), o = (y[e] - _[e]) / P * n * Math.sqrt(k);
160
+ r += a * a, i += a * o, l += o * o, u += a * t, g += o * t;
161
+ }
162
+ }
163
+ let b = .001 * (r + l) + 1e-9, x = r + b, S = l + b, E = x * S - i * i;
164
+ if (!(E > 0)) continue;
165
+ let D = -(S * u - i * g) / E, O = -(x * g - i * u) / E, j = f[t], M = h[t], F = N(n), I = !1;
166
+ for (let e = 1; e >= .125 && !I; e /= 2) f[t] = Math.min(240, Math.max(16, j + e * D)), h[t] = Math.min(240, Math.max(16, M + e * O)), N(n) < F && (I = !0);
167
+ I || (f[t] = j, h[t] = M);
168
+ }
169
+ }
170
+ }
171
+ function w(t) {
172
+ let { width: n, height: r, siting: i, y: l, cb: u, cr: d } = t;
173
+ if (v(n, r, "fromYuv420"), l.length !== n * r || u.length !== n * r / 4 || d.length !== u.length) throw e("fromYuv420: plane sizes do not match the picture", "headless");
174
+ let f = n * r, m = new Uint8ClampedArray(f * 4), h = Float32Array.from(u), g = Float32Array.from(d), { read: _ } = x(n, r, i);
175
+ for (let e = 0; e < f; e++) {
176
+ let [t, n] = _(h, g, e), r = (l[e] - 16) / 219, i = (t - 128) / 224, u = (n - 128) / 224, d = e * 4;
177
+ m[d] = Math.round(p(r + a * u) * 255), m[d + 1] = Math.round(p(r - s * i - c * u) * 255), m[d + 2] = Math.round(p(r + o * i) * 255), m[d + 3] = 255;
178
+ }
179
+ return m;
180
+ }
181
+ function T(e) {
182
+ let t = new Uint8Array(e.y.length + 2 * e.cb.length);
183
+ return t.set(e.y, 0), t.set(e.cb, e.y.length), t.set(e.cr, e.y.length + e.cb.length), t;
184
+ }
185
+ //#endregion
186
+ export { w as fromYuv420, T as i420Bytes, y as toYuv420 };
package/package.json CHANGED
@@ -1,122 +1,130 @@
1
- {
2
- "name": "@margoengine/headless",
3
- "version": "0.1.0",
4
- "description": "Render without a browser page: a stand-in canvas for core, GPU globals from the WebGPU binding you pass in, and readback to RGBA pixels or PNG bytes.",
5
- "keywords": [
6
- "margoengine",
7
- "webgpu",
8
- "headless",
9
- "node",
10
- "thumbnail",
11
- "png"
12
- ],
13
- "homepage": "https://margoengine.com",
14
- "bugs": {
15
- "url": "https://github.com/scottcampbelldata/margoengine/issues"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/scottcampbelldata/margoengine.git",
20
- "directory": "packages/headless"
21
- },
22
- "license": "Apache-2.0",
23
- "author": "Scott Campbell",
24
- "type": "module",
25
- "sideEffects": false,
26
- "exports": {
27
- ".": {
28
- "types": "./dist/index.d.ts",
29
- "import": "./dist/index.js"
30
- },
31
- "./frames": {
32
- "types": "./dist/frames.d.ts",
33
- "import": "./dist/frames.js"
34
- },
35
- "./video": {
36
- "types": "./dist/video.d.ts",
37
- "import": "./dist/video.js"
38
- },
39
- "./ffmpeg": {
40
- "types": "./dist/ffmpeg.d.ts",
41
- "import": "./dist/ffmpeg.js"
42
- },
43
- "./ffmpeg-files": {
44
- "types": "./dist/ffmpeg-files.d.ts",
45
- "import": "./dist/ffmpeg-files.js"
46
- },
47
- "./stage": {
48
- "types": "./dist/stage.d.ts",
49
- "import": "./dist/stage.js"
50
- },
51
- "./compare": {
52
- "types": "./dist/compare.d.ts",
53
- "import": "./dist/compare.js"
54
- },
55
- "./formats": {
56
- "types": "./dist/formats.d.ts",
57
- "import": "./dist/formats.js"
58
- },
59
- "./tiles": {
60
- "types": "./dist/tiles.d.ts",
61
- "import": "./dist/tiles.js"
62
- },
63
- "./accumulate": {
64
- "types": "./dist/accumulate.d.ts",
65
- "import": "./dist/accumulate.js"
66
- },
67
- "./null": {
68
- "types": "./dist/null.d.ts",
69
- "import": "./dist/null.js"
70
- },
71
- "./gif": {
72
- "types": "./dist/gif.d.ts",
73
- "import": "./dist/gif.js"
74
- },
75
- "./look": {
76
- "types": "./dist/look.d.ts",
77
- "import": "./dist/look.js"
78
- }
79
- },
80
- "files": [
81
- "dist",
82
- "LICENSE",
83
- "NOTICE"
84
- ],
85
- "publishConfig": {
86
- "access": "public"
87
- },
88
- "peerDependencies": {
89
- "@margoengine/core": "^0.1.0",
90
- "@margoengine/stage": "^0.1.0",
91
- "@margoengine/environment": "^0.1.0",
92
- "@margoengine/exporters": "^0.1.0",
93
- "@margoengine/post": "^0.1.0"
94
- },
95
- "scripts": {
96
- "build": "node ../../scripts/build-optional.js headless",
97
- "test": "npm run build && node --test tests/*.test.js",
98
- "test:real-ffmpeg": "npm run build && node scripts/test-real-ffmpeg.mjs && node scripts/test-real-ffmpeg-files.mjs",
99
- "test:gpu": "cd ../.. && node packages/headless/tests/browser-check.mjs && node packages/headless/tests/node-check.mjs && node packages/headless/tests/transparent-gpu.mjs",
100
- "prepack": "npm run build",
101
- "test:gpu:gif": "cd ../.. && node packages/headless/tests/gif-gpu.mjs",
102
- "test:gpu:tiles": "cd ../.. && node packages/headless/tests/tiles-gpu.mjs",
103
- "test:gpu:accumulate": "cd ../.. && node packages/headless/tests/accumulate-gpu.mjs"
104
- },
105
- "peerDependenciesMeta": {
106
- "@margoengine/stage": {
107
- "optional": true
108
- },
109
- "@margoengine/environment": {
110
- "optional": true
111
- },
112
- "@margoengine/exporters": {
113
- "optional": true
114
- },
115
- "@margoengine/post": {
116
- "optional": true
117
- }
118
- },
119
- "dependencies": {
120
- "@margoengine/math": "^0.1.0"
121
- }
122
- }
1
+ {
2
+ "name": "@margoengine/headless",
3
+ "version": "1.0.0",
4
+ "description": "Render without a browser page: a stand-in canvas for core, GPU globals from the WebGPU binding you pass in, and readback to RGBA pixels or PNG bytes.",
5
+ "keywords": [
6
+ "margoengine",
7
+ "webgpu",
8
+ "headless",
9
+ "node",
10
+ "thumbnail",
11
+ "png"
12
+ ],
13
+ "homepage": "https://margoengine.com",
14
+ "bugs": {
15
+ "url": "https://github.com/scottcampbelldata/margoengine/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/scottcampbelldata/margoengine.git",
20
+ "directory": "packages/headless"
21
+ },
22
+ "license": "Apache-2.0",
23
+ "author": "Scott Campbell",
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./frames": {
32
+ "types": "./dist/frames.d.ts",
33
+ "import": "./dist/frames.js"
34
+ },
35
+ "./video": {
36
+ "types": "./dist/video.d.ts",
37
+ "import": "./dist/video.js"
38
+ },
39
+ "./ffmpeg": {
40
+ "types": "./dist/ffmpeg.d.ts",
41
+ "import": "./dist/ffmpeg.js"
42
+ },
43
+ "./ffmpeg-files": {
44
+ "types": "./dist/ffmpeg-files.d.ts",
45
+ "import": "./dist/ffmpeg-files.js"
46
+ },
47
+ "./stage": {
48
+ "types": "./dist/stage.d.ts",
49
+ "import": "./dist/stage.js"
50
+ },
51
+ "./compare": {
52
+ "types": "./dist/compare.d.ts",
53
+ "import": "./dist/compare.js"
54
+ },
55
+ "./formats": {
56
+ "types": "./dist/formats.d.ts",
57
+ "import": "./dist/formats.js"
58
+ },
59
+ "./tiles": {
60
+ "types": "./dist/tiles.d.ts",
61
+ "import": "./dist/tiles.js"
62
+ },
63
+ "./accumulate": {
64
+ "types": "./dist/accumulate.d.ts",
65
+ "import": "./dist/accumulate.js"
66
+ },
67
+ "./null": {
68
+ "types": "./dist/null.d.ts",
69
+ "import": "./dist/null.js"
70
+ },
71
+ "./gif": {
72
+ "types": "./dist/gif.d.ts",
73
+ "import": "./dist/gif.js"
74
+ },
75
+ "./look": {
76
+ "types": "./dist/look.d.ts",
77
+ "import": "./dist/look.js"
78
+ },
79
+ "./yuv420": {
80
+ "types": "./dist/yuv420.d.ts",
81
+ "import": "./dist/yuv420.js"
82
+ },
83
+ "./yuv420-pool": {
84
+ "types": "./dist/yuv420-pool.d.ts",
85
+ "import": "./dist/yuv420-pool.js"
86
+ }
87
+ },
88
+ "files": [
89
+ "dist",
90
+ "LICENSE",
91
+ "NOTICE"
92
+ ],
93
+ "publishConfig": {
94
+ "access": "public"
95
+ },
96
+ "peerDependencies": {
97
+ "@margoengine/core": "^1.0.0",
98
+ "@margoengine/stage": "^1.0.0",
99
+ "@margoengine/environment": "^1.0.0",
100
+ "@margoengine/exporters": "^1.0.0",
101
+ "@margoengine/post": "^1.0.0"
102
+ },
103
+ "scripts": {
104
+ "build": "node ../../scripts/build-optional.js headless",
105
+ "test": "npm run build && node --test tests/*.test.js",
106
+ "test:real-ffmpeg": "npm run build && node scripts/test-real-ffmpeg.mjs && node scripts/test-real-ffmpeg-files.mjs",
107
+ "test:gpu": "cd ../.. && node packages/headless/tests/browser-check.mjs && node packages/headless/tests/node-check.mjs && node packages/headless/tests/transparent-gpu.mjs",
108
+ "prepack": "npm run build",
109
+ "test:gpu:gif": "cd ../.. && node packages/headless/tests/gif-gpu.mjs",
110
+ "test:gpu:tiles": "cd ../.. && node packages/headless/tests/tiles-gpu.mjs",
111
+ "test:gpu:accumulate": "cd ../.. && node packages/headless/tests/accumulate-gpu.mjs"
112
+ },
113
+ "peerDependenciesMeta": {
114
+ "@margoengine/stage": {
115
+ "optional": true
116
+ },
117
+ "@margoengine/environment": {
118
+ "optional": true
119
+ },
120
+ "@margoengine/exporters": {
121
+ "optional": true
122
+ },
123
+ "@margoengine/post": {
124
+ "optional": true
125
+ }
126
+ },
127
+ "dependencies": {
128
+ "@margoengine/math": "^1.0.0"
129
+ }
130
+ }
@@ -1,15 +0,0 @@
1
- //#region src/ffmpeg-colour.ts
2
- var e = (e) => `scale=out_color_matrix=bt709:out_range=tv:out_chroma_loc=left,format=${e},setparams=color_primaries=bt709:color_trc=iec61966-2-1:colorspace=bt709:range=tv:chroma_location=left`, t = [
3
- "-colorspace",
4
- "bt709",
5
- "-color_primaries",
6
- "bt709",
7
- "-color_trc",
8
- "iec61966-2-1",
9
- "-color_range",
10
- "tv",
11
- "-chroma_sample_location",
12
- "left"
13
- ];
14
- //#endregion
15
- export { e as n, t };