rc-js-util
Advanced tools
Comparing version 5.0.0-alpha6 to 5.0.0-alpha7
@@ -79,6 +79,6 @@ import { IWebAssemblyMemoryMemory } from "./i-web-assembly-memory"; | ||
addOnPostRun(cb: () => any): void; | ||
preloadedImages: any; | ||
preloadedAudios: any; | ||
quit(status: number, error: unknown): void; | ||
_malloc(size: number): number; | ||
_free(ptr: number): void; | ||
ASAN_OPTIONS?: string; | ||
} | ||
@@ -85,0 +85,0 @@ /** |
@@ -5,2 +5,3 @@ "use strict"; | ||
// extracted to allow for future extension, webgl only supports float32 matrices so no point right now | ||
// todo jack: webgl2 does in fact allow far more types, roll this back... | ||
var Mat3F32Factory = /** @class */ (function () { | ||
@@ -7,0 +8,0 @@ function Mat3F32Factory() { |
@@ -78,2 +78,13 @@ import "rc-js-util-globals/index"; | ||
static breakpoint(): boolean; | ||
/** | ||
* Logging which can be conditionally enabled by setting `DEBUG_VERBOSE` to true. | ||
* | ||
* @example | ||
* ```typescript | ||
* function foo(a1: number) { | ||
* DEBUG_MODE && _Debug.verboseLog(`got me a ${a1}`); | ||
* } | ||
* ``` | ||
*/ | ||
static verboseLog(message: string): void; | ||
static getStackTrace(): string; | ||
@@ -80,0 +91,0 @@ /** |
@@ -105,2 +105,18 @@ "use strict"; | ||
}; | ||
/** | ||
* Logging which can be conditionally enabled by setting `DEBUG_VERBOSE` to true. | ||
* | ||
* @example | ||
* ```typescript | ||
* function foo(a1: number) { | ||
* DEBUG_MODE && _Debug.verboseLog(`got me a ${a1}`); | ||
* } | ||
* ``` | ||
*/ | ||
_Debug.verboseLog = function (message) { | ||
if (!_Debug.isFlagSet(debug_flags_1.debugFlags.DEBUG_VERBOSE)) { | ||
return; | ||
} | ||
console.debug(message); | ||
}; | ||
_Debug.getStackTrace = function () { | ||
@@ -107,0 +123,0 @@ var error = new Error(); |
@@ -14,2 +14,6 @@ /** | ||
DEBUG_DISABLE_BREAKPOINT_FLAG: "DEBUG_DISABLE_BREAKPOINT"; | ||
/** | ||
* Enable verbose logging. | ||
*/ | ||
DEBUG_VERBOSE: "DEBUG_VERBOSE"; | ||
}; |
@@ -17,3 +17,7 @@ "use strict"; | ||
DEBUG_DISABLE_BREAKPOINT_FLAG: "DEBUG_DISABLE_BREAKPOINT", | ||
/** | ||
* Enable verbose logging. | ||
*/ | ||
DEBUG_VERBOSE: "DEBUG_VERBOSE", | ||
}; | ||
//# sourceMappingURL=debug-flags.js.map |
@@ -30,8 +30,10 @@ import "./debug/debug-namepace"; | ||
export { IDictionary } from "./typescript/i-dictionary"; | ||
export { INumericKeyedDictionary } from "./typescript/i-numeric-keyed-dictionary"; | ||
export { TKeysOf } from "./typescript/t-keys-of"; | ||
export { TNullable } from "./typescript/t-nullable"; | ||
export { TPickExcept } from "./typescript/t-pick-except"; | ||
export { TUnionToIntersection } from "./typescript/t-union-to-intersection"; | ||
export { INumericKeyedDictionary } from "./typescript/i-numeric-keyed-dictionary"; | ||
export { TUnpackArray } from "./typescript/t-unpack-array"; | ||
export { TUnpackIfArray } from "./typescript/t-unpack-if-array"; | ||
export { TWriteable } from "./typescript/t-writable"; | ||
export { IEmscriptenWrapper } from "./web-assembly/emscripten/i-emscripten-wrapper"; | ||
@@ -38,0 +40,0 @@ export { getEmscriptenWrapper } from "./web-assembly/emscripten/get-emscripten-wrapper"; |
@@ -21,2 +21,3 @@ "use strict"; | ||
var _debug_1 = require("../debug/_debug"); | ||
var null_ptr_1 = require("../web-assembly/emscripten/null-ptr"); | ||
/** | ||
@@ -31,3 +32,3 @@ * @public | ||
_this.wasmPtr = wasmPtr; | ||
DEBUG_MODE && _debug_1._Debug.assert(_this.wasmPtr !== 0, "expected pointer to object but got null_ptr"); | ||
DEBUG_MODE && _debug_1._Debug.assert(_this.wasmPtr !== null_ptr_1.nullPtr, "expected pointer to object but got null ptr"); | ||
return _this; | ||
@@ -34,0 +35,0 @@ } |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @public | ||
*/ | ||
export declare type TKeysOf<T extends object> = (keyof T)[]; |
@@ -7,2 +7,2 @@ import { IEmscriptenWrapper } from "./i-emscripten-wrapper"; | ||
*/ | ||
export declare function getEmscriptenWrapper(memory: IWebAssemblyMemoryMemory, emscriptenModuleFactory: Emscripten.EmscriptenModuleFactory): Promise<IEmscriptenWrapper>; | ||
export declare function getEmscriptenWrapper<T extends Emscripten.EmscriptenModule>(memory: IWebAssemblyMemoryMemory, emscriptenModuleFactory: Emscripten.EmscriptenModuleFactory, extension?: Partial<T>): Promise<IEmscriptenWrapper>; |
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -46,3 +57,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
*/ | ||
function getEmscriptenWrapper(memory, emscriptenModuleFactory) { | ||
function getEmscriptenWrapper(memory, emscriptenModuleFactory, extension) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -54,9 +65,7 @@ var memoryListener, instance, wrapper; | ||
memoryListener = new multicast_event_1.MulticastEvent(); | ||
return [4 /*yield*/, emscriptenModuleFactory({ wasmMemory: memory })]; | ||
return [4 /*yield*/, emscriptenModuleFactory(__assign({ wasmMemory: memory }, extension))]; | ||
case 1: | ||
instance = _a.sent(); | ||
shim_web_assembly_memory_1.shimWebAssemblyMemory(memory, function (buffer, previous, delta) { | ||
DEBUG_MODE && _debug_1._Debug.runBlock(function () { | ||
console.debug("WebAssembly memory grew from " + previous + " to " + (previous + delta) + " pages."); | ||
}); | ||
DEBUG_MODE && _debug_1._Debug.verboseLog("WebAssembly memory grew from " + previous + " to " + (previous + delta) + " pages."); | ||
wrapper.dataView = new DataView(wrapper.memory.buffer); | ||
@@ -63,0 +72,0 @@ memoryListener.emit(buffer, previous, delta); |
@@ -5,2 +5,5 @@ import { IWebAssemblyMemoryMemory } from "../../external/i-web-assembly-memory"; | ||
*/ | ||
export declare function geWasmTestMemory(): IWebAssemblyMemoryMemory; | ||
export declare function geWasmTestMemory(options: { | ||
initial: number; | ||
maximum?: number; | ||
}): IWebAssemblyMemoryMemory; |
@@ -7,6 +7,6 @@ "use strict"; | ||
*/ | ||
function geWasmTestMemory() { | ||
return new WebAssembly.Memory({ initial: 256, maximum: 512 }); | ||
function geWasmTestMemory(options) { | ||
return new WebAssembly.Memory(options); | ||
} | ||
exports.geWasmTestMemory = geWasmTestMemory; | ||
//# sourceMappingURL=get-wasm-test-memory.js.map |
@@ -20,4 +20,4 @@ import { TTypedArrayCtor } from "../../array/typed-array/t-typed-array-ctor"; | ||
getInstance(): InstanceType<TCtor>; | ||
protected constructor(cMethodPrefix: string, ctor: TCtor, wrapper: IEmscriptenWrapper, size: number, clearMemory: boolean); | ||
protected onRelease(): void; | ||
protected constructor(cMethodPrefix: string, ctor: TCtor, wrapper: IEmscriptenWrapper, size: number, clearMemory: boolean); | ||
private createInstance; | ||
@@ -24,0 +24,0 @@ private onEventMemoryResize; |
@@ -23,2 +23,3 @@ "use strict"; | ||
var _production_1 = require("../../production/_production"); | ||
var null_ptr_1 = require("../emscripten/null-ptr"); | ||
/** | ||
@@ -40,4 +41,3 @@ * @alpha | ||
}; | ||
if (_this.wasmPtr === 0) { | ||
// null_ptr | ||
if (_this.wasmPtr === null_ptr_1.nullPtr) { | ||
throw _production_1._Production.error("Failed to allocate memory for shared array."); | ||
@@ -93,2 +93,3 @@ } | ||
var arrayPtr = this.wrapper.instance[this.cGetArrayAddress](this.wasmPtr); | ||
DEBUG_MODE && _debug_1._Debug.assert(arrayPtr !== null_ptr_1.nullPtr, "failed to get array address"); | ||
var instance = new this.ctor(this.wrapper.memory.buffer, arrayPtr, size); | ||
@@ -95,0 +96,0 @@ if (DEBUG_MODE) { |
@@ -7,10 +7,20 @@ cmake_minimum_required(VERSION 3.17) | ||
if (${BUILD_JSUTIL_TEST}) | ||
# test module - matches the name of the ts module | ||
add_executable(test-module src/SharedArray.cpp src/DebugUtil.cpp) | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG_MODE") | ||
set_target_properties(test-module PROPERTIES LINK_FLAGS "-O0 -g -Weverything -s IMPORTED_MEMORY -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1") | ||
target_link_libraries(test-module PUBLIC GSL) | ||
# test modules - matches the names of the ts module | ||
# safe_heap and *sanitize do not play well with each other, test separately as they catch slightly different things | ||
set(CommonLinkFlags "-O0 -g -s NODEJS_CATCH_REJECTION=0 -s NODEJS_CATCH_EXIT=0 -s IMPORTED_MEMORY -s MODULARIZE=1") | ||
add_executable(asan-test-module src/SharedArray.cpp src/DebugUtil.cpp) | ||
set_target_properties(asan-test-module PROPERTIES | ||
LINK_FLAGS "${CommonLinkFlags} -s INITIAL_MEMORY=512mb -fsanitize=address -fsanitize=undefined -s EXIT_RUNTIME=1" | ||
COMPILE_FLAGS "-fsanitize=address -fsanitize=undefined" | ||
) | ||
target_link_libraries(asan-test-module PUBLIC GSL) | ||
target_include_directories(asan-test-module PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>") | ||
add_executable(safe-heap-test-module src/SharedArray.cpp src/DebugUtil.cpp) | ||
set_target_properties(safe-heap-test-module PROPERTIES LINK_FLAGS "${CommonLinkFlags} -s INITIAL_MEMORY=8192kb -s ALLOW_MEMORY_GROWTH=1 -s SAFE_HEAP") | ||
target_link_libraries(safe-heap-test-module PUBLIC GSL) | ||
target_include_directories(safe-heap-test-module PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>") | ||
endif () | ||
# create library | ||
@@ -26,7 +36,1 @@ add_library(JsUtil STATIC src/SharedArray.cpp src/DebugUtil.cpp) | ||
) | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "CLANG") | ||
target_compile_options(JsUtil PRIVATE -Werror -Wall -Wextra -pedantic) | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
target_compile_options(JsUtil PRIVATE /W4) | ||
endif () |
{ | ||
"name": "rc-js-util", | ||
"version": "5.0.0-alpha6", | ||
"version": "5.0.0-alpha7", | ||
"license": "MIT", | ||
@@ -17,3 +17,3 @@ "scripts": { | ||
"dependencies": { | ||
"rc-js-util-globals": "^0.0.2" | ||
"rc-js-util-globals": "^0.1.0" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
389886
358
5016
+ Addedrc-js-util-globals@0.1.0(transitive)
- Removedrc-js-util-globals@0.0.2(transitive)
Updatedrc-js-util-globals@^0.1.0