@galacean/engine-design 2.0.0-alpha.52 → 2.0.0-alpha.54
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/main.js +1094 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +1081 -0
- package/dist/module.js.map +1 -0
- package/package.json +3 -2
- package/types/physics/ICollider.d.ts +4 -3
- package/types/physics/IPhysicsScene.d.ts +81 -36
- package/types/physics/shape/IColliderShape.d.ts +5 -0
- package/types/shader-compiler/ICondition.d.ts +88 -7
- package/types/shader-compiler/IShaderCompiler.d.ts +17 -9
- package/types/shader-compiler/IShaderProgramSource.d.ts +5 -0
- package/types/shader-compiler/PreprocessorExpression.d.ts +174 -0
- package/types/shader-compiler/ShaderIncludePath.d.ts +7 -0
- package/types/shader-compiler/index.d.ts +8 -6
- package/types/shader-compiler/shaderSource/IShaderPassSource.d.ts +21 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { Condition } from "./ICondition";
|
|
2
|
+
/**
|
|
3
|
+
* Location and certainty of a preprocessor-expression parse failure.
|
|
4
|
+
*/
|
|
5
|
+
export interface PreprocessorExpressionParseError {
|
|
6
|
+
/** Human-readable syntax error. */
|
|
7
|
+
readonly message: string;
|
|
8
|
+
/** Zero-based start offset in the expression. */
|
|
9
|
+
readonly start: number;
|
|
10
|
+
/** Zero-based exclusive end offset in the expression. */
|
|
11
|
+
readonly end: number;
|
|
12
|
+
/** Whether macro expansion cannot make the expression valid. */
|
|
13
|
+
readonly certain: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Successful preprocessor-expression parse.
|
|
17
|
+
*/
|
|
18
|
+
export interface ParsedPreprocessorExpression {
|
|
19
|
+
readonly ok: true;
|
|
20
|
+
/** Serializable expression tree. */
|
|
21
|
+
readonly condition: Condition;
|
|
22
|
+
/** Whether evaluation depends on macro replacement text. */
|
|
23
|
+
readonly hasExpandableIdentifier: boolean;
|
|
24
|
+
/** Definite evaluation failure that is independent of macro state. */
|
|
25
|
+
readonly evaluationError?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Failed preprocessor-expression parse.
|
|
29
|
+
*/
|
|
30
|
+
export interface InvalidPreprocessorExpression {
|
|
31
|
+
readonly ok: false;
|
|
32
|
+
/** Structured parse failure. */
|
|
33
|
+
readonly error: PreprocessorExpressionParseError;
|
|
34
|
+
/** Whether an identifier may expand into missing syntax. */
|
|
35
|
+
readonly hasExpandableIdentifier: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of parsing a preprocessor expression.
|
|
39
|
+
*/
|
|
40
|
+
export type PreprocessorExpressionParseResult = ParsedPreprocessorExpression | InvalidPreprocessorExpression;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves identifiers and macro-definition checks while evaluating an expression tree.
|
|
43
|
+
*/
|
|
44
|
+
export interface PreprocessorExpressionContext {
|
|
45
|
+
/**
|
|
46
|
+
* Resolves an identifier to a signed 32-bit integer.
|
|
47
|
+
* @param name - Macro identifier.
|
|
48
|
+
* @returns Resolved integer value; undefined identifiers return zero.
|
|
49
|
+
*/
|
|
50
|
+
resolveIdentifier(name: string): number;
|
|
51
|
+
/**
|
|
52
|
+
* Tests whether a macro exists.
|
|
53
|
+
* @param name - Macro identifier.
|
|
54
|
+
* @returns Whether the identifier is defined.
|
|
55
|
+
*/
|
|
56
|
+
isDefined(name: string): boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the subset of macro state known during source preprocessing.
|
|
60
|
+
*
|
|
61
|
+
* `undefined` means that the caller must preserve both possibilities. This keeps include
|
|
62
|
+
* reachability conservative when a macro may be supplied by the runtime configuration.
|
|
63
|
+
*/
|
|
64
|
+
export interface PartiallyKnownPreprocessorExpressionContext {
|
|
65
|
+
/**
|
|
66
|
+
* Resolves an identifier against known source macro state.
|
|
67
|
+
* @param name - Macro identifier.
|
|
68
|
+
* @returns Known value, definite error, or an empty result when the value depends on external macro state.
|
|
69
|
+
*/
|
|
70
|
+
resolveIdentifier(name: string): PartiallyKnownPreprocessorExpressionResult;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves whether a macro is defined.
|
|
73
|
+
* @param name - Macro identifier.
|
|
74
|
+
* @returns Known definition state, or `undefined` when supplied externally.
|
|
75
|
+
*/
|
|
76
|
+
isDefined(name: string): boolean | undefined;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Result of evaluating an expression against incomplete macro state.
|
|
80
|
+
*/
|
|
81
|
+
export interface PartiallyKnownPreprocessorExpressionResult {
|
|
82
|
+
/** Known signed 32-bit value, absent when external macro state still matters. */
|
|
83
|
+
readonly value?: number;
|
|
84
|
+
/** Definite failure reached without assuming an external macro value. */
|
|
85
|
+
readonly error?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* One object-like or function-like shader macro.
|
|
89
|
+
*/
|
|
90
|
+
export interface PreprocessorExpressionMacro {
|
|
91
|
+
/** Replacement-list source before parameter substitution. */
|
|
92
|
+
readonly body: string;
|
|
93
|
+
/** Function parameters; absent for an object-like macro. */
|
|
94
|
+
readonly parameters?: readonly string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Result of token-aware preprocessor-expression macro expansion.
|
|
98
|
+
*/
|
|
99
|
+
export interface PreprocessorExpressionExpansionResult {
|
|
100
|
+
/** Comment-free, token-normalized expanded expression. */
|
|
101
|
+
readonly expression: string;
|
|
102
|
+
/** Deterministic expansion failure. */
|
|
103
|
+
readonly error?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Result of shader source macro expansion, including a deterministic failure when expansion stops.
|
|
107
|
+
*/
|
|
108
|
+
export interface ShaderMacroExpansionResult {
|
|
109
|
+
/** Expanded source with preprocessing token boundaries and comments preserved. */
|
|
110
|
+
readonly source: string;
|
|
111
|
+
/** Deterministic expansion failure. */
|
|
112
|
+
readonly error?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Parses the complete integer-expression grammar used by `#if` and `#elif`.
|
|
116
|
+
* @param expression - Text after the preprocessor directive.
|
|
117
|
+
* @returns A serializable tree or a structured parse failure.
|
|
118
|
+
*/
|
|
119
|
+
export declare function parsePreprocessorExpression(expression: string): PreprocessorExpressionParseResult;
|
|
120
|
+
/**
|
|
121
|
+
* Resolves `defined` operators and removes comments with the expression parser's tokenization rules.
|
|
122
|
+
* @param expression - Expression before ordinary macro replacement.
|
|
123
|
+
* @param isDefined - Resolves whether one macro name is defined, or returns `undefined` when external state decides.
|
|
124
|
+
* @returns Token-normalized expression with every known `defined` operator replaced by `0` or `1`.
|
|
125
|
+
*/
|
|
126
|
+
export declare function resolvePreprocessorDefinedOperators(expression: string, isDefined: (name: string) => boolean | undefined): string;
|
|
127
|
+
/**
|
|
128
|
+
* Expands object-like and function-like macros with the expression parser's tokenization rules.
|
|
129
|
+
* @param expression - Expression after any caller-owned `defined` resolution.
|
|
130
|
+
* @param resolveMacro - Resolves source or runtime macro definitions by name.
|
|
131
|
+
* @returns Token-normalized expansion or a deterministic depth error.
|
|
132
|
+
*/
|
|
133
|
+
export declare function expandPreprocessorExpressionMacros(expression: string, resolveMacro: (name: string) => PreprocessorExpressionMacro | undefined): PreprocessorExpressionExpansionResult;
|
|
134
|
+
/**
|
|
135
|
+
* Expands shader macros using the same argument prescan and rescan rules as conditional expressions.
|
|
136
|
+
* @param source - Shader text without macro definition or conditional directives.
|
|
137
|
+
* @param resolveMacro - Resolves the macro state active at this source location.
|
|
138
|
+
* @returns Expanded shader source, or a deterministic expansion-limit error.
|
|
139
|
+
*/
|
|
140
|
+
export declare function expandShaderMacros(source: string, resolveMacro: (name: string) => PreprocessorExpressionMacro | undefined): ShaderMacroExpansionResult;
|
|
141
|
+
/**
|
|
142
|
+
* Evaluates an expression whose result is independent of macro state.
|
|
143
|
+
* @param expression - Complete preprocessor expression text.
|
|
144
|
+
* @returns 32-bit result, or `undefined` when the expression is invalid, state-dependent, or unevaluable.
|
|
145
|
+
*/
|
|
146
|
+
export declare function evaluateContextFreePreprocessorExpression(expression: string): number | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Evaluates a parsed condition whose result is independent of macro state.
|
|
149
|
+
* @param condition - Parsed preprocessor expression tree.
|
|
150
|
+
* @returns 32-bit result, or `undefined` when macro state or an invalid operation affects the result.
|
|
151
|
+
*/
|
|
152
|
+
export declare function evaluateContextFreePreprocessorCondition(condition: Condition): number | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Evaluates the part of a preprocessor expression determined by known source macro state.
|
|
155
|
+
* @param condition - Parsed preprocessor expression tree.
|
|
156
|
+
* @param context - Partially known macro values and definition states.
|
|
157
|
+
* @returns 32-bit result, or `undefined` when any reachable input remains unknown.
|
|
158
|
+
*/
|
|
159
|
+
export declare function evaluatePartiallyKnownPreprocessorCondition(condition: Condition, context: PartiallyKnownPreprocessorExpressionContext): number | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Evaluates the known portion of an expression while preserving definite evaluation failures.
|
|
162
|
+
* @param condition - Parsed preprocessor expression tree.
|
|
163
|
+
* @param context - Partially known macro values and definition states.
|
|
164
|
+
* @returns Known value, definite error, or an empty result when external state still matters.
|
|
165
|
+
*/
|
|
166
|
+
export declare function evaluatePartiallyKnownPreprocessorConditionResult(condition: Condition, context: PartiallyKnownPreprocessorExpressionContext): PartiallyKnownPreprocessorExpressionResult;
|
|
167
|
+
/**
|
|
168
|
+
* Evaluates a parsed preprocessor expression with signed 32-bit arithmetic matching ANGLE's preprocessor.
|
|
169
|
+
* @param condition - Serializable expression tree.
|
|
170
|
+
* @param context - Active macro value and definition resolver.
|
|
171
|
+
* @returns Signed 32-bit result; nonzero values are true.
|
|
172
|
+
* @throws Error when an active expression divides by zero or contains a deferred node.
|
|
173
|
+
*/
|
|
174
|
+
export declare function evaluatePreprocessorExpression(condition: Condition, context: PreprocessorExpressionContext): number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a registered shader-include key to its canonical lookup form.
|
|
3
|
+
* @param includeKey - Logical project path, project-root path, or absolute URL.
|
|
4
|
+
* @returns Canonical registry key without the virtual shader-root prefix.
|
|
5
|
+
* @throws Error when the key is empty or an absolute URL is malformed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeShaderIncludeKey(includeKey: string): string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export type { IShaderCompiler } from "./IShaderCompiler";
|
|
2
|
-
export type { Condition, DefinedCondition, NotDefinedCondition, CompareCondition, BoolCondition, ShaderInstruction } from "./ICondition";
|
|
2
|
+
export type { Condition, DefinedCondition, NotDefinedCondition, CompareCondition, BoolCondition, NumericCondition, IdentifierCondition, UnaryCondition, BinaryCondition, DeferredCondition, ShaderInstruction } from "./ICondition";
|
|
3
|
+
export * from "./PreprocessorExpression";
|
|
4
|
+
export * from "./ShaderIncludePath";
|
|
3
5
|
export type { IPrecompiledShader, IPrecompiledSubShader, IPrecompiledPass } from "./IPrecompiledShader";
|
|
4
6
|
export type { IShaderProgramSource as IShaderInfo } from "./IShaderProgramSource";
|
|
5
|
-
export { IRenderStates } from "./shaderSource/IRenderStates";
|
|
6
|
-
export { IShaderPassSource } from "./shaderSource/IShaderPassSource";
|
|
7
|
-
export { IShaderPosition } from "./shaderSource/IShaderPosition";
|
|
7
|
+
export type { IRenderStates } from "./shaderSource/IRenderStates";
|
|
8
|
+
export type { IShaderPassSource } from "./shaderSource/IShaderPassSource";
|
|
9
|
+
export type { IShaderPosition } from "./shaderSource/IShaderPosition";
|
|
8
10
|
export type { IShaderSource } from "./shaderSource/IShaderSource";
|
|
9
|
-
export { IStatement } from "./shaderSource/IStatement";
|
|
10
|
-
export { ISubShaderSource } from "./shaderSource/ISubShaderSource";
|
|
11
|
+
export type { IStatement } from "./shaderSource/IStatement";
|
|
12
|
+
export type { ISubShaderSource } from "./shaderSource/ISubShaderSource";
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { IRenderStates } from "./IRenderStates";
|
|
2
|
+
import { IShaderPosition } from "./IShaderPosition";
|
|
2
3
|
import { IStatement } from "./IStatement";
|
|
4
|
+
/** Parsed ShaderLab pass structure before backend generation. */
|
|
3
5
|
export interface IShaderPassSource {
|
|
6
|
+
/** Pass name. */
|
|
4
7
|
name: string;
|
|
8
|
+
/** ShaderLab statements inherited by or declared on the pass. */
|
|
5
9
|
pendingContents: IStatement[];
|
|
10
|
+
/** Whether the pass references another pass through `UsePass`. */
|
|
6
11
|
isUsePass: boolean;
|
|
12
|
+
/** User-defined pass tags. */
|
|
7
13
|
tags?: Record<string, number | string | boolean>;
|
|
14
|
+
/** Parsed render-state constants and variables. */
|
|
8
15
|
renderStates: IRenderStates;
|
|
9
16
|
/** Shader source code. */
|
|
10
17
|
contents: string;
|
|
18
|
+
/** Start offsets of Shader, SubShader, and Pass content layers in `contents`. */
|
|
19
|
+
contentScopeStarts: readonly number[];
|
|
20
|
+
/** Vertex entry-point name. */
|
|
11
21
|
vertexEntry: string;
|
|
22
|
+
/** Fragment entry-point name. */
|
|
12
23
|
fragmentEntry: string;
|
|
24
|
+
/** Source range of the vertex entry-point name. */
|
|
25
|
+
vertexEntryLocation?: {
|
|
26
|
+
start: IShaderPosition;
|
|
27
|
+
end: IShaderPosition;
|
|
28
|
+
};
|
|
29
|
+
/** Source range of the fragment entry-point name. */
|
|
30
|
+
fragmentEntryLocation?: {
|
|
31
|
+
start: IShaderPosition;
|
|
32
|
+
end: IShaderPosition;
|
|
33
|
+
};
|
|
13
34
|
}
|