Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added noir/compiler/wasm/dist/node/index_bg.wasm
Binary file not shown.
5,743 changes: 5,743 additions & 0 deletions noir/compiler/wasm/dist/node/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions noir/compiler/wasm/dist/node/main.js.map

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions noir/compiler/wasm/dist/types/nodejs/noir_wasm.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
export function init_log_level(filter: string): void;
export function build_info(): any;
export function compile(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
export function __wbindgen_object_drop_ref(arg0: any): void;
export function __wbg_constructor_a29cdb41a75eb0e8(arg0: any): number;
export function __wbg_constructor_a3b5b211c5053ce8(): number;
export function __wbindgen_is_undefined(arg0: any): boolean;
export function __wbg_new_abda76e883ba8a5f(): number;
export function __wbg_stack_658279fe44541cf6(arg0: any, arg1: any): void;
export function __wbg_error_f851667af71bcfc6(arg0: any, arg1: any): void;
export function __wbindgen_string_new(arg0: any, arg1: any): number;
export function __wbg_debug_e3f6a1578e6d45ca(arg0: any): void;
export function __wbg_debug_efabe4eb183aa5d4(arg0: any, arg1: any, arg2: any, arg3: any): void;
export function __wbg_error_a7e23606158b68b9(arg0: any): void;
export function __wbg_error_50f42b952a595a23(arg0: any, arg1: any, arg2: any, arg3: any): void;
export function __wbg_info_05db236d79f1b785(arg0: any): void;
export function __wbg_info_24d8f53d98f12b95(arg0: any, arg1: any, arg2: any, arg3: any): void;
export function __wbg_warn_9bdd743e9f5fe1e0(arg0: any): void;
export function __wbg_warn_8342bfbc6028193a(arg0: any, arg1: any, arg2: any, arg3: any): void;
export function __wbindgen_string_get(arg0: any, arg1: any): void;
export function __wbg_set_07da13cc24b69217(...args: any[]): any;
export function __wbg_parse_76a8a18ca3f8730b(...args: any[]): any;
export function __wbg_stringify_d06ad2addc54d51e(...args: any[]): any;
export function __wbindgen_debug_string(arg0: any, arg1: any): void;
export function __wbindgen_throw(arg0: any, arg1: any): never;
/**
*/
export class PathToFileSourceMap {
static __wrap(ptr: any): any;
__destroy_into_raw(): number | undefined;
__wbg_ptr: number | undefined;
free(): void;
/**
* @param {string} path
* @param {string} source_code
* @returns {boolean}
*/
add_source_code(path: string, source_code: string): boolean;
}
/**
* This is a wrapper class that is wasm-bindgen compatible
* We do not use js_name and rename it like CrateId because
* then the impl block is not picked up in javascript.
*/
export class CompilerContext {
static __wrap(ptr: any): any;
/**
* @param {PathToFileSourceMap} source_map
*/
constructor(source_map: PathToFileSourceMap);
__destroy_into_raw(): number | undefined;
__wbg_ptr: number | undefined;
free(): void;
/**
* @param {string} path_to_crate
* @returns {CrateId}
*/
process_root_crate(path_to_crate: string): CrateId;
/**
* @param {string} path_to_crate
* @returns {CrateId}
*/
process_dependency_crate(path_to_crate: string): CrateId;
/**
* @param {string} crate_name
* @param {CrateId} from
* @param {CrateId} to
*/
add_dependency_edge(crate_name: string, from: CrateId, to: CrateId): void;
/**
* @param {number} program_width
* @returns {CompileResult}
*/
compile_program(program_width: number): CompileResult;
/**
* @param {number} program_width
* @returns {CompileResult}
*/
compile_contract(program_width: number): CompileResult;
}
/**
*/
export class CrateId {
static __wrap(ptr: any): any;
__destroy_into_raw(): number | undefined;
__wbg_ptr: number | undefined;
free(): void;
}
declare let wasm: any;
export { wasm as __wasm };
7 changes: 7 additions & 0 deletions noir/compiler/wasm/dist/types/src/index.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FileManager } from './noir/file-manager/file-manager';
import { createNodejsFileManager } from './noir/file-manager/nodejs-file-manager';
import { LogFn } from './utils';
import { CompilationResult } from './types/noir_artifact';
declare function compile(fileManager: FileManager, projectPath?: string, logFn?: LogFn, debugLogFn?: LogFn): Promise<CompilationResult>;
declare const createFileManager: typeof createNodejsFileManager;
export { compile, createFileManager, CompilationResult };
7 changes: 7 additions & 0 deletions noir/compiler/wasm/dist/types/src/index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FileManager } from './noir/file-manager/file-manager';
import { createNodejsFileManager } from './noir/file-manager/nodejs-file-manager';
import { LogFn } from './utils';
import { CompilationResult } from './types/noir_artifact';
declare function compile(fileManager: FileManager, projectPath?: string, logFn?: LogFn, debugLogFn?: LogFn): Promise<CompilationResult>;
declare const createFileManager: typeof createNodejsFileManager;
export { compile, createFileManager, CompilationResult };
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Package } from '../package';
import { Dependency, DependencyResolver } from './dependency-resolver';
/**
* Noir Dependency Resolver
*/
export declare class DependencyManager {
#private;
/**
* Creates a new dependency resolver
* @param resolvers - A list of dependency resolvers to use
* @param entryPoint - The entry point of the project
*/
constructor(resolvers: readonly DependencyResolver[] | undefined, entryPoint: Package);
/**
* Gets dependencies for the entry point
*/
getEntrypointDependencies(): string[];
/**
* Get transitive libraries used by the package
*/
getLibraries(): [string, Dependency][];
/**
* A map of library dependencies
*/
getLibraryDependencies(): {
[k: string]: string[];
};
/**
* Resolves dependencies for a package.
*/
resolveDependencies(): Promise<void>;
/**
* Gets the version of a dependency in the dependency tree
* @param name - Dependency name
* @returns The dependency's version
*/
getVersionOf(name: string): string | undefined;
/**
* Gets the names of the crates in this dependency list
*/
getPackageNames(): string[];
/**
* Looks up a dependency
* @param sourceId - The source being resolved
* @returns The path to the resolved file
*/
findFile(sourceId: string): string | null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DependencyConfig } from '../../types/noir_package_config';
import { Package } from '../package';
/**
* A Noir dependency
*/
export type Dependency = {
/** version string as determined by the resolver */
version?: string;
/** the actual package source code */
package: Package;
};
/**
* Resolves a dependency for a package.
*/
export interface DependencyResolver {
/**
* Resolve a dependency for a package.
* @param pkg - The package to resolve dependencies for
* @param dep - The dependency config to resolve
*/
resolveDependency(pkg: Package, dep: DependencyConfig): Promise<Dependency | null>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FileManager } from '../file-manager/file-manager';
import { Package } from '../package';
import { Dependency, DependencyResolver } from './dependency-resolver';
import { DependencyConfig, GitDependencyConfig } from '../../types/noir_package_config';
/**
* Downloads dependencies from github
*/
export declare class GithubDependencyResolver implements DependencyResolver {
#private;
constructor(fm: FileManager);
/**
* Resolves a dependency from github. Returns null if URL is for a different website.
* @param _pkg - The package to resolve the dependency for
* @param dependency - The dependency configuration
* @returns asd
*/
resolveDependency(_pkg: Package, dependency: DependencyConfig): Promise<Dependency | null>;
}
/**
* Returns a safe filename for a value
* @param val - The value to convert
*/
export declare function safeFilename(val: string): string;
/**
* Resolves a dependency's archive URL.
* @param dependency - The dependency configuration
* @returns The URL to the library archive
*/
export declare function resolveGithubCodeArchive(dependency: GitDependencyConfig, format: 'zip' | 'tar'): URL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { FileManager } from '../file-manager/file-manager';
import { Package } from '../package';
import { Dependency, DependencyResolver } from './dependency-resolver';
import { DependencyConfig } from '../../types/noir_package_config';
/**
* Resolves dependencies on-disk, relative to current package
*/
export declare class LocalDependencyResolver implements DependencyResolver {
#private;
constructor(fm: FileManager);
resolveDependency(parent: Package, config: DependencyConfig): Promise<Dependency | null>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* A file system interface that matches the node fs module.
*/
export interface FileSystem {
/** Checks if the file exists */
existsSync: (path: string) => boolean;
/** Creates a directory structure */
mkdir: (dir: string, opts?: {
/** Create parent directories as needed */
recursive: boolean;
}) => Promise<void>;
/** Writes a file */
writeFile: (path: string, data: Uint8Array) => Promise<void>;
/** Reads a file */
readFile: (path: string, encoding?: 'utf-8') => Promise<Uint8Array | string>;
/** Renames a file */
rename: (oldPath: string, newPath: string) => Promise<void>;
/** Reads a directory */
readdir: (path: string, options?: {
/** Traverse child directories recursively */
recursive: boolean;
}) => Promise<string[]>;
}
/**
* A file manager that writes file to a specific directory but reads globally.
*/
export declare class FileManager {
#private;
constructor(fs: FileSystem, dataDir: string);
/**
* Returns the data directory
*/
getDataDir(): string;
/**
* Saves a file to the data directory.
* @param name - File to save
* @param stream - File contents
*/
writeFile(name: string, stream: ReadableStream<Uint8Array>): Promise<void>;
/**
* Reads a file from the filesystem and returns a buffer
* Saves a file to the data directory.
* @param oldName - File to save
* @param newName - File contents
*/
moveFile(oldName: string, newName: string): Promise<void>;
/**
* Reads a file from the disk and returns a buffer
* @param name - File to read
*/
readFile(name: string): Promise<Uint8Array>;
/**
* Reads a file from the filesystem as a string
* @param name - File to read
* @param encoding - Encoding to use
*/
readFile(name: string, encoding: 'utf-8'): Promise<string>;
/**
* Checks if a file exists and is accessible
* @param name - File to check
*/
hasFileSync(name: string): boolean;
/**
* Reads a file from the filesystem
* @param dir - File to read
* @param options - Readdir options
*/
readdir(dir: string, options?: {
/**
* Traverse child directories recursively
*/
recursive: boolean;
}): Promise<string[]>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IFs } from 'memfs';
import { FileManager } from './file-manager';
/**
* Creates a new FileManager instance based on a MemFS instance
* @param memFS - the memfs backing instance
* @param dataDir - where to store files
*/
export declare function createMemFSFileManager(memFS?: IFs, dataDir?: string): FileManager;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FileManager } from './file-manager';
export declare function readdirRecursive(dir: string): Promise<string[]>;
/**
* Creates a new FileManager instance based on nodejs fs
* @param dataDir - where to store files
*/
export declare function createNodejsFileManager(dataDir: string): FileManager;
31 changes: 31 additions & 0 deletions noir/compiler/wasm/dist/types/src/noir/noir-wasm-compiler.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { FileManager } from './file-manager/file-manager';
import { LogFn } from '../utils';
import { CompilationResult } from '../types/noir_artifact';
/** Compilation options */
export type NoirWasmCompileOptions = {
/** Logging function */
log: LogFn;
/** Log debugging information through this function */
debugLog: LogFn;
};
/**
* Noir Package Compiler
*/
export declare class NoirWasmCompiler {
#private;
private constructor();
/**
* Creates a new compiler instance.
* @param fileManager - The file manager to use
* @param projectPath - The path to the project
* @param opts - Compilation options
*/
static new(fileManager: FileManager, projectPath: string, wasmCompiler: any, sourceMap: any, opts: NoirWasmCompileOptions): Promise<NoirWasmCompiler>;
/**
* Compile EntryPoint
*/
/**
* Compile EntryPoint
*/
compile(): Promise<CompilationResult>;
}
Loading