@navita/core 0.2.0 → 1.0.0
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/evaluateAndProcess.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
4
|
var swc = require('@navita/swc');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var createCompiledFunction = require('./helpers/createCompiledFunction.cjs');
|
|
6
|
+
var createDefineFunction = require('./helpers/createDefineFunction.cjs');
|
|
7
|
+
var setAdapter = require('./helpers/setAdapter.cjs');
|
|
8
8
|
|
|
9
9
|
const rootDir = path.resolve(__dirname, "../../");
|
|
10
10
|
const isExternal = (dependency)=>dependency.startsWith(rootDir) || dependency.includes('node_modules');
|
|
@@ -26,13 +26,13 @@ async function evaluateAndProcess({ type , filePath , source , engine , resolver
|
|
|
26
26
|
entryPoint: type === 'entryPoint',
|
|
27
27
|
importMap
|
|
28
28
|
});
|
|
29
|
-
const define =
|
|
29
|
+
const define = createDefineFunction.createDefineFunction({
|
|
30
30
|
filePath,
|
|
31
31
|
resolver,
|
|
32
32
|
isExternal,
|
|
33
33
|
resolverCache,
|
|
34
34
|
nodeModuleCache,
|
|
35
|
-
setAdapter: ()=>
|
|
35
|
+
setAdapter: ()=>setAdapter.setAdapter({
|
|
36
36
|
engine,
|
|
37
37
|
resultCache: resultCache
|
|
38
38
|
})
|
|
@@ -48,7 +48,7 @@ async function evaluateAndProcess({ type , filePath , source , engine , resolver
|
|
|
48
48
|
resolverCache,
|
|
49
49
|
moduleCache
|
|
50
50
|
})).then(({ result })=>result));
|
|
51
|
-
const compiledFn =
|
|
51
|
+
const compiledFn = createCompiledFunction.createCompiledFunction(`return ${newSource}`, define);
|
|
52
52
|
moduleCache.set(cacheKey, {
|
|
53
53
|
source,
|
|
54
54
|
compiledFn
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vm = require('node:vm');
|
|
4
|
-
var
|
|
4
|
+
var magicProxy = require('./magicProxy.cjs');
|
|
5
5
|
|
|
6
6
|
const context = vm.createContext({
|
|
7
7
|
global
|
|
@@ -14,14 +14,6 @@ Object
|
|
|
14
14
|
[name]: globalThis[name],
|
|
15
15
|
}), {});
|
|
16
16
|
`).runInContext(context);
|
|
17
|
-
const vmGlobalsNonEnumerableRecord = {};
|
|
18
|
-
Object.getOwnPropertyNames(global).forEach((name)=>{
|
|
19
|
-
// The second condition here is to prevent jest's Symbol polyfill from being added.
|
|
20
|
-
// https://github.com/jestjs/jest/blob/25a8785584c9d54a05887001ee7f498d489a5441/packages/jest-util/src/installCommonGlobals.ts#L49
|
|
21
|
-
if (!vmGlobalsRecord[name] && global[name] !== globalThis.Symbol) {
|
|
22
|
-
vmGlobalsNonEnumerableRecord[name] = global[name];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
17
|
function createCompiledFunction(source, define) {
|
|
26
18
|
// This looks a bit weird, but it's much quicker to do it this way than to
|
|
27
19
|
// run vm.runInContext. There's a bit more information in this issue:
|
|
@@ -29,10 +21,9 @@ function createCompiledFunction(source, define) {
|
|
|
29
21
|
const sandbox = {
|
|
30
22
|
define,
|
|
31
23
|
...vmGlobalsRecord,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
navigator: helpers_magicProxy.createMagicProxy(),
|
|
24
|
+
window: magicProxy.createMagicProxy(),
|
|
25
|
+
document: magicProxy.createMagicProxy(),
|
|
26
|
+
navigator: magicProxy.createMagicProxy(),
|
|
36
27
|
console
|
|
37
28
|
};
|
|
38
29
|
const params = Object.keys(sandbox);
|
|
@@ -12,14 +12,6 @@ Object
|
|
|
12
12
|
[name]: globalThis[name],
|
|
13
13
|
}), {});
|
|
14
14
|
`).runInContext(context);
|
|
15
|
-
const vmGlobalsNonEnumerableRecord = {};
|
|
16
|
-
Object.getOwnPropertyNames(global).forEach((name)=>{
|
|
17
|
-
// The second condition here is to prevent jest's Symbol polyfill from being added.
|
|
18
|
-
// https://github.com/jestjs/jest/blob/25a8785584c9d54a05887001ee7f498d489a5441/packages/jest-util/src/installCommonGlobals.ts#L49
|
|
19
|
-
if (!vmGlobalsRecord[name] && global[name] !== globalThis.Symbol) {
|
|
20
|
-
vmGlobalsNonEnumerableRecord[name] = global[name];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
15
|
function createCompiledFunction(source, define) {
|
|
24
16
|
// This looks a bit weird, but it's much quicker to do it this way than to
|
|
25
17
|
// run vm.runInContext. There's a bit more information in this issue:
|
|
@@ -27,7 +19,6 @@ function createCompiledFunction(source, define) {
|
|
|
27
19
|
const sandbox = {
|
|
28
20
|
define,
|
|
29
21
|
...vmGlobalsRecord,
|
|
30
|
-
...vmGlobalsNonEnumerableRecord,
|
|
31
22
|
window: createMagicProxy(),
|
|
32
23
|
document: createMagicProxy(),
|
|
33
24
|
navigator: createMagicProxy(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navita/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Core package for Navita. Used for creating integrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"outdent": "^0.8.0",
|
|
30
30
|
"magic-string": "^0.30.3",
|
|
31
31
|
"@navita/types": "0.1.0",
|
|
32
|
+
"@navita/adapter": "0.1.0",
|
|
32
33
|
"@navita/swc": "0.1.0",
|
|
33
|
-
"@navita/engine": "0.2.
|
|
34
|
-
"@navita/adapter": "0.1.0"
|
|
34
|
+
"@navita/engine": "0.2.1"
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"author": "Eagerpatch",
|