@neon-rs/load 0.0.167 → 0.0.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +68 -1
- package/package.json +1 -1
- package/types/index.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lazy = exports.bin = exports.currentTarget = void 0;
|
|
3
|
+
exports.__UNSTABLE_proxy = exports.__UNSTABLE_loader = exports.lazy = exports.bin = exports.currentTarget = void 0;
|
|
4
4
|
function currentTarget() {
|
|
5
5
|
let os = null;
|
|
6
6
|
switch (process.platform) {
|
|
@@ -134,3 +134,70 @@ function lazy(optionsOrLoaders, exports) {
|
|
|
134
134
|
: lazyV2(optionsOrLoaders);
|
|
135
135
|
}
|
|
136
136
|
exports.lazy = lazy;
|
|
137
|
+
function __UNSTABLE_loader(loaders) {
|
|
138
|
+
const target = currentTarget();
|
|
139
|
+
if (!loaders.hasOwnProperty(target)) {
|
|
140
|
+
throw new Error(`no precompiled module found for ${target}`);
|
|
141
|
+
}
|
|
142
|
+
const loader = loaders[target];
|
|
143
|
+
let loaded = null;
|
|
144
|
+
return () => {
|
|
145
|
+
if (loaded) {
|
|
146
|
+
return loaded;
|
|
147
|
+
}
|
|
148
|
+
loaded = loader();
|
|
149
|
+
return loaded;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
exports.__UNSTABLE_loader = __UNSTABLE_loader;
|
|
153
|
+
function __UNSTABLE_proxy(loaders) {
|
|
154
|
+
const target = currentTarget();
|
|
155
|
+
if (!loaders.hasOwnProperty(target)) {
|
|
156
|
+
throw new Error(`no precompiled module found for ${target}`);
|
|
157
|
+
}
|
|
158
|
+
const loader = loaders[target];
|
|
159
|
+
let loaded = null;
|
|
160
|
+
function load() {
|
|
161
|
+
if (!loaded) {
|
|
162
|
+
loaded = loader();
|
|
163
|
+
}
|
|
164
|
+
return loaded;
|
|
165
|
+
}
|
|
166
|
+
const handler = {
|
|
167
|
+
has(_target, key) {
|
|
168
|
+
return Reflect.has(load(), key);
|
|
169
|
+
},
|
|
170
|
+
get(_target, key) {
|
|
171
|
+
return Reflect.get(load(), key);
|
|
172
|
+
},
|
|
173
|
+
ownKeys(_target) {
|
|
174
|
+
return Reflect.ownKeys(load());
|
|
175
|
+
},
|
|
176
|
+
defineProperty(_target, _key, _descriptor) {
|
|
177
|
+
throw new Error('attempt to modify read-only Neon module proxy');
|
|
178
|
+
},
|
|
179
|
+
deleteProperty(_target, _key) {
|
|
180
|
+
throw new Error('attempt to modify read-only Neon module proxy');
|
|
181
|
+
},
|
|
182
|
+
set(_target, _key, _val) {
|
|
183
|
+
throw new Error('attempt to modify read-only Neon module proxy');
|
|
184
|
+
},
|
|
185
|
+
setPrototypeOf(_target, _proto) {
|
|
186
|
+
throw new Error('attempt to modify read-only Neon module proxy');
|
|
187
|
+
},
|
|
188
|
+
getPrototypeOf(_target) {
|
|
189
|
+
return Object.getPrototypeOf(load());
|
|
190
|
+
},
|
|
191
|
+
isExtensible(_target) {
|
|
192
|
+
return Reflect.isExtensible(load());
|
|
193
|
+
},
|
|
194
|
+
preventExtensions(_target) {
|
|
195
|
+
return Reflect.preventExtensions(load());
|
|
196
|
+
},
|
|
197
|
+
getOwnPropertyDescriptor(_target, key) {
|
|
198
|
+
return Reflect.getOwnPropertyDescriptor(load(), key);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
return new Proxy({}, handler);
|
|
202
|
+
}
|
|
203
|
+
exports.__UNSTABLE_proxy = __UNSTABLE_proxy;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export type LazyOptions = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function lazy(loaders: Record<string, () => any>, exports: string[]): any;
|
|
9
9
|
export declare function lazy(options: LazyOptions): any;
|
|
10
|
+
export declare function __UNSTABLE_loader(loaders: Record<string, () => Record<string, any>>): () => Record<string, any>;
|
|
11
|
+
export declare function __UNSTABLE_proxy(loaders: Record<string, () => Record<string, any>>): any;
|