First Commit.

This commit is contained in:
2025-12-25 09:56:43 +01:00
commit e21bba7f0b
40 changed files with 6040 additions and 0 deletions

199
source/consoleColors.js Normal file
View File

@@ -0,0 +1,199 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
class consoleColors{
colors = new Array();
backgroundColors = new Array();
addColor( colorName, colorCode ) {
var color = new Object();
color.name = colorName;
color.code = colorCode;
this.colors.push( color );
}
addBackgroundColor( colorName, colorCode ) {
var color = new Object();
color.name = colorName;
color.code = colorCode;
this.backgroundColors.push( color );
}
constructor() {
this.createTextColors();
this.createBackgroundColors();
return this.createMethods();
}
createTextColors() {
this.addColor( "white", 37 );
this.addColor( "black", 30 );
this.addColor( "blue", 34 );
this.addColor( "cyan", 36 );
this.addColor( "green", 32 );
this.addColor( "magenta", 35 );
this.addColor( "red", 31 );
this.addColor( "yellow", 33 );
this.addColor( "brightBlack", 90 );
this.addColor( "brightRed", 91 );
this.addColor( "brightGreen", 92 );
this.addColor( "brightYellow", 93 );
this.addColor( "brightBlue", 94 );
this.addColor( "brightMagenta", 95 );
this.addColor( "brightCyan", 96 );
this.addColor( "brightWhite", 97 );
}
createBackgroundColors() {
this.addBackgroundColor( "bgBlack", 40 );
this.addBackgroundColor( "bgRed", 41 );
this.addBackgroundColor( "bgGreen", 42 );
this.addBackgroundColor( "bgYellow", 43 );
this.addBackgroundColor( "bgBlue", 44 );
this.addBackgroundColor( "bgMagenta", 45 );
this.addBackgroundColor( "bgCyan", 46 );
this.addBackgroundColor( "bgWhite", 47 );
this.addBackgroundColor( "bgBrightBlack", 100 );
this.addBackgroundColor( "bgBrightRed", 101 );
this.addBackgroundColor( "bgBrightGreen", 102 );
this.addBackgroundColor( "bgBrightYellow", 103 );
this.addBackgroundColor( "bgBrightBlue", 104 );
this.addBackgroundColor( "bgBrightMagenta", 105 );
this.addBackgroundColor( "bgBrightCyan", 106 );
this.addBackgroundColor( "bgBrightWhite", 107 );
}
createMethodsForTextColor( color, colorMethods ) {
var name = color.name;
var code = color.code;
var open = '\u001b[' + code + 'm';
var close = '\u001b[39m';
colorMethods[ name ] = function ( value ) {
return open + value + close;
}
}
createMethodsForBackgroundColor( color, colorMethods ) {
var name = color.name;
var code = color.code;
var open = '\u001b[' + code + 'm';
var close = '\u001b[49m';
colorMethods[ name ] = function ( value ) {
return open + value + close;
}
}
createMethods() {
var colors = this.colors;
var colorMethods = new Array();
for ( var i = 0; i < colors.length; i++ ) {
var textColor = colors[i];
this.createMethodsForTextColor( textColor, colorMethods );
}
var backgroundColors = this.backgroundColors;
for ( var i = 0; i < backgroundColors.length; i++ ) {
var backgroundColor = backgroundColors[i];
this.createMethodsForBackgroundColor( backgroundColor, colorMethods );
}
return colorMethods;
}
}
export default new consoleColors();

637
source/css.js Normal file
View File

@@ -0,0 +1,637 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE,
as published by the Free Software Foundation.
See the GNU AFFERO GENERAL PUBLIC LICENSE, for more details.
https://unifyjs.org
*/
import cssRules from './cssRules.js';
import document from './document.js';
import cssManager from './cssManager.js';
import tools from './tools.js';
import definitions from './definitions.js';
export default class css{
cssCache = new cssManager();
global_css = "";
skipBoxTerms = new Array( "box-sizing", "box-shadow", "box-reflect", "box-decoration-break" );
constructor() {
this.boxTermWithoutPrefix = new Array();
for (var i = 0; i < this.skipBoxTerms.length; i++) {
var boxTerm = this.skipBoxTerms[i]
this.boxTermWithoutPrefix[i] = boxTerm.replace("box-")
}
}
PerformPropertyGridCorrection( property ) {
for ( var i = 0; i < this.skipBoxTerms.length; i++ ) {
if( this.boxTermWithoutPrefix[ i ].includes( property ) ) {
property = this.skipBoxTerms[ i ];
}
}
return property;
}
parseObject( object ){
var objectName = object.propertyName;
object.__proto__.css = new cssRules();
object.__proto__.boxRules = new cssRules();
object.__proto__.cssRules = new cssRules();
object.cssRules.addStyleListener( "hover", ":hover" );
object.cssRules.addStyleListener( "visited", ":visited" );
object.cssRules.addStyleListener( "link", ":link" );
object.cssRules.addStyleListener( "active", ":active" );
object.cssRules.addStyleListener( "placeholder", "::placeholder" );
object.cssRules.addStyleListener( "scrollbar", "::-webkit-scrollbar" );
object.cssRules.addStyleListener( "scrollbarTrack", "::-webkit-scrollbar-track" );
object.cssRules.addStyleListener( "scrollbarThumb", "::-webkit-scrollbar-thumb" );
object.cssRules.addStyleListener( "scrollbarThumbHover", "::-webkit-scrollbar-thumb:hover" );
}
parseCSSValue( value ) {
if( typeof value == "number" ) {
value += "px";
}
return value;
}
createStyleRule( normalizedProperty, value ){
if( !value ) {
return "";
}
value = this.parseCSSValue( value );
normalizedProperty = this.PerformPropertyGridCorrection( normalizedProperty );
return "\t" + normalizedProperty + ":" + value + "; \n";
}
compareUpperCase( term ) {
const compare = function( current ){ if( term.indexOf( current ) != -1 ){ return true; } }
const n = definitions.alphabet;
var map = n.map( compare );
return map; // [false, false, true, false] where true is where higher case is
}
hasUpperCase( a ) {
let regExp = /[A-Z]/;
return regExp.test( a );
}
replaceUpperCase( word ) {
var map = this.compareUpperCase( word );
var letter = definitions.alphabet[ map.indexOf( true ) ];
return word.replace( letter, "-" + letter.toLowerCase() );
}
normalizePropertyName( name ) {
return tools.firstLowerCase( name.replace("__", "").replace("box", "") );
}
// needs caching
normalizeProperty( name ) {
// webkit -> -webkit
if( name.slice( 0, 6 ) == "webkit" ) {
name = "-" + name;
}
for (var i = 0; i < 6; i++) {
if( this.hasUpperCase( name ) ) {
name = this.replaceUpperCase( name ); // backgroundColor -> background-color-and-something
}
}
return name;
}
setter( object, domStyleObject, propertyName, property, value ) {
object[ "__" + propertyName ] = value;
value = this.parseCSSValue( value );
property = this.PerformPropertyGridCorrection( property );
var NSTabNames = new Array("svg", "circle")
// todo : doesnt work properly
//if( NSTabNames.includes( object.element.tagName ) ) {
// domStyleObject.setAttributeNS( null, property, value );
//} else {
domStyleObject.setProperty( property, value );
//}
}
createSetter( property, objectProperty, object, domStyleObject ) {
var css = this;
object[ "__" + objectProperty ] = object[ objectProperty ];
object.__defineSetter__( objectProperty, this.setter.bind( this, object, domStyleObject, objectProperty, property ) );
}
getter( object, objectProperty, value ) {
var newValue = object[ "__" + objectProperty ];
if(typeof newValue == "string") {
var chars = newValue.split();
if( chars[chars.length-2] == "p" && chars[chars.length-1] == "x" ) {
chars = chars.slice(0, -2);
newValue = chars.join();
}
}
if( tools.isCustomNumber( newValue ) ) {
return parseFloat( newValue );
} else {
return newValue;
}
}
createGetter( property, objectProperty, object, domStyleObject ) {
object.__defineGetter__( objectProperty, this.getter.bind( this, object, objectProperty ) );
}
parseProperty( property, object ) {
var propertyName = property.name;
var propertyValue = property.value;
var normalizedProperty = this.normalizeProperty( propertyName );
//if( propertyName == "gridArea" && propertyValue == "none" ) {
// return false;
//}
var slicedProperty = propertyName.toLowerCase().slice( 0, 3 );
if( slicedProperty == "box" ) {
object.boxRules.style += this.parseCssTerm( object, propertyName, propertyValue, object.elements[0], "box" );
} else {
object.css.style += this.parseCssTerm( object, propertyName, propertyValue, object.element )
}
this.parseExtraStyleSuffixes( object, propertyName, propertyValue );
}
parseExtraStyleSuffixes( object, propertyName, propertyValue ) {
var styleTypes = object.cssRules.styleTypes;
for ( var i = 0; i < styleTypes.length; i++ ) {
var cssType = styleTypes[i];
var propertyTerm = cssType.propertyTerm;
var slicedProperty = propertyName.slice( 0, propertyTerm.length );
if( slicedProperty == propertyTerm && propertyName.length > slicedProperty.length ) {
cssType.css += this.parseCssTerm( object, propertyName, propertyValue, object.elements[0], propertyTerm );
}
}
}
parseCssTerm( object, propertyName, propertyValue, element, term = "" ) {
var cssPropertyName = tools.firstLowerCase( propertyName.replace( term, "" ) );
var normalizedProperty = this.normalizeProperty( cssPropertyName );
if( this.propertyIsStyle( normalizedProperty ) ) {
// Setters and getters don't work yet for special suffixes.
if( !term || term == "box" ) {
this.createSetter( normalizedProperty, propertyName, object, element.style );
this.createGetter( normalizedProperty, propertyName, object, element.style );
}
return this.createStyleRule( normalizedProperty, propertyValue );
} else {
return "";
}
}
clearCache() {
this.cssCache.rules = new Array();
}
parseCssRule( object, objectPropertyName, propertyName, propertyValue ) {
var normalizedProperty = this.normalizeProperty( objectPropertyName );
object.boxRules.style += this.createStyleRule( normalizedProperty, propertyValue );
this.createSetter( objectPropertyName, propertyName, object, object.elements[0].style );
this.createGetter( objectPropertyName, propertyName, object, object.elements[0].style );
}
createSelector( className, afterTerm ) {
var selector = "." + className;
selector += "." + this.device;
selector += "." + this.os;
selector += "." + this.tint;
// this doesnt work yet.
if( afterTerm ) {
selector += afterTerm;
}
//selector += "," + selector.replace( "_" + id, "" );
return selector;
}
createStyleSheet( object ){
var objectName = tools.createCSSClassName( object );
var body = object.css.style;
if( object.customElement ) {
var selector = this.createSelector( objectName + "Element" );
this.global_css += this.cssCache.getRule( selector, body );
var selector = this.createSelector( objectName + "Grid" );
this.global_css += this.cssCache.getRule( selector, body );
} else {
var selector = this.createSelector( objectName + "Grid" );
this.global_css += this.cssCache.getRule( selector, body );
}
if( object.boxRules ) {
var selector = this.createSelector( objectName + "Box" );
var body = object.boxRules.style;
this.global_css += this.cssCache.getRule( selector, body );
}
var styleTypes = object.cssRules.styleTypes;
for (var i = 0; i < styleTypes.length; i++) {
var cssType = styleTypes[i];
if( object.useCustomElement ) {
var selector = this.createSelector( objectName + "Element", cssType.cssSuffix );
} else {
var selector = this.createSelector( objectName + "Grid", cssType.cssSuffix );
}
var body = cssType.css;
if( body != "" ) {
//console.log("cssType.cssSuffix", cssType.cssSuffix);
this.global_css += this.cssCache.getRule( selector, body );
}
}
if( !object.parent ) {
this.writeCssToPage( this.global_css );
this.global_css = "";
}
if( object.dynamic ) {
this.writeCssToPage( this.global_css );
this.global_css = "";
}
}
writeCssToPage( css ) {
if( css == "" ) {
return false;
}
var style = document.createElement("style");
style.innerHTML = css;
document.head.appendChild( style );
}
removeStripe( name ) {
var splitName = name.split("-");
if( splitName.length > 1 ) {
return splitName[1].toLowerCase();
} else {
return name;
}
}
getStyleSheetObject(){
if( !document.body ) {
return definitions.css;
/*
var array = JSON.parse(cssDef);
var object = new Object();
for (var i = 0; i < array.length; i++) {
var def = array[i];
if( this.hasUpperCase( def ) ) {
object[ this.replaceUpperCase( def ) ] = '';
console.log( this.replaceUpperCase( def ) );
} else {
object[ def ] = '';
}
}
*/
return object;
}
if( document.body.style ) {
var bodyStyle = document.body.style;
bodyStyle.webkitBoxShadow = "";
return bodyStyle;
}
if( document.body.styleSheets ) {
// fix please!!!! not allowed
return document.styleSheets[1].cssRules[0].style;
} else {
return document.customStyleTerms;
}
}
camelCaseToDash( name ) {
for ( var i = 0; i < 4; i++ ) {
if( this.hasUpperCase( name ) ) {
name = this.replaceUpperCase( name ); // backgroundColor -> background-color
}
}
return name;
}
removeBoxPrefix( name ) {
if( !name.includes("webkit-box") ) {
name = name.replace("box", "").toLowerCase();
}
return name;
}
checkBoxSpecialCase( name ) {
for (var i = 0; i < this.boxTermWithoutPrefix.length; i++) {
if( this.boxTermWithoutPrefix[ i ].includes( name ) ) {
return true;
}
}
}
propertyIsStyle( name ){
name = this.camelCaseToDash( name );
name = this.removeBoxPrefix( name );
if( this.checkBoxSpecialCase( name ) ) {
return true;
}
var styleTerms = this.getStyleSheetObject();
if( typeof styleTerms[ name ] == "string" ) {
return true;
} else {
return false;
}
}
propertyHasStyle( name ){
var styleTerms = Object.keys( definitions.css );
if( styleTerms.includes( name.toLowerCase() ) ) {
return true;
} else {
return false;
}
}
}

63
source/cssManager.js Normal file
View File

@@ -0,0 +1,63 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE,
as published by the Free Software Foundation.
See the GNU AFFERO GENERAL PUBLIC LICENSE, for more details.
https://unifyjs.org
*/
import tools from './tools.js';
export default class cssManager{
rules = new Array();
addRule( selector, body ) {
var rule = new Object();
rule.selector = selector;
rule.body = body;
this.rules[ selector ] = body;
}
composeCss( selector, body ) {
if( body == "") {
return "";
}
return "\n" + selector + "{ " + "\n" + body + "\n" + " } " + "\n";
}
getRule( selector, body ) {
selector = tools.cleanRollup( selector );
if( this.rules[ selector ] ) {
return "";
} else {
this.addRule( selector, body );
return this.composeCss( selector, body );
}
}
}

39
source/cssRules.js Normal file
View File

@@ -0,0 +1,39 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE,
as published by the Free Software Foundation.
See the GNU AFFERO GENERAL PUBLIC LICENSE, for more details.
https://unifyjs.org
*/
export default class cssRules{
style = "";
styleTypes = new Array();
addStyleListener( propertyTerm, cssSuffix ) {
var styleType = new Object();
styleType.propertyTerm = propertyTerm;
styleType.cssSuffix = cssSuffix;
styleType.css = "";
this.styleTypes.push( styleType );
}
}

1606
source/database.js Normal file
View File

File diff suppressed because it is too large Load Diff

24
source/datatype.js Normal file
View File

@@ -0,0 +1,24 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
*/
export default {
'BOOLEAN' : 'BOOLEAN',
'INTEGER' : 'INTEGER',
'REAL' : 'REAL',
'VARCHAR' : 'TEXT',
'TEXT' : 'TEXT',
'BLOB' : 'BLOB'
}

28
source/definitions.js Normal file
View File

File diff suppressed because one or more lines are too long

124
source/document.js Normal file
View File

@@ -0,0 +1,124 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
class documentTool {
createElementDummy( object ) {
object.createElement = function( tag ){
var object = new Object();
object.tag = tag;
return false;
}
}
createElementNSDummy( object ) {
object.createElementNS = function( tag ){
var object = new Object();
object.tag = tag;
return false;
}
}
createDummyDomMethods( object ) {
this.createElementDummy( object );
this.createElementNSDummy( object );
}
bindCustomStyleTerms( object ) {
object.customStyleTerms = ["background", "width", "height", "flexDirection", "color", "border", "margin", "padding", "boxBackground"];
}
addBoxProperties( object ) {
for( var c = 0; c < object.customStyleTerms.length; c++ ) {
object.customStyleTerms[ object.customStyleTerms[ c ] ] = "";
object.customStyleTerms[ "box" + this.CamelCase( object.customStyleTerms[ c ] ) ] = "";
}
}
createCustomStyleTerms( object ) {
this.bindCustomStyleTerms( object );
this.addBoxProperties( object );
}
getDocument(){
if( typeof document == "undefined" ){
var object = new Object();
this.createDummyDomMethods( object );
this.createCustomStyleTerms( object );
this.type = "server";
return object;
} else {
document.type = "client";
return document;
}
}
CamelCase( string ){
if( string ) {
string = string.toUpperCase();
string = string[0].toUpperCase() + string.slice(1,string.lenth).toLowerCase();
return string;
}
}
}
var object = new documentTool();
export default object.getDocument();

52
source/joinSQL.js Normal file
View File

@@ -0,0 +1,52 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
import querySQL from './querySQL.js';
class joinSide{
table;
column;
}
export default class joinSQL extends querySQL{
__className = "joinSQL";
type = "join";
left = new joinSide();
right = new joinSide();
joins = new Array();
querys = new Array();
addJoin( join ) {
this.joins.push( join );
}
addQuery( query ) {
this.querys.push( query );
}
}

5
source/node_modules/better-sqlite3/.gitattributes generated vendored Normal file
View File

@@ -0,0 +1,5 @@
*.lzz linguist-language=C++
*.cpp -diff
*.hpp -diff
*.c -diff
*.h -diff

21
source/node_modules/better-sqlite3/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Joshua Wise
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

Binary file not shown.

25
source/node_modules/better-sqlite3/getBinary.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var platform = process.platform;
var version = process.versions.modules;
var architecture = process.arch;
var betterSqliteVersion = "8.1.0";
console.log( platform );
console.log( version );
console.log( architecture );
var filename = "better-sqlite3-v"+ betterSqliteVersion +"-node-v" + version + "-" + platform + "-" + architecture + ".tar.gz";
console.log(filename);
//better-sqlite3-v8.1.0-node-v108-linux-x64.tar.gz
//better-sqlite3-v8.1.0-node-v108-linux-x64.tar.gz

100
source/node_modules/better-sqlite3/lib/database.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
'use strict';
const fs = require('fs');
const path = require('path');
const util = require('./util');
const SqliteError = require('./sqlite-error');
let DEFAULT_ADDON;
function Database(filenameGiven, options) {
if (new.target == null) {
return new Database(filenameGiven, options);
}
// Apply defaults
let buffer;
if (Buffer.isBuffer(filenameGiven)) {
buffer = filenameGiven;
filenameGiven = ':memory:';
}
if (filenameGiven == null) filenameGiven = '';
if (options == null) options = {};
// Validate arguments
if (typeof filenameGiven !== 'string') throw new TypeError('Expected first argument to be a string');
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
if ('readOnly' in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
if ('memory' in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
// Interpret options
const filename = filenameGiven.trim();
const anonymous = filename === '' || filename === ':memory:';
const readonly = util.getBooleanOption(options, 'readonly');
const fileMustExist = util.getBooleanOption(options, 'fileMustExist');
const timeout = 'timeout' in options ? options.timeout : 5000;
const verbose = 'verbose' in options ? options.verbose : null;
const nativeBindingPath = 'nativeBinding' in options ? options.nativeBinding : null;
// Validate interpreted options
if (readonly && anonymous && !buffer) throw new TypeError('In-memory/temporary databases cannot be readonly');
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
if (timeout > 0x7fffffff) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
if (verbose != null && typeof verbose !== 'function') throw new TypeError('Expected the "verbose" option to be a function');
if (nativeBindingPath != null && typeof nativeBindingPath !== 'string') throw new TypeError('Expected the "nativeBinding" option to be a string');
// Load the native addon
let addon;
if ( nativeBindingPath == null ) {
//console.log("loading Better_sqlite3.node")
var platform = process.platform;
var version = process.versions.modules;
var architecture = process.arch;
var betterSqliteVersion = "8.1.0";
var folderName = "better-sqlite3-v"+ betterSqliteVersion +"-node-v" + version + "-" + platform + "-" + architecture;
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require('../binaries/'+ folderName + "/Release/better_sqlite3.node"));
} else {
addon = require(path.resolve(nativeBindingPath).replace(/(\.node)?$/, '.node'));
}
if (!addon.isInitialized) {
addon.setErrorConstructor(SqliteError);
addon.isInitialized = true;
}
// Make sure the specified directory exists
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
throw new TypeError('Cannot open database because the directory does not exist');
}
Object.defineProperties(this, {
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
...wrappers.getters,
});
}
const wrappers = require('./methods/wrappers');
Database.prototype.prepare = wrappers.prepare;
Database.prototype.transaction = require('./methods/transaction');
Database.prototype.pragma = require('./methods/pragma');
Database.prototype.backup = require('./methods/backup');
Database.prototype.serialize = require('./methods/serialize');
Database.prototype.function = require('./methods/function');
Database.prototype.aggregate = require('./methods/aggregate');
Database.prototype.table = require('./methods/table');
Database.prototype.loadExtension = wrappers.loadExtension;
Database.prototype.exec = wrappers.exec;
Database.prototype.close = wrappers.close;
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
Database.prototype.unsafeMode = wrappers.unsafeMode;
Database.prototype[util.inspect] = require('./methods/inspect');
module.exports = Database;

3
source/node_modules/better-sqlite3/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./database');
module.exports.SqliteError = require('./sqlite-error');

View File

@@ -0,0 +1,43 @@
'use strict';
const { getBooleanOption, cppdb } = require('../util');
module.exports = function defineAggregate(name, options) {
// Validate arguments
if (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');
if (typeof options !== 'object' || options === null) throw new TypeError('Expected second argument to be an options object');
if (!name) throw new TypeError('User-defined function name cannot be an empty string');
// Interpret options
const start = 'start' in options ? options.start : null;
const step = getFunctionOption(options, 'step', true);
const inverse = getFunctionOption(options, 'inverse', false);
const result = getFunctionOption(options, 'result', false);
const safeIntegers = 'safeIntegers' in options ? +getBooleanOption(options, 'safeIntegers') : 2;
const deterministic = getBooleanOption(options, 'deterministic');
const directOnly = getBooleanOption(options, 'directOnly');
const varargs = getBooleanOption(options, 'varargs');
let argCount = -1;
// Determine argument count
if (!varargs) {
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
if (argCount > 0) argCount -= 1;
if (argCount > 100) throw new RangeError('User-defined functions cannot have more than 100 arguments');
}
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
return this;
};
const getFunctionOption = (options, key, required) => {
const value = key in options ? options[key] : null;
if (typeof value === 'function') return value;
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
if (required) throw new TypeError(`Missing required option "${key}"`);
return null;
};
const getLength = ({ length }) => {
if (Number.isInteger(length) && length >= 0) return length;
throw new TypeError('Expected function.length to be a positive integer');
};

View File

@@ -0,0 +1,67 @@
'use strict';
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const { cppdb } = require('../util');
const fsAccess = promisify(fs.access);
module.exports = async function backup(filename, options) {
if (options == null) options = {};
// Validate arguments
if (typeof filename !== 'string') throw new TypeError('Expected first argument to be a string');
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
// Interpret options
filename = filename.trim();
const attachedName = 'attached' in options ? options.attached : 'main';
const handler = 'progress' in options ? options.progress : null;
// Validate interpreted options
if (!filename) throw new TypeError('Backup filename cannot be an empty string');
if (filename === ':memory:') throw new TypeError('Invalid backup filename ":memory:"');
if (typeof attachedName !== 'string') throw new TypeError('Expected the "attached" option to be a string');
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
if (handler != null && typeof handler !== 'function') throw new TypeError('Expected the "progress" option to be a function');
// Make sure the specified directory exists
await fsAccess(path.dirname(filename)).catch(() => {
throw new TypeError('Cannot save backup because the directory does not exist');
});
const isNewFile = await fsAccess(filename).then(() => false, () => true);
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
};
const runBackup = (backup, handler) => {
let rate = 0;
let useDefault = true;
return new Promise((resolve, reject) => {
setImmediate(function step() {
try {
const progress = backup.transfer(rate);
if (!progress.remainingPages) {
backup.close();
resolve(progress);
return;
}
if (useDefault) {
useDefault = false;
rate = 100;
}
if (handler) {
const ret = handler(progress);
if (ret !== undefined) {
if (typeof ret === 'number' && ret === ret) rate = Math.max(0, Math.min(0x7fffffff, Math.round(ret)));
else throw new TypeError('Expected progress callback to return a number or undefined');
}
}
setImmediate(step);
} catch (err) {
backup.close();
reject(err);
}
});
});
};

View File

@@ -0,0 +1,31 @@
'use strict';
const { getBooleanOption, cppdb } = require('../util');
module.exports = function defineFunction(name, options, fn) {
// Apply defaults
if (options == null) options = {};
if (typeof options === 'function') { fn = options; options = {}; }
// Validate arguments
if (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');
if (typeof fn !== 'function') throw new TypeError('Expected last argument to be a function');
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
if (!name) throw new TypeError('User-defined function name cannot be an empty string');
// Interpret options
const safeIntegers = 'safeIntegers' in options ? +getBooleanOption(options, 'safeIntegers') : 2;
const deterministic = getBooleanOption(options, 'deterministic');
const directOnly = getBooleanOption(options, 'directOnly');
const varargs = getBooleanOption(options, 'varargs');
let argCount = -1;
// Determine argument count
if (!varargs) {
argCount = fn.length;
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError('Expected function.length to be a positive integer');
if (argCount > 100) throw new RangeError('User-defined functions cannot have more than 100 arguments');
}
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
return this;
};

View File

@@ -0,0 +1,7 @@
'use strict';
const DatabaseInspection = function Database() {};
module.exports = function inspect(depth, opts) {
return Object.assign(new DatabaseInspection(), this);
};

View File

@@ -0,0 +1,12 @@
'use strict';
const { getBooleanOption, cppdb } = require('../util');
module.exports = function pragma(source, options) {
if (options == null) options = {};
if (typeof source !== 'string') throw new TypeError('Expected first argument to be a string');
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
const simple = getBooleanOption(options, 'simple');
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
return simple ? stmt.pluck().get() : stmt.all();
};

View File

@@ -0,0 +1,16 @@
'use strict';
const { cppdb } = require('../util');
module.exports = function serialize(options) {
if (options == null) options = {};
// Validate arguments
if (typeof options !== 'object') throw new TypeError('Expected first argument to be an options object');
// Interpret and validate options
const attachedName = 'attached' in options ? options.attached : 'main';
if (typeof attachedName !== 'string') throw new TypeError('Expected the "attached" option to be a string');
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
return this[cppdb].serialize(attachedName);
};

189
source/node_modules/better-sqlite3/lib/methods/table.js generated vendored Normal file
View File

@@ -0,0 +1,189 @@
'use strict';
const { cppdb } = require('../util');
module.exports = function defineTable(name, factory) {
// Validate arguments
if (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');
if (!name) throw new TypeError('Virtual table module name cannot be an empty string');
// Determine whether the module is eponymous-only or not
let eponymous = false;
if (typeof factory === 'object' && factory !== null) {
eponymous = true;
factory = defer(parseTableDefinition(factory, 'used', name));
} else {
if (typeof factory !== 'function') throw new TypeError('Expected second argument to be a function or a table definition object');
factory = wrapFactory(factory);
}
this[cppdb].table(factory, name, eponymous);
return this;
};
function wrapFactory(factory) {
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
const thisObject = {
module: moduleName,
database: databaseName,
table: tableName,
};
// Generate a new table definition by invoking the factory
const def = apply.call(factory, thisObject, args);
if (typeof def !== 'object' || def === null) {
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
}
return parseTableDefinition(def, 'returned', moduleName);
};
}
function parseTableDefinition(def, verb, moduleName) {
// Validate required properties
if (!hasOwnProperty.call(def, 'rows')) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
}
if (!hasOwnProperty.call(def, 'columns')) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
}
// Validate "rows" property
const rows = def.rows;
if (typeof rows !== 'function' || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
}
// Validate "columns" property
let columns = def.columns;
if (!Array.isArray(columns) || !(columns = [...columns]).every(x => typeof x === 'string')) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
}
if (columns.length !== new Set(columns).size) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
}
if (!columns.length) {
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
}
// Validate "parameters" property
let parameters;
if (hasOwnProperty.call(def, 'parameters')) {
parameters = def.parameters;
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every(x => typeof x === 'string')) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
}
} else {
parameters = inferParameters(rows);
}
if (parameters.length !== new Set(parameters).size) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
}
if (parameters.length > 32) {
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
}
for (const parameter of parameters) {
if (columns.includes(parameter)) {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
}
}
// Validate "safeIntegers" option
let safeIntegers = 2;
if (hasOwnProperty.call(def, 'safeIntegers')) {
const bool = def.safeIntegers;
if (typeof bool !== 'boolean') {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
}
safeIntegers = +bool;
}
// Validate "directOnly" option
let directOnly = false;
if (hasOwnProperty.call(def, 'directOnly')) {
directOnly = def.directOnly;
if (typeof directOnly !== 'boolean') {
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
}
}
// Generate SQL for the virtual table definition
const columnDefinitions = [
...parameters.map(identifier).map(str => `${str} HIDDEN`),
...columns.map(identifier),
];
return [
`CREATE TABLE x(${columnDefinitions.join(', ')});`,
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
parameters,
safeIntegers,
directOnly,
];
}
function wrapGenerator(generator, columnMap, moduleName) {
return function* virtualTable(...args) {
/*
We must defensively clone any buffers in the arguments, because
otherwise the generator could mutate one of them, which would cause
us to return incorrect values for hidden columns, potentially
corrupting the database.
*/
const output = args.map(x => Buffer.isBuffer(x) ? Buffer.from(x) : x);
for (let i = 0; i < columnMap.size; ++i) {
output.push(null); // Fill with nulls to prevent gaps in array (v8 optimization)
}
for (const row of generator(...args)) {
if (Array.isArray(row)) {
extractRowArray(row, output, columnMap.size, moduleName);
yield output;
} else if (typeof row === 'object' && row !== null) {
extractRowObject(row, output, columnMap, moduleName);
yield output;
} else {
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
}
}
};
}
function extractRowArray(row, output, columnCount, moduleName) {
if (row.length !== columnCount) {
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
}
const offset = output.length - columnCount;
for (let i = 0; i < columnCount; ++i) {
output[i + offset] = row[i];
}
}
function extractRowObject(row, output, columnMap, moduleName) {
let count = 0;
for (const key of Object.keys(row)) {
const index = columnMap.get(key);
if (index === undefined) {
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
}
output[index] = row[key];
count += 1;
}
if (count !== columnMap.size) {
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
}
}
function inferParameters({ length }) {
if (!Number.isInteger(length) || length < 0) {
throw new TypeError('Expected function.length to be a positive integer');
}
const params = [];
for (let i = 0; i < length; ++i) {
params.push(`$${i + 1}`);
}
return params;
}
const { hasOwnProperty } = Object.prototype;
const { apply } = Function.prototype;
const GeneratorFunctionPrototype = Object.getPrototypeOf(function*(){});
const identifier = str => `"${str.replace(/"/g, '""')}"`;
const defer = x => () => x;

View File

@@ -0,0 +1,75 @@
'use strict';
const { cppdb } = require('../util');
const controllers = new WeakMap();
module.exports = function transaction(fn) {
if (typeof fn !== 'function') throw new TypeError('Expected first argument to be a function');
const db = this[cppdb];
const controller = getController(db, this);
const { apply } = Function.prototype;
// Each version of the transaction function has these same properties
const properties = {
default: { value: wrapTransaction(apply, fn, db, controller.default) },
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
database: { value: this, enumerable: true },
};
Object.defineProperties(properties.default.value, properties);
Object.defineProperties(properties.deferred.value, properties);
Object.defineProperties(properties.immediate.value, properties);
Object.defineProperties(properties.exclusive.value, properties);
// Return the default version of the transaction function
return properties.default.value;
};
// Return the database's cached transaction controller, or create a new one
const getController = (db, self) => {
let controller = controllers.get(db);
if (!controller) {
const shared = {
commit: db.prepare('COMMIT', self, false),
rollback: db.prepare('ROLLBACK', self, false),
savepoint: db.prepare('SAVEPOINT `\t_bs3.\t`', self, false),
release: db.prepare('RELEASE `\t_bs3.\t`', self, false),
rollbackTo: db.prepare('ROLLBACK TO `\t_bs3.\t`', self, false),
};
controllers.set(db, controller = {
default: Object.assign({ begin: db.prepare('BEGIN', self, false) }, shared),
deferred: Object.assign({ begin: db.prepare('BEGIN DEFERRED', self, false) }, shared),
immediate: Object.assign({ begin: db.prepare('BEGIN IMMEDIATE', self, false) }, shared),
exclusive: Object.assign({ begin: db.prepare('BEGIN EXCLUSIVE', self, false) }, shared),
});
}
return controller;
};
// Return a new transaction function by wrapping the given function
const wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
let before, after, undo;
if (db.inTransaction) {
before = savepoint;
after = release;
undo = rollbackTo;
} else {
before = begin;
after = commit;
undo = rollback;
}
before.run();
try {
const result = apply.call(fn, this, arguments);
after.run();
return result;
} catch (ex) {
if (db.inTransaction) {
undo.run();
if (undo !== rollback) after.run();
}
throw ex;
}
};

View File

@@ -0,0 +1,54 @@
'use strict';
const { cppdb } = require('../util');
exports.prepare = function prepare(sql) {
return this[cppdb].prepare(sql, this, false);
};
exports.exec = function exec(sql) {
this[cppdb].exec(sql);
return this;
};
exports.close = function close() {
this[cppdb].close();
return this;
};
exports.loadExtension = function loadExtension(...args) {
this[cppdb].loadExtension(...args);
return this;
};
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
this[cppdb].defaultSafeIntegers(...args);
return this;
};
exports.unsafeMode = function unsafeMode(...args) {
this[cppdb].unsafeMode(...args);
return this;
};
exports.getters = {
name: {
get: function name() { return this[cppdb].name; },
enumerable: true,
},
open: {
get: function open() { return this[cppdb].open; },
enumerable: true,
},
inTransaction: {
get: function inTransaction() { return this[cppdb].inTransaction; },
enumerable: true,
},
readonly: {
get: function readonly() { return this[cppdb].readonly; },
enumerable: true,
},
memory: {
get: function memory() { return this[cppdb].memory; },
enumerable: true,
},
};

20
source/node_modules/better-sqlite3/lib/sqlite-error.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
'use strict';
const descriptor = { value: 'SqliteError', writable: true, enumerable: false, configurable: true };
function SqliteError(message, code) {
if (new.target !== SqliteError) {
return new SqliteError(message, code);
}
if (typeof code !== 'string') {
throw new TypeError('Expected second argument to be a string');
}
Error.call(this, message);
descriptor.value = '' + message;
Object.defineProperty(this, 'message', descriptor);
Error.captureStackTrace(this, SqliteError);
this.code = code;
}
Object.setPrototypeOf(SqliteError, Error);
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
Object.defineProperty(SqliteError.prototype, 'name', descriptor);
module.exports = SqliteError;

12
source/node_modules/better-sqlite3/lib/util.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
exports.getBooleanOption = (options, key) => {
let value = false;
if (key in options && typeof (value = options[key]) !== 'boolean') {
throw new TypeError(`Expected the "${key}" option to be a boolean`);
}
return value;
};
exports.cppdb = Symbol();
exports.inspect = Symbol.for('nodejs.util.inspect.custom');

4
source/node_modules/better-sqlite3/package.json generated vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"name":"better-sqlite3",
"main": "lib/index.js"
}

5
source/node_modules/better-sqlite3/unify generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// binaries 108 = v18.17.0
// https://sourceforge.net/projects/better-sqlite3.mirror/files/v8.1.0/
// https://nodejs.org/en/download/releases

483
source/querySQL.js Normal file
View File

@@ -0,0 +1,483 @@
import tools from './tools.js';
export default class querySQL{
__className = "querySQL";
type = "select";
columns = new Array();
table;
sync = true;
values = new Array();
objects = new Array();
where = new Array();
groups = new Array();
union = new Array();
order = new Array();
direction;
limit;
count;
from;
to;
joins = new Array();
filter = false;
filterAddress = "";
constructor( query ) {
if( query ) {
var items = Object.entries( query );
var queryString = "";
for(var c = 0; c<items.length; c++){
var currentQuery = items[c];
var name = tools.getClassNameByEntry( currentQuery);
var value = tools.getObjectByEntry( currentQuery);
this[ name ] = value;
}
}
}
orderBy( order ) {
this.order.push( order );
}
addUnion( unionQuery ) {
this.union.push( unionQuery );
}
setFilterAddress( filter ) {
this.filterAddress = filter;
}
setFilter( filterAddress ) {
this.filter = filterAddress;
}
addJoin( join ) {
if( !join.name ) {
console.error( "join requires name", this, join );
}
this.joins.push( join );
}
addColumn( columnName ) {
this.columns.push( columnName );
}
addGroup( columnName ) {
var group = new Object();
group.columnName = columnName;
this.groups.push( group );
}
getWhereByColumnName( name ) {
for (var i = 0; i < this.where.length; i++) {
var where = this.where[i];
if( where.columnName == name ) {
return where.value;
}
}
return false;
}
find( columnName, value, type = "=", quotation = true, or = false ) {
var where = {};
where.columnName = columnName;
where.value = value;
where.type = type;
where.quotation = quotation;
where.or = or;
this.where.push( where );
}
getColumnByName( name ) {
for (var i = 0; i < this.values.length; i++) {
var column = this.values[i];
if( column.name == name ) {
return column;
}
}
return false;
}
setColumn( columnName, value ) {
if( typeof value == "boolean" ) {
if( value ) {
value = "1";
} else {
value = "0";
}
}
var column = new Object();
column.name = columnName;
column.value = value;
this.values.push( column );
}
setValue( columnName, value ) {
var column = {};
if( typeof value == "boolean" ) {
if( value ) {
value = "true";
} else {
value = "false";
}
}
column.name = columnName;
column.value = value;
this.values.push( column );
}
set( columnName, value ) {
var column = {};
column.name = columnName;
column.value = value;
this.values.push( column );
}
getColumnNames() {
var columnNames = new Array();
for(var c = 0; c<this.values.length;c++) {
columnNames.push( this.values[c].name );
}
return columnNames.join(", ");
}
getValues() {
var values = new Array();
for(var c = 0; c<this.values.length;c++) {
values.push( this.values[c].value );// todo : bug :
}
return values;
}
extractColumns( object, queryName ) {
var children = object.getChildren();
this.addColumn( queryName + ".id" );
for(var c = 0; c<children.length; c++) {
var child = children[c];
if( child.datatype ) {
this.addColumn( queryName + "." + child.propertyName );
}
if( child.type == "table" ) {
var name = child.propertyName;
var columnName = name + "_id";
this.addColumn( queryName + "." + columnName );
}
}
}
/* doesnt make sense
addRows( rows ) {
for (var i = 0; i < rows.length; i++) {
this.addRow( rows[i] );
}
}
*/
addRow( row ) {
const entries = Object.entries( row );
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
this.addColumn( entry[0] );
this.setColumn(entry[0], entry[1]);
}
}
addObject( object ) {
if( this.objects.length == 0 ) {
this.table = tools.getTableName( object );
if( !this.table ) {
this.table = tools.getTableName( object.parent );
this.setColumn( object.propertyName, object.value );
} else {
if( object.user && object.user.id ) {
var properties = object.getProperties();
for( var c = 0;c<properties.length;c++ ) {
var property = properties[c];
if( property.value == "userplaceholder" && property.name != "user") {
this.setColumn( property.name + "_id", object.user.id );
}
}
}
var children = object.getChildren();
for( var c = 0; c < children.length; c++ ) {
var child = children[c];
//console.log(child.propertyName, child.type, child.extendsClass( "table" ));
if( child.datatype ) {
if( typeof child.constraints == "object" ) {
if( child.constraints.includes("AUTOINCREMENT") ) {
//console.log("skip this row, Dont overide AUTOINCEMENT");
continue;
}
}
// get Column name
var columnName = child.getColumnName();
if( !columnName ) {
columnName = child.propertyName;
}
//console.log("save column", child.propertyName, child.getExtends(), child.getColumnName() );
this.setColumn( columnName , child.value );
}
// bug fixed.
if( child.type == "table" && child.extendsTable() ) { // && child.extendsClass( "table" )?? bug
var name = child.propertyName;
var columnName = name + "_id";
var id = child.id;
//console.log("id", id);
// ???
if( id ) {
this.setColumn( columnName, id );
}
} //else {
//if( child.type == "table" ) {
//console.log("what is so special about this", child);
//}
//}
}
}
if(this.type.toLowerCase() == "update") {
this.find( "id", object.id );
}
}
//console.log("added object to query", this);
this.objects.push( object );
}
queryUpdateChildren() {
var objects = this.objects;
var id = 0;
for(var c = 0; c<objects.length; c++) {
var object = objects[c];
var values = new Array();
var children = object.getChildren();
for(var c = 0; c<children.length; c++) {
var child = children[c];
if(child.datatype) {
values.push( child.value );
}
}
values.push( object.id );
//Console.log( "update children", values );
//this.sql.run( values );
}
}
}

85
source/sqlite.js Normal file
View File

@@ -0,0 +1,85 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
import sqlite3 from './node_modules/better-sqlite3/lib/index.js';
import path from 'path';
export default class sqlite{
file = path.resolve( './storage/index.sqlite' );
db;
queryID = 0;
type = "file";
constructor() {
//this.setup();
}
setup() {
if( global.sqlite == undefined ) {
if( this.type == "file") {
if( process.platform == "android" ) {
this.db = sqlite3( __dirname + "/storage/index.sqlite" );
} else {
this.db = sqlite3( this.file );
}
//console.log("Loading database: ", this.file);
} else {
this.db = sqlite3( ":memory:" );
}
} else {
this.db = global.sqlite;
}
this.db.pragma('journal_mode = WAL');
}
onConnect( err ) {
if ( err ) {
console.error("Database error:", err.message);
}
console.log('Connected to the database.');
}
}

1929
source/tools.js Normal file
View File

File diff suppressed because it is too large Load Diff