Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

prettier-plugin-glsl

Package Overview
Dependencies
11
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.9 to 0.0.10

lib/node-helpers.d.ts

0

lib/builtins.d.ts

@@ -0,0 +0,0 @@ export type Matrix = number[] & {

@@ -0,0 +0,0 @@ import { TokenType } from "chevrotain";

export declare const ERRORS: Record<string, string>;
//# sourceMappingURL=errors.d.ts.map
export declare function recurseJSON(replacer: (this: any, key: string, value: any) => any, x: unknown): any;
export declare const simplifyCst: (x: unknown) => any;
//# sourceMappingURL=gendiagrams.d.ts.map

@@ -0,0 +0,0 @@ export * from "./lexer";

@@ -0,0 +0,0 @@ import { ILexingResult, IToken, Lexer, TokenType } from "chevrotain";

@@ -0,0 +0,0 @@ import { Matrix } from "./builtins";

@@ -0,0 +0,0 @@ import { IToken } from "chevrotain";

@@ -0,0 +0,0 @@ import { EmbeddedActionsParser, IRecognitionException, IRuleConfig, IToken, TokenType } from "chevrotain";

@@ -0,0 +0,0 @@ import { Token } from "./nodes";

@@ -0,0 +0,0 @@ import { Plugin, SupportInfo } from "prettier";

@@ -0,0 +0,0 @@ import { FunctionCall, Node, Token } from "./nodes";

@@ -0,0 +0,0 @@ import { Many } from "lodash";

28

package.json

@@ -12,3 +12,3 @@ {

],
"version": "0.0.9",
"version": "0.0.10",
"description": "Prettier (https://prettier.io) plugin for GLSL (OpenGL Shading Language).",

@@ -38,3 +38,3 @@ "exports": "./lib/prettier-plugin.cjs.js",

"@netflix/nerror": "^1.1.3",
"chevrotain": "^10.4.2",
"chevrotain": "^10.5.0",
"lodash": "^4.17.21"

@@ -48,17 +48,17 @@ },

"@types/dedent": "^0.7.0",
"@types/jest": "^29.4.0",
"@types/lodash": "^4.14.191",
"@types/node": "^18.14.2",
"@types/node-fetch": "^2.6.2",
"@types/jest": "^29.5.0",
"@types/lodash": "^4.14.192",
"@types/node": "^18.15.11",
"@types/node-fetch": "^2.6.3",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.6.0",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-cflint": "^1.0.0",
"eslint-plugin-import": "^2.27.5",
"filesize": "^10.0.6",
"jest": "^29.4.3",
"node-fetch": "^3.3.0",
"rollup": "^3.17.3",
"filesize": "^10.0.7",
"jest": "^29.5.0",
"node-fetch": "^3.3.1",
"rollup": "^3.20.2",
"rollup-plugin-terser": "^7.0.2",

@@ -65,0 +65,0 @@ "ts-jest": "^29.0.5",

@@ -1078,29 +1078,2 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */

function getMatrixDimensions(
t: TokenType,
): [cols: number, rows: number] | undefined {
switch (t) {
case TOKEN.MAT2X2:
return [2, 2]
case TOKEN.MAT2X3:
return [2, 3]
case TOKEN.MAT2X4:
return [2, 4]
case TOKEN.MAT3X2:
return [3, 2]
case TOKEN.MAT3X3:
return [3, 3]
case TOKEN.MAT3X4:
return [3, 4]
case TOKEN.MAT4X2:
return [4, 2]
case TOKEN.MAT4X3:
return [4, 3]
case TOKEN.MAT4X4:
return [4, 4]
default:
return undefined
}
}
function getAssignOpBinaryOp(t: TokenType): TokenType {

@@ -1107,0 +1080,0 @@ switch (t) {

@@ -22,3 +22,5 @@ // noinspection JSUnusedGlobalSymbols

Declarator,
FunctionCall,
isExpression,
isNode,
isToken,

@@ -32,2 +34,3 @@ Node,

import { parseInput } from "./parser"
import { getMatrixDimensions } from "./node-helpers"

@@ -497,2 +500,83 @@ interface PrettierComment extends Token {

/**
* Print function calls to mat* with literals as a grid.
*/
function printFunctionCall(n: FunctionCall): Doc {
const argDocs = path.map(print, "args")
let mDim
let argParts: Doc[] | undefined
if (
n.callee.arraySpecifier === undefined &&
isToken(n.callee.typeSpecifierNonArray) &&
(mDim = getMatrixDimensions(
n.callee.typeSpecifierNonArray.tokenType,
)) !== undefined &&
mDim[0] * mDim[1] === n.args.length
) {
const allArgsAreConstants = n.args.every(
(e) =>
(e.kind === "constantExpression" &&
(e.const_.tokenType === TOKEN.FLOATCONSTANT ||
e.const_.tokenType === TOKEN.INTCONSTANT)) ||
(e.kind === "unaryExpression" &&
(e.op.tokenType === TOKEN.PLUS ||
e.op.tokenType === TOKEN.DASH) &&
e.on.kind === "constantExpression" &&
(e.on.const_.tokenType === TOKEN.FLOATCONSTANT ||
e.on.const_.tokenType === TOKEN.INTCONSTANT)),
)
if (allArgsAreConstants) {
const suffixes: number[] = []
const prefixes: number[] = []
let maxPrefix = 0
let maxSuffix = 0
for (let i = 0; i < n.args.length; i++) {
const printedArg = argDocs[i]
let periodIndex =
typeof printedArg === "string"
? printedArg.indexOf(".")
: 1 + (printedArg as string[])[1].indexOf(".")
if (periodIndex === -1) {
periodIndex =
typeof printedArg === "string"
? printedArg.length
: 1 + (printedArg as string[])[1].length
}
prefixes[i] = periodIndex
suffixes[i] =
(typeof printedArg === "string"
? printedArg.length
: 1 + (printedArg as string[])[1].length) - periodIndex
maxPrefix = Math.max(maxPrefix, prefixes[i])
maxSuffix = Math.max(maxSuffix, suffixes[i])
}
argParts = []
const colCount = mDim[0]
for (let i = 0; i < argDocs.length; i++) {
const leftPad = maxPrefix - prefixes[i]
const rightPad = maxSuffix - suffixes[i]
const alignedArg =
leftPad === 0 && rightPad === 0
? argDocs[i]
: [" ".repeat(leftPad), argDocs[i], " ".repeat(rightPad)]
argParts.push(i % colCount === 0 ? hardline : " ")
argParts.push(alignedArg)
if (i !== argDocs.length - 1) {
argParts.push(",")
}
}
}
}
if (!argParts) {
argParts = [softline, join([",", line], argDocs)]
}
return group([
p<typeof n>("callee"),
"(",
indent(argParts),
softline,
")",
])
}
try {

@@ -852,9 +936,3 @@ switch (n.kind) {

case "functionCall":
return group([
p<typeof n>("callee"),
"(",
indent([softline, join([",", line], path.map(print, "args"))]),
softline,
")",
])
return printFunctionCall(n)
case "methodCall":

@@ -1149,2 +1227,13 @@ return [

printComment,
hasPrettierIgnore(path: AstPath<IToken | Node>) {
const value = path.getValue()
return (
(value &&
isNode(value) &&
value.comments?.some((c) =>
/\/\/\s*prettier-ignore\b.*/.test(c.image),
)) ??
false
)
},
},

@@ -1151,0 +1240,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc