@basemaps/lambda-tiler 6.33.0 → 6.34.0
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/CHANGELOG.md +19 -0
- package/build/__tests__/xyz.util.d.ts +1 -1
- package/build/__tests__/xyz.util.d.ts.map +1 -1
- package/build/__tests__/xyz.util.js +2 -2
- package/build/__tests__/xyz.util.js.map +1 -1
- package/build/arcgis/__tests__/arcgis.style.json.test.d.ts +2 -0
- package/build/arcgis/__tests__/arcgis.style.json.test.d.ts.map +1 -0
- package/build/arcgis/__tests__/arcgis.style.json.test.js +128 -0
- package/build/arcgis/__tests__/arcgis.style.json.test.js.map +1 -0
- package/build/arcgis/__tests__/vector.tiler.server.test.d.ts +2 -0
- package/build/arcgis/__tests__/vector.tiler.server.test.d.ts.map +1 -0
- package/build/arcgis/__tests__/vector.tiler.server.test.js +47 -0
- package/build/arcgis/__tests__/vector.tiler.server.test.js.map +1 -0
- package/build/arcgis/arcgis.info.d.ts +3 -0
- package/build/arcgis/arcgis.info.d.ts.map +1 -0
- package/build/arcgis/arcgis.info.js +25 -0
- package/build/arcgis/arcgis.info.js.map +1 -0
- package/build/arcgis/arcgis.style.json.d.ts +9 -0
- package/build/arcgis/arcgis.style.json.d.ts.map +1 -0
- package/build/arcgis/arcgis.style.json.js +73 -0
- package/build/arcgis/arcgis.style.json.js.map +1 -0
- package/build/arcgis/vector.tile.server.d.ts +8 -0
- package/build/arcgis/vector.tile.server.d.ts.map +1 -0
- package/build/arcgis/vector.tile.server.js +71 -0
- package/build/arcgis/vector.tile.server.js.map +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +14 -2
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/fonts.test.js +14 -26
- package/build/routes/__tests__/fonts.test.js.map +1 -1
- package/build/routes/__tests__/sprites.test.js +7 -1
- package/build/routes/__tests__/sprites.test.js.map +1 -1
- package/build/routes/fonts.d.ts +0 -2
- package/build/routes/fonts.d.ts.map +1 -1
- package/build/routes/fonts.js +3 -66
- package/build/routes/fonts.js.map +1 -1
- package/build/routes/sprites.d.ts.map +1 -1
- package/build/routes/sprites.js +3 -29
- package/build/routes/sprites.js.map +1 -1
- package/build/util/assets.provider.d.ts +27 -0
- package/build/util/assets.provider.d.ts.map +1 -0
- package/build/util/assets.provider.js +56 -0
- package/build/util/assets.provider.js.map +1 -0
- package/build/util/config.cache.d.ts +16 -0
- package/build/util/config.cache.d.ts.map +1 -0
- package/build/util/config.cache.js +41 -0
- package/build/util/config.cache.js.map +1 -0
- package/build/util/response.d.ts +2 -1
- package/build/util/response.d.ts.map +1 -1
- package/build/util/response.js +1 -0
- package/build/util/response.js.map +1 -1
- package/dist/index.js +53 -53
- package/dist/node_modules/.package-lock.json +4 -4
- package/dist/node_modules/node-abi/abi_registry.json +8 -1
- package/dist/node_modules/node-abi/package.json +1 -1
- package/dist/package-lock.json +8 -8
- package/dist/package.json +1 -1
- package/package.json +4 -4
- package/src/__tests__/xyz.util.ts +7 -2
- package/src/arcgis/__tests__/arcgis.style.json.test.ts +153 -0
- package/src/arcgis/__tests__/vector.tiler.server.test.ts +61 -0
- package/src/arcgis/arcgis.info.ts +26 -0
- package/src/arcgis/arcgis.style.json.ts +81 -0
- package/src/arcgis/vector.tile.server.ts +78 -0
- package/src/index.ts +16 -2
- package/src/routes/__tests__/fonts.test.ts +14 -29
- package/src/routes/__tests__/sprites.test.ts +7 -2
- package/src/routes/fonts.ts +4 -64
- package/src/routes/sprites.ts +4 -27
- package/src/util/assets.provider.ts +67 -0
- package/src/util/config.cache.ts +44 -0
- package/src/util/response.ts +3 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,53 +2,36 @@ import { Env } from '@basemaps/shared';
|
|
|
2
2
|
import { fsa } from '@chunkd/fs';
|
|
3
3
|
import o from 'ospec';
|
|
4
4
|
import { handler } from '../../index.js';
|
|
5
|
+
import { assetProvider } from '../../util/assets.provider.js';
|
|
5
6
|
import { mockRequest } from '../../__tests__/xyz.util.js';
|
|
6
|
-
import { fontList
|
|
7
|
+
import { fontList } from '../fonts.js';
|
|
7
8
|
import { FsMemory } from './memory.fs.js';
|
|
8
9
|
o.spec('/v1/fonts', () => {
|
|
9
10
|
const memory = new FsMemory();
|
|
10
11
|
o.before(() => {
|
|
11
12
|
fsa.register('memory://', memory);
|
|
12
13
|
});
|
|
14
|
+
const assetLocation = process.env[Env.AssetLocation];
|
|
13
15
|
o.beforeEach(() => {
|
|
14
16
|
process.env[Env.AssetLocation] = 'memory://';
|
|
17
|
+
assetProvider.set('memory://');
|
|
15
18
|
});
|
|
16
19
|
o.afterEach(() => {
|
|
17
|
-
|
|
20
|
+
assetProvider.set(assetLocation);
|
|
18
21
|
memory.files.clear();
|
|
19
22
|
});
|
|
20
|
-
o('should
|
|
21
|
-
await Promise.all([
|
|
22
|
-
fsa.write('memory://fonts/Roboto Thin/0-255.pbf', Buffer.from('')),
|
|
23
|
-
fsa.write('memory://fonts/Roboto Thin/256-512.pbf', Buffer.from('')),
|
|
24
|
-
fsa.write('memory://fonts/Roboto Black/0-255.pbf', Buffer.from('')),
|
|
25
|
-
]);
|
|
26
|
-
const fonts = await getFonts('memory://fonts/');
|
|
27
|
-
o(fonts).deepEquals(['Roboto Black', 'Roboto Thin']);
|
|
28
|
-
});
|
|
29
|
-
o('should return empty list if no fonts found', async () => {
|
|
30
|
-
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
31
|
-
o(res.status).equals(200);
|
|
32
|
-
o(res.body).equals('[]');
|
|
33
|
-
o(res.header('etag')).notEquals(undefined);
|
|
34
|
-
o(res.header('cache-control')).equals('public, max-age=604800, stale-while-revalidate=86400');
|
|
35
|
-
});
|
|
36
|
-
o('should return 404 if no assets defined', async () => {
|
|
37
|
-
delete process.env[Env.AssetLocation];
|
|
23
|
+
o('should return 404 if no font found', async () => {
|
|
38
24
|
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
39
25
|
o(res.status).equals(404);
|
|
40
26
|
});
|
|
41
27
|
o('should return a list of fonts found', async () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
fsa.write('memory://fonts/Roboto Thin/256-512.pbf', Buffer.from('')),
|
|
45
|
-
fsa.write('memory://fonts/Roboto Black/0-255.pbf', Buffer.from('')),
|
|
46
|
-
]);
|
|
28
|
+
var _a;
|
|
29
|
+
await fsa.write('memory://fonts.json', Buffer.from(JSON.stringify(['Roboto Black', 'Roboto Thin'])));
|
|
47
30
|
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
48
31
|
o(res.status).equals(200);
|
|
49
32
|
o(res.header('content-type')).equals('application/json');
|
|
50
33
|
o(res.header('content-encoding')).equals(undefined);
|
|
51
|
-
o(res.
|
|
34
|
+
o((_a = res._body) === null || _a === void 0 ? void 0 : _a.toString()).equals(JSON.stringify(['Roboto Black', 'Roboto Thin']));
|
|
52
35
|
});
|
|
53
36
|
o('should get the correct font', async () => {
|
|
54
37
|
await fsa.write('memory://fonts/Roboto Thin/0-255.pbf', Buffer.from(''));
|
|
@@ -70,5 +53,10 @@ o.spec('/v1/fonts', () => {
|
|
|
70
53
|
o(res255.header('etag')).notEquals(undefined);
|
|
71
54
|
o(res255.header('cache-control')).equals('public, max-age=604800, stale-while-revalidate=86400');
|
|
72
55
|
});
|
|
56
|
+
o('should return 404 if no asset location set', async () => {
|
|
57
|
+
assetProvider.set(undefined);
|
|
58
|
+
const res = await fontList(mockRequest('/v1/fonts.json'));
|
|
59
|
+
o(res.status).equals(404);
|
|
60
|
+
});
|
|
73
61
|
});
|
|
74
62
|
//# sourceMappingURL=fonts.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.test.js","sourceRoot":"","sources":["../../../src/routes/__tests__/fonts.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,CAAC,MAAM,OAAO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,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,sDAAsD,CAAC,CAAC;IACnG,CAAC,CAAC,CAAC;IAEH,CAAC,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QACzD,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { Env } from '@basemaps/shared';
|
|
2
2
|
import { fsa } from '@chunkd/fs';
|
|
3
3
|
import o from 'ospec';
|
|
4
|
+
import { createSandbox } from 'sinon';
|
|
4
5
|
import { gunzipSync, gzipSync } from 'zlib';
|
|
5
6
|
import { handler } from '../../index.js';
|
|
7
|
+
import { assetProvider } from '../../util/assets.provider.js';
|
|
6
8
|
import { mockRequest } from '../../__tests__/xyz.util.js';
|
|
7
9
|
import { FsMemory } from './memory.fs.js';
|
|
8
10
|
o.spec('/v1/sprites', () => {
|
|
9
11
|
const memory = new FsMemory();
|
|
12
|
+
const sandbox = createSandbox();
|
|
10
13
|
o.before(() => {
|
|
11
14
|
fsa.register('memory://', memory);
|
|
12
15
|
});
|
|
16
|
+
const assetLocation = process.env[Env.AssetLocation];
|
|
13
17
|
o.beforeEach(() => {
|
|
14
18
|
process.env[Env.AssetLocation] = 'memory://';
|
|
19
|
+
assetProvider.set('memory://');
|
|
15
20
|
});
|
|
16
21
|
o.afterEach(() => {
|
|
17
|
-
|
|
22
|
+
assetProvider.set(assetLocation);
|
|
18
23
|
memory.files.clear();
|
|
24
|
+
sandbox.restore();
|
|
19
25
|
});
|
|
20
26
|
o('should return 404 if no assets defined', async () => {
|
|
21
27
|
delete process.env[Env.AssetLocation];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprites.test.js","sourceRoot":"","sources":["../../../src/routes/__tests__/sprites.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,CAAC,MAAM,OAAO,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC9B,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE;QACZ,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"sprites.test.js","sourceRoot":"","sources":["../../../src/routes/__tests__/sprites.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,CAAC,MAAM,OAAO,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE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c,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACzD,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,sDAAsD,CAAC,CAAC;QAC9F,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACnG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/build/routes/fonts.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ interface FontGet {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
export declare function fontGet(req: LambdaHttpRequest<FontGet>): Promise<LambdaHttpResponse>;
|
|
9
|
-
/** Get the unique name of folders is a path that contain .pbf files */
|
|
10
|
-
export declare function getFonts(fontPath: string): Promise<string[]>;
|
|
11
9
|
export declare function fontList(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
|
|
12
10
|
export {};
|
|
13
11
|
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/routes/fonts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/routes/fonts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIvE,UAAU,OAAO;IACf,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG1F;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAElF"}
|
package/build/routes/fonts.js
CHANGED
|
@@ -1,73 +1,10 @@
|
|
|
1
|
-
import { Env } from '@basemaps/shared';
|
|
2
|
-
import { fsa } from '@chunkd/fs';
|
|
3
|
-
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
4
1
|
import path from 'path';
|
|
5
|
-
import {
|
|
6
|
-
import { Etag } from '../util/etag.js';
|
|
7
|
-
import { NotFound, NotModified } from '../util/response.js';
|
|
2
|
+
import { assetProvider } from '../util/assets.provider.js';
|
|
8
3
|
export async function fontGet(req) {
|
|
9
|
-
const assetLocation = Env.get(Env.AssetLocation);
|
|
10
|
-
if (assetLocation == null)
|
|
11
|
-
return NotFound();
|
|
12
4
|
const targetFile = path.join('fonts', req.params.fontStack, req.params.range) + '.pbf';
|
|
13
|
-
|
|
14
|
-
return serveFromCotar(req, assetLocation, targetFile, 'application/x-protobuf');
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
const filePath = fsa.join(assetLocation, targetFile);
|
|
18
|
-
const buf = await fsa.read(filePath);
|
|
19
|
-
const cacheKey = Etag.key(buf);
|
|
20
|
-
if (Etag.isNotModified(req, cacheKey))
|
|
21
|
-
return NotModified();
|
|
22
|
-
const response = LambdaHttpResponse.ok().buffer(buf, 'application/x-protobuf');
|
|
23
|
-
response.header(HttpHeader.ETag, cacheKey);
|
|
24
|
-
response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
|
|
25
|
-
if (isGzip(buf))
|
|
26
|
-
response.header(HttpHeader.ContentEncoding, 'gzip');
|
|
27
|
-
return response;
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
if (e.code === 404)
|
|
31
|
-
return NotFound();
|
|
32
|
-
throw e;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/** Get the unique name of folders is a path that contain .pbf files */
|
|
36
|
-
export async function getFonts(fontPath) {
|
|
37
|
-
const fonts = new Set();
|
|
38
|
-
// TODO use {recursive: false}
|
|
39
|
-
for await (const font of fsa.list(fontPath)) {
|
|
40
|
-
if (!font.endsWith('.pbf'))
|
|
41
|
-
continue;
|
|
42
|
-
const dirName = path.basename(path.dirname(font)); // TODO this only works for /a/b.pbf and not /a/b/c.pbf
|
|
43
|
-
if (dirName.includes('/'))
|
|
44
|
-
continue;
|
|
45
|
-
fonts.add(dirName);
|
|
46
|
-
}
|
|
47
|
-
// Ensure the fonts are alphabetical
|
|
48
|
-
return [...fonts].sort();
|
|
5
|
+
return assetProvider.serve(req, targetFile, 'application/x-protobuf');
|
|
49
6
|
}
|
|
50
7
|
export async function fontList(req) {
|
|
51
|
-
|
|
52
|
-
if (assetLocation == null)
|
|
53
|
-
return NotFound();
|
|
54
|
-
if (assetLocation.endsWith('.tar.co'))
|
|
55
|
-
return serveFromCotar(req, assetLocation, 'fonts.json', 'application/json');
|
|
56
|
-
try {
|
|
57
|
-
const filePath = fsa.join(assetLocation, '/fonts');
|
|
58
|
-
const fonts = await getFonts(filePath);
|
|
59
|
-
const cacheKey = Etag.key(fonts);
|
|
60
|
-
if (Etag.isNotModified(req, cacheKey))
|
|
61
|
-
return NotModified();
|
|
62
|
-
const response = LambdaHttpResponse.ok().buffer(JSON.stringify(fonts), 'application/json');
|
|
63
|
-
response.header(HttpHeader.ETag, cacheKey);
|
|
64
|
-
response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
|
|
65
|
-
return response;
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
if (e.code === 404)
|
|
69
|
-
return NotFound();
|
|
70
|
-
throw e;
|
|
71
|
-
}
|
|
8
|
+
return assetProvider.serve(req, 'fonts.json', 'application/json');
|
|
72
9
|
}
|
|
73
10
|
//# sourceMappingURL=fonts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/routes/fonts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/routes/fonts.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAM3D,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAA+B;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;IACvF,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAsB;IACnD,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../src/routes/sprites.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../src/routes/sprites.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIvE,UAAU,SAAS;IACjB,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAMD,wBAAsB,SAAS,CAAC,GAAG,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9F"}
|
package/build/routes/sprites.js
CHANGED
|
@@ -1,42 +1,16 @@
|
|
|
1
|
-
import { Env } from '@basemaps/shared';
|
|
2
1
|
import { fsa } from '@chunkd/fs';
|
|
3
2
|
import path from 'path';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { isGzip, serveFromCotar } from '../util/cotar.serve.js';
|
|
7
|
-
import { Etag } from '../util/etag.js';
|
|
3
|
+
import { NotFound } from '../util/response.js';
|
|
4
|
+
import { assetProvider } from '../util/assets.provider.js';
|
|
8
5
|
const Extensions = new Map();
|
|
9
6
|
Extensions.set('.png', 'image/png');
|
|
10
7
|
Extensions.set('.json', 'application/json');
|
|
11
8
|
export async function spriteGet(req) {
|
|
12
|
-
const assetLocation = Env.get(Env.AssetLocation);
|
|
13
|
-
if (assetLocation == null)
|
|
14
|
-
return NotFound();
|
|
15
9
|
const extension = path.extname(req.params.spriteName);
|
|
16
10
|
const mimeType = Extensions.get(extension);
|
|
17
11
|
if (mimeType == null)
|
|
18
12
|
return NotFound();
|
|
19
13
|
const targetFile = fsa.join('sprites', req.params.spriteName);
|
|
20
|
-
|
|
21
|
-
return serveFromCotar(req, assetLocation, targetFile, mimeType);
|
|
22
|
-
try {
|
|
23
|
-
const filePath = fsa.join(assetLocation, targetFile);
|
|
24
|
-
req.set('target', filePath);
|
|
25
|
-
const buf = await fsa.read(filePath);
|
|
26
|
-
const cacheKey = Etag.key(buf);
|
|
27
|
-
if (Etag.isNotModified(req, cacheKey))
|
|
28
|
-
return NotModified();
|
|
29
|
-
const response = LambdaHttpResponse.ok().buffer(buf, mimeType);
|
|
30
|
-
response.header(HttpHeader.ETag, cacheKey);
|
|
31
|
-
response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
|
|
32
|
-
if (isGzip(buf))
|
|
33
|
-
response.header(HttpHeader.ContentEncoding, 'gzip');
|
|
34
|
-
return response;
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
if (e.code === 404)
|
|
38
|
-
return NotFound();
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
14
|
+
return assetProvider.serve(req, targetFile, mimeType);
|
|
41
15
|
}
|
|
42
16
|
//# sourceMappingURL=sprites.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprites.js","sourceRoot":"","sources":["../../src/routes/sprites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sprites.js","sourceRoot":"","sources":["../../src/routes/sprites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQ3D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;AAC7B,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACpC,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAiC;IAC/D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,QAAQ,IAAI,IAAI;QAAE,OAAO,QAAQ,EAAE,CAAC;IAExC,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9D,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { LambdaHttpResponse, LambdaHttpRequest } from '@linzjs/lambda';
|
|
3
|
+
export declare class AssetProvider {
|
|
4
|
+
/**
|
|
5
|
+
* Assets can be ready from the following locations.
|
|
6
|
+
*
|
|
7
|
+
* /home/blacha/config/build/assets # Local File
|
|
8
|
+
* /home/blacha/config/build/assets.tar.co # Local Cotar
|
|
9
|
+
* s3://linz-baesmaps/assets/ # Remote location
|
|
10
|
+
* s3://linz-basemaps/assets/assets-b4ff211a.tar.co # Remote Cotar
|
|
11
|
+
*/
|
|
12
|
+
/** Path of the assets location */
|
|
13
|
+
path: string | undefined;
|
|
14
|
+
set(path?: string): void;
|
|
15
|
+
get(fileName: string): Promise<Buffer | null>;
|
|
16
|
+
getFromCotar(path: string, fileName: string): Promise<Buffer | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Load a assets from local path or cotar returning the file back as a LambdaResponse
|
|
19
|
+
*
|
|
20
|
+
* This will also set two headers
|
|
21
|
+
* - Content-Encoding if the file starts with gzip magic
|
|
22
|
+
* - Content-Type from the parameter contentType
|
|
23
|
+
*/
|
|
24
|
+
serve(req: LambdaHttpRequest, file: string, contentType: string): Promise<LambdaHttpResponse>;
|
|
25
|
+
}
|
|
26
|
+
export declare const assetProvider: AssetProvider;
|
|
27
|
+
//# sourceMappingURL=assets.provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.provider.d.ts","sourceRoot":"","sources":["../../src/util/assets.provider.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAc,MAAM,gBAAgB,CAAC;AAMnF,qBAAa,aAAa;IACxB;;;;;;;OAOG;IAEH,kCAAkC;IAClC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAe7C,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAM1E;;;;;;OAMG;IACG,KAAK,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAYpG;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { fsa } from '@chunkd/fs';
|
|
2
|
+
import { LambdaHttpResponse, HttpHeader } from '@linzjs/lambda';
|
|
3
|
+
import { isGzip } from './cotar.serve.js';
|
|
4
|
+
import { Etag } from './etag.js';
|
|
5
|
+
import { NotFound, NotModified } from './response.js';
|
|
6
|
+
import { CoSources } from './source.cache.js';
|
|
7
|
+
export class AssetProvider {
|
|
8
|
+
set(path) {
|
|
9
|
+
this.path = path;
|
|
10
|
+
}
|
|
11
|
+
async get(fileName) {
|
|
12
|
+
if (this.path == null)
|
|
13
|
+
return null;
|
|
14
|
+
// get assets file from cotar
|
|
15
|
+
if (this.path.endsWith('.tar.co'))
|
|
16
|
+
return await this.getFromCotar(this.path, fileName);
|
|
17
|
+
// get assets file for directory
|
|
18
|
+
try {
|
|
19
|
+
const filePath = fsa.join(this.path, fileName);
|
|
20
|
+
return await fsa.read(filePath);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
if (e.code === 404)
|
|
24
|
+
return null;
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async getFromCotar(path, fileName) {
|
|
29
|
+
const cotar = await CoSources.getCotar(path);
|
|
30
|
+
const data = await cotar.get(fileName);
|
|
31
|
+
return data ? Buffer.from(data) : data;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Load a assets from local path or cotar returning the file back as a LambdaResponse
|
|
35
|
+
*
|
|
36
|
+
* This will also set two headers
|
|
37
|
+
* - Content-Encoding if the file starts with gzip magic
|
|
38
|
+
* - Content-Type from the parameter contentType
|
|
39
|
+
*/
|
|
40
|
+
async serve(req, file, contentType) {
|
|
41
|
+
const buf = await assetProvider.get(file);
|
|
42
|
+
if (buf == null)
|
|
43
|
+
return NotFound();
|
|
44
|
+
const cacheKey = Etag.key(buf);
|
|
45
|
+
if (Etag.isNotModified(req, cacheKey))
|
|
46
|
+
return NotModified();
|
|
47
|
+
const response = LambdaHttpResponse.ok().buffer(buf, contentType);
|
|
48
|
+
response.header(HttpHeader.ETag, cacheKey);
|
|
49
|
+
response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
|
|
50
|
+
if (isGzip(buf))
|
|
51
|
+
response.header(HttpHeader.ContentEncoding, 'gzip');
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export const assetProvider = new AssetProvider();
|
|
56
|
+
//# sourceMappingURL=assets.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.provider.js","sourceRoot":"","sources":["../../src/util/assets.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAqB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,OAAO,aAAa;IAaxB,GAAG,CAAC,IAAa;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,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YAAE,OAAO,WAAW,EAAE,CAAC;QAE5D,MAAM,QAAQ,GAAG,kBAAkB,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAClE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC3C,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,sDAAsD,CAAC,CAAC;QACjG,IAAI,MAAM,CAAC,GAAG,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConfigBundled, ConfigProviderMemory } from '@basemaps/config';
|
|
2
|
+
import { SwappingLru } from './swapping.lru.js';
|
|
3
|
+
declare class LruConfig {
|
|
4
|
+
configProvider: Promise<ConfigProviderMemory>;
|
|
5
|
+
constructor(config: Promise<ConfigBundled>);
|
|
6
|
+
get size(): number;
|
|
7
|
+
}
|
|
8
|
+
export declare class ConfigCache {
|
|
9
|
+
cache: SwappingLru<LruConfig>;
|
|
10
|
+
constructor(maxSize: number);
|
|
11
|
+
getConfig(location: string): Promise<ConfigProviderMemory | null>;
|
|
12
|
+
}
|
|
13
|
+
/** Cache 20 configs(Around 500KB each)*/
|
|
14
|
+
export declare const CachedConfig: ConfigCache;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=config.cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.cache.d.ts","sourceRoot":"","sources":["../../src/util/config.cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,cAAM,SAAS;IACb,cAAc,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;gBAElC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC;IAQ1C,IAAI,IAAI,IAAI,MAAM,CAGjB;CACF;AAED,qBAAa,WAAW;IACtB,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;gBAClB,OAAO,EAAE,MAAM;IAI3B,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAalE;AAED,yCAAyC;AACzC,eAAO,MAAM,YAAY,aAAsB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ConfigProviderMemory } from '@basemaps/config';
|
|
2
|
+
import { fsa } from '@chunkd/fs';
|
|
3
|
+
import { SwappingLru } from './swapping.lru.js';
|
|
4
|
+
class LruConfig {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.configProvider = config.then((c) => {
|
|
7
|
+
const configProvider = ConfigProviderMemory.fromJson(c);
|
|
8
|
+
configProvider.createVirtualTileSets();
|
|
9
|
+
return configProvider;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
get size() {
|
|
13
|
+
// Return size 1 for the config and cache the number of configs based on size number.
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class ConfigCache {
|
|
18
|
+
constructor(maxSize) {
|
|
19
|
+
this.cache = new SwappingLru(maxSize);
|
|
20
|
+
}
|
|
21
|
+
getConfig(location) {
|
|
22
|
+
var _a;
|
|
23
|
+
const existing = (_a = this.cache.get(location)) === null || _a === void 0 ? void 0 : _a.configProvider;
|
|
24
|
+
if (existing != null)
|
|
25
|
+
return existing;
|
|
26
|
+
try {
|
|
27
|
+
const configJson = fsa.readJson(location);
|
|
28
|
+
const config = new LruConfig(configJson);
|
|
29
|
+
this.cache.set(location, config);
|
|
30
|
+
return config.configProvider;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
if (e.code === 404)
|
|
34
|
+
return Promise.resolve(null);
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Cache 20 configs(Around 500KB each)*/
|
|
40
|
+
export const CachedConfig = new ConfigCache(20);
|
|
41
|
+
//# sourceMappingURL=config.cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.cache.js","sourceRoot":"","sources":["../../src/util/config.cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,SAAS;IAGb,YAAY,MAA8B;QACxC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACtC,MAAM,cAAc,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACxD,cAAc,CAAC,qBAAqB,EAAE,CAAC;YACvC,OAAO,cAAc,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI;QACN,qFAAqF;QACrF,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAED,MAAM,OAAO,WAAW;IAEtB,YAAY,OAAe;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAY,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,SAAS,CAAC,QAAgB;;QACxB,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,0CAAE,cAAc,CAAC;QAC1D,IAAI,QAAQ,IAAI,IAAI;YAAE,OAAO,QAAQ,CAAC;QACtC,IAAI;YACF,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAgB,QAAQ,CAAC,CAAC;YACzD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACjC,OAAO,MAAM,CAAC,cAAc,CAAC;SAC9B;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG;gBAAE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;CACF;AAED,yCAAyC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC"}
|
package/build/util/response.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LambdaHttpResponse } from '@linzjs/lambda';
|
|
1
|
+
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
2
|
export declare const NotFound: () => LambdaHttpResponse;
|
|
3
3
|
export declare const NotModified: () => LambdaHttpResponse;
|
|
4
4
|
export declare const NoContent: () => LambdaHttpResponse;
|
|
5
|
+
export declare const OkResponse: (req: LambdaHttpRequest) => LambdaHttpResponse;
|
|
5
6
|
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/util/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/util/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,eAAO,MAAM,QAAQ,QAAO,kBAA8D,CAAC;AAC3F,eAAO,MAAM,WAAW,QAAO,kBAAiE,CAAC;AACjG,eAAO,MAAM,SAAS,QAAO,kBAA+D,CAAC;AAC7F,eAAO,MAAM,UAAU,QAAS,iBAAiB,KAAG,kBACqD,CAAC"}
|
package/build/util/response.js
CHANGED
|
@@ -2,4 +2,5 @@ import { LambdaHttpResponse } from '@linzjs/lambda';
|
|
|
2
2
|
export const NotFound = () => new LambdaHttpResponse(404, 'Not Found');
|
|
3
3
|
export const NotModified = () => new LambdaHttpResponse(304, 'Not modified');
|
|
4
4
|
export const NoContent = () => new LambdaHttpResponse(204, 'No Content');
|
|
5
|
+
export const OkResponse = (req) => new LambdaHttpResponse(200, 'ok').json({ id: req.id, correlationId: req.correlationId, message: 'ok' });
|
|
5
6
|
//# sourceMappingURL=response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/util/response.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/util/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAuB,EAAE,CAAC,IAAI,kBAAkB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,GAAuB,EAAE,CAAC,IAAI,kBAAkB,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,SAAS,GAAG,GAAuB,EAAE,CAAC,IAAI,kBAAkB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAsB,EAAsB,EAAE,CACvE,IAAI,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC"}
|