ng-talkback 21.0.14 → 21.0.17
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/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod.re-export.json +1 -0
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib-prod/build-info._auto-generated_.js +14 -30
- package/lib-prod/env/env.angular-node-app.js +130 -71
- package/lib-prod/env/env.docs-webapp.js +130 -71
- package/lib-prod/env/env.electron-app.js +130 -71
- package/lib-prod/env/env.mobile-app.js +130 -71
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +130 -71
- package/lib-prod/env/env.vscode-plugin.js +130 -71
- package/lib-prod/env/index.js +6 -23
- package/lib-prod/es6.backend.js +5 -5
- package/lib-prod/features/error-rate.backend.js +23 -24
- package/lib-prod/features/latency.backend.js +26 -29
- package/lib-prod/index._auto-generated_.js +0 -6
- package/lib-prod/index.js +15 -31
- package/lib-prod/logger.backend.js +20 -21
- package/lib-prod/migrations/index.js +1 -19
- package/lib-prod/migrations/migrations_index._auto-generated_.js +0 -4
- package/lib-prod/options.backend.js +86 -82
- package/lib-prod/package.json +1 -1
- package/lib-prod/request-handler.backend.js +124 -138
- package/lib-prod/server.backend.js +78 -84
- package/lib-prod/summary.backend.js +20 -21
- package/lib-prod/talkback-factory.backend.js +17 -18
- package/lib-prod/tape-matcher.backend.js +87 -89
- package/lib-prod/tape-renderer.backend.js +88 -94
- package/lib-prod/tape-store.backend.js +86 -91
- package/lib-prod/tape.backend.js +69 -74
- package/lib-prod/types.backend.js +0 -3
- package/lib-prod/utils/content-encoding.backend.js +34 -35
- package/lib-prod/utils/headers.backend.js +13 -15
- package/lib-prod/utils/media-type.backend.js +45 -46
- package/lib-prod.re-export.json +1 -0
- package/package.json +3 -2
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod.re-export.json +1 -0
- package/lib-prod/build-info._auto-generated_.d.ts +0 -24
- package/lib-prod/build-info._auto-generated_.js.map +0 -1
- package/lib-prod/env/env.angular-node-app.d.ts +0 -64
- package/lib-prod/env/env.angular-node-app.js.map +0 -1
- package/lib-prod/env/env.docs-webapp.d.ts +0 -64
- package/lib-prod/env/env.docs-webapp.js.map +0 -1
- package/lib-prod/env/env.electron-app.d.ts +0 -64
- package/lib-prod/env/env.electron-app.js.map +0 -1
- package/lib-prod/env/env.mobile-app.d.ts +0 -64
- package/lib-prod/env/env.mobile-app.js.map +0 -1
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +0 -64
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +0 -1
- package/lib-prod/env/env.vscode-plugin.d.ts +0 -64
- package/lib-prod/env/env.vscode-plugin.js.map +0 -1
- package/lib-prod/env/index.d.ts +0 -6
- package/lib-prod/env/index.js.map +0 -1
- package/lib-prod/es6.backend.d.ts +0 -2
- package/lib-prod/es6.backend.js.map +0 -1
- package/lib-prod/features/error-rate.backend.d.ts +0 -9
- package/lib-prod/features/error-rate.backend.js.map +0 -1
- package/lib-prod/features/latency.backend.d.ts +0 -8
- package/lib-prod/features/latency.backend.js.map +0 -1
- package/lib-prod/index._auto-generated_.d.ts +0 -0
- package/lib-prod/index._auto-generated_.js.map +0 -1
- package/lib-prod/index.d.ts +0 -41
- package/lib-prod/index.js.map +0 -1
- package/lib-prod/logger.backend.d.ts +0 -7
- package/lib-prod/logger.backend.js.map +0 -1
- package/lib-prod/migrations/index.d.ts +0 -1
- package/lib-prod/migrations/index.js.map +0 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js.map +0 -1
- package/lib-prod/options.backend.d.ts +0 -52
- package/lib-prod/options.backend.js.map +0 -1
- package/lib-prod/request-handler.backend.d.ts +0 -13
- package/lib-prod/request-handler.backend.js.map +0 -1
- package/lib-prod/server.backend.d.ts +0 -17
- package/lib-prod/server.backend.js.map +0 -1
- package/lib-prod/summary.backend.d.ts +0 -8
- package/lib-prod/summary.backend.js.map +0 -1
- package/lib-prod/talkback-factory.backend.d.ts +0 -7
- package/lib-prod/talkback-factory.backend.js.map +0 -1
- package/lib-prod/tape-matcher.backend.d.ts +0 -12
- package/lib-prod/tape-matcher.backend.js.map +0 -1
- package/lib-prod/tape-renderer.backend.d.ts +0 -24
- package/lib-prod/tape-renderer.backend.js.map +0 -1
- package/lib-prod/tape-store.backend.d.ts +0 -16
- package/lib-prod/tape-store.backend.js.map +0 -1
- package/lib-prod/tape.backend.d.ts +0 -19
- package/lib-prod/tape.backend.js.map +0 -1
- package/lib-prod/types.backend.d.ts +0 -43
- package/lib-prod/types.backend.js.map +0 -1
- package/lib-prod/utils/content-encoding.backend.d.ts +0 -10
- package/lib-prod/utils/content-encoding.backend.js.map +0 -1
- package/lib-prod/utils/headers.backend.d.ts +0 -4
- package/lib-prod/utils/headers.backend.js.map +0 -1
- package/lib-prod/utils/media-type.backend.d.ts +0 -10
- package/lib-prod/utils/media-type.backend.js.map +0 -1
|
@@ -1,99 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const tape_matcher_backend_1 = require("./tape-matcher.backend");
|
|
6
|
-
const tape_renderer_backend_1 = require("./tape-renderer.backend");
|
|
1
|
+
import { fse, path, json5, mkdirp } from "tnp-core/lib-prod";
|
|
2
|
+
import Tape from "./tape.backend";
|
|
3
|
+
import TapeMatcher from "./tape-matcher.backend";
|
|
4
|
+
import TapeRenderer from "./tape-renderer.backend";
|
|
7
5
|
class TapeStore {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
console.log(`Error reading tape ${fullPath}`, e.message);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.loadTapesAtDir(fullPath + "/");
|
|
41
|
-
}
|
|
6
|
+
path;
|
|
7
|
+
options;
|
|
8
|
+
tapes;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.path = path.normalize(options.path + "/");
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.tapes = [];
|
|
13
|
+
}
|
|
14
|
+
async load() {
|
|
15
|
+
mkdirp.sync(this.path);
|
|
16
|
+
await this.loadTapesAtDir(this.path);
|
|
17
|
+
console.log(`Loaded ${this.tapes.length} tapes`);
|
|
18
|
+
}
|
|
19
|
+
async loadTapesAtDir(directory) {
|
|
20
|
+
const items = fse.readdirSync(directory);
|
|
21
|
+
for (let i = 0; i < items.length; i++) {
|
|
22
|
+
const filename = items[i];
|
|
23
|
+
const fullPath = `${directory}${filename}`;
|
|
24
|
+
const stat = fse.statSync(fullPath);
|
|
25
|
+
if (!stat.isDirectory()) {
|
|
26
|
+
try {
|
|
27
|
+
const data = fse.readFileSync(fullPath, "utf8");
|
|
28
|
+
const raw = json5.parse(data);
|
|
29
|
+
const tape = await Tape.fromStore(raw, this.options);
|
|
30
|
+
tape.path = filename;
|
|
31
|
+
this.tapes.push(tape);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.log(`Error reading tape ${fullPath}`, e.message);
|
|
42
34
|
}
|
|
35
|
+
} else {
|
|
36
|
+
this.loadTapesAtDir(fullPath + "/");
|
|
37
|
+
}
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
}
|
|
40
|
+
find(newTape) {
|
|
41
|
+
const foundTape = this.tapes.find((t) => {
|
|
42
|
+
this.options.logger.debug(`Comparing against tape ${t.path}`);
|
|
43
|
+
return new TapeMatcher(t, this.options).sameAs(newTape);
|
|
44
|
+
});
|
|
45
|
+
if (foundTape) {
|
|
46
|
+
foundTape.used = true;
|
|
47
|
+
this.options.logger.log(`Found matching tape for ${newTape.req.url} at ${foundTape.path}`);
|
|
48
|
+
return foundTape;
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
tape.path = lib_prod_1.path.relative(this.path, fullFilename);
|
|
68
|
-
}
|
|
69
|
-
this.options.logger.log(`Saving request ${tape.req.url} at ${tape.path}`);
|
|
70
|
-
const tapeRenderer = new tape_renderer_backend_1.default(tape);
|
|
71
|
-
const toSave = await tapeRenderer.render();
|
|
72
|
-
lib_prod_1.fse.writeFileSync(fullFilename, lib_prod_1.json5.stringify(toSave, null, 4));
|
|
50
|
+
}
|
|
51
|
+
async save(tape) {
|
|
52
|
+
tape.new = true;
|
|
53
|
+
tape.used = true;
|
|
54
|
+
const tapePath = tape.path;
|
|
55
|
+
let fullFilename;
|
|
56
|
+
if (tapePath) {
|
|
57
|
+
fullFilename = path.join(this.path, tapePath);
|
|
58
|
+
} else {
|
|
59
|
+
this.tapes.push(tape);
|
|
60
|
+
fullFilename = this.createTapePath(tape);
|
|
61
|
+
tape.path = path.relative(this.path, fullFilename);
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
this.options.logger.log(`Saving request ${tape.req.url} at ${tape.path}`);
|
|
64
|
+
const tapeRenderer = new TapeRenderer(tape);
|
|
65
|
+
const toSave = await tapeRenderer.render();
|
|
66
|
+
fse.writeFileSync(fullFilename, json5.stringify(toSave, null, 4));
|
|
67
|
+
}
|
|
68
|
+
currentTapeId() {
|
|
69
|
+
return this.tapes.length;
|
|
70
|
+
}
|
|
71
|
+
hasTapeBeenUsed(tapeName) {
|
|
72
|
+
return this.tapes.some((t) => t.used && t.path === tapeName);
|
|
73
|
+
}
|
|
74
|
+
resetTapeUsage() {
|
|
75
|
+
return this.tapes.forEach((t) => t.used = false);
|
|
76
|
+
}
|
|
77
|
+
createTapePath(tape) {
|
|
78
|
+
const currentTapeId = this.currentTapeId();
|
|
79
|
+
let tapePath = `unnamed-${currentTapeId}.json5`;
|
|
80
|
+
if (this.options.tapeNameGenerator) {
|
|
81
|
+
tapePath = this.options.tapeNameGenerator(currentTapeId, tape);
|
|
76
82
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
resetTapeUsage() {
|
|
81
|
-
return this.tapes.forEach(t => t.used = false);
|
|
82
|
-
}
|
|
83
|
-
createTapePath(tape) {
|
|
84
|
-
const currentTapeId = this.currentTapeId();
|
|
85
|
-
let tapePath = `unnamed-${currentTapeId}.json5`;
|
|
86
|
-
if (this.options.tapeNameGenerator) {
|
|
87
|
-
tapePath = this.options.tapeNameGenerator(currentTapeId, tape);
|
|
88
|
-
}
|
|
89
|
-
let result = lib_prod_1.path.normalize(lib_prod_1.path.join(this.options.path, tapePath));
|
|
90
|
-
if (!result.endsWith(".json5")) {
|
|
91
|
-
result = `${result}.json5`;
|
|
92
|
-
}
|
|
93
|
-
const dir = lib_prod_1.path.dirname(result);
|
|
94
|
-
lib_prod_1.mkdirp.sync(dir);
|
|
95
|
-
return result;
|
|
83
|
+
let result = path.normalize(path.join(this.options.path, tapePath));
|
|
84
|
+
if (!result.endsWith(".json5")) {
|
|
85
|
+
result = `${result}.json5`;
|
|
96
86
|
}
|
|
87
|
+
const dir = path.dirname(result);
|
|
88
|
+
mkdirp.sync(dir);
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
97
91
|
}
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
export {
|
|
93
|
+
TapeStore as default
|
|
94
|
+
};
|
package/lib-prod/tape.backend.js
CHANGED
|
@@ -1,80 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const content_encoding_backend_1 = require("./utils/content-encoding.backend");
|
|
7
|
-
const URL = require("url");
|
|
8
|
-
const querystring = require("querystring");
|
|
9
|
-
// const URL = require('url')
|
|
10
|
-
// const querystring = require('querystring')
|
|
1
|
+
import MediaType from "./utils/media-type.backend";
|
|
2
|
+
import TapeRenderer from "./tape-renderer.backend";
|
|
3
|
+
import ContentEncoding from "./utils/content-encoding.backend";
|
|
4
|
+
import * as URL from "url";
|
|
5
|
+
import * as querystring from "querystring";
|
|
11
6
|
class Tape {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
req;
|
|
8
|
+
res;
|
|
9
|
+
options;
|
|
10
|
+
queryParamsToIgnore;
|
|
11
|
+
meta;
|
|
12
|
+
path;
|
|
13
|
+
new = false;
|
|
14
|
+
used = false;
|
|
15
|
+
constructor(req, options) {
|
|
16
|
+
this.req = { ...req };
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.normalizeBody();
|
|
19
|
+
this.cleanupHeaders();
|
|
20
|
+
this.queryParamsToIgnore = this.options.ignoreQueryParams;
|
|
21
|
+
this.cleanupQueryParams();
|
|
22
|
+
this.meta = {
|
|
23
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
24
|
+
host: this.options.host
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
static async fromStore(raw, options) {
|
|
28
|
+
return TapeRenderer.fromStore(raw, options);
|
|
29
|
+
}
|
|
30
|
+
cleanupHeaders() {
|
|
31
|
+
const newHeaders = { ...this.req.headers };
|
|
32
|
+
this.options.ignoreHeaders.forEach((h) => delete newHeaders[h]);
|
|
33
|
+
this.req = {
|
|
34
|
+
...this.req,
|
|
35
|
+
headers: newHeaders
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
cleanupQueryParams() {
|
|
39
|
+
if (this.queryParamsToIgnore.length === 0) {
|
|
40
|
+
return;
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const url = URL.parse(this.req.url, true);
|
|
43
|
+
if (!url.search) {
|
|
44
|
+
return;
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
const query = { ...url.query };
|
|
47
|
+
this.queryParamsToIgnore.forEach((q) => delete query[q]);
|
|
48
|
+
const newQuery = querystring.stringify(query);
|
|
49
|
+
if (newQuery) {
|
|
50
|
+
url.query = query;
|
|
51
|
+
url.search = "?" + newQuery;
|
|
52
|
+
} else {
|
|
53
|
+
url.query = null;
|
|
54
|
+
url.search = null;
|
|
43
55
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
const query = { ...url.query };
|
|
53
|
-
this.queryParamsToIgnore.forEach(q => delete query[q]);
|
|
54
|
-
const newQuery = querystring.stringify(query);
|
|
55
|
-
if (newQuery) {
|
|
56
|
-
url.query = query;
|
|
57
|
-
url.search = "?" + newQuery;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
url.query = null;
|
|
61
|
-
url.search = null;
|
|
62
|
-
}
|
|
63
|
-
this.req.url = URL.format(url);
|
|
64
|
-
}
|
|
65
|
-
normalizeBody() {
|
|
66
|
-
const mediaType = new media_type_backend_1.default(this.req);
|
|
67
|
-
const contentEncoding = new content_encoding_backend_1.default(this.req);
|
|
68
|
-
if (contentEncoding.isUncompressed() && mediaType.isJSON() && this.req.body.length > 0) {
|
|
69
|
-
this.req.body = Buffer.from(JSON.stringify(JSON.parse(this.req.body.toString()), null, 2));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async clone() {
|
|
73
|
-
const tapeRenderer = new tape_renderer_backend_1.default(this);
|
|
74
|
-
const raw = await tapeRenderer.render();
|
|
75
|
-
return Tape.fromStore(raw, this.options);
|
|
56
|
+
this.req.url = URL.format(url);
|
|
57
|
+
}
|
|
58
|
+
normalizeBody() {
|
|
59
|
+
const mediaType = new MediaType(this.req);
|
|
60
|
+
const contentEncoding = new ContentEncoding(this.req);
|
|
61
|
+
if (contentEncoding.isUncompressed() && mediaType.isJSON() && this.req.body.length > 0) {
|
|
62
|
+
this.req.body = Buffer.from(JSON.stringify(JSON.parse(this.req.body.toString()), null, 2));
|
|
76
63
|
}
|
|
64
|
+
}
|
|
65
|
+
async clone() {
|
|
66
|
+
const tapeRenderer = new TapeRenderer(this);
|
|
67
|
+
const raw = await tapeRenderer.render();
|
|
68
|
+
return Tape.fromStore(raw, this.options);
|
|
69
|
+
}
|
|
77
70
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
var tape_backend_default = Tape;
|
|
72
|
+
export {
|
|
73
|
+
Tape,
|
|
74
|
+
tape_backend_default as default
|
|
75
|
+
};
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const zlib = require('zlib');
|
|
4
|
-
const headers_backend_1 = require("./headers.backend");
|
|
1
|
+
const zlib = require("zlib");
|
|
2
|
+
import Headers from "./headers.backend";
|
|
5
3
|
const ALGORITHMS = {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
gzip: { compress: zlib.gzipSync, uncompress: zlib.gunzipSync },
|
|
5
|
+
deflate: { compress: zlib.deflateSync, uncompress: zlib.inflateSync }
|
|
8
6
|
};
|
|
9
7
|
class ContentEncoding {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
reqRes;
|
|
9
|
+
constructor(reqRes) {
|
|
10
|
+
this.reqRes = reqRes;
|
|
11
|
+
}
|
|
12
|
+
isUncompressed() {
|
|
13
|
+
const contentEncoding = this.contentEncoding();
|
|
14
|
+
return !contentEncoding || contentEncoding === "identity";
|
|
15
|
+
}
|
|
16
|
+
supportedAlgorithm() {
|
|
17
|
+
const contentEncoding = this.contentEncoding();
|
|
18
|
+
return Object.keys(ALGORITHMS).includes(contentEncoding);
|
|
19
|
+
}
|
|
20
|
+
contentEncoding() {
|
|
21
|
+
return Headers.read(this.reqRes.headers, "content-encoding");
|
|
22
|
+
}
|
|
23
|
+
async uncompressedBody(body) {
|
|
24
|
+
const contentEncoding = this.contentEncoding();
|
|
25
|
+
if (!this.supportedAlgorithm()) {
|
|
26
|
+
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
13
27
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
supportedAlgorithm() {
|
|
19
|
-
|
|
20
|
-
return Object.keys(ALGORITHMS).includes(contentEncoding);
|
|
21
|
-
}
|
|
22
|
-
contentEncoding() {
|
|
23
|
-
return headers_backend_1.default.read(this.reqRes.headers, "content-encoding");
|
|
24
|
-
}
|
|
25
|
-
async uncompressedBody(body) {
|
|
26
|
-
const contentEncoding = this.contentEncoding();
|
|
27
|
-
if (!this.supportedAlgorithm()) {
|
|
28
|
-
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
29
|
-
}
|
|
30
|
-
return ALGORITHMS[contentEncoding].uncompress(body);
|
|
31
|
-
}
|
|
32
|
-
async compressedBody(body) {
|
|
33
|
-
const contentEncoding = this.contentEncoding();
|
|
34
|
-
if (!this.supportedAlgorithm()) {
|
|
35
|
-
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
36
|
-
}
|
|
37
|
-
return ALGORITHMS[contentEncoding].compress(body);
|
|
28
|
+
return ALGORITHMS[contentEncoding].uncompress(body);
|
|
29
|
+
}
|
|
30
|
+
async compressedBody(body) {
|
|
31
|
+
const contentEncoding = this.contentEncoding();
|
|
32
|
+
if (!this.supportedAlgorithm()) {
|
|
33
|
+
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
38
34
|
}
|
|
35
|
+
return ALGORITHMS[contentEncoding].compress(body);
|
|
36
|
+
}
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
export {
|
|
39
|
+
ContentEncoding as default
|
|
40
|
+
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
class Headers {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
static write(headers, headerName, value, type) {
|
|
14
|
-
headers[headerName] = type === "req" ? value : [value];
|
|
2
|
+
static read(headers, headerName) {
|
|
3
|
+
const value = headers[headerName];
|
|
4
|
+
if (Array.isArray(value)) {
|
|
5
|
+
return value[0];
|
|
6
|
+
} else {
|
|
7
|
+
return value;
|
|
15
8
|
}
|
|
9
|
+
}
|
|
10
|
+
static write(headers, headerName, value, type) {
|
|
11
|
+
headers[headerName] = type === "req" ? value : [value];
|
|
12
|
+
}
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export {
|
|
15
|
+
Headers as default
|
|
16
|
+
};
|
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const lib_prod_1 = require("tnp-core/lib-prod");
|
|
5
|
-
const headers_backend_1 = require("./headers.backend");
|
|
6
|
-
const contentTypeParser = require('content-type');
|
|
1
|
+
import { ___NS__merge } from "tnp-core/lib-prod";
|
|
2
|
+
import Headers from "./headers.backend";
|
|
3
|
+
const contentTypeParser = require("content-type");
|
|
7
4
|
const equals = (to) => (contentType) => to == contentType;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const jsonTypes = [
|
|
6
|
+
equals("application/json"),
|
|
7
|
+
(contentType) => contentType.startsWith("application/") && contentType.endsWith("+json")
|
|
11
8
|
];
|
|
12
9
|
const humanReadableContentTypes = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
equals("application/javascript"),
|
|
11
|
+
equals("text/css"),
|
|
12
|
+
equals("text/html"),
|
|
13
|
+
equals("text/javascript"),
|
|
14
|
+
equals("text/plain"),
|
|
15
|
+
...jsonTypes
|
|
19
16
|
];
|
|
20
17
|
class MediaType {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
htmlReqRes;
|
|
19
|
+
constructor(htmlReqRes) {
|
|
20
|
+
this.htmlReqRes = htmlReqRes;
|
|
21
|
+
}
|
|
22
|
+
isHumanReadable() {
|
|
23
|
+
const contentType = this.contentType();
|
|
24
|
+
if (!contentType) {
|
|
25
|
+
return false;
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
return humanReadableContentTypes.some((comparator) => comparator(contentType));
|
|
28
|
+
}
|
|
29
|
+
isJSON() {
|
|
30
|
+
const contentType = this.contentType();
|
|
31
|
+
if (!contentType) {
|
|
32
|
+
return false;
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
contentType() {
|
|
41
|
-
const contentTypeHeader = headers_backend_1.default.read(this.headers(), "content-type");
|
|
42
|
-
if (!contentTypeHeader) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const parsedContentType = contentTypeParser.parse(contentTypeHeader);
|
|
46
|
-
return parsedContentType.type;
|
|
47
|
-
}
|
|
48
|
-
headers() {
|
|
49
|
-
return lib_prod_1._.merge(this.htmlReqRes.headers, {
|
|
50
|
-
'content-type': 'application/json'
|
|
51
|
-
});
|
|
34
|
+
const result = jsonTypes.some((comparator) => comparator("application/json"));
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
contentType() {
|
|
38
|
+
const contentTypeHeader = Headers.read(this.headers(), "content-type");
|
|
39
|
+
if (!contentTypeHeader) {
|
|
40
|
+
return null;
|
|
52
41
|
}
|
|
42
|
+
const parsedContentType = contentTypeParser.parse(contentTypeHeader);
|
|
43
|
+
return parsedContentType.type;
|
|
44
|
+
}
|
|
45
|
+
headers() {
|
|
46
|
+
return ___NS__merge(this.htmlReqRes.headers, {
|
|
47
|
+
"content-type": "application/json"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
export {
|
|
52
|
+
MediaType as default,
|
|
53
|
+
jsonTypes
|
|
54
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-talkback",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.17",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "node tools/build.js",
|
|
6
6
|
"ci": "yarn ts-check && yarn test && yarn build && USE_DIST=1 yarn test",
|
|
@@ -49,5 +49,6 @@
|
|
|
49
49
|
"url": "https://github.com/darekf77/ng-talkback"
|
|
50
50
|
},
|
|
51
51
|
"bin": {},
|
|
52
|
-
"peerDependencies": {}
|
|
52
|
+
"peerDependencies": {},
|
|
53
|
+
"devDependencies": {}
|
|
53
54
|
}
|
package/websql/package.json
CHANGED
package/websql-prod/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Autogenerated by current cli tool
|
|
3
|
-
*/
|
|
4
|
-
export declare const BUILD_FRAMEWORK_CLI_NAME = "tnp";
|
|
5
|
-
/**
|
|
6
|
-
* This value can be change in taon.jsonc (appId)
|
|
7
|
-
*/
|
|
8
|
-
export declare const APP_ID = "com.domain.example.ng-talkback";
|
|
9
|
-
/**
|
|
10
|
-
* Autogenerated by current cli tool
|
|
11
|
-
*/
|
|
12
|
-
export declare const BUILD_BASE_HREF = "";
|
|
13
|
-
/**
|
|
14
|
-
* This value can be change in taon.jsonc (overrideNpmName)
|
|
15
|
-
*/
|
|
16
|
-
export declare const PROJECT_NPM_NAME = "ng-talkback";
|
|
17
|
-
/**
|
|
18
|
-
* Taon version from you project taon.json
|
|
19
|
-
*/
|
|
20
|
-
export declare const CURRENT_PACKAGE_TAON_VERSION = "v21";
|
|
21
|
-
/**
|
|
22
|
-
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
23
|
-
*/
|
|
24
|
-
export declare const CURRENT_PACKAGE_VERSION = "21.0.14";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-info._auto-generated_.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC;;GAEG;AACU,QAAA,wBAAwB,GAAG,KAAK,CAAC;AAC9C;;GAEG;AACU,QAAA,MAAM,GAAG,gCAAgC,CAAC;AACvD;;GAEG;AACU,QAAA,eAAe,GAAG,EAAE,CAAC;AAClC;;GAEG;AACU,QAAA,gBAAgB,GAAG,aAAa,CAAC;AAC9C;;GAEG;AACU,QAAA,4BAA4B,GAAG,KAAK,CAAC;AAClD;;GAEG;AACU,QAAA,uBAAuB,GAAG,SAAS,CAAC;AACjD,yCAAyC"}
|