Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1.31
  • master
  • 1.10.0
  • 1.30.1
  • 1.31.0
  • 1.8.0
  • 1.9.0
  • 3.100.0
  • 3.100.1
  • 3.100.10
  • 3.100.11
  • 3.100.12
  • 3.100.13
  • 3.100.14
  • 3.100.15
  • 3.100.16
  • 3.100.17
  • 3.100.18
  • 3.100.19
  • 3.100.2
  • 3.100.20
  • 3.100.3
  • 3.100.4
  • 3.100.5
  • 3.100.6
  • 3.100.7
  • 3.100.8
  • 3.100.9
  • 3.101.0
  • 3.101.1
  • 3.101.2
  • 3.101.3
  • 3.102.0
  • 3.102.1
  • 3.102.2
  • 3.102.3
  • 3.102.4
  • 3.102.5
  • 3.102.6
  • 3.103.0
  • 3.103.1
  • 3.104.0
  • 3.104.1
  • 3.105.0
  • 3.105.1
  • 3.105.2
  • 3.106.0
  • 3.106.1
  • 3.107.0
  • 3.108.0
  • 3.108.1
  • 3.108.2
  • 3.108.3
  • 3.108.4
  • 3.108.5
  • 3.109.0
  • 3.110.0
  • 3.110.1
  • 3.110.2
  • 3.110.3
  • 3.110.4
  • 3.111.0
  • 3.112.0
  • 3.112.1
  • 3.112.2
  • 3.112.3
  • 3.112.4
  • 3.113.0
  • 3.114.0
  • 3.114.1
  • 3.114.2
  • 3.114.3
  • 3.114.4
  • 3.114.5
  • 3.114.6
  • 3.114.7
  • 3.115.0
  • 3.115.1
  • 3.115.2
  • 3.115.3
  • 3.115.4
  • 3.116.0
  • 3.116.1
  • 3.117.0
  • 3.117.1
  • 3.117.2
  • 3.117.3
  • 3.118.0
  • 3.118.1
  • 3.119.0
  • 3.120.0
  • 3.121.0
  • 3.51.5
  • 3.52.0
  • 3.52.1
  • 3.53.0
  • 3.54.0
  • 3.55.0
  • 3.55.1
  • 3.55.2
  • 3.55.3
  • 3.55.4
102 results

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
  • 1.31
  • master
  • 1.10.0
  • 1.30.1
  • 1.31.0
  • 1.8.0
  • 1.9.0
  • 3.100.0
  • 3.100.1
  • 3.100.10
  • 3.100.11
  • 3.100.12
  • 3.100.13
  • 3.100.14
  • 3.100.15
  • 3.100.16
  • 3.100.17
  • 3.100.18
  • 3.100.19
  • 3.100.2
  • 3.100.20
  • 3.100.3
  • 3.100.4
  • 3.100.5
  • 3.100.6
  • 3.100.7
  • 3.100.8
  • 3.100.9
  • 3.101.0
  • 3.101.1
  • 3.101.2
  • 3.101.3
  • 3.102.0
  • 3.102.1
  • 3.102.2
  • 3.102.3
  • 3.102.4
  • 3.102.5
  • 3.102.6
  • 3.103.0
  • 3.103.1
  • 3.104.0
  • 3.104.1
  • 3.105.0
  • 3.105.1
  • 3.105.2
  • 3.106.0
  • 3.106.1
  • 3.107.0
  • 3.108.0
  • 3.108.1
  • 3.108.2
  • 3.108.3
  • 3.108.4
  • 3.108.5
  • 3.109.0
  • 3.110.0
  • 3.110.1
  • 3.110.2
  • 3.110.3
  • 3.110.4
  • 3.111.0
  • 3.112.0
  • 3.112.1
  • 3.112.2
  • 3.112.3
  • 3.112.4
  • 3.113.0
  • 3.114.0
  • 3.114.1
  • 3.114.2
  • 3.114.3
  • 3.114.4
  • 3.114.5
  • 3.114.6
  • 3.114.7
  • 3.115.0
  • 3.115.1
  • 3.115.2
  • 3.115.3
  • 3.115.4
  • 3.116.0
  • 3.116.1
  • 3.117.0
  • 3.117.1
  • 3.117.2
  • 3.117.3
  • 3.118.0
  • 3.118.1
  • 3.119.0
  • 3.120.0
  • 3.121.0
  • 3.51.5
  • 3.52.0
  • 3.52.1
  • 3.53.0
  • 3.54.0
  • 3.55.0
  • 3.55.1
  • 3.55.2
  • 3.55.3
  • 3.55.4
102 results
Show changes
Commits on Source (5)
Showing
with 309 additions and 256 deletions
<a name="v3.4.0"></a>
## [v3.4.0] - 2023-01-08
### Add Features
- add new layer class Server
### Changes
- remove unused code
<a name="v3.3.0"></a>
## [v3.3.0] - 2023-01-07
### Add Features
......@@ -162,6 +171,7 @@
<a name="1.8.0"></a>
## 1.8.0 - 2021-08-15
[v3.4.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.3.0...v3.4.0
[v3.3.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.2.0...v3.3.0
[v3.2.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.1.2...v3.2.0
[v3.1.2]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.1.1...v3.1.2
......
......@@ -73,7 +73,7 @@ We do try to work around some browser bugs, but on the whole we don't use polyfi
However, many functions can be mapped via [polyfill.io](https://polyfill.io/) and thus the compatibility can be increased.
```html
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,CustomEvent,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.matchAll,String.prototype.padStart,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.for,Symbol.hasInstance,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,Blob,CustomEvent,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.matchAll,String.prototype.padStart,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.for,Symbol.hasInstance,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
```
......
{
"name": "@schukai/monster",
"version": "3.2.0",
"version": "3.3.0",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [
"framework",
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
* This file is licensed under the AGPLv3 License.
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol,instanceSymbol} from "../../constants.mjs";
import {isObject} from "../../types/is.mjs";
import {Datasource} from "../datasource.mjs";
import {Pathfinder} from "../pathfinder.mjs";
import {Pipe} from "../pipe.mjs";
export {Server}
/**
* Base class for all server datasources
*
* @license AGPLv3
* @since 3.4.0
* @copyright schukai GmbH
* @memberOf Monster.Data.Datasource
* @summary The Server class encapsulates the access to a server datasource
*/
class Server extends Datasource {
/**
* This method is called by the `instanceof` operator.
* @returns {symbol}
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/data/datasource/server");
}
/**
* This prepares the data that comes from the server.
* Should not be called directly.
*
* @private
* @param {Object} payload
* @returns {Object}
*/
transformServerPayload(payload) {
const self = this;
payload = doTransform.call(self, 'read', payload);
const dataPath = self.getOption('read.path');
if (dataPath) {
payload = (new Pathfinder(payload)).getVia(dataPath);
}
return payload;
}
/**
* This prepares the data for writing and should not be called directly.
*
* @private
* @param {Object} payload
* @returns {Object}
*/
prepareServerPayload(payload) {
const self = this;
payload = doTransform.call(self, 'write', payload);
let sheathingObject = self.getOption('write.sheathing.object');
let sheathingPath = self.getOption('write.sheathing.path');
if (sheathingObject && sheathingPath) {
const sub = payload;
payload = sheathingObject;
(new Pathfinder(payload)).setVia(sheathingPath, sub);
}
return payload;
}
}
/**
*
* @param self
* @param obj
* @returns {*}
*/
function doTransform(type, obj) {
const self = this;
let transformation = self.getOption(type + '.mapping.transformer');
if (transformation !== undefined) {
const pipe = new Pipe(transformation);
const callbacks = self.getOption(type + '.mapping.callbacks')
if (isObject(callbacks)) {
for (const key in callbacks) {
if (callbacks.hasOwnProperty(key) && typeof callbacks[key] === 'function') {
pipe.setCallback(key, callbacks[key]);
}
}
}
obj = pipe.run(obj);
}
return obj;
}
......@@ -5,12 +5,12 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol,instanceSymbol} from "../../constants.mjs";
import {isObject} from "../../types/is.mjs";
import {Datasource} from "../datasource.mjs";
import {Pathfinder} from "../pathfinder.mjs";
import {Pipe} from "../pipe.mjs";
import {WriteError} from "./restapi/writeerror.mjs";
import {internalSymbol, instanceSymbol} from "../../../constants.mjs";
import {isObject} from "../../../types/is.mjs";
import {Server} from "../server.mjs";
import {Pathfinder} from "../../pathfinder.mjs";
import {Pipe} from "../../pipe.mjs";
import {WriteError} from "../restapi/writeerror.mjs";
export {RestAPI}
......@@ -21,25 +21,21 @@ export {RestAPI}
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
* @memberOf Monster.Data.Datasource
* @memberOf Monster.Data.Datasource.Server
* @summary The RestAPI is a class that binds a REST API server.
*/
class RestAPI extends Datasource {
class RestAPI extends Server {
/**
*
* @param {Object} [readDefinition] An options object containing any custom settings that you want to apply to the read request.
* @param {Object} [writeDefinition] An options object containing any custom settings that you want to apply to the write request.
* @param {Object} [options] options contains definitions for the datasource.
*/
constructor(readDefinition, writeDefinition) {
constructor(options) {
super();
const options = {}
if (isObject(readDefinition)) options.read = readDefinition;
if (isObject(writeDefinition)) options.write = writeDefinition;
if (isObject(options)) {
this.setOptions(options);
}
}
......@@ -49,7 +45,7 @@ class RestAPI extends Datasource {
* @since 2.1.0
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/data/datasource/restapi");
return Symbol.for("@schukai/monster/data/datasource/server/restapi");
}
/**
......@@ -124,7 +120,8 @@ class RestAPI extends Datasource {
let init = self.getOption('read.init');
if (!isObject(init)) init = {};
return fetch(self.getOption('read.url'), init).then(resp => {
return new Promise((resolve, reject) => {
fetch(self.getOption('read.url'), init).then(resp => {
response = resp;
const acceptedStatus = self.getOption('read.acceptedStatus', [200]);
......@@ -150,19 +147,10 @@ class RestAPI extends Datasource {
throw new Error('the response does not contain a valid json (actual: ' + body + ').');
}
let transformation = self.getOption('read.mapping.transformer');
if (transformation !== undefined) {
const pipe = new Pipe(transformation);
for (const callback of self.getOption('read.mapping.callbacks')) {
pipe.setCallback(callback.constructor.name, callback);
}
obj = pipe.run(obj);
}
self.set(self.transformServerPayload.call(self, obj));
resolve(response);
}).catch(reject);
self.set(obj);
return response;
})
}
......@@ -173,7 +161,6 @@ class RestAPI extends Datasource {
write() {
const self = this;
let init = self.getOption('write.init');
if (!isObject(init)) init = {};
if (typeof init['headers'] !== 'object') {
......@@ -182,42 +169,28 @@ class RestAPI extends Datasource {
}
}
let obj = self.get();
let transformation = self.getOption('write.mapping.transformer');
if (transformation !== undefined) {
const pipe = new Pipe(transformation);
for (const callback of self.getOption('write.mapping.callbacks')) {
pipe.setCallback(callback.constructor.name, callback);
}
obj = pipe.run(obj);
}
let sheathingObject = self.getOption('write.sheathing.object');
let sheathingPath = self.getOption('write.sheathing.path');
let reportPath = self.getOption('write.report.path');
if (sheathingObject && sheathingPath) {
const sub = obj;
obj = sheathingObject;
(new Pathfinder(obj)).setVia(sheathingPath, sub);
}
let obj = self.prepareServerPayload(self.get());
init['body'] = JSON.stringify(obj);
return fetch(self.getOption('write.url'), init).then(response => {
return new Promise((resolve, reject) => {
fetch(self.getOption('write.url'), init).then(response => {
const acceptedStatus = self.getOption('write.acceptedStatus', [200, 201]);
const acceptedStatus = self.getOption('write.acceptedStatus', [200, 2001]);
if (acceptedStatus.indexOf(response.status) === -1) {
if (acceptedStatus.indexOf(response.status) > -1) {
reject(response);
return;
}
return response.text().then((body) => {
response.text().then((body) => {
let obj, validation;
let obj = {}, validation = {};
try {
obj = JSON.parse(body);
validation = new Pathfinder(obj).getVia(reportPath)
if (reportPath) {
validation = (new Pathfinder(obj)).getVia(reportPath);
}
} catch (e) {
......@@ -225,18 +198,20 @@ class RestAPI extends Datasource {
body = body.substring(0, 97) + '...';
}
throw new Error('the response does not contain a valid json (actual: ' + body + ').');
reject(new Error('the response does not contain a valid json (actual: ' + body + ').'));
return;
}
throw new WriteError('the data cannot be written (response ' + response.status + ')', response, validation)
reject(new WriteError('the data cannot be written (response ' + response.status + ')', response, validation))
return;
})
}).catch(reject);
}
}).catch(reject);
})
return response;
});
}
......
......@@ -5,15 +5,14 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol, instanceSymbol} from "../../constants.mjs";
import {isString, isObject} from "../../types/is.mjs";
import {WebConnect} from "../../net/webconnect.mjs";
import {Message} from "../../net/webconnect/message.mjs";
import {Datasource} from "../datasource.mjs";
import {Pathfinder} from "../pathfinder.mjs";
import {Pipe} from "../pipe.mjs";
import {internalSymbol, instanceSymbol} from "../../../constants.mjs";
import {isString, isObject} from "../../../types/is.mjs";
import {WebConnect as NetWebConnect} from "../../../net/webconnect.mjs";
import {Message} from "../../../net/webconnect/message.mjs";
import {Server} from "../server.mjs";
export {WebSocketDatasource}
export {WebConnect}
/**
......@@ -24,32 +23,7 @@ export {WebSocketDatasource}
*/
const webConnectSymbol = Symbol("connection");
/**
*
* @param self
* @param obj
* @returns {*}
*/
function doTransform(type, obj) {
const self = this;
let transformation = self.getOption(type + '.mapping.transformer');
if (transformation !== undefined) {
const pipe = new Pipe(transformation);
const callbacks = self.getOption(type + '.mapping.callbacks')
if (isObject(callbacks)) {
for (const key in callbacks) {
if (callbacks.hasOwnProperty(key) && typeof callbacks[key] === 'function') {
pipe.setCallback(key, callbacks[key]);
}
}
}
obj = pipe.run(obj);
}
return obj;
}
/**
* The RestAPI is a class that enables a REST API server.
......@@ -58,10 +32,10 @@ function doTransform(type, obj) {
* @license AGPLv3
* @since 3.1.0
* @copyright schukai GmbH
* @memberOf Monster.Data.Datasource
* @memberOf Monster.Data.Datasource.Server
* @summary The LocalStorage class encapsulates the access to data objects.
*/
class WebSocketDatasource extends Datasource {
class WebConnect extends Server {
/**
*
......@@ -78,7 +52,7 @@ class WebSocketDatasource extends Datasource {
if (!isObject(options)) options = {};
this.setOptions(options);
this[webConnectSymbol] = new WebConnect({
this[webConnectSymbol] = new NetWebConnect({
url: self.getOption('url'),
connection: {
timeout: self.getOption('connection.timeout'),
......@@ -111,7 +85,7 @@ class WebSocketDatasource extends Datasource {
* @returns {symbol}
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/data/datasource/websocket");
return Symbol.for("@schukai/monster/data/datasource/server/webconnect");
}
/**
......@@ -195,7 +169,6 @@ class WebSocketDatasource extends Datasource {
}
obj = obj.getData();
obj = self.transformServerPayload.call(self, obj);
self.set( obj);
}
......@@ -206,95 +179,6 @@ class WebSocketDatasource extends Datasource {
};
// const self = this;
// let response;
//
// if (self[webConnectSymbol]?.socket?.readyState !== 1) {
// return Promise.reject('The connection is not established.');
// }
//
// return new Promise((resolve, reject) => {
// if (self[receiveQueueSymbol].isEmpty()) {
// resolve();
// }
//
// while (!self[receiveQueueSymbol].isEmpty()) {
//
// const event = self[receiveQueueSymbol].poll();
// const body = event?.data;
// if (!body) continue;
//
// let obj;
// try {
// obj = JSON.parse(body);
// } catch (e) {
//
// let msg = 'the response does not contain a valid json (actual: ';
//
// if (body.length > 100) {
// msg += body.substring(0, 97) + '...';
// } else {
// msg += body;
// }
//
// msg += "; " + e.message + ')';
//
// reject(msg);
// return;
// }
//
// obj = self.transformServerPayload.call(self, obj);
//
//
// self.set(obj);
// return response;
// }
// })
//}
/**
* This prepares the data that comes from the server.
* Should not be called directly.
*
* @private
* @param {Object} payload
* @returns {Object}
*/
transformServerPayload(payload) {
const self = this;
payload = doTransform.call(self, 'read', payload);
const dataPath = self.getOption('read.path');
if (dataPath) {
payload = (new Pathfinder(payload)).getVia(dataPath);
}
return payload;
}
/**
* This prepares the data for writing and should not be called directly.
*
* @private
* @param {Object} payload
* @returns {Object}
*/
prepareServerPayload(payload) {
const self = this;
payload = doTransform.call(self, 'write', payload);
let sheathingObject = self.getOption('write.sheathing.object');
let sheathingPath = self.getOption('write.sheathing.path');
if (sheathingObject && sheathingPath) {
const sub = payload;
payload = sheathingObject;
(new Pathfinder(payload)).setVia(sheathingPath, sub);
}
return payload;
}
/**
* @return {Promise}
......@@ -305,13 +189,12 @@ class WebSocketDatasource extends Datasource {
return self[webConnectSymbol].send(obj)
}
/**
* @return {RestAPI}
*/
getClone() {
const self = this;
return new WebSocketDatasource(self[internalSymbol].getRealSubject()['options']);
return new WebConnect(self[internalSymbol].getRealSubject()['options']);
}
}
......
......@@ -191,7 +191,7 @@ class Locale extends Base {
*
* ```
* <script type="module">
* import {Monster} from '@schukai/monster/source//monster.mjs';
* import {Monster} from '@schukai/monster/source/monster.mjs';
* new Monster.I18n.createLocale()
* </script>
* ```
......
......@@ -31,7 +31,7 @@ export {Stylesheet} from "./dom/resource/link/stylesheet.mjs"
export {Data} from "./dom/resource/data.mjs"
export {Link} from "./dom/resource/link.mjs"
export {Script} from "./dom/resource/script.mjs"
export {Updater} from "./dom/updater.mjs"
export {Updater, addObjectWithUpdaterToElement} from "./dom/updater.mjs"
export {CustomControl} from "./dom/customcontrol.mjs"
export {getLocaleOfDocument} from "./dom/locale.mjs"
export {Theme, getDocumentTheme} from "./dom/theme.mjs"
......@@ -91,6 +91,7 @@ export {
ATTRIBUTE_EXPORTPARTS,
ATTRIBUTE_HIDDEN,
objectUpdaterLinkSymbol,
customElementUpdaterLinkSymbol
} from "./dom/constants.mjs"
export {
......@@ -127,14 +128,18 @@ export {Locale, parseLocale} from "./i18n/locale.mjs"
export {Formatter as I18nFormatter} from "./i18n/formatter.mjs"
export {Fetch} from "./i18n/providers/fetch.mjs"
export {Provider} from "./i18n/provider.mjs"
export {Message} from "./net/webconnect/message.mjs"
export {WebConnect as NetWebConnect} from "./net/webconnect.mjs"
export {
internalSymbol,
internalStateSymbol
internalStateSymbol,
instanceSymbol
} from "./constants.mjs"
export {MediaType, parseMediaType} from "./types/mediatype.mjs"
export {typeOf} from "./types/typeof.mjs"
export {ObserverList} from "./types/observerlist.mjs"
export {RandomID} from "./types/randomid.mjs"
export {ObservableQueue} from "./types/observablequeue.mjs"
export {UUID} from "./types/uuid.mjs"
export {Observer} from "./types/observer.mjs"
export {TokenList} from "./types/tokenlist.mjs"
......@@ -182,13 +187,16 @@ export {buildTree} from "./data/buildtree.mjs"
export {Transformer} from "./data/transformer.mjs"
export {Pathfinder, DELIMITER, WILDCARD} from "./data/pathfinder.mjs"
export {diff} from "./data/diff.mjs"
export {RestAPI} from "./data/datasource/restapi.mjs"
export {Server} from "./data/datasource/server.mjs"
export {SessionStorage} from "./data/datasource/storage/sessionstorage.mjs"
export {LocalStorage} from "./data/datasource/storage/localstorage.mjs"
export {RestAPI} from "./data/datasource/server/restapi.mjs"
export {WebConnect} from "./data/datasource/server/webconnect.mjs"
export {WriteError} from "./data/datasource/restapi/writeerror.mjs"
export {Storage, storageObjectSymbol} from "./data/datasource/storage.mjs"
export {random} from "./math/random.mjs"
export {Monster}
/**
......
......@@ -84,7 +84,7 @@ function getGlobal() {
*
* ```
* <script type="module">
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.mjs';
* import {Monster} from '@schukai/monster/source/monster.mjs';
* Monster.Types.getGlobalObject('document')
* // ↦ { }
* </script>
......@@ -124,7 +124,7 @@ function getGlobalObject(name) {
*
* ```
* <script type="module">
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.mjs';
* import {Monster} from '@schukai/monster/source/monster.mjs';
* console.log(Monster.Types.getGlobalFunction('parseInt')) // ↦ f parseInt() { }
* </script>
* ```
......
......@@ -134,7 +134,7 @@ class MediaType extends Base {
*
* ```
* <script type="module">
* import {Monster} from '@schukai/monster/source//monster.mjs';
* import {Monster} from '@schukai/monster/source/monster.mjs';
* console.log(Monster.Types.parseMediaType())
* </script>
* ```
......
......@@ -149,7 +149,7 @@ function getMonsterVersion() {
}
/** don't touch, replaced by make with package.json version */
monsterVersion = new Version('3.2.0')
monsterVersion = new Version('3.3.0')
return monsterVersion;
......
{
"name": "monster",
"version": "3.2.0",
"version": "3.3.0",
"description": "monster",
"repository": {
"type": "git",
......
......@@ -10,6 +10,8 @@ let exportLines = []
function scanSymbols(root) {
let f;
const dir = fs.opendirSync(root);
while ((f = dir.readSync()) !== null) {
......@@ -20,6 +22,8 @@ function scanSymbols(root) {
continue;
}
if(f.name==="monster.mjs") continue;
if ((path.extname(f.name) !== ".mjs")) {
continue;
}
......
import {expect} from "chai"
import {Server} from "../../../../../application/source/data/datasource/server.mjs";
describe('Server', function () {
it('should transform data', function () {
let writeCallbackCalled = false
let readCallbackCalled = false
const server = new Server({
write: {
mapping: {
transformer: "call:onWrite",
callbacks: {
onWrite: (data) => {
writeCallbackCalled = true
return data
}
}
},
sheathing: {
object: {
demo: 1,
data: {
xyz: undefined
}
},
path: "data.xyz",
},
},
read: {
mapping: {
transformer: "call:onRead",
callbacks: {
onRead: (data) => {
readCallbackCalled = true
return data
}
}
},
path: 'data.xyz',
}
})
expect(server.transformServerPayload({demo: 1, data: {xyz: 2}})).to.deep.equal({demo: 1, data: {xyz: 2}})
expect(server.prepareServerPayload({demo: 1, data: {xyz: 2}})).to.deep.equal({demo: 1, data: {xyz: 2}})
})
});
"use strict";
import {expect} from "chai"
import {RestAPI} from "../../../../../application/source/data/datasource/restapi.mjs";
import {validateObject} from "../../../../../application/source/types/validate.mjs";
import {RestAPI} from "../../../../../../application/source/data/datasource/server/restapi.mjs";
import {validateObject} from "../../../../../../application/source/types/validate.mjs";
describe('RestAPI', function () {
......@@ -18,16 +18,19 @@ describe('RestAPI', function () {
returnStatus = 200;
fetchReference = globalThis['fetch'];
globalThis['fetch'] = function (url, options) {
if (!url) throw new Error('missing url')
globalThis['fetch'] = function (options) {
return new Promise((resolve, reject) => {
resolve({
text: function () {
return JSON.stringify({
return new Promise((resolve, reject) => {
resolve(JSON.stringify({
a: "test"
})
}));
});
},
status: returnStatus
});
......@@ -52,11 +55,14 @@ describe('RestAPI', function () {
});
it('write should ', function (done) {
const ds = new RestAPI({url: 'https://monsterjs.org/assets/world.json'}, {url: 'https://monsterjs.org/assets/world.json'})
const ds = new RestAPI({url: 'https://monsterjs.org/assets/world.json'},
{
url: 'https://monsterjs.org/assets/world.json',
acceptedStatus: [99]
})
ds.write().then(data => {
validateObject(data);
done();
}).catch(e => done(e));
done("should not be here");
}).catch(e => done());
});
......
import {expect} from "chai"
import {WebSocketDatasource} from "../../../../../application/source/data/datasource/websocket.mjs";
import {initWebSocket} from "../../../util/websocket.mjs";
import {WebConnect} from "../../../../../../application/source/data/datasource/server/webconnect.mjs";
import {initWebSocket} from "../../../../util/websocket.mjs";
const testUrl = "wss://ws.postman-echo.com/raw"
......@@ -33,7 +33,9 @@ describe('Websocket', function () {
if (sym2.toString() === 'Symbol(connection)') {
const socket = connection[sym2]?.socket;
if (socket) {
socket.terminate()
if (typeof socket?.terminate === 'function') {
socket?.['terminate']()
}
}
}
}
......@@ -45,10 +47,10 @@ describe('Websocket', function () {
it('should get clone', function () {
ds = new WebSocketDatasource(testUrl)
ds = new WebConnect(testUrl)
const clone = ds.getClone()
expect(clone).to.be.an.instanceof(WebSocketDatasource)
expect(clone).to.be.an.instanceof(WebConnect)
})
......@@ -58,7 +60,7 @@ describe('Websocket', function () {
let writeCallbackCalled = false
let readCallbackCalled = false
ds = new WebSocketDatasource({
ds = new WebConnect({
url: testUrl,
write: {
mapping: {
......@@ -132,7 +134,7 @@ describe('Websocket', function () {
})
it('should connect', function (done) {
ds = new WebSocketDatasource({
ds = new WebConnect({
url: testUrl,
reconnect: {
enabled: false
......@@ -148,7 +150,7 @@ describe('Websocket', function () {
})
it('should send message', function (done) {
ds = new WebSocketDatasource({
ds = new WebConnect({
url: testUrl,
reconnect: {
enabled: false
......
......@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion
/** don´t touch, replaced by make with package.json version */
monsterVersion = new Version('3.2.0')
monsterVersion = new Version('3.3.0')
let m = getMonsterVersion();
......
......@@ -26,7 +26,7 @@ describe('Websocket', function () {
// without this, the node test will hang
for (const sym of Object.getOwnPropertySymbols(ds)) {
if (sym.toString() === 'Symbol(connection)') {
if (ds[sym]?.socket?.['terminate']) {
if (typeof ds[sym]?.socket?.terminate === 'function') {
ds[sym]?.socket?.['terminate']()
}
}
......
......@@ -30,10 +30,13 @@ import "../cases/i18n/locale.mjs";
import "../cases/i18n/formatter.mjs";
import "../cases/i18n/providers/fetch.mjs";
import "../cases/i18n/provider.mjs";
import "../cases/net/webconnect/message.mjs";
import "../cases/net/webconnect.mjs";
import "../cases/types/mediatype.mjs";
import "../cases/types/typeof.mjs";
import "../cases/types/observerlist.mjs";
import "../cases/types/randomid.mjs";
import "../cases/types/observablequeue.mjs";
import "../cases/types/uuid.mjs";
import "../cases/types/observer.mjs";
import "../cases/types/tokenlist.mjs";
......@@ -75,8 +78,9 @@ import "../cases/data/buildtree.mjs";
import "../cases/data/transformer.mjs";
import "../cases/data/pathfinder.mjs";
import "../cases/data/diff.mjs";
import "../cases/data/datasource/restapi.mjs";
import "../cases/data/datasource/server.mjs";
import "../cases/data/datasource/storage/sessionstorage.mjs";
import "../cases/data/datasource/storage/localstorage.mjs";
import "../cases/data/datasource/webservice.mjs";
import "../cases/data/datasource/server/restapi.mjs";
import "../cases/data/datasource/server/websocket.mjs";
import "../cases/math/random.mjs";
......@@ -5,7 +5,7 @@
<title>Mocha Monster</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="mocha.css"/>
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,CustomEvent,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.matchAll,String.prototype.padStart,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.for,Symbol.hasInstance,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,Blob,CustomEvent,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.matchAll,String.prototype.padStart,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.for,Symbol.hasInstance,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,DataView,document,DocumentFragment,Element,Event,globalThis,HTMLDocument,HTMLTemplateElement,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.getOwnPropertyDescriptor,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.matchAll,String.prototype.padStart,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.iterator,WeakMap,WeakSet"
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
......@@ -14,8 +14,8 @@
</head>
<body>
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
<h1 style='margin-bottom: 0.1em;'>Monster 3.0.0</h1>
<div id="lastupdate" style='font-size:0.7em'>last update Fr 6. Jan 12:54:47 CET 2023</div>
<h1 style='margin-bottom: 0.1em;'>Monster 3.3.0</h1>
<div id="lastupdate" style='font-size:0.7em'>last update So 8. Jan 17:05:05 CET 2023</div>
</div>
<div id="mocks"></div>
<div id="mocha"></div>
......