🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

glsl-modules

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-modules - npm Package Compare versions

Comparing version
0.5.0
to
0.6.0
+6
dist/core-system/module-content/uniform.d.ts
import { BaseEntity } from "./base-entity.js";
export declare const uniformRegex: RegExp;
export declare class Uniform extends BaseEntity {
readonly type = "uniform";
protected getDependencyTestString(): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Uniform = exports.uniformRegex = void 0;
const base_entity_js_1 = require("./base-entity.js");
exports.uniformRegex = /(uniform\s+(\w+)[\w\[\]]*\s+(\w+)[\w\[\]]*\s*;)/;
class Uniform extends base_entity_js_1.BaseEntity {
constructor() {
super(...arguments);
this.type = "uniform";
}
getDependencyTestString() {
const [, , type] = this.definition.match(exports.uniformRegex);
return type;
}
}
exports.Uniform = Uniform;
+8
-9
import { GLSLModule } from "./glsl-module.js";
import { GLSLPlugin } from "./glsl-plugin.js";
import { ModuleEntity } from "./module-content/types.js";
type LibraryStructure = {
[key: string]: LibraryStructure | GLSLModule | string;
type NestedLibraryDefinition = {
[key: string]: NestedLibraryDefinition | string;
};
type LibraryModules = Record<string, GLSLModule>;
type DefinitionInput = LibraryStructure | GLSLModule | string;
type LibraryDefinition = NestedLibraryDefinition | string;
export type GLSLLibraryOptions = {
name: string;
definition: DefinitionInput;
plugins?: GLSLPlugin[];
dependencies?: GLSLLibrary[];
definition: LibraryDefinition;
plugins?: Array<GLSLPlugin>;
dependencies?: Array<GLSLLibrary>;
};

@@ -18,3 +17,3 @@ export declare class GLSLLibrary {

modules: LibraryModules;
plugins: GLSLPlugin[];
plugins: Array<GLSLPlugin>;
dependencies: Record<string, GLSLLibrary>;

@@ -27,5 +26,5 @@ private isCompiled;

addPlugin(plugin: GLSLPlugin): void;
getEntity(path: string, name: string, type: "import" | "ambient", originId: string): ModuleEntity[];
getEntity(path: string, name: string, type: "import" | "ambient", originId: string): import("./module-content/types.js").ModuleEntity[];
addDependency(library: GLSLLibrary): this;
}
export {};

@@ -14,3 +14,8 @@ "use strict";

this.plugins = plugins;
this.definition = definition;
if (typeof definition === "string") {
this.definition = { [indexKey]: definition };
}
else {
this.definition = definition;
}
this.dependencies = { [name]: this };

@@ -33,11 +38,3 @@ for (const dependency of dependencies)

const context = { plugins, libraries: this.dependencies };
if (definition instanceof glsl_module_js_1.GLSLModule) {
this.modules[indexKey] = definition;
}
else if (typeof definition === "string") {
this.modules[indexKey] = new glsl_module_js_1.GLSLModule(name, definition, context);
}
else {
processLibraryStructure(name, definition, this.modules, context);
}
processLibraryStructure(name, definition, this.modules, context);
for (const module of Object.values(this.modules))

@@ -69,5 +66,2 @@ module.applyPlugins();

}
else if (entry instanceof glsl_module_js_1.GLSLModule) {
moduleObject[currentPath] = entry;
}
else {

@@ -74,0 +68,0 @@ processLibraryStructure(currentPath, entry, moduleObject, context);

@@ -12,9 +12,9 @@ import { Export, Import, ModuleEntity } from "./module-content/index.js";

libraries: Record<string, GLSLLibrary>;
plugins: GLSLPlugin[];
plugins: Array<GLSLPlugin>;
};
export declare class GLSLModule {
path: string;
entities: ModuleEntity[];
imports: Import[];
exports: Export[];
entities: Array<ModuleEntity>;
imports: Array<Import>;
exports: Array<Export>;
unparsedCode: string;

@@ -27,3 +27,3 @@ isShaderModule: boolean;

applyPlugins(): void;
getEntity(request: EntityRequest): ModuleEntity[];
getEntity(request: EntityRequest): Array<ModuleEntity>;
resolve(): string;

@@ -30,0 +30,0 @@ private validateExport;

import { Define, Export, Func, Import, ModuleEntity, Struct, Variable } from "./module-content/index.js";
import { Uniform } from "./module-content/uniform";
export declare class GLSLParser {
originalCode: string;
path: string;
imports: Import[];
exports: Export[];
entities: ModuleEntity[];
imports: Array<Import>;
exports: Array<Export>;
entities: Array<ModuleEntity>;
code: string;
constructor(code: string, path: string);
parseAll(): this;
parseUniforms(): Uniform[];
parseFunctions(): Func[];

@@ -12,0 +14,0 @@ parseVariables(): Variable[];

@@ -7,2 +7,3 @@ "use strict";

const index_js_2 = require("./module-content/index.js");
const uniform_1 = require("./module-content/uniform");
class GLSLParser {

@@ -20,2 +21,3 @@ constructor(code, path) {

this.parseExports();
this.parseUniforms();
this.parseFunctions();

@@ -27,2 +29,13 @@ this.parseVariables();

}
parseUniforms() {
let uniforms = [];
for (const match of (0, index_js_1.matchIterator)(this.code, uniform_1.uniformRegex)) {
const [definition, type, name] = match.groups;
const { startIndex, endIndex } = match;
uniforms.push(new uniform_1.Uniform(name, this.path, startIndex, definition));
this.code = (0, index_js_1.blankOutSubstring)(this.code, startIndex, endIndex);
}
this.entities.push(...uniforms);
return uniforms;
}
parseFunctions() {

@@ -29,0 +42,0 @@ let functions = [];

@@ -9,9 +9,9 @@ import { Import, ModuleEntity } from "./module-content/index.js";

path: string;
localEntities: EntityWithContext[];
importedEntities: EntityWithContext[];
allEntities: ModuleEntity[];
imports: Import[];
constructor(path: string, localEntities: ModuleEntity[], imports: Import[], importedEntities: ModuleEntity[]);
updateEntities(localEntities: ModuleEntity[], imports: Import[], importedEntities: ModuleEntity[]): void;
getEntitiesByName(name: string): EntityWithContext[];
localEntities: Array<EntityWithContext>;
importedEntities: Array<EntityWithContext>;
allEntities: Array<ModuleEntity>;
imports: Array<Import>;
constructor(path: string, localEntities: Array<ModuleEntity>, imports: Array<Import>, importedEntities: Array<ModuleEntity>);
updateEntities(localEntities: Array<ModuleEntity>, imports: Array<Import>, importedEntities: Array<ModuleEntity>): void;
getEntitiesByName(name: string): Array<EntityWithContext>;
getEntitiesById(id: string): ModuleEntity[];

@@ -22,7 +22,7 @@ }

preprocess?: (code: string, isShader: boolean) => string;
transform?: (moduleEntities: ModuleEntity[], context: PluginContext, isShader: boolean) => ModuleEntity[] | void;
transform?: (moduleEntities: Array<ModuleEntity>, context: PluginContext, isShader: boolean) => Array<ModuleEntity> | void;
postprocess?: (code: string, entity: ModuleEntity, context: PluginContext, isShader: boolean) => string;
};
type GLSLPluginFunction<A extends any[] = any[]> = (...args: A) => GLSLPlugin;
export declare function definePlugin<A extends any[]>(pluginFunction: GLSLPluginFunction<A>): GLSLPluginFunction<A>;
type GLSLPluginFunction<A extends Array<any> = Array<any>> = (...args: A) => GLSLPlugin;
export declare function definePlugin<A extends Array<any>>(pluginFunction: GLSLPluginFunction<A>): GLSLPluginFunction<A>;
export {};
import { GLSLLibrary } from "./glsl-library.js";
import { GLSLPlugin } from "./glsl-plugin.js";
export type GLSLRegistryOptions = {
libraries?: GLSLLibrary[];
plugins?: GLSLPlugin[];
libraries?: Array<GLSLLibrary>;
plugins?: Array<GLSLPlugin>;
};
export declare class GLSLRegistry {
libraries: Record<string, GLSLLibrary>;
plugins: GLSLPlugin[];
plugins: Array<GLSLPlugin>;
constructor(options?: GLSLRegistryOptions);

@@ -11,0 +11,0 @@ addLibrary(library: GLSLLibrary): this;

import { EntityDependency } from "./entity-dependency.js";
import { ModuleEntity } from "./types.js";
declare const entityTypes: readonly ["function", "variable", "struct", "define"];
declare const entityTypes: readonly ["function", "variable", "struct", "define", "uniform"];
export type EntityType = typeof entityTypes[number];

@@ -13,11 +13,11 @@ export declare abstract class BaseEntity {

index: number;
dependencies: EntityDependency[];
dependencies: Array<EntityDependency>;
constructor(name: string, path: string, index: number, definition: string);
getResolvedDefinition(idNameMap: Record<string, string>): string;
isDependentOn(candidate: ModuleEntity): boolean;
addDependencies(...dependencies: EntityDependency[]): void;
addDependencies(...dependencies: Array<EntityDependency>): void;
removeDependency(id: string): void;
protected abstract getDependencyTestString(): string;
determineDependencies(candidateDependencies: EntityDependency[]): void;
determineDependencies(candidateDependencies: Array<EntityDependency>): void;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseEntity = void 0;
const entityTypes = ["function", "variable", "struct", "define"];
const entityTypes = ["function", "variable", "struct", "define", "uniform"];
class BaseEntity {

@@ -6,0 +6,0 @@ constructor(name, path, index, definition) {

@@ -8,3 +8,3 @@ import { BaseEntity } from "./base-entity.js";

constructor(name: string, type: string, index: number);
static parse(args: string[]): Argument[];
static parse(args: Array<string>): Argument[];
static parseArgumentsString(code: string): Argument[];

@@ -14,5 +14,5 @@ }

readonly type = "function";
arguments: Argument[];
constructor(name: string, path: string, index: number, definition: string, args: Argument[]);
arguments: Array<Argument>;
constructor(name: string, path: string, index: number, definition: string, args: Array<Argument>);
protected getDependencyTestString(): string;
}

@@ -10,1 +10,2 @@ export * from "./base-entity.js";

export * from "./types.js";
export * from "./uniform.js";

@@ -26,1 +26,2 @@ "use strict";

__exportStar(require("./types.js"), exports);
__exportStar(require("./uniform.js"), exports);

@@ -6,5 +6,5 @@ import { Argument } from "./func.js";

readonly type = "struct";
arguments: Argument[];
constructor(name: string, path: string, index: number, definition: string, args: Argument[]);
arguments: Array<Argument>;
constructor(name: string, path: string, index: number, definition: string, args: Array<Argument>);
protected getDependencyTestString(): string;
}

@@ -5,3 +5,3 @@ "use strict";

const base_entity_js_1 = require("./base-entity.js");
exports.structRegex = /^ *(struct\s+(\w+)\s+{([^}]+)}\s*;)/m;
exports.structRegex = /^ *(struct\s+(\w+)\s*{([^}]+)}\s*;)/m;
const extractStructBodyRegex = /^[^{]*{([\s\S]*)}\s*;$/;

@@ -8,0 +8,0 @@ class Struct extends base_entity_js_1.BaseEntity {

import { Define } from "./define.js";
import { Func } from "./func.js";
import { Struct } from "./struct.js";
import { Uniform } from "./uniform";
import { Variable } from "./variable.js";
export type ModuleEntity = Func | Define | Struct | Variable;
export type ModuleEntity = Func | Define | Struct | Variable | Uniform;

@@ -5,3 +5,3 @@ "use strict";

const base_entity_js_1 = require("./base-entity.js");
exports.variableRegex = /\s*((?:const\s+)?(\w+)\s+(\w+)\s+=\s+(\S+)\s*;)(?![^{]*})/;
exports.variableRegex = /((?:const\s+)?(\w+)[\w\[\]]*\s+(\w+)[\w\[\]]*\s+=\s+([^;]+)\s*;)(?![^{]*})/;
class Variable extends base_entity_js_1.BaseEntity {

@@ -8,0 +8,0 @@ constructor() {

@@ -6,4 +6,4 @@ import { DependencyGraph } from "../utils/topological-sort.js";

module: GLSLModule;
allEntities: ModuleEntity[];
idToEntityMap: Record<string, ModuleEntity[]>;
allEntities: Array<ModuleEntity>;
idToEntityMap: Record<string, Array<ModuleEntity>>;
constructor(module: GLSLModule);

@@ -14,3 +14,3 @@ createIdToEntityMap(): Record<string, ModuleEntity[]>;

sortEntitiesByDependencyOrder(): void;
createNameCollisionMap(entities: ModuleEntity[]): Record<string, string>;
createNameCollisionMap(entities: Array<ModuleEntity>): Record<string, string>;
}

@@ -10,5 +10,5 @@ /**

type ColorStringsOptions = {
formats?: ColorStringFormat[];
formats?: Array<ColorStringFormat>;
};
export declare function cssColorsPlugin(options?: ColorStringsOptions): GLSLPlugin;
export {};
export declare class Match {
selection: string;
groups: string[];
groups: Array<string>;
startIndex: number;

@@ -5,0 +5,0 @@ endIndex: number;

import { GLSLLibrary } from "../core-system/glsl-library.js";
import { ModuleEntity } from "../core-system/module-content/index.js";
export declare function resolveDependencies(entities: ModuleEntity[], libraries: Record<string, GLSLLibrary>): ModuleEntity[];
export declare function resolveDependencies(entities: Array<ModuleEntity>, libraries: Record<string, GLSLLibrary>): ModuleEntity[];
{
"name": "glsl-modules",
"version": "0.5.0",
"version": "0.6.0",
"exports": {

@@ -50,2 +50,2 @@ ".": {

}
}
}

@@ -297,2 +297,5 @@ <div align="center">

As of now, function overloads are not supported.
Only one higher-order function can have a given name.
### named-arguments

@@ -299,0 +302,0 @@ Makes it possible to specify arguments in a JS object-like fashion, both when calling functions and creating structs.