@engine262/engine262 0.0.1-093c8cb33fc82c295390da3d9e124c21ad7e6281

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.
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ const engine262 = require('..');
4
+ const { getContext } = require('./context');
5
+
6
+ module.exports = {
7
+ Debugger: {
8
+ enable() {
9
+ return { debuggerId: 'debugger.0' };
10
+ },
11
+ setAsyncCallStackDepth() {},
12
+ setBlackboxPatterns() {},
13
+ setPauseOnExceptions() {},
14
+ },
15
+ Profiler: {
16
+ enable() {},
17
+ },
18
+ Runtime: {
19
+ enable() {},
20
+ compileScript() {
21
+ return { scriptId: 'script.0' };
22
+ },
23
+ callFunctionOn(options) {
24
+ const context = getContext(options.executionContextId);
25
+ const { Value: F } = context.realm.evaluateScript(`(${options.functionDeclaration})`);
26
+ const thisValue = options.objectId
27
+ ? context.getObject(options.objectId)
28
+ : engine262.Value.undefined;
29
+ const args = options.arguments.map((a) => {
30
+ if ('value' in a) {
31
+ return new engine262.Value(context.realm, a.value);
32
+ }
33
+ if ('objectId' in a) {
34
+ return context.getObject(a.objectId);
35
+ }
36
+ if ('unserializableValue' in a) {
37
+ throw new RangeError();
38
+ }
39
+ return engine262.Value.undefined;
40
+ });
41
+ const r = engine262.Call(F, thisValue, args);
42
+ return context.createEvaluationResult(r, options);
43
+ },
44
+ evaluate(options) {
45
+ if (options.throwOnSideEffect || options.awaitPromise) {
46
+ return {
47
+ exceptionDetails: {
48
+ text: 'unsupported',
49
+ lineNumber: 0,
50
+ columnNumber: 0,
51
+ },
52
+ };
53
+ }
54
+
55
+ const context = getContext(options.contextId);
56
+ const r = context.realm.evaluateScript(options.expression);
57
+ return context.createEvaluationResult(r, options);
58
+ },
59
+ getHeapUsage() {
60
+ return { usedSize: 0, totalSize: 0 };
61
+ },
62
+ getIsolateId() {
63
+ return { id: 'isolate.0' };
64
+ },
65
+ getProperties(options) {
66
+ const context = getContext();
67
+ const object = context.getObject(options.objectId);
68
+
69
+ const properties = context.getProperties(object, options);
70
+ if (properties instanceof engine262.AbruptCompletion) {
71
+ return context.createEvaluationResult(properties, options);
72
+ }
73
+
74
+ return {
75
+ result: properties.properties,
76
+ internalProperties: properties.internalProperties,
77
+ };
78
+ },
79
+ globalLexicalScopeNames({ executionContextId }) {
80
+ const context = getContext(executionContextId);
81
+ const envRec = context.realm.realm.GlobalEnv.EnvironmentRecord;
82
+ const names = Map.prototype.keys.call(envRec.DeclarativeRecord.bindings);
83
+ return {
84
+ names: [...names],
85
+ };
86
+ },
87
+ releaseObjectGroup({ objectGroup }) {
88
+ getContext().releaseObjectGroup(objectGroup);
89
+ },
90
+ runIfWaitingForDebugger(params, ctx) {
91
+ ctx.sendEvent('Runtime.executionContextCreated', {
92
+ context: {
93
+ id: '0',
94
+ origin: 'file://',
95
+ name: 'context.0',
96
+ auxData: {},
97
+ },
98
+ });
99
+ },
100
+ },
101
+ HeapProfiler: {
102
+ enable() {},
103
+ collectGarbage() {},
104
+ },
105
+ };
@@ -0,0 +1,87 @@
1
+ 'use strict';
2
+
3
+ const http = require('http');
4
+ const WebSocket = require('ws'); // eslint-disable-line import/no-extraneous-dependencies
5
+ const packageJson = require('../package.json');
6
+ const protocol = require('./js_protocol.json');
7
+ const methods = require('./methods');
8
+
9
+ const server = http.createServer((req, res) => {
10
+ if (req.method !== 'GET') {
11
+ res.writeHead(405);
12
+ res.end();
13
+ return;
14
+ }
15
+
16
+ const json = (obj) => {
17
+ const s = JSON.stringify(obj);
18
+ res.writeHead(200, {
19
+ 'Content-Type': 'application/json',
20
+ 'Content-Length': Buffer.byteLength(s),
21
+ });
22
+ res.end(s);
23
+ };
24
+
25
+ switch (req.url) {
26
+ case '/json':
27
+ case '/json/list':
28
+ json([{
29
+ description: `${packageJson.name} instance`,
30
+ devtoolsFrontendUrl: 'chrome-devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=localhost:9229/',
31
+ devtoolsFrontendUrlCompat: 'chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:9229/',
32
+ faviconUrl: 'https://avatars0.githubusercontent.com/u/51185628',
33
+ id: 'inspector.0',
34
+ title: 'engine262',
35
+ type: 'node',
36
+ url: `file://${process.cwd()}`,
37
+ webSocketDebuggerUrl: 'ws://localhost:9229/',
38
+ }]);
39
+ break;
40
+ case '/json/version':
41
+ json({
42
+ 'Browser': `${packageJson.name}/v${packageJson.version}`,
43
+ 'Protocol-Version': `${protocol.version.major}.${protocol.version.minor}`,
44
+ });
45
+ break;
46
+ case '/json/protocol':
47
+ json(protocol);
48
+ break;
49
+ default:
50
+ res.writeHead(404);
51
+ res.end();
52
+ break;
53
+ }
54
+ });
55
+
56
+ const wss = new WebSocket.Server({ server });
57
+
58
+ wss.on('connection', (ws) => {
59
+ const send = (obj) => {
60
+ const s = JSON.stringify(obj);
61
+ // console.log('<-', s);
62
+ ws.send(s);
63
+ };
64
+
65
+ ws._socket.unref();
66
+
67
+ const context = {
68
+ sendEvent(event, params) {
69
+ send({ method: event, params });
70
+ },
71
+ };
72
+
73
+ ws.on('message', (data) => {
74
+ // console.log('->', data);
75
+ const { id, method, params } = JSON.parse(data);
76
+ const [k, v] = method.split('.');
77
+ Promise.resolve(methods[k][v](params, context))
78
+ .then((result = {}) => {
79
+ send({ id, result });
80
+ });
81
+ });
82
+ });
83
+
84
+ server.listen(9229, '127.0.0.1', () => {
85
+ console.log('Debugger listening at localhost:9229'); // eslint-disable-line no-console
86
+ });
87
+ server.unref();
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@engine262/engine262",
3
+ "version": "0.0.1-093c8cb33fc82c295390da3d9e124c21ad7e6281",
4
+ "description": "Implementation of ECMA-262 in JavaScript",
5
+ "author": "engine262 Contributors",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/engine262/engine262#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/engine262/engine262/issues"
10
+ },
11
+ "main": "dist/engine262",
12
+ "scripts": {
13
+ "lint": "eslint rollup.config.js test/ src/ bin/ inspector/ scripts/ --cache --ext=js,mjs",
14
+ "build": "npm run build:regex_data && npm run build:engine",
15
+ "build:regex_data": "node scripts/gen_regex_sets.js",
16
+ "build:engine": "rollup -c",
17
+ "test": "bash test/test_root.sh",
18
+ "test:test262": "node test/test262/test262.js",
19
+ "test:supplemental": "node test/supplemental.js",
20
+ "test:json": "node test/json/json.js",
21
+ "coverage": "c8 --reporter=lcov npm run test",
22
+ "prepublishOnly": "node scripts/tag_version_with_git_hash.js",
23
+ "postpublish": "git reset --hard HEAD"
24
+ },
25
+ "bin": {
26
+ "engine262": "bin/engine262.js"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/engine262/engine262.git"
31
+ },
32
+ "devDependencies": {
33
+ "@babel/core": "^7.12.13",
34
+ "@babel/eslint-parser": "^7.12.13",
35
+ "@babel/plugin-proposal-optional-chaining": "^7.12.13",
36
+ "@engine262/eslint-plugin": "file:./test/eslint-plugin-engine262",
37
+ "@rollup/plugin-babel": "^5.2.3",
38
+ "@rollup/plugin-commonjs": "^17.1.0",
39
+ "@rollup/plugin-json": "^4.1.0",
40
+ "@rollup/plugin-node-resolve": "^11.1.1",
41
+ "@snek/source-map-support": "^1.0.4",
42
+ "@unicode/unicode-13.0.0": "^1.0.3",
43
+ "acorn": "^8.0.5",
44
+ "c8": "^7.5.0",
45
+ "eslint": "^7.19.0",
46
+ "eslint-config-airbnb-base": "^14.2.1",
47
+ "eslint-plugin-import": "^2.22.1",
48
+ "glob": "^7.1.6",
49
+ "js-yaml": "^3.14.0",
50
+ "minimatch": "^3.0.4",
51
+ "rollup": "^2.38.5",
52
+ "ws": "^7.2.3"
53
+ }
54
+ }