dockerized and templates

master
Theunis J. Botha 2021-06-18 13:54:08 +02:00
parent 537725a21b
commit fd04d04973
34 changed files with 8177 additions and 8741 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
src/.gitignore

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
*.swp

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM alpine:3.14
WORKDIR "/app"
RUN apk add --no-cache nodejs && \
apk add --update npm
#COPY gulpfile.js .
#COPY webpack.config.js .
COPY package.json .
COPY entrypoint.sh .
RUN npm install --also-dev
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@ -1 +0,0 @@
src/README.md

2
README.md Normal file
View File

@ -0,0 +1,2 @@
[R3 v2.0]

View File

@ -167,6 +167,8 @@ class Event {
} }
//EVENT_GENERATED_START
Event.OBJECT_CREATED = 0x1; Event.OBJECT_CREATED = 0x1;
//EVENT_GENERATED_END
module.exports = Event; module.exports = Event;

View File

@ -1,6 +1,6 @@
const Event = require('./r3-event'); const Event = require('./r3-event');
class Object extends Event { class R3Object extends Event {
constructor() { constructor() {
@ -14,4 +14,4 @@ class Object extends Event {
} }
module.exports = Object; module.exports = R3Object;

View File

@ -1,5 +1,5 @@
const System = require('./r3-system'); const System = require('./r3-system');
const Object = require('../r3-object'); const R3Object = require('../r3-r3-object');
const Event = require('../r3-event'); const Event = require('../r3-event');
class LinkingSystem extends System { class LinkingSystem extends System {
@ -17,7 +17,7 @@ class LinkingSystem extends System {
} }
); );
let object = new Object(); let object = new R3Object();
return true; return true;

View File

@ -1,4 +1,4 @@
module.exports = class Utils { class Utils {
constructor() { constructor() {
@ -1243,3 +1243,5 @@ module.exports = class Utils {
return pad.substring(0, pad.length - string.length) + string; return pad.substring(0, pad.length - string.length) + string;
}; };
} }
module.exports = Utils;

64
dist/r3-node/r3-vector-applier-again.js vendored Normal file
View File

@ -0,0 +1,64 @@
const R3Object = require('r3-r3-object.js');
const Event = require('r3-event');
const Utils = require('r3-utils');
/**
OPTIONS_START
OPTIONS_END
INSTANCE_MAPPING_START
INSTANCE_MAPPING_END
LINKED_OBJECTS_START
LINKED_OBJECTS_END
**/
class VectorApplierAgain extends R3Object {
constructor(options) {
super(options);
this.emit(Event.OBJECT_CREATED);
//OPTIONS_INIT_START
//OPTIONS_INIT_END
this.emit(Event.OBJECT_INITIALIZED);
}
createInstance() {
//CREATE_INSTANCE_BEFORE_START
this.emit(Event.CREATE_INSTANCE);
//CREATE_INSTANCE_BEFORE_END
//CREATE_INSTANCE_AFTER_START
this.createInstance();
this.emit(Event.INSTANCE_CREATED);
//CREATE_INSTANCE_AFTER_END
}
updateInstance() {
//UPDATE_INSTANCE_BEFORE_START
//UPDATE_INSTANCE_BEFORE_END
//UPDATE_INSTANCE_AFTER_START
//UPDATE_INSTANCE_AFTER_END
}
updateFromInstance() {
//UPDATE_FROM_INSTANCE_BEFORE_START
//UPDATE_FROM_INSTANCE_BEFORE_END
//UPDATE_FROM_INSTANCE_AFTER_START
//UPDATE_FROM_INSTANCE_AFTER_END
}
}

6
dist/r3-node/r3.js vendored
View File

@ -1,5 +1,5 @@
const {System, SystemLinking, SystemSocket} = require('./r3-system'); const {System, SystemLinking, SystemSocket} = require('./r3-system');
const Object = require('./r3-object'); const R3Object = require('./r3-r3-object');
class R3 { class R3 {
@ -7,12 +7,12 @@ class R3 {
} }
static version() { static version() {
return 'Fri Jun 18 2021 02:04:29 GMT+0200 (Central European Summer Time)'; return 'Fri Jun 18 2021 11:52:07 GMT+0000 (Coordinated Universal Time)';
} }
} }
R3.Object = Object; R3.R3Object = R3Object;
R3.System = System; R3.System = System;
R3.System.Linking = SystemLinking; R3.System.Linking = SystemLinking;
R3.System.Socket = SystemSocket; R3.System.Socket = SystemSocket;

44
dist/r3.js vendored

File diff suppressed because one or more lines are too long

2
entrypoint.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
npm run $1

View File

@ -1 +0,0 @@
src/gulpfile.js

218
gulpfile.js Normal file
View File

@ -0,0 +1,218 @@
const {series, parallel, src, dest, watch} = require('gulp');
const clean = require('gulp-clean');
const stringReplace = require('gulp-string-replace');
const webpack_stream = require('webpack-stream');
const webpack_config = require('./webpack.config.js');
const map = require('map-stream');
// gulp.task('buildEvents', buildEvents);
const paths = {
source : './src/r3/**/*.js',
testSource : './test/*.js',
web : './dist',
node : './dist/r3-node'
};
function replace() {
return stringReplace('__DATE__', new Date().toString());
}
function clearBuild() {
return src(
paths.node,
{
allowEmpty: true
}
).pipe(clean());
}
function build() {
return src(paths.source)
.pipe(webpack_stream( webpack_config ))
.pipe(replace())
.pipe(dest(paths.web));
}
function buildNode() {
return src(paths.source)
.pipe(replace())
.pipe(dest(paths.node));
}
//
// function logMatches(regex) {
// return map(function(file, done) {
//
// //console.log(file);
//
// let contents = file.contents.toString();
//
// let m;
//
// do {
// m = regex.exec(contents);
// if (m) {
// console.log(m[0]);
// }
// } while (m);
// let matches = [...contents.matchAll(regex)];
// if (matches) {
// matches.map(
// function(match) {
// console.log(match[0]);
// }
// )
// }
// file.contents.toString().match(regex).forEach(function(match) {
// console.log(file.path + ': ' + match);
// });
// done(null, file);
// });
// }
// function buildEvents() {
//
// return gulp.src(
// [
// paths.source,
// paths.testSource
// ]
// ).pipe(logMatches(/Event\.([A-Z]+_*){2,}/g));
// $files = scandir('.', SCANDIR_SORT_DESCENDING);
//
// $events = [];
//
// foreach ($files as $file) {
//
//
// if (
// preg_match('/\.js$/', $file) &&
// !preg_match('/r3\-a\-2\-event/', $file)
// ) {
// echo "processing file " . $file . "\n";
//
// $fn = fopen($file, "r");
//
// while (!feof($fn)) {
// $line = fgets($fn);
//
//
// if (
// preg_match('/R3.Event\./', $line) &&
// !preg_match('/Emit|Subscribe|.call|GetEventName|Async|prototype/', $line)
// ) {
// $matches = [];
// preg_match_all('/(R3.Event\..*?)(\s+|,|;|$|\))/', $line, $matches);
//
// if ($matches[1] && $matches[1][0]) {
//
// $event = $matches[1][0];
//
// if (in_array($event, $events)) {
// // Do nothing
// } else {
// array_push($events, $event);
// }
//
// }
//
//
// }
//
//
// }
//
// fclose($fn);
// }
//
//
// }
//
// array_push($events, 'R3.Event.START');
// array_push($events, 'R3.Event.PAUSE');
// array_push($events, 'R3.Event.RESTART');
//
// sort($events);
//
// $i = 1;
//
// $eventList = '';
//
// $eventFunction = "/**\n * R3.Event.GetEventName\n * @param eventId\n * @returns {string}\n * @constructor\n */\nR3.Event.GetEventName = function(eventId) {\n\n\tswitch(eventId) {\n";
//
// foreach ($events as $event) {
// $eventList .= $event . " = " . "0x" . dechex($i) . ";\n";
//
// $eventFunction .= "\t\tcase 0x" . dechex($i). " : return '" . strtolower(str_replace('R3.Event.', '', $event)) . "';\n";
//
// $i++;
// }
//
// $eventList .= "R3.Event.MAX_EVENTS = " . "0x" . dechex($i) . ";\n\n";
//
// $eventFunction .= "\t\tdefault :\n\t\t\tthrow new Error('Event type not defined : ' + eventId);\n";
// $eventFunction .= "\t}\n\n";
// $eventFunction .= "};\n";
//
// echo $eventList;
// echo $eventFunction;
//
// file_put_contents('r3-a-2-event-1.js', $eventList . $eventFunction);
//
// }
const updateFile = function(path) {
return function(cb) {
console.log('updating ' + path);
cb();
}
}
function monitor() {
const watcher = watch(
[paths.source],
series([
clearBuild,
parallel(build, buildNode)
])
);
watcher.on(
'add',
function (path, stats) {
series([
clearBuild,
parallel(build, buildNode)
])();
}
);
watcher.on(
'unlink',
function (path, stats) {
series([
clearBuild,
parallel(build, buildNode)
])();
}
);
watcher.on(
'change',
function (path, stats) {
series([
clearBuild,
updateFile(path),
parallel(build, buildNode)
])();
}
);
}
exports.build = series([clearBuild, parallel(build, buildNode)]);
exports.default = series([clearBuild, parallel(build, buildNode), monitor]);

1
package-lock.json generated
View File

@ -1 +0,0 @@
src/package-lock.json

7637
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
src/package.json

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "r3",
"version": "2.0.0",
"description": "",
"private": true,
"dependencies": {
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.5",
"@feathersjs/express": "^4.5.3",
"@feathersjs/feathers": "^4.5.3",
"@feathersjs/socketio": "^4.5.3",
"babel-loader": "^8.2.2",
"chai": "^4.3.4",
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-concat": "^2.6.1",
"gulp-sort": "^2.0.0",
"gulp-string-replace": "^1.1.2",
"map-stream": "0.0.7",
"mocha": "^9.0.0",
"webpack": "^5.39.1",
"webpack-stream": "^6.1.2"
},
"scripts": {
"test": "mocha --recursive",
"test-debug": "mocha --inspect-brk --recursive",
"build": "webpack --webpack-config.js",
"watch": "webpack --webpack-config.js --watch",
"start": "gulp"
},
"keywords": [],
"author": "",
"license": "ISC"
}

2
src/.gitignore vendored
View File

@ -1,2 +0,0 @@
node_modules
*.swp

View File

@ -1,2 +0,0 @@
[R3 v2.0]

View File

@ -1,205 +0,0 @@
const gulp = require('gulp');
const clean = require('gulp-clean');
const stringReplace = require('gulp-string-replace');
const webpack_stream = require('webpack-stream');
const webpack_config = require('./webpack.config.js');
const map = require('map-stream');
gulp.task('build', gulp.series([clearBuild, gulp.parallel(build, buildNode)]));
gulp.task('default', gulp.series([clearBuild, gulp.parallel(build, buildNode), monitor]));
gulp.task('buildEvents', buildEvents);
const paths = {
source : './src/r3/**/*.js',
testSource : './test/*.js',
web : './dist',
node : './dist/r3-node'
};
function replace() {
return stringReplace('__DATE__', new Date().toString());
}
function clearBuild() {
return gulp.src(paths.node, {allowEmpty: true})
.pipe(clean());
}
function build() {
return gulp.src(paths.source)
.pipe(webpack_stream( webpack_config ))
.pipe(replace())
.pipe(gulp.dest(paths.web));
}
function buildNode() {
return gulp.src(paths.source)
.pipe(replace())
.pipe(gulp.dest(paths.node));
}
function logMatches(regex) {
return map(function(file, done) {
//console.log(file);
let contents = file.contents.toString();
let m;
do {
m = regex.exec(contents);
if (m) {
console.log(m[0]);
}
} while (m);
// let matches = [...contents.matchAll(regex)];
// if (matches) {
// matches.map(
// function(match) {
// console.log(match[0]);
// }
// )
// }
// file.contents.toString().match(regex).forEach(function(match) {
// console.log(file.path + ': ' + match);
// });
done(null, file);
});
}
function buildEvents() {
return gulp.src(
[
paths.source,
paths.testSource
]
).pipe(logMatches(/Event\.([A-Z]+_*){2,}/g));
// $files = scandir('.', SCANDIR_SORT_DESCENDING);
//
// $events = [];
//
// foreach ($files as $file) {
//
//
// if (
// preg_match('/\.js$/', $file) &&
// !preg_match('/r3\-a\-2\-event/', $file)
// ) {
// echo "processing file " . $file . "\n";
//
// $fn = fopen($file, "r");
//
// while (!feof($fn)) {
// $line = fgets($fn);
//
//
// if (
// preg_match('/R3.Event\./', $line) &&
// !preg_match('/Emit|Subscribe|.call|GetEventName|Async|prototype/', $line)
// ) {
// $matches = [];
// preg_match_all('/(R3.Event\..*?)(\s+|,|;|$|\))/', $line, $matches);
//
// if ($matches[1] && $matches[1][0]) {
//
// $event = $matches[1][0];
//
// if (in_array($event, $events)) {
// // Do nothing
// } else {
// array_push($events, $event);
// }
//
// }
//
//
// }
//
//
// }
//
// fclose($fn);
// }
//
//
// }
//
// array_push($events, 'R3.Event.START');
// array_push($events, 'R3.Event.PAUSE');
// array_push($events, 'R3.Event.RESTART');
//
// sort($events);
//
// $i = 1;
//
// $eventList = '';
//
// $eventFunction = "/**\n * R3.Event.GetEventName\n * @param eventId\n * @returns {string}\n * @constructor\n */\nR3.Event.GetEventName = function(eventId) {\n\n\tswitch(eventId) {\n";
//
// foreach ($events as $event) {
// $eventList .= $event . " = " . "0x" . dechex($i) . ";\n";
//
// $eventFunction .= "\t\tcase 0x" . dechex($i). " : return '" . strtolower(str_replace('R3.Event.', '', $event)) . "';\n";
//
// $i++;
// }
//
// $eventList .= "R3.Event.MAX_EVENTS = " . "0x" . dechex($i) . ";\n\n";
//
// $eventFunction .= "\t\tdefault :\n\t\t\tthrow new Error('Event type not defined : ' + eventId);\n";
// $eventFunction .= "\t}\n\n";
// $eventFunction .= "};\n";
//
// echo $eventList;
// echo $eventFunction;
//
// file_put_contents('r3-a-2-event-1.js', $eventList . $eventFunction);
}
function monitor() {
const watcher = gulp.watch(
[paths.source],
gulp.series[
clearBuild,
gulp.parallel(build, buildNode)
]
);
watcher.on(
'add',
function (path, stats) {
gulp.series([
clearBuild,
gulp.parallel(build, buildNode)
])();
}
);
watcher.on(
'unlink',
function (path, stats) {
gulp.series([
clearBuild,
gulp.parallel(build, buildNode)
])();
}
);
watcher.on(
'change',
function (path, stats) {
gulp.series([
clearBuild,
gulp.parallel(build, buildNode)
])();
}
);
}

8428
src/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +0,0 @@
{
"name": "r3",
"version": "2.0.0",
"description": "",
"private": true,
"dependencies": {
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.5",
"@feathersjs/express": "^4.5.3",
"@feathersjs/feathers": "^4.5.3",
"@feathersjs/socketio": "^4.5.3",
"babel-loader": "^8.2.2",
"webpack": "^5.39.1",
"webpack-stream": "^6.1.2"
},
"devDependencies": {
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-concat": "^2.6.1",
"gulp-sort": "^2.0.0",
"gulp-string-replace": "^1.1.2",
"map-stream": "0.0.7",
"chai": "^4.2.0",
"mocha": "^7.1.1"
},
"scripts": {
"test": "mocha --recursive",
"test-debug": "mocha --inspect-brk --recursive",
"build": "webpack --webpack-config.js",
"watch": "webpack --webpack-config.js --watch"
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -167,6 +167,8 @@ class Event {
} }
//EVENT_GENERATED_START
Event.OBJECT_CREATED = 0x1; Event.OBJECT_CREATED = 0x1;
//EVENT_GENERATED_END
module.exports = Event; module.exports = Event;

View File

@ -1,6 +1,6 @@
const Event = require('./r3-event'); const Event = require('./r3-event');
class Object extends Event { class R3Object extends Event {
constructor() { constructor() {
@ -14,4 +14,4 @@ class Object extends Event {
} }
module.exports = Object; module.exports = R3Object;

View File

@ -1,5 +1,5 @@
const System = require('./r3-system'); const System = require('./r3-system');
const Object = require('../r3-object'); const R3Object = require('../r3-r3-object');
const Event = require('../r3-event'); const Event = require('../r3-event');
class LinkingSystem extends System { class LinkingSystem extends System {
@ -17,7 +17,7 @@ class LinkingSystem extends System {
} }
); );
let object = new Object(); let object = new R3Object();
return true; return true;

View File

@ -1,4 +1,4 @@
module.exports = class Utils { class Utils {
constructor() { constructor() {
@ -1243,3 +1243,5 @@ module.exports = class Utils {
return pad.substring(0, pad.length - string.length) + string; return pad.substring(0, pad.length - string.length) + string;
}; };
} }
module.exports = Utils;

View File

@ -0,0 +1,64 @@
const R3Object = require('r3-r3-object.js');
const Event = require('r3-event');
const Utils = require('r3-utils');
/**
OPTIONS_START
OPTIONS_END
INSTANCE_MAPPING_START
INSTANCE_MAPPING_END
LINKED_OBJECTS_START
LINKED_OBJECTS_END
**/
class VectorApplierAgain extends R3Object {
constructor(options) {
super(options);
this.emit(Event.OBJECT_CREATED);
//OPTIONS_INIT_START
//OPTIONS_INIT_END
this.emit(Event.OBJECT_INITIALIZED);
}
createInstance() {
//CREATE_INSTANCE_BEFORE_START
this.emit(Event.CREATE_INSTANCE);
//CREATE_INSTANCE_BEFORE_END
//CREATE_INSTANCE_AFTER_START
this.createInstance();
this.emit(Event.INSTANCE_CREATED);
//CREATE_INSTANCE_AFTER_END
}
updateInstance() {
//UPDATE_INSTANCE_BEFORE_START
//UPDATE_INSTANCE_BEFORE_END
//UPDATE_INSTANCE_AFTER_START
//UPDATE_INSTANCE_AFTER_END
}
updateFromInstance() {
//UPDATE_FROM_INSTANCE_BEFORE_START
//UPDATE_FROM_INSTANCE_BEFORE_END
//UPDATE_FROM_INSTANCE_AFTER_START
//UPDATE_FROM_INSTANCE_AFTER_END
}
}

View File

@ -1,5 +1,5 @@
const {System, SystemLinking, SystemSocket} = require('./r3-system'); const {System, SystemLinking, SystemSocket} = require('./r3-system');
const Object = require('./r3-object'); const R3Object = require('./r3-r3-object');
class R3 { class R3 {
@ -12,7 +12,7 @@ class R3 {
} }
R3.Object = Object; R3.R3Object = R3Object;
R3.System = System; R3.System = System;
R3.System.Linking = SystemLinking; R3.System.Linking = SystemLinking;
R3.System.Socket = SystemSocket; R3.System.Socket = SystemSocket;

View File

@ -0,0 +1,2 @@
this.createInstance();
this.emit(Event.INSTANCE_CREATED);

View File

@ -0,0 +1 @@
this.emit(Event.CREATE_INSTANCE);

View File

@ -0,0 +1,61 @@
const EXTEND_CLASS = require('EXTEND_CLASS_FILE_NAME');
const Event = require('r3-event');
const Utils = require('r3-utils');
/**
OPTIONS_START
OPTIONS_END
INSTANCE_MAPPING_START
INSTANCE_MAPPING_END
LINKED_OBJECTS_START
LINKED_OBJECTS_END
**/
class CLASS_NAME extends EXTEND_CLASS {
constructor(options) {
super(options);
this.emit(Event.OBJECT_CREATED);
//OPTIONS_INIT_START
//OPTIONS_INIT_END
this.emit(Event.OBJECT_INITIALIZED);
}
createInstance() {
//CREATE_INSTANCE_BEFORE_START
//CREATE_INSTANCE_BEFORE_END
//CREATE_INSTANCE_AFTER_START
//CREATE_INSTANCE_AFTER_END
}
updateInstance() {
//UPDATE_INSTANCE_BEFORE_START
//UPDATE_INSTANCE_BEFORE_END
//UPDATE_INSTANCE_AFTER_START
//UPDATE_INSTANCE_AFTER_END
}
updateFromInstance() {
//UPDATE_FROM_INSTANCE_BEFORE_START
//UPDATE_FROM_INSTANCE_BEFORE_END
//UPDATE_FROM_INSTANCE_AFTER_START
//UPDATE_FROM_INSTANCE_AFTER_END
}
}

View File

@ -1,28 +0,0 @@
const path = require('path');
module.exports = {
entry: './src/r3/index.js',
output: {
filename: 'r3.js',
path: path.resolve(
__dirname + '/../',
'dist'
)
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
],
},
mode: 'development',
devtool: 'inline-source-map'
};

View File

@ -1 +0,0 @@
src/webpack.config.js

28
webpack.config.js Normal file
View File

@ -0,0 +1,28 @@
const path = require('path');
module.exports = {
entry: './src/r3/index.js',
output: {
filename: 'r3.js',
path: path.resolve(
__dirname + '/../',
'dist'
)
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
],
},
mode: 'development',
devtool: 'inline-source-map'
};