@neon-rs/load
Advanced tools
Comparing version 0.0.169 to 0.0.170
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.__UNSTABLE_proxy = exports.__UNSTABLE_loader = exports.lazy = exports.bin = exports.currentTarget = void 0; | ||
exports.__UNSTABLE_proxy = exports.proxy = exports.__UNSTABLE_loader = exports.lazy = exports.bin = exports.currentTarget = void 0; | ||
function currentTarget() { | ||
@@ -153,4 +153,11 @@ let os = null; | ||
exports.__UNSTABLE_loader = __UNSTABLE_loader; | ||
function __UNSTABLE_proxy(loaders) { | ||
function isTargetTable(options) { | ||
return !('targets' in options); | ||
} | ||
function proxy(options) { | ||
if (isTargetTable(options)) { | ||
options = { targets: options }; | ||
} | ||
const target = currentTarget(); | ||
const loaders = options.targets; | ||
if (!loaders.hasOwnProperty(target)) { | ||
@@ -163,3 +170,13 @@ throw new Error(`no precompiled module found for ${target}`); | ||
if (!loaded) { | ||
loaded = loader(); | ||
if (options.debug) { | ||
try { | ||
loaded = options.debug(); | ||
} | ||
catch (_e) { | ||
loaded = null; | ||
} | ||
} | ||
if (!loaded) { | ||
loaded = loader(); | ||
} | ||
} | ||
@@ -205,2 +222,6 @@ return loaded; | ||
} | ||
exports.proxy = proxy; | ||
function __UNSTABLE_proxy(options) { | ||
return proxy(options); | ||
} | ||
exports.__UNSTABLE_proxy = __UNSTABLE_proxy; |
{ | ||
"name": "@neon-rs/load", | ||
"version": "0.0.169", | ||
"version": "0.0.170", | ||
"description": "Utilities for loading Neon modules.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -11,2 +11,9 @@ export declare function currentTarget(): string; | ||
export declare function __UNSTABLE_loader(loaders: Record<string, () => Record<string, any>>): () => Record<string, any>; | ||
export declare function __UNSTABLE_proxy(loaders: Record<string, () => Record<string, any>>): any; | ||
export type ModuleObject = Record<string, any>; | ||
export type TargetTable = Record<string, () => ModuleObject>; | ||
export type ProxyOptions = { | ||
targets: TargetTable; | ||
debug?: () => ModuleObject; | ||
}; | ||
export declare function proxy(options: TargetTable | ProxyOptions): any; | ||
export declare function __UNSTABLE_proxy(options: TargetTable | ProxyOptions): any; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9589
242