@shaderfrog/core 1.5.1 → 1.5.3
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/package.json +2 -2
- package/strategy/assignemntTo.js +7 -2
- package/util/ast.d.ts +1 -1
- package/util/ast.js +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shaderfrog/core",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Shaderfrog core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lodash.groupby": "^4.6.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@shaderfrog/glsl-parser": "^
|
|
51
|
+
"@shaderfrog/glsl-parser": "^4.0.0",
|
|
52
52
|
"babylonjs": ">=4",
|
|
53
53
|
"playcanvas": "^1.65.3",
|
|
54
54
|
"three": ">=0.50"
|
package/strategy/assignemntTo.js
CHANGED
|
@@ -16,8 +16,13 @@ export var applyAssignmentToStrategy = function (strategy, ast, graphNode, sibli
|
|
|
16
16
|
nodeInput(name, "filler_".concat(name), 'filler', undefined, // Data type for what plugs into this filler
|
|
17
17
|
['code', 'data'], false),
|
|
18
18
|
function (fillerAst) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if ('expression' in assignNode) {
|
|
20
|
+
assignNode.expression.right =
|
|
21
|
+
fillerAst;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
assignNode.initializer = fillerAst;
|
|
25
|
+
}
|
|
21
26
|
return ast;
|
|
22
27
|
},
|
|
23
28
|
],
|
package/util/ast.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Program } from '@shaderfrog/glsl-parser/ast';
|
|
|
7
7
|
import { ShaderStage } from '../graph/graph-types';
|
|
8
8
|
import { Scope } from '@shaderfrog/glsl-parser/parser/scope';
|
|
9
9
|
export declare const findVec4Constructor: (ast: AstNode) => AstNode | undefined;
|
|
10
|
-
export declare const findAssignmentTo: (ast: AstNode | Program, assignTo: string) =>
|
|
10
|
+
export declare const findAssignmentTo: (ast: AstNode | Program, assignTo: string) => DeclarationNode | ExpressionStatementNode;
|
|
11
11
|
export declare const findDeclarationOf: (ast: AstNode | Program, declarationOf: string) => DeclarationNode | undefined;
|
|
12
12
|
export declare const from2To3: (ast: Program, stage: ShaderStage) => void;
|
|
13
13
|
export declare const outDeclaration: (name: string) => Object;
|
package/util/ast.js
CHANGED
|
@@ -61,6 +61,16 @@ export var findAssignmentTo = function (ast, assignTo) {
|
|
|
61
61
|
path.skip();
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
+
declaration_statement: {
|
|
65
|
+
enter: function (path) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
var foundDecl = (_b = (_a = path.node.declaration) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.find(function (decl) { var _a; return ((_a = decl === null || decl === void 0 ? void 0 : decl.identifier) === null || _a === void 0 ? void 0 : _a.identifier) === assignTo; });
|
|
68
|
+
if (foundDecl === null || foundDecl === void 0 ? void 0 : foundDecl.initializer) {
|
|
69
|
+
assign = foundDecl;
|
|
70
|
+
}
|
|
71
|
+
path.skip();
|
|
72
|
+
},
|
|
73
|
+
},
|
|
64
74
|
};
|
|
65
75
|
visit(ast, visitors);
|
|
66
76
|
return assign;
|