@aelionsdk/material-sdk 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/bundled-schemas.d.ts +5 -0
- package/dist/bundled-schemas.d.ts.map +1 -0
- package/dist/bundled-schemas.js +3 -0
- package/dist/canonical.d.ts +6 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +33 -0
- package/dist/catalog.d.ts +24 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +47 -0
- package/dist/composition.d.ts +42 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +169 -0
- package/dist/definition-builder.d.ts +48 -0
- package/dist/definition-builder.d.ts.map +1 -0
- package/dist/definition-builder.js +159 -0
- package/dist/graph-builder.d.ts +45 -0
- package/dist/graph-builder.d.ts.map +1 -0
- package/dist/graph-builder.js +125 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/lab.d.ts +48 -0
- package/dist/lab.d.ts.map +1 -0
- package/dist/lab.js +169 -0
- package/dist/migration.d.ts +22 -0
- package/dist/migration.d.ts.map +1 -0
- package/dist/migration.js +59 -0
- package/dist/package-limits.d.ts +30 -0
- package/dist/package-limits.d.ts.map +1 -0
- package/dist/package-limits.js +202 -0
- package/dist/package-shape.d.ts +6 -0
- package/dist/package-shape.d.ts.map +1 -0
- package/dist/package-shape.js +547 -0
- package/dist/package-snapshot.d.ts +5 -0
- package/dist/package-snapshot.d.ts.map +1 -0
- package/dist/package-snapshot.js +31 -0
- package/dist/package.d.ts +12 -0
- package/dist/package.d.ts.map +1 -0
- package/dist/package.js +244 -0
- package/dist/registry.d.ts +32 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +150 -0
- package/dist/schema-validation.d.ts +4 -0
- package/dist/schema-validation.d.ts.map +1 -0
- package/dist/schema-validation.js +36 -0
- package/dist/security.d.ts +70 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +161 -0
- package/dist/types.d.ts +245 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/validation.d.ts +6 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +124 -0
- package/dist/zip.d.ts +4 -0
- package/dist/zip.d.ts.map +1 -0
- package/dist/zip.js +172 -0
- package/package.json +46 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { JsonValue } from '@aelionsdk/core';
|
|
2
|
+
import type { GraphBinding, MaterialGraph } from '@aelionsdk/material-compiler';
|
|
3
|
+
export type GraphValueType = 'float' | 'enum' | 'visual-frame';
|
|
4
|
+
export interface GraphValue<T extends GraphValueType> {
|
|
5
|
+
readonly type: T;
|
|
6
|
+
readonly binding: GraphBinding;
|
|
7
|
+
}
|
|
8
|
+
export type FloatValue = GraphValue<'float'>;
|
|
9
|
+
export type EnumValue = GraphValue<'enum'>;
|
|
10
|
+
export type VisualFrameValue = GraphValue<'visual-frame'>;
|
|
11
|
+
export declare class MaterialGraphBuilder {
|
|
12
|
+
#private;
|
|
13
|
+
literal(number: number): FloatValue;
|
|
14
|
+
enum(value_: string): EnumValue;
|
|
15
|
+
parameterFloat(id: string): FloatValue;
|
|
16
|
+
parameterEnum(id: string): EnumValue;
|
|
17
|
+
inputFrame(id: string): VisualFrameValue;
|
|
18
|
+
resource(id: string): GraphValue<'visual-frame'>;
|
|
19
|
+
systemFloat(id: 'sequenceTimeUs' | 'itemTimeUs' | 'itemDurationUs' | 'normalizedItemTime' | 'transitionProgress' | 'frameIndex' | 'frameDurationUs' | 'qualityScale' | 'randomSeed'): FloatValue;
|
|
20
|
+
transitionCurve(id: string, progress: FloatValue, curve: EnumValue): FloatValue;
|
|
21
|
+
mix(id: string, a: VisualFrameValue, b: VisualFrameValue, amount: FloatValue): VisualFrameValue;
|
|
22
|
+
temperature(id: string, source: VisualFrameValue, amount: FloatValue): VisualFrameValue;
|
|
23
|
+
liftBlack(id: string, source: VisualFrameValue, amount: FloatValue): VisualFrameValue;
|
|
24
|
+
extractHighlights(id: string, source: VisualFrameValue, threshold: FloatValue): VisualFrameValue;
|
|
25
|
+
gaussianBlur(id: string, source: VisualFrameValue, radiusPx: FloatValue): VisualFrameValue;
|
|
26
|
+
scaleRgb(id: string, source: VisualFrameValue, scale: FloatValue): VisualFrameValue;
|
|
27
|
+
screen(id: string, base: VisualFrameValue, overlay: VisualFrameValue): VisualFrameValue;
|
|
28
|
+
multiplyFrames(id: string, base: VisualFrameValue, overlay: VisualFrameValue): VisualFrameValue;
|
|
29
|
+
addFrames(id: string, base: VisualFrameValue, overlay: VisualFrameValue): VisualFrameValue;
|
|
30
|
+
exposure(id: string, source: VisualFrameValue, stops: FloatValue): VisualFrameValue;
|
|
31
|
+
contrast(id: string, source: VisualFrameValue, amount: FloatValue): VisualFrameValue;
|
|
32
|
+
saturation(id: string, source: VisualFrameValue, amount: FloatValue): VisualFrameValue;
|
|
33
|
+
invert(id: string, source: VisualFrameValue): VisualFrameValue;
|
|
34
|
+
add(id: string, a: FloatValue, b: FloatValue): FloatValue;
|
|
35
|
+
subtract(id: string, a: FloatValue, b: FloatValue): FloatValue;
|
|
36
|
+
multiply(id: string, a: FloatValue, b: FloatValue): FloatValue;
|
|
37
|
+
divide(id: string, a: FloatValue, b: FloatValue): FloatValue;
|
|
38
|
+
clamp(id: string, input: FloatValue, min: FloatValue, max: FloatValue): FloatValue;
|
|
39
|
+
smoothstep(id: string, edge0: FloatValue, edge1: FloatValue, x: FloatValue): FloatValue;
|
|
40
|
+
output(id: string, frame: VisualFrameValue): this;
|
|
41
|
+
build(): MaterialGraph;
|
|
42
|
+
}
|
|
43
|
+
export declare function materialGraph(build: (graph: MaterialGraphBuilder) => void): MaterialGraph;
|
|
44
|
+
export type MaterialGraphLiteral = JsonValue;
|
|
45
|
+
//# sourceMappingURL=graph-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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AAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,gBAAgB;IAI9D,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU;IAIzD,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU;IAI9D,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU;IAI9D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU;IAI5D,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU;IAIlF,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU;IAIvF,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAQjD,KAAK,IAAI,aAAa;CASvB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,aAAa,CAIzF;AAGD,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { MATERIAL_GRAPH_SCHEMA, MATERIAL_NODE_SET } from './types.js';
|
|
2
|
+
function value(type, binding) {
|
|
3
|
+
return { type, binding };
|
|
4
|
+
}
|
|
5
|
+
export class MaterialGraphBuilder {
|
|
6
|
+
#nodes = [];
|
|
7
|
+
#ids = new Set();
|
|
8
|
+
#outputs = {};
|
|
9
|
+
literal(number) {
|
|
10
|
+
if (!Number.isFinite(number))
|
|
11
|
+
throw new TypeError('Graph literals must be finite');
|
|
12
|
+
return value('float', { value: number });
|
|
13
|
+
}
|
|
14
|
+
enum(value_) {
|
|
15
|
+
return value('enum', { value: value_ });
|
|
16
|
+
}
|
|
17
|
+
parameterFloat(id) {
|
|
18
|
+
return value('float', { parameter: id });
|
|
19
|
+
}
|
|
20
|
+
parameterEnum(id) {
|
|
21
|
+
return value('enum', { parameter: id });
|
|
22
|
+
}
|
|
23
|
+
inputFrame(id) {
|
|
24
|
+
return value('visual-frame', { inputPort: id });
|
|
25
|
+
}
|
|
26
|
+
resource(id) {
|
|
27
|
+
return value('visual-frame', { resource: id });
|
|
28
|
+
}
|
|
29
|
+
systemFloat(id) {
|
|
30
|
+
return value('float', { system: id });
|
|
31
|
+
}
|
|
32
|
+
#node(id, type, inputs, output, outputType) {
|
|
33
|
+
if (this.#ids.has(id))
|
|
34
|
+
throw new TypeError(`Duplicate Material Graph node ${id}`);
|
|
35
|
+
this.#ids.add(id);
|
|
36
|
+
this.#nodes.push({
|
|
37
|
+
id,
|
|
38
|
+
type,
|
|
39
|
+
typeVersion: '1.0.0',
|
|
40
|
+
inputs: Object.fromEntries(Object.entries(inputs).map(([name, input]) => [name, input.binding])),
|
|
41
|
+
});
|
|
42
|
+
return value(outputType, { node: id, output });
|
|
43
|
+
}
|
|
44
|
+
transitionCurve(id, progress, curve) {
|
|
45
|
+
return this.#node(id, 'time.transition-curve', { progress, curve }, 'value', 'float');
|
|
46
|
+
}
|
|
47
|
+
mix(id, a, b, amount) {
|
|
48
|
+
return this.#node(id, 'composite.mix', { a, b, amount }, 'frame', 'visual-frame');
|
|
49
|
+
}
|
|
50
|
+
temperature(id, source, amount) {
|
|
51
|
+
return this.#node(id, 'color.temperature', { source, amount }, 'frame', 'visual-frame');
|
|
52
|
+
}
|
|
53
|
+
liftBlack(id, source, amount) {
|
|
54
|
+
return this.#node(id, 'color.lift-black', { source, amount }, 'frame', 'visual-frame');
|
|
55
|
+
}
|
|
56
|
+
extractHighlights(id, source, threshold) {
|
|
57
|
+
return this.#node(id, 'color.extract-highlights', { source, threshold }, 'frame', 'visual-frame');
|
|
58
|
+
}
|
|
59
|
+
gaussianBlur(id, source, radiusPx) {
|
|
60
|
+
return this.#node(id, 'blur.gaussian', { source, radiusPx }, 'frame', 'visual-frame');
|
|
61
|
+
}
|
|
62
|
+
scaleRgb(id, source, scale) {
|
|
63
|
+
return this.#node(id, 'color.scale-rgb', { source, scale }, 'frame', 'visual-frame');
|
|
64
|
+
}
|
|
65
|
+
screen(id, base, overlay) {
|
|
66
|
+
return this.#node(id, 'composite.screen', { base, overlay }, 'frame', 'visual-frame');
|
|
67
|
+
}
|
|
68
|
+
multiplyFrames(id, base, overlay) {
|
|
69
|
+
return this.#node(id, 'composite.multiply', { base, overlay }, 'frame', 'visual-frame');
|
|
70
|
+
}
|
|
71
|
+
addFrames(id, base, overlay) {
|
|
72
|
+
return this.#node(id, 'composite.add', { base, overlay }, 'frame', 'visual-frame');
|
|
73
|
+
}
|
|
74
|
+
exposure(id, source, stops) {
|
|
75
|
+
return this.#node(id, 'color.exposure', { source, stops }, 'frame', 'visual-frame');
|
|
76
|
+
}
|
|
77
|
+
contrast(id, source, amount) {
|
|
78
|
+
return this.#node(id, 'color.contrast', { source, amount }, 'frame', 'visual-frame');
|
|
79
|
+
}
|
|
80
|
+
saturation(id, source, amount) {
|
|
81
|
+
return this.#node(id, 'color.saturation', { source, amount }, 'frame', 'visual-frame');
|
|
82
|
+
}
|
|
83
|
+
invert(id, source) {
|
|
84
|
+
return this.#node(id, 'color.invert', { source }, 'frame', 'visual-frame');
|
|
85
|
+
}
|
|
86
|
+
add(id, a, b) {
|
|
87
|
+
return this.#node(id, 'math.add', { a, b }, 'value', 'float');
|
|
88
|
+
}
|
|
89
|
+
subtract(id, a, b) {
|
|
90
|
+
return this.#node(id, 'math.subtract', { a, b }, 'value', 'float');
|
|
91
|
+
}
|
|
92
|
+
multiply(id, a, b) {
|
|
93
|
+
return this.#node(id, 'math.multiply', { a, b }, 'value', 'float');
|
|
94
|
+
}
|
|
95
|
+
divide(id, a, b) {
|
|
96
|
+
return this.#node(id, 'math.divide', { a, b }, 'value', 'float');
|
|
97
|
+
}
|
|
98
|
+
clamp(id, input, min, max) {
|
|
99
|
+
return this.#node(id, 'math.clamp', { value: input, min, max }, 'value', 'float');
|
|
100
|
+
}
|
|
101
|
+
smoothstep(id, edge0, edge1, x) {
|
|
102
|
+
return this.#node(id, 'math.smoothstep', { edge0, edge1, x }, 'value', 'float');
|
|
103
|
+
}
|
|
104
|
+
output(id, frame) {
|
|
105
|
+
if (!('node' in frame.binding)) {
|
|
106
|
+
throw new TypeError('A Material Graph output must reference a node output');
|
|
107
|
+
}
|
|
108
|
+
this.#outputs[id] = { node: frame.binding.node, output: frame.binding.output };
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
build() {
|
|
112
|
+
return {
|
|
113
|
+
$schema: MATERIAL_GRAPH_SCHEMA,
|
|
114
|
+
graphVersion: '1.0.0',
|
|
115
|
+
nodeSet: MATERIAL_NODE_SET,
|
|
116
|
+
nodes: this.#nodes.map(node => ({ ...node, inputs: { ...node.inputs } })),
|
|
117
|
+
outputs: { ...this.#outputs },
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function materialGraph(build) {
|
|
122
|
+
const builder = new MaterialGraphBuilder();
|
|
123
|
+
build(builder);
|
|
124
|
+
return builder.build();
|
|
125
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './canonical.js';
|
|
2
|
+
export * from './catalog.js';
|
|
3
|
+
export * from './composition.js';
|
|
4
|
+
export * from './definition-builder.js';
|
|
5
|
+
export * from './graph-builder.js';
|
|
6
|
+
export * from './lab.js';
|
|
7
|
+
export * from './migration.js';
|
|
8
|
+
export { decodeMaterialJson, packMaterialPackage, verifyMaterialPackage } from './package.js';
|
|
9
|
+
export * from './package-limits.js';
|
|
10
|
+
export * from './registry.js';
|
|
11
|
+
export * from './security.js';
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
export * from './validation.js';
|
|
14
|
+
export * from './zip.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC9F,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './canonical.js';
|
|
2
|
+
export * from './catalog.js';
|
|
3
|
+
export * from './composition.js';
|
|
4
|
+
export * from './definition-builder.js';
|
|
5
|
+
export * from './graph-builder.js';
|
|
6
|
+
export * from './lab.js';
|
|
7
|
+
export * from './migration.js';
|
|
8
|
+
export { decodeMaterialJson, packMaterialPackage, verifyMaterialPackage } from './package.js';
|
|
9
|
+
export * from './package-limits.js';
|
|
10
|
+
export * from './registry.js';
|
|
11
|
+
export * from './security.js';
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
export * from './validation.js';
|
|
14
|
+
export * from './zip.js';
|
package/dist/lab.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Diagnostic, JsonValue } from '@aelionsdk/core';
|
|
2
|
+
import { type CompileMaterialOptions, type MaterialExecutionPlan } from '@aelionsdk/material-compiler';
|
|
3
|
+
import type { AuthoredMaterial, MaterialPackageFile, MaterialPackageMetadata, PackedMaterialPackage } from './types.js';
|
|
4
|
+
export interface MaterialLabBudgetReport {
|
|
5
|
+
readonly nodes: number;
|
|
6
|
+
readonly depth: number;
|
|
7
|
+
readonly passes: number;
|
|
8
|
+
readonly textureSamples: number;
|
|
9
|
+
readonly intermediateTextures: number;
|
|
10
|
+
}
|
|
11
|
+
export interface MaterialLabBackendReport {
|
|
12
|
+
readonly available: boolean;
|
|
13
|
+
readonly graphHash?: string;
|
|
14
|
+
readonly executionPlan?: MaterialExecutionPlan;
|
|
15
|
+
readonly error?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MaterialLabReport {
|
|
18
|
+
readonly timeUs: number;
|
|
19
|
+
readonly parameters: Readonly<Record<string, JsonValue>>;
|
|
20
|
+
readonly inputs: Readonly<Record<string, JsonValue>>;
|
|
21
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
22
|
+
readonly budget: MaterialLabBudgetReport;
|
|
23
|
+
readonly webgl2: MaterialLabBackendReport;
|
|
24
|
+
readonly webgpu: MaterialLabBackendReport;
|
|
25
|
+
readonly gpuTimingsUs: readonly number[];
|
|
26
|
+
}
|
|
27
|
+
export interface MaterialGoldenDiff {
|
|
28
|
+
readonly passed: boolean;
|
|
29
|
+
readonly comparedValues: number;
|
|
30
|
+
readonly differingValues: number;
|
|
31
|
+
readonly maximumError: number;
|
|
32
|
+
readonly meanError: number;
|
|
33
|
+
}
|
|
34
|
+
/** Headless Material Lab model shared by UI, CI and package authoring tools. */
|
|
35
|
+
export declare class MaterialLabSession {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(authored: AuthoredMaterial);
|
|
38
|
+
setTime(timeUs: number): void;
|
|
39
|
+
setParameter(id: string, value: JsonValue): void;
|
|
40
|
+
setInput(id: string, descriptor: JsonValue): void;
|
|
41
|
+
recordGpuTiming(totalUs: number): void;
|
|
42
|
+
analyze(options?: {
|
|
43
|
+
readonly budget?: CompileMaterialOptions['budget'];
|
|
44
|
+
}): MaterialLabReport;
|
|
45
|
+
exportPackage(metadata: MaterialPackageMetadata, files?: readonly MaterialPackageFile[]): Promise<PackedMaterialPackage>;
|
|
46
|
+
}
|
|
47
|
+
export declare function compareMaterialGolden(actual: Uint8Array | Uint8ClampedArray, expected: Uint8Array | Uint8ClampedArray, tolerance?: number): MaterialGoldenDiff;
|
|
48
|
+
//# sourceMappingURL=lab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lab.d.ts","sourceRoot":"","sources":["../src/lab.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU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BAAgB,qBAAqB,CACnC,MAAM,EAAE,UAAU,GAAG,iBAAiB,EACtC,QAAQ,EAAE,UAAU,GAAG,iBAAiB,EACxC,SAAS,SAAI,GACZ,kBAAkB,CAqBpB"}
|
package/dist/lab.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { compileMaterialGraph, compileMaterialGraphToWebGl2, compileMaterialGraphToWebGpu, } from '@aelionsdk/material-compiler';
|
|
2
|
+
import { packMaterialPackage } from './package.js';
|
|
3
|
+
import { validateAuthoredMaterial } from './validation.js';
|
|
4
|
+
function compilerType(type) {
|
|
5
|
+
return ['float', 'integer', 'angle', 'duration'].includes(type)
|
|
6
|
+
? 'float'
|
|
7
|
+
: type === 'enum'
|
|
8
|
+
? 'enum'
|
|
9
|
+
: undefined;
|
|
10
|
+
}
|
|
11
|
+
function compileOptions(authored) {
|
|
12
|
+
return {
|
|
13
|
+
parameters: Object.fromEntries(authored.definition.parameters.flatMap(parameter => {
|
|
14
|
+
const type = compilerType(parameter.type);
|
|
15
|
+
return type === undefined ? [] : [[parameter.id, type]];
|
|
16
|
+
})),
|
|
17
|
+
inputPorts: Object.fromEntries(authored.definition.ports
|
|
18
|
+
.filter(port => port.direction === 'input' && port.type === 'visual-frame')
|
|
19
|
+
.map(port => [port.id, 'visual-frame'])),
|
|
20
|
+
systems: {
|
|
21
|
+
sequenceTimeUs: 'float',
|
|
22
|
+
itemTimeUs: 'float',
|
|
23
|
+
itemDurationUs: 'float',
|
|
24
|
+
normalizedItemTime: 'float',
|
|
25
|
+
transitionProgress: 'float',
|
|
26
|
+
frameIndex: 'float',
|
|
27
|
+
frameDurationUs: 'float',
|
|
28
|
+
qualityScale: 'float',
|
|
29
|
+
randomSeed: 'float',
|
|
30
|
+
},
|
|
31
|
+
specializationValues: Object.fromEntries(authored.definition.parameters
|
|
32
|
+
.filter(parameter => parameter.affects === 'specialization')
|
|
33
|
+
.map(parameter => [parameter.id, parameter.default])),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function backendReport(operation) {
|
|
37
|
+
try {
|
|
38
|
+
const value = operation();
|
|
39
|
+
return { available: true, graphHash: value.graphHash, executionPlan: value.executionPlan };
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return { available: false, error: error instanceof Error ? error.message : 'Backend failed' };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function validParameterValue(type, value) {
|
|
46
|
+
if (type === 'boolean')
|
|
47
|
+
return typeof value === 'boolean';
|
|
48
|
+
if (['integer', 'duration'].includes(type))
|
|
49
|
+
return typeof value === 'number' && Number.isSafeInteger(value);
|
|
50
|
+
if (['float', 'angle'].includes(type))
|
|
51
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
52
|
+
if (type === 'enum' || type === 'string')
|
|
53
|
+
return typeof value === 'string';
|
|
54
|
+
return value !== null;
|
|
55
|
+
}
|
|
56
|
+
/** Headless Material Lab model shared by UI, CI and package authoring tools. */
|
|
57
|
+
export class MaterialLabSession {
|
|
58
|
+
#authored;
|
|
59
|
+
#parameters;
|
|
60
|
+
#inputs = {};
|
|
61
|
+
#gpuTimingsUs = [];
|
|
62
|
+
#timeUs = 0;
|
|
63
|
+
constructor(authored) {
|
|
64
|
+
this.#authored = structuredClone(authored);
|
|
65
|
+
this.#parameters = Object.fromEntries(authored.definition.parameters.map(parameter => [
|
|
66
|
+
parameter.id,
|
|
67
|
+
structuredClone(parameter.default),
|
|
68
|
+
]));
|
|
69
|
+
}
|
|
70
|
+
setTime(timeUs) {
|
|
71
|
+
if (!Number.isSafeInteger(timeUs) || timeUs < 0)
|
|
72
|
+
throw new RangeError('MATERIAL_LAB_TIME_INVALID');
|
|
73
|
+
this.#timeUs = timeUs;
|
|
74
|
+
}
|
|
75
|
+
setParameter(id, value) {
|
|
76
|
+
const definition = this.#authored.definition.parameters.find(parameter => parameter.id === id);
|
|
77
|
+
if (definition === undefined)
|
|
78
|
+
throw new ReferenceError(`MATERIAL_LAB_PARAMETER_MISSING: ${id}`);
|
|
79
|
+
if (!validParameterValue(definition.type, value)) {
|
|
80
|
+
throw new TypeError(`MATERIAL_LAB_PARAMETER_TYPE_INVALID: ${id}`);
|
|
81
|
+
}
|
|
82
|
+
if (typeof value === 'number' &&
|
|
83
|
+
((definition.range?.min !== undefined && value < definition.range.min) ||
|
|
84
|
+
(definition.range?.max !== undefined && value > definition.range.max))) {
|
|
85
|
+
throw new RangeError(`MATERIAL_LAB_PARAMETER_RANGE_INVALID: ${id}`);
|
|
86
|
+
}
|
|
87
|
+
this.#parameters[id] = structuredClone(value);
|
|
88
|
+
}
|
|
89
|
+
setInput(id, descriptor) {
|
|
90
|
+
const port = this.#authored.definition.ports.find(value => value.id === id && value.direction === 'input');
|
|
91
|
+
if (port === undefined)
|
|
92
|
+
throw new ReferenceError(`MATERIAL_LAB_INPUT_MISSING: ${id}`);
|
|
93
|
+
this.#inputs[id] = structuredClone(descriptor);
|
|
94
|
+
}
|
|
95
|
+
recordGpuTiming(totalUs) {
|
|
96
|
+
if (!Number.isSafeInteger(totalUs) || totalUs < 0)
|
|
97
|
+
throw new RangeError('GPU_TIMING_INVALID');
|
|
98
|
+
this.#gpuTimingsUs.push(totalUs);
|
|
99
|
+
if (this.#gpuTimingsUs.length > 256)
|
|
100
|
+
this.#gpuTimingsUs.shift();
|
|
101
|
+
}
|
|
102
|
+
analyze(options = {}) {
|
|
103
|
+
const validation = validateAuthoredMaterial(this.#authored, options);
|
|
104
|
+
const graph = this.#authored.graph;
|
|
105
|
+
if (graph === undefined) {
|
|
106
|
+
return {
|
|
107
|
+
timeUs: this.#timeUs,
|
|
108
|
+
parameters: structuredClone(this.#parameters),
|
|
109
|
+
inputs: structuredClone(this.#inputs),
|
|
110
|
+
diagnostics: validation.diagnostics,
|
|
111
|
+
budget: { nodes: 0, depth: 0, passes: 0, textureSamples: 0, intermediateTextures: 0 },
|
|
112
|
+
webgl2: { available: false, error: 'Material has no graph implementation' },
|
|
113
|
+
webgpu: { available: false, error: 'Material has no graph implementation' },
|
|
114
|
+
gpuTimingsUs: [...this.#gpuTimingsUs],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const compile = {
|
|
118
|
+
...compileOptions(this.#authored),
|
|
119
|
+
...(options.budget === undefined ? {} : { budget: options.budget }),
|
|
120
|
+
};
|
|
121
|
+
const analysis = compileMaterialGraph(graph, compile);
|
|
122
|
+
const webgl2 = backendReport(() => compileMaterialGraphToWebGl2(graph, compile));
|
|
123
|
+
const webgpu = backendReport(() => compileMaterialGraphToWebGpu(graph, compile));
|
|
124
|
+
const plan = webgl2.executionPlan ?? webgpu.executionPlan;
|
|
125
|
+
return {
|
|
126
|
+
timeUs: this.#timeUs,
|
|
127
|
+
parameters: structuredClone(this.#parameters),
|
|
128
|
+
inputs: structuredClone(this.#inputs),
|
|
129
|
+
diagnostics: [...validation.diagnostics, ...analysis.diagnostics],
|
|
130
|
+
budget: {
|
|
131
|
+
nodes: analysis.order.length,
|
|
132
|
+
depth: analysis.depth,
|
|
133
|
+
passes: plan?.passes.length ?? analysis.estimatedPasses,
|
|
134
|
+
textureSamples: analysis.estimatedTextureSamples,
|
|
135
|
+
intermediateTextures: plan?.intermediateTextureCount ?? 0,
|
|
136
|
+
},
|
|
137
|
+
webgl2,
|
|
138
|
+
webgpu,
|
|
139
|
+
gpuTimingsUs: [...this.#gpuTimingsUs],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exportPackage(metadata, files = []) {
|
|
143
|
+
return packMaterialPackage({ metadata, materials: [this.#authored], files });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function compareMaterialGolden(actual, expected, tolerance = 2) {
|
|
147
|
+
if (actual.length !== expected.length)
|
|
148
|
+
throw new RangeError('MATERIAL_GOLDEN_SIZE_MISMATCH');
|
|
149
|
+
if (!Number.isSafeInteger(tolerance) || tolerance < 0 || tolerance > 255) {
|
|
150
|
+
throw new RangeError('MATERIAL_GOLDEN_TOLERANCE_INVALID');
|
|
151
|
+
}
|
|
152
|
+
let differingValues = 0;
|
|
153
|
+
let maximumError = 0;
|
|
154
|
+
let totalError = 0;
|
|
155
|
+
for (let index = 0; index < actual.length; index++) {
|
|
156
|
+
const error = Math.abs((actual[index] ?? 0) - (expected[index] ?? 0));
|
|
157
|
+
if (error > tolerance)
|
|
158
|
+
differingValues++;
|
|
159
|
+
maximumError = Math.max(maximumError, error);
|
|
160
|
+
totalError += error;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
passed: differingValues === 0,
|
|
164
|
+
comparedValues: actual.length,
|
|
165
|
+
differingValues,
|
|
166
|
+
maximumError,
|
|
167
|
+
meanError: actual.length === 0 ? 0 : totalError / actual.length,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JsonValue } from '@aelionsdk/core';
|
|
2
|
+
export type MaterialMigrationDomain = 'protocol' | 'package' | 'definition' | 'node-set';
|
|
3
|
+
export interface MaterialMigration {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly domain: MaterialMigrationDomain;
|
|
6
|
+
readonly from: string;
|
|
7
|
+
readonly to: string;
|
|
8
|
+
migrate(value: JsonValue): JsonValue;
|
|
9
|
+
}
|
|
10
|
+
export interface MaterialMigrationReport {
|
|
11
|
+
readonly domain: MaterialMigrationDomain;
|
|
12
|
+
readonly from: string;
|
|
13
|
+
readonly to: string;
|
|
14
|
+
readonly migrationIds: readonly string[];
|
|
15
|
+
readonly value: JsonValue;
|
|
16
|
+
}
|
|
17
|
+
export declare class MaterialMigrationRegistry {
|
|
18
|
+
#private;
|
|
19
|
+
register(migration: MaterialMigration): void;
|
|
20
|
+
migrate(domain: MaterialMigrationDomain, from: string, to: string, input: JsonValue): MaterialMigrationReport;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,CAAC;AAEzF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAQD,qBAAa,yBAAyB;;IAG7B,QAAQ,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAQ5C,OAAO,CACZ,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,SAAS,GACf,uBAAuB;CAiD3B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { canonicalMaterialBytes } from './canonical.js';
|
|
2
|
+
function equalBytes(left, right) {
|
|
3
|
+
return (left.byteLength === right.byteLength && left.every((value, index) => value === right[index]));
|
|
4
|
+
}
|
|
5
|
+
export class MaterialMigrationRegistry {
|
|
6
|
+
#migrations = new Map();
|
|
7
|
+
register(migration) {
|
|
8
|
+
const key = this.#key(migration.domain, migration.from, migration.to);
|
|
9
|
+
if (migration.id.length === 0 || migration.from === migration.to || this.#migrations.has(key)) {
|
|
10
|
+
throw new TypeError('MATERIAL_MIGRATION_INVALID');
|
|
11
|
+
}
|
|
12
|
+
this.#migrations.set(key, migration);
|
|
13
|
+
}
|
|
14
|
+
migrate(domain, from, to, input) {
|
|
15
|
+
if (from === to) {
|
|
16
|
+
return { domain, from, to, migrationIds: [], value: structuredClone(input) };
|
|
17
|
+
}
|
|
18
|
+
const path = this.#path(domain, from, to);
|
|
19
|
+
if (path === undefined)
|
|
20
|
+
throw new ReferenceError(`MATERIAL_MIGRATION_MISSING: ${from} -> ${to}`);
|
|
21
|
+
let value = structuredClone(input);
|
|
22
|
+
for (const migration of path) {
|
|
23
|
+
const first = migration.migrate(structuredClone(value));
|
|
24
|
+
const second = migration.migrate(structuredClone(value));
|
|
25
|
+
if (!equalBytes(canonicalMaterialBytes(first), canonicalMaterialBytes(second))) {
|
|
26
|
+
throw new TypeError(`MATERIAL_MIGRATION_NON_DETERMINISTIC: ${migration.id}`);
|
|
27
|
+
}
|
|
28
|
+
value = structuredClone(first);
|
|
29
|
+
}
|
|
30
|
+
return { domain, from, to, migrationIds: path.map(value => value.id), value };
|
|
31
|
+
}
|
|
32
|
+
#path(domain, from, to) {
|
|
33
|
+
const queue = [
|
|
34
|
+
{ version: from, path: [] },
|
|
35
|
+
];
|
|
36
|
+
const visited = new Set([from]);
|
|
37
|
+
while (queue.length > 0) {
|
|
38
|
+
const current = queue.shift();
|
|
39
|
+
if (current === undefined)
|
|
40
|
+
break;
|
|
41
|
+
const next = [...this.#migrations.values()]
|
|
42
|
+
.filter(value => value.domain === domain && value.from === current.version)
|
|
43
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
44
|
+
for (const migration of next) {
|
|
45
|
+
const path = [...current.path, migration];
|
|
46
|
+
if (migration.to === to)
|
|
47
|
+
return path;
|
|
48
|
+
if (!visited.has(migration.to)) {
|
|
49
|
+
visited.add(migration.to);
|
|
50
|
+
queue.push({ version: migration.to, path });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
#key(domain, from, to) {
|
|
57
|
+
return `${domain}\0${from}\0${to}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MaterialPackageByteLimitOptions, MaterialPackageByteLimits, PackedMaterialPackage } from './types.js';
|
|
2
|
+
export declare const MATERIAL_PACKAGE_MAX_FILES = 256;
|
|
3
|
+
export declare const MATERIAL_PACKAGE_MAX_FILE_BYTES: number;
|
|
4
|
+
export declare const MATERIAL_PACKAGE_MAX_MANIFEST_BYTES: number;
|
|
5
|
+
export declare const MATERIAL_PACKAGE_MAX_BYTES: number;
|
|
6
|
+
export declare const MATERIAL_PACKAGE_MAX_ARCHIVE_BYTES: number;
|
|
7
|
+
export declare const DEFAULT_MATERIAL_PACKAGE_BYTE_LIMITS: MaterialPackageByteLimits;
|
|
8
|
+
export interface InspectedMaterialPackageFile {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly data: Uint8Array;
|
|
11
|
+
readonly byteLength: number;
|
|
12
|
+
}
|
|
13
|
+
export interface MaterialPackageTransportInspection {
|
|
14
|
+
readonly limits: MaterialPackageByteLimits;
|
|
15
|
+
readonly integrity: PackedMaterialPackage['integrity'];
|
|
16
|
+
readonly manifestBytes: Uint8Array;
|
|
17
|
+
readonly manifestByteLength: number;
|
|
18
|
+
readonly archiveBytes: Uint8Array;
|
|
19
|
+
readonly archiveByteLength: number;
|
|
20
|
+
readonly files: readonly InspectedMaterialPackageFile[];
|
|
21
|
+
readonly packageBytes: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function materialPackageBudgetExceeded(scope: string, actual: number, limit: number): never;
|
|
24
|
+
export declare function resolveMaterialPackageByteLimits(options?: MaterialPackageByteLimitOptions): MaterialPackageByteLimits;
|
|
25
|
+
export declare function addMaterialPackageBytes(total: number, value: number, scope: string): number;
|
|
26
|
+
export declare function materialUint8ArrayByteLength(value: unknown, scope: string): number;
|
|
27
|
+
export declare function copyMaterialBytes(value: Uint8Array, expectedByteLength: number, scope: string): Uint8Array;
|
|
28
|
+
export declare function validMaterialPackagePath(path: unknown): path is string;
|
|
29
|
+
export declare function inspectPackedMaterialPackage(packed: PackedMaterialPackage, options?: MaterialPackageByteLimitOptions): MaterialPackageTransportInspection;
|
|
30
|
+
//# sourceMappingURL=package-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-limits.d.ts","sourceRoot":"","sources":["../src/package-limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,+BAA+B,QAAmB,CAAC;AAChE,eAAO,MAAM,mCAAmC,QAAa,CAAC;AAC9D,eAAO,MAAM,0BAA0B,QAAmB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,QAAmB,CAAC;AA+BnE,eAAO,MAAM,oCAAoC,EAAE,yBAMjD,CAAC;AAEH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACvD,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAClC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACxD,QAAQ,CAAC,Y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