Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

as-loader

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-loader - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1--canary.25.c02907e.0

2

loader/compiler-host.d.ts

@@ -1,2 +0,2 @@

import { DiagnosticMessage, APIOptions } from "assemblyscript/cli/asc";
import type { DiagnosticMessage, APIOptions } from "assemblyscript/cli/asc";
declare type CompilerHost = Required<Pick<APIOptions, "stdout" | "stderr" | "readFile" | "writeFile" | "listFiles" | "reportDiagnostic">> & {

@@ -3,0 +3,0 @@ getDiagnostics(): DiagnosticMessage[];

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCompilerHost = void 0;
var path_1 = __importDefault(require("path"));
var asc_1 = __importDefault(require("assemblyscript/cli/asc"));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var path = require("path");
var asc = require("assemblyscript/cli/asc");
function createCompilerHost(context) {
var memVolume = {};
var stderr = asc_1.default.createMemoryStream();
var stdout = asc_1.default.createMemoryStream();
var stderr = asc.createMemoryStream();
var stdout = asc.createMemoryStream();
var diagnostics = [];
function readFile(fileName, baseDir) {
var filePath = baseDir ? path_1.default.resolve(baseDir, fileName) : fileName;
var filePath = baseDir ? path.resolve(baseDir, fileName) : fileName;
if (memVolume[filePath]) {

@@ -30,3 +26,3 @@ return memVolume[filePath];

function writeFile(fileName, contents, baseDir) {
var filePath = baseDir ? path_1.default.resolve(baseDir, fileName) : fileName;
var filePath = baseDir ? path.resolve(baseDir, fileName) : fileName;
memVolume[filePath] = Buffer.isBuffer(contents)

@@ -38,3 +34,3 @@ ? contents

function listFiles(dirName, baseDir) {
var dirPath = baseDir ? path_1.default.resolve(baseDir, dirName) : dirName;
var dirPath = baseDir ? path.resolve(baseDir, dirName) : dirName;
try {

@@ -41,0 +37,0 @@ return context.fs

@@ -1,4 +0,4 @@

import { DiagnosticMessage } from "assemblyscript/cli/asc";
import type { DiagnosticMessage } from "assemblyscript/cli/asc";
import { LineColumn } from "./line-column";
import { CompilerHost } from "./compiler-host";
import type { CompilerHost } from "./compiler-host";
interface Location {

@@ -5,0 +5,0 @@ start?: LineColumn;

@@ -17,10 +17,7 @@ "use strict";

})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AssemblyScriptError = void 0;
var path_1 = __importDefault(require("path"));
var path = require("path");
var line_column_1 = require("./line-column");
var AssemblyScriptError = /** @class */ (function (_super) {
var AssemblyScriptError = (function (_super) {
__extends(AssemblyScriptError, _super);

@@ -33,3 +30,2 @@ function AssemblyScriptError(message, file, location) {

_this.loc = location;
// webpack quirks...
_this.module = {

@@ -65,5 +61,5 @@ identifier: function () {

}
var baseUrl = path_1.default.relative(context, baseDir);
var baseUrl = path.relative(context, baseDir);
var file = fileName
? "./" + path_1.default.join(baseUrl, fileName).replace(/\\/g, "/")
? "./" + path.join(baseUrl, fileName).replace(/\\/g, "/")
: undefined;

@@ -70,0 +66,0 @@ return new AssemblyScriptError(diagnostic.message, file, location);

@@ -29,8 +29,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var path_1 = __importDefault(require("path"));
var asc_1 = __importDefault(require("assemblyscript/cli/asc"));
var path = require("path");
var asc = require("assemblyscript/cli/asc");
var assemblyscript_1 = require("assemblyscript");

@@ -42,6 +39,5 @@ var loader_utils_1 = require("loader-utils");

var error_1 = require("./error");
var schema_json_1 = __importDefault(require("./schema.json"));
var schema = require("./schema.json");
var webpack_1 = require("./webpack");
var SUPPORTED_EXTENSIONS = [".wasm", ".js"];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function loader(buffer) {

@@ -51,7 +47,6 @@ var _this = this;

var options = loader_utils_1.getOptions(this);
schema_utils_1.validate(schema_json_1.default, options, {
schema_utils_1.validate(schema, options, {
name: "AssemblyScript Loader",
baseDataPath: "options",
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
var callback = this.async();

@@ -62,6 +57,3 @@ var isDone = false;

var _d = options, _e = _d.name, name = _e === void 0 ? "[name].[contenthash].wasm" : _e, _f = _d.raw, raw = _f === void 0 ? false : _f, _g = _d.fallback, fallback = _g === void 0 ? false : _g, _h = _d.bind, bind = _h === void 0 ? false : _h, userAscOptions = __rest(_d, ["name", "raw", "fallback", "bind"]);
var ascOptions = __assign({
// default options
// when user imports wasm with webassembly type, it's not possible to pass env
runtime: ((_a = module.type) === null || _a === void 0 ? void 0 : _a.startsWith("webassembly")) ? "stub" : "incremental", exportRuntime: !((_b = module.type) === null || _b === void 0 ? void 0 : _b.startsWith("webassembly")) &&
var ascOptions = __assign({ runtime: ((_a = module.type) === null || _a === void 0 ? void 0 : _a.startsWith("webassembly")) ? "stub" : "incremental", exportRuntime: !((_b = module.type) === null || _b === void 0 ? void 0 : _b.startsWith("webassembly")) &&
userAscOptions.exportRuntime !== "stub", debug: this.mode === "development", optimizeLevel: 3, shrinkLevel: 1, noAssert: this.mode === "production" }, userAscOptions);

@@ -73,3 +65,2 @@ if (!SUPPORTED_EXTENSIONS.some(function (extension) { return name.endsWith(extension); })) {

if (bind && name.endsWith(".wasm")) {
// overwrite options for bind
ascOptions.exportRuntime = true;

@@ -79,3 +70,2 @@ ascOptions.transform = "as-bind";

if (name.endsWith(".js")) {
// overwrite options for js
ascOptions.runtime = "stub";

@@ -85,3 +75,3 @@ ascOptions.exportRuntime = false;

var shouldGenerateSourceMap = this.sourceMap;
var baseDir = path_1.default.dirname(this.resourcePath);
var baseDir = path.dirname(this.resourcePath);
var outFileName = loader_utils_1.interpolateName(this, name, {

@@ -106,3 +96,3 @@ context: context,

var args = __spreadArray([
path_1.default.basename(this.resourcePath),
path.basename(this.resourcePath),
"--baseDir",

@@ -113,5 +103,5 @@ baseDir,

], options_1.mapAscOptionsToArgs(ascOptions));
asc_1.default.ready
asc.ready
.then(function () {
asc_1.default.main(args, {
asc.main(args, {
readFile: host.readFile,

@@ -125,3 +115,2 @@ writeFile: host.writeFile,

var _a;
// prevent from multiple callback calls from asc side
if (isDone) {

@@ -161,4 +150,2 @@ return 0;

if (((_a = module.type) === null || _a === void 0 ? void 0 : _a.startsWith("webassembly")) || raw) {
// uses module type: "webassembly/sync" or "webasssembly/async" or raw: true -
// return binary instead of emitting files
var rawSourceMap = null;

@@ -183,3 +170,3 @@ if (sourceMapFileContent) {

immutable: /\[([^:\]]+:)?(hash|contenthash)(:[^\]]+)?]/gi.test(name),
sourceFilename: path_1.default
sourceFilename: path
.relative(_this.rootContext, _this.resourcePath)

@@ -190,4 +177,2 @@ .replace(/\\/g, "/"),

_this.emitFile(sourceMapFileName, sourceMapFileContent, null, {
// we can't easily re-write link from wasm to source map and because of that,
// we can't use [contenthash] for source map file name
immutable: false,

@@ -194,0 +179,0 @@ development: true,

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

if (value) {
// add flag only if value is true
args.push("--" + key);

@@ -15,0 +14,0 @@ }

@@ -7,12 +7,4 @@ interface CompatibleWebpackModule {

}
/**
* Add warning to module.
* Supports webpack 4 and webpack 5.
*/
declare function addWarningToModule(module: CompatibleWebpackModule, error: Error): void;
/**
* Add error to module.
* Supports webpack 4 and webpack 5.
*/
declare function addErrorToModule(module: CompatibleWebpackModule, error: Error): void;
export { addWarningToModule, addErrorToModule };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addErrorToModule = exports.addWarningToModule = void 0;
/**
* Add warning to module.
* Supports webpack 4 and webpack 5.
*/
function addWarningToModule(module, error) {

@@ -17,6 +13,2 @@ if (typeof module.addWarning === "function") {

exports.addWarningToModule = addWarningToModule;
/**
* Add error to module.
* Supports webpack 4 and webpack 5.
*/
function addErrorToModule(module, error) {

@@ -23,0 +15,0 @@ if (typeof module.addError === "function") {

{
"name": "as-loader",
"version": "0.9.0",
"version": "0.9.1--canary.25.c02907e.0",
"description": "AssemblyScript loader for webpack",

@@ -5,0 +5,0 @@ "main": "loader/index.js",

@@ -0,9 +1,8 @@

/// <reference path="types/std.d.ts" />
import type { Imports } from "@assemblyscript/loader";
import type { BoundWasmModuleInstance, JsModuleInstance, BoundModuleInstance, AsLoaderModule } from "./types";
import "./types/std";
import type { JsModuleInstance, AsLoaderModule, BoundModuleInstance, BoundWasmModuleInstance } from "./types";
import type { Pointer, NonPointerTypes, NullablePointer, PointerCast, PointerCastArray, PointerCastFunction, PointerCastInstance, PointerCastObject } from "./types/pointer";
import type { AsLoaderRuntime } from "./types/runtime";
declare function instantiate<TModule, TImports extends Imports | undefined = Imports | undefined>(module: TModule | string, load: (url: string) => Promise<unknown>, imports: TImports, fallback: false, supports?: () => boolean): Promise<BoundWasmModuleInstance<TModule, TImports>>;
declare function instantiate<TModule, TImports extends Imports | undefined = Imports | undefined>(module: TModule | string, load: (url: string) => Promise<unknown>, imports?: TImports, fallback?: true, supports?: () => boolean): Promise<BoundModuleInstance<TModule, TImports>>;
export { instantiate, Imports, BoundWasmModuleInstance, JsModuleInstance, BoundModuleInstance, AsLoaderModule, };
export * from "./types/pointer";
export * from "./types/bound";
export * from "./types/runtime";
export { instantiate, Imports, BoundWasmModuleInstance, JsModuleInstance, BoundModuleInstance, AsLoaderModule, Pointer, NonPointerTypes, NullablePointer, PointerCast, PointerCastArray, PointerCastFunction, PointerCastInstance, PointerCastObject, AsLoaderRuntime, };
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.instantiate = void 0;
var AsBind = __importStar(require("as-bind"));
var context_1 = require("./context");
require("./types/std");
var AsBind = require("as-bind");
function instantiate(module, load, imports, fallback, supports) {
if (imports === void 0) { imports = {}; }
if (fallback === void 0) { fallback = true; }
if (supports === void 0) { supports = function () { return Boolean(context_1.context && context_1.context.WebAssembly); }; }
return __awaiter(this, void 0, void 0, function () {
var moduleURL, _a;
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
moduleURL = module;
if (!supports()) return [3 /*break*/, 2];
_a = [{ type: "wasm-bound" }];
return [4 /*yield*/, AsBind.instantiate(load(moduleURL), imports)];
case 1:
// WebAssembly is supported
return [2 /*return*/, __assign.apply(void 0, _a.concat([(_c.sent())]))];
case 2:
if (!(fallback && moduleURL.fallback)) return [3 /*break*/, 4];
_b = {
type: "js"
};
return [4 /*yield*/, moduleURL.fallback()];
case 3: return [2 /*return*/, (_b.exports = _c.sent(),
_b)];
case 4: throw new Error("Cannot load \"" + moduleURL + "\" module. WebAssembly is not supported in this environment.");
}
if (supports === void 0) { supports = function () { return typeof WebAssembly === "object"; }; }
if (supports()) {
return AsBind.instantiate(load(module), imports || {}).then(function (result) {
result.type = "wasm-bound";
return result;
});
});
}
else if (fallback && module.fallback) {
return module.fallback().then(function (exports) { return ({
type: "js",
exports: exports,
}); });
}
return Promise.reject(new Error("Cannot load \"" + module + "\" module. WebAssembly is not supported in this environment."));
}
exports.instantiate = instantiate;
__exportStar(require("./types/pointer"), exports);
__exportStar(require("./types/bound"), exports);
__exportStar(require("./types/runtime"), exports);

@@ -0,8 +1,8 @@

/// <reference path="types/std.d.ts" />
import { Imports } from "@assemblyscript/loader";
import type { WasmModuleInstance, JsModuleInstance, ModuleInstance, AsLoaderModule } from "./types";
import "./types/std";
import type { Pointer, NonPointerTypes, NullablePointer, PointerCast, PointerCastArray, PointerCastFunction, PointerCastInstance, PointerCastObject } from "./types/pointer";
import type { AsLoaderRuntime } from "./types/runtime";
declare function instantiate<TModule>(module: TModule | string, load: (url: string) => Promise<unknown>, imports?: Imports, fallback?: false, supports?: () => boolean): Promise<WasmModuleInstance<TModule>>;
declare function instantiate<TModule>(module: TModule | string, load: (url: string) => Promise<unknown>, imports: Imports | undefined, fallback: true, supports?: () => boolean): Promise<ModuleInstance<TModule>>;
export { instantiate, Imports, WasmModuleInstance, JsModuleInstance, ModuleInstance, AsLoaderModule, };
export * from "./types/pointer";
export * from "./types/runtime";
export { instantiate, Imports, WasmModuleInstance, JsModuleInstance, ModuleInstance, AsLoaderModule, Pointer, NonPointerTypes, NullablePointer, PointerCast, PointerCastArray, PointerCastFunction, PointerCastInstance, PointerCastObject, AsLoaderRuntime, };
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.instantiate = void 0;
var loader_1 = require("@assemblyscript/loader");
var context_1 = require("./context");
require("./types/std");
function instantiate(module, load, imports, fallback, supports) {
if (imports === void 0) { imports = {}; }
if (fallback === void 0) { fallback = false; }
if (supports === void 0) { supports = function () { return Boolean(context_1.context && context_1.context.WebAssembly); }; }
return __awaiter(this, void 0, void 0, function () {
var moduleURL, _a;
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
moduleURL = module;
if (!supports()) return [3 /*break*/, 2];
_a = [{ type: "wasm" }];
return [4 /*yield*/, loader_1.instantiate(load(moduleURL), imports)];
case 1:
// WebAssembly is supported
return [2 /*return*/, __assign.apply(void 0, _a.concat([(_c.sent())]))];
case 2:
if (!(fallback && moduleURL.fallback)) return [3 /*break*/, 4];
_b = {
type: "js"
};
return [4 /*yield*/, moduleURL.fallback()];
case 3: return [2 /*return*/, (_b.exports = _c.sent(),
_b)];
case 4: throw new Error("Cannot load \"" + moduleURL + "\" module. WebAssembly is not supported in this environment.");
}
});
});
if (supports === void 0) { supports = function () { return typeof WebAssembly === "object"; }; }
if (supports()) {
return loader_1.instantiate(load(module), imports || {}).then(function (result) { return ({
type: "wasm",
exports: result.exports,
instance: result.instance,
module: result.module,
}); });
}
else if (fallback && module.fallback) {
return module.fallback().then(function (exports) { return ({
type: "js",
exports: exports,
}); });
}
return Promise.reject(new Error("Cannot load \"" + module + "\" module. WebAssembly is not supported in this environment."));
}
exports.instantiate = instantiate;
__exportStar(require("./types/pointer"), exports);
__exportStar(require("./types/runtime"), exports);
"use strict";
/// <reference lib="esnext.bigint" />
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,71 +6,37 @@ import { Pointer } from "./pointer";

table?: WebAssembly.Table;
/** Explicit start function, if requested. */
_start(): void;
/** Copies a string's value from the module's memory. */
__getString(ptr: Pointer<string>): string;
/** Copies an ArrayBuffer's value from the module's memory. */
__getArrayBuffer(ptr: Pointer<ArrayBuffer>): ArrayBuffer;
/** Copies an array's values from the module's memory. Infers the array type from RTTI. */
__getArray<T extends number>(ptr: Pointer<T[]>): T[];
/** Copies an Int8Array's values from the module's memory. */
__getInt8Array(ptr: Pointer<Int8Array>): Int8Array;
/** Copies an Uint8Array's values from the module's memory. */
__getUint8Array(ptr: Pointer<Uint8Array>): Uint8Array;
/** Copies an Uint8ClampedArray's values from the module's memory. */
__getUint8ClampedArray(ptr: Pointer<Uint8ClampedArray>): Uint8ClampedArray;
/** Copies an Int16Array's values from the module's memory. */
__getInt16Array(ptr: Pointer<Int16Array>): Int16Array;
/** Copies an Uint16Array's values from the module's memory. */
__getUint16Array(ptr: Pointer<Uint16Array>): Uint16Array;
/** Copies an Int32Array's values from the module's memory. */
__getInt32Array(ptr: Pointer<Int32Array>): Int32Array;
/** Copies an Uint32Array's values from the module's memory. */
__getUint32Array(ptr: Pointer<Uint32Array>): Uint32Array;
/** Copies an Int32Array's values from the module's memory. */
__getInt64Array?(ptr: Pointer<BigInt64Array>): BigInt64Array;
/** Copies an Uint32Array's values from the module's memory. */
__getUint64Array?(ptr: Pointer<BigUint64Array>): BigUint64Array;
/** Copies a Float32Array's values from the module's memory. */
__getFloat32Array(ptr: Pointer<Float32Array>): Float32Array;
/** Copies a Float64Array's values from the module's memory. */
__getFloat64Array(ptr: Pointer<Float64Array>): Float64Array;
/** Gets a live view on an array's values in the module's memory. Infers the array type from RTTI. */
__getArrayView(ptr: Pointer<ArrayBufferView>): ArrayBufferView;
/** Gets a live view on an Int8Array's values in the module's memory. */
__getInt8ArrayView(ptr: Pointer<Int8Array>): Int8Array;
/** Gets a live view on an Uint8Array's values in the module's memory. */
__getUint8ArrayView(ptr: Pointer<Uint8Array>): Uint8Array;
/** Gets a live view on an Uint8ClampedArray's values in the module's memory. */
__getUint8ClampedArrayView(ptr: Pointer<Uint8ClampedArray>): Uint8ClampedArray;
/** Gets a live view on an Int16Array's values in the module's memory. */
__getInt16ArrayView(ptr: Pointer<Int16Array>): Int16Array;
/** Gets a live view on an Uint16Array's values in the module's memory. */
__getUint16ArrayView(ptr: Pointer<Uint16Array>): Uint16Array;
/** Gets a live view on an Int32Array's values in the module's memory. */
__getInt32ArrayView(ptr: Pointer<Int32Array>): Int32Array;
/** Gets a live view on an Uint32Array's values in the module's memory. */
__getUint32ArrayView(ptr: Pointer<Uint32Array>): Uint32Array;
/** Gets a live view on an Int32Array's values in the module's memory. */
__getInt64ArrayView?(ptr: Pointer<BigInt64Array>): BigInt64Array;
/** Gets a live view on an Uint32Array's values in the module's memory. */
__getUint64ArrayView?(ptr: Pointer<BigUint64Array>): BigUint64Array;
/** Gets a live view on a Float32Array's values in the module's memory. */
__getFloat32ArrayView(ptr: Pointer<Float32Array>): Float32Array;
/** Gets a live view on a Float64Array's values in the module's memory. */
__getFloat64ArrayView(ptr: Pointer<Float64Array>): Float64Array;
/** Tests whether a managed object is an instance of the class represented by the specified base id. */
__instanceof<T>(ptr: Pointer, id: TypeId<T>): ptr is Pointer<T>;
/** Allocates a new string in the module's memory and returns a reference (pointer) to it. */
__newString(str: string): Pointer<string>;
/** Allocates a new array in the module's memory and returns a reference (pointer) to it. */
__newArray<T extends ArrayLike<unknown>>(id: number, values: T): Pointer<T>;
/** Allocates an instance of the class represented by the specified id. */
__new<T>(size: number, id: TypeId<T>): Pointer<T>;
/** Pins a managed object externally, preventing it from becoming garbage collected. */
__pin<T>(ptr: Pointer<T>): Pointer<T>;
/** Unpins a managed object externally, allowing it to become garbage collected. */
__unpin(ptr: Pointer): void;
/** Performs a full garbage collection cycle. */
__collect(incremental?: boolean): void;
}
export {};

@@ -12,5 +12,3 @@ declare type bool = boolean;

declare type f64 = number;
/** Special type evaluating the indexed access index type. */
declare type indexof<T extends unknown[]> = keyof T;
/** Special type evaluating the indexed access value type. */
declare type valueof<T extends unknown[]> = T[0];
"use strict";
/* eslint-disable @typescript-eslint/no-unused-vars */
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc