├── server ├── .npmignore ├── test │ ├── evaluate │ │ ├── async │ │ │ ├── output.js │ │ │ └── input.js │ │ ├── basic │ │ │ ├── output.js │ │ │ └── input.js │ │ ├── scratchpad │ │ │ ├── output-1.js │ │ │ ├── output.js │ │ │ ├── output-2.js │ │ │ ├── input-1.js │ │ │ ├── input-2.js │ │ │ └── input.js │ │ ├── commonjs │ │ │ ├── output-6.js │ │ │ ├── output-3.js │ │ │ ├── output-4.js │ │ │ ├── input-6.js │ │ │ ├── output-5.js │ │ │ ├── output-1.js │ │ │ ├── input-3.js │ │ │ ├── output-2.js │ │ │ ├── input-5.js │ │ │ ├── input-1.js │ │ │ ├── input-4.js │ │ │ └── input-2.js │ │ ├── native-addons │ │ │ ├── output.js │ │ │ └── input.js │ │ ├── default-exports-and-imports │ │ │ ├── output-2.js │ │ │ ├── output-3.js │ │ │ ├── output-4.js │ │ │ ├── output-6.js │ │ │ ├── output-1.js │ │ │ ├── input-6.js │ │ │ ├── input-1.js │ │ │ ├── output-5.js │ │ │ ├── input-5.js │ │ │ ├── input-2.js │ │ │ ├── input-3.js │ │ │ └── input-4.js │ │ ├── dynamic-imports │ │ │ ├── output-1.js │ │ │ ├── output-2.js │ │ │ ├── input-1.js │ │ │ └── input-2.js │ │ ├── imports-built-ins │ │ │ ├── output.js │ │ │ └── input.js │ │ ├── exports-and-imports │ │ │ ├── output-1.js │ │ │ ├── output-2.js │ │ │ ├── input-1.js │ │ │ └── input-2.js │ │ └── index.ts │ └── transform │ │ ├── imports │ │ ├── input.js │ │ └── output.js │ │ ├── basic │ │ ├── input.js │ │ └── output.js │ │ ├── exports │ │ ├── input.js │ │ └── output.js │ │ └── index.ts ├── README.md ├── src │ ├── scratchpad │ │ ├── file-2.js │ │ └── file-1.js │ ├── cli.ts │ ├── scratchpad.ts │ ├── index.ts │ ├── compile-typescript.ts │ └── engine.ts ├── tsconfig.json └── package.json ├── .deepsource.toml ├── demos ├── emacs │ ├── basic.gif │ ├── basic.webm │ ├── modules.gif │ └── modules.webm └── vscode │ ├── basic.gif │ └── modules.gif ├── vscode ├── .vscodeignore ├── .vscode │ ├── extensions.json │ ├── tasks.json │ ├── settings.json │ └── launch.json ├── CHANGELOG.md ├── tsconfig.json ├── src │ ├── test │ │ ├── suite │ │ │ ├── extension.test.ts │ │ │ └── index.ts │ │ └── runTest.ts │ └── extension.ts ├── .eslintrc.json ├── README.md ├── package.json ├── vsc-extension-quickstart.md └── LICENSE ├── .gitignore ├── .editorconfig ├── notes.org ├── README.md ├── skerrick.el └── LICENSE /server/.npmignore: -------------------------------------------------------------------------------- 1 | /src 2 | -------------------------------------------------------------------------------- /server/test/evaluate/async/output.js: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /server/test/evaluate/basic/output.js: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /server/test/evaluate/scratchpad/output-1.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /server/test/evaluate/scratchpad/output.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/output-6.js: -------------------------------------------------------------------------------- 1 | 200 -------------------------------------------------------------------------------- /server/test/evaluate/native-addons/output.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /server/test/evaluate/basic/input.js: -------------------------------------------------------------------------------- 1 | const x = 42; 2 | x; 3 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/output-3.js: -------------------------------------------------------------------------------- 1 | 42 2 | // --- 3 | 100 -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/output-2.js: -------------------------------------------------------------------------------- 1 | 20 -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/output-3.js: -------------------------------------------------------------------------------- 1 | 400 -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/output-4.js: -------------------------------------------------------------------------------- 1 | 400 -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/output-6.js: -------------------------------------------------------------------------------- 1 | 900 -------------------------------------------------------------------------------- /server/test/evaluate/dynamic-imports/output-1.js: -------------------------------------------------------------------------------- 1 | Symbol([[defaultExport]]) -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | See https://github.com/anonimitoraf/skerrick for more info 2 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/output-4.js: -------------------------------------------------------------------------------- 1 | function () { 2 | return m3.c; 3 | } -------------------------------------------------------------------------------- /server/test/transform/imports/input.js: -------------------------------------------------------------------------------- 1 | import { f, g, h } from '/somewhere' 2 | -------------------------------------------------------------------------------- /server/test/evaluate/scratchpad/output-2.js: -------------------------------------------------------------------------------- 1 | { 2 | "a": 10, 3 | "default": 200 4 | } -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "javascript" 5 | enabled = true -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/input-6.js: -------------------------------------------------------------------------------- 1 | import C from './input-5'; 2 | 3 | new C().g(); 4 | -------------------------------------------------------------------------------- /server/test/evaluate/dynamic-imports/output-2.js: -------------------------------------------------------------------------------- 1 | { 2 | "a": 10, 3 | "default": 200 4 | } -------------------------------------------------------------------------------- /server/test/evaluate/imports-built-ins/output.js: -------------------------------------------------------------------------------- 1 | bleh.png 2 | // --- 3 | .png 4 | // --- 5 | blah -------------------------------------------------------------------------------- /demos/emacs/basic.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anonimitoraf/skerrick/HEAD/demos/emacs/basic.gif -------------------------------------------------------------------------------- /demos/emacs/basic.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anonimitoraf/skerrick/HEAD/demos/emacs/basic.webm -------------------------------------------------------------------------------- /demos/emacs/modules.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anonimitoraf/skerrick/HEAD/demos/emacs/modules.gif -------------------------------------------------------------------------------- /demos/vscode/basic.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anonimitoraf/skerrick/HEAD/demos/vscode/basic.gif -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/output-5.js: -------------------------------------------------------------------------------- 1 | class { 2 | g() { 3 | return 200; 4 | } 5 | 6 | } -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/output-1.js: -------------------------------------------------------------------------------- 1 | function f(x) { 2 | return x + x; 3 | } -------------------------------------------------------------------------------- /demos/emacs/modules.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anonimitoraf/skerrick/HEAD/demos/emacs/modules.webm -------------------------------------------------------------------------------- /demos/vscode/modules.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anonimitoraf/skerrick/HEAD/demos/vscode/modules.gif -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/output-1.js: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": 2 4 | } 5 | // --- 6 | 2 7 | // --- 8 | -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/input-6.js: -------------------------------------------------------------------------------- 1 | import C from './input-5'; 2 | 3 | new C().g(); 4 | -------------------------------------------------------------------------------- /server/test/evaluate/scratchpad/input-1.js: -------------------------------------------------------------------------------- 1 | export const a = 10; 2 | 3 | const b = 200; 4 | export default b; 5 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/input-3.js: -------------------------------------------------------------------------------- 1 | const m2 = require('./input-2'); 2 | m2; 3 | // --- 4 | exports.c = 100; 5 | -------------------------------------------------------------------------------- /server/test/evaluate/dynamic-imports/input-1.js: -------------------------------------------------------------------------------- 1 | export const a = 10; 2 | 3 | const b = 200; 4 | export default b; 5 | -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/input-1.js: -------------------------------------------------------------------------------- 1 | export default function f (x) { 2 | return x + x; 3 | } 4 | -------------------------------------------------------------------------------- /server/test/transform/basic/input.js: -------------------------------------------------------------------------------- 1 | const a = 1; 2 | // --- 3 | let a = 1; 4 | // --- 5 | var a = 1; 6 | // --- 7 | a = 2; 8 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/output-2.js: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": 2 4 | } 5 | // --- 6 | 1 7 | // --- 8 | 2 9 | // --- 10 | 42 -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/output-5.js: -------------------------------------------------------------------------------- 1 | class __defaultExport2 { 2 | g() { 3 | return 900; 4 | } 5 | 6 | } -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/input-5.js: -------------------------------------------------------------------------------- 1 | import f from './input-4'; 2 | f(); 3 | 4 | module.exports = class { 5 | g() { return 200; } 6 | } 7 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/input-1.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | a: 1 3 | } 4 | // --- 5 | module.exports.b = 2; 6 | // --- 7 | // exports.c = 3; 8 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/input-4.js: -------------------------------------------------------------------------------- 1 | const m3 = require('./input-3'); 2 | m3.c; 3 | 4 | module.exports = function () { 5 | return m3.c; 6 | } 7 | -------------------------------------------------------------------------------- /server/test/transform/imports/output.js: -------------------------------------------------------------------------------- 1 | registerValue("/input.js", "h", h) 2 | registerValue("/input.js", "g", g) 3 | registerValue("/input.js", "f", f) -------------------------------------------------------------------------------- /server/test/evaluate/native-addons/input.js: -------------------------------------------------------------------------------- 1 | const print = require('a-native-example') 2 | 3 | print('hello world') // will print "hello world" from C++ 4 | -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/input-5.js: -------------------------------------------------------------------------------- 1 | import f from './input-4'; 2 | 3 | f(); 4 | 5 | export default class { 6 | g() { return 900; } 7 | } 8 | -------------------------------------------------------------------------------- /server/test/evaluate/exports-and-imports/output-1.js: -------------------------------------------------------------------------------- 1 | 84 2 | // --- 3 | f 4 | // --- 5 | f1 6 | // --- 7 | f 8 | // --- 9 | h 10 | // --- 11 | x1 12 | // --- 13 | -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/input-2.js: -------------------------------------------------------------------------------- 1 | import defaultExport from './input-1.js' 2 | 3 | const y = defaultExport(10); 4 | export default y; 5 | 6 | y; 7 | -------------------------------------------------------------------------------- /server/test/evaluate/scratchpad/input-2.js: -------------------------------------------------------------------------------- 1 | (async () => { 2 | const m = await import('./input-1'); 3 | console.log('Module imported dynamically', m); 4 | return m; 5 | })(); 6 | -------------------------------------------------------------------------------- /vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | src/** 4 | .gitignore 5 | .yarnrc 6 | vsc-extension-quickstart.md 7 | **/tsconfig.json 8 | **/.eslintrc.json 9 | **/*.map 10 | **/*.ts 11 | -------------------------------------------------------------------------------- /server/test/evaluate/commonjs/input-2.js: -------------------------------------------------------------------------------- 1 | const m1 = require('./input-1'); 2 | m1; 3 | // --- 4 | m1.a; 5 | // --- 6 | const { b } = require('./input-1'); 7 | b; 8 | // --- 9 | module.exports = 42; 10 | -------------------------------------------------------------------------------- /server/test/evaluate/async/input.js: -------------------------------------------------------------------------------- 1 | const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); 2 | (async () => { 3 | await sleep(2000); 4 | console.log('after some sleep'); 5 | return 42; 6 | })(); 7 | -------------------------------------------------------------------------------- /vscode/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | *.log 4 | tmp/ 5 | 6 | *.tern-port 7 | node_modules/ 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | *.tsbuildinfo 12 | .npm 13 | .eslintcache 14 | /server/dist 15 | /vscode/out 16 | .npmrc 17 | -------------------------------------------------------------------------------- /server/test/evaluate/scratchpad/input.js: -------------------------------------------------------------------------------- 1 | export const a = 10; 2 | 3 | const b = 200; 4 | export default b; 5 | 6 | console.log(require('path')); 7 | const print = require('a-native-example') 8 | print('hello world') // will print "hello world" from C++ 9 | -------------------------------------------------------------------------------- /server/test/transform/basic/output.js: -------------------------------------------------------------------------------- 1 | const a = 1; 2 | registerValue("/input.js", "a", a) 3 | // --- 4 | let a = 1; 5 | registerValue("/input.js", "a", a) 6 | // --- 7 | var a = 1; 8 | registerValue("/input.js", "a", a) 9 | // --- 10 | return a = 2; -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/input-3.js: -------------------------------------------------------------------------------- 1 | import defaultExport from './input-2.js' 2 | 3 | export default class Foo { 4 | bar () { 5 | return defaultExport * defaultExport; 6 | } 7 | } 8 | 9 | const foo = new Foo(); 10 | foo.bar(); 11 | -------------------------------------------------------------------------------- /server/test/evaluate/dynamic-imports/input-2.js: -------------------------------------------------------------------------------- 1 | (async () => { 2 | const p = await import('path'); 3 | const m = await import('./input-1'); 4 | console.log('Built-in imported dynamically', p.basename); 5 | console.log('Module imported dynamically', m); 6 | return m; 7 | })(); 8 | -------------------------------------------------------------------------------- /server/test/evaluate/imports-built-ins/input.js: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | path.basename('/blah/bleh.png'); 3 | // --- 4 | import pathDefault from 'path'; 5 | pathDefault.extname('/blah/bleh.png'); 6 | // --- 7 | import { Buffer } from 'buffer'; 8 | Buffer.from('blah').toString(); 9 | -------------------------------------------------------------------------------- /vscode/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "skerrick" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release 10 | -------------------------------------------------------------------------------- /server/test/evaluate/exports-and-imports/output-2.js: -------------------------------------------------------------------------------- 1 | 20 2 | // --- 3 | 30 4 | // --- 5 | 30 6 | // --- 7 | 60 8 | // --- 9 | 90 10 | // --- 11 | 400 12 | // --- 13 | 14 | // --- 15 | 1.5 16 | // --- 17 | 1.5 18 | // --- 19 | 2 20 | // --- 21 | 3 22 | // --- 23 | 3 24 | // --- 25 | 4 26 | // --- 27 | -------------------------------------------------------------------------------- /server/src/scratchpad/file-2.js: -------------------------------------------------------------------------------- 1 | // import { a, b } from './file-1'; 2 | 3 | // a; 4 | // b; 5 | 6 | // console.log(a); 7 | 8 | // export const c = 5; 9 | 10 | module.exports = { 11 | c: 5, 12 | d: 6, 13 | default: 7 14 | } 15 | // module.exports['c'] = 5; 16 | 17 | // const x = 42; 18 | // export default x; 19 | -------------------------------------------------------------------------------- /server/test/evaluate/default-exports-and-imports/input-4.js: -------------------------------------------------------------------------------- 1 | import Foo from './input-3.js' 2 | 3 | const foo = new Foo(); 4 | 5 | class Baz { 6 | foo () { return foo; } 7 | } 8 | 9 | /** Returns the bar of foo */ 10 | export default function () { 11 | return foo.bar(); 12 | } 13 | 14 | new Baz().foo().bar(); 15 | -------------------------------------------------------------------------------- /vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES2020", 5 | "outDir": "out", 6 | "lib": [ 7 | "ES2020" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "esModuleInterop": true, 12 | "strict": true, 13 | "noImplicitAny": false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # Indentation 12 | [*] 13 | indent_style = space 14 | indent_size = 2 15 | -------------------------------------------------------------------------------- /server/src/cli.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { serve } from '.'; 4 | 5 | const [,, port, entrypoint, evalImports] = process.argv; 6 | console.log('--- Port:', port); 7 | console.log('--- Entry point', entrypoint); 8 | console.log('--- Eval imports?', evalImports === 'true'); 9 | serve(parseInt(port), entrypoint, evalImports === 'true'); 10 | -------------------------------------------------------------------------------- /server/src/scratchpad.ts: -------------------------------------------------------------------------------- 1 | import { transform } from './engine' 2 | 3 | function transformLog(code) { 4 | const modulePath = '/some-module.js'; 5 | console.log(transform(modulePath, code)); 6 | console.log(); 7 | } 8 | 9 | // transformLog('export const x = 42;'); 10 | // transformLog('const y = 21; export { y as y1 };'); 11 | transformLog('import { x } from "./blah"; export { y as y2 };'); 12 | transformLog('export { y };'); 13 | -------------------------------------------------------------------------------- /server/test/evaluate/exports-and-imports/input-1.js: -------------------------------------------------------------------------------- 1 | export function f(x) { 2 | return x + x; 3 | } 4 | f(42); 5 | // --- 6 | export { f }; 7 | // --- 8 | export { f as f1 }; 9 | // --- 10 | export function g(x) { 11 | return f(x) + x; 12 | } 13 | export { g as g1 }; 14 | export { f, g as g2 }; 15 | // --- 16 | function h (x) { 17 | return g(x) + x; 18 | } 19 | export { h }; 20 | // --- 21 | export const x = 1.5; 22 | const y = 2; 23 | export { x as x1, y }; 24 | // --- 25 | -------------------------------------------------------------------------------- /vscode/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /vscode/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off" 11 | } -------------------------------------------------------------------------------- /vscode/src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /server/test/evaluate/exports-and-imports/input-2.js: -------------------------------------------------------------------------------- 1 | import { f, f1 } from './input-1.js'; 2 | f(10); 3 | // --- 4 | f1(15); 5 | // --- 6 | import { g, g1, g2 } from './input-1.js' 7 | g(10); 8 | // --- 9 | g1(20); 10 | // --- 11 | g2(30); 12 | // --- 13 | import { h } from './input-1.js' 14 | h(100); 15 | // --- 16 | import { x, x1, y } from './input-1.js' 17 | // --- 18 | x 19 | // --- 20 | x1 21 | // --- 22 | y 23 | // --- 24 | f(x); 25 | // --- 26 | f(x1); 27 | // --- 28 | f(y); 29 | // --- 30 | // import defaultFn from '/input-1.js'; 31 | // defaultFn.f(2); 32 | -------------------------------------------------------------------------------- /vscode/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | }, 19 | "ignorePatterns": [ 20 | "out", 21 | "dist", 22 | "**/*.d.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /server/src/scratchpad/file-1.js: -------------------------------------------------------------------------------- 1 | import { c } from './file-2'; 2 | const r = require('./file-2'); 3 | r; 4 | // r.c; 5 | // r.d; 6 | // r.default; 7 | 8 | // c; 9 | // export const a = 1 + c; 10 | // export const b = 2; 11 | // d; 12 | 13 | // WORKS 14 | // import { add } from 'lodash'; 15 | // add(2, 2); 16 | 17 | // WORKS 18 | // import * as _ from 'lodash'; 19 | // _.add(3, 3); 20 | // _; 21 | 22 | // // WORKS 23 | // import _ from 'lodash'; 24 | // _.add(1, 1); 25 | 26 | // console.log('RRRRR', require('lodash')); 27 | // const _ = require('lodash'); 28 | // _.add(3, 3); 29 | 30 | // import * as file2 from './file-2'; 31 | // file2; 32 | -------------------------------------------------------------------------------- /server/test/transform/exports/input.js: -------------------------------------------------------------------------------- 1 | export const x = 1; 2 | // --- 3 | export function f (x) { return x } 4 | // --- 5 | const x = 1; 6 | export { x }; 7 | // --- 8 | const x = 1; 9 | const y = 2; 10 | export { x, y }; 11 | // --- 12 | const x = 1; 13 | const y = 2; 14 | export { x as x1, y as y1 }; 15 | // --- 16 | const x = 1; 17 | const y = 2; 18 | export { x as x1, y }; 19 | // --- 20 | const x = 1; 21 | export { x as x1, y }; 22 | // --- 23 | export { x as x1, y }; 24 | export { a }; 25 | export { b }; 26 | // --- 27 | const x = 1; 28 | export default x; 29 | // --- 30 | export const a = 1; 31 | export const b = 1; 32 | export const c = 1; 33 | -------------------------------------------------------------------------------- /vscode/src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": [ 4 | "ESNext" 5 | ], 6 | "outDir": "dist", 7 | "removeComments": false, 8 | "target": "ES6", 9 | "esModuleInterop": true, 10 | "moduleResolution": "node", 11 | "module": "CommonJS", 12 | "paths": {}, 13 | "sourceMap": true, 14 | "sourceRoot": "/", 15 | "alwaysStrict": false, 16 | "allowUnreachableCode": true, 17 | "noImplicitAny": false, 18 | "noImplicitUseStrict": true, 19 | "strictNullChecks": true, 20 | "noImplicitReturns": false, 21 | "noUncheckedIndexedAccess": false, 22 | "noUnusedLocals": false, 23 | "noUnusedParameters": false, 24 | "strict": false, 25 | "declaration": true 26 | }, 27 | "include": ["src/**/*.ts"], 28 | "exclude": [ 29 | "node_modules/**/*" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /server/test/transform/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import fs from 'fs' 3 | import { transform } from '../../engine' 4 | import { serve } from '../..'; 5 | 6 | const stopServer = serve(); 7 | 8 | const dirs = [ 9 | 'basic', 10 | 'exports', 11 | 'imports' 12 | ] 13 | 14 | for (const dir of dirs) { 15 | const inputPath = path.join(__dirname, dir, 'input.js'); 16 | const outputPath = path.join(__dirname, dir, 'output.js'); 17 | 18 | const delimiter = "// ---"; 19 | const blocksToEval = fs.readFileSync(inputPath, 'utf-8').split(delimiter); 20 | const output = blocksToEval 21 | .map(code => { 22 | try { 23 | return transform('/input.js', code); 24 | } catch (e) { 25 | return e.stack || e.message; 26 | } 27 | }) 28 | .join('\n' + delimiter + '\n'); 29 | fs.writeFileSync(outputPath, output); 30 | } 31 | 32 | stopServer(); 33 | -------------------------------------------------------------------------------- /vscode/src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import Mocha from 'mocha'; 3 | import glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /vscode/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "${defaultBuildTask}" 19 | }, 20 | { 21 | "name": "Extension Tests", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "args": [ 25 | "--extensionDevelopmentPath=${workspaceFolder}", 26 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 27 | ], 28 | "outFiles": [ 29 | "${workspaceFolder}/out/test/**/*.js" 30 | ], 31 | "preLaunchTask": "${defaultBuildTask}" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "skerrick", 3 | "version": "0.0.9", 4 | "description": "", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/anonimitoraf/skerrick.git" 8 | }, 9 | "main": "dist/index.js", 10 | "scripts": { 11 | "build": "rimraf dist && tsc", 12 | "build:watch": "rimraf dist && tsc -w", 13 | "prepublishOnly": "npm run build", 14 | "start": "ts-node index.ts", 15 | "test:transform": "ts-node test/transform/index.ts", 16 | "test:evaluate": "ts-node test/evaluate/index.ts", 17 | "test:evaluate:scratch": "ts-node test/evaluate/index.ts scratch" 18 | }, 19 | "author": "Rafael Nicdao", 20 | "license": "GPL-3.0", 21 | "dependencies": { 22 | "@babel/core": "^7.16.7", 23 | "@babel/parser": "^7.16.7", 24 | "@babel/types": "^7.16.7", 25 | "a-native-example": "^1.0.0", 26 | "babel-plugin-source-map-support": "^2.1.3", 27 | "babel-plugin-transform-commonjs": "^1.1.6", 28 | "capture-console": "^1.0.1", 29 | "express": "^4.17.2", 30 | "lodash": "^4.17.21", 31 | "source-map-support": "^0.5.21", 32 | "strip-color": "^0.1.0", 33 | "typescript": "^4.5.5", 34 | "uuid": "^8.3.2" 35 | }, 36 | "devDependencies": { 37 | "@types/babel__core": "^7.1.18", 38 | "@types/express": "^4.17.13", 39 | "@types/lodash": "^4.14.178", 40 | "@types/node": "^17.0.8", 41 | "@types/uuid": "^8.3.4", 42 | "rimraf": "^3.0.2" 43 | }, 44 | "bin": { 45 | "skerrick": "./dist/cli.js" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vscode/README.md: -------------------------------------------------------------------------------- 1 | REPL-driven development for NodeJS! 2 | 3 | See https://github.com/anonimitoraf/skerrick for more info 4 | 5 | # Installation 6 | 7 | Check it out: https://marketplace.visualstudio.com/items?itemName=anonimitoraf.skerrick 8 | 9 | # Features 10 | 11 | * Make changes to your running program without having to restart it! 12 | 13 | Is this like hot-reloading? 14 | Yes, but (arguably) even better, because you choose which code to evaluate! With hot-reloading, your code gets re-evaluated for every change you make, whether you want to or not. 15 | * Evaluate code and see the results inline - A feedback loop that is faster than ever! 16 | 17 | # Demos 18 | 19 | ### Basic 20 | ![Basic usage](/demos/vscode/basic.gif) 21 | 22 | ### Module support 23 | ![Module support](/demos/vscode/modules.gif) 24 | 25 | # Configuration 26 | | Configuration | Desc | Default | 27 | |:--|:--|:--| 28 | | `skerrick.serverPort` | Port to run the `skerrick` server on | 4321 | 29 | | `skerrick.resultOverlayCharCountTrunc` | Results with char count longer than this are truncated | 120 | 30 | 31 | # Usage 32 | | Command | Desc | 33 | |:--|:--| 34 | | `Skerrick: Start server` | Starts the server. Note that your current buffer will be evaluated, so you probably want to run this command while being on your program's entry point file. | 35 | | `Skerrick: Stop server` | Stops the server. | 36 | | `Skerrick: Evaluate selected code` | Evaluates the selected region. Shows the eval result as an overlay. Result/stdout/stderr get written to the `Output > Skerrick` panel. | 37 | 38 | # Known Issues 39 | 40 | See https://github.com/anonimitoraf/skerrick/issues 41 | -------------------------------------------------------------------------------- /server/test/transform/exports/output.js: -------------------------------------------------------------------------------- 1 | const x = 1; 2 | registerValueExport("/input.js", "x", "x"); 3 | return registerValue("/input.js", "x", x); 4 | // --- 5 | function f(x) { 6 | return x; 7 | } 8 | 9 | registerValueExport("/input.js", "f", "f") 10 | registerValue("/input.js", "f", f) 11 | // --- 12 | const x = 1; 13 | registerValue("/input.js", "x", x) 14 | registerValueExport("/input.js", "x", "x") 15 | // --- 16 | const x = 1; 17 | registerValue("/input.js", "x", x) 18 | const y = 2; 19 | registerValue("/input.js", "y", y) 20 | registerValueExport("/input.js", "y", "y") 21 | registerValueExport("/input.js", "x", "x") 22 | // --- 23 | const x = 1; 24 | registerValue("/input.js", "x", x) 25 | const y = 2; 26 | registerValue("/input.js", "y", y) 27 | registerValueExport("/input.js", "y", "y1") 28 | registerValueExport("/input.js", "x", "x1") 29 | // --- 30 | const x = 1; 31 | registerValue("/input.js", "x", x) 32 | const y = 2; 33 | registerValue("/input.js", "y", y) 34 | registerValueExport("/input.js", "y", "y") 35 | registerValueExport("/input.js", "x", "x1") 36 | // --- 37 | const x = 1; 38 | registerValue("/input.js", "x", x) 39 | registerValueExport("/input.js", "y", "y") 40 | registerValueExport("/input.js", "x", "x1") 41 | // --- 42 | registerValueExport("/input.js", "y", "y") 43 | registerValueExport("/input.js", "x", "x1") 44 | registerValueExport("/input.js", "a", "a") 45 | registerValueExport("/input.js", "b", "b") 46 | // --- 47 | const x = 1; 48 | registerValue("/input.js", "x", x) 49 | x; 50 | registerDefaultValueExport("/input.js", "x") 51 | // --- 52 | const a = 1; 53 | registerValueExport("/input.js", "a", "a"); 54 | registerValue("/input.js", "a", a); 55 | const b = 1; 56 | registerValueExport("/input.js", "b", "b"); 57 | registerValue("/input.js", "b", b); 58 | const c = 1; 59 | registerValueExport("/input.js", "c", "c"); 60 | return registerValue("/input.js", "c", c); -------------------------------------------------------------------------------- /server/test/evaluate/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import fs from 'fs' 3 | import { evaluate } from '../../src/engine' 4 | import { serve } from '../..'; 5 | 6 | const stopServer = serve(); 7 | 8 | const isScratch = process.argv[2] === 'scratch'; 9 | 10 | const dirs = isScratch 11 | ? ['scratchpad'] 12 | : [ 13 | 'basic', 14 | 'exports-and-imports', 15 | 'default-exports-and-imports', 16 | 'imports-built-ins', 17 | 'commonjs', 18 | 'async', 19 | 'native-addons', 20 | 'dynamic-imports' 21 | ] 22 | 23 | const delimiter = "// ---"; 24 | 25 | (async () => { 26 | for (const dir of dirs) { 27 | console.log('--------------------------------------------------------'); 28 | console.log(' Evaluation: ' + dir); 29 | console.log('--------------------------------------------------------'); 30 | 31 | const rootDir = path.join(__dirname, dir); 32 | 33 | const inputAndOutputPaths = fs.readdirSync(rootDir) 34 | .filter(f => /^input.*/.test(f)) 35 | .map(f => [f, f.replace(/^input(.*)/, 'output$1')]) 36 | .map(([input, output]) => [path.join(rootDir, input), path.join(rootDir, output)]); 37 | 38 | for (const [inputPath, outputPath] of inputAndOutputPaths) { 39 | const inputBlocksToEval = fs.readFileSync(inputPath, 'utf-8').split(delimiter); 40 | fs.writeFileSync(outputPath, ''); 41 | await Promise.all(inputBlocksToEval 42 | .map(code => { 43 | try { 44 | // `/` to force the filename to be treated as absolute 45 | return evaluate(inputPath, code, true, isScratch); 46 | } catch (e) { 47 | return Promise.resolve(e.stack || e.message); 48 | } 49 | })).then(xs => fs.writeFileSync(outputPath, xs 50 | .map(x => typeof x === 'object' ? JSON.stringify(x, null, 2) : x) 51 | .join('\n' + delimiter + '\n') 52 | )); 53 | } 54 | } 55 | })(); 56 | 57 | stopServer(); 58 | -------------------------------------------------------------------------------- /notes.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Notes 2 | 3 | * Test Suite 4 | - [ ] Make it easy to visually map the input lines of code -> output lines 5 | * TODOs - Server 6 | - [X] Fix exports: bindings being repeated N! times 7 | - [X] Support importing of built-ins (e.g. ='fs'=) 8 | - [X] Auto-evaluation of dependencies (e.g. starting from =index.js=) 9 | - [X] Test if cyclic deps are supported 10 | - The problem here is that the Skerrick needs to be able to access all the files of the project. 11 | - Either, Skerrick is started as part of the project OR 12 | - The editor sends Skerrick the files it needs to evaluate - 2 way comms needed 13 | For now, I'll support the former since it seems easier to do. Actually, the latter might not be feasible. Imagine having to send MBs of node_modules files across the wire! 14 | - [-] Support commonjs modules [5/17] 15 | - [X] module.exports = { x: 1 } 16 | - [X] module.exports.x = 'something' 17 | - [X] exports.x = 'something' 18 | - [X] require('ns') 19 | - [ ] require.resolve 20 | - [ ] require.cache 21 | - [ ] require.main 22 | - [ ] module.children 23 | - [ ] module.filename 24 | - [ ] module.id 25 | - [ ] module.isPreloading 26 | - [ ] module.loaded 27 | - [ ] module.path 28 | - [ ] module.paths 29 | - [ ] module.require 30 | - [X] Auto-eval of cjs stuff. At the moment only es6 ones get auto-eval 31 | - [ ] Clean up of exports. At the moment, intermediate values stay in the namespaces 32 | - [X] Support dynamic imports 33 | - [X] Check behavior of native libs - is special consideration needed? 34 | - [ ] Typescript support 35 | - [ ] Stack traces 36 | * TODOs - Emacs 37 | - [X] JSON outputs are showing up as plists 38 | - [X] Overlays should disappear on movement 39 | - [X] Support result truncation 40 | - [X] Focus stdout/stderr buffer on eval, when needed 41 | * TODOs - VSCode 42 | - [X] Command to start/stop server 43 | - [X] Support result truncation 44 | - [X] Focus stdout/stderr buffer on eval, when needed 45 | - [ ] Icon 46 | * Document caveats 47 | - Normal execution: error when undefined identifier vs Skerrick: No error 48 | -------------------------------------------------------------------------------- /server/src/index.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import express from 'express'; 4 | import process from 'process'; 5 | import stripColor from 'strip-color'; 6 | import captureConsole from 'capture-console'; 7 | import { evaluate } from './engine'; 8 | 9 | /** Instantiates a Skerrick server. Returns a fn that stops the server. */ 10 | export function serve(port = 4321, entryFilePath?: string, evalImports?: boolean) { 11 | if (entryFilePath) { 12 | if (!path.isAbsolute(entryFilePath)) { 13 | throw Error(`Entry file path needs to be absolute. Got ${entryFilePath}`); 14 | } 15 | evaluate(entryFilePath, fs.readFileSync(entryFilePath, { encoding: 'utf-8' }), true, true); 16 | } 17 | 18 | const server = express(); 19 | 20 | let stdout = ''; 21 | let stderr = ''; 22 | 23 | server.use(express.urlencoded({ extended: true })); 24 | server.use(express.json()); 25 | 26 | server.post('/eval', async (req, res) => { 27 | const { code, modulePath } = req.body; 28 | 29 | if (!modulePath || !code) { 30 | throw new Error(`Both modulePath and code are required in the req body!`); 31 | } 32 | if (!path.isAbsolute(modulePath)) { 33 | return res.status(500).send(`Only absolute paths allowed! Got ${modulePath} instead`); 34 | } 35 | 36 | try { 37 | const result = await evaluate(modulePath, code, evalImports, false); 38 | res.status(200).send({ result, stdout, stderr }); 39 | } catch (e) { 40 | res.status(200).send({ stderr: removeEscapeCodes(e.stack || e.message) }); 41 | } 42 | 43 | // Clean up for the next request 44 | stdout = ''; 45 | stderr = ''; 46 | }) 47 | 48 | const serverInstance = server.listen(port, () => { 49 | console.log(`Skerrick server listening on port ${port}`); 50 | 51 | captureConsole.startCapture(process.stdout, function(v) { 52 | stdout = stripColor(v); 53 | }); 54 | 55 | captureConsole.startCapture(process.stderr, function(v) { 56 | stderr = stripColor(v); 57 | }); 58 | }); 59 | 60 | return () => serverInstance.close(); 61 | } 62 | 63 | const escapeCodeRe = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; 64 | function removeEscapeCodes(s: string | undefined) { 65 | return s?.replace(escapeCodeRe, ''); 66 | } 67 | -------------------------------------------------------------------------------- /vscode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "skerrick", 3 | "displayName": "Skerrick", 4 | "description": "REPL-driven development for NodeJS", 5 | "version": "0.1.0", 6 | "repository": { 7 | "url": "https://github.com/anonimitoraf/skerrick" 8 | }, 9 | "license": "GPL-3.0", 10 | "engines": { 11 | "vscode": "^1.64.0" 12 | }, 13 | "publisher": "anonimitoraf", 14 | "categories": [ 15 | "Other" 16 | ], 17 | "activationEvents": [ 18 | "onCommand:skerrick.evalSelected", 19 | "onCommand:skerrick.startServer", 20 | "onCommand:skerrick.stopServer" 21 | ], 22 | "main": "./out/extension.js", 23 | "contributes": { 24 | "commands": [ 25 | { 26 | "command": "skerrick.evalSelected", 27 | "title": "Skerrick: Evaluate selected code" 28 | }, 29 | { 30 | "command": "skerrick.startServer", 31 | "title": "Skerrick: Start server. NOTE: This will evaluate the current file" 32 | }, 33 | { 34 | "command": "skerrick.stopServer", 35 | "title": "Skerrick: Stop server" 36 | } 37 | ], 38 | "configuration": { 39 | "title": "Skerrick", 40 | "properties": { 41 | "skerrick.resultOverlayCharCountTrunc": { 42 | "type": "number", 43 | "default": 120, 44 | "description": "Evaluation results longer than this, will be shown as overlays with truncated contents. Full results can be found in the Ouput > Skerrick panel" 45 | }, 46 | "skerrick.serverPort": { 47 | "type": "number", 48 | "default": 4321, 49 | "description": "Port to run the skerrick server on" 50 | } 51 | } 52 | } 53 | }, 54 | "scripts": { 55 | "vscode:prepublish": "npm run compile", 56 | "compile": "tsc -p ./", 57 | "watch": "tsc -watch -p ./", 58 | "pretest": "npm run compile && npm run lint", 59 | "lint": "eslint src --ext ts", 60 | "test": "node ./out/test/runTest.js" 61 | }, 62 | "devDependencies": { 63 | "@types/glob": "^7.2.0", 64 | "@types/mocha": "^9.0.0", 65 | "@types/node": "14.x", 66 | "@types/vscode": "^1.64.0", 67 | "@typescript-eslint/eslint-plugin": "^5.9.1", 68 | "@typescript-eslint/parser": "^5.9.1", 69 | "@vscode/test-electron": "^2.0.3", 70 | "eslint": "^8.6.0", 71 | "glob": "^7.2.0", 72 | "mocha": "^9.1.3", 73 | "typescript": "^4.5.4" 74 | }, 75 | "dependencies": { 76 | "axios": "^0.25.0", 77 | "chalk": "^4.1.2", 78 | "skerrick": "^0.0.7" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vscode/vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your extension and command. 7 | * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `src/extension.ts` - this is the main file where you will provide the implementation of your command. 9 | * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 10 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. 11 | 12 | ## Get up and running straight away 13 | 14 | * Press `F5` to open a new window with your extension loaded. 15 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 16 | * Set breakpoints in your code inside `src/extension.ts` to debug your extension. 17 | * Find output from your extension in the debug console. 18 | 19 | ## Make changes 20 | 21 | * You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. 22 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 23 | 24 | 25 | ## Explore the API 26 | 27 | * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. 28 | 29 | ## Run tests 30 | 31 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. 32 | * Press `F5` to run the tests in a new window with your extension loaded. 33 | * See the output of the test result in the debug console. 34 | * Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder. 35 | * The provided test runner will only consider files matching the name pattern `**.test.ts`. 36 | * You can create folders inside the `test` folder to structure your tests any way you want. 37 | 38 | ## Go further 39 | 40 | * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). 41 | * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace. 42 | * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). 43 | -------------------------------------------------------------------------------- /server/src/compile-typescript.ts: -------------------------------------------------------------------------------- 1 | // COPIED FROM https://github.com/ashleydavis/typescript-compilation-example/blob/master/src/index.ts 2 | import ts from "typescript"; 3 | 4 | // 5 | // A snippet of TypeScript code that has a semantic/type error in it. 6 | // 7 | const code 8 | = "function foo(input: number) {\n" 9 | + " console.log('Hello!');\n" 10 | + "};\n" 11 | + "foo('x');" 12 | ; 13 | 14 | // 15 | // Result of compiling TypeScript code. 16 | // 17 | export interface CompilationResult { 18 | code?: string; 19 | diagnostics: ts.Diagnostic[] 20 | }; 21 | 22 | // 23 | // Check and compile in-memory TypeScript code for errors. 24 | // 25 | function compileTypeScriptCode(code: string, libs: string[]): CompilationResult { 26 | const options = ts.getDefaultCompilerOptions(); 27 | const realHost = ts.createCompilerHost(options, true); 28 | 29 | const dummyFilePath = "/in-memory-file.ts"; 30 | const dummySourceFile = ts.createSourceFile(dummyFilePath, code, ts.ScriptTarget.Latest); 31 | let outputCode: string | undefined = undefined; 32 | 33 | const host: ts.CompilerHost = { 34 | fileExists: filePath => filePath === dummyFilePath || realHost.fileExists(filePath), 35 | directoryExists: realHost.directoryExists && realHost.directoryExists.bind(realHost), 36 | getCurrentDirectory: realHost.getCurrentDirectory.bind(realHost), 37 | getDirectories: realHost.getDirectories?.bind(realHost), 38 | getCanonicalFileName: fileName => realHost.getCanonicalFileName(fileName), 39 | getNewLine: realHost.getNewLine.bind(realHost), 40 | getDefaultLibFileName: realHost.getDefaultLibFileName.bind(realHost), 41 | getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile) => fileName === dummyFilePath 42 | ? dummySourceFile 43 | : realHost.getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile), 44 | readFile: filePath => filePath === dummyFilePath 45 | ? code 46 | : realHost.readFile(filePath), 47 | useCaseSensitiveFileNames: () => realHost.useCaseSensitiveFileNames(), 48 | writeFile: (fileName, data) => outputCode = data, 49 | }; 50 | 51 | const rootNames = libs.map(lib => require.resolve(`typescript/lib/lib.${lib}.d.ts`)); 52 | const program = ts.createProgram(rootNames.concat([dummyFilePath]), options, host); 53 | const emitResult = program.emit(); 54 | const diagnostics = ts.getPreEmitDiagnostics(program); 55 | return { 56 | code: outputCode, 57 | diagnostics: emitResult.diagnostics.concat(diagnostics) 58 | }; 59 | } 60 | 61 | console.log("==== Evaluating code ===="); 62 | console.log(code); 63 | console.log(); 64 | 65 | const libs = ['es2015']; 66 | const result = compileTypeScriptCode(code, libs); 67 | 68 | console.log("==== Output code ===="); 69 | console.log(result.code); 70 | console.log(); 71 | 72 | console.log("==== Diagnostics ===="); 73 | for (const diagnostic of result.diagnostics) { 74 | console.log(diagnostic.messageText); 75 | } 76 | console.log(); 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Skerrick 2 | 3 | > noun: **skerrick** 4 | > the smallest bit. 5 | > _"there's not a skerrick of food in the house"_ 6 | 7 | **REPL-driven development for NodeJS** 8 | * Programming in tiny increments - Apply patches to your running program without having to restart it 9 | * [Tell me more!](https://purelyfunctional.tv/lesson/what-is-repl-driven-development/) 10 | 11 | Inspired by (check them out!): 12 | * SLIME: The Superior Lisp Interaction Mode for Emacs 13 | * CIDER: The Clojure(Script) Interactive Development Environment that Rocks! 14 | * Calva: integrated REPL powered environment for enjoyable and productive Clojure and ClojureScript development in Visual Studio Code 15 | 16 | ## :warning: DISCLAIMERS :warning: 17 | * THIS PROJECT IS IN ALPHA STATE! I WOULD APPRECIATE IT IF YOU REPORT ANY BUGS/ISSUES YOU FIND. MAYBE EVEN CONTRIBUTE PATCHES/FIXES IF YOU HAVE THE TIME ;) 18 | * The code is currently very messy and not well-written. I just wanted to get a working prototype out of the door as quickly as I could. I will be improving the implementation over time. Feel free to give me suggestions if you have any! 19 | 20 | ## VSCode 21 | 22 | :sparkles: [Documentation](/vscode/README.md) :sparkles: 23 | 24 | ## Emacs 25 | 26 | [![MELPA](https://melpa.org/packages/skerrick-badge.svg)](https://melpa.org/#/skerrick) 27 | 28 | ### Demos 29 | 30 | #### Basic 31 | ![Basic usage](/demos/emacs/basic.gif) 32 | 33 | #### Module support 34 | ![Module support](/demos/emacs/modules.gif) 35 | 36 | ### Requirements 37 | * `node`/`npm` installed and accessible by Emacs 38 | 39 | ### Installation 40 | `skerrick` is in MELPA 41 | 42 | Or, if you're using Quelpa: 43 | ``` 44 | (quelpa '(skerrick :repo "anonimitoraf/skerrick" :fetcher github)) 45 | 46 | ;; Needs to be run on the very first install of skerrick. Or when you want to upgrade. 47 | (unless (equal (shell-command-to-string "type skerrick") "skerrick not found\n") 48 | (skerrick-install-or-upgrade-server-binary)) 49 | 50 | ;; Should be run in a JS buffer; it is buffer specific. 51 | ;; (skerrick-start-server) 52 | 53 | ;; Now main function, entry point is: 54 | ;; M-x skerrick-eval-region 55 | ``` 56 | 57 | It may also be helpful to provide a quick keyboard shortcut. E.g., `C-x C-e` evaluates ELisp, so let's mimic that for JS buffers: 58 | ``` 59 | ;; Evaluate a region, if any is selected; otherwise evaluate the current line. 60 | (bind-key 61 | "C-x C-e" (lambda () 62 | (interactive) 63 | (if (use-region-p) 64 | (skerrick-eval-region) 65 | (beginning-of-line) 66 | (set-mark-command nil) 67 | (end-of-line) 68 | (skerrick-eval-region) 69 | (pop-mark))) 70 | 'js-mode-map) 71 | ``` 72 | 73 | ### Configuration 74 | | Configuration | Desc | Default | 75 | |:--|:--|:--| 76 | | `skerrick-server-port` | Port to run the `skerrick` server on | 4321 | 77 | | `skerrick-result-overlay-face` | Face used to display evaluation results | | 78 | | `skerrick-result-overlay-char-count-trunc` | Results with char count longer than this are truncated | 120 | 79 | | `skerrick-pop-result-buffer-for-stdout` | Show result buffer if stdout is non-empty | t | 80 | | `skerrick-pop-result-buffer-for-stderr` | Show result buffer if stderr is non-empty | t | 81 | 82 | ### Usage 83 | | Command | Desc | 84 | |:--|:--| 85 | | `skerrick-install-or-upgrade-server-binary` | Needs to be run on the very first install of skerrick. Or when you want to upgrade. | 86 | | `skerrick-start-server` | Starts the server. Note that your current buffer will be evaluated, so you probably want to run this command while being on your program's entry point file. | 87 | | `skerrick-stop-server` | Stops the server. | 88 | | `skerrick-eval-region` | Evaluates the selected region. Shows the eval result as an overlay. Stdout/stderr get written to the buffer `*skerrick-stdout-stderr*`. | 89 | 90 | ## Write a plug-in for your editor/IDE! 91 | 92 | [![NPM](https://nodei.co/npm/skerrick.png)](https://nodei.co/npm/skerrick/) 93 | 94 | * `npm install -g skerrick` - this installs the bin `skerrick` 95 | 96 | Invoked like so: `skerrick PORT ENTRYPOINT_FULL_FILE_PATH` 97 | 98 | * The REST protocol is as simple as it can be: 99 | * POST to `/eval` payloads of shape: 100 | ```json 101 | { 102 | "modulePath": "/full/path/to/file/of/code/to/eval", 103 | "code": "const x = 42; console.log(x); x + x;" 104 | } 105 | ``` 106 | * Response shape: 107 | ```json 108 | { 109 | "result": "84", 110 | "stdout": "42", 111 | "stderr": "" 112 | } 113 | ``` 114 | 115 | * :rocket: Tell me about your plug-in so I can add it to this README! :rocket: 116 | -------------------------------------------------------------------------------- /vscode/src/extension.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import { DecorationOptions, Range, TextEditor, TextEditorSelectionChangeKind } from 'vscode'; 3 | import axios, { AxiosInstance } from 'axios'; 4 | import * as skerrickServer from 'skerrick'; 5 | 6 | interface EvalResult { 7 | result: any; 8 | stdout: string; 9 | stderr: string; 10 | } 11 | 12 | let http: AxiosInstance; 13 | 14 | const outputChannel = vscode.window.createOutputChannel('Skerrick'); 15 | 16 | const config = vscode.workspace.getConfiguration('skerrick'); 17 | const configResultOverlayCharCountTrunc: number = config.get('resultOverlayCharCountTrunc') || 120; 18 | const configserverPort: number = config.get('serverPort') || 4321; 19 | 20 | let evalOverlay: DecorationOptions | undefined = undefined; 21 | const overlayType = vscode.window.createTextEditorDecorationType({ 22 | after: { 23 | margin: "0 0 0 0.5rem" 24 | }, 25 | dark: { after: { border: "0.5px solid #808080" } }, 26 | light: { after: { border: "0.5px solid #c5c5c5" } } 27 | }); 28 | 29 | export function activate(context: vscode.ExtensionContext) { 30 | console.log('Skerrick activated'); 31 | 32 | http = axios.create({ baseURL: 'http://localhost:' + configserverPort }); 33 | 34 | // Hide overlays on keyboard movement otherwise, the overlay moves too 35 | vscode.window.onDidChangeTextEditorSelection(event => { 36 | const editor = vscode.window.activeTextEditor; 37 | if (!editor) return; // No open text editor 38 | // (Vim uses "Command events") 39 | if (event.kind === TextEditorSelectionChangeKind.Command 40 | || event.kind === TextEditorSelectionChangeKind.Keyboard) { 41 | hideOverlays(editor); 42 | } 43 | }) 44 | 45 | const evalCommand = vscode.commands.registerCommand('skerrick.evalSelected', async () => { 46 | try { 47 | await evalCode() 48 | } catch (e) { 49 | vscode.window.showErrorMessage(`Failed to evaluate code: ${e}`); 50 | } 51 | }); 52 | const startServerCommand = vscode.commands.registerCommand('skerrick.startServer', startServer); 53 | const stopServerCommand = vscode.commands.registerCommand('skerrick.stopServer', stopServer); 54 | 55 | [evalCommand, startServerCommand, stopServerCommand].forEach(cmd => context.subscriptions.push(cmd)); 56 | } 57 | 58 | async function evalCode() { 59 | const editor = vscode.window.activeTextEditor; 60 | if (!editor) return; // No open text editor 61 | 62 | const { selection } = editor; 63 | 64 | const code = editor.document.getText(selection); 65 | const filePath = editor.document.fileName; 66 | 67 | outputChannel.appendLine(`[EVAL] ${code}`); 68 | const { result, stdout, stderr } = await http.post('/eval', { code, modulePath: filePath }).then(r => r.data); 69 | outputChannel.appendLine(`[RESULT] ${result}`); 70 | 71 | let overlayText: string; 72 | if (result === undefined) { 73 | overlayText = '=> undefined'; 74 | } else if (result.toString().length > configResultOverlayCharCountTrunc) { 75 | overlayText = '=> ' + result.toString().substring(0, configResultOverlayCharCountTrunc) + '... (result truncated, see Output > Skerrick panel)'; 76 | outputChannel.show(true); 77 | } else { 78 | overlayText = '=> ' + result.toString(); 79 | } 80 | 81 | if (stdout) outputChannel.appendLine(`[STDOUT] ${stdout}`); 82 | if (stderr) outputChannel.appendLine(`[STDERR] ${stderr}`); 83 | // TODO Maybe make this configurable 84 | if (stdout?.trim() || stderr?.trim()) { 85 | outputChannel.show(true); 86 | } 87 | 88 | if (!evalOverlay) { 89 | evalOverlay = makeOverlay(selection, overlayText); 90 | } else { 91 | evalOverlay = updateOverlay(evalOverlay, selection, overlayText); 92 | } 93 | editor.setDecorations(overlayType, [evalOverlay]); 94 | } 95 | 96 | function makeOverlay(selection: Range, text: string) { 97 | const decoration: DecorationOptions = { 98 | range: selection, 99 | renderOptions: { after: { contentText: text } } 100 | }; 101 | return decoration; 102 | } 103 | 104 | function updateOverlay(overlay: DecorationOptions, newRange: Range, newText: string) { 105 | overlay.range = newRange; 106 | overlay.renderOptions!.after!.contentText = newText; 107 | return overlay; 108 | } 109 | 110 | function hideOverlays(editor: TextEditor) { 111 | editor.setDecorations(overlayType, []); 112 | } 113 | 114 | let serverInstance: (() => void) | undefined; 115 | 116 | function startServer() { 117 | if (serverInstance) { 118 | outputChannel.appendLine(`[NOTICE]: Attempted to start skerrick server but it's already running. No op...`); 119 | } 120 | 121 | const editor = vscode.window.activeTextEditor; 122 | if (!editor) return; // No open text editor 123 | 124 | const filePath = editor.document.fileName; 125 | serverInstance = skerrickServer.serve(configserverPort, filePath, true); 126 | outputChannel.appendLine(`[NOTICE]: Started skerrick server on port ${configserverPort}`); 127 | } 128 | 129 | function stopServer() { 130 | if (!serverInstance) { 131 | outputChannel.appendLine(`[NOTICE]: Attempted to stop skerrick server but there is no running instance. No op...`); 132 | } else { 133 | serverInstance(); 134 | serverInstance = undefined; 135 | outputChannel.appendLine(`[NOTICE]: Stopped skerrick server on port ${configserverPort}`); 136 | } 137 | } 138 | 139 | // this method is called when your extension is deactivated 140 | export function deactivate() { 141 | stopServer(); 142 | } 143 | -------------------------------------------------------------------------------- /skerrick.el: -------------------------------------------------------------------------------- 1 | ;;; skerrick.el --- REPL-driven development for NodeJS -*- lexical-binding: t; -*- 2 | ;; 3 | ;; Copyright (C) 2022 Rafael Nicdao 4 | ;; 5 | ;; Author: Rafael Nicdao 6 | ;; Maintainer: Rafael Nicdao 7 | ;; Created: January 01, 2022 8 | ;; Modified: January 01, 2022 9 | ;; Version: 0.0.1 10 | ;; Keywords: languages javascript js repl repl-driven 11 | ;; Homepage: https://github.com/anonimitoraf/skerrick 12 | ;; Package-Requires: ((emacs "27.1") (request "0.3.2")) 13 | ;; 14 | ;; This file is not part of GNU Emacs. 15 | ;; 16 | ;; skerrick is free software: you can redistribute it and/or modify 17 | ;; it under the terms of the GNU General Public License as published by 18 | ;; the Free Software Foundation, either version 3 of the License, or 19 | ;; (at your option) any later version. 20 | 21 | ;; skerrick is distributed in the hope that it will be useful, 22 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | ;; GNU General Public License for more details. 25 | 26 | ;; You should have received a copy of the GNU General Public License 27 | ;; along with skerrick. If not, see . 28 | ;; 29 | ;;; Commentary: 30 | ;; REPL-driven development for NodeJS. See https://github.com/anonimitoraf/skerrick for more info. 31 | ;; 32 | ;;; Code: 33 | 34 | (require 'cl-lib) 35 | (require 'request) 36 | 37 | (defface skerrick-result-overlay-face 38 | '((((class color) (background light)) 39 | :background "grey90" 40 | :foreground "black" 41 | :box (:line-width -1 :color "#ECBE7B")) 42 | (((class color) (background dark)) 43 | :background "grey10" 44 | :foreground "#ECBE7B" 45 | :box (:line-width -1 :color "#ECBE7B"))) 46 | "Face used to display evaluation results at the end of line." 47 | :group 'skerrick) 48 | 49 | (defvar skerrick-server-port 4321) 50 | (defvar skerrick-result-overlay-char-count-trunc 120 51 | "If the evaluation result is longer than this, then it's truncated.") 52 | (defvar skerrick-pop-result-buffer-for-stdout t 53 | "Show the result buffer if stderr is non-empty.") 54 | (defvar skerrick-pop-result-buffer-for-stderr t 55 | "Show the result buffer if stderr is non-empty.") 56 | 57 | (defvar skerrick--result-buffer "*skerrick-result*") 58 | (defvar skerrick--eval-overlay nil) 59 | (defvar skerrick--remove-eval-overlay-on-next-cmd? nil) 60 | (defvar skerrick--hooks-setup? nil) 61 | 62 | (defun skerrick--propertize-error (error) 63 | "Style ERROR msg." 64 | (propertize error 'face '(:foreground "red"))) 65 | 66 | (defun skerrick--display-overlay (value face) 67 | "Show an overlay containing VALUE customized by FACE." 68 | (overlay-put skerrick--eval-overlay 'before-string 69 | (propertize value 'face face))) 70 | 71 | (defun skerrick--append-to-process-buffer (value &optional show-buffer?) 72 | "Append VALUE to designated buffer. Optionally, SHOW-BUFFER." 73 | (save-excursion 74 | (with-current-buffer (get-buffer-create skerrick--result-buffer) 75 | (read-only-mode -1) 76 | (goto-char (point-max)) ; Append to buffer 77 | (insert value ?\n) 78 | (read-only-mode +1)) 79 | (when show-buffer? 80 | (display-buffer-in-side-window (get-buffer-create skerrick--result-buffer) '((side . right))) 81 | ;; TODO Scroll down the result buffer/window to the bottom 82 | ))) 83 | 84 | (defun skerrick--process-server-response (response) 85 | "Process RESPONSE from skerrick server." 86 | (let* ((stdout (string-trim (alist-get 'stdout response))) 87 | (stderr (string-trim (alist-get 'stderr response))) 88 | (result (alist-get 'result response)) 89 | (result-str (if result (json-encode result) "undefined"))) 90 | (skerrick--append-to-process-buffer (format "[RESULT] %s" result-str)) 91 | (unless (zerop (length stdout)) 92 | (skerrick--append-to-process-buffer (format "[STDOUT] %s" stdout) 93 | skerrick-pop-result-buffer-for-stdout)) 94 | (unless (zerop (length stderr)) 95 | (skerrick--append-to-process-buffer (format "[STDERR] %s" (skerrick--propertize-error stderr)) 96 | skerrick-pop-result-buffer-for-stderr)) 97 | (skerrick--display-overlay (format " => %s " (if (> (length result-str) skerrick-result-overlay-char-count-trunc) 98 | (format "%s (result truncated, see buffer %s)" 99 | (truncate-string-to-width result-str skerrick-result-overlay-char-count-trunc nil nil t) 100 | skerrick--result-buffer) 101 | result-str)) 102 | 'skerrick-result-overlay-face) 103 | (setq skerrick--remove-eval-overlay-on-next-cmd? t))) 104 | 105 | (defun skerrick--send-eval-req (code module-path) 106 | "Send CODE and MODULE-PATH to sever." 107 | (request 108 | (concat "http://localhost:" (prin1-to-string skerrick-server-port) "/eval") 109 | :type "POST" 110 | :data (json-encode `(("code" . ,code) 111 | ("modulePath" . ,module-path))) 112 | :parser 'json-read 113 | :encoding 'utf-8 114 | :headers '(("Content-Type" . "application/json")) 115 | :success (cl-function (lambda (&key data &allow-other-keys) 116 | (skerrick--process-server-response data))))) 117 | 118 | (defun skerrick-remove-eval-overlay () 119 | "Remove eval overlay." 120 | (interactive) 121 | (when (overlayp skerrick--eval-overlay) 122 | (delete-overlay skerrick--eval-overlay) 123 | (setq skerrick--remove-eval-overlay-on-next-cmd? nil))) 124 | 125 | ;;;###autoload 126 | (defun skerrick-eval-region () 127 | "Evaluate the selected JS code." 128 | (interactive) 129 | (unless skerrick--hooks-setup? 130 | (add-hook 'post-command-hook (lambda () (when skerrick--remove-eval-overlay-on-next-cmd? 131 | (skerrick-remove-eval-overlay)))) 132 | (setq skerrick--hooks-setup? t)) 133 | (let* ((beg (region-beginning)) 134 | (end (region-end)) 135 | (selected-code (format "%s" (buffer-substring-no-properties beg end))) 136 | (file-path (buffer-file-name))) 137 | ;; Clean up previous eval overlay 138 | (skerrick-remove-eval-overlay) 139 | (save-excursion 140 | (goto-char end) 141 | ;; Make sure the overlay is actually at the end of the evaluated region, not on a newline 142 | (skip-chars-backward "\r\n[:blank:]") 143 | ;; Seems like the END arg of make-overlay is useless. Just use the same value as BEGIN 144 | (setq skerrick--eval-overlay (make-overlay (point) (point) (current-buffer)))) 145 | (skerrick--append-to-process-buffer (format "\n[EVAL - %s]\n%s" file-path selected-code)) 146 | (skerrick--send-eval-req selected-code file-path))) 147 | 148 | ;;;###autoload 149 | (defun skerrick-install-or-upgrade-server-binary () 150 | "Install or upgrade skerrick from NPM." 151 | (interactive) 152 | (async-shell-command "npm install -g skerrick")) 153 | 154 | (defvar skerrick-process nil) 155 | 156 | ;;;###autoload 157 | (defun skerrick-start-server () 158 | "Start skerrick server." 159 | (interactive) 160 | (if (and skerrick-process (process-live-p skerrick-process)) 161 | (message "Skerrick server already running") 162 | (progn 163 | (setq skerrick-process (start-process "skerrick-server" "*skerrick-server*" 164 | "skerrick" (prin1-to-string skerrick-server-port) (buffer-file-name))) 165 | (message "Started skerrick server on %s" skerrick-server-port)))) 166 | 167 | ;;;###autoload 168 | (defun skerrick-stop-server () 169 | "Stop skerrick server." 170 | (interactive) 171 | (if (and skerrick-process (process-live-p skerrick-process)) 172 | (progn 173 | (stop-process skerrick-process) 174 | (setq skerrick-process nil) 175 | (message "Stopped skerrick server")) 176 | (message "No running skerrick server"))) 177 | 178 | (provide 'skerrick) 179 | ;;; skerrick.el ends here 180 | -------------------------------------------------------------------------------- /server/src/engine.ts: -------------------------------------------------------------------------------- 1 | import vm from 'vm'; 2 | import _ from 'lodash'; 3 | import { v4 as uuid } from 'uuid'; 4 | import { createRequire } from 'module'; 5 | import fsPath from 'path'; 6 | import fs from 'fs'; 7 | import * as babel from '@babel/core'; 8 | import * as t from '@babel/types'; 9 | import { Binding, NodePath, Scope } from '@babel/traverse'; 10 | import { PluginPass } from '@babel/core'; 11 | 12 | const symbols = { 13 | defaultExport: Symbol('[[defaultExport]]'), 14 | namespaceExport: Symbol('[[namespaceExport]]') 15 | } 16 | 17 | type Namespace = string; 18 | 19 | type NamespaceValuesByKey = Map; 20 | const namespaces = new Map(); 21 | 22 | // Exports have an exported name and a local name (they could be the same). When looking up 23 | // an export, the lookup key is exported name. Which internally (within the namespace), resolves 24 | // to some value pointed to, by the local name. 25 | interface Export { 26 | exported: string | symbol; 27 | local: string; 28 | } 29 | type ExportsByExported = Map; 30 | const valueExports = new Map(); 31 | 32 | // Imports have an imported name and a local name (they could be the same). When constructing 33 | // the env's scope, we want to use the latter (if defined). 34 | // The former is used to resolve the import from the source module (of the import) 35 | interface Import { 36 | importedNamespace: Namespace 37 | imported: string | symbol; 38 | local: string; 39 | isBuiltIn?: boolean; 40 | } 41 | type ImportsByLocal = Map; 42 | const valueImports = new Map(); 43 | 44 | interface NamespaceImport { 45 | importedNamespace: Namespace 46 | local: string; 47 | } 48 | type NamespaceImportsByLocal = Map; 49 | const namespaceImports = new Map(); 50 | 51 | function requireCustom(importingNamespace: string, importedNamespace: string, evalImports?: boolean, debug?: boolean) { 52 | const requiredNsNormalized = normalizeImportPath(importingNamespace, importedNamespace); 53 | const isBuiltIn = !fsPath.isAbsolute(importedNamespace); 54 | if (isBuiltIn) { 55 | return createRequire(importingNamespace)(requiredNsNormalized); 56 | } 57 | 58 | if (evalImports) { 59 | evaluate(requiredNsNormalized, fs.readFileSync(requiredNsNormalized, { encoding: 'utf8' }), evalImports, debug); 60 | } 61 | const defaultExport = valueExports.get(requiredNsNormalized)?.get(symbols.defaultExport); 62 | const result = defaultExport && namespaces.get(requiredNsNormalized)?.get(defaultExport.local); 63 | return result; 64 | } 65 | 66 | export function evaluate(namespace: string, code: string, evalImports?: boolean, debug?: boolean) { 67 | const codeTransformed = transform(namespace, code, evalImports, debug); 68 | 69 | if (debug) { 70 | console.log(`code transformed:\n${codeTransformed}`); 71 | console.log(); 72 | } 73 | 74 | const ns: NamespaceValuesByKey = namespaces.get(namespace) || new Map(); 75 | const nsImports: ImportsByLocal = valueImports.get(namespace) || new Map(); 76 | 77 | const nsImportsForScope = {}; 78 | for (const [local, { importedNamespace, imported, isBuiltIn }] of nsImports.entries()) { 79 | if (!isBuiltIn && imported === symbols.namespaceExport) { 80 | nsImportsForScope[local] = constructNamespaceExport(importedNamespace); 81 | } else if (isBuiltIn) { 82 | const module = createRequire(namespace)(importedNamespace); 83 | switch (imported) { 84 | case symbols.defaultExport: 85 | nsImportsForScope[local] = module; 86 | break; 87 | case symbols.namespaceExport: 88 | nsImportsForScope[local] = module; 89 | break; 90 | default: 91 | nsImportsForScope[local] = module[imported]; 92 | break; 93 | } 94 | } else { 95 | const nsExports = valueExports.get(importedNamespace); 96 | const exported = nsExports?.get(imported); 97 | const exportedValue = exported && namespaces.get(importedNamespace)?.get(exported.local); 98 | nsImportsForScope[local] = exportedValue; 99 | } 100 | } 101 | 102 | const exportsStub = new Proxy({}, { 103 | set(obj, prop, value) { 104 | const localKeyOfDefaultExport = valueExports.get(namespace)?.get(symbols.defaultExport)?.local; 105 | if (localKeyOfDefaultExport) { 106 | const defaultExport = namespaces.get(namespace)?.get(localKeyOfDefaultExport); 107 | if (defaultExport) { 108 | defaultExport[prop] = value; 109 | } 110 | } else { 111 | const id = uuid(); 112 | registerValue(namespace, id, { [prop]: value }); 113 | registerDefaultValueExport(namespace, id); 114 | } 115 | return true; 116 | }, 117 | get(target, prop, receiver) { 118 | // TODO Find out if `exports.default` needs to be supported 119 | const exportsOfNs = valueExports.get(namespace)?.values() || []; 120 | const exportValue = [...exportsOfNs].find(e => e.local === prop); 121 | return exportValue; 122 | } 123 | }) 124 | 125 | const requireStub = importedNamespace => requireCustom(namespace, importedNamespace, evalImports, debug); 126 | 127 | const moduleStub = new Proxy({ 128 | exports: exportsStub 129 | }, { 130 | set(obj, prop, value) { 131 | obj[prop] = value; 132 | 133 | if (prop === 'exports') { 134 | const id = uuid(); 135 | registerValue(namespace, id, value); 136 | registerDefaultValueExport(namespace, id); 137 | 138 | // for (const [k, v] of Object.entries(value)) { 139 | // const id = uuid(); 140 | // registerValue(namespace, id, v); 141 | // registerValueExport(namespace, id, k); 142 | // } 143 | } 144 | return true; 145 | } 146 | }); 147 | const __filenameStub = namespace; 148 | const __dirnameStub = fsPath.dirname(namespace); 149 | const cjsStubs = { 150 | module: moduleStub, 151 | exports: moduleStub.exports, 152 | require: requireStub, 153 | __filename: __filenameStub, 154 | __dirname: __dirnameStub 155 | }; 156 | 157 | const nsForScope = _([...ns.entries()]) 158 | .map(([k, v]) => [k, v]) 159 | .fromPairs() 160 | .value(); 161 | 162 | if (debug) { 163 | // console.log('all exports', namespaceExports); 164 | console.log('all imports', namespaceImports); 165 | console.log('ns imports for scope', nsImportsForScope); 166 | console.log('ns for scope', nsForScope); 167 | } 168 | 169 | const vmGlobal = {}; 170 | const globalProps = Object.getOwnPropertyNames(global); 171 | for (const k of globalProps) { 172 | vmGlobal[k] = global[k]; 173 | } 174 | 175 | const result = vm.runInContext(` 176 | with (nsImportsForScope) { 177 | with (nsForScope) { 178 | (function () { 179 | "use strict"; 180 | try { 181 | ${codeTransformed} 182 | } catch (e) { 183 | console.error(e); 184 | } 185 | })(); 186 | } 187 | }`, vm.createContext({ 188 | ...vmGlobal, 189 | ...cjsStubs, 190 | nsImportsForScope, 191 | nsForScope, 192 | registerValue, 193 | registerValueExport, 194 | registerValueImport, 195 | registerDefaultValueExport, 196 | dynamicImport, 197 | }), { 198 | filename: namespace, 199 | microtaskMode: undefined, 200 | lineOffset: -5, columnOffset: -11 // TODO Is this correct? 201 | }); 202 | return result; 203 | } 204 | 205 | function constructNamespaceExport(namespace: string) { 206 | const values: NamespaceValuesByKey = namespaces.get(namespace) || new Map(); 207 | const exports: ExportsByExported = valueExports.get(namespace) || new Map(); 208 | const nsExport = _([...exports.values()]) 209 | .map(({ exported, local }) => { 210 | const v = values.get(local); 211 | switch (exported) { 212 | case symbols.defaultExport: return ['default', v]; 213 | default: return [exported, v]; 214 | } 215 | }) 216 | .filter(x => !!x) 217 | .fromPairs() 218 | .value(); 219 | return nsExport; 220 | } 221 | 222 | function registerValue(namespace: string, key: string, value: any) { 223 | const values: NamespaceValuesByKey = namespaces.get(namespace) || new Map(); 224 | namespaces.set(namespace, values); 225 | values.set(key, value); 226 | return value; 227 | } 228 | 229 | function registerValueExport( 230 | namespace: string, 231 | local: Export['local'], 232 | exported: Export['exported'] 233 | ) { 234 | const nsExports: ExportsByExported = valueExports.get(namespace) || new Map(); 235 | valueExports.set(namespace, nsExports); 236 | nsExports.set(exported, { exported, local }); 237 | return exported; 238 | } 239 | 240 | function registerDefaultValueExport( 241 | namespace: string, 242 | local: Export['local'] 243 | ) { 244 | const exports: ExportsByExported = valueExports.get(namespace) || new Map(); 245 | valueExports.set(namespace, exports); 246 | exports.set(symbols.defaultExport, { exported: symbols.defaultExport, local }); 247 | return symbols.defaultExport.toString(); 248 | } 249 | 250 | function registerValueImport( 251 | importingNamespace: string, 252 | local: Import['local'], 253 | imported: Import['imported'], 254 | importedNamespace: string, 255 | isBuiltIn = false 256 | ) { 257 | const absoluteImportedNamespace = normalizeImportPath(importingNamespace, importedNamespace); 258 | const imports: ImportsByLocal = valueImports.get(importingNamespace) || new Map(); 259 | valueImports.set(importingNamespace, imports); 260 | imports.set(local, { imported, local, importedNamespace: absoluteImportedNamespace, isBuiltIn }); 261 | return local; 262 | } 263 | 264 | function dynamicImport( 265 | importingNamespace: string, 266 | importedNamespace: string, 267 | evalImports?: boolean, 268 | debug?: boolean 269 | ) { 270 | const importedNamespaceNormalized = normalizeImportPath(importingNamespace, importedNamespace); 271 | const isBuiltIn = !fsPath.isAbsolute(importedNamespaceNormalized); 272 | if (isBuiltIn) { 273 | return Promise.resolve(createRequire(importingNamespace)(importedNamespaceNormalized)); 274 | } 275 | 276 | if (evalImports) { 277 | evaluate(importedNamespaceNormalized, fs.readFileSync(importedNamespaceNormalized, { encoding: 'utf8' }), evalImports, debug); 278 | } 279 | return Promise.resolve(constructNamespaceExport(importedNamespaceNormalized)); 280 | } 281 | 282 | export function transform(namespace: string, code: string, evalImports?: boolean, debug?: boolean) { 283 | const output = babel.transformSync(code, { 284 | plugins: [transformer(evalImports, debug)], 285 | filename: namespace, 286 | parserOpts: { 287 | allowUndeclaredExports: true, 288 | } 289 | }); 290 | return output?.code; 291 | } 292 | 293 | function extractFileName(state: PluginPass) { 294 | const { filename } = state.file.opts; 295 | if (!filename) { 296 | throw Error('No filename'); 297 | } 298 | return filename; 299 | } 300 | 301 | function transformer(evalImports?: boolean, debug?: boolean) { 302 | return () => ({ 303 | visitor: { 304 | Program(path: NodePath, state: PluginPass) { 305 | const fileName = extractFileName(state); 306 | for (const [bindingKey, binding] of Object.entries(path.scope.bindings)) { 307 | // console.log('BINDING:', bindingKey, 'path node type:', binding.path.type); 308 | // NOTE: Imports are not bound/stored as values within the namespace. They are instead 309 | // resolved dynamically when evaluating code. 310 | if (binding.path.type === 'ImportSpecifier' 311 | || binding.path.type === 'ImportDefaultSpecifier' 312 | || binding.path.type === 'ImportNamespaceSpecifier') { 313 | continue; 314 | } 315 | const registerValueExpr = t.expressionStatement( 316 | t.callExpression( 317 | t.identifier(registerValue.name), [ 318 | t.stringLiteral(fileName), 319 | t.stringLiteral(binding.identifier.name), 320 | binding.identifier 321 | ]) 322 | ); 323 | const parent = binding.path.parentPath; 324 | if (!parent) continue; 325 | // For variable declarations, the parent is "VariableDeclaration". 326 | // If we insert after the path (not the parent), we get something like: 327 | // `const x = 10, ` which we don't want. 328 | // Instead we want something like: 329 | // ``` 330 | // const x = 10; 331 | // 332 | // ``` 333 | if (parent.type !== 'Program') { 334 | parent.insertAfter(registerValueExpr); 335 | } else { 336 | binding.path.insertAfter(registerValueExpr); 337 | } 338 | } 339 | }, 340 | CallExpression(path: NodePath, state: PluginPass) { 341 | if (path.node.callee.type !== 'Import') { 342 | return; 343 | } 344 | 345 | const fileName = extractFileName(state); 346 | const dynamicImportExpr = t.expressionStatement( 347 | t.callExpression( 348 | t.identifier(dynamicImport.name), [ 349 | t.stringLiteral(fileName), 350 | path.node.arguments[0], 351 | t.booleanLiteral(!!evalImports), 352 | t.booleanLiteral(!!debug) 353 | ]) 354 | ); 355 | path.replaceWith(dynamicImportExpr); 356 | }, 357 | ExpressionStatement(path: NodePath, state: PluginPass) { 358 | if (path.scope.block.type !== 'Program') { 359 | return; // Not a global declaration 360 | } 361 | 362 | const isLastChild = path.getAllNextSiblings().length <= 0; 363 | if (!isLastChild) return; 364 | 365 | // E.g. `1 + 1`, we want to wrap as `return 1 + 1` 366 | const toReturn = t.returnStatement(path.node.expression); 367 | path.replaceWith(toReturn); 368 | }, 369 | ExportNamedDeclaration(path: NodePath, state: PluginPass) { 370 | const fileName = extractFileName(state); 371 | 372 | // E.g. `export { x, y as y1 }` 373 | if (path.node.specifiers.length > 0) { 374 | // e.g. `export { x, y as y1 }` 375 | for (const specifier of (path.node.specifiers || [])) { 376 | if (specifier.type !== 'ExportSpecifier') continue; 377 | 378 | const registerExportExpr = t.expressionStatement( 379 | t.callExpression( 380 | t.identifier(registerValueExport.name), [ 381 | t.stringLiteral(fileName), 382 | t.stringLiteral(specifier.local.name), 383 | specifier.exported.type === 'StringLiteral' ? specifier.exported : t.stringLiteral(specifier.exported.name), 384 | ]) 385 | ); 386 | path.insertAfter(registerExportExpr); 387 | } 388 | path.remove(); 389 | return; 390 | } 391 | 392 | const processedBindingsByScope: Map> = state['processedBindingsByScope'] as any || new Map(); 393 | state['processedBindingsByScope'] = processedBindingsByScope; 394 | 395 | const scope = path.scope; 396 | for (const [bindingKey, binding] of Object.entries(scope.bindings)) { 397 | 398 | const processedBindings = processedBindingsByScope.get(scope) || new Set(); 399 | processedBindingsByScope.set(scope, processedBindings); 400 | if (processedBindings.has(binding)) { 401 | // console.log(`Processed binding ${bindingKey} previously. Ignoring...`); 402 | continue; 403 | } else { 404 | processedBindings.add(binding); 405 | } 406 | 407 | const registerExportExpr = t.expressionStatement( 408 | t.callExpression( 409 | t.identifier(registerValueExport.name), [ 410 | t.stringLiteral(fileName), 411 | t.stringLiteral(binding.identifier.name), 412 | t.stringLiteral(binding.identifier.name) 413 | ]) 414 | ); 415 | const { path } = binding; 416 | const isExportedVar = ancestorsAre(path, [ 417 | 'VariableDeclarator', 418 | 'VariableDeclaration', 419 | 'ExportNamedDeclaration' 420 | ]); 421 | const isExportedFn = ancestorsAre(path, [ 422 | 'FunctionDeclaration', 423 | 'ExportNamedDeclaration' 424 | ]) 425 | if (isExportedVar || isExportedFn) { 426 | binding.path.parentPath?.insertAfter(registerExportExpr); 427 | } 428 | } 429 | // E.g. `export const x = 1` => `const x = 1` 430 | if (path.node.declaration) { 431 | path.replaceWith(path.node.declaration); 432 | } 433 | }, 434 | ExportDefaultDeclaration(path: NodePath, state: PluginPass) { 435 | const fileName = extractFileName(state); 436 | 437 | let local: t.Identifier; 438 | const { declaration } = path.node; 439 | // Non-named fn or class 440 | if (t.isFunctionDeclaration(declaration) || t.isClassDeclaration(declaration)) { 441 | if (declaration.id === null || declaration.id === undefined) { 442 | const id = t.identifier(_.uniqueId('__defaultExport')); 443 | declaration.id = id; 444 | const registerValueExpr = t.expressionStatement( 445 | t.callExpression( 446 | t.identifier(registerValue.name), [ 447 | t.stringLiteral(fileName), 448 | t.stringLiteral(id.name), 449 | id 450 | ]) 451 | ); 452 | path.insertAfter(registerValueExpr); 453 | } 454 | local = declaration.id; 455 | } else if (t.isIdentifier(declaration)) { 456 | local = declaration; 457 | } else { 458 | return unexpected(`Default export: ${declaration.type}`); 459 | } 460 | 461 | const registerDefaultExportExpr = t.expressionStatement( 462 | t.callExpression( 463 | t.identifier(registerDefaultValueExport.name), [ 464 | t.stringLiteral(fileName), 465 | t.stringLiteral(local.name) 466 | ]) 467 | ); 468 | path.replaceWith(path.node.declaration); 469 | path.insertAfter(registerDefaultExportExpr); 470 | }, 471 | ImportDeclaration: { 472 | enter: (path: NodePath, state: PluginPass) => { 473 | const fileName = extractFileName(state); 474 | const importedNamespace = normalizeImportPath(fileName, path.node.source.value); 475 | 476 | const isBuiltIn = !fsPath.isAbsolute(importedNamespace); 477 | 478 | // Check whether we want to evaluate a module. We don't re-evaluate it if it's previously 479 | // been evaluated to avoid infinite recursion if there are cyclic deps 480 | if (!isBuiltIn && evalImports && !namespaces.get(importedNamespace)) { 481 | namespaces.set(importedNamespace, new Map()); 482 | evaluate(importedNamespace, fs.readFileSync(importedNamespace, { encoding: 'utf8' }), evalImports, debug); 483 | } 484 | 485 | if (path.node.specifiers.length <= 0) { 486 | // TODO Importing for side-effects - Do I even need to do anything here? 487 | } 488 | 489 | for (const specifier of path.node.specifiers) { 490 | switch (specifier.type) { 491 | case 'ImportNamespaceSpecifier': 492 | registerValueImport( 493 | fileName, 494 | specifier.local.name, 495 | symbols.namespaceExport, 496 | path.node.source.value, 497 | isBuiltIn 498 | ); 499 | break; 500 | case 'ImportDefaultSpecifier': 501 | registerValueImport( 502 | fileName, 503 | specifier.local.name, 504 | symbols.defaultExport, 505 | path.node.source.value, 506 | isBuiltIn 507 | ); 508 | break; 509 | case 'ImportSpecifier': 510 | registerValueImport( 511 | fileName, 512 | specifier.local.name, 513 | specifier.imported.type === 'StringLiteral' 514 | ? specifier.imported.value 515 | : specifier.imported.name, 516 | path.node.source.value, 517 | isBuiltIn 518 | ); 519 | break; 520 | default: 521 | return unexpected(`Import specifier type ${(specifier as any).type}`) 522 | } 523 | } 524 | }, 525 | exit: (path: NodePath, state: PluginPass) => { 526 | path.remove(); 527 | } 528 | } 529 | } 530 | }) 531 | } 532 | 533 | function normalizeImportPath(importingNamespace: string, importedNamespace: string) { 534 | try { 535 | const req = createRequire(importingNamespace); 536 | return req.resolve(importedNamespace); 537 | } catch (e) { 538 | console.error("Failed to normalize import path: ", e); 539 | throw e; 540 | } 541 | } 542 | 543 | function ancestorsAre(node: any, types: babel.Node['type'][]) { 544 | let isSatisfied = true; 545 | for (const t of types) { 546 | if (node.type !== t) { 547 | return false; 548 | } 549 | node = node.parentPath; 550 | } 551 | return isSatisfied; 552 | } 553 | 554 | function notImplementedYet(feature) { 555 | throw Error('Sorry not implemented yet: ' + feature); 556 | } 557 | 558 | function unexpected(thing) { 559 | throw Error('Unexpected: ' + thing); 560 | } 561 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /vscode/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------