@loaders.gl/tile-converter 4.0.0-alpha.15 → 4.0.0-alpha.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.
Files changed (87) hide show
  1. package/dist/converter.min.js +64 -64
  2. package/dist/dist.min.js +29 -47
  3. package/dist/es5/deps-installer/deps-installer.js +1 -1
  4. package/dist/es5/i3s-server/app.js +20 -12
  5. package/dist/es5/i3s-server/app.js.map +1 -1
  6. package/dist/es5/i3s-server/bin/www.js +25 -53
  7. package/dist/es5/i3s-server/bin/www.js.map +1 -1
  8. package/dist/es5/i3s-server/controllers/index-controller.js +23 -22
  9. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  10. package/dist/es5/i3s-server/controllers/slpk-controller.js +31 -30
  11. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  12. package/dist/es5/i3s-server/routes/index.js +2 -2
  13. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  14. package/dist/es5/i3s-server/routes/slpk-router.js +14 -13
  15. package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -1
  16. package/dist/es5/i3s-server/utils/create-scene-server.js +7 -4
  17. package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -1
  18. package/dist/es5/i3s-server/utils/server-utils.js +49 -0
  19. package/dist/es5/i3s-server/utils/server-utils.js.map +1 -0
  20. package/dist/es5/pgm-loader.js +1 -1
  21. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +1 -1
  22. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -1
  23. package/dist/es5/slpk-extractor/slpk-extractor.js +2 -2
  24. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  25. package/dist/esm/deps-installer/deps-installer.js +1 -1
  26. package/dist/esm/i3s-server/app.js +9 -7
  27. package/dist/esm/i3s-server/app.js.map +1 -1
  28. package/dist/esm/i3s-server/bin/i3s-server.min.js +124 -222
  29. package/dist/esm/i3s-server/bin/www.js +14 -43
  30. package/dist/esm/i3s-server/bin/www.js.map +1 -1
  31. package/dist/esm/i3s-server/controllers/index-controller.js +4 -7
  32. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
  33. package/dist/esm/i3s-server/controllers/slpk-controller.js +8 -19
  34. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  35. package/dist/esm/i3s-server/routes/index.js +1 -1
  36. package/dist/esm/i3s-server/routes/index.js.map +1 -1
  37. package/dist/esm/i3s-server/routes/slpk-router.js +5 -11
  38. package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -1
  39. package/dist/esm/i3s-server/utils/create-scene-server.js +2 -5
  40. package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -1
  41. package/dist/esm/i3s-server/utils/server-utils.js +40 -0
  42. package/dist/esm/i3s-server/utils/server-utils.js.map +1 -0
  43. package/dist/esm/pgm-loader.js +1 -1
  44. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +1 -1
  45. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -1
  46. package/dist/esm/slpk-extractor/slpk-extractor.js +2 -2
  47. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  48. package/dist/i3s-server/app.d.ts +1 -2
  49. package/dist/i3s-server/app.d.ts.map +1 -1
  50. package/dist/i3s-server/app.js +22 -15
  51. package/dist/i3s-server/bin/www.d.ts.map +1 -1
  52. package/dist/i3s-server/bin/www.js +31 -77
  53. package/dist/i3s-server/controllers/index-controller.d.ts +6 -1
  54. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -1
  55. package/dist/i3s-server/controllers/index-controller.js +16 -8
  56. package/dist/i3s-server/controllers/slpk-controller.d.ts +13 -2
  57. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  58. package/dist/i3s-server/controllers/slpk-controller.js +19 -13
  59. package/dist/i3s-server/routes/index.d.ts +1 -2
  60. package/dist/i3s-server/routes/index.d.ts.map +1 -1
  61. package/dist/i3s-server/routes/index.js +6 -2
  62. package/dist/i3s-server/routes/slpk-router.d.ts +2 -2
  63. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  64. package/dist/i3s-server/routes/slpk-router.js +15 -14
  65. package/dist/i3s-server/utils/create-scene-server.d.ts +11 -5
  66. package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -1
  67. package/dist/i3s-server/utils/create-scene-server.js +11 -3
  68. package/dist/i3s-server/utils/server-utils.d.ts +24 -0
  69. package/dist/i3s-server/utils/server-utils.d.ts.map +1 -0
  70. package/dist/i3s-server/utils/server-utils.js +66 -0
  71. package/dist/slpk-extractor/helpers/file-handle-provider.js +1 -1
  72. package/dist/slpk-extractor/slpk-extractor.js +1 -1
  73. package/dist/slpk-extractor.min.js +1 -1
  74. package/package.json +19 -15
  75. package/src/i3s-server/{app.js → app.ts} +10 -8
  76. package/src/i3s-server/bin/www.ts +38 -0
  77. package/src/i3s-server/controllers/{index-controller.js → index-controller.ts} +10 -9
  78. package/src/i3s-server/controllers/slpk-controller.ts +32 -0
  79. package/src/i3s-server/routes/{index.js → index.ts} +2 -1
  80. package/src/i3s-server/routes/{slpk-router.js → slpk-router.ts} +5 -10
  81. package/src/i3s-server/utils/create-scene-server.ts +20 -0
  82. package/src/i3s-server/utils/server-utils.ts +70 -0
  83. package/src/slpk-extractor/helpers/file-handle-provider.ts +1 -1
  84. package/src/slpk-extractor/slpk-extractor.ts +1 -1
  85. package/src/i3s-server/bin/www.js +0 -102
  86. package/src/i3s-server/controllers/slpk-controller.js +0 -31
  87. package/src/i3s-server/utils/create-scene-server.js +0 -15
@@ -1,12 +1,20 @@
1
1
  #!/usr/bin/env node
2
- const app = require('../app');
3
- const debug = require('debug')('i3s-server:server');
4
- const https = require('https');
5
- const http = require('http');
6
- const fs = require('fs');
7
- const path = require('path');
2
+ import { app } from '../app';
3
+ import https from 'https';
4
+ import http from 'http';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { formErrorHandler, formListeningHandler, normalizePort } from '../utils/server-utils';
8
8
  const httpPort = normalizePort(process.env.PORT || '80');
9
+ if (httpPort === false) {
10
+ console.error("Incorrect HTTP port");
11
+ process.exit(1);
12
+ }
9
13
  const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
14
+ if (httpsPort === false) {
15
+ console.error("Incorrect HTTPs port");
16
+ process.exit(1);
17
+ }
10
18
  const options = {
11
19
  key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),
12
20
  cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))
@@ -19,41 +27,4 @@ httpServer.on('listening', formListeningHandler(httpServer));
19
27
  httpsServer.listen(httpsPort);
20
28
  httpsServer.on('error', formErrorHandler(httpsPort));
21
29
  httpsServer.on('listening', formListeningHandler(httpsServer));
22
- function normalizePort(val) {
23
- const chkPort = parseInt(val, 10);
24
- if (isNaN(chkPort)) {
25
- return val;
26
- }
27
- if (chkPort >= 0) {
28
- return chkPort;
29
- }
30
- return false;
31
- }
32
- function formErrorHandler(optionalPort) {
33
- return function onError(error) {
34
- if (error.syscall !== 'listen') {
35
- throw error;
36
- }
37
- const bind = typeof global.port === 'string' ? "Pipe ".concat(optionalPort) : "Port ".concat(optionalPort);
38
- switch (error.code) {
39
- case 'EACCES':
40
- console.error("".concat(bind, " requires elevated privileges"));
41
- process.exit(1);
42
- break;
43
- case 'EADDRINUSE':
44
- console.error("".concat(bind, " is already in use"));
45
- process.exit(1);
46
- break;
47
- default:
48
- throw error;
49
- }
50
- };
51
- }
52
- function formListeningHandler(optionalServer) {
53
- return function onListening() {
54
- const addr = optionalServer.address();
55
- const bind = typeof addr === 'string' ? "pipe ".concat(addr) : "port ".concat(addr.port);
56
- debug("Listening on ".concat(bind));
57
- };
58
- }
59
30
  //# sourceMappingURL=www.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"www.js","names":["app","require","debug","https","http","fs","path","httpPort","normalizePort","process","env","PORT","httpsPort","HTTPS_PORT","options","key","readFileSync","join","__dirname","cert","httpServer","createServer","httpsServer","listen","on","formErrorHandler","formListeningHandler","val","chkPort","parseInt","isNaN","optionalPort","onError","error","syscall","bind","global","port","concat","code","console","exit","optionalServer","onListening","addr","address"],"sources":["../../../../src/i3s-server/bin/www.js"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nconst app = require('../app');\nconst debug = require('debug')('i3s-server:server');\nconst https = require('https');\nconst http = require('http');\nconst fs = require('fs');\nconst path = require('path');\n\n/**\n * Get port from environment and store in Express.\n */\n\nconst httpPort = normalizePort(process.env.PORT || '80'); // eslint-disable-line no-process-env, no-undef\nconst httpsPort = normalizePort(process.env.HTTPS_PORT || '443'); // eslint-disable-line no-process-env, no-undef\n\n/**\n * Create HTTP server.\n */\n\nconst options = {\n key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),\n cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))\n};\n\nconst httpServer = http.createServer(app);\nconst httpsServer = https.createServer(options, app);\n\n/**\n * Listen on provided port, on all network interfaces.\n */\n\nhttpServer.listen(httpPort);\nhttpServer.on('error', formErrorHandler(httpPort));\nhttpServer.on('listening', formListeningHandler(httpServer));\n\nhttpsServer.listen(httpsPort);\nhttpsServer.on('error', formErrorHandler(httpsPort));\nhttpsServer.on('listening', formListeningHandler(httpsServer));\n\n/**\n * Normalize a port into a number, string, or false.\n */\n\nfunction normalizePort(val) {\n const chkPort = parseInt(val, 10);\n\n if (isNaN(chkPort)) {\n // named pipe\n return val;\n }\n\n if (chkPort >= 0) {\n // port number\n return chkPort;\n }\n\n return false;\n}\n\n/**\n * Event listener for HTTP/HTTPS server \"error\" event.\n */\n\nfunction formErrorHandler(optionalPort) {\n return function onError(error) {\n if (error.syscall !== 'listen') {\n throw error;\n }\n\n const bind = typeof global.port === 'string' ? `Pipe ${optionalPort}` : `Port ${optionalPort}`;\n\n // handle specific listen errors with friendly messages\n switch (error.code) {\n case 'EACCES':\n console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console, no-undef\n process.exit(1); // eslint-disable-line no-process-exit, no-undef\n break;\n case 'EADDRINUSE':\n console.error(`${bind} is already in use`); // eslint-disable-line no-console, no-undef\n process.exit(1); // eslint-disable-line no-process-exit, no-undef\n break;\n default:\n throw error;\n }\n };\n}\n\n/**\n * Event listener for HTTP/HTTPS server \"listening\" event.\n */\nfunction formListeningHandler(optionalServer) {\n return function onListening() {\n const addr = optionalServer.address();\n const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;\n debug(`Listening on ${bind}`);\n };\n}\n"],"mappings":"AAAA;AAMA,MAAMA,GAAG,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAC7B,MAAMC,KAAK,GAAGD,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;AACnD,MAAME,KAAK,GAAGF,OAAO,CAAC,OAAO,CAAC;AAC9B,MAAMG,IAAI,GAAGH,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAMI,EAAE,GAAGJ,OAAO,CAAC,IAAI,CAAC;AACxB,MAAMK,IAAI,GAAGL,OAAO,CAAC,MAAM,CAAC;AAM5B,MAAMM,QAAQ,GAAGC,aAAa,CAACC,OAAO,CAACC,GAAG,CAACC,IAAI,IAAI,IAAI,CAAC;AACxD,MAAMC,SAAS,GAAGJ,aAAa,CAACC,OAAO,CAACC,GAAG,CAACG,UAAU,IAAI,KAAK,CAAC;AAMhE,MAAMC,OAAO,GAAG;EACdC,GAAG,EAAEV,EAAE,CAACW,YAAY,CAACV,IAAI,CAACW,IAAI,CAACC,SAAS,EAAE,kBAAkB,CAAC,CAAC;EAC9DC,IAAI,EAAEd,EAAE,CAACW,YAAY,CAACV,IAAI,CAACW,IAAI,CAACC,SAAS,EAAE,mBAAmB,CAAC;AACjE,CAAC;AAED,MAAME,UAAU,GAAGhB,IAAI,CAACiB,YAAY,CAACrB,GAAG,CAAC;AACzC,MAAMsB,WAAW,GAAGnB,KAAK,CAACkB,YAAY,CAACP,OAAO,EAAEd,GAAG,CAAC;AA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CAAC,CAAC;QACf;MACF;QACE,MAAMR,KAAK;IACf;EACF,CAAC;AACH;AAKA,SAASP,oBAAoBA,CAACgB,cAAc,EAAE;EAC5C,OAAO,SAASC,WAAWA,CAAA,EAAG;IAC5B,MAAMC,IAAI,GAAGF,cAAc,CAACG,OAAO,CAAC,CAAC;IACrC,MAAMV,IAAI,GAAG,OAAOS,IAAI,KAAK,QAAQ,WAAAN,MAAA,CAAWM,IAAI,YAAAN,MAAA,CAAaM,IAAI,CAACP,IAAI,CAAE;IAC5EnC,KAAK,iBAAAoC,MAAA,CAAiBH,IAAI,CAAE,CAAC;EAC/B,CAAC;AACH"}
1
+ {"version":3,"file":"www.js","names":["app","https","http","fs","path","formErrorHandler","formListeningHandler","normalizePort","httpPort","process","env","PORT","console","error","exit","httpsPort","HTTPS_PORT","options","key","readFileSync","join","__dirname","cert","httpServer","createServer","httpsServer","listen","on"],"sources":["../../../../src/i3s-server/bin/www.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport {app} from '../app';\nimport https from 'https';\nimport http from 'http';\nimport fs from 'fs';\nimport path from 'path';\nimport {formErrorHandler, formListeningHandler, normalizePort} from '../utils/server-utils';\n\n/** Get port from environment and store in Express. */\nconst httpPort = normalizePort(process.env.PORT || '80');\nif (httpPort === false) {\n console.error(`Incorrect HTTP port`);\n process.exit(1);\n}\nconst httpsPort = normalizePort(process.env.HTTPS_PORT || '443');\nif (httpsPort === false) {\n console.error(`Incorrect HTTPs port`);\n process.exit(1);\n}\n\n/** Create HTTP server. */\nconst options = {\n key: fs.readFileSync(path.join(__dirname, '../certs/key.pem')),\n cert: fs.readFileSync(path.join(__dirname, '../certs/cert.pem'))\n};\n\nconst httpServer = http.createServer(app);\nconst httpsServer = https.createServer(options, app);\n\n/** Listen on provided port, on all network interfaces. */\nhttpServer.listen(httpPort);\nhttpServer.on('error', formErrorHandler(httpPort));\nhttpServer.on('listening', formListeningHandler(httpServer));\n\nhttpsServer.listen(httpsPort);\nhttpsServer.on('error', form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;AAClDe,UAAU,CAACI,EAAE,CAAC,WAAW,EAAErB,oBAAoB,CAACiB,UAAU,CAAC,CAAC;AAE5DE,WAAW,CAACC,MAAM,CAACX,SAAS,CAAC;AAC7BU,WAAW,CAACE,EAAE,CAAC,OAAO,EAAEtB,gBAAgB,CAACU,SAAS,CAAC,CAAC;AACpDU,WAAW,CAACE,EAAE,CAAC,WAAW,EAAErB,oBAAoB,CAACmB,WAAW,CAAC,CAAC"}
@@ -1,12 +1,12 @@
1
- const path = require('path');
2
- const fs = require('fs');
1
+ import path from 'path';
2
+ import fs from 'fs';
3
3
  const {
4
4
  promises
5
5
  } = fs;
6
6
  const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
7
- const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
8
- async function getFileNameByUrl(url) {
7
+ export async function getFileNameByUrl(url) {
9
8
  const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];
9
+ const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
10
10
  for (const ext of extensions) {
11
11
  const fileName = "".concat(FULL_LAYER_PATH).concat(url, "/index.").concat(ext);
12
12
  try {
@@ -18,7 +18,4 @@ async function getFileNameByUrl(url) {
18
18
  }
19
19
  return null;
20
20
  }
21
- module.exports = {
22
- getFileNameByUrl
23
- };
24
21
  //# sourceMappingURL=index-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-controller.js","names":["path","require","fs","promises","I3S_LAYER_PATH","process","env","I3sLayerPath","FULL_LAYER_PATH","join","cwd","getFileNameByUrl","url","extensions","ext","fileName","concat","access","module","exports"],"sources":["../../../../src/i3s-server/controllers/index-controller.js"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\n\nconst {promises} = fs;\n\nconst I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef\nconst FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef\n\nasync function getFileNameByUrl(url) {\n const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];\n for (const ext of extensions) {\n const fileName = `${FULL_LAYER_PATH}${url}/index.${ext}`;\n try {\n await promises.access(fileName);\n return fileName;\n } catch {\n continue; // eslint-disable-line no-continue\n }\n }\n return null;\n}\n\nmodule.exports = {\n getFileNameByUrl\n};\n"],"mappings":"AAAA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAMC,EAAE,GAAGD,OAAO,CAAC,IAAI,CAAC;AAExB,MAAM;EAACE;AAAQ,CAAC,GAAGD,EAAE;AAErB,MAAME,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AACrD,MAAMC,eAAe,GAAGR,IAAI,CAACS,IAAI,CAACJ,OAAO,CAACK,GAAG,CAAC,CAAC,EAAEN,cAAc,CAAC;AAEhE,eAAeO,gBAAgBA,CAACC,GAAG,EAAE;EACnC,MAAMC,UAAU,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC;EAC3E,KAAK,MAAMC,GAAG,IAAID,UAAU,EAAE;IAC5B,MAAME,QAAQ,MAAAC,MAAA,CAAMR,eAAe,EAAAQ,MAAA,CAAGJ,GAAG,aAAAI,MAAA,CAAUF,GAAG,CAAE;IACxD,IAAI;MACF,MAAMX,QAAQ,CAACc,MAAM,CAACF,QAAQ,CAAC;MAC/B,OAAOA,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IACF;EACF;EACA,OAAO,IAAI;AACb;AAEAG,MAAM,CAACC,OAAO,GAAG;EACfR;AACF,CAAC"}
1
+ {"version":3,"file":"index-controller.js","names":["path","fs","promises","I3S_LAYER_PATH","process","env","I3sLayerPath","getFileNameByUrl","url","extensions","FULL_LAYER_PATH","join","cwd","ext","fileName","concat","access"],"sources":["../../../../src/i3s-server/controllers/index-controller.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\n\nconst {promises} = fs;\n\nconst I3S_LAYER_PATH = process.env.I3sLayerPath || '';\n\n/**\n * Get local file name by input HTTP URL\n * @param url - I3S HTTP service url\n * @returns - local file name\n */\nexport async function getFileNameByUrl(url: string): Promise<string | null> {\n const extensions = ['json', 'bin', 'jpg', 'jpeg', 'png', 'bin.dds', 'ktx2'];\n const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);\n for (const ext of extensions) {\n const fileName = `${FULL_LAYER_PATH}${url}/index.${ext}`;\n try {\n await promises.access(fileName);\n return fileName;\n } catch {\n continue; // eslint-disable-line no-continue\n }\n }\n return null;\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AAEnB,MAAM;EAACC;AAAQ,CAAC,GAAGD,EAAE;AAErB,MAAME,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AAOrD,OAAO,eAAeC,gBAAgBA,CAACC,GAAW,EAA0B;EAC1E,MAAMC,UAAU,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC;EAC3E,MAAMC,eAAe,GAAGV,IAAI,CAACW,IAAI,CAACP,OAAO,CAACQ,GAAG,CAAC,CAAC,EAAET,cAAc,CAAC;EAChE,KAAK,MAAMU,GAAG,IAAIJ,UAAU,EAAE;IAC5B,MAAMK,QAAQ,MAAAC,MAAA,CAAML,eAAe,EAAAK,MAAA,CAAGP,GAAG,aAAAO,MAAA,CAAUF,GAAG,CAAE;IACxD,IAAI;MACF,MAAMX,QAAQ,CAACc,MAAM,CAACF,QAAQ,CAAC;MAC/B,OAAOA,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IACF;EACF;EACA,OAAO,IAAI;AACb"}
@@ -1,21 +1,14 @@
1
- require('@loaders.gl/polyfills');
2
- const {
3
- parseSLPK
4
- } = require('@loaders.gl/i3s');
5
- const path = require('path');
6
- const {
7
- FileHandleProvider
8
- } = require('@loaders.gl/tile-converter');
1
+ import '@loaders.gl/polyfills';
2
+ import { parseSLPK } from '@loaders.gl/i3s';
3
+ import { FileHandleProvider } from '@loaders.gl/tile-converter';
9
4
  let slpkArchive;
10
- const loadArchive = async fullLayerPath => {
11
- slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath));
5
+ export const loadArchive = async fullLayerPath => {
6
+ slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath), msg => console.log(msg));
7
+ console.log('The server is ready to use');
12
8
  };
13
- const I3S_LAYER_PATH = process.env.I3sLayerPath || '';
14
- const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH);
15
- loadArchive(FULL_LAYER_PATH);
16
- async function getFileByUrl(url) {
9
+ export async function getFileByUrl(url) {
17
10
  const trimmedPath = /^\/?(.*)\/?$/.exec(url);
18
- let uncompressedFile;
11
+ let uncompressedFile = null;
19
12
  if (trimmedPath) {
20
13
  try {
21
14
  uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));
@@ -23,8 +16,4 @@ async function getFileByUrl(url) {
23
16
  }
24
17
  return uncompressedFile;
25
18
  }
26
- module.exports = {
27
- loadArchive,
28
- getFileByUrl
29
- };
30
19
  //# sourceMappingURL=slpk-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-controller.js","names":["require","parseSLPK","path","FileHandleProvider","slpkArchive","loadArchive","fullLayerPath","from","I3S_LAYER_PATH","process","env","I3sLayerPath","FULL_LAYER_PATH","join","cwd","getFileByUrl","url","trimmedPath","exec","uncompressedFile","Buffer","getFile","e","module","exports"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.js"],"sourcesContent":["require('@loaders.gl/polyfills');\nconst {parseSLPK} = require('@loaders.gl/i3s');\nconst path = require('path');\nconst {FileHandleProvider} = require('@loaders.gl/tile-converter');\n\nlet slpkArchive;\n\nconst loadArchive = async (fullLayerPath) => {\n slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath));\n};\n\nconst I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef\nconst FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef\n\nloadArchive(FULL_LAYER_PATH);\n\nasync function getFileByUrl(url) {\n const trimmedPath = /^\\/?(.*)\\/?$/.exec(url);\n let uncompressedFile;\n if (trimmedPath) {\n try {\n uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));\n } catch (e) {}\n }\n return uncompressedFile;\n}\n\nmodule.exports = {\n loadArchive,\n getFileByUrl\n};\n"],"mappings":"AAAAA,OAAO,CAAC,uBAAuB,CAAC;AAChC,MAAM;EAACC;AAAS,CAAC,GAAGD,OAAO,CAAC,iBAAiB,CAAC;AAC9C,MAAME,IAAI,GAAGF,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAM;EAACG;AAAkB,CAAC,GAAGH,OAAO,CAAC,4BAA4B,CAAC;AAElE,IAAII,WAAW;AAEf,MAAMC,WAAW,GAAG,MAAOC,aAAa,IAAK;EAC3CF,WAAW,GAAG,MAAMH,SAAS,CAAC,MAAME,kBAAkB,CAACI,IAAI,CAACD,aAAa,CAAC,CAAC;AAC7E,CAAC;AAED,MAAME,cAAc,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,EAAE;AACrD,MAAMC,eAAe,GAAGV,IAAI,CAACW,IAAI,CAACJ,OAAO,CAACK,GAAG,CAAC,CAAC,EAAEN,cAAc,CAAC;AAEhEH,WAAW,CAACO,eAAe,CAAC;AAE5B,eAAeG,YAAYA,CAACC,GAAG,EAAE;EAC/B,MAAMC,WAAW,GAAG,cAAc,CAACC,IAAI,CAACF,GAAG,CAAC;EAC5C,IAAIG,gBAAgB;EACpB,IAAIF,WAAW,EAAE;IACf,IAAI;MACFE,gBAAgB,GAAGC,MAAM,CAACb,IAAI,CAAC,MAAMH,WAAW,CAACiB,OAAO,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC,OAAOK,CAAC,EAAE,CAAC;EACf;EACA,OAAOH,gBAAgB;AACzB;AAEAI,MAAM,CAACC,OAAO,GAAG;EACfnB,WAAW;EACXU;AACF,CAAC"}
1
+ {"version":3,"file":"slpk-controller.js","names":["parseSLPK","FileHandleProvider","slpkArchive","loadArchive","fullLayerPath","from","msg","console","log","getFileByUrl","url","trimmedPath","exec","uncompressedFile","Buffer","getFile","e"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.ts"],"sourcesContent":["import '@loaders.gl/polyfills';\nimport {parseSLPK} from '@loaders.gl/i3s';\nimport {FileHandleProvider} from '@loaders.gl/tile-converter';\n\nlet slpkArchive;\n\n/**\n * Open SLPK file for reading and load HASH file\n * @param fullLayerPath - full path to SLPK file\n */\nexport const loadArchive = async (fullLayerPath: string): Promise<void> => {\n slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath), (msg) =>\n console.log(msg)\n );\n console.log('The server is ready to use');\n};\n\n/**\n * Get a file from SLPK\n * @param url - I3S HTTP URL\n * @returns - file content\n */\nexport async function getFileByUrl(url: string) {\n const trimmedPath = /^\\/?(.*)\\/?$/.exec(url);\n let uncompressedFile: Buffer | null = null;\n if (trimmedPath) {\n try {\n uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));\n } catch (e) {}\n }\n return uncompressedFile;\n}\n"],"mappings":"AAAA,OAAO,uBAAuB;AAC9B,SAAQA,SAAS,QAAO,iBAAiB;AACzC,SAAQC,kBAAkB,QAAO,4BAA4B;AAE7D,IAAIC,WAAW;AAMf,OAAO,MAAMC,WAAW,GAAG,MAAOC,aAAqB,IAAoB;EACzEF,WAAW,GAAG,MAAMF,SAAS,CAAC,MAAMC,kBAAkB,CAACI,IAAI,CAACD,aAAa,CAAC,EAAGE,GAAG,IAC9EC,OAAO,CAACC,GAAG,CAACF,GAAG,CACjB,CAAC;EACDC,OAAO,CAACC,GAAG,CAAC,4BAA4B,CAAC;AAC3C,CAAC;AAOD,OAAO,eAAeC,YAAYA,CAACC,GAAW,EAAE;EAC9C,MAAMC,WAAW,GAAG,cAAc,CAACC,IAAI,CAACF,GAAG,CAAC;EAC5C,IAAIG,gBAA+B,GAAG,IAAI;EAC1C,IAAIF,WAAW,EAAE;IACf,IAAI;MACFE,gBAAgB,GAAGC,MAAM,CAACT,IAAI,CAAC,MAAMH,WAAW,CAACa,OAAO,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC,OAAOK,CAAC,EAAE,CAAC;EACf;EACA,OAAOH,gBAAgB;AACzB"}
@@ -1,4 +1,4 @@
1
- const express = require('express');
1
+ import express from 'express';
2
2
  const router = express.Router();
3
3
  const {
4
4
  getFileNameByUrl
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["express","require","router","Router","getFileNameByUrl","get","req","res","next","fileName","path","sendFile","status","send","module","exports"],"sources":["../../../../src/i3s-server/routes/index.js"],"sourcesContent":["const express = require('express');\nconst router = express.Router();\nconst {getFileNameByUrl} = require('../controllers/index-controller');\n\n/* GET home page. */\nrouter.get('*', async function (req, res, next) {\n const fileName = await getFileNameByUrl(req.path);\n if (fileName) {\n res.sendFile(fileName);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nmodule.exports = router;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAGC,OAAO,CAAC,SAAS,CAAC;AAClC,MAAMC,MAAM,GAAGF,OAAO,CAACG,MAAM,CAAC,CAAC;AAC/B,MAAM;EAACC;AAAgB,CAAC,GAAGH,OAAO,CAAC,iCAAiC,CAAC;AAGrEC,MAAM,CAACG,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9C,MAAMC,QAAQ,GAAG,MAAML,gBAAgB,CAACE,GAAG,CAACI,IAAI,CAAC;EACjD,IAAID,QAAQ,EAAE;IACZF,GAAG,CAACI,QAAQ,CAACF,QAAQ,CAAC;EACxB,CAAC,MAAM;IACLF,GAAG,CAACK,MAAM,CAAC,GAAG,CAAC;IACfL,GAAG,CAACM,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEFC,MAAM,CAACC,OAAO,GAAGb,MAAM"}
1
+ {"version":3,"file":"index.js","names":["express","router","Router","getFileNameByUrl","require","get","req","res","next","fileName","path","sendFile","status","send","module","exports"],"sources":["../../../../src/i3s-server/routes/index.ts"],"sourcesContent":["import express from 'express';\n\nconst router = express.Router();\nconst {getFileNameByUrl} = require('../controllers/index-controller');\n\n/* GET home page. */\nrouter.get('*', async function (req, res, next) {\n const fileName = await getFileNameByUrl(req.path);\n if (fileName) {\n res.sendFile(fileName);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nmodule.exports = router;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAE7B,MAAMC,MAAM,GAAGD,OAAO,CAACE,MAAM,CAAC,CAAC;AAC/B,MAAM;EAACC;AAAgB,CAAC,GAAGC,OAAO,CAAC,iCAAiC,CAAC;AAGrEH,MAAM,CAACI,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9C,MAAMC,QAAQ,GAAG,MAAMN,gBAAgB,CAACG,GAAG,CAACI,IAAI,CAAC;EACjD,IAAID,QAAQ,EAAE;IACZF,GAAG,CAACI,QAAQ,CAACF,QAAQ,CAAC;EACxB,CAAC,MAAM;IACLF,GAAG,CAACK,MAAM,CAAC,GAAG,CAAC;IACfL,GAAG,CAACM,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEFC,MAAM,CAACC,OAAO,GAAGd,MAAM"}
@@ -1,9 +1,7 @@
1
- const express = require('express');
2
- const {
3
- getFileByUrl
4
- } = require('../controllers/slpk-controller');
5
- const createSceneServer = require('../utils/create-scene-server');
6
- const sceneServerRouter = express.Router();
1
+ import express from 'express';
2
+ import { getFileByUrl } from '../controllers/slpk-controller';
3
+ import { createSceneServer } from '../utils/create-scene-server';
4
+ export const sceneServerRouter = express.Router();
7
5
  sceneServerRouter.get('*', async function (req, res, next) {
8
6
  const file = await getFileByUrl('/');
9
7
  if (file) {
@@ -15,7 +13,7 @@ sceneServerRouter.get('*', async function (req, res, next) {
15
13
  res.send('File not found');
16
14
  }
17
15
  });
18
- const router = express.Router();
16
+ export const router = express.Router();
19
17
  router.get('*', async function (req, res, next) {
20
18
  console.log(req.path);
21
19
  const file = await getFileByUrl(req.path);
@@ -26,8 +24,4 @@ router.get('*', async function (req, res, next) {
26
24
  res.send('File not found');
27
25
  }
28
26
  });
29
- module.exports = {
30
- sceneServerRouter,
31
- router
32
- };
33
27
  //# sourceMappingURL=slpk-router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-router.js","names":["express","require","getFileByUrl","createSceneServer","sceneServerRouter","Router","get","req","res","next","file","layer","JSON","parse","toString","sceneServerResponse","name","send","status","router","console","log","path","module","exports"],"sources":["../../../../src/i3s-server/routes/slpk-router.js"],"sourcesContent":["const express = require('express');\nconst {getFileByUrl} = require('../controllers/slpk-controller');\nconst createSceneServer = require('../utils/create-scene-server');\n\nconst sceneServerRouter = express.Router();\nsceneServerRouter.get('*', async function (req, res, next) {\n const file = await getFileByUrl('/');\n if (file) {\n const layer = JSON.parse(file.toString());\n const sceneServerResponse = createSceneServer(layer.name, layer);\n res.send(sceneServerResponse);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nconst router = express.Router();\nrouter.get('*', async function (req, res, next) {\n console.log(req.path);\n const file = await getFileByUrl(req.path);\n if (file) {\n res.send(file);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nmodule.exports = {\n sceneServerRouter,\n router\n};\n"],"mappings":"AAAA,MAAMA,OAAO,GAAGC,OAAO,CA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BAAiB;EACjBe;AACF,CAAC"}
1
+ {"version":3,"file":"slpk-router.js","names":["express","getFileByUrl","createSceneServer","sceneServerRouter","Router","get","req","res","next","file","layer","JSON","parse","toString","sceneServerResponse","name","send","status","router","console","log","path"],"sources":["../../../../src/i3s-server/routes/slpk-router.ts"],"sourcesContent":["import express from 'express';\nimport {getFileByUrl} from '../controllers/slpk-controller';\nimport {createSceneServer} from '../utils/create-scene-server';\n\nexport const sceneServerRouter = express.Router();\nsceneServerRouter.get('*', async function (req, res, next) {\n const file = await getFileByUrl('/');\n if (file) {\n const layer = JSON.parse(file.toString());\n const sceneServerResponse = createSceneServer(layer.name, layer);\n res.send(sceneServerResponse);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n\nexport const router = express.Router();\nrouter.get('*', async function (req, res, next) {\n console.log(req.path);\n const file = await getFileByUrl(req.path);\n if (file) {\n res.send(file);\n } else {\n res.status(404);\n res.send('File not found');\n }\n});\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAC7B,SAAQC,YAAY,QAAO,gCAAgC;AAC3D,SAAQC,iBAAiB,QAAO,8BAA8B;AAE9D,OAAO,MAAMC,iBAAiB,GAAGH,OAAO,CAACI,MAAM,CAAC,CAAC;AACjDD,iBAAiB,CAACE,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EACzD,MAAMC,IAAI,GAAG,MAAMR,YAAY,CAAC,GAAG,CAAC;EACpC,IAAIQ,IAAI,EAAE;IACR,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,QAAQ,CAAC,CAAC,CAAC;IACzC,MAAMC,mBAAmB,GAAGZ,iBAAiB,CAACQ,KAAK,CAACK,IAAI,EAAEL,KAAK,CAAC;IAChEH,GAAG,CAACS,IAAI,CAACF,mBAAmB,CAAC;EAC/B,CAAC,MAAM;IACLP,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC;IACfV,GAAG,CAACS,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC;AAEF,OAAO,MAAME,MAAM,GAAGlB,OAAO,CAACI,MAAM,CAAC,CAAC;AACtCc,MAAM,CAACb,GAAG,CAAC,GAAG,EAAE,gBAAgBC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE;EAC9CW,OAAO,CAACC,GAAG,CAACd,GAAG,CAACe,IAAI,CAAC;EACrB,MAAMZ,IAAI,GAAG,MAAMR,YAAY,CAACK,GAAG,CAACe,IAAI,CAAC;EACzC,IAAIZ,IAAI,EAAE;IACRF,GAAG,CAACS,IAAI,CAACP,IAAI,CAAC;EAChB,CAAC,MAAM;IACLF,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC;IACfV,GAAG,CAACS,IAAI,CAAC,gBAAgB,CAAC;EAC5B;AACF,CAAC,CAAC"}
@@ -1,7 +1,5 @@
1
- const {
2
- v4: uuidv4
3
- } = require('uuid');
4
- const createSceneServer = (name, layer) => {
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ export const createSceneServer = (name, layer) => {
5
3
  return {
6
4
  serviceItemId: uuidv4().replace(/-/gi, ''),
7
5
  serviceName: name,
@@ -12,5 +10,4 @@ const createSceneServer = (name, layer) => {
12
10
  layers: [layer]
13
11
  };
14
12
  };
15
- module.exports = createSceneServer;
16
13
  //# sourceMappingURL=create-scene-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-scene-server.js","names":["v4","uuidv4","require","createSceneServer","name","layer","serviceItemId","replace","serviceName","currentVersion","serviceVersion","supportedBindings","layers","module","exports"],"sources":["../../../../src/i3s-server/utils/create-scene-server.js"],"sourcesContent":["const {v4: uuidv4} = require('uuid');\n\nconst createSceneServer = (name, layer) => {\n return {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n serviceName: name,\n name,\n currentVersion: '10.7',\n serviceVersion: '1.8',\n supportedBindings: ['REST'],\n layers: [layer]\n };\n};\n\nmodule.exports = createSceneServer;\n"],"mappings":"AAAA,MAAM;EAACA,EAAE,EAAEC;AAAM,CAAC,GAAGC,OAAO,CAAC,MAAM,CAAC;AAEpC,MAAMC,iBAAiB,GAAGA,CAACC,IAAI,EAAEC,KAAK,KAAK;EACzC,OAAO;IACLC,aAAa,EAAEL,MAAM,CAAC,CAAC,CAACM,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1CC,WAAW,EAAEJ,IAAI;IACjBA,IAAI;IACJK,cAAc,EAAE,MAAM;IACtBC,cAAc,EAAE,KAAK;IACrBC,iBAAiB,EAAE,CAAC,MAAM,CAAC;IAC3BC,MAAM,EAAE,CAACP,KAAK;EAChB,CAAC;AACH,CAAC;AAEDQ,MAAM,CAACC,OAAO,GAAGX,iBAAiB"}
1
+ {"version":3,"file":"create-scene-server.js","names":["v4","uuidv4","createSceneServer","name","layer","serviceItemId","replace","serviceName","currentVersion","serviceVersion","supportedBindings","layers"],"sources":["../../../../src/i3s-server/utils/create-scene-server.ts"],"sourcesContent":["import {SceneLayer3D} from '@loaders.gl/i3s';\nimport {v4 as uuidv4} from 'uuid';\n\n/**\n * Create `/SceneServer` response\n * @param name - service name, custom user-friendly name of the service\n * @param layer - I3S layer JSON\n * @returns reponse JSON for `/SceneServer` route\n */\nexport const createSceneServer = (name: string, layer: SceneLayer3D) => {\n return {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n serviceName: name,\n name,\n currentVersion: '10.7',\n serviceVersion: '1.8',\n supportedBindings: ['REST'],\n layers: [layer]\n };\n};\n"],"mappings":"AACA,SAAQA,EAAE,IAAIC,MAAM,QAAO,MAAM;AAQjC,OAAO,MAAMC,iBAAiB,GAAGA,CAACC,IAAY,EAAEC,KAAmB,KAAK;EACtE,OAAO;IACLC,aAAa,EAAEJ,MAAM,CAAC,CAAC,CAACK,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1CC,WAAW,EAAEJ,IAAI;IACjBA,IAAI;IACJK,cAAc,EAAE,MAAM;IACtBC,cAAc,EAAE,KAAK;IACrBC,iBAAiB,EAAE,CAAC,MAAM,CAAC;IAC3BC,MAAM,EAAE,CAACP,KAAK;EAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ import debugFactory from 'debug';
2
+ const debug = debugFactory('i3s-server:server');
3
+ export function normalizePort(val) {
4
+ const chkPort = parseInt(val, 10);
5
+ if (Number.isNaN(chkPort)) {
6
+ return val;
7
+ }
8
+ if (chkPort >= 0) {
9
+ return chkPort;
10
+ }
11
+ return false;
12
+ }
13
+ export function formErrorHandler(optionalPort) {
14
+ return function onError(error) {
15
+ if (error.syscall !== 'listen') {
16
+ throw error;
17
+ }
18
+ const bind = typeof optionalPort === 'string' ? "Pipe ".concat(optionalPort) : "Port ".concat(optionalPort);
19
+ switch (error.code) {
20
+ case 'EACCES':
21
+ console.error("".concat(bind, " requires elevated privileges"));
22
+ process.exit(1);
23
+ break;
24
+ case 'EADDRINUSE':
25
+ console.error("".concat(bind, " is already in use"));
26
+ process.exit(1);
27
+ break;
28
+ default:
29
+ throw error;
30
+ }
31
+ };
32
+ }
33
+ export function formListeningHandler(optionalServer) {
34
+ return function onListening() {
35
+ const addr = optionalServer.address();
36
+ const bind = typeof addr === 'string' ? "pipe ".concat(addr) : "port ".concat(addr === null || addr === void 0 ? void 0 : addr.port);
37
+ debug("Listening on ".concat(bind));
38
+ };
39
+ }
40
+ //# sourceMappingURL=server-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-utils.js","names":["debugFactory","debug","normalizePort","val","chkPort","parseInt","Number","isNaN","formErrorHandler","optionalPort","onError","error","syscall","bind","concat","code","console","process","exit","formListeningHandler","optionalServer","onListening","addr","address","port"],"sources":["../../../../src/i3s-server/utils/server-utils.ts"],"sourcesContent":["import type {Server as HttpsServer} from 'https';\nimport type {Server as HttpServer} from 'http';\n\nimport debugFactory from 'debug';\nconst debug = debugFactory('i3s-server:server');\n\n/**\n * Normalize a port into a number, string, or false.\n * @param val - port value from env variables\n * @returns - `number` for port, `string` for a named pipe, or `false` if the port number is not correct\n */\nexport function normalizePort(val: string): number | string | false {\n const chkPort = parseInt(val, 10);\n\n if (Number.isNaN(chkPort)) {\n // named pipe\n return val;\n }\n\n if (chkPort >= 0) {\n // port number\n return chkPort;\n }\n\n return false;\n}\n\n/**\n * Event listener creator for HTTP/HTTPS server \"error\" event.\n * @param optionalPort - the port/named pipe the server is started on\n * @return callback to handle server errors\n */\nexport function formErrorHandler(\n optionalPort: string | number\n): (error: NodeJS.ErrnoException) => void {\n return function onError(error: NodeJS.ErrnoException) {\n if (error.syscall !== 'listen') {\n throw error;\n }\n\n const bind = typeof optionalPort === 'string' ? `Pipe ${optionalPort}` : `Port ${optionalPort}`;\n\n // handle specific listen errors with friendly messages\n switch (error.code) {\n case 'EACCES':\n console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console, no-undef\n process.exit(1); // eslint-disable-line no-process-exit, no-undef\n break;\n case 'EADDRINUSE':\n console.error(`${bind} is already in use`); // eslint-disable-line no-console, no-undef\n process.exit(1); // eslint-disable-line no-process-exit, no-undef\n break;\n default:\n throw error;\n }\n };\n}\n\n/**\n * Event listener for HTTP/HTTPS server \"listening\" event.\n * @param optionalServer - http or https NodeJS server\n * @return callback that is triggered when the server has started\n */\nexport function formListeningHandler(optionalServer: HttpsServer | HttpServer): () => void {\n return function onListening() {\n const addr = optionalServer.address();\n const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr?.port}`;\n debug(`Listening on ${bind}`);\n };\n}\n"],"mappings":"AAGA,OAAOA,YAAY,MAAM,OAAO;AAChC,MAAMC,KAAK,GAAGD,YAAY,CAAC,mBAAmB,CAAC;AAO/C,OAAO,SAASE,aAAaA,CAACC,GAAW,EAA2B;EAClE,MAAMC,OAAO,GAAGC,QAAQ,CAACF,GAAG,EAAE,EAAE,CAAC;EAEjC,IAAIG,MAAM,CAACC,KAAK,CAACH,OAAO,CAAC,EAAE;IAEzB,OAAOD,GAAG;EACZ;EAEA,IAAIC,OAAO,IAAI,CAAC,EAAE;IAEhB,OAAOA,OAAO;EAChB;EAEA,OAAO,KAAK;AACd;AAOA,OAAO,SAASI,gBAAgBA,CAC9BC,YAA6B,EACW;EACxC,OAAO,SAASC,OAAOA,CAACC,KAA4B,EAAE;IACpD,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;MAC9B,MAAMD,KAAK;IACb;IAEA,MAAME,IAAI,GAAG,OAAOJ,YAAY,KAAK,QAAQ,WAAAK,MAAA,CAAWL,YAAY,YAAAK,MAAA,CAAaL,YAAY,CAAE;IAG/F,QAAQE,KAAK,CAACI,IAAI;MAChB,KAAK,QAAQ;QACXC,OAAO,CAACL,KAAK,IAAAG,MAAA,CAAID,IAAI,kCAA+B,CAAC;QACrDI,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;QACf;MACF,KAAK,YAAY;QACfF,OAAO,CAACL,KAAK,IAAAG,MAAA,CAAID,IAAI,uBAAoB,CAAC;QAC1CI,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;QACf;MACF;QACE,MAAMP,KAAK;IACf;EACF,CAAC;AACH;AAOA,OAAO,SAASQ,oBAAoBA,CAACC,cAAwC,EAAc;EACzF,OAAO,SAASC,WAAWA,CAAA,EAAG;IAC5B,MAAMC,IAAI,GAAGF,cAAc,CAACG,OAAO,CAAC,CAAC;IACrC,MAAMV,IAAI,GAAG,OAAOS,IAAI,KAAK,QAAQ,WAAAR,MAAA,CAAWQ,IAAI,YAAAR,MAAA,CAAaQ,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEE,IAAI,CAAE;IAC7EvB,KAAK,iBAAAa,MAAA,CAAiBD,IAAI,CAAE,CAAC;EAC/B,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  import { parsePGM } from '@math.gl/geoid';
2
- const VERSION = typeof "4.0.0-alpha.15" !== 'undefined' ? "4.0.0-alpha.15" : 'latest';
2
+ const VERSION = typeof "4.0.0-alpha.17" !== 'undefined' ? "4.0.0-alpha.17" : 'latest';
3
3
  export const PGMLoader = {
4
4
  name: 'PGM - Netpbm grayscale image format',
5
5
  id: 'pgm',
@@ -33,7 +33,7 @@ export class FileHandleProvider {
33
33
  return val;
34
34
  }
35
35
  async getBigUint64(offset) {
36
- const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 4, offset)).buffer.buffer).at(0);
36
+ const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
37
37
  if (val === undefined) {
38
38
  throw new Error('something went wrong');
39
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file-handle-provider.js","names":["FileHandle","FileHandleProvider","from","path","fileDescriptor","open","stat","size","constructor","_defineProperty","getUint8","offset","val","Uint8Array","read","Buffer","alloc","buffer","at","undefined","Error","getUint16","Uint16Array","getUint32","Uint32Array","getBigUint64","BigInt64Array","slice","startOffsset","endOffset","bigLength","Number","MAX_SAFE_INTEGER","length"],"sources":["../../../../src/slpk-extractor/helpers/file-handle-provider.ts"],"sourcesContent":["import {FileProvider} from '@loaders.gl/i3s';\nimport {FileHandle} from './fs-promises';\n\n/**\n * Provides file data using node fs library\n */\nexport class FileHandleProvider implements FileProvider {\n /**\n * Returns a new copy of FileHandleProvider\n * @param path The path to the file in file system\n */\n static async from(path: string): Promise<FileHandleProvider> {\n const fileDescriptor = await FileHandle.open(path);\n return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);\n }\n\n /**\n * The FileHandle from which data is provided\n */\n private fileDescriptor: FileHandle;\n\n /**\n * The file length in bytes\n */\n private size: bigint;\n\n private constructor(fileDescriptor: FileHandle, size: bigint) {\n this.fileDescriptor = fileDescriptor;\n this.size = size;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n const val = new Uint8Array(\n (await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n const val = new Uint16Array(\n (await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n const val = new Uint32Array(\n (await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n const val = new BigInt64Array(\n (await this.fileDescriptor.read(Buffer.alloc(8), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffsset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer\n .buffer;\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.size;\n }\n}\n"],"mappings":";AACA,SAAQA,UAAU,QAAO,eAAe;AAKxC,OAAO,MAAMC,kBAAkB,C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le","FileHandleProvider","from","path","fileDescriptor","open","stat","size","constructor","_defineProperty","getUint8","offset","val","Uint8Array","read","Buffer","alloc","buffer","at","undefined","Error","getUint16","Uint16Array","getUint32","Uint32Array","getBigUint64","BigInt64Array","slice","startOffsset","endOffset","bigLength","Number","MAX_SAFE_INTEGER","length"],"sources":["../../../../src/slpk-extractor/helpers/file-handle-provider.ts"],"sourcesContent":["import {FileProvider} from '@loaders.gl/i3s';\nimport {FileHandle} from './fs-promises';\n\n/**\n * Provides file data using node fs library\n */\nexport class FileHandleProvider implements FileProvider {\n /**\n * Returns a new copy of FileHandleProvider\n * @param path The path to the file in file system\n */\n static async from(path: string): Promise<FileHandleProvider> {\n const fileDescriptor = await FileHandle.open(path);\n return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);\n }\n\n /**\n * The FileHandle from which data is provided\n */\n private fileDescriptor: FileHandle;\n\n /**\n * The file length in bytes\n */\n private size: bigint;\n\n private constructor(fileDescriptor: FileHandle, size: bigint) {\n this.fileDescriptor = fileDescriptor;\n this.size = size;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n const val = new Uint8Array(\n (await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n const val = new Uint16Array(\n (await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n const val = new Uint32Array(\n (await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n const val = new BigInt64Array(\n (await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffsset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer\n .buffer;\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.size;\n }\n}\n"],"mappings":";AACA,SAAQA,UAAU,QAAO,eAAe;AAKxC,OAAO,MAAMC,kBAAkB,CAAyB;EAKtD,aAAaC,IAAIA,CAACC,IAAY,EAA+B;IAC3D,MAAMC,cAAc,GAAG,MAAMJ,UAAU,CAACK,IAAI,CAACF,IAAI,CAAC;IAClD,OAAO,IAAIF,kBAAkB,CAACG,cAAc,EAAEA,cAAc,CAACE,IAAI,CAACC,IAAI,CAAC;EACzE;EAYQC,WAAWA,CAACJ,cAA0B,EAAEG,IAAY,EAAE;IAAAE,eAAA;IAAAA,eAAA;IAC5D,IAAI,CAACL,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACG,IAAI,GAAGA,IAAI;EAClB;EAMA,MAAMG,QAAQA,CAACC,MAAc,E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,CAACtB,cAAc,CAACU,IAAI,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEL,MAAM,CAAC,EAAEM,MAAM,CAACA,MACzE,CAAC,CAACC,EAAE,CAAC,CAAC,CAAC;IACP,IAAIN,GAAG,KAAKO,SAAS,EAAE;MACrB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;IACzC;IACA,OAAOR,GAAG;EACZ;EAOA,MAAMe,KAAKA,CAACC,YAAoB,EAAEC,SAAiB,EAAwB;IACzE,MAAMC,SAAS,GAAGD,SAAS,GAAGD,YAAY;IAC1C,IAAIE,SAAS,GAAGC,MAAM,CAACC,gBAAgB,EAAE;MACvC,MAAM,IAAIZ,KAAK,CAAC,eAAe,CAAC;IAClC;IACA,MAAMa,MAAM,GAAGF,MAAM,CAACD,SAAS,CAAC;IAChC,OAAO,CAAC,MAAM,IAAI,CAAC1B,cAAc,CAACU,IAAI,CAACC,MAAM,CAACC,KAAK,CAACiB,MAAM,CAAC,EAAE,CAAC,EAAEA,MAAM,EAAEL,YAAY,CAAC,EAAEX,MAAM,CAC1FA,MAAM;EACX;EAKA,IAAIgB,MAAMA,CAAA,EAAW;IACnB,OAAO,IAAI,CAAC1B,IAAI;EAClB;AACF"}
@@ -18,12 +18,12 @@ export default class SLPKConverter {
18
18
  const provider = await FileHandleProvider.from(inputUrl);
19
19
  let localHeader = await parseZipLocalFileHeader(0n, provider);
20
20
  while (localHeader) {
21
- var _localHeader, _localHeader2;
21
+ var _localHeader;
22
22
  await this.writeFile(await this.unGzip({
23
23
  name: this.correctIndexNames(localHeader.fileName),
24
24
  data: await provider.slice(localHeader.fileDataOffset, localHeader.fileDataOffset + localHeader.compressedSize)
25
25
  }), options.outputPath);
26
- localHeader = await parseZipLocalFileHeader(((_localHeader = localHeader) === null || _localHeader === void 0 ? void 0 : _localHeader.fileDataOffset) + ((_localHeader2 = localHeader) === null || _localHeader2 === void 0 ? void 0 : _localHeader2.compressedSize), provider);
26
+ localHeader = await parseZipLocalFileHeader(localHeader.fileDataOffset + ((_localHeader = localHeader) === null || _localHeader === void 0 ? void 0 : _localHeader.compressedSize), provider);
27
27
  }
28
28
  return 'success';
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"slpk-extractor.js","names":["isBrowser","BROWSER_ERROR_MESSAGE","FileHandleProvider","parseZipLocalFileHeader","path","GZipCompression","writeFile","indexNames","SLPKConverter","extract","options","console","log","inputUrl","provider","from","localHeader","_localHeader","_localHeader2","unGzip","name","correctIndexNames","fileName","data","slice","fileDataOffset","compressedSize","outputPath","includes","filename","join","dirname","parts","exec","concat","at","file","_file$name","test","_file$name2","compression","decompressedData","decompress","Promise","resolve","finalPath","dirName"],"sources":["../../../src/slpk-extractor/slpk-extractor.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/core';\n\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {FileHandleProvider} from './helpers/file-handle-provider';\nimport {parseZipLocalFileHeader} from '@loaders.gl/i3s';\nimport {path} from '@loaders.gl/loader-utils';\nimport {GZipCompression} from '@loaders.gl/compression';\nimport {writeFile} from '../lib/utils/file-utils';\n\nconst indexNames = [\n '3dSceneLayer.json.gz',\n '3dNodeIndexDocument.json.gz',\n 'sharedResource.json.gz'\n];\n\n/**\n * Description of the file in the SLPK\n */\ntype File = {\n name: string | null;\n data: ArrayBuffer;\n};\n\n/**\n * Converter from slpk to i3s\n */\nexport default class SLPKConverter {\n /**\n * Extract slpk to i3s\n * @param options\n * @param options.inputUrl the url to read SLPK file\n * @param options.outputPath the output filename\n */\n public async extract(options: {inputUrl: string; outputPath: string}): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl} = options;\n\n const provider = await FileHandleProvider.from(inputUrl);\n\n let localHeader = await parseZipLocalFileHeader(0n, provider);\n while (localHeader) {\n await this.writeFile(\n await this.unGzip({\n name: this.correctIndexNames(localHeader.fileName),\n data: await provider.slice(\n localHeader.fileDataOffset,\n localHeader.fileDataOffset + localHeader.compressedSize\n )\n }),\n options.outputPath\n );\n localHeader = await parseZipLocalFileHeader(\n localHeader?.fileDataOffset + localHeader?.compressedSize,\n provider\n );\n }\n\n return 'success';\n }\n\n /**\n * Defines file name and path for i3s format\n * @param fileName initial file name and path\n */\n\n private correctIndexNames(fileName: string): string | null {\n if (indexNames.includes(path.filename(path.join('/', fileName)))) {\n return path.join(path.dirname(fileName), 'index.json.gz');\n }\n // finds path with name part and extention part\n let parts = /^(.*\\/[^\\/\\.]*)(\\..+)$/.exec(fileName);\n if (!parts) {\n return null;\n }\n return `${parts?.at(1)}/index${parts?.at(2)}`;\n }\n\n private async unGzip(file: File): Promise<File> {\n if (/\\.gz$/.test(file.name ?? '')) {\n const compression = new GZipCompression();\n\n const decompressedData = await compression.decompress(file.data);\n\n return {data: decompressedData, name: (file.name ?? '').slice(0, -3)};\n }\n return Promise.resolve(file);\n }\n\n private async writeFile(options: File, outputPath: string): Promise<void> {\n if (!options.name) {\n return;\n }\n const finalPath = path.join(outputPath, options.name);\n const dirName = path.dirname(finalPath);\n const fileName = path.filename(finalPath);\n await writeFile(dirName, options.data, fileName);\n }\n}\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,kBAAkB;AAE1C,SAAQC,qBAAqB,QAAO,cAAc;AAClD,SAAQC,kBAAkB,QAAO,gCAAgC;AACjE,SAAQC,uBAAuB,QAAO,iBAAiB;AACvD,SAAQC,IAAI,QAAO,0BAA0B;AAC7C,SAAQC,eAAe,QAAO,yBAAyB;AACvD,SAAQC,SAAS,QAAO,yBAAyB;AAEjD,MAAMC,UAAU,GAAG,CACjB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,CACzB;AAaD,eAAe,MAAMC,aAAa,CAAC;EAOjC,MAAaC,OAAOA,CAACC,OAA+C,EAAmB;IACrF,IAAIV,SAAS,EAAE;MACbW,OAAO,CAACC,GAAG,CAACX,q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":["isBrowser","BROWSER_ERROR_MESSAGE","FileHandleProvider","parseZipLocalFileHeader","path","GZipCompression","writeFile","indexNames","SLPKConverter","extract","options","console","log","inputUrl","provider","from","localHeader","_localHeader","unGzip","name","correctIndexNames","fileName","data","slice","fileDataOffset","compressedSize","outputPath","includes","filename","join","dirname","parts","exec","concat","at","file","_file$name","test","_file$name2","compression","decompressedData","decompress","Promise","resolve","finalPath","dirName"],"sources":["../../../src/slpk-extractor/slpk-extractor.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/core';\n\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {FileHandleProvider} from './helpers/file-handle-provider';\nimport {parseZipLocalFileHeader} from '@loaders.gl/i3s';\nimport {path} from '@loaders.gl/loader-utils';\nimport {GZipCompression} from '@loaders.gl/compression';\nimport {writeFile} from '../lib/utils/file-utils';\n\nconst indexNames = [\n '3dSceneLayer.json.gz',\n '3dNodeIndexDocument.json.gz',\n 'sharedResource.json.gz'\n];\n\n/**\n * Description of the file in the SLPK\n */\ntype File = {\n name: string | null;\n data: ArrayBuffer;\n};\n\n/**\n * Converter from slpk to i3s\n */\nexport default class SLPKConverter {\n /**\n * Extract slpk to i3s\n * @param options\n * @param options.inputUrl the url to read SLPK file\n * @param options.outputPath the output filename\n */\n public async extract(options: {inputUrl: string; outputPath: string}): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl} = options;\n\n const provider = await FileHandleProvider.from(inputUrl);\n\n let localHeader = await parseZipLocalFileHeader(0n, provider);\n while (localHeader) {\n await this.writeFile(\n await this.unGzip({\n name: this.correctIndexNames(localHeader.fileName),\n data: await provider.slice(\n localHeader.fileDataOffset,\n localHeader.fileDataOffset + localHeader.compressedSize\n )\n }),\n options.outputPath\n );\n localHeader = await parseZipLocalFileHeader(\n localHeader.fileDataOffset + localHeader?.compressedSize,\n provider\n );\n }\n\n return 'success';\n }\n\n /**\n * Defines file name and path for i3s format\n * @param fileName initial file name and path\n */\n\n private correctIndexNames(fileName: string): string | null {\n if (indexNames.includes(path.filename(path.join('/', fileName)))) {\n return path.join(path.dirname(fileName), 'index.json.gz');\n }\n // finds path with name part and extention part\n let parts = /^(.*\\/[^\\/\\.]*)(\\..+)$/.exec(fileName);\n if (!parts) {\n return null;\n }\n return `${parts?.at(1)}/index${parts?.at(2)}`;\n }\n\n private async unGzip(file: File): Promise<File> {\n if (/\\.gz$/.test(file.name ?? '')) {\n const compression = new GZipCompression();\n\n const decompressedData = await compression.decompress(file.data);\n\n return {data: decompressedData, name: (file.name ?? '').slice(0, -3)};\n }\n return Promise.resolve(file);\n }\n\n private async writeFile(options: File, outputPath: string): Promise<void> {\n if (!options.name) {\n return;\n }\n const finalPath = path.join(outputPath, options.name);\n const dirName = path.dirname(finalPath);\n const fileName = path.filename(finalPath);\n await writeFile(dirName, options.data, fileName);\n }\n}\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,kBAAkB;AAE1C,SAAQC,qBAAqB,QAAO,cAAc;AAClD,SAAQC,kBAAkB,QAAO,gCAAgC;AACjE,SAAQC,uBAAuB,QAAO,iBAAiB;AACvD,SAAQC,IAAI,QAAO,0BAA0B;AAC7C,SAAQC,eAAe,QAAO,yBAAyB;AACvD,SAAQC,SAAS,QAAO,yBAAyB;AAEjD,MAAMC,UAAU,GAAG,CACjB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,CACzB;AAaD,eAAe,MAAMC,aAAa,CAAC;EAOjC,MAAaC,OAAOA,CAACC,OAA+C,EAAmB;IACrF,IAAIV,SAAS,EAAE;MACbW,OAAO,CAACC,GAAG,CAACX,qBAAqB,CAAC;MAClC,OAAOA,qBAAqB;IAC9B;IACA,MAAM;MAACY;IAAQ,CAAC,GAAGH,OAAO;IAE1B,MAAMI,QAAQ,GAAG,MAAMZ,kBAAkB,CAACa,IAAI,CAACF,QAAQ,CAAC;IAExD,IAAIG,WAAW,GAAG,MAAMb,uBA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I,EAAAD,UAAA,GAACD,IAAI,CAAChB,IAAI,cAAAiB,UAAA,cAAAA,UAAA,GAAI,EAAE,CAAC,EAAE;MAAA,IAAAE,WAAA;MACjC,MAAMC,WAAW,GAAG,IAAIlC,eAAe,CAAC,CAAC;MAEzC,MAAMmC,gBAAgB,GAAG,MAAMD,WAAW,CAACE,UAAU,CAACN,IAAI,CAACb,IAAI,CAAC;MAEhE,OAAO;QAACA,IAAI,EAAEkB,gBAAgB;QAAErB,IAAI,EAAE,EAAAmB,WAAA,GAACH,IAAI,CAAChB,IAAI,cAAAmB,WAAA,cAAAA,WAAA,GAAI,EAAE,EAAEf,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;MAAC,CAAC;IACvE;IACA,OAAOmB,OAAO,CAACC,OAAO,CAACR,IAAI,CAAC;EAC9B;EAEA,MAAc7B,SAASA,CAACI,OAAa,EAAEgB,UAAkB,EAAiB;IACxE,IAAI,CAAChB,OAAO,CAACS,IAAI,EAAE;MACjB;IACF;IACA,MAAMyB,SAAS,GAAGxC,IAAI,CAACyB,IAAI,CAACH,UAAU,EAAEhB,OAAO,CAACS,IAAI,CAAC;IACrD,MAAM0B,OAAO,GAAGzC,IAAI,CAAC0B,OAAO,CAACc,SAAS,CAAC;IACvC,MAAMvB,QAAQ,GAAGjB,IAAI,CAACwB,QAAQ,CAACgB,SAAS,CAAC;IACzC,MAAMtC,SAAS,CAACuC,OAAO,EAAEnC,OAAO,CAACY,IAAI,EAAED,QAAQ,CAAC;EAClD;AACF"}
@@ -1,3 +1,2 @@
1
- export = app;
2
- declare const app: any;
1
+ export declare const app: import("express-serve-static-core").Express;
3
2
  //# sourceMappingURL=app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.js"],"names":[],"mappings":";AAQA,uBAAsB"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,GAAG,6CAAY,CAAC"}
@@ -1,22 +1,29 @@
1
1
  "use strict";
2
- const express = require('express');
3
- const path = require('path');
4
- const logger = require('morgan');
5
- const cors = require('cors');
6
- const indexRouter = require('./routes/index');
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.app = void 0;
7
+ const express_1 = __importDefault(require("express"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const morgan_1 = __importDefault(require("morgan"));
10
+ const cors_1 = __importDefault(require("cors"));
11
+ const slpk_controller_1 = require("./controllers/slpk-controller");
7
12
  const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
8
- const app = express();
9
- app.use(logger('dev'));
10
- app.use(express.json());
11
- app.use(express.urlencoded({ extended: false }));
12
- app.use(express.static(path.join(__dirname, 'public')));
13
- app.use(cors());
13
+ const FULL_LAYER_PATH = path_1.default.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
14
+ (0, slpk_controller_1.loadArchive)(FULL_LAYER_PATH);
15
+ const indexRouter = require('./routes/index');
16
+ exports.app = (0, express_1.default)();
17
+ exports.app.use((0, morgan_1.default)('dev'));
18
+ exports.app.use(express_1.default.json());
19
+ exports.app.use(express_1.default.urlencoded({ extended: false }));
20
+ exports.app.use(express_1.default.static(path_1.default.join(__dirname, 'public')));
21
+ exports.app.use((0, cors_1.default)());
14
22
  if (/\.slpk$/.test(I3S_LAYER_PATH)) {
15
23
  const { sceneServerRouter, router } = require('./routes/slpk-router');
16
- app.use('/SceneServer/layers/0', router);
17
- app.use('/SceneServer', sceneServerRouter);
24
+ exports.app.use('/SceneServer/layers/0', router);
25
+ exports.app.use('/SceneServer', sceneServerRouter);
18
26
  }
19
27
  else {
20
- app.use('/', indexRouter);
28
+ exports.app.use('/', indexRouter);
21
29
  }
22
- module.exports = app;
@@ -1 +1 @@
1
- {"version":3,"file":"www.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/bin/www.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"www.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/bin/www.ts"],"names":[],"mappings":""}