@babylonjs/smart-filters 1.0.13 → 8.19.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/blockFoundation/aggregateBlock.d.ts +3 -3
- package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/aggregateBlock.js +1 -2
- package/dist/blockFoundation/aggregateBlock.js.map +1 -1
- package/dist/blockFoundation/baseBlock.d.ts +2 -2
- package/dist/blockFoundation/baseBlock.d.ts.map +1 -1
- package/dist/blockFoundation/baseBlock.js +5 -6
- package/dist/blockFoundation/baseBlock.js.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.js +2 -2
- package/dist/blockFoundation/customAggregateBlock.js.map +1 -1
- package/dist/blockFoundation/customShaderBlock.d.ts +9 -0
- package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customShaderBlock.js +47 -7
- package/dist/blockFoundation/customShaderBlock.js.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.js +4 -4
- package/dist/blockFoundation/disableableShaderBlock.js.map +1 -1
- package/dist/blockFoundation/index.js +0 -2
- package/dist/blockFoundation/index.js.map +1 -1
- package/dist/blockFoundation/inputBlock.d.ts +8 -8
- package/dist/blockFoundation/inputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -1
- package/dist/blockFoundation/inputBlock.js +7 -7
- package/dist/blockFoundation/inputBlock.js.map +1 -1
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.serializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.serializer.js +26 -28
- package/dist/blockFoundation/inputBlock.serializer.js.map +1 -1
- package/dist/blockFoundation/outputBlock.d.ts +4 -9
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/outputBlock.js +13 -14
- package/dist/blockFoundation/outputBlock.js.map +1 -1
- package/dist/blockFoundation/shaderBlock.d.ts +4 -4
- package/dist/blockFoundation/shaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/shaderBlock.js +13 -19
- package/dist/blockFoundation/shaderBlock.js.map +1 -1
- package/dist/blockFoundation/textureOptions.d.ts +1 -1
- package/dist/blockFoundation/textureOptions.js +1 -1
- package/dist/command/command.d.ts +1 -1
- package/dist/command/command.js +1 -1
- package/dist/command/commandBuffer.d.ts +1 -1
- package/dist/command/commandBuffer.d.ts.map +1 -1
- package/dist/command/commandBuffer.js +2 -2
- package/dist/command/commandBufferDebugger.d.ts +2 -2
- package/dist/command/commandBufferDebugger.d.ts.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/command/index.d.ts +3 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +5 -1
- package/dist/command/index.js.map +1 -1
- package/dist/connection/connectionPoint.d.ts +3 -3
- package/dist/connection/connectionPoint.d.ts.map +1 -1
- package/dist/connection/connectionPoint.js +2 -2
- package/dist/connection/connectionPoint.js.map +1 -1
- package/dist/connection/connectionPointCompatibilityState.d.ts +1 -1
- package/dist/connection/connectionPointCompatibilityState.js +1 -1
- package/dist/connection/connectionPointType.d.ts +3 -3
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.d.ts +3 -3
- package/dist/connection/connectionPointWithDefault.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.js.map +1 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/index.js +3 -3
- package/dist/connection/index.js.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.d.ts +2 -2
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.js +2 -2
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
- package/dist/editorUtils/index.d.ts +1 -0
- package/dist/editorUtils/index.d.ts.map +1 -1
- package/dist/editorUtils/index.js +2 -0
- package/dist/editorUtils/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/optimization/dependencyGraph.js.map +1 -1
- package/dist/optimization/optimizedShaderBlock.d.ts +4 -4
- package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -1
- package/dist/optimization/optimizedShaderBlock.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts +2 -2
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +34 -57
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
- package/dist/runtime/renderTargetGenerator.js +5 -7
- package/dist/runtime/renderTargetGenerator.js.map +1 -1
- package/dist/runtime/shaderRuntime.d.ts +7 -7
- package/dist/runtime/shaderRuntime.d.ts.map +1 -1
- package/dist/runtime/shaderRuntime.js +7 -8
- package/dist/runtime/shaderRuntime.js.map +1 -1
- package/dist/runtime/smartFilterRuntime.d.ts +3 -3
- package/dist/runtime/smartFilterRuntime.d.ts.map +1 -1
- package/dist/runtime/smartFilterRuntime.js.map +1 -1
- package/dist/runtime/strongRef.d.ts +1 -1
- package/dist/runtime/strongRef.js +1 -1
- package/dist/serialization/importCustomBlockDefinition.d.ts +1 -1
- package/dist/serialization/importCustomBlockDefinition.js +8 -9
- package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +2 -2
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +6 -6
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +9 -12
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/serialization/smartFilterSerializer.d.ts +2 -2
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterSerializer.js +10 -13
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +2 -2
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +1 -1
- package/dist/serialization/v1/index.d.ts +1 -0
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +2 -0
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +3 -3
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts +2 -2
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
- package/dist/smartFilter.d.ts +8 -8
- package/dist/smartFilter.d.ts.map +1 -1
- package/dist/smartFilter.js +6 -7
- package/dist/smartFilter.js.map +1 -1
- package/dist/utils/buildTools/buildShaders.d.ts +3 -2
- package/dist/utils/buildTools/buildShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/buildShaders.js +7 -6
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +4 -2
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.js +136 -141
- package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +4 -4
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +55 -48
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -1
- package/dist/utils/buildTools/convertShaders.d.ts +8 -5
- package/dist/utils/buildTools/convertShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/convertShaders.js +38 -14
- package/dist/utils/buildTools/convertShaders.js.map +1 -1
- package/dist/utils/buildTools/shaderConverter.d.ts +4 -4
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +17 -21
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.d.ts +3 -2
- package/dist/utils/buildTools/watchShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +10 -8
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/renderTargetUtils.d.ts +3 -3
- package/dist/utils/renderTargetUtils.d.ts.map +1 -1
- package/dist/utils/renderTargetUtils.js +4 -4
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +8 -8
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js +16 -28
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/dist/utils/textureLoaders.d.ts +2 -2
- package/dist/utils/textureLoaders.d.ts.map +1 -1
- package/dist/utils/textureLoaders.js +2 -3
- package/dist/utils/textureLoaders.js.map +1 -1
- package/dist/utils/textureUtils.d.ts +5 -5
- package/dist/utils/textureUtils.d.ts.map +1 -1
- package/dist/utils/textureUtils.js +1 -1
- package/dist/utils/textureUtils.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/license.md +21 -21
- package/package.json +13 -8
- package/src/blockFoundation/aggregateBlock.ts +148 -151
- package/src/blockFoundation/baseBlock.ts +339 -364
- package/src/blockFoundation/customAggregateBlock.ts +88 -104
- package/src/blockFoundation/customShaderBlock.ts +362 -326
- package/src/blockFoundation/disableableShaderBlock.ts +91 -100
- package/src/blockFoundation/index.ts +9 -9
- package/src/blockFoundation/inputBlock.deserializer.ts +72 -97
- package/src/blockFoundation/inputBlock.serialization.types.ts +126 -132
- package/src/blockFoundation/inputBlock.serializer.ts +150 -150
- package/src/blockFoundation/inputBlock.ts +181 -192
- package/src/blockFoundation/outputBlock.ts +144 -151
- package/src/blockFoundation/shaderBlock.ts +156 -163
- package/src/blockFoundation/textureOptions.ts +57 -57
- package/src/command/command.ts +59 -59
- package/src/command/commandBuffer.ts +71 -71
- package/src/command/commandBufferDebugger.ts +14 -14
- package/src/command/index.ts +7 -3
- package/src/connection/connectionPoint.ts +205 -214
- package/src/connection/connectionPointCompatibilityState.ts +31 -31
- package/src/connection/connectionPointType.ts +45 -45
- package/src/connection/connectionPointWithDefault.ts +27 -35
- package/src/connection/index.ts +8 -9
- package/src/editorUtils/editableInPropertyPage.ts +106 -106
- package/src/editorUtils/index.ts +3 -1
- package/src/index.ts +16 -15
- package/src/optimization/dependencyGraph.ts +96 -96
- package/src/optimization/index.ts +1 -1
- package/src/optimization/optimizedShaderBlock.ts +131 -134
- package/src/optimization/smartFilterOptimizer.ts +757 -825
- package/src/runtime/index.ts +8 -6
- package/src/runtime/renderTargetGenerator.ts +222 -248
- package/src/runtime/shaderRuntime.ts +174 -173
- package/src/runtime/smartFilterRuntime.ts +112 -112
- package/src/runtime/strongRef.ts +18 -18
- package/src/serialization/importCustomBlockDefinition.ts +86 -86
- package/src/serialization/index.ts +10 -7
- package/src/serialization/serializedBlockDefinition.ts +12 -12
- package/src/serialization/serializedShaderBlockDefinition.ts +7 -7
- package/src/serialization/serializedSmartFilter.ts +6 -6
- package/src/serialization/smartFilterDeserializer.ts +190 -220
- package/src/serialization/smartFilterSerializer.ts +110 -121
- package/src/serialization/v1/defaultBlockSerializer.ts +21 -21
- package/src/serialization/v1/index.ts +4 -2
- package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -85
- package/src/serialization/v1/smartFilterSerialization.types.ts +129 -133
- package/src/smartFilter.ts +255 -260
- package/src/utils/buildTools/buildShaders.ts +14 -13
- package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -385
- package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -172
- package/src/utils/buildTools/convertShaders.ts +65 -43
- package/src/utils/buildTools/recordVersionNumber.js +24 -0
- package/src/utils/buildTools/shaderConverter.ts +466 -478
- package/src/utils/buildTools/watchShaders.ts +44 -42
- package/src/utils/index.ts +4 -2
- package/src/utils/renderTargetUtils.ts +30 -35
- package/src/utils/shaderCodeUtils.ts +192 -207
- package/src/utils/textureLoaders.ts +31 -43
- package/src/utils/textureUtils.ts +28 -32
- package/src/version.ts +2 -2
- package/dist/utils/buildTools/determineVersion.d.ts +0 -36
- package/dist/utils/buildTools/determineVersion.d.ts.map +0 -1
- package/dist/utils/buildTools/determineVersion.js +0 -109
- package/dist/utils/buildTools/determineVersion.js.map +0 -1
- package/dist/utils/buildTools/versionUp.d.ts +0 -2
- package/dist/utils/buildTools/versionUp.d.ts.map +0 -1
- package/dist/utils/buildTools/versionUp.js +0 -53
- package/dist/utils/buildTools/versionUp.js.map +0 -1
- package/src/utils/buildTools/determineVersion.ts +0 -128
- package/src/utils/buildTools/versionUp.ts +0 -61
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The format of a texture - corresponds to the Babylon.js TextureFormat constants
|
|
3
|
-
*/
|
|
4
|
-
export enum TextureFormat {
|
|
5
|
-
/** Babylon Constants.TEXTUREFORMAT_RGBA */
|
|
6
|
-
RGBA = 5,
|
|
7
|
-
/** Babylon Constants.TEXTUREFORMAT_R */
|
|
8
|
-
R = 6,
|
|
9
|
-
/** Babylon Constants.TEXTUREFORMAT_RG */
|
|
10
|
-
RG = 7,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The type of a texture - corresponds to the Babylon.js TextureType constants
|
|
15
|
-
*/
|
|
16
|
-
export enum TextureType {
|
|
17
|
-
/** Babylon Constants.TEXTURETYPE_UNSIGNED_BYTE */
|
|
18
|
-
UNSIGNED_BYTE = 0,
|
|
19
|
-
/** Babylon Constants.TEXTURETYPE_FLOAT */
|
|
20
|
-
FLOAT = 1,
|
|
21
|
-
/** Babylon Constants.TEXTURETYPE_HALF_FLOAT */
|
|
22
|
-
HALF_FLOAT = 2,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// IMPORTANT: Update textureOptionsMatch() if you add more fields to OutputTextureOptions
|
|
26
|
-
/**
|
|
27
|
-
* Describes the requirements for the output texture of a shader block.
|
|
28
|
-
*/
|
|
29
|
-
export type OutputTextureOptions = {
|
|
30
|
-
/**
|
|
31
|
-
* The texture size ratio (output size of this block / size of the Smart Filter output)
|
|
32
|
-
*/
|
|
33
|
-
ratio: number;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The format of the texture
|
|
37
|
-
*/
|
|
38
|
-
format: TextureFormat;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The type of the texture
|
|
42
|
-
*/
|
|
43
|
-
type: TextureType;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Compares two OutputTextureOptions to see if they match.
|
|
48
|
-
* @param a - The first OutputTextureOptions
|
|
49
|
-
* @param b - The second OutputTextureOptions
|
|
50
|
-
* @returns True if the two options match, false otherwise
|
|
51
|
-
*/
|
|
52
|
-
export function
|
|
53
|
-
if (a === undefined || b === undefined) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return a.ratio === b.ratio && a.format === b.format && a.type === b.type;
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The format of a texture - corresponds to the Babylon.js TextureFormat constants
|
|
3
|
+
*/
|
|
4
|
+
export enum TextureFormat {
|
|
5
|
+
/** Babylon Constants.TEXTUREFORMAT_RGBA */
|
|
6
|
+
RGBA = 5,
|
|
7
|
+
/** Babylon Constants.TEXTUREFORMAT_R */
|
|
8
|
+
R = 6,
|
|
9
|
+
/** Babylon Constants.TEXTUREFORMAT_RG */
|
|
10
|
+
RG = 7,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The type of a texture - corresponds to the Babylon.js TextureType constants
|
|
15
|
+
*/
|
|
16
|
+
export enum TextureType {
|
|
17
|
+
/** Babylon Constants.TEXTURETYPE_UNSIGNED_BYTE */
|
|
18
|
+
UNSIGNED_BYTE = 0,
|
|
19
|
+
/** Babylon Constants.TEXTURETYPE_FLOAT */
|
|
20
|
+
FLOAT = 1,
|
|
21
|
+
/** Babylon Constants.TEXTURETYPE_HALF_FLOAT */
|
|
22
|
+
HALF_FLOAT = 2,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// IMPORTANT: Update textureOptionsMatch() if you add more fields to OutputTextureOptions
|
|
26
|
+
/**
|
|
27
|
+
* Describes the requirements for the output texture of a shader block.
|
|
28
|
+
*/
|
|
29
|
+
export type OutputTextureOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* The texture size ratio (output size of this block / size of the Smart Filter output)
|
|
32
|
+
*/
|
|
33
|
+
ratio: number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The format of the texture
|
|
37
|
+
*/
|
|
38
|
+
format: TextureFormat;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The type of the texture
|
|
42
|
+
*/
|
|
43
|
+
type: TextureType;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Compares two OutputTextureOptions to see if they match.
|
|
48
|
+
* @param a - The first OutputTextureOptions
|
|
49
|
+
* @param b - The second OutputTextureOptions
|
|
50
|
+
* @returns True if the two options match, false otherwise
|
|
51
|
+
*/
|
|
52
|
+
export function TextureOptionsMatch(a: OutputTextureOptions | undefined, b: OutputTextureOptions | undefined): boolean {
|
|
53
|
+
if (a === undefined || b === undefined) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return a.ratio === b.ratio && a.format === b.format && a.type === b.type;
|
|
57
|
+
}
|
package/src/command/command.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the owner of a command.
|
|
3
|
-
*/
|
|
4
|
-
export interface ICommandOwner {
|
|
5
|
-
/**
|
|
6
|
-
* The friendly name of the owner.
|
|
7
|
-
*/
|
|
8
|
-
readonly name: string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The blockType of the owner;
|
|
12
|
-
*/
|
|
13
|
-
readonly blockType: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents a the action of a @see Command. This is what will be executed during a command buffer execution.
|
|
18
|
-
*/
|
|
19
|
-
export type CommandAction = () => void;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Represents a command to execute.
|
|
23
|
-
*
|
|
24
|
-
* A command contains a function that will be executed at runtime by the smart filter.
|
|
25
|
-
*
|
|
26
|
-
* It also contains the owner of the command for debugging purposes.
|
|
27
|
-
*/
|
|
28
|
-
export type Command = {
|
|
29
|
-
/**
|
|
30
|
-
* The friendly name of the command.
|
|
31
|
-
*/
|
|
32
|
-
readonly name: string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The owner of the command.
|
|
36
|
-
* In practice, it will mostly be a block, the smart filter or a tool injecting commands.
|
|
37
|
-
*/
|
|
38
|
-
readonly owner: ICommandOwner;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Defines the action to execute.
|
|
42
|
-
*/
|
|
43
|
-
readonly action: CommandAction;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Creates a new command.
|
|
48
|
-
* @param name - The friendly name of the command
|
|
49
|
-
* @param owner - The owner of the command
|
|
50
|
-
* @param action - The action to execute when the command is executed
|
|
51
|
-
* @returns The new command
|
|
52
|
-
*/
|
|
53
|
-
export function
|
|
54
|
-
return {
|
|
55
|
-
name,
|
|
56
|
-
owner,
|
|
57
|
-
action,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Represents the owner of a command.
|
|
3
|
+
*/
|
|
4
|
+
export interface ICommandOwner {
|
|
5
|
+
/**
|
|
6
|
+
* The friendly name of the owner.
|
|
7
|
+
*/
|
|
8
|
+
readonly name: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The blockType of the owner;
|
|
12
|
+
*/
|
|
13
|
+
readonly blockType: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents a the action of a @see Command. This is what will be executed during a command buffer execution.
|
|
18
|
+
*/
|
|
19
|
+
export type CommandAction = () => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents a command to execute.
|
|
23
|
+
*
|
|
24
|
+
* A command contains a function that will be executed at runtime by the smart filter.
|
|
25
|
+
*
|
|
26
|
+
* It also contains the owner of the command for debugging purposes.
|
|
27
|
+
*/
|
|
28
|
+
export type Command = {
|
|
29
|
+
/**
|
|
30
|
+
* The friendly name of the command.
|
|
31
|
+
*/
|
|
32
|
+
readonly name: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The owner of the command.
|
|
36
|
+
* In practice, it will mostly be a block, the smart filter or a tool injecting commands.
|
|
37
|
+
*/
|
|
38
|
+
readonly owner: ICommandOwner;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Defines the action to execute.
|
|
42
|
+
*/
|
|
43
|
+
readonly action: CommandAction;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new command.
|
|
48
|
+
* @param name - The friendly name of the command
|
|
49
|
+
* @param owner - The owner of the command
|
|
50
|
+
* @param action - The action to execute when the command is executed
|
|
51
|
+
* @returns The new command
|
|
52
|
+
*/
|
|
53
|
+
export function CreateCommand(name: string, owner: ICommandOwner, action: CommandAction): Command {
|
|
54
|
+
return {
|
|
55
|
+
name,
|
|
56
|
+
owner,
|
|
57
|
+
action,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import type { Command } from "./command";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents the action to run when calling `visitCommands` on a @see CommandBuffer.
|
|
5
|
-
*/
|
|
6
|
-
export type CommandsVisitor = (command: Command) => void;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @see CommandsVisitor used to execute the commands of a @see CommandBuffer.
|
|
10
|
-
* @param command - The command to execute.
|
|
11
|
-
*/
|
|
12
|
-
function
|
|
13
|
-
command.action();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A command buffer is a list of commands to execute.
|
|
18
|
-
* This is used to store the list of tasks the current smart filter needs to execute.
|
|
19
|
-
*/
|
|
20
|
-
export class CommandBuffer {
|
|
21
|
-
private readonly _commands: Command[] = [];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new command buffer.
|
|
25
|
-
* @param args - the list of commands to add to the command buffer
|
|
26
|
-
*/
|
|
27
|
-
constructor(...args: Command[]) {
|
|
28
|
-
for (const command of args) {
|
|
29
|
-
this.push(command);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Adds a command to the command buffer.
|
|
35
|
-
* @param command - the command to add
|
|
36
|
-
*/
|
|
37
|
-
public push(command: Command) {
|
|
38
|
-
this._commands.push(command);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Clears the command buffer and empty the list of commands.
|
|
43
|
-
*/
|
|
44
|
-
public clear() {
|
|
45
|
-
this._commands.length = 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Visits all the commands in the command buffer.
|
|
50
|
-
* @param commandVisitor - The action to execute on each command
|
|
51
|
-
*/
|
|
52
|
-
public visitCommands(commandVisitor: CommandsVisitor): void {
|
|
53
|
-
for (const command of this._commands) {
|
|
54
|
-
commandVisitor(command);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Execute all the commands in the command buffer.
|
|
60
|
-
*/
|
|
61
|
-
public execute() {
|
|
62
|
-
this.visitCommands(
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Dispose the resources associated to the command buffer.
|
|
67
|
-
*/
|
|
68
|
-
public dispose() {
|
|
69
|
-
this.clear();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
1
|
+
import type { Command } from "./command.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the action to run when calling `visitCommands` on a @see CommandBuffer.
|
|
5
|
+
*/
|
|
6
|
+
export type CommandsVisitor = (command: Command) => void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @see CommandsVisitor used to execute the commands of a @see CommandBuffer.
|
|
10
|
+
* @param command - The command to execute.
|
|
11
|
+
*/
|
|
12
|
+
function ExecuteCommandsVisitor(command: Command) {
|
|
13
|
+
command.action();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A command buffer is a list of commands to execute.
|
|
18
|
+
* This is used to store the list of tasks the current smart filter needs to execute.
|
|
19
|
+
*/
|
|
20
|
+
export class CommandBuffer {
|
|
21
|
+
private readonly _commands: Command[] = [];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new command buffer.
|
|
25
|
+
* @param args - the list of commands to add to the command buffer
|
|
26
|
+
*/
|
|
27
|
+
constructor(...args: Command[]) {
|
|
28
|
+
for (const command of args) {
|
|
29
|
+
this.push(command);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Adds a command to the command buffer.
|
|
35
|
+
* @param command - the command to add
|
|
36
|
+
*/
|
|
37
|
+
public push(command: Command) {
|
|
38
|
+
this._commands.push(command);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Clears the command buffer and empty the list of commands.
|
|
43
|
+
*/
|
|
44
|
+
public clear() {
|
|
45
|
+
this._commands.length = 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Visits all the commands in the command buffer.
|
|
50
|
+
* @param commandVisitor - The action to execute on each command
|
|
51
|
+
*/
|
|
52
|
+
public visitCommands(commandVisitor: CommandsVisitor): void {
|
|
53
|
+
for (const command of this._commands) {
|
|
54
|
+
commandVisitor(command);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Execute all the commands in the command buffer.
|
|
60
|
+
*/
|
|
61
|
+
public execute() {
|
|
62
|
+
this.visitCommands(ExecuteCommandsVisitor);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Dispose the resources associated to the command buffer.
|
|
67
|
+
*/
|
|
68
|
+
public dispose() {
|
|
69
|
+
this.clear();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Logger } from "
|
|
2
|
-
import type { CommandBuffer } from "./commandBuffer";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Logs all the commands associated to a command buffer.
|
|
6
|
-
* @param commandBuffer - The command buffer to log
|
|
7
|
-
*/
|
|
8
|
-
export function
|
|
9
|
-
Logger.Log("----- Command buffer commands -----");
|
|
10
|
-
commandBuffer.visitCommands((command) => {
|
|
11
|
-
Logger.Log(` Owner: ${command.owner.blockType} (${command.owner.name}) - Command: ${command.name}`);
|
|
12
|
-
});
|
|
13
|
-
Logger.Log("-----------------------------------");
|
|
14
|
-
}
|
|
1
|
+
import { Logger } from "core/Misc/logger.js";
|
|
2
|
+
import type { CommandBuffer } from "./commandBuffer.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Logs all the commands associated to a command buffer.
|
|
6
|
+
* @param commandBuffer - The command buffer to log
|
|
7
|
+
*/
|
|
8
|
+
export function LogCommands(commandBuffer: Readonly<CommandBuffer>) {
|
|
9
|
+
Logger.Log("----- Command buffer commands -----");
|
|
10
|
+
commandBuffer.visitCommands((command) => {
|
|
11
|
+
Logger.Log(` Owner: ${command.owner.blockType} (${command.owner.name}) - Command: ${command.name}`);
|
|
12
|
+
});
|
|
13
|
+
Logger.Log("-----------------------------------");
|
|
14
|
+
}
|
package/src/command/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export * from "./command.js";
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
export * from "./command.js";
|
|
2
|
+
// Back compat for when camelCase was used
|
|
3
|
+
export { CreateCommand as createCommand } from "./command.js";
|
|
4
|
+
export * from "./commandBuffer.js";
|
|
5
|
+
export { LogCommands } from "./commandBufferDebugger.js";
|
|
6
|
+
// Back compat for when camelCase was used
|
|
7
|
+
export { LogCommands as logCommands } from "./commandBufferDebugger.js";
|