@loaders.gl/images 4.0.0-beta.6 → 4.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,9 +1,6 @@
1
- Copyright (c) 2015 Uber Technologies, Inc.
2
-
3
- This software includes parts of PhiloGL (https://github.com/philogb/philogl)
4
- under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
1
+ loaders.gl is licensed under the MIT license
5
2
 
6
- This software includes adaptations of postprocessing code from THREE.js (https://github.com/mrdoob/three.js/) under MIT license. Additional attribution given in specific source files. THREE.js parts Copyright © 2010-2018 three.js authors.
3
+ Copyright (c) vis.gl contributors
7
4
 
8
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
6
  of this software and associated documentation files (the "Software"), to deal
@@ -23,8 +20,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
21
  THE SOFTWARE.
25
22
 
23
+ ---
24
+
25
+ Copyright (c) 2015 Uber Technologies, Inc.
26
26
 
27
- loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License:
27
+ loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium)
28
+ under the Apache 2 License (found in the submodule: modules/3d-tiles):)
28
29
 
29
30
  Copyright 2011-2018 CesiumJS Contributors
30
31
 
@@ -38,4 +39,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
38
39
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
40
  See the License for the specific language governing permissions and limitations under the License.
40
41
 
41
- Cesium-derived code can be found in the submodule: modules/3d-tiles
package/dist/dist.dev.js CHANGED
@@ -37,7 +37,8 @@ var __exports__ = (() => {
37
37
  getSupportedImageFormats: () => getSupportedImageFormats,
38
38
  isImage: () => isImage,
39
39
  isImageFormatSupported: () => isImageFormatSupported,
40
- isImageTypeSupported: () => isImageTypeSupported
40
+ isImageTypeSupported: () => isImageTypeSupported,
41
+ loadImage: () => loadImage
41
42
  });
42
43
 
43
44
  // src/lib/utils/version.ts
@@ -592,6 +593,11 @@ var __exports__ = (() => {
592
593
  image.onerror = () => resolve(false);
593
594
  });
594
595
  }
596
+
597
+ // src/index.ts
598
+ function loadImage() {
599
+ throw new Error("loadImage has moved to @loaders.gl/textures");
600
+ }
595
601
  return __toCommonJS(src_exports);
596
602
  })();
597
603
  return __exports__;
@@ -1 +1 @@
1
- {"version":3,"file":"image-writer.d.ts","sourceRoot":"","sources":["../src/image-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAI3C,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,WAAW,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,4BAA4B;AAC5B,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,kBAAkB,CAaxE,CAAC"}
1
+ {"version":3,"file":"image-writer.d.ts","sourceRoot":"","sources":["../src/image-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAI3C,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,WAAW,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,4BAA4B;AAC5B,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,kBAAkB,CAaxE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"image-writer.js","names":["VERSION","encodeImage","ImageWriter","name","id","module","version","extensions","options","image","mimeType","jpegQuality","encode"],"sources":["../src/image-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Writer, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {ImageDataType} from './types';\nimport {VERSION} from './lib/utils/version';\nimport {encodeImage} from './lib/encoders/encode-image';\n\nexport type ImageWriterOptions = WriterOptions & {\n image?: {\n mimeType?: 'image/png';\n jpegQuality?: number | null;\n };\n};\n\n/** Writer for image data */\nexport const ImageWriter: Writer<ImageDataType, never, ImageWriterOptions> = {\n name: 'Images',\n id: 'image',\n module: 'images',\n version: VERSION,\n extensions: ['jpeg'],\n options: {\n image: {\n mimeType: 'image/png',\n jpegQuality: null\n }\n },\n encode: encodeImage\n};\n"],"mappings":"SAIQA,OAAO;AAAA,SACPC,WAAW;AAUnB,OAAO,MAAMC,WAA6D,GAAG;EAC3EC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAEN,OAAO;EAChBO,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,OAAO,EAAE;IACPC,KAAK,EAAE;MACLC,QAAQ,EAAE,WAAW;MACrBC,WAAW,EAAE;IACf;EACF,CAAC;EACDC,MAAM,EAAEX;AACV,CAAC"}
1
+ {"version":3,"file":"image-writer.js","names":["VERSION","encodeImage","ImageWriter","name","id","module","version","extensions","options","image","mimeType","jpegQuality","encode"],"sources":["../src/image-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Writer, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {ImageDataType} from './types';\nimport {VERSION} from './lib/utils/version';\nimport {encodeImage} from './lib/encoders/encode-image';\n\nexport type ImageWriterOptions = WriterOptions & {\n image?: {\n mimeType?: 'image/png';\n jpegQuality?: number | null;\n };\n};\n\n/** Writer for image data */\nexport const ImageWriter: Writer<ImageDataType, never, ImageWriterOptions> = {\n name: 'Images',\n id: 'image',\n module: 'images',\n version: VERSION,\n extensions: ['jpeg'],\n options: {\n image: {\n mimeType: 'image/png',\n jpegQuality: null\n }\n },\n encode: encodeImage\n};\n"],"mappings":"SAKQA,OAAO;AAAA,SACPC,WAAW;AAUnB,OAAO,MAAMC,WAA6D,GAAG;EAC3EC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAEN,OAAO;EAChBO,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,OAAO,EAAE;IACPC,KAAK,EAAE;MACLC,QAAQ,EAAE,WAAW;MACrBC,WAAW,EAAE;IACf;EACF,CAAC;EACDC,MAAM,EAAEX;AACV,CAAC"}
package/dist/index.cjs CHANGED
@@ -30,7 +30,8 @@ __export(src_exports, {
30
30
  getSupportedImageFormats: () => getSupportedImageFormats,
31
31
  isImage: () => isImage,
32
32
  isImageFormatSupported: () => isImageFormatSupported,
33
- isImageTypeSupported: () => isImageTypeSupported
33
+ isImageTypeSupported: () => isImageTypeSupported,
34
+ loadImage: () => loadImage
34
35
  });
35
36
  module.exports = __toCommonJS(src_exports);
36
37
 
@@ -598,3 +599,8 @@ async function testBrowserImageFormatSupportAsync(testImageDataURL) {
598
599
  image.onerror = () => resolve(false);
599
600
  });
600
601
  }
602
+
603
+ // src/index.ts
604
+ function loadImage() {
605
+ throw new Error("loadImage has moved to @loaders.gl/textures");
606
+ }
package/dist/index.d.ts CHANGED
@@ -7,4 +7,6 @@ export { isImageTypeSupported, getDefaultImageType } from './lib/category-api/im
7
7
  export { isImage, getImageType, getImageSize, getImageData } from './lib/category-api/parsed-image-api';
8
8
  export { getSupportedImageFormats } from './lib/category-api/image-format';
9
9
  export { isImageFormatSupported } from './lib/category-api/image-format';
10
+ /** @deprecated Temporary placeholder to prevent builds from breaking */
11
+ export declare function loadImage(): void;
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,aAAa,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACrE,YAAY,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAK3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,+BAA+B,CAAC;AAExF,OAAO,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAC,wBAAwB,EAAC,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,aAAa,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACrE,YAAY,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAK3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,+BAA+B,CAAC;AAExF,OAAO,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAC,wBAAwB,EAAC,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC;AAGvE,wEAAwE;AACxE,wBAAgB,SAAS,SAExB"}
package/dist/index.js CHANGED
@@ -5,4 +5,7 @@ export { isImageTypeSupported, getDefaultImageType } from "./lib/category-api/im
5
5
  export { isImage, getImageType, getImageSize, getImageData } from "./lib/category-api/parsed-image-api.js";
6
6
  export { getSupportedImageFormats } from "./lib/category-api/image-format.js";
7
7
  export { isImageFormatSupported } from "./lib/category-api/image-format.js";
8
+ export function loadImage() {
9
+ throw new Error('loadImage has moved to @loaders.gl/textures');
10
+ }
8
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ImageLoader","ImageWriter","getBinaryImageMetadata","isImageTypeSupported","getDefaultImageType","isImage","getImageType","getImageSize","getImageData","getSupportedImageFormats","isImageFormatSupported"],"sources":["../src/index.ts"],"sourcesContent":["// TYPES\nexport type {ImageDataType, ImageType, ImageTypeEnum} from './types';\nexport type {ImageLoaderOptions} from './image-loader';\n\n// LOADERS AND WRITERS\nexport {ImageLoader} from './image-loader';\nexport {ImageWriter} from './image-writer';\n\n// IMAGE CATEGORY API\n\n// Binary Image API\nexport {getBinaryImageMetadata} from './lib/category-api/binary-image-api';\n\n// Parsed Image API\nexport {isImageTypeSupported, getDefaultImageType} from './lib/category-api/image-type';\n\nexport {\n isImage,\n getImageType,\n getImageSize,\n getImageData\n} from './lib/category-api/parsed-image-api';\n\n// EXPERIMENTAL\nexport {getSupportedImageFormats} from './lib/category-api/image-format';\nexport {isImageFormatSupported} from './lib/category-api/image-format';\n"],"mappings":"SAKQA,WAAW;AAAA,SACXC,WAAW;AAAA,SAKXC,sBAAsB;AAAA,SAGtBC,oBAAoB,EAAEC,mBAAmB;AAAA,SAG/CC,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,YAAY;AAAA,SAINC,wBAAwB;AAAA,SACxBC,sBAAsB"}
1
+ {"version":3,"file":"index.js","names":["ImageLoader","ImageWriter","getBinaryImageMetadata","isImageTypeSupported","getDefaultImageType","isImage","getImageType","getImageSize","getImageData","getSupportedImageFormats","isImageFormatSupported","loadImage","Error"],"sources":["../src/index.ts"],"sourcesContent":["// TYPES\nexport type {ImageDataType, ImageType, ImageTypeEnum} from './types';\nexport type {ImageLoaderOptions} from './image-loader';\n\n// LOADERS AND WRITERS\nexport {ImageLoader} from './image-loader';\nexport {ImageWriter} from './image-writer';\n\n// IMAGE CATEGORY API\n\n// Binary Image API\nexport {getBinaryImageMetadata} from './lib/category-api/binary-image-api';\n\n// Parsed Image API\nexport {isImageTypeSupported, getDefaultImageType} from './lib/category-api/image-type';\n\nexport {\n isImage,\n getImageType,\n getImageSize,\n getImageData\n} from './lib/category-api/parsed-image-api';\n\n// EXPERIMENTAL\nexport {getSupportedImageFormats} from './lib/category-api/image-format';\nexport {isImageFormatSupported} from './lib/category-api/image-format';\n\n// REMOVED\n/** @deprecated Temporary placeholder to prevent builds from breaking */\nexport function loadImage() {\n throw new Error('loadImage has moved to @loaders.gl/textures');\n}\n"],"mappings":"SAKQA,WAAW;AAAA,SACXC,WAAW;AAAA,SAKXC,sBAAsB;AAAA,SAGtBC,oBAAoB,EAAEC,mBAAmB;AAAA,SAG/CC,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,YAAY;AAAA,SAINC,wBAAwB;AAAA,SACxBC,sBAAsB;AAI9B,OAAO,SAASC,SAASA,CAAA,EAAG;EAC1B,MAAM,IAAIC,KAAK,CAAC,6CAA6C,CAAC;AAChE"}
@@ -1 +1 @@
1
- {"version":3,"file":"image-format.d.ts","sourceRoot":"","sources":["../../../src/lib/category-api/image-format.ts"],"names":[],"mappings":"AAqBA,+FAA+F;AAC/F,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAgBrE;AAKD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQhE"}
1
+ {"version":3,"file":"image-format.d.ts","sourceRoot":"","sources":["../../../src/lib/category-api/image-format.ts"],"names":[],"mappings":"AAsBA,+FAA+F;AAC/F,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAgBrE;AAKD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"image-format.js","names":["isBrowser","MIME_TYPES","mimeTypeSupportedPromise","getSupportedImageFormats","supportedMimeTypes","Set","mimeType","supported","checkBrowserImageFormatSupportAsync","checkNodeImageFormatSupport","add","mimeTypeSupportedSync","isImageFormatSupported","undefined","checkBrowserImageFormatSupport","_globalThis$loaders","_globalThis$loaders2","NODE_FORMAT_SUPPORT","imageFormatsNode","globalThis","loaders","parseImageNode","Boolean","includes","testBrowserImageFormatSupport","TEST_IMAGE","dataURL","testBrowserImageFormatSupportAsync","element","document","createElement","toDataURL","indexOf","testImageDataURL","Promise","resolve","image","Image","src","onload","height","onerror"],"sources":["../../../src/lib/category-api/image-format.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {isBrowser} from '@loaders.gl/loader-utils';\n\nconst MIME_TYPES = [\n 'image/png',\n 'image/jpeg',\n 'image/gif',\n 'image/webp',\n 'image/avif',\n 'image/tiff',\n // TODO - what is the correct type for SVG\n 'image/svg',\n 'image/svg+xml',\n 'image/bmp',\n 'image/vnd.microsoft.icon'\n];\n\n/** Only one round of tests is performed */\nconst mimeTypeSupportedPromise: Promise<Set<string>> | null = null;\n\n/** Run-time browser detection of file formats requires async tests for most precise results */\nexport async function getSupportedImageFormats(): Promise<Set<string>> {\n if (mimeTypeSupportedPromise) {\n return await mimeTypeSupportedPromise;\n }\n\n const supportedMimeTypes = new Set<string>();\n for (const mimeType of MIME_TYPES) {\n const supported = isBrowser\n ? await checkBrowserImageFormatSupportAsync(mimeType)\n : checkNodeImageFormatSupport(mimeType);\n if (supported) {\n supportedMimeTypes.add(mimeType);\n }\n }\n\n return supportedMimeTypes;\n}\n\n/** Cache sync values for speed */\nconst mimeTypeSupportedSync: {[mimeType: string]: boolean} = {};\n\n/**\n * Check if image MIME type is supported. Result is cached to avoid repeated tests.\n */\nexport function isImageFormatSupported(mimeType: string): boolean {\n if (mimeTypeSupportedSync[mimeType] === undefined) {\n const supported = isBrowser\n ? checkBrowserImageFormatSupport(mimeType)\n : checkNodeImageFormatSupport(mimeType);\n mimeTypeSupportedSync[mimeType] = supported;\n }\n return mimeTypeSupportedSync[mimeType];\n}\n\n/**\n * Checks that polyfills are installed and that mimeType is supported by polyfills\n * @todo Ideally polyfills should declare what formats they support, instead of storing that data here.\n */\nfunction checkNodeImageFormatSupport(mimeType: string): boolean {\n const NODE_FORMAT_SUPPORT = ['image/png', 'image/jpeg', 'image/gif'];\n const imageFormatsNode = globalThis.loaders?.imageFormatsNode || NODE_FORMAT_SUPPORT;\n const parseImageNode = globalThis.loaders?.parseImageNode;\n return Boolean(parseImageNode) && imageFormatsNode.includes(mimeType);\n}\n\n/** Checks image format support synchronously.\n * @note Unreliable, fails on AVIF\n */\nfunction checkBrowserImageFormatSupport(mimeType: string): boolean {\n switch (mimeType) {\n case 'image/avif': // Will fail\n case 'image/webp':\n return testBrowserImageFormatSupport(mimeType);\n default:\n return true;\n }\n}\n\nconst TEST_IMAGE = {\n 'image/avif':\n 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=',\n // Lossy test image. Support for lossy images doesn't guarantee support for all WebP images.\n 'image/webp': 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA'\n};\n\n/** Checks WebP and AVIF support asynchronously */\nasync function checkBrowserImageFormatSupportAsync(mimeType: string): Promise<boolean> {\n const dataURL = TEST_IMAGE[mimeType];\n return dataURL ? await testBrowserImageFormatSupportAsync(dataURL) : true;\n}\n\n/**\n * Checks browser synchronously\n * Checks if toDataURL supports the mimeType.\n * @note Imperfect testOn Chrome this is true for WebP but not for AVIF\n */\nfunction testBrowserImageFormatSupport(mimeType: string): boolean {\n try {\n const element = document.createElement('canvas');\n const dataURL = element.toDataURL(mimeType);\n return dataURL.indexOf(`data:${mimeType}`) === 0;\n } catch {\n // Probably Safari...\n return false;\n }\n}\n\n// Check WebPSupport asynchronously\nasync function testBrowserImageFormatSupportAsync(testImageDataURL: string): Promise<boolean> {\n return new Promise((resolve) => {\n const image = new Image();\n image.src = testImageDataURL;\n image.onload = () => resolve(image.height > 0);\n image.onerror = () => resolve(false);\n });\n}\n"],"mappings":"AAEA,SAAQA,SAAS,QAAO,0BAA0B;AAElD,MAAMC,UAAU,GAAG,CACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EAEZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,0BAA0B,CAC3B;AAGD,MAAMC,wBAAqD,GAAG,IAAI;AAGlE,OAAO,eAAeC,wBAAwBA,CAAA,EAAyB;EACrE,IAAID,wBAAwB,EAAE;IAC5B,OAAO,MAAMA,wBAAwB;EACvC;EAEA,MAAME,kBAAkB,GAAG,IA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A6B,CAAClB,QAAQ,CAAC;IAChD;MACE,OAAO,IAAI;EACf;AACF;AAEA,MAAMmB,UAAU,GAAG;EACjB,YAAY,EACV,ybAAyb;EAE3b,YAAY,EAAE;AAChB,CAAC;AAGD,eAAejB,mCAAmCA,CAACF,QAAgB,EAAoB;EACrF,MAAMoB,OAAO,GAAGD,UAAU,CAACnB,QAAQ,CAAC;EACpC,OAAOoB,OAAO,GAAG,MAAMC,kCAAkC,CAACD,OAAO,CAAC,GAAG,IAAI;AAC3E;AAOA,SAASF,6BAA6BA,CAAClB,QAAgB,EAAW;EAChE,IAAI;IACF,MAAMsB,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;IAChD,MAAMJ,OAAO,GAAGE,OAAO,CAACG,SAAS,CAACzB,QAAQ,CAAC;IAC3C,OAAOoB,OAAO,CAACM,OAAO,CAAE,QAAO1B,QAAS,EAAC,CAAC,KAAK,CAAC;EAClD,CAAC,CAAC,MAAM;IAEN,OAAO,KAAK;EACd;AACF;AAGA,eAAeqB,kCAAkCA,CAACM,gBAAwB,EAAoB;EAC5F,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,CAAC;IACzBD,KAAK,CAACE,GAAG,GAAGL,gBAAgB;IAC5BG,KAAK,CAACG,MAAM,GAAG,MAAMJ,OAAO,CAACC,KAAK,CAACI,MAAM,GAAG,CAAC,CAAC;IAC9CJ,KAAK,CAACK,OAAO,GAAG,MAAMN,OAAO,CAAC,KAAK,CAAC;EACtC,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"image-format.js","names":["isBrowser","MIME_TYPES","mimeTypeSupportedPromise","getSupportedImageFormats","supportedMimeTypes","Set","mimeType","supported","checkBrowserImageFormatSupportAsync","checkNodeImageFormatSupport","add","mimeTypeSupportedSync","isImageFormatSupported","undefined","checkBrowserImageFormatSupport","_globalThis$loaders","_globalThis$loaders2","NODE_FORMAT_SUPPORT","imageFormatsNode","globalThis","loaders","parseImageNode","Boolean","includes","testBrowserImageFormatSupport","TEST_IMAGE","dataURL","testBrowserImageFormatSupportAsync","element","document","createElement","toDataURL","indexOf","testImageDataURL","Promise","resolve","image","Image","src","onload","height","onerror"],"sources":["../../../src/lib/category-api/image-format.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {isBrowser} from '@loaders.gl/loader-utils';\n\nconst MIME_TYPES = [\n 'image/png',\n 'image/jpeg',\n 'image/gif',\n 'image/webp',\n 'image/avif',\n 'image/tiff',\n // TODO - what is the correct type for SVG\n 'image/svg',\n 'image/svg+xml',\n 'image/bmp',\n 'image/vnd.microsoft.icon'\n];\n\n/** Only one round of tests is performed */\nconst mimeTypeSupportedPromise: Promise<Set<string>> | null = null;\n\n/** Run-time browser detection of file formats requires async tests for most precise results */\nexport async function getSupportedImageFormats(): Promise<Set<string>> {\n if (mimeTypeSupportedPromise) {\n return await mimeTypeSupportedPromise;\n }\n\n const supportedMimeTypes = new Set<string>();\n for (const mimeType of MIME_TYPES) {\n const supported = isBrowser\n ? await checkBrowserImageFormatSupportAsync(mimeType)\n : checkNodeImageFormatSupport(mimeType);\n if (supported) {\n supportedMimeTypes.add(mimeType);\n }\n }\n\n return supportedMimeTypes;\n}\n\n/** Cache sync values for speed */\nconst mimeTypeSupportedSync: {[mimeType: string]: boolean} = {};\n\n/**\n * Check if image MIME type is supported. Result is cached to avoid repeated tests.\n */\nexport function isImageFormatSupported(mimeType: string): boolean {\n if (mimeTypeSupportedSync[mimeType] === undefined) {\n const supported = isBrowser\n ? checkBrowserImageFormatSupport(mimeType)\n : checkNodeImageFormatSupport(mimeType);\n mimeTypeSupportedSync[mimeType] = supported;\n }\n return mimeTypeSupportedSync[mimeType];\n}\n\n/**\n * Checks that polyfills are installed and that mimeType is supported by polyfills\n * @todo Ideally polyfills should declare what formats they support, instead of storing that data here.\n */\nfunction checkNodeImageFormatSupport(mimeType: string): boolean {\n const NODE_FORMAT_SUPPORT = ['image/png', 'image/jpeg', 'image/gif'];\n const imageFormatsNode = globalThis.loaders?.imageFormatsNode || NODE_FORMAT_SUPPORT;\n const parseImageNode = globalThis.loaders?.parseImageNode;\n return Boolean(parseImageNode) && imageFormatsNode.includes(mimeType);\n}\n\n/** Checks image format support synchronously.\n * @note Unreliable, fails on AVIF\n */\nfunction checkBrowserImageFormatSupport(mimeType: string): boolean {\n switch (mimeType) {\n case 'image/avif': // Will fail\n case 'image/webp':\n return testBrowserImageFormatSupport(mimeType);\n default:\n return true;\n }\n}\n\nconst TEST_IMAGE = {\n 'image/avif':\n 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=',\n // Lossy test image. Support for lossy images doesn't guarantee support for all WebP images.\n 'image/webp': 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA'\n};\n\n/** Checks WebP and AVIF support asynchronously */\nasync function checkBrowserImageFormatSupportAsync(mimeType: string): Promise<boolean> {\n const dataURL = TEST_IMAGE[mimeType];\n return dataURL ? await testBrowserImageFormatSupportAsync(dataURL) : true;\n}\n\n/**\n * Checks browser synchronously\n * Checks if toDataURL supports the mimeType.\n * @note Imperfect testOn Chrome this is true for WebP but not for AVIF\n */\nfunction testBrowserImageFormatSupport(mimeType: string): boolean {\n try {\n const element = document.createElement('canvas');\n const dataURL = element.toDataURL(mimeType);\n return dataURL.indexOf(`data:${mimeType}`) === 0;\n } catch {\n // Probably Safari...\n return false;\n }\n}\n\n// Check WebPSupport asynchronously\nasync function testBrowserImageFormatSupportAsync(testImageDataURL: string): Promise<boolean> {\n return new Promise((resolve) => {\n const image = new Image();\n image.src = testImageDataURL;\n image.onload = () => resolve(image.height > 0);\n image.onerror = () => resolve(false);\n });\n}\n"],"mappings":"AAGA,SAAQA,SAAS,QAAO,0BAA0B;AAElD,MAAMC,UAAU,GAAG,CACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EAEZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,0BAA0B,CAC3B;AAGD,MAAMC,wBAAqD,GAAG,IAAI;AAGlE,OAAO,eAAeC,wBAAwBA,CAAA,EAAyB;EACrE,IAAID,wBAAwB,EAAE;IAC5B,OAAO,MAAMA,wBAAwB;EACvC;EAEA,MAAME,kBAAkB,GAAG,IAAIC,GAAG,CAAS,CAAC;EAC5C,KAAK,MAAMC,QAAQ,IAAIL,UAAU,EAAE;IACjC,MAAMM,SAAS,GAAGP,SAAS,GACvB,MAAMQ,mCAAmC,CAACF,QAAQ,CAAC,GACnDG,2BAA2B,CAACH,QAAQ,CAAC;IACzC,IAAIC,SAAS,EAAE;MACbH,kBAAkB,CAACM,GAAG,CAACJ,QAAQ,CAAC;IAClC;EACF;EAEA,OAAOF,kBAAkB;AAC3B;AAGA,MAAMO,qBAAoD,GAAG,CAAC,CAAC;AAK/D,OAAO,SAASC,sBAAsBA,CAACN,QAAgB,EAAW;EAChE,IAAIK,qBAAqB,CAACL,QAAQ,CAAC,KAAKO,SAAS,EAAE;IACjD,MAAMN,SAAS,GAAGP,SAAS,GACvBc,8BAA8B,CAACR,QAAQ,CAAC,GACxCG,2BAA2B,CAACH,QAAQ,CAAC;IACzCK,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B,QAAS,EAAC,CAAC,KAAK,CAAC;EAClD,CAAC,CAAC,MAAM;IAEN,OAAO,KAAK;EACd;AACF;AAGA,eAAeqB,kCAAkCA,CAACM,gBAAwB,EAAoB;EAC5F,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,CAAC;IACzBD,KAAK,CAACE,GAAG,GAAGL,gBAAgB;IAC5BG,KAAK,CAACG,MAAM,GAAG,MAAMJ,OAAO,CAACC,KAAK,CAACI,MAAM,GAAG,CAAC,CAAC;IAC9CJ,KAAK,CAACK,OAAO,GAAG,MAAMN,OAAO,CAAC,KAAK,CAAC;EACtC,CAAC,CAAC;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-isobmff-binary.d.ts","sourceRoot":"","sources":["../../../src/lib/category-api/parse-isobmff-binary.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAa1E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAmDvE"}
1
+ {"version":3,"file":"parse-isobmff-binary.d.ts","sourceRoot":"","sources":["../../../src/lib/category-api/parse-isobmff-binary.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAa1E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAmDvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-isobmff-binary.js","names":["getISOBMFFMediaType","buffer","checkString","decodeMajorBrand","brandMajor","getUTF8String","replace","trim","extension","mimeType","array","start","end","String","fromCharCode","slice","stringToBytes","string","map","character","charCodeAt","header","offset","arguments","length","undefined","headerBytes","i"],"sources":["../../../src/lib/category-api/parse-isobmff-binary.ts"],"sourcesContent":["// loaders.gl, MIT license\n// code adapted from https://github.com/sindresorhus/file-type under MIT license\n\n/**\n * Box is a container format that can contain a variety of media related files,\n * so we want to return information about which type of file is actually contained inside\n */\nexport type BoxFileType = {extension: string; mimeType: string};\n\n/**\n * Tests if a buffer is in ISO base media file format (ISOBMFF) @see https://en.wikipedia.org/wiki/ISO_base_media_file_format\n * (ISOBMFF is a media container standard based on the Apple QuickTime container format)\n */\nexport function getISOBMFFMediaType(buffer: Uint8Array): BoxFileType | null {\n // Almost all ISO base media files start with `ftyp` box. (It's not required to be first, but it's recommended to be.)\n if (!checkString(buffer, 'ftyp', 4)) {\n return null;\n }\n\n // Extra check: test for 8859-1 printable characters (for simplicity, it's a mask which also catches one non-printable character).\n if ((buffer[8] & 0x60) === 0x00) {\n return null;\n }\n\n // `ftyp` box must contain a brand major identifier, which must consist of ISO 8859-1 printable characters.\n return decodeMajorBrand(buffer);\n}\n\n/**\n * brands explained @see https://github.com/strukturag/libheif/issues/83\n * code adapted from @see https://github.com/sindresorhus/file-type/blob/main/core.js#L489-L492\n */\nexport function decodeMajorBrand(buffer: Uint8Array): BoxFileType | null {\n const brandMajor = getUTF8String(buffer, 8, 12).replace('\\0', ' ').trim();\n\n switch (brandMajor) {\n case 'avif':\n case 'avis':\n return {extension: 'avif', mimeType: 'image/avif'};\n default:\n return null;\n }\n // We don't need these now, but they are easy to add\n // case 'mif1':\n // return {extension: 'heic', mimeType: 'image/heif'};\n // case 'msf1':\n // return {extension: 'heic', mimeType: 'image/heif-sequence'};\n // case 'heic':\n // case 'heix':\n // return {extension: 'heic', mimeType: 'image/heic'};\n // case 'hevc':\n // case 'hevx':\n // return {extension: 'heic', mimeType: 'image/heic-sequence'};\n // case 'qt':\n // return {ext: 'mov', mime: 'video/quicktime'};\n // case 'M4V':\n // case 'M4VH':\n // case 'M4VP':\n // return {ext: 'm4v', mime: 'video/x-m4v'};\n // case 'M4P':\n // return {ext: 'm4p', mime: 'video/mp4'};\n // case 'M4B':\n // return {ext: 'm4b', mime: 'audio/mp4'};\n // case 'M4A':\n // return {ext: 'm4a', mime: 'audio/x-m4a'};\n // case 'F4V':\n // return {ext: 'f4v', mime: 'video/mp4'};\n // case 'F4P':\n // return {ext: 'f4p', mime: 'video/mp4'};\n // case 'F4A':\n // return {ext: 'f4a', mime: 'audio/mp4'};\n // case 'F4B':\n // return {ext: 'f4b', mime: 'audio/mp4'};\n // case 'crx':\n // return {ext: 'cr3', mime: 'image/x-canon-cr3'};\n // default:\n // if (brandMajor.startsWith('3g')) {\n // if (brandMajor.startsWith('3g2')) {\n // return {ext: '3g2', mime: 'video/3gpp2'};\n // }\n // return {ext: '3gp', mime: 'video/3gpp'};\n // }\n // return {ext: 'mp4', mime: 'video/mp4'};\n}\n\n/** Interpret a chunk of bytes as a UTF8 string */\nfunction getUTF8String(array: Uint8Array, start: number, end: number): string {\n return String.fromCharCode(...array.slice(start, end));\n}\n\nfunction stringToBytes(string: string): number[] {\n return [...string].map((character) => character.charCodeAt(0));\n}\n\nfunction checkString(buffer: ArrayLike<number>, header: string, offset: number = 0): boolean {\n const headerBytes = stringToBytes(header);\n\n for (let i = 0; i < headerBytes.length; ++i) {\n if (headerBytes[i] !== buffer[i + offset]) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":"AAaA,OAAO,SAASA,mBAAmBA,CAACC,MAAkB,EAAsB;EAE1E,IAAI,CAACC,WAAW,CAACD,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE;IACnC,OAAO,IAAI;EACb;EAGA,IAAI,CAACA,MAAM,CAAC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AAI;AACb"}
1
+ {"version":3,"file":"parse-isobmff-binary.js","names":["getISOBMFFMediaType","buffer","checkString","decodeMajorBrand","brandMajor","getUTF8String","replace","trim","extension","mimeType","array","start","end","String","fromCharCode","slice","stringToBytes","string","map","character","charCodeAt","header","offset","arguments","length","undefined","headerBytes","i"],"sources":["../../../src/lib/category-api/parse-isobmff-binary.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n// code adapted from https://github.com/sindresorhus/file-type under MIT license\n\n/**\n * Box is a container format that can contain a variety of media related files,\n * so we want to return information about which type of file is actually contained inside\n */\nexport type BoxFileType = {extension: string; mimeType: string};\n\n/**\n * Tests if a buffer is in ISO base media file format (ISOBMFF) @see https://en.wikipedia.org/wiki/ISO_base_media_file_format\n * (ISOBMFF is a media container standard based on the Apple QuickTime container format)\n */\nexport function getISOBMFFMediaType(buffer: Uint8Array): BoxFileType | null {\n // Almost all ISO base media files start with `ftyp` box. (It's not required to be first, but it's recommended to be.)\n if (!checkString(buffer, 'ftyp', 4)) {\n return null;\n }\n\n // Extra check: test for 8859-1 printable characters (for simplicity, it's a mask which also catches one non-printable character).\n if ((buffer[8] & 0x60) === 0x00) {\n return null;\n }\n\n // `ftyp` box must contain a brand major identifier, which must consist of ISO 8859-1 printable characters.\n return decodeMajorBrand(buffer);\n}\n\n/**\n * brands explained @see https://github.com/strukturag/libheif/issues/83\n * code adapted from @see https://github.com/sindresorhus/file-type/blob/main/core.js#L489-L492\n */\nexport function decodeMajorBrand(buffer: Uint8Array): BoxFileType | null {\n const brandMajor = getUTF8String(buffer, 8, 12).replace('\\0', ' ').trim();\n\n switch (brandMajor) {\n case 'avif':\n case 'avis':\n return {extension: 'avif', mimeType: 'image/avif'};\n default:\n return null;\n }\n // We don't need these now, but they are easy to add\n // case 'mif1':\n // return {extension: 'heic', mimeType: 'image/heif'};\n // case 'msf1':\n // return {extension: 'heic', mimeType: 'image/heif-sequence'};\n // case 'heic':\n // case 'heix':\n // return {extension: 'heic', mimeType: 'image/heic'};\n // case 'hevc':\n // case 'hevx':\n // return {extension: 'heic', mimeType: 'image/heic-sequence'};\n // case 'qt':\n // return {ext: 'mov', mime: 'video/quicktime'};\n // case 'M4V':\n // case 'M4VH':\n // case 'M4VP':\n // return {ext: 'm4v', mime: 'video/x-m4v'};\n // case 'M4P':\n // return {ext: 'm4p', mime: 'video/mp4'};\n // case 'M4B':\n // return {ext: 'm4b', mime: 'audio/mp4'};\n // case 'M4A':\n // return {ext: 'm4a', mime: 'audio/x-m4a'};\n // case 'F4V':\n // return {ext: 'f4v', mime: 'video/mp4'};\n // case 'F4P':\n // return {ext: 'f4p', mime: 'video/mp4'};\n // case 'F4A':\n // return {ext: 'f4a', mime: 'audio/mp4'};\n // case 'F4B':\n // return {ext: 'f4b', mime: 'audio/mp4'};\n // case 'crx':\n // return {ext: 'cr3', mime: 'image/x-canon-cr3'};\n // default:\n // if (brandMajor.startsWith('3g')) {\n // if (brandMajor.startsWith('3g2')) {\n // return {ext: '3g2', mime: 'video/3gpp2'};\n // }\n // return {ext: '3gp', mime: 'video/3gpp'};\n // }\n // return {ext: 'mp4', mime: 'video/mp4'};\n}\n\n/** Interpret a chunk of bytes as a UTF8 string */\nfunction getUTF8String(array: Uint8Array, start: number, end: number): string {\n return String.fromCharCode(...array.slice(start, end));\n}\n\nfunction stringToBytes(string: string): number[] {\n return [...string].map((character) => character.charCodeAt(0));\n}\n\nfunction checkString(buffer: ArrayLike<number>, header: string, offset: number = 0): boolean {\n const headerBytes = stringToBytes(header);\n\n for (let i = 0; i < headerBytes.length; ++i) {\n if (headerBytes[i] !== buffer[i + offset]) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":"AAcA,OAAO,SAASA,mBAAmBA,CAACC,MAAkB,EAAsB;EAE1E,IAAI,CAACC,WAAW,CAACD,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE;IACnC,OAAO,IAAI;EACb;EAGA,IAAI,CAACA,MAAM,CAAC,CAAC,CAA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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/images",
3
- "version": "4.0.0-beta.6",
3
+ "version": "4.0.0-beta.8",
4
4
  "description": "Framework-independent loaders and writers for images (PNG, JPG, ...)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,9 +40,9 @@
40
40
  "build-bundle": "ocular-bundle ./src/index.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@loaders.gl/loader-utils": "4.0.0-beta.6"
43
+ "@loaders.gl/loader-utils": "4.0.0-beta.8"
44
44
  },
45
- "gitHead": "2840f605b7a551e2ffef5f960231d989a0414c50",
45
+ "gitHead": "ec3d1747b4c01c52a235455d6462680e711b4e19",
46
46
  "devDependencies": {
47
47
  "@types/get-pixels": "^3.3.2"
48
48
  }
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  import type {Writer, WriterOptions} from '@loaders.gl/loader-utils';
4
5
  import type {ImageDataType} from './types';
package/src/index.ts CHANGED
@@ -24,3 +24,9 @@ export {
24
24
  // EXPERIMENTAL
25
25
  export {getSupportedImageFormats} from './lib/category-api/image-format';
26
26
  export {isImageFormatSupported} from './lib/category-api/image-format';
27
+
28
+ // REMOVED
29
+ /** @deprecated Temporary placeholder to prevent builds from breaking */
30
+ export function loadImage() {
31
+ throw new Error('loadImage has moved to @loaders.gl/textures');
32
+ }
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  import {isBrowser} from '@loaders.gl/loader-utils';
4
5
 
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
  // code adapted from https://github.com/sindresorhus/file-type under MIT license
3
4
 
4
5
  /**