@onerjs/smart-filters 8.25.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.
Files changed (66) hide show
  1. package/license.md +21 -0
  2. package/package.json +52 -0
  3. package/readme.md +9 -0
  4. package/src/IDisposable.ts +9 -0
  5. package/src/blockFoundation/aggregateBlock.ts +148 -0
  6. package/src/blockFoundation/baseBlock.ts +339 -0
  7. package/src/blockFoundation/customAggregateBlock.ts +88 -0
  8. package/src/blockFoundation/customShaderBlock.ts +362 -0
  9. package/src/blockFoundation/disableableShaderBlock.ts +91 -0
  10. package/src/blockFoundation/index.ts +9 -0
  11. package/src/blockFoundation/inputBlock.deserializer.ts +72 -0
  12. package/src/blockFoundation/inputBlock.serialization.types.ts +126 -0
  13. package/src/blockFoundation/inputBlock.serializer.ts +150 -0
  14. package/src/blockFoundation/inputBlock.ts +181 -0
  15. package/src/blockFoundation/outputBlock.ts +144 -0
  16. package/src/blockFoundation/shaderBlock.ts +156 -0
  17. package/src/blockFoundation/textureOptions.ts +57 -0
  18. package/src/command/command.ts +59 -0
  19. package/src/command/commandBuffer.ts +71 -0
  20. package/src/command/commandBufferDebugger.ts +14 -0
  21. package/src/command/index.ts +7 -0
  22. package/src/connection/connectionPoint.ts +205 -0
  23. package/src/connection/connectionPointCompatibilityState.ts +31 -0
  24. package/src/connection/connectionPointDirection.ts +9 -0
  25. package/src/connection/connectionPointType.ts +45 -0
  26. package/src/connection/connectionPointWithDefault.ts +27 -0
  27. package/src/connection/index.ts +8 -0
  28. package/src/editorUtils/editableInPropertyPage.ts +106 -0
  29. package/src/editorUtils/index.ts +3 -0
  30. package/src/index.ts +16 -0
  31. package/src/optimization/dependencyGraph.ts +96 -0
  32. package/src/optimization/index.ts +1 -0
  33. package/src/optimization/optimizedShaderBlock.ts +131 -0
  34. package/src/optimization/smartFilterOptimizer.ts +757 -0
  35. package/src/runtime/index.ts +8 -0
  36. package/src/runtime/renderTargetGenerator.ts +222 -0
  37. package/src/runtime/shaderRuntime.ts +174 -0
  38. package/src/runtime/smartFilterRuntime.ts +112 -0
  39. package/src/runtime/strongRef.ts +18 -0
  40. package/src/serialization/importCustomBlockDefinition.ts +86 -0
  41. package/src/serialization/index.ts +10 -0
  42. package/src/serialization/serializedBlockDefinition.ts +12 -0
  43. package/src/serialization/serializedShaderBlockDefinition.ts +7 -0
  44. package/src/serialization/serializedSmartFilter.ts +6 -0
  45. package/src/serialization/smartFilterDeserializer.ts +190 -0
  46. package/src/serialization/smartFilterSerializer.ts +110 -0
  47. package/src/serialization/v1/defaultBlockSerializer.ts +21 -0
  48. package/src/serialization/v1/index.ts +4 -0
  49. package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -0
  50. package/src/serialization/v1/smartFilterSerialization.types.ts +129 -0
  51. package/src/smartFilter.ts +255 -0
  52. package/src/utils/buildTools/buildShaders.ts +14 -0
  53. package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -0
  54. package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -0
  55. package/src/utils/buildTools/convertShaders.ts +65 -0
  56. package/src/utils/buildTools/recordVersionNumber.js +24 -0
  57. package/src/utils/buildTools/shaderCode.types.ts +59 -0
  58. package/src/utils/buildTools/shaderConverter.ts +466 -0
  59. package/src/utils/buildTools/watchShaders.ts +44 -0
  60. package/src/utils/index.ts +4 -0
  61. package/src/utils/renderTargetUtils.ts +30 -0
  62. package/src/utils/shaderCodeUtils.ts +192 -0
  63. package/src/utils/textureLoaders.ts +31 -0
  64. package/src/utils/textureUtils.ts +28 -0
  65. package/src/utils/uniqueIdGenerator.ts +28 -0
  66. package/src/version.ts +4 -0
@@ -0,0 +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 CreateCommand(name: string, owner: ICommandOwner, action: CommandAction): Command {
54
+ return {
55
+ name,
56
+ owner,
57
+ action,
58
+ };
59
+ }
@@ -0,0 +1,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
+ }
@@ -0,0 +1,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
+ }
@@ -0,0 +1,7 @@
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";
@@ -0,0 +1,205 @@
1
+ import type { Nullable } from "core/types.js";
2
+ import { ConnectionPointCompatibilityState, GetCompatibilityIssueMessage } from "./connectionPointCompatibilityState.js";
3
+ import { ConnectionPointDirection } from "./connectionPointDirection.js";
4
+ import type { BaseBlock } from "../blockFoundation/baseBlock.js";
5
+ import type { ConnectionPointType, ConnectionPointValue } from "./connectionPointType.js";
6
+ import type { StrongRef } from "../runtime/strongRef.js";
7
+
8
+ /**
9
+ * This represents a strong reference to the data being passed through a connection point.
10
+ */
11
+ export type RuntimeData<U extends ConnectionPointType> = StrongRef<ConnectionPointValue<U>>;
12
+
13
+ /**
14
+ * This defines a connection point.
15
+ *
16
+ * A connection point is any input/output of a block.
17
+ * It can be linked to another connection point following some rules:
18
+ * - The type of the connection point must be compatible with the other one.
19
+ * - The direction of the connection point must be different from the other one.
20
+ * - The connection cannot create a cycle in the list of blocks.
21
+ * The relationship is always 1:N for input:output
22
+ */
23
+ export class ConnectionPoint<U extends ConnectionPointType = ConnectionPointType> {
24
+ /**
25
+ * The name of the connection point.
26
+ * This is used to identify the connection point inside a block.
27
+ */
28
+ public readonly name: string;
29
+
30
+ /**
31
+ * The type of the connection point (float, texture, etc.)
32
+ */
33
+ public readonly type: U;
34
+
35
+ /**
36
+ * The direction of the connection point (input or output)
37
+ */
38
+ public readonly direction: ConnectionPointDirection;
39
+
40
+ /**
41
+ * The smart filter block the connection point belongs to.
42
+ */
43
+ public readonly ownerBlock: BaseBlock;
44
+
45
+ /**
46
+ * User provided name for the connection point.
47
+ */
48
+ public displayName: Nullable<string> = null;
49
+
50
+ /**
51
+ * The @see RunTimeData used during the init phase to reference the result of the previous block.
52
+ * Those are only used for input connection points.
53
+ * The previous block are "pushing" this in during the init stage.
54
+ */
55
+ public runtimeData: Nullable<RuntimeData<U>> = null;
56
+
57
+ /**
58
+ * The default runtimeData used when no connection is made to the connection point.
59
+ */
60
+ public readonly defaultRuntimeData: Nullable<RuntimeData<U>> = null;
61
+
62
+ private _connectedTo: Nullable<ConnectionPoint<U>> = null;
63
+ private _endpoints: Array<ConnectionPoint<U>> = [];
64
+
65
+ /**
66
+ * Create a new connection point.
67
+ * @param name - The name the connection point has in the block
68
+ * @param ownerBlock - The block the connection point belongs to
69
+ * @param type - The type of the connection point
70
+ * @param direction - The direction of the connection point
71
+ * @param defaultRuntimeData - The default runtime data to use when no connection is made to the connection point
72
+ */
73
+ constructor(name: string, ownerBlock: BaseBlock, type: U, direction: ConnectionPointDirection, defaultRuntimeData: Nullable<RuntimeData<U>> = null) {
74
+ this.name = name;
75
+ this.ownerBlock = ownerBlock;
76
+ this.type = type;
77
+ this.direction = direction;
78
+ this.defaultRuntimeData = defaultRuntimeData;
79
+ this.runtimeData = defaultRuntimeData;
80
+ }
81
+
82
+ /**
83
+ * @returns The connection point this connection point is connected to.
84
+ * (the one on the other side of the connection)
85
+ * Only input connection points have a connected point which they received their value from.
86
+ * (Relation is always 1:N for input:output)
87
+ */
88
+ public get connectedTo(): Nullable<ConnectionPoint<U>> {
89
+ return this._connectedTo;
90
+ }
91
+
92
+ /**
93
+ * @returns The connection points this output connection point is connected to.
94
+ * (the ones on the other side of the connection)
95
+ * Only output connection points have a list of endpoints which they provide their value to.
96
+ * (Relation is always 1:N for input:output)
97
+ */
98
+ public get endpoints(): ReadonlyArray<ConnectionPoint<U>> {
99
+ return this._endpoints;
100
+ }
101
+
102
+ /**
103
+ * Gets a state indicating if the current point can be connected to another point
104
+ * @param other - defines the other connection point
105
+ * @returns the compatibility state
106
+ */
107
+ public checkCompatibilityState(other: ConnectionPoint<U>): ConnectionPointCompatibilityState {
108
+ // Only connects output to input
109
+ if (this.direction === ConnectionPointDirection.Input) {
110
+ return other.checkCompatibilityState(this);
111
+ }
112
+
113
+ // Check types
114
+ if (this.type !== other.type) {
115
+ return ConnectionPointCompatibilityState.TypeIncompatible;
116
+ }
117
+
118
+ // Check directions
119
+ if (this.direction === other.direction) {
120
+ return ConnectionPointCompatibilityState.DirectionIncompatible;
121
+ }
122
+
123
+ // Check hierarchy
124
+ if (other.ownerBlock.isAnAncestorOf(this.ownerBlock)) {
125
+ return ConnectionPointCompatibilityState.HierarchyIssue;
126
+ }
127
+
128
+ return ConnectionPointCompatibilityState.Compatible;
129
+ }
130
+
131
+ /**
132
+ * Checks if the connection point can be connected to another one.
133
+ * @param connectionPoint - The other connection point to check compatibility with
134
+ * @returns true if the connection point can be connected to the other one
135
+ */
136
+ public canConnectTo(connectionPoint: ConnectionPoint<U>) {
137
+ return this.checkCompatibilityState(connectionPoint) === ConnectionPointCompatibilityState.Compatible;
138
+ }
139
+
140
+ /**
141
+ * Connect this connection point to another one.
142
+ * @param other - The other connection point to connect to
143
+ * @throws if the connection point cannot be connected to the other one
144
+ */
145
+ public connectTo(other: ConnectionPoint<U>): void {
146
+ // Only connects output to input
147
+ if (this.direction === ConnectionPointDirection.Input) {
148
+ other.connectTo(this);
149
+ return;
150
+ }
151
+
152
+ // Check compatibility
153
+ const compatibility = this.checkCompatibilityState(other);
154
+ if (compatibility !== ConnectionPointCompatibilityState.Compatible) {
155
+ throw GetCompatibilityIssueMessage(compatibility);
156
+ }
157
+
158
+ // Adds the connection point to the list of endpoints
159
+ this._endpoints.push(other);
160
+ // Fill at the same time the connectedTo property of the other connection point
161
+ other._connectedTo = this;
162
+ }
163
+
164
+ /**
165
+ * Disconnects this point from one of his endpoint
166
+ * @param endpoint - defines the other connection point
167
+ */
168
+ public disconnectFrom(endpoint: ConnectionPoint<U>): void {
169
+ const index = this._endpoints.indexOf(endpoint);
170
+ if (index === -1) {
171
+ return;
172
+ }
173
+
174
+ // Remove the connection point from the list of endpoints
175
+ this._endpoints.splice(index, 1);
176
+
177
+ // Connections are double-linked - remove the reference back to this connection point from the one we just disconnected from
178
+ endpoint._connectedTo = null;
179
+ endpoint.runtimeData = endpoint.defaultRuntimeData;
180
+ }
181
+
182
+ /**
183
+ * Disconnects this point from all its endpoints.
184
+ */
185
+ public disconnectAllEndpoints(): void {
186
+ // Detach outputs
187
+ let endpoint: ConnectionPoint<U> | undefined;
188
+ while ((endpoint = this._endpoints[0])) {
189
+ this.disconnectFrom(endpoint);
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Propagates the current runtime data to all endpoints.
195
+ */
196
+ public propagateRuntimeData(): void {
197
+ if (!this.runtimeData) {
198
+ this.runtimeData = {} as RuntimeData<U>;
199
+ }
200
+
201
+ for (const endpoint of this.endpoints) {
202
+ endpoint.runtimeData = this.runtimeData;
203
+ }
204
+ }
205
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Defines how compatible connection points are.
3
+ */
4
+ export enum ConnectionPointCompatibilityState {
5
+ /** Points are compatibles */
6
+ Compatible,
7
+ /** Points are incompatible because of their types */
8
+ TypeIncompatible,
9
+ /** Points are incompatible because of their directions */
10
+ DirectionIncompatible,
11
+ /** Points are incompatible because they are in the same hierarchy **/
12
+ HierarchyIssue,
13
+ }
14
+
15
+ /**
16
+ * Gets a user friendly message for the given compatibility state.
17
+ * @param state - Defines the compatibility state
18
+ * @returns the message associated with a compatibility state.
19
+ */
20
+ export function GetCompatibilityIssueMessage(state: ConnectionPointCompatibilityState): string {
21
+ switch (state) {
22
+ case ConnectionPointCompatibilityState.TypeIncompatible:
23
+ return "Cannot connect two different connection types";
24
+ case ConnectionPointCompatibilityState.DirectionIncompatible:
25
+ return "Cannot connect with the same direction";
26
+ case ConnectionPointCompatibilityState.HierarchyIssue:
27
+ return "Source block cannot be connected with one of its ancestors";
28
+ default:
29
+ return "";
30
+ }
31
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Defines the direction of a connection point.
3
+ */
4
+ export enum ConnectionPointDirection {
5
+ /** Input */
6
+ Input = 0,
7
+ /** Output */
8
+ Output = 1,
9
+ }
@@ -0,0 +1,45 @@
1
+ import type { ThinTexture } from "core/Materials/Textures/thinTexture.js";
2
+ import type { IColor3Like, IColor4Like, IVector2Like } from "core/Maths/math.like.js";
3
+ import type { Nullable } from "core/types.js";
4
+
5
+ /**
6
+ * Defines the type of a connection point.
7
+ */
8
+ export enum ConnectionPointType {
9
+ /** Float */
10
+ Float = 1,
11
+ /** Texture */
12
+ Texture = 2,
13
+ /** Color3 */
14
+ Color3 = 3,
15
+ /** Color4 */
16
+ Color4 = 4,
17
+ /** Boolean */
18
+ Boolean = 5,
19
+ /** Vector2 */
20
+ Vector2 = 6,
21
+ }
22
+
23
+ /**
24
+ * A union of all supported connection point types
25
+ */
26
+ export type AllConnectionPointTypes =
27
+ | ConnectionPointType.Float
28
+ | ConnectionPointType.Texture
29
+ | ConnectionPointType.Color3
30
+ | ConnectionPointType.Color4
31
+ | ConnectionPointType.Boolean
32
+ | ConnectionPointType.Vector2;
33
+
34
+ /**
35
+ * Retrieves the type of the value from the Connection point type.
36
+ */
37
+ // prettier-ignore
38
+ export type ConnectionPointValue<T extends ConnectionPointType = ConnectionPointType> =
39
+ T extends ConnectionPointType.Float ? number :
40
+ T extends ConnectionPointType.Texture ? Nullable<ThinTexture> :
41
+ T extends ConnectionPointType.Color3 ? IColor3Like :
42
+ T extends ConnectionPointType.Color4 ? IColor4Like :
43
+ T extends ConnectionPointType.Boolean ? boolean :
44
+ T extends ConnectionPointType.Vector2 ? IVector2Like :
45
+ never;
@@ -0,0 +1,27 @@
1
+ import type { BaseBlock } from "../blockFoundation/baseBlock.js";
2
+ import { ConnectionPoint, type RuntimeData } from "./connectionPoint.js";
3
+ import type { ConnectionPointDirection } from "./connectionPointDirection.js";
4
+ import type { ConnectionPointType } from "./connectionPointType.js";
5
+
6
+ /**
7
+ * A ConnectionPoint whose runtimeData is never null - if not hooked up to a connection, it will use a default value.
8
+ */
9
+ export class ConnectionPointWithDefault<U extends ConnectionPointType = ConnectionPointType> extends ConnectionPoint<U> {
10
+ /**
11
+ * The runtime data for this ConnectionPoint - it will never be null - if not hooked up to a connection, it will use the default value.
12
+ */
13
+ public override runtimeData: RuntimeData<U>;
14
+
15
+ /**
16
+ * Create a new ConnectionPointWithDefault
17
+ * @param name - The name the connection point has in the block
18
+ * @param ownerBlock - The block the connection point belongs to
19
+ * @param type - The type of the connection point
20
+ * @param direction - The direction of the connection point
21
+ * @param runtimeData - The runtimeData to use for this connection point if no connection is made
22
+ */
23
+ constructor(name: string, ownerBlock: BaseBlock, type: U, direction: ConnectionPointDirection, runtimeData: RuntimeData<U>) {
24
+ super(name, ownerBlock, type, direction, runtimeData);
25
+ this.runtimeData = runtimeData;
26
+ }
27
+ }
@@ -0,0 +1,8 @@
1
+ export { ConnectionPointDirection } from "./connectionPointDirection.js";
2
+ export { ConnectionPointType } from "./connectionPointType.js";
3
+ export { type ConnectionPointValue } from "./connectionPointType.js";
4
+ export { ConnectionPointCompatibilityState, GetCompatibilityIssueMessage } from "./connectionPointCompatibilityState.js";
5
+ // Back compat for when camelCase was used
6
+ export { GetCompatibilityIssueMessage as getCompatibilityIssueMessage } from "./connectionPointCompatibilityState.js";
7
+ export { ConnectionPoint } from "./connectionPoint.js";
8
+ export { type RuntimeData } from "./connectionPoint.js";
@@ -0,0 +1,106 @@
1
+ import type { Observable } from "core/Misc/observable.js";
2
+
3
+ /**
4
+ * Enum defining the type of properties that can be edited in the property pages in the node editor
5
+ */
6
+ export enum PropertyTypeForEdition {
7
+ /** property is a boolean */
8
+ Boolean,
9
+ /** property is a float */
10
+ Float,
11
+ /** property is a int */
12
+ Int,
13
+ /** property is a Vector2 */
14
+ Vector2,
15
+ /** property is a list of values */
16
+ List,
17
+ }
18
+
19
+ /**
20
+ * Interface that defines an option in a variable of type list
21
+ */
22
+ export interface IEditablePropertyListOption {
23
+ /** label of the option */
24
+ label: string;
25
+ /** value of the option */
26
+ value: number | string;
27
+ }
28
+
29
+ /**
30
+ * Interface that defines the options available for an editable property
31
+ */
32
+ export interface IEditablePropertyOption {
33
+ /** min value */
34
+ min?: number;
35
+ /** max value */
36
+ max?: number;
37
+ /** notifiers: indicates which actions to take when the property is changed */
38
+ notifiers?: {
39
+ /** the entity should be rebuilt */
40
+ rebuild?: boolean;
41
+ /** the preview should be updated */
42
+ update?: boolean;
43
+ /** the onPreviewCommandActivated observer of the preview manager should be triggered */
44
+ activatePreviewCommand?: boolean;
45
+ /** a callback to trigger */
46
+ callback?: () => boolean | undefined | void;
47
+ /** a callback to validate the property. Returns true if the property is ok, else false. If false, the rebuild/update/callback events won't be called */
48
+ onValidation?: (block: any, propertyName: string) => boolean;
49
+ };
50
+ /** a list of the options for a property of type list */
51
+ options?: IEditablePropertyListOption[] | Observable<IEditablePropertyListOption[]>;
52
+ /** whether the options' values should be treated as strings */
53
+ valuesAreStrings?: boolean;
54
+ /** If supplied, the sub property to read/write */
55
+ subPropertyName?: string;
56
+ }
57
+
58
+ /**
59
+ * Interface that describes an editable property
60
+ */
61
+ export interface IPropertyDescriptionForEdition {
62
+ /** name of the property */
63
+ propertyName: string;
64
+ /** display name of the property */
65
+ displayName: string;
66
+ /** type of the property */
67
+ type: PropertyTypeForEdition;
68
+ /** group of the property - all properties with the same group value will be displayed in a specific section */
69
+ groupName: string;
70
+ /** options for the property */
71
+ options: IEditablePropertyOption;
72
+ /** name of the class that contains the property */
73
+ className: string;
74
+ }
75
+
76
+ /**
77
+ * Decorator that flags a property in a node block as being editable
78
+ * @param displayName - the display name of the property
79
+ * @param propertyType - the type of the property
80
+ * @param groupName - the group name of the property
81
+ * @param options - the options of the property
82
+ * @returns the decorator
83
+ */
84
+ export function EditableInPropertyPage(
85
+ displayName: string,
86
+ propertyType: PropertyTypeForEdition = PropertyTypeForEdition.Boolean,
87
+ groupName: string = "PROPERTIES",
88
+ options?: IEditablePropertyOption
89
+ ) {
90
+ return (target: any, propertyKey: string) => {
91
+ let propStore: IPropertyDescriptionForEdition[] = target._propStore;
92
+ if (!propStore) {
93
+ propStore = [];
94
+ target._propStore = propStore;
95
+ }
96
+
97
+ propStore.push({
98
+ propertyName: propertyKey,
99
+ displayName: displayName,
100
+ type: propertyType,
101
+ groupName: groupName,
102
+ options: options ?? {},
103
+ className: target.constructor.name,
104
+ });
105
+ };
106
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./editableInPropertyPage.js";
2
+ // Back compat for when camelCase was used
3
+ export { EditableInPropertyPage as editableInPropertyPage } from "./editableInPropertyPage.js";
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ /* eslint-disable import/no-internal-modules */
2
+ export * from "./command/index.js";
3
+ export * from "./connection/index.js";
4
+ export * from "./blockFoundation/index.js";
5
+ export * from "./editorUtils/index.js";
6
+ export * from "./optimization/index.js";
7
+ export * from "./runtime/index.js";
8
+ export * from "./serialization/index.js";
9
+ export * from "./utils/index.js";
10
+
11
+ export { type IDisposable } from "./IDisposable.js";
12
+ export { SmartFilter, type InitializationData } from "./smartFilter.js";
13
+ export * from "./version.js";
14
+
15
+ // So that users of the Smart Filters core can easily modify the logger settings (e.g. to change the logging level)
16
+ export { Logger } from "core/Misc/logger.js";