@cyanheads/pixoo-mcp-server 1.2.1 → 1.3.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/AGENTS.md +17 -10
- package/CLAUDE.md +17 -10
- package/Dockerfile +63 -46
- package/README.md +16 -12
- package/changelog/1.2.x/1.2.2.md +40 -0
- package/changelog/1.3.x/1.3.0.md +35 -0
- package/dist/config/server-config.d.ts +1 -1
- package/dist/config/server-config.d.ts.map +1 -1
- package/dist/config/server-config.js +6 -1
- package/dist/config/server-config.js.map +1 -1
- package/dist/mcp-server/resources/definitions/pixoo-design-guide.resource.d.ts.map +1 -1
- package/dist/mcp-server/resources/definitions/pixoo-design-guide.resource.js +4 -1
- package/dist/mcp-server/resources/definitions/pixoo-design-guide.resource.js.map +1 -1
- package/dist/mcp-server/tools/asset-source-schema.d.ts +13 -0
- package/dist/mcp-server/tools/asset-source-schema.d.ts.map +1 -0
- package/dist/mcp-server/tools/asset-source-schema.js +25 -0
- package/dist/mcp-server/tools/asset-source-schema.js.map +1 -0
- package/dist/mcp-server/tools/definitions/pixoo-compose-scene.tool.d.ts +139 -55
- package/dist/mcp-server/tools/definitions/pixoo-compose-scene.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-compose-scene.tool.js +182 -79
- package/dist/mcp-server/tools/definitions/pixoo-compose-scene.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-design-brief.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-design-brief.tool.js +14 -6
- package/dist/mcp-server/tools/definitions/pixoo-design-brief.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-discover-devices.tool.d.ts +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-discover-devices.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-discover-devices.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-display-text.tool.d.ts +8 -9
- package/dist/mcp-server/tools/definitions/pixoo-display-text.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-display-text.tool.js +50 -29
- package/dist/mcp-server/tools/definitions/pixoo-display-text.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-overlay-text.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-overlay-text.tool.js +1 -3
- package/dist/mcp-server/tools/definitions/pixoo-overlay-text.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-push-image.tool.d.ts +30 -1
- package/dist/mcp-server/tools/definitions/pixoo-push-image.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/pixoo-push-image.tool.js +106 -28
- package/dist/mcp-server/tools/definitions/pixoo-push-image.tool.js.map +1 -1
- package/dist/mcp-server/tools/finish-schema.d.ts +28 -0
- package/dist/mcp-server/tools/finish-schema.d.ts.map +1 -0
- package/dist/mcp-server/tools/finish-schema.js +42 -0
- package/dist/mcp-server/tools/finish-schema.js.map +1 -0
- package/dist/renderer/finish.d.ts +34 -0
- package/dist/renderer/finish.d.ts.map +1 -0
- package/dist/renderer/finish.js +62 -0
- package/dist/renderer/finish.js.map +1 -0
- package/dist/renderer/keyframes.d.ts +5 -1
- package/dist/renderer/keyframes.d.ts.map +1 -1
- package/dist/renderer/keyframes.js +16 -2
- package/dist/renderer/keyframes.js.map +1 -1
- package/dist/renderer/remote-image.d.ts +9 -7
- package/dist/renderer/remote-image.d.ts.map +1 -1
- package/dist/renderer/remote-image.js +15 -23
- package/dist/renderer/remote-image.js.map +1 -1
- package/dist/renderer/scene-renderer.d.ts +59 -14
- package/dist/renderer/scene-renderer.d.ts.map +1 -1
- package/dist/renderer/scene-renderer.js +204 -66
- package/dist/renderer/scene-renderer.js.map +1 -1
- package/dist/renderer/text-engine.d.ts +40 -11
- package/dist/renderer/text-engine.d.ts.map +1 -1
- package/dist/renderer/text-engine.js +75 -40
- package/dist/renderer/text-engine.js.map +1 -1
- package/dist/services/pixoo/pixoo-service.d.ts.map +1 -1
- package/dist/services/pixoo/pixoo-service.js +9 -33
- package/dist/services/pixoo/pixoo-service.js.map +1 -1
- package/package.json +3 -3
- package/server.json +3 -3
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Remote image fetch — downloads an https image
|
|
3
|
-
* toolkit's
|
|
4
|
-
*
|
|
2
|
+
* @fileoverview Remote image fetch — downloads an https image's encoded bytes into
|
|
3
|
+
* memory for the toolkit's image loaders. Shared by the scene renderer's image elements
|
|
4
|
+
* and the pixoo_push_image tool.
|
|
5
5
|
* @module renderer/remote-image
|
|
6
6
|
*/
|
|
7
|
-
import * as os from 'node:os';
|
|
8
|
-
import * as path from 'node:path';
|
|
9
7
|
import { notFound } from '@cyanheads/mcp-ts-core/errors';
|
|
10
8
|
import { fetchWithTimeout } from '@cyanheads/mcp-ts-core/utils';
|
|
11
9
|
/** Wall-clock budget for a remote image fetch, headers through body. */
|
|
12
10
|
const FETCH_TIMEOUT_MS = 15_000;
|
|
13
11
|
/** Ceiling on a downloaded image before it is decoded. */
|
|
14
12
|
const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
13
|
+
/** An https URL; the scheme is case-insensitive (RFC 3986 §3.1). */
|
|
14
|
+
const HTTPS_URL = /^https:\/\//i;
|
|
15
15
|
/** True when the string is a URL rather than a local filesystem path. */
|
|
16
16
|
export function isRemoteSource(source) {
|
|
17
|
-
return
|
|
17
|
+
return /^https?:\/\//i.test(source);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Fetch an https image and
|
|
21
|
-
*
|
|
20
|
+
* Fetch an https image and return its bytes as served, undecoded. Nothing is written to
|
|
21
|
+
* disk: the caller passes the bytes to the toolkit's loader, where a body that is not an image
|
|
22
|
+
* fails to decode.
|
|
22
23
|
*
|
|
23
24
|
* Private and loopback addresses are deliberately reachable: this server drives a
|
|
24
25
|
* LAN device, so a NAS or local web server is a legitimate image host.
|
|
@@ -27,19 +28,19 @@ export function isRemoteSource(source) {
|
|
|
27
28
|
* down instead of reading on to the deadline or the byte cap.
|
|
28
29
|
*
|
|
29
30
|
* @throws {McpError} NotFound with `reason: 'asset_not_found'` for a non-https URL,
|
|
30
|
-
* an unreachable or non-2xx endpoint, or a response over {@link MAX_IMAGE_BYTES}.
|
|
31
|
+
* an unreachable or non-2xx endpoint, or a response over {@link MAX_IMAGE_BYTES}. The
|
|
32
|
+
* message names the failure; the framework fills in the calling tool's declared recovery.
|
|
31
33
|
* @throws {McpError} RequestCancelled when `ctx.signal` aborts while the body streams.
|
|
32
34
|
* @throws {McpError} Timeout when the body outlasts {@link FETCH_TIMEOUT_MS}, or when the
|
|
33
35
|
* `ctx.signal` abort is a caller-side deadline (a `TimeoutError` reason). A tool handler
|
|
34
36
|
* still answers the deadline as RequestCancelled: the handler factory settles any throw
|
|
35
37
|
* after the request's signal fired as a cancellation.
|
|
36
38
|
*/
|
|
37
|
-
export async function
|
|
38
|
-
if (!
|
|
39
|
+
export async function fetchRemoteImageBytes(source, ctx) {
|
|
40
|
+
if (!HTTPS_URL.test(source)) {
|
|
39
41
|
throw notFound(`Only https URLs are supported. Received: "${source}".`, {
|
|
40
42
|
reason: 'asset_not_found',
|
|
41
43
|
url: source,
|
|
42
|
-
recovery: { hint: 'Use an https URL, or pass an absolute local file path instead.' },
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
// A throw here after the signal fired still reaches the caller as a cancellation:
|
|
@@ -47,18 +48,13 @@ export async function fetchRemoteImageToTempPng(source, ctx) {
|
|
|
47
48
|
const resp = await fetchWithTimeout(source, FETCH_TIMEOUT_MS, ctx, {
|
|
48
49
|
signal: ctx.signal,
|
|
49
50
|
}).catch((err) => {
|
|
50
|
-
throw notFound(`Failed to fetch image from "${source}": ${err instanceof Error ? err.message : String(err)}`, {
|
|
51
|
-
reason: 'asset_not_found',
|
|
52
|
-
url: source,
|
|
53
|
-
recovery: { hint: 'Check the URL is reachable and returns an image, then retry.' },
|
|
54
|
-
});
|
|
51
|
+
throw notFound(`Failed to fetch image from "${source}": ${err instanceof Error ? err.message : String(err)}`, { reason: 'asset_not_found', url: source });
|
|
55
52
|
});
|
|
56
53
|
/** Both size gates fail the same way; only the field naming the measurement differs. */
|
|
57
54
|
const tooLarge = (bytes, field) => notFound(`Image response too large (${bytes} bytes; limit: ${MAX_IMAGE_BYTES}).`, {
|
|
58
55
|
reason: 'asset_not_found',
|
|
59
56
|
url: source,
|
|
60
57
|
[field]: bytes,
|
|
61
|
-
recovery: { hint: 'Downscale the image before hosting it, or point at a smaller file.' },
|
|
62
58
|
});
|
|
63
59
|
// content-length is advisory: it bails before the body is read, but the byte
|
|
64
60
|
// count taken while streaming is the gate that actually holds.
|
|
@@ -83,10 +79,6 @@ export async function fetchRemoteImageToTempPng(source, ctx) {
|
|
|
83
79
|
chunks.push(value);
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
|
-
|
|
87
|
-
const { default: sharp } = await import('sharp');
|
|
88
|
-
const tmpPath = path.join(os.tmpdir(), `pixoo-img-${Date.now()}-${Math.random().toString(36).slice(2)}.png`);
|
|
89
|
-
await sharp(buf).png().toFile(tmpPath);
|
|
90
|
-
return tmpPath;
|
|
82
|
+
return Buffer.concat(chunks, received);
|
|
91
83
|
}
|
|
92
84
|
//# sourceMappingURL=remote-image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-image.js","sourceRoot":"","sources":["../../src/renderer/remote-image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"remote-image.js","sourceRoot":"","sources":["../../src/renderer/remote-image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,wEAAwE;AACxE,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,0DAA0D;AAC1D,MAA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D;IAC/D,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,IAAI,aAAa,GAAG,eAAe,EAAE,CAAC;QACpC,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,MAAM,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IACtC,IAAI,MAAM,EAAE,CAAC;QACX,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC;YAC7B,IAAI,QAAQ,GAAG,eAAe,EAAE,CAAC;gBAC/B,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;gBACtB,MAAM,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACzC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
* @module renderer/scene-renderer
|
|
4
4
|
*/
|
|
5
5
|
import type { Context } from '@cyanheads/mcp-ts-core';
|
|
6
|
-
import { Canvas, downsampleSprite, type PixooSize } from '@cyanheads/pixoo-toolkit';
|
|
6
|
+
import { type BlendMode, Canvas, downsampleSprite, type PixooSize } from '@cyanheads/pixoo-toolkit';
|
|
7
|
+
import { type Finish } from './finish.js';
|
|
7
8
|
import { type EffectName, type KeyframeMap } from './keyframes.js';
|
|
8
|
-
import { type LayoutEntry, type SemanticX, type SemanticY, type TextStyle } from './text-engine.js';
|
|
9
|
+
import { type FontVariant, type LayoutEntry, type SemanticX, type SemanticY, type TextStyle } from './text-engine.js';
|
|
9
10
|
import { type PaletteName, type ThemeName } from './themes.js';
|
|
10
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Background specification: a solid color string, or an object holding exactly one of
|
|
13
|
+
* `gradient` or `theme` (the compose tool's input schema enforces the exactly-one rule).
|
|
14
|
+
*/
|
|
11
15
|
export type BackgroundSpec = string | {
|
|
12
|
-
gradient
|
|
16
|
+
gradient?: {
|
|
13
17
|
type: 'v' | 'h' | 'r';
|
|
14
18
|
from: string;
|
|
15
19
|
to: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
theme: ThemeName;
|
|
20
|
+
} | undefined;
|
|
21
|
+
theme?: ThemeName | undefined;
|
|
19
22
|
};
|
|
20
23
|
/** Effect specification for elements. */
|
|
21
24
|
export interface EffectSpec {
|
|
@@ -27,6 +30,8 @@ export interface EffectSpec {
|
|
|
27
30
|
/** Base element properties. */
|
|
28
31
|
interface BaseElement {
|
|
29
32
|
animate?: KeyframeMap;
|
|
33
|
+
/** How the element's pixels combine with what lies beneath (default `normal`, source-over). */
|
|
34
|
+
blend?: BlendMode;
|
|
30
35
|
dx?: number;
|
|
31
36
|
dy?: number;
|
|
32
37
|
effect?: EffectSpec;
|
|
@@ -36,7 +41,7 @@ interface BaseElement {
|
|
|
36
41
|
/** Text element. */
|
|
37
42
|
export interface TextElement extends BaseElement {
|
|
38
43
|
color?: string;
|
|
39
|
-
font?:
|
|
44
|
+
font?: FontVariant;
|
|
40
45
|
style?: TextStyle;
|
|
41
46
|
text: string;
|
|
42
47
|
type: 'text';
|
|
@@ -66,6 +71,8 @@ export interface RectElement extends BaseElement {
|
|
|
66
71
|
to: string;
|
|
67
72
|
};
|
|
68
73
|
h: number;
|
|
74
|
+
/** `borderColor` border thickness in whole pixels, growing inward (default 1). */
|
|
75
|
+
strokeWidth?: number;
|
|
69
76
|
type: 'rect';
|
|
70
77
|
w: number;
|
|
71
78
|
x: number;
|
|
@@ -73,16 +80,24 @@ export interface RectElement extends BaseElement {
|
|
|
73
80
|
}
|
|
74
81
|
/** Circle element. */
|
|
75
82
|
export interface CircleElement extends BaseElement {
|
|
83
|
+
/** Shade the outline's pixels by coverage (default false). Outline only. */
|
|
84
|
+
antialias?: boolean;
|
|
76
85
|
color?: string;
|
|
77
86
|
cx: number;
|
|
78
87
|
cy: number;
|
|
79
88
|
fill?: boolean;
|
|
80
89
|
radius: number;
|
|
90
|
+
/** Outline thickness in whole pixels, centered on the circle (default 1). Outline only. */
|
|
91
|
+
strokeWidth?: number;
|
|
81
92
|
type: 'circle';
|
|
82
93
|
}
|
|
83
94
|
/** Line element. */
|
|
84
95
|
export interface LineElement extends BaseElement {
|
|
96
|
+
/** Shade the line's pixels by coverage (default false). */
|
|
97
|
+
antialias?: boolean;
|
|
85
98
|
color?: string;
|
|
99
|
+
/** Thickness in whole pixels, centered on the line (default 1). */
|
|
100
|
+
strokeWidth?: number;
|
|
86
101
|
type: 'line';
|
|
87
102
|
x0: number;
|
|
88
103
|
x1: number;
|
|
@@ -132,6 +147,8 @@ export interface PixelsElement extends BaseElement {
|
|
|
132
147
|
}
|
|
133
148
|
/** Image element. */
|
|
134
149
|
export interface ImageElement extends BaseElement {
|
|
150
|
+
/** Palette finish applied to the loaded image before it is drawn. */
|
|
151
|
+
finish?: Finish;
|
|
135
152
|
fit?: 'contain' | 'cover' | 'fill';
|
|
136
153
|
h?: number;
|
|
137
154
|
kernel?: 'nearest' | 'lanczos3' | 'mitchell';
|
|
@@ -154,36 +171,64 @@ export interface SpriteElement extends BaseElement {
|
|
|
154
171
|
y?: number;
|
|
155
172
|
}
|
|
156
173
|
export type SceneElement = TextElement | IconElement | RectElement | CircleElement | LineElement | ProgressElement | SparklineElement | BitmapElement | PixelsElement | ImageElement | SpriteElement;
|
|
174
|
+
/** A sprite sheet downsampled to its cell grid. */
|
|
175
|
+
type SpriteSheet = Awaited<ReturnType<typeof downsampleSprite>>;
|
|
157
176
|
/**
|
|
158
177
|
* Pre-loaded asset cache for images and sprites. Images are keyed by element: the
|
|
159
|
-
* loader bakes
|
|
160
|
-
*
|
|
178
|
+
* loader bakes an image's fit, kernel, size, and position into its canvas, and a
|
|
179
|
+
* `finish` is applied to a copy of it, so elements share a canvas only when they share
|
|
180
|
+
* a source, all of those, and a finish. Sprites are keyed by {@link spriteKey}.
|
|
161
181
|
*/
|
|
162
182
|
export interface AssetCache {
|
|
163
183
|
images: Map<ImageElement, Canvas>;
|
|
164
|
-
sprites: Map<string,
|
|
184
|
+
sprites: Map<string, SpriteSheet>;
|
|
165
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* The message for an image source that was read but did not decode: the source as the
|
|
188
|
+
* caller passed it, then the decoder's reason. Only the reason's first line is kept —
|
|
189
|
+
* libvips repeats itself across several lines on a corrupt header.
|
|
190
|
+
*/
|
|
191
|
+
export declare function decodeFailureMessage(label: string, source: string, err: unknown): string;
|
|
166
192
|
/**
|
|
167
193
|
* Preload all async assets referenced in elements. Images load onto a `size` canvas,
|
|
168
194
|
* the scene's own, so an image with no `w`/`h` fits the display.
|
|
169
195
|
*
|
|
196
|
+
* Each distinct load runs once per call, however many elements share it: a URL is
|
|
197
|
+
* fetched once, a sprite sheet decodes once per grid, and an image decodes once per
|
|
198
|
+
* placement — source, fit, kernel, position, and size, all of which `loadImage` bakes
|
|
199
|
+
* into its canvas. `loadImage` decodes and places in one call, so a source placed two
|
|
200
|
+
* ways decodes twice. An image's `finish` runs once per placement and finish, on the
|
|
201
|
+
* placement's canvas, which it never mutates: elements differing only in `finish` share
|
|
202
|
+
* the decode and nothing after it.
|
|
203
|
+
*
|
|
170
204
|
* `ctx` is threaded through so a remote image fetch correlates to the originating
|
|
171
205
|
* request in logs and traces, and stops when that request is cancelled.
|
|
206
|
+
*
|
|
207
|
+
* @throws {McpError} NotFound with `reason: 'asset_not_found'` for a missing or
|
|
208
|
+
* unreadable path, a sprite path given as a URL, or a URL that cannot be fetched.
|
|
209
|
+
* @throws {McpError} InvalidParams with `reason: 'invalid_image'` for an image source
|
|
210
|
+
* or sprite sheet that was read but did not decode.
|
|
211
|
+
* @throws {Error} The toolkit's `Unknown color` error for an unresolvable `finish`
|
|
212
|
+
* palette entry.
|
|
172
213
|
*/
|
|
173
214
|
export declare function preloadAssets(elements: SceneElement[], ctx: Context, size: PixooSize): Promise<AssetCache>;
|
|
174
215
|
/** Apply a background spec to a canvas. */
|
|
175
216
|
export declare function applyBackground(canvas: Canvas, bg: BackgroundSpec): void;
|
|
217
|
+
/** A scene element's layout entry: elements are placed as given and never refit. */
|
|
218
|
+
export type SceneLayoutEntry = LayoutEntry & {
|
|
219
|
+
action: 'none';
|
|
220
|
+
};
|
|
176
221
|
/** Render a single element onto a canvas at a specific frame. */
|
|
177
|
-
export declare function renderElement(canvas: Canvas, el: SceneElement, elIdx: number, frameIdx: number, totalFrames: number, assets: AssetCache, layoutEntries:
|
|
222
|
+
export declare function renderElement(canvas: Canvas, el: SceneElement, elIdx: number, frameIdx: number, totalFrames: number, assets: AssetCache, layoutEntries: SceneLayoutEntry[]): void;
|
|
178
223
|
/** Render a complete frame. */
|
|
179
224
|
export declare function renderFrame(frameIdx: number, totalFrames: number, background: BackgroundSpec, elements: SceneElement[], assets: AssetCache, size?: 16 | 32 | 64): {
|
|
180
225
|
canvas: Canvas;
|
|
181
|
-
layoutEntries:
|
|
226
|
+
layoutEntries: SceneLayoutEntry[];
|
|
182
227
|
};
|
|
183
228
|
/** Render all frames of a scene. */
|
|
184
229
|
export declare function renderScene(background: BackgroundSpec, elements: SceneElement[], frameCount: number, ctx: Context, size?: PixooSize): Promise<{
|
|
185
230
|
frames: Canvas[];
|
|
186
|
-
layoutEntries:
|
|
231
|
+
layoutEntries: SceneLayoutEntry[];
|
|
187
232
|
}>;
|
|
188
233
|
export {};
|
|
189
234
|
//# sourceMappingURL=scene-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene-renderer.d.ts","sourceRoot":"","sources":["../../src/renderer/scene-renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACL,MAAM,EACN,gBAAgB,
|
|
1
|
+
{"version":3,"file":"scene-renderer.d.ts","sourceRoot":"","sources":["../../src/renderer/scene-renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACL,KAAK,SAAS,EACd,MAAM,EACN,gBAAgB,EAMhB,KAAK,SAAS,EAKf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,aAAa,CAAC;AAEvD,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,WAAW,EAGhB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA+B,KAAK,WAAW,EAAU,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpG;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN;IACE,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3E,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEN,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,UAAU,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