landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
|
||||
/* global WorkerGlobalScope */
|
||||
function add(fn) {
|
||||
if (typeof WorkerGlobalScope === 'function' && self instanceof WorkerGlobalScope) {// this is run inside of a webworker
|
||||
} else {
|
||||
/**
|
||||
* if we are on react-native, there is no window.addEventListener
|
||||
* @link https://github.com/pubkey/unload/issues/6
|
||||
*/
|
||||
if (typeof window.addEventListener !== 'function') return;
|
||||
/**
|
||||
* for normal browser-windows, we use the beforeunload-event
|
||||
*/
|
||||
|
||||
window.addEventListener('beforeunload', function () {
|
||||
fn();
|
||||
}, true);
|
||||
/**
|
||||
* for iframes, we have to use the unload-event
|
||||
* @link https://stackoverflow.com/q/47533670/3443137
|
||||
*/
|
||||
|
||||
window.addEventListener('unload', function () {
|
||||
fn();
|
||||
}, true);
|
||||
}
|
||||
/**
|
||||
* TODO add fallback for safari-mobile
|
||||
* @link https://stackoverflow.com/a/26193516/3443137
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
var _default = {
|
||||
add: add
|
||||
};
|
||||
exports["default"] = _default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var unload = require('./index.js');
|
||||
|
||||
window['unload'] = unload;
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.add = add;
|
||||
exports.runAll = runAll;
|
||||
exports.removeAll = removeAll;
|
||||
exports.getSize = getSize;
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _detectNode = _interopRequireDefault(require("detect-node"));
|
||||
|
||||
var _browser = _interopRequireDefault(require("./browser.js"));
|
||||
|
||||
var _node = _interopRequireDefault(require("./node.js"));
|
||||
|
||||
var USE_METHOD = _detectNode["default"] ? _node["default"] : _browser["default"];
|
||||
var LISTENERS = new Set();
|
||||
var startedListening = false;
|
||||
|
||||
function startListening() {
|
||||
if (startedListening) return;
|
||||
startedListening = true;
|
||||
USE_METHOD.add(runAll);
|
||||
}
|
||||
|
||||
function add(fn) {
|
||||
startListening();
|
||||
if (typeof fn !== 'function') throw new Error('Listener is no function');
|
||||
LISTENERS.add(fn);
|
||||
var addReturn = {
|
||||
remove: function remove() {
|
||||
return LISTENERS["delete"](fn);
|
||||
},
|
||||
run: function run() {
|
||||
LISTENERS["delete"](fn);
|
||||
return fn();
|
||||
}
|
||||
};
|
||||
return addReturn;
|
||||
}
|
||||
|
||||
function runAll() {
|
||||
var promises = [];
|
||||
LISTENERS.forEach(function (fn) {
|
||||
promises.push(fn());
|
||||
LISTENERS["delete"](fn);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
function removeAll() {
|
||||
LISTENERS.clear();
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
return LISTENERS.size;
|
||||
}
|
||||
|
||||
var _default = {
|
||||
add: add,
|
||||
runAll: runAll,
|
||||
removeAll: removeAll,
|
||||
getSize: getSize
|
||||
};
|
||||
exports["default"] = _default;
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
// set to true to log events
|
||||
var DEBUG = false;
|
||||
|
||||
function add(fn) {
|
||||
process.on('exit', function () {
|
||||
DEBUG && console.log('node: exit');
|
||||
return fn();
|
||||
});
|
||||
/**
|
||||
* on the following events,
|
||||
* the process will not end if there are
|
||||
* event-handlers attached,
|
||||
* therefore we have to call process.exit()
|
||||
*/
|
||||
|
||||
process.on('beforeExit', function () {
|
||||
DEBUG && console.log('node: beforeExit');
|
||||
return fn().then(function () {
|
||||
return process.exit();
|
||||
});
|
||||
}); // catches ctrl+c event
|
||||
|
||||
process.on('SIGINT', function () {
|
||||
DEBUG && console.log('node: SIGNINT');
|
||||
return fn().then(function () {
|
||||
return process.exit();
|
||||
});
|
||||
}); // catches uncaught exceptions
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
DEBUG && console.log('node: uncaughtException');
|
||||
return fn().then(function () {
|
||||
console.trace(err);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var _default = {
|
||||
add: add
|
||||
};
|
||||
exports["default"] = _default;
|
||||
Reference in New Issue
Block a user