metadata-detector-broker 3.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Christoph Guttandin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # metadata-detector-broker
2
+
3
+ **The broker which is used by the metadata-detector package.**
4
+
5
+ [![dependencies](https://img.shields.io/david/chrisguttandin/metadata-detector-broker.svg?style=flat-square)](https://github.com/chrisguttandin/metadata-detector-broker/network/dependencies)
6
+ [![version](https://img.shields.io/npm/v/metadata-detector-broker.svg?style=flat-square)](https://www.npmjs.com/package/metadata-detector-broker)
@@ -0,0 +1,5 @@
1
+ export declare const load: (url: string) => {
2
+ locate: (arrayBuffer: ArrayBuffer) => Promise<[number, number][]>;
3
+ strip: (arrayBuffer: ArrayBuffer) => Promise<ArrayBuffer>;
4
+ };
5
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI,QAAS,MAAM;0BAKC,WAAW,KAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;yBAwB1C,WAAW,KAAG,QAAQ,WAAW,CAAC;CA4BjE,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { addUniqueNumber } from 'fast-unique-numbers';
2
+ export const load = (url) => {
3
+ const worker = new Worker(url);
4
+ const ongoingRecordingRequests = new Set();
5
+ const locate = (arrayBuffer) => {
6
+ return new Promise((resolve, reject) => {
7
+ const id = addUniqueNumber(ongoingRecordingRequests);
8
+ const onMessage = ({ data }) => {
9
+ if (data.id === id) {
10
+ ongoingRecordingRequests.delete(id);
11
+ worker.removeEventListener('message', onMessage);
12
+ if (data.error === null) {
13
+ resolve(data.result.locations);
14
+ }
15
+ else {
16
+ reject(new Error(data.error.message));
17
+ }
18
+ }
19
+ };
20
+ worker.addEventListener('message', onMessage);
21
+ worker.postMessage({ id, method: 'locate', params: { arrayBuffer } }, [arrayBuffer]);
22
+ });
23
+ };
24
+ const strip = (arrayBuffer) => {
25
+ return new Promise((resolve, reject) => {
26
+ const id = addUniqueNumber(ongoingRecordingRequests);
27
+ const onMessage = ({ data }) => {
28
+ if (data.id === id) {
29
+ ongoingRecordingRequests.delete(id);
30
+ worker.removeEventListener('message', onMessage);
31
+ if (data.error === null) {
32
+ resolve(data.result.arrayBuffer);
33
+ }
34
+ else {
35
+ reject(new Error(data.error.message));
36
+ }
37
+ }
38
+ };
39
+ worker.addEventListener('message', onMessage);
40
+ worker.postMessage({ id, method: 'strip', params: { arrayBuffer } }, [arrayBuffer]);
41
+ });
42
+ };
43
+ return {
44
+ locate,
45
+ strip
46
+ };
47
+ };
48
+ //# sourceMappingURL=module.js.map
@@ -0,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AwB,EAAE;QAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,MAAM,EAAE,GAAG,eAAe,CAAC,wBAAwB,CAAC,CAAC;YAErD,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAgB,EAAE,EAAE;gBACzC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;oBAChB,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAEpC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;oBAEjD,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;wBACrB,OAAO,CAAkB,IAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;qBACtD;yBAAM;wBACH,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;qBACzC;iBACJ;YACL,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAE9C,MAAM,CAAC,WAAW,CAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;QACvG,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO;QACH,MAAM;QACN,KAAK;KACR,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,81 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fast-unique-numbers')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'fast-unique-numbers'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.metadataDetectorBroker = {}, global.fastUniqueNumbers));
5
+ }(this, (function (exports, fastUniqueNumbers) { 'use strict';
6
+
7
+ var load = function load(url) {
8
+ var worker = new Worker(url);
9
+ var ongoingRecordingRequests = new Set();
10
+
11
+ var locate = function locate(arrayBuffer) {
12
+ return new Promise(function (resolve, reject) {
13
+ var id = fastUniqueNumbers.addUniqueNumber(ongoingRecordingRequests);
14
+
15
+ var onMessage = function onMessage(_ref) {
16
+ var data = _ref.data;
17
+
18
+ if (data.id === id) {
19
+ ongoingRecordingRequests["delete"](id);
20
+ worker.removeEventListener('message', onMessage);
21
+
22
+ if (data.error === null) {
23
+ resolve(data.result.locations);
24
+ } else {
25
+ reject(new Error(data.error.message));
26
+ }
27
+ }
28
+ };
29
+
30
+ worker.addEventListener('message', onMessage);
31
+ worker.postMessage({
32
+ id: id,
33
+ method: 'locate',
34
+ params: {
35
+ arrayBuffer: arrayBuffer
36
+ }
37
+ }, [arrayBuffer]);
38
+ });
39
+ };
40
+
41
+ var strip = function strip(arrayBuffer) {
42
+ return new Promise(function (resolve, reject) {
43
+ var id = fastUniqueNumbers.addUniqueNumber(ongoingRecordingRequests);
44
+
45
+ var onMessage = function onMessage(_ref2) {
46
+ var data = _ref2.data;
47
+
48
+ if (data.id === id) {
49
+ ongoingRecordingRequests["delete"](id);
50
+ worker.removeEventListener('message', onMessage);
51
+
52
+ if (data.error === null) {
53
+ resolve(data.result.arrayBuffer);
54
+ } else {
55
+ reject(new Error(data.error.message));
56
+ }
57
+ }
58
+ };
59
+
60
+ worker.addEventListener('message', onMessage);
61
+ worker.postMessage({
62
+ id: id,
63
+ method: 'strip',
64
+ params: {
65
+ arrayBuffer: arrayBuffer
66
+ }
67
+ }, [arrayBuffer]);
68
+ });
69
+ };
70
+
71
+ return {
72
+ locate: locate,
73
+ strip: strip
74
+ };
75
+ };
76
+
77
+ exports.load = load;
78
+
79
+ Object.defineProperty(exports, '__esModule', { value: true });
80
+
81
+ })));
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "author": "Christoph Guttandin",
3
+ "bugs": {
4
+ "url": "https://github.com/chrisguttandin/metadata-detector-broker/issues"
5
+ },
6
+ "config": {
7
+ "commitizen": {
8
+ "path": "cz-conventional-changelog"
9
+ }
10
+ },
11
+ "dependencies": {
12
+ "@babel/runtime": "^7.15.4",
13
+ "fast-unique-numbers": "^6.0.6",
14
+ "metadata-detector-worker": "^4.0.38",
15
+ "tslib": "^2.3.1"
16
+ },
17
+ "description": "The broker which is used by the metadata-detector package.",
18
+ "devDependencies": {
19
+ "@babel/core": "^7.15.5",
20
+ "@babel/plugin-external-helpers": "^7.14.5",
21
+ "@babel/plugin-transform-runtime": "^7.15.0",
22
+ "@babel/preset-env": "^7.15.6",
23
+ "@commitlint/cli": "^13.1.0",
24
+ "@commitlint/config-angular": "^13.1.0",
25
+ "@rollup/plugin-babel": "^5.3.0",
26
+ "chai": "^4.3.4",
27
+ "commitizen": "^4.2.4",
28
+ "cz-conventional-changelog": "^3.3.0",
29
+ "eslint": "^7.32.0",
30
+ "eslint-config-holy-grail": "^50.1.8",
31
+ "grunt": "^1.4.1",
32
+ "grunt-cli": "^1.4.3",
33
+ "grunt-contrib-clean": "^2.0.0",
34
+ "grunt-sh": "^0.2.0",
35
+ "husky": "^7.0.2",
36
+ "karma": "^6.3.4",
37
+ "karma-chrome-launcher": "^3.1.0",
38
+ "karma-firefox-launcher": "^2.1.1",
39
+ "karma-mocha": "^2.0.1",
40
+ "karma-safari-launcher": "^1.0.0",
41
+ "karma-sauce-launcher": "^4.3.6",
42
+ "karma-sinon-chai": "^2.0.2",
43
+ "karma-webpack": "^5.0.0",
44
+ "load-grunt-config": "^4.0.1",
45
+ "mocha": "^9.1.1",
46
+ "prettier": "^2.4.1",
47
+ "pretty-quick": "^3.1.1",
48
+ "rollup": "^2.56.3",
49
+ "sinon": "^11.1.2",
50
+ "sinon-chai": "^3.7.0",
51
+ "ts-loader": "^9.2.5",
52
+ "tsconfig-holy-grail": "^11.1.12",
53
+ "tslint": "^6.1.3",
54
+ "tslint-config-holy-grail": "^53.2.25",
55
+ "typescript": "^4.4.3",
56
+ "webpack": "^5.53.0"
57
+ },
58
+ "files": [
59
+ "build/es2019/",
60
+ "build/es5/",
61
+ "src/"
62
+ ],
63
+ "homepage": "https://github.com/chrisguttandin/metadata-detector-broker",
64
+ "license": "MIT",
65
+ "main": "build/es5/bundle.js",
66
+ "module": "build/es2019/module.js",
67
+ "name": "metadata-detector-broker",
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "https://github.com/chrisguttandin/metadata-detector-broker.git"
71
+ },
72
+ "scripts": {
73
+ "prepare": "husky install",
74
+ "prepublishOnly": "grunt build",
75
+ "test": "grunt lint && grunt test"
76
+ },
77
+ "types": "build/es2019/module.d.ts",
78
+ "version": "3.0.38"
79
+ }
package/src/module.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { addUniqueNumber } from 'fast-unique-numbers';
2
+ import { ILocateRequest, ILocateResponse, IStripRequest, IStripResponse, IWorkerEvent } from 'metadata-detector-worker';
3
+
4
+ export const load = (url: string) => {
5
+ const worker = new Worker(url);
6
+
7
+ const ongoingRecordingRequests: Set<number> = new Set();
8
+
9
+ const locate = (arrayBuffer: ArrayBuffer): Promise<[number, number][]> => {
10
+ return new Promise((resolve, reject) => {
11
+ const id = addUniqueNumber(ongoingRecordingRequests);
12
+
13
+ const onMessage = ({ data }: IWorkerEvent) => {
14
+ if (data.id === id) {
15
+ ongoingRecordingRequests.delete(id);
16
+
17
+ worker.removeEventListener('message', onMessage);
18
+
19
+ if (data.error === null) {
20
+ resolve((<ILocateResponse>data).result.locations);
21
+ } else {
22
+ reject(new Error(data.error.message));
23
+ }
24
+ }
25
+ };
26
+
27
+ worker.addEventListener('message', onMessage);
28
+
29
+ worker.postMessage(<ILocateRequest>{ id, method: 'locate', params: { arrayBuffer } }, [arrayBuffer]);
30
+ });
31
+ };
32
+
33
+ const strip = (arrayBuffer: ArrayBuffer): Promise<ArrayBuffer> => {
34
+ return new Promise((resolve, reject) => {
35
+ const id = addUniqueNumber(ongoingRecordingRequests);
36
+
37
+ const onMessage = ({ data }: IWorkerEvent) => {
38
+ if (data.id === id) {
39
+ ongoingRecordingRequests.delete(id);
40
+
41
+ worker.removeEventListener('message', onMessage);
42
+
43
+ if (data.error === null) {
44
+ resolve((<IStripResponse>data).result.arrayBuffer);
45
+ } else {
46
+ reject(new Error(data.error.message));
47
+ }
48
+ }
49
+ };
50
+
51
+ worker.addEventListener('message', onMessage);
52
+
53
+ worker.postMessage(<IStripRequest>{ id, method: 'strip', params: { arrayBuffer } }, [arrayBuffer]);
54
+ });
55
+ };
56
+
57
+ return {
58
+ locate,
59
+ strip
60
+ };
61
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "compilerOptions": {
3
+ "isolatedModules": true
4
+ },
5
+ "extends": "tsconfig-holy-grail/src/tsconfig-browser"
6
+ }