converted to tyescript for memes
parent
b3342f0928
commit
c347189e4b
|
|
@ -1 +1,2 @@
|
|||
node_modules
|
||||
node_modules
|
||||
out
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
node_modules
|
||||
src
|
||||
test
|
||||
.editorconfig
|
||||
tsconfig.json
|
||||
|
|
@ -13,8 +13,8 @@ STATEMENT -> _ LINK_DECLARATION EOL {% ([,stuff]) => { return stuff } %}
|
|||
IMPORT_STATMENT -> %IMPORT __ STRING __ %AS __ IDENTIFIER {% ([,,moduleName,,,,identifier]) => { return { type: 'import', name: identifier, importName: moduleName }} %}
|
||||
| %IMPORT __ IDENTIFIER __ %FROM __ STRING {% ([,,identifier,,,,moduleName]) => { return { type: 'import', name: identifier, importName: moduleName }} %}
|
||||
|
||||
FUNCTION_DECLARATION -> _ IDENTIFIER _ PARAMETERS:? _ JS_BLOCK EOL {% ([,name,,params,,block]) => { return { type: 'function', name: name, block, parameters: params } } %}
|
||||
| _ %ASYNC __ IDENTIFIER _ PARAMETERS:? _ JS_BLOCK_ASYNC EOL {% ([,,,name,,params,,block]) => { return { type: 'function', name: name, block, parameters: params } } %}
|
||||
FUNCTION_DECLARATION -> _ IDENTIFIER _ PARAMETERS:? _ JS_BLOCK EOL {% ([,name,,params,,block]) => { return { type: 'function', name: name, block, parameters: params ?? [], async: false } } %}
|
||||
| _ %ASYNC __ IDENTIFIER _ PARAMETERS:? _ JS_BLOCK_ASYNC EOL {% ([,,,name,,params,,block]) => { return { type: 'function', name: name, block, parameters: params ?? [], async: true } } %}
|
||||
|
||||
DIRECTIVE_STATEMENT -> DIRECTIVE __ IDENTIFIER EOL {% ([directive,,identifier]) => { return { type: 'directive', directive, value: identifier }} %}
|
||||
| DIRECTIVE EOL {% ([directive]) => { return { type: 'directive', directive, value: true }} %}
|
||||
|
|
@ -42,10 +42,10 @@ EOL -> _ %SEMICOLON:?
|
|||
STRING -> %STRING {% ([d]) => d.value.substring(1, d.value.length - 1) %}
|
||||
SEMICOLON -> %SEMICOLON
|
||||
IDENTIFIER -> %IDENTIFIER {% ([id]) => id.value %}
|
||||
JS_BLOCK -> %JS_BLOCK {% ([block]) => (`(() => {${block.value.substring(2, block.value.length - 2)}});`) %}
|
||||
| %JS_BLOCK2 {% ([block]) => (`(() => {${block.value.substring(1, block.value.length - 1)}});`) %}
|
||||
JS_BLOCK_ASYNC -> %JS_BLOCK {% ([block]) => (`(async () => {${block.value.substring(2, block.value.length - 2)}});`) %}
|
||||
| %JS_BLOCK2 {% ([block]) => (`(async () => {${block.value.substring(1, block.value.length - 1)}});`) %}
|
||||
JS_BLOCK -> %JS_BLOCK {% ([block]) => (`{${block.value.substring(2, block.value.length - 2)}}`) %}
|
||||
| %JS_BLOCK2 {% ([block]) => (`{${block.value.substring(1, block.value.length - 1)}}`) %}
|
||||
JS_BLOCK_ASYNC -> %JS_BLOCK {% ([block]) => (`{${block.value.substring(2, block.value.length - 2)}}`) %}
|
||||
| %JS_BLOCK2 {% ([block]) => (`{${block.value.substring(1, block.value.length - 1)}}`) %}
|
||||
SPREAD_OPERATOR -> %SPREAD_OPERATOR
|
||||
_ -> null | %SPACE {% () => undefined %}
|
||||
__ -> %SPACE {% () => undefined %}
|
||||
13
package.json
13
package.json
|
|
@ -5,14 +5,16 @@
|
|||
"license": "MIT",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"vogue": "run.js"
|
||||
"vogue": "out/run.js"
|
||||
},
|
||||
"scripts": {
|
||||
"c": "nearleyc",
|
||||
"test": "node run.js test",
|
||||
"test": "node --enable-source-maps --unhandled-rejections=strict out/run.js test",
|
||||
"debug": "cross-env DEBUG=vogue:* yarn test",
|
||||
"postinstall": "cd test && yarn",
|
||||
"tsc": "tsc"
|
||||
"debug:watch": "cross-env DEBUG=vogue:* supervisor -w out -n exit --exec yarn -- test",
|
||||
"postinstall": "yarn compile && cd test && yarn",
|
||||
"postcompile:watch": "echo DONE",
|
||||
"compile": "tsc",
|
||||
"compile:watch": "tsc --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/debug": "^4.1.5",
|
||||
|
|
@ -26,6 +28,7 @@
|
|||
"moo": "^0.5.1",
|
||||
"nearley": "^2.20.1",
|
||||
"nedb": "^1.8.0",
|
||||
"supervisor": "^0.12.0",
|
||||
"typescript": "^4.2.4",
|
||||
"uglify-js": "^3.13.5",
|
||||
"yarn": "^1.22.10"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import debug from 'debug';
|
|||
import _ from 'lodash';
|
||||
const log = debug('vogue:instance');
|
||||
import vm from 'vm';
|
||||
import Module, { Link } from './Module.js';
|
||||
import System from './System.js';
|
||||
import { KV } from './KV.js';
|
||||
/**
|
||||
* @typedef {import('./System.js').default} System
|
||||
* @typedef {import('./Module.js').default} Module
|
||||
|
|
@ -12,33 +15,45 @@ import vm from 'vm';
|
|||
|
||||
|
||||
export default class Instance extends Serializable {
|
||||
/** @type {Module} */
|
||||
module = null;
|
||||
module: Module;
|
||||
links = {}
|
||||
system = null;
|
||||
context = null;
|
||||
system: System;
|
||||
context: vm.Context;
|
||||
locals = [];
|
||||
internalFunctions = {};
|
||||
/** @type {Proxy<Instance>} */
|
||||
_link = null;
|
||||
_link: Instance;
|
||||
location: string;
|
||||
|
||||
createContext() {
|
||||
const initialContext = {};
|
||||
createContext(): vm.Context {
|
||||
if(this.context) return this.context;
|
||||
|
||||
const initialContext: KV = {};
|
||||
|
||||
// system globals!
|
||||
// TODO turn this into its own vogue module! system.create/instance.create
|
||||
// TODO request context from system...
|
||||
initialContext.create = this.system.create.bind(this.system);
|
||||
for(const name of this.system.staticInstances)
|
||||
initialContext.create = this.system.createInstance.bind(this.system);
|
||||
for(const name in this.system.staticInstances)
|
||||
initialContext[name] = this.system.staticInstances[name];
|
||||
|
||||
// local links!
|
||||
// optional arrays
|
||||
// TODO maybe make these property accessors to allow for some automation
|
||||
for(const name of this.module.links.optional.arrays)
|
||||
initialContext[name] = [];
|
||||
for(const name of this.module.links.optional.single)
|
||||
initialContext[name] = null;
|
||||
for(const link of this.module.links.filter((v: Link) => v.array && !v.required))
|
||||
initialContext[link.name] = [];
|
||||
for(const link of this.module.links.filter((v: Link) => !v.array && !v.required))
|
||||
initialContext[link.name] = null;
|
||||
|
||||
const context = vm.createContext(initialContext);
|
||||
|
||||
for(const name in this.module.functions) {
|
||||
const { code, parameters, async } = this.module.functions[name];
|
||||
const injectedScript =
|
||||
`
|
||||
var ${name} = ${async ? 'async' : ''} function ${name}(${parameters.join(', ')}) ${code}
|
||||
`;
|
||||
vm.runInContext(injectedScript, context);
|
||||
}
|
||||
|
||||
// local functions time!
|
||||
// for(const name of this.module.functions)
|
||||
|
|
@ -65,26 +80,18 @@ export default class Instance extends Serializable {
|
|||
// }
|
||||
// // ctx.create =
|
||||
// this.locals.push('create');
|
||||
this.context = ctx;
|
||||
return context;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Module} module
|
||||
* @param {string} location
|
||||
* @param {Object<string, any>} parameters
|
||||
* @param {System} system
|
||||
*/
|
||||
constructor(module, location, parameters, system) {
|
||||
constructor(module: Module, location: string, parameters: {[name: string]: any}, system: System) {
|
||||
super();
|
||||
this.module = module;
|
||||
this.location = location;
|
||||
this.system = system;
|
||||
|
||||
this.createContext();
|
||||
this.context = this.createContext();
|
||||
|
||||
this._link = new Proxy(this, {
|
||||
get(target, prop, receiver) {
|
||||
get(target: Instance, prop, receiver) {
|
||||
if(prop === 'restore') return undefined;
|
||||
if(prop in target.module.functions) {
|
||||
// TODO return the fn
|
||||
|
|
@ -95,12 +102,16 @@ export default class Instance extends Serializable {
|
|||
});
|
||||
}
|
||||
|
||||
hasPublicFunction(name) {
|
||||
hasPublicFunction(name: string) {
|
||||
return (name in this.module.functions);
|
||||
}
|
||||
|
||||
invokeInternal(name, ...args) {
|
||||
invokeInternal(name: string, ...args: any[]): any {
|
||||
log('invoking', this.module.name.full + '.' + name, 'with args', args);
|
||||
|
||||
if(typeof this.context[name] === 'function') {
|
||||
this.context[name](...args);
|
||||
} else throw new Error(`${name} is not a function in ${this.module.name.full}`)
|
||||
}
|
||||
|
||||
get link () {
|
||||
183
src/Module.js
183
src/Module.js
|
|
@ -1,183 +0,0 @@
|
|||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
import { createAst } from './createAst';
|
||||
import path from 'path';
|
||||
import debug from 'debug';
|
||||
import { createRequire } from 'module';
|
||||
var log = debug('vogue:module');
|
||||
var Module = /** @class */ (function () {
|
||||
function Module() {
|
||||
this.links = {
|
||||
required: {
|
||||
single: [],
|
||||
arrays: []
|
||||
},
|
||||
optional: {
|
||||
single: [],
|
||||
arrays: []
|
||||
}
|
||||
};
|
||||
this.globals = [];
|
||||
this.functions = [];
|
||||
this.identifiers = {};
|
||||
this.name = {
|
||||
space: '',
|
||||
last: '',
|
||||
full: ''
|
||||
};
|
||||
this.imports = {};
|
||||
this.variables = {
|
||||
cold: [],
|
||||
warm: []
|
||||
};
|
||||
this.directives = {
|
||||
'singleton': false,
|
||||
'keepalive': false,
|
||||
'static': ''
|
||||
};
|
||||
}
|
||||
Module.prototype.directive = function (_a) {
|
||||
var directive = _a.directive, value = _a.value;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_b) {
|
||||
this.directives[directive] = value;
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Module.prototype.link = function (_a) {
|
||||
var required = _a.required, array = _a.array, name = _a.name;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_b) {
|
||||
this.links[required ? 'required' : 'optional'][array ? 'arrays' : 'single']
|
||||
.push(name);
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Module.prototype.namespace = function (_a) {
|
||||
var namespace = _a.namespace;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_b) {
|
||||
this.name.space = namespace;
|
||||
this.name.full = this.name.space + '.' + this.name.last;
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Module.prototype["function"] = function (_a) {
|
||||
var name = _a.name, block = _a.block, parameters = _a.parameters;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_b) {
|
||||
this.functions[name] = {
|
||||
code: block,
|
||||
parameters: parameters
|
||||
};
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Module.prototype["import"] = function (_a) {
|
||||
var importName = _a.importName, name = _a.name;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var nodePath, __require__, imported;
|
||||
return __generator(this, function (_b) {
|
||||
nodePath = path.resolve(this.rootDir, 'node_module');
|
||||
log('#'.repeat(80));
|
||||
log(nodePath);
|
||||
__require__ = createRequire(nodePath);
|
||||
imported = __require__(importName);
|
||||
if ('default' in imported)
|
||||
this.imports[name] = imported["default"];
|
||||
else
|
||||
this.imports[name] = imported;
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Module.prototype.variable = function (_a) {
|
||||
var persist = _a.persist, name = _a.name;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_b) {
|
||||
this.variables[persist ? 'cold' : 'warm'].push(name);
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Module.create = function (location, rootDir) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var module, ast, name, _i, ast_1, item;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
module = new Module();
|
||||
ast = createAst(location);
|
||||
name = path.parse(location).name;
|
||||
module.name.last = name;
|
||||
module.name.full = name;
|
||||
module.rootDir = rootDir;
|
||||
_i = 0, ast_1 = ast;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
if (!(_i < ast_1.length)) return [3 /*break*/, 4];
|
||||
item = ast_1[_i];
|
||||
if ('name' in item) {
|
||||
if (item.name in module.identifiers)
|
||||
throw new Error('Identifier ' + item.name + ' already declared!');
|
||||
else
|
||||
module.identifiers[item.name] = item.type;
|
||||
}
|
||||
if (!(item.type in module)) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, module[item.type](item)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
_a.label = 3;
|
||||
case 3:
|
||||
_i++;
|
||||
return [3 /*break*/, 1];
|
||||
case 4:
|
||||
log('='.repeat(80));
|
||||
log(location);
|
||||
log(module);
|
||||
return [2 /*return*/, module];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return Module;
|
||||
}());
|
||||
export default Module;
|
||||
|
|
@ -1,11 +1,20 @@
|
|||
import { createAst, DirectiveRule, DirectiveValue, FunctionRule, ImportRule, LinkRule, NamespaceRule, VariableRule } from './createAst'
|
||||
import {
|
||||
createAst,
|
||||
DirectiveRule,
|
||||
FunctionRule,
|
||||
ImportRule,
|
||||
LinkRule,
|
||||
NamespaceRule,
|
||||
Rule,
|
||||
VariableRule
|
||||
} from './createAst.js'
|
||||
import path from 'path';
|
||||
import debug from 'debug';
|
||||
import { createRequire } from 'module';
|
||||
import { pathToFileURL } from 'url';
|
||||
const log = debug('vogue:module');
|
||||
|
||||
type Link = {
|
||||
export type Link = {
|
||||
name: string,
|
||||
array: boolean,
|
||||
required: boolean
|
||||
|
|
@ -17,35 +26,41 @@ export default class Module {
|
|||
functions: {
|
||||
[name: string]: {
|
||||
code: string,
|
||||
async: boolean,
|
||||
parameters: string[]
|
||||
}
|
||||
} = {};
|
||||
identifiers = {};
|
||||
identifiers: {
|
||||
[name: string]: Rule["type"]
|
||||
} = {};
|
||||
name = {
|
||||
space: '',
|
||||
last: '',
|
||||
full: ''
|
||||
};
|
||||
imports = {};
|
||||
variables = {
|
||||
imports: {
|
||||
[key: string]: any
|
||||
} = {};
|
||||
variables: any = {
|
||||
cold: [],
|
||||
warm: []
|
||||
};
|
||||
directives: {
|
||||
[key: string]: DirectiveValue
|
||||
} = {
|
||||
'singleton': false,
|
||||
'keepalive': false,
|
||||
'static': ''
|
||||
};
|
||||
// directives
|
||||
'singleton': boolean = false;
|
||||
'keepalive': boolean = false;
|
||||
'static': string = '';
|
||||
// other stuff
|
||||
rootDir: string = '';
|
||||
|
||||
|
||||
async directive({directive, value}: DirectiveRule) {
|
||||
this.directives[directive] = value;
|
||||
async directive({ directive, value }: DirectiveRule): Promise<void> {
|
||||
if (typeof this[directive] === 'boolean')
|
||||
(this[directive] as boolean) = value as boolean;
|
||||
else if (typeof this[directive] === 'string')
|
||||
(this[directive] as string) = value as string;
|
||||
// = value as string;
|
||||
}
|
||||
|
||||
async link({required, array, name}: LinkRule) {
|
||||
async link({ required, array, name }: LinkRule): Promise<void> {
|
||||
this.links.push({
|
||||
name,
|
||||
required,
|
||||
|
|
@ -53,29 +68,30 @@ export default class Module {
|
|||
});
|
||||
}
|
||||
|
||||
async namespace({namespace}: NamespaceRule) {
|
||||
async namespace({ namespace }: NamespaceRule): Promise<void> {
|
||||
this.name.space = namespace;
|
||||
this.name.full = this.name.space + '.' + this.name.last;
|
||||
}
|
||||
|
||||
async function({name, block, parameters}: FunctionRule) {
|
||||
async function({ name, block, parameters, async }: FunctionRule): Promise<void> {
|
||||
this.functions[name] = {
|
||||
code: block,
|
||||
parameters
|
||||
parameters,
|
||||
async
|
||||
};
|
||||
}
|
||||
|
||||
async import({importName, name}: ImportRule) {
|
||||
async import({ importName, name }: ImportRule): Promise<void> {
|
||||
const nodePath = path.resolve(this.rootDir, 'node_module');
|
||||
log('#'.repeat(80));
|
||||
log(nodePath);
|
||||
const __require__ = createRequire(nodePath);
|
||||
const imported = __require__(importName);
|
||||
if('default' in imported) this.imports[name] = imported.default;
|
||||
if ('default' in imported) this.imports[name] = imported.default;
|
||||
else this.imports[name] = imported;
|
||||
}
|
||||
|
||||
async variable({persist, name}: VariableRule) {
|
||||
async variable({ persist, name }: VariableRule): Promise<void> {
|
||||
this.variables[persist ? 'cold' : 'warm'].push(name);
|
||||
}
|
||||
|
||||
|
|
@ -90,13 +106,16 @@ export default class Module {
|
|||
|
||||
for (const item of ast) {
|
||||
if ('name' in item) {
|
||||
if(item.name in module.identifiers)
|
||||
if (item.name in module.identifiers)
|
||||
throw new Error('Identifier ' + item.name + ' already declared!');
|
||||
else module.identifiers[item.name] = item.type;
|
||||
else {
|
||||
module.identifiers[item.name] = item.type;
|
||||
}
|
||||
}
|
||||
|
||||
if(item.type in module) {
|
||||
await module[item.type](item);
|
||||
if (item.type in module) {
|
||||
const func = module[item.type] as ((arg0: Rule) => Promise<void>)
|
||||
func.call(module, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
// import { Ubjson } from '@shelacek/ubjson';
|
||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { KV } from './KV';
|
||||
|
||||
export default class Serializable {
|
||||
|
||||
constructor(...args: any[]) {}
|
||||
|
||||
// things that need to be stored only in cold
|
||||
// storage are keyed with a special prefix
|
||||
static CLASS_REFERENCE = '$$CLASS_NAME';
|
||||
|
|
@ -13,25 +17,29 @@ export default class Serializable {
|
|||
|
||||
start() {}
|
||||
|
||||
toUbj() {
|
||||
return Ubjson.encode(this.toSerializableObject());
|
||||
}
|
||||
// toUbj() {
|
||||
// return Ubjson.encode(this.toSerializableObject());
|
||||
// }
|
||||
|
||||
static fromUbj(buffer) {
|
||||
return this.fromSerializableObject(Ubjson.decode(buffer));
|
||||
}
|
||||
// static fromUbj(buffer) {
|
||||
// return this.fromSerializableObject(Ubjson.decode(buffer));
|
||||
// }
|
||||
|
||||
toJson() {
|
||||
return JSON.stringify(this.toSerializableObject(), null, 2);
|
||||
}
|
||||
|
||||
static fromJson(str) {
|
||||
static serializationDependencies(): any[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
static fromJson(str: string) {
|
||||
return this.fromSerializableObject(JSON.parse(str));
|
||||
}
|
||||
|
||||
toSerializableObject() {
|
||||
|
||||
const transformValue = (val) => {
|
||||
const transformValue = (val: any): any => {
|
||||
if(Array.isArray(val)) {
|
||||
return transformArray(val);
|
||||
} else if (val === null || val === undefined) {
|
||||
|
|
@ -43,8 +51,8 @@ export default class Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
const transformObject = (obj) => {
|
||||
const clone = {};
|
||||
const transformObject = (obj: KV): KV => {
|
||||
const clone: KV = {};
|
||||
for(const prop of Object.keys(obj)) {
|
||||
if(prop.startsWith('_')) continue;
|
||||
|
||||
|
|
@ -56,7 +64,7 @@ export default class Serializable {
|
|||
return clone;
|
||||
}
|
||||
|
||||
const transformArray = (arr) => {
|
||||
const transformArray = (arr: any[]): any[] => {
|
||||
const clone = [];
|
||||
for(const item of arr) {
|
||||
clone.push(transformValue(item));
|
||||
|
|
@ -67,10 +75,10 @@ export default class Serializable {
|
|||
return transformObject(this);
|
||||
}
|
||||
|
||||
static fromSerializableObject(obj) {
|
||||
static fromSerializableObject(obj: KV) {
|
||||
if(obj[Serializable.CLASS_REFERENCE] !== this.name) return null;
|
||||
|
||||
const transformValue = (val) => {
|
||||
const transformValue = (val: any): any => {
|
||||
if(Array.isArray(val)) {
|
||||
return transformArray(val);
|
||||
} else if(val === null || val === undefined) {
|
||||
|
|
@ -78,7 +86,9 @@ export default class Serializable {
|
|||
} else if(typeof val === 'object') {
|
||||
if(Serializable.CLASS_REFERENCE in val) {
|
||||
const classes = this.serializationDependencies();
|
||||
const matchingClasses = classes.filter(classObject => classObject.name === val[Serializable.CLASS_REFERENCE]);
|
||||
const matchingClasses = classes.filter((classObject) => {
|
||||
classObject.name === val[Serializable.CLASS_REFERENCE]
|
||||
});
|
||||
if(matchingClasses.length === 1) {
|
||||
return matchingClasses[0].fromSerializableObject(val);
|
||||
} else {
|
||||
|
|
@ -91,8 +101,8 @@ export default class Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
const transformObject = (obj) => {
|
||||
const clone = {};
|
||||
const transformObject = (obj: KV): KV => {
|
||||
const clone: KV = {};
|
||||
for(const prop of Object.keys(obj)) {
|
||||
if(prop.startsWith('_')) continue;
|
||||
|
||||
|
|
@ -101,7 +111,7 @@ export default class Serializable {
|
|||
return clone;
|
||||
}
|
||||
|
||||
const transformArray = (arr) => {
|
||||
const transformArray = (arr: any[]): any[] => {
|
||||
const clone = [];
|
||||
for(const item of arr) {
|
||||
clone.push(transformValue(item));
|
||||
|
|
@ -125,7 +135,7 @@ export default class Serializable {
|
|||
switch(encoding) {
|
||||
case 'json': return this.toJson();
|
||||
case 'ubjson':
|
||||
case 'ubj': return this.toUbj();
|
||||
// case 'ubj': return this.toUbj();
|
||||
default: {
|
||||
throw new TypeError('Unknown encoding: ' + encoding);
|
||||
}
|
||||
|
|
@ -133,14 +143,14 @@ export default class Serializable {
|
|||
|
||||
}
|
||||
|
||||
static deserialize(obj, {
|
||||
static deserialize(obj: any, {
|
||||
encoding = 'json'
|
||||
} = {}) {
|
||||
|
||||
switch(encoding) {
|
||||
case 'json': return this.fromJson(obj);
|
||||
case 'ubjson':
|
||||
case 'ubj': return this.fromUbj(obj);
|
||||
// case 'ubj': return this.fromUbj(obj);
|
||||
default: {
|
||||
throw new TypeError('Unknown encoding: ' + encoding);
|
||||
}
|
||||
|
|
@ -149,32 +159,40 @@ export default class Serializable {
|
|||
|
||||
async restore() {}
|
||||
|
||||
static createFromDisk(filename, ...args) {
|
||||
static createFromDisk(filename: string, ...args: any[]) {
|
||||
if(existsSync(filename)) {
|
||||
const instance = this.deserialize(readFileSync(createFilepath(filename)));
|
||||
// TS is plain and simply wrong... symbols can be used to index object...
|
||||
// @ts-ignore
|
||||
instance[Serializable.PERSIST_LOCATION] = createFilepath(filename);
|
||||
instance.restore();
|
||||
instance?.restore();
|
||||
return instance;
|
||||
} else {
|
||||
const instance = new this(...args);
|
||||
// again... TS is wrong...
|
||||
// @ts-ignore
|
||||
instance[Serializable.PERSIST_LOCATION] = createFilepath(filename);
|
||||
instance.updateDisk();
|
||||
instance?.updateDisk();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
updateDisk(filepath) {
|
||||
updateDisk(filepath?: string) {
|
||||
// if it hasnt yet been written to disk...
|
||||
// this can happen if the contrustor
|
||||
// was called outside of createFromDisk
|
||||
if(filepath) {
|
||||
// see above... TS7053 is just _wrong_. incorrect. thats not how JS works.
|
||||
// @ts-ignore
|
||||
this[Serializable.PERSIST_LOCATION] = createFilepath(filepath);
|
||||
}
|
||||
const data = this.serialize();
|
||||
// this is getting annoying...
|
||||
// @ts-ignore
|
||||
writeFileSync(this[Serializable.PERSIST_LOCATION], data);
|
||||
}
|
||||
}
|
||||
|
||||
function createFilepath(path) {
|
||||
function createFilepath(path: string) {
|
||||
return `data/${path}`;
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
import Instance from './Instance';
|
||||
import Serializable from './Serializable';
|
||||
import _ from 'lodash';
|
||||
import Module from './Module';
|
||||
import debug from 'debug';
|
||||
var log = debug('vogue:system');
|
||||
var get = _.get, set = _.set;
|
||||
var System = /** @class */ (function (_super) {
|
||||
__extends(System, _super);
|
||||
function System(modules, rootDir) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.instances = [];
|
||||
_this.namespace = {};
|
||||
_this.staticInstances = {};
|
||||
_this.modules = modules;
|
||||
_this.createNamespace();
|
||||
var bootModules = _this.deriveBootModules();
|
||||
_this.createStaticInstances();
|
||||
_this.rootDir = rootDir;
|
||||
log('instantiating boot modules...');
|
||||
for (var _i = 0, bootModules_1 = bootModules; _i < bootModules_1.length; _i++) {
|
||||
var name_1 = bootModules_1[_i];
|
||||
log(' ' + name_1);
|
||||
_this.newInstance(name_1);
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
System.prototype.createStaticInstances = function () {
|
||||
log('deriving static modules...');
|
||||
var staticModules = this.modules.filter(function (module) {
|
||||
return !!module.static;
|
||||
}).map(function (module) {
|
||||
log(' ' + module.name.full);
|
||||
return module;
|
||||
});
|
||||
log('instantiating static modules...');
|
||||
for (var _i = 0, staticModules_1 = staticModules; _i < staticModules_1.length; _i++) {
|
||||
var module_1 = staticModules_1[_i];
|
||||
log(' ' + module_1.static + ': ' + module_1.name.full);
|
||||
this.staticInstances[module_1.static] =
|
||||
this.newInstance(module_1.name.full, {});
|
||||
}
|
||||
};
|
||||
System.prototype.deriveBootModules = function () {
|
||||
log('deriving boot modules...');
|
||||
var bootModules = this.modules.filter(function (module) {
|
||||
return module.singleton;
|
||||
}).map(function (module) {
|
||||
return module.name.full;
|
||||
});
|
||||
for (var _i = 0, bootModules_2 = bootModules; _i < bootModules_2.length; _i++) {
|
||||
var name_2 = bootModules_2[_i];
|
||||
log(' ' + name_2);
|
||||
}
|
||||
return bootModules;
|
||||
};
|
||||
System.prototype.createNamespace = function () {
|
||||
log('creating namespace map...');
|
||||
this.namespace = this.modules.reduce(function (acc, val) {
|
||||
if (get(acc, val.name.full) instanceof Module)
|
||||
throw new Error('Duplicate module "' + val.name.full + '"');
|
||||
set(acc, val.name.full, val);
|
||||
log(' ' + val.name.full);
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
System.prototype.getModule = function (name) {
|
||||
return get(this.namespace, name);
|
||||
};
|
||||
System.prototype.createInstance = function (name, args) {
|
||||
if (args === void 0) { args = {}; }
|
||||
return new Instance(this.getModule(name), null, args, this);
|
||||
};
|
||||
System.prototype.newInstance = function (name, args) {
|
||||
if (args === void 0) { args = {}; }
|
||||
var instance = this.createInstance(name, args);
|
||||
var link = instance.link;
|
||||
if (instance.hasPublicFunction('restore'))
|
||||
instance.invokeInternal('restore');
|
||||
return link;
|
||||
};
|
||||
return System;
|
||||
}(Serializable));
|
||||
export default System;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import Instance from './Instance';
|
||||
import Serializable from './Serializable';
|
||||
import Instance from './Instance.js';
|
||||
import Serializable from './Serializable.js';
|
||||
import _ from 'lodash';
|
||||
import Module from './Module';
|
||||
import Module from './Module.js';
|
||||
import debug from 'debug';
|
||||
const log = debug('vogue:system')
|
||||
|
||||
|
|
@ -79,12 +79,14 @@ class System extends Serializable {
|
|||
}, {});
|
||||
}
|
||||
|
||||
getModule(name: ModuleName) {
|
||||
return get(this.namespace, name);
|
||||
getModule(name: ModuleName): Module {
|
||||
const module = get(this.namespace, name);
|
||||
if(module instanceof Module) return module;
|
||||
else throw Error(`${name} is not a module`);
|
||||
}
|
||||
|
||||
createInstance(name: ModuleName, args = {}) {
|
||||
return new Instance(this.getModule(name), null, args, this);
|
||||
return new Instance(this.getModule(name), '', args, this);
|
||||
}
|
||||
|
||||
newInstance(name: ModuleName, args = {}) {
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
import nearley from 'nearley';
|
||||
// TODO none of these shits have typings, but its OKAY
|
||||
// @ts-ignore
|
||||
import compile from 'nearley/lib/compile.js';
|
||||
// @ts-ignore
|
||||
import generate from 'nearley/lib/generate.js';
|
||||
// @ts-ignore
|
||||
import nearleyGrammar from 'nearley/lib/nearley-language-bootstrapped.js';
|
||||
// @ts-ignore
|
||||
import moo from 'moo';
|
||||
import tokens from './tokens';
|
||||
import { readFileSync } from 'fs';
|
||||
import debug from 'debug';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
var log = debug('vogue:ast');
|
||||
var grammarFile = resolve(fileURLToPath(dirname(import.meta.url)), 'grammar.ne');
|
||||
log('grammarFile:', grammarFile);
|
||||
function createParser() {
|
||||
// Parse the grammar source into an AST
|
||||
var grammarParser = new nearley.Parser(nearleyGrammar);
|
||||
grammarParser.feed(readFileSync(grammarFile).toString());
|
||||
var grammarAst = grammarParser.results[0]; // TODO check for errors
|
||||
// Compile the AST into a set of rules
|
||||
var grammarInfoObject = compile(grammarAst, {});
|
||||
// Generate JavaScript code from the rules
|
||||
var grammarJs = generate(grammarInfoObject, "grammar");
|
||||
var lexer = moo.compile(tokens);
|
||||
// lexer.__proto__.formatError = function(token, message) {
|
||||
// if (token == null) {
|
||||
// // An undefined token indicates EOF
|
||||
// var text = this.buffer.slice(this.index)
|
||||
// var token = {
|
||||
// text: text,
|
||||
// offset: this.index,
|
||||
// lineBreaks: text.indexOf('\n') === -1 ? 0 : 1,
|
||||
// line: this.line,
|
||||
// col: this.col,
|
||||
// }
|
||||
// }
|
||||
// var start = Math.max(0, token.offset - token.col + 1)
|
||||
// var eol = token.lineBreaks ? token.text.indexOf('\n') : token.text.length
|
||||
// var firstLine = this.buffer.substring(start, token.offset + eol)
|
||||
// message += " at line " + token.line + " col " + token.col + ":\n\n"
|
||||
// message += " " + firstLine + "\n"
|
||||
// message += " " + Array(token.col).join(" ") + "^"
|
||||
// return message
|
||||
// }
|
||||
// Pretend this is a CommonJS environment to catch exports from the grammar.
|
||||
var module = { exports: {} };
|
||||
eval(grammarJs);
|
||||
var grammar = module.exports;
|
||||
// THESE IS COMPLICATED SHITS, IDK MAN WHAT ARE TYPINGS
|
||||
// @ts-ignore
|
||||
return new nearley.Parser(nearley.Grammar.fromCompiled(grammar));
|
||||
}
|
||||
export function createAst(location) {
|
||||
var parser = createParser();
|
||||
var contents = readFileSync(location).toString();
|
||||
// parser.reportError = function(token) {
|
||||
// return JSON.stringify(token, null, 2);
|
||||
// var message = this.lexer.formatError(token, 'invalid syntax') + '\n';
|
||||
// message += 'Unexpected ' + (token.type ? token.type + ' token: ' : '');
|
||||
// message +=
|
||||
// JSON.stringify(token.value !== undefined ? token.value : token) + '\n';
|
||||
// return message;
|
||||
// };
|
||||
parser.feed(contents);
|
||||
parser.finish();
|
||||
var ast = parser.results[0];
|
||||
log('='.repeat(80));
|
||||
log(location);
|
||||
log(ast);
|
||||
return ast || [];
|
||||
}
|
||||
|
|
@ -9,15 +9,15 @@ import nearleyGrammar from 'nearley/lib/nearley-language-bootstrapped.js';
|
|||
// @ts-ignore
|
||||
import moo from 'moo';
|
||||
|
||||
import tokens from './tokens';
|
||||
import tokens from './tokens.js';
|
||||
import { readFileSync } from 'fs';
|
||||
import debug from 'debug';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import minify from './minify';
|
||||
import minify from './minify.js';
|
||||
|
||||
const log = debug('vogue:ast');
|
||||
const grammarFile = resolve(fileURLToPath(dirname(import.meta.url)), 'grammar.ne');
|
||||
const grammarFile = resolve(fileURLToPath(dirname(import.meta.url)), '..', 'lib', 'grammar.ne');
|
||||
log('grammarFile:', grammarFile);
|
||||
|
||||
function createParser() {
|
||||
|
|
@ -69,7 +69,8 @@ export type FunctionRule = {
|
|||
type: 'function',
|
||||
name: string
|
||||
block: string,
|
||||
parameters: string[]
|
||||
parameters: string[],
|
||||
async: boolean
|
||||
};
|
||||
|
||||
export type VariableRule = {
|
||||
|
|
@ -79,7 +80,7 @@ export type VariableRule = {
|
|||
};
|
||||
|
||||
export type NamespaceRule = {
|
||||
type: 'namesapce',
|
||||
type: 'namespace',
|
||||
namespace: string
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import uglify from 'uglify-js';
|
||||
export default (function (code) {
|
||||
return uglify.minify(code, {
|
||||
compress: {
|
||||
dead_code: true,
|
||||
global_defs: {
|
||||
DEBUG: false
|
||||
}
|
||||
},
|
||||
sourceMap: {
|
||||
content: 'inline'
|
||||
}
|
||||
}).code;
|
||||
});
|
||||
96
src/run.js
96
src/run.js
|
|
@ -1,96 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
};
|
||||
import debug from 'debug';
|
||||
var log = debug('vogue:cli');
|
||||
var systemLocation = resolve(process.argv[2]);
|
||||
import { parse, resolve, dirname } from 'path';
|
||||
import { readdirSync, lstatSync } from 'fs';
|
||||
import _ from 'lodash';
|
||||
import Module from './Module';
|
||||
import System from './System';
|
||||
import './extensions.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
var get = _.get, set = _.set;
|
||||
var standardLibrary = resolve(fileURLToPath(dirname(import.meta.url)), 'lib');
|
||||
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var ignoreDeps, files, fullpaths, modules, sys;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
ignoreDeps = function (path) { return parse(path).name !== 'node_modules'; };
|
||||
files = __spreadArray(__spreadArray([], walkdirSync(systemLocation, ignoreDeps)), walkdirSync(standardLibrary, ignoreDeps));
|
||||
fullpaths = files
|
||||
.filter(function (v) { return lstatSync(v).isFile(); })
|
||||
.filter(function (v) { return parse(v).ext === '.v'; });
|
||||
log('included modules');
|
||||
log(files);
|
||||
log('parsing modules...');
|
||||
return [4 /*yield*/, Promise.all(fullpaths.map(function (loc) { return Module.create(loc, systemLocation); }))];
|
||||
case 1:
|
||||
modules = _a.sent();
|
||||
sys = new System(modules, systemLocation);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })();
|
||||
function walkdirSync(root, filter) {
|
||||
if (filter === void 0) { filter = function () { return true; }; }
|
||||
log('reading', root, '...');
|
||||
var paths = readdirSync(root).map(function (v) { return resolve(root, v); });
|
||||
var _a = sift(paths.filter(filter), function (v) { return lstatSync(v).isFile(); }), files = _a[0], dirs = _a[1];
|
||||
log("files: " + files.length + " | dirs: " + dirs.length);
|
||||
var rfiles = dirs.map(function (v) { return walkdirSync(v, filter); }).reduce(function (a, v) { return __spreadArray(__spreadArray([], a), v); }, []);
|
||||
return __spreadArray(__spreadArray([], files), rfiles);
|
||||
}
|
||||
function sift(a, fn) {
|
||||
var left = [], right = [];
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
var v = a[i];
|
||||
var lr = !!fn(v, i, a);
|
||||
if (lr)
|
||||
left = __spreadArray(__spreadArray([], left), [v]);
|
||||
else
|
||||
right = __spreadArray(__spreadArray([], right), [v]);
|
||||
}
|
||||
return [left, right];
|
||||
}
|
||||
|
|
@ -7,15 +7,15 @@ import { parse, resolve, dirname } from 'path';
|
|||
import { readdirSync, lstatSync } from 'fs';
|
||||
|
||||
import _ from 'lodash';
|
||||
import Module from './Module';
|
||||
import System from './System';
|
||||
import Module from './Module.js';
|
||||
import System from './System.js';
|
||||
import './extensions.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
// globals inside grammar context
|
||||
import minify from './minify';
|
||||
|
||||
const { get, set } = _;
|
||||
const standardLibrary = resolve(fileURLToPath(dirname(import.meta.url)), 'lib');
|
||||
const standardLibrary = resolve(fileURLToPath(dirname(import.meta.url)), '..', 'lib', 'vogue');
|
||||
|
||||
(async () => {
|
||||
// TODO simplify this line gaddam
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
export default {
|
||||
LINK: 'link',
|
||||
NAMESPACE: 'namespace',
|
||||
REQUIRED: 'required',
|
||||
SINGLETON: 'singleton',
|
||||
KEEPALIVE: 'keepalive',
|
||||
STATIC: 'static',
|
||||
MEMBER: 'member',
|
||||
RUNTIME: 'runtime',
|
||||
IMPORT: 'import',
|
||||
ASYNC: 'async',
|
||||
AS: 'as',
|
||||
FROM: 'from',
|
||||
COMMA: ',',
|
||||
STRING: /'(?:\\['\\]|[^\n'\\])*'/,
|
||||
LSQBRACKET: '[',
|
||||
RSQBRACKET: ']',
|
||||
LPAREN: '(',
|
||||
RPAREN: ')',
|
||||
SPREAD_OPERATOR: '...',
|
||||
DOTOP: '.',
|
||||
JS_BLOCK: /\[\[[^]*?\n\]\]$/,
|
||||
JS_BLOCK2: /{[^]*?\n}$/,
|
||||
IDENTIFIER: /[a-zA-Z][a-zA-Z0-9]*/,
|
||||
SPACE: { match: /\s+/, lineBreaks: true },
|
||||
SEMICOLON: ';'
|
||||
};
|
||||
|
|
@ -3,7 +3,11 @@
|
|||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "esnext",
|
||||
"outDir": "out",
|
||||
"sourceMap": true,
|
||||
"declaration": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -156,6 +156,10 @@ source-map@^0.6.1:
|
|||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
|
||||
supervisor@^0.12.0:
|
||||
version "0.12.0"
|
||||
resolved "https://registry.yarnpkg.com/supervisor/-/supervisor-0.12.0.tgz#de7e6337015b291851c10f3538c4a7f04917ecc1"
|
||||
|
||||
typescript@^4.2.4:
|
||||
version "4.2.4"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
|
||||
|
|
|
|||
Reference in New Issue