@edifice.io/utilities 2.0.0-develop-rc.15

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 (50) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +19 -0
  3. package/dist/add-timestamp-to-url/add-timestamp-to-url.cjs +1 -0
  4. package/dist/add-timestamp-to-url/add-timestamp-to-url.d.ts +6 -0
  5. package/dist/add-timestamp-to-url/add-timestamp-to-url.js +7 -0
  6. package/dist/add-timestamp-to-url/index.d.ts +1 -0
  7. package/dist/custom-size/custom-size.cjs +1 -0
  8. package/dist/custom-size/custom-size.d.ts +1 -0
  9. package/dist/custom-size/custom-size.js +8 -0
  10. package/dist/custom-size/index.d.ts +1 -0
  11. package/dist/get-or-generate-blobId/get-or-generate-blobId.cjs +1 -0
  12. package/dist/get-or-generate-blobId/get-or-generate-blobId.d.ts +9 -0
  13. package/dist/get-or-generate-blobId/get-or-generate-blobId.js +15 -0
  14. package/dist/get-or-generate-blobId/index.d.ts +1 -0
  15. package/dist/get-thumbnail/get-thumbnail.cjs +1 -0
  16. package/dist/get-thumbnail/get-thumbnail.d.ts +8 -0
  17. package/dist/get-thumbnail/get-thumbnail.js +6 -0
  18. package/dist/get-thumbnail/index.d.ts +1 -0
  19. package/dist/image-resizer/image-resizer.cjs +1 -0
  20. package/dist/image-resizer/image-resizer.d.ts +45 -0
  21. package/dist/image-resizer/image-resizer.js +96 -0
  22. package/dist/image-resizer/index.d.ts +1 -0
  23. package/dist/index.cjs +1 -0
  24. package/dist/index.d.ts +11 -0
  25. package/dist/index.js +25 -0
  26. package/dist/library-maps/index.d.ts +1 -0
  27. package/dist/library-maps/library-maps.cjs +1 -0
  28. package/dist/library-maps/library-maps.d.ts +4 -0
  29. package/dist/library-maps/library-maps.js +12 -0
  30. package/dist/mime-type-utils/index.d.ts +1 -0
  31. package/dist/mime-type-utils/mime-type-utils.cjs +1 -0
  32. package/dist/mime-type-utils/mime-type-utils.d.ts +22 -0
  33. package/dist/mime-type-utils/mime-type-utils.js +145 -0
  34. package/dist/noop/index.d.ts +1 -0
  35. package/dist/noop/noop.cjs +1 -0
  36. package/dist/noop/noop.d.ts +4 -0
  37. package/dist/noop/noop.js +5 -0
  38. package/dist/string-utils/index.d.ts +1 -0
  39. package/dist/string-utils/string-utils.cjs +1 -0
  40. package/dist/string-utils/string-utils.d.ts +6 -0
  41. package/dist/string-utils/string-utils.js +17 -0
  42. package/dist/time/index.d.ts +1 -0
  43. package/dist/time/time.cjs +1 -0
  44. package/dist/time/time.d.ts +2 -0
  45. package/dist/time/time.js +11 -0
  46. package/dist/video/index.d.ts +1 -0
  47. package/dist/video/video.cjs +1 -0
  48. package/dist/video/video.d.ts +1 -0
  49. package/dist/video/video.js +9 -0
  50. package/package.json +44 -0
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function m(e){const t=new Date().getTime(),a=e.includes("?")?"&":"?";return`${e}${a}timestamp=${t}`}exports.addTimestampToImageUrl=m;
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * @param imageUrl : string
4
+ * @returns workspace file path with timestamp
5
+ */
6
+ export declare function addTimestampToImageUrl(imageUrl: string): string;
@@ -0,0 +1,7 @@
1
+ function m(t) {
2
+ const e = (/* @__PURE__ */ new Date()).getTime(), a = t.includes("?") ? "&" : "?";
3
+ return `${t}${a}timestamp=${e}`;
4
+ }
5
+ export {
6
+ m as addTimestampToImageUrl
7
+ };
@@ -0,0 +1 @@
1
+ export * from './add-timestamp-to-url';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(o,r)=>{if(o==0)return"0 octets";const t=1e3,i=r||2,s=["octets","Ko","Mo","Go"],e=Math.floor(Math.log(o)/Math.log(t));return parseFloat((o/Math.pow(t,e)).toFixed(i))+" "+s[e]};exports.customSize=a;
@@ -0,0 +1 @@
1
+ export declare const customSize: (bytes: number, decimalPoint: number) => string;
@@ -0,0 +1,8 @@
1
+ const c = (o, r) => {
2
+ if (o == 0) return "0 octets";
3
+ const t = 1e3, a = r || 2, s = ["octets", "Ko", "Mo", "Go"], e = Math.floor(Math.log(o) / Math.log(t));
4
+ return parseFloat((o / Math.pow(t, e)).toFixed(a)) + " " + s[e];
5
+ };
6
+ export {
7
+ c as customSize
8
+ };
@@ -0,0 +1 @@
1
+ export * from './custom-size';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../string-utils/string-utils.cjs"),a=(e,r)=>{const t="virtualID";if(!Object.hasOwnProperty.apply(e,[t])){const i=r??`${n.StringUtils.generateVirtualId()}#${e.size}`;Object.defineProperty(e,t,{value:i,writable:!1})}return e[t]};exports.getOrGenerateBlobId=a;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get or generate a virtual ID for a blob object.
3
+ * Virtual ID is immutable once generated.
4
+ *
5
+ * @param blob the Blob or File
6
+ * @param id (optional) Use this ID instead of generating one the first time.
7
+ * @return the blog virtual ID
8
+ */
9
+ export declare const getOrGenerateBlobId: (blob: Blob | File, id?: string) => any;
@@ -0,0 +1,15 @@
1
+ import { StringUtils as i } from "../string-utils/string-utils.js";
2
+ const s = (e, r) => {
3
+ const t = "virtualID";
4
+ if (!Object.hasOwnProperty.apply(e, [t])) {
5
+ const a = r ?? `${i.generateVirtualId()}#${e.size}`;
6
+ Object.defineProperty(e, t, {
7
+ value: a,
8
+ writable: !1
9
+ });
10
+ }
11
+ return e[t];
12
+ };
13
+ export {
14
+ s as getOrGenerateBlobId
15
+ };
@@ -0,0 +1 @@
1
+ export * from './get-or-generate-blobId';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e,i=0,t=0){return!e.includes("data:image")&&!e.includes("thumbnail")&&(e=e+(e.includes("?")?"&thumbnail=":"?thumbnail=")+`${i}x${t}`),e}exports.getThumbnail=n;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get the thumbnail query string for an image source
3
+ * @param src Image source
4
+ * @param width Width of the thumbnail (0 if you when to keep the aspect ratio and only set the height)
5
+ * @param height Height of the thumbnail (0 if you when to keep the aspect ratio and only set the width)
6
+ * @returns Image source with the thumbnail query string
7
+ */
8
+ export declare function getThumbnail(src: string, width?: number, height?: number): string;
@@ -0,0 +1,6 @@
1
+ function t(i, n = 0, u = 0) {
2
+ return !i.includes("data:image") && !i.includes("thumbnail") && (i = i + (i.includes("?") ? "&thumbnail=" : "?thumbnail=") + `${n}x${u}`), i;
3
+ }
4
+ export {
5
+ t as getThumbnail
6
+ };
@@ -0,0 +1 @@
1
+ export * from './get-thumbnail';
@@ -0,0 +1 @@
1
+ "use strict";class p{static changeDimension(e,n,t,r){return t>r&&(e=Math.round(e*r/t),t=r),e>n&&(t=Math.round(t*n/e),e=n),{height:e,width:t}}static renameFileNameExtension(e,n){const t=e.split(".");return t.pop(),t.join(".")+"."+n}static resizeImage(e,n,t,r,o="jpeg",g=80){const a=g/100,i=document.createElement("canvas"),l=`image/${o}`;let c=e.width,m=e.height;const h=this.changeDimension(m,r,c,t);c=h.width,m=h.height;const s=i.getContext("2d");return s&&(i.width=c,i.height=m,s.fillStyle="white",s.fillRect(0,0,i.width,i.height),s.imageSmoothingEnabled&&s.imageSmoothingQuality&&(s.imageSmoothingQuality="high"),s.drawImage(e,0,0,c,m)),new Promise((w,d)=>{i.toBlob(u=>{u?w(new File([u],n,{type:l,lastModified:new Date().getTime()})):d()},l,a)})}static async resizeImageFile(e,n=1440,t=1440,r=80){if(!e)throw Error("Image resizer: file not found!");if(!e.type||!e.type.startsWith("image/"))throw Error("Image resizer: the file given is not an image.");const o="jpeg";return new Promise(g=>{const a=new Image;a.setAttribute("style","max-width: none;"),a.src=URL.createObjectURL(e),a.onload=async()=>{const i=await this.resizeImage(a,this.renameFileNameExtension(e.name,o),n,t,o,r);g(i)},a.onerror=i=>{throw Error("Image Loading Error: "+i)}})}}module.exports=p;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * ImageResizer is a utility class that provides methods to resize and compress images.
3
+ */
4
+ export default class ImageResizer {
5
+ /**
6
+ * Adjusts the dimensions of an image to fit within the specified maximum width and height,
7
+ * preserving the aspect ratio.
8
+ *
9
+ * @param height - The original height of the image.
10
+ * @param maxHeight - The maximum allowed height for the image.
11
+ * @param width - The original width of the image.
12
+ * @param maxWidth - The maximum allowed width for the image.
13
+ * @returns An object containing the adjusted height and width of the image.
14
+ */
15
+ private static changeDimension;
16
+ /**
17
+ * Renames the file extension of a given filename.
18
+ *
19
+ * @param filename - The original filename whose extension needs to be changed.
20
+ * @param newExtension - The new extension to be applied to the filename.
21
+ * @returns The filename with the new extension.
22
+ */
23
+ private static renameFileNameExtension;
24
+ /**
25
+ * Resizes an image to the specified dimensions and compresses it to the specified format and quality.
26
+ *
27
+ * @param image - The HTMLImageElement to be resized.
28
+ * @param fileName - The name of the output file.
29
+ * @param maxWidth - The maximum width of the resized image.
30
+ * @param maxHeight - The maximum height of the resized image.
31
+ * @param compressFormat - The format to compress the image to (default is "jpeg").
32
+ * @param quality - The quality of the compressed image, as a percentage (default is 80).
33
+ * @returns A Promise that resolves to a File object containing the resized and compressed image.
34
+ */
35
+ private static resizeImage;
36
+ /**
37
+ * Resize and compress Image File in JPEG format (other format don't work well with canvas.toBlob() with quality parameter)
38
+ * @param file The image file to resize
39
+ * @param maxWidth The maximum width of the resized image
40
+ * @param maxHeight The maximum height of the resized image
41
+ * @param quality The quality of the compressed image
42
+ * @returns The resized image file
43
+ */
44
+ static resizeImageFile(file: File, maxWidth?: number, maxHeight?: number, quality?: number): Promise<File>;
45
+ }
@@ -0,0 +1,96 @@
1
+ class p {
2
+ /**
3
+ * Adjusts the dimensions of an image to fit within the specified maximum width and height,
4
+ * preserving the aspect ratio.
5
+ *
6
+ * @param height - The original height of the image.
7
+ * @param maxHeight - The maximum allowed height for the image.
8
+ * @param width - The original width of the image.
9
+ * @param maxWidth - The maximum allowed width for the image.
10
+ * @returns An object containing the adjusted height and width of the image.
11
+ */
12
+ static changeDimension(e, n, t, a) {
13
+ return t > a && (e = Math.round(e * a / t), t = a), e > n && (t = Math.round(t * n / e), e = n), { height: e, width: t };
14
+ }
15
+ /**
16
+ * Renames the file extension of a given filename.
17
+ *
18
+ * @param filename - The original filename whose extension needs to be changed.
19
+ * @param newExtension - The new extension to be applied to the filename.
20
+ * @returns The filename with the new extension.
21
+ */
22
+ static renameFileNameExtension(e, n) {
23
+ const t = e.split(".");
24
+ return t.pop(), t.join(".") + "." + n;
25
+ }
26
+ /**
27
+ * Resizes an image to the specified dimensions and compresses it to the specified format and quality.
28
+ *
29
+ * @param image - The HTMLImageElement to be resized.
30
+ * @param fileName - The name of the output file.
31
+ * @param maxWidth - The maximum width of the resized image.
32
+ * @param maxHeight - The maximum height of the resized image.
33
+ * @param compressFormat - The format to compress the image to (default is "jpeg").
34
+ * @param quality - The quality of the compressed image, as a percentage (default is 80).
35
+ * @returns A Promise that resolves to a File object containing the resized and compressed image.
36
+ */
37
+ static resizeImage(e, n, t, a, s = "jpeg", g = 80) {
38
+ const r = g / 100, i = document.createElement("canvas"), l = `image/${s}`;
39
+ let c = e.width, m = e.height;
40
+ const h = this.changeDimension(
41
+ m,
42
+ a,
43
+ c,
44
+ t
45
+ );
46
+ c = h.width, m = h.height;
47
+ const o = i.getContext("2d");
48
+ return o && (i.width = c, i.height = m, o.fillStyle = "white", o.fillRect(0, 0, i.width, i.height), o.imageSmoothingEnabled && o.imageSmoothingQuality && (o.imageSmoothingQuality = "high"), o.drawImage(e, 0, 0, c, m)), new Promise((u, w) => {
49
+ i.toBlob(
50
+ (d) => {
51
+ d ? u(
52
+ new File([d], n, {
53
+ type: l,
54
+ lastModified: (/* @__PURE__ */ new Date()).getTime()
55
+ })
56
+ ) : w();
57
+ },
58
+ l,
59
+ r
60
+ );
61
+ });
62
+ }
63
+ /**
64
+ * Resize and compress Image File in JPEG format (other format don't work well with canvas.toBlob() with quality parameter)
65
+ * @param file The image file to resize
66
+ * @param maxWidth The maximum width of the resized image
67
+ * @param maxHeight The maximum height of the resized image
68
+ * @param quality The quality of the compressed image
69
+ * @returns The resized image file
70
+ */
71
+ static async resizeImageFile(e, n = 1440, t = 1440, a = 80) {
72
+ if (!e) throw Error("Image resizer: file not found!");
73
+ if (!e.type || !e.type.startsWith("image/"))
74
+ throw Error("Image resizer: the file given is not an image.");
75
+ const s = "jpeg";
76
+ return new Promise((g) => {
77
+ const r = new Image();
78
+ r.setAttribute("style", "max-width: none;"), r.src = URL.createObjectURL(e), r.onload = async () => {
79
+ const i = await this.resizeImage(
80
+ r,
81
+ this.renameFileNameExtension(e.name, s),
82
+ n,
83
+ t,
84
+ s,
85
+ a
86
+ );
87
+ g(i);
88
+ }, r.onerror = (i) => {
89
+ throw Error("Image Loading Error: " + i);
90
+ };
91
+ });
92
+ }
93
+ }
94
+ export {
95
+ p as default
96
+ };
@@ -0,0 +1 @@
1
+ export { default as ImageResizer } from './image-resizer';
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./add-timestamp-to-url/add-timestamp-to-url.cjs"),r=require("./custom-size/custom-size.cjs"),i=require("./get-or-generate-blobId/get-or-generate-blobId.cjs"),s=require("./get-thumbnail/get-thumbnail.cjs"),o=require("./image-resizer/image-resizer.cjs"),a=require("./library-maps/library-maps.cjs"),n=require("./mime-type-utils/mime-type-utils.cjs"),m=require("./noop/noop.cjs"),u=require("./string-utils/string-utils.cjs"),e=require("./time/time.cjs"),l=require("./video/video.cjs");exports.addTimestampToImageUrl=t.addTimestampToImageUrl;exports.customSize=r.customSize;exports.getOrGenerateBlobId=i.getOrGenerateBlobId;exports.getThumbnail=s.getThumbnail;exports.ImageResizer=o;exports.libraryMaps=a.libraryMaps;exports.MimeTypeUtils=n.MimeTypeUtils;exports.NOOP=m.NOOP;exports.StringUtils=u.StringUtils;exports.convertMsToMS=e.convertMsToMS;exports.padTo2Digits=e.padTo2Digits;exports.getBestSupportedMimeType=l.getBestSupportedMimeType;
@@ -0,0 +1,11 @@
1
+ export * from './add-timestamp-to-url';
2
+ export * from './custom-size';
3
+ export * from './get-or-generate-blobId';
4
+ export * from './get-thumbnail';
5
+ export * from './image-resizer';
6
+ export * from './library-maps';
7
+ export * from './mime-type-utils';
8
+ export * from './noop';
9
+ export * from './string-utils';
10
+ export * from './time';
11
+ export * from './video';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ import { addTimestampToImageUrl as o } from "./add-timestamp-to-url/add-timestamp-to-url.js";
2
+ import { customSize as m } from "./custom-size/custom-size.js";
3
+ import { getOrGenerateBlobId as f } from "./get-or-generate-blobId/get-or-generate-blobId.js";
4
+ import { getThumbnail as a } from "./get-thumbnail/get-thumbnail.js";
5
+ import { default as s } from "./image-resizer/image-resizer.js";
6
+ import { libraryMaps as l } from "./library-maps/library-maps.js";
7
+ import { MimeTypeUtils as d } from "./mime-type-utils/mime-type-utils.js";
8
+ import { NOOP as n } from "./noop/noop.js";
9
+ import { StringUtils as S } from "./string-utils/string-utils.js";
10
+ import { convertMsToMS as y, padTo2Digits as I } from "./time/time.js";
11
+ import { getBestSupportedMimeType as U } from "./video/video.js";
12
+ export {
13
+ s as ImageResizer,
14
+ d as MimeTypeUtils,
15
+ n as NOOP,
16
+ S as StringUtils,
17
+ o as addTimestampToImageUrl,
18
+ y as convertMsToMS,
19
+ m as customSize,
20
+ U as getBestSupportedMimeType,
21
+ f as getOrGenerateBlobId,
22
+ a as getThumbnail,
23
+ l as libraryMaps,
24
+ I as padTo2Digits
25
+ };
@@ -0,0 +1 @@
1
+ export * from './library-maps';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={blog:"Blog",mindmap:"MindMap",scrapbook:"ScrapBook",collaborativewall:"CollaborativeWall",timelinegenerator:"TimelineGenerator",wiki:"Wiki",exercizer:"Exercizer"};exports.libraryMaps=e;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Object literal to find correct app code for Library Webapp
3
+ */
4
+ export declare const libraryMaps: Record<string, string>;
@@ -0,0 +1,12 @@
1
+ const e = {
2
+ blog: "Blog",
3
+ mindmap: "MindMap",
4
+ scrapbook: "ScrapBook",
5
+ collaborativewall: "CollaborativeWall",
6
+ timelinegenerator: "TimelineGenerator",
7
+ wiki: "Wiki",
8
+ exercizer: "Exercizer"
9
+ };
10
+ export {
11
+ e as libraryMaps
12
+ };
@@ -0,0 +1 @@
1
+ export * from './mime-type-utils';
@@ -0,0 +1 @@
1
+ "use strict";var p=Object.defineProperty;var d=(i,t,s)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var n=(i,t,s)=>d(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=class o{constructor(){n(this,"wordExtensions",new Set);n(this,"excelExtensions",new Set);n(this,"pptExtensions",new Set);n(this,"fileExtensionMap",new Map);n(this,"csvContentType",new Set);n(this,"csvExtensions",new Set);n(this,"txtExtensions",new Set);n(this,"mdExtensions",new Set);n(this,"PDF","application/pdf");n(this,"OCTET_STREAM","application/octet-stream");this.txtExtensions.add("txt"),this.mdExtensions.add("md"),this.wordExtensions.add("doc"),this.wordExtensions.add("dot"),this.wordExtensions.add("docx"),this.wordExtensions.add("dotx"),this.wordExtensions.add("docm"),this.wordExtensions.add("dotm"),this.wordExtensions.add("odt"),this.wordExtensions.add("ott"),this.wordExtensions.add("oth"),this.wordExtensions.add("odm"),this.excelExtensions.add("xls"),this.excelExtensions.add("xlt"),this.excelExtensions.add("xla"),this.excelExtensions.add("xlsx"),this.excelExtensions.add("xltx"),this.excelExtensions.add("xlsm"),this.excelExtensions.add("xltm"),this.excelExtensions.add("xlam"),this.excelExtensions.add("xlsb"),this.excelExtensions.add("ods"),this.excelExtensions.add("ots"),this.pptExtensions.add("ppt"),this.pptExtensions.add("pot"),this.pptExtensions.add("pps"),this.pptExtensions.add("ppa"),this.pptExtensions.add("pptx"),this.pptExtensions.add("potx"),this.pptExtensions.add("ppsx"),this.pptExtensions.add("ppam"),this.pptExtensions.add("pptm"),this.pptExtensions.add("potm"),this.pptExtensions.add("ppsm"),this.pptExtensions.add("odp"),this.pptExtensions.add("otp"),this.csvExtensions.add("csv"),this.fileExtensionMap.set("doc","application/msword"),this.fileExtensionMap.set("dot","application/msword"),this.fileExtensionMap.set("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),this.fileExtensionMap.set("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"),this.fileExtensionMap.set("docm","application/vnd.ms-word.document.macroEnabled.12"),this.fileExtensionMap.set("dotm","application/vnd.ms-word.template.macroEnabled.12"),this.fileExtensionMap.set("xls","application/vnd.ms-excel"),this.fileExtensionMap.set("xlt","application/vnd.ms-excel"),this.fileExtensionMap.set("xla","application/vnd.ms-excel"),this.fileExtensionMap.set("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),this.fileExtensionMap.set("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"),this.fileExtensionMap.set("xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"),this.fileExtensionMap.set("xltm","application/vnd.ms-excel.template.macroEnabled.12"),this.fileExtensionMap.set("xlam","application/vnd.ms-excel.addin.macroEnabled.12"),this.fileExtensionMap.set("xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"),this.fileExtensionMap.set("ppt","application/vnd.ms-powerpoint"),this.fileExtensionMap.set("pot","application/vnd.ms-powerpoint"),this.fileExtensionMap.set("pps","application/vnd.ms-powerpoint"),this.fileExtensionMap.set("ppa","application/vnd.ms-powerpoint"),this.fileExtensionMap.set("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),this.fileExtensionMap.set("potx","application/vnd.openxmlformats-officedocument.presentationml.template"),this.fileExtensionMap.set("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),this.fileExtensionMap.set("ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"),this.fileExtensionMap.set("pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),this.fileExtensionMap.set("potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),this.fileExtensionMap.set("ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),this.fileExtensionMap.set("odt","application/vnd.oasis.opendocument.text"),this.fileExtensionMap.set("ott","application/vnd.oasis.opendocument.text-template"),this.fileExtensionMap.set("oth","application/vnd.oasis.opendocument.text-web"),this.fileExtensionMap.set("odm","application/vnd.oasis.opendocument.text-master"),this.fileExtensionMap.set("odg","application/vnd.oasis.opendocument.graphics"),this.fileExtensionMap.set("otg","application/vnd.oasis.opendocument.graphics-template"),this.fileExtensionMap.set("odp","application/vnd.oasis.opendocument.presentation"),this.fileExtensionMap.set("otp","application/vnd.oasis.opendocument.presentation-template"),this.fileExtensionMap.set("ods","application/vnd.oasis.opendocument.spreadsheet"),this.fileExtensionMap.set("ots","application/vnd.oasis.opendocument.spreadsheet-template"),this.fileExtensionMap.set("odc","application/vnd.oasis.opendocument.chart"),this.fileExtensionMap.set("odf","application/vnd.oasis.opendocument.formula"),this.fileExtensionMap.set("odb","application/vnd.oasis.opendocument.database"),this.fileExtensionMap.set("odi","application/vnd.oasis.opendocument.image"),this.fileExtensionMap.set("oxt","application/vnd.openofficeorg.extension"),this.fileExtensionMap.set("txt","text/plain"),this.fileExtensionMap.set("md","text/markdown"),this.csvContentType.add("text/comma-separated-values"),this.csvContentType.add("text/csv"),this.csvContentType.add("application/csv")}getContentTypeForExtension(t){return this.fileExtensionMap.has(t)?this.fileExtensionMap.get(t)??null:null}getExtensionForContentType(t){for(const s of Array.from(this.fileExtensionMap.keys()))if((this.fileExtensionMap.get(s)||"").toLowerCase()==(t||"").toLowerCase())return s;return null}isWordLike(t,s){const e=this.getExtensionForContentType(t);return e?this.wordExtensions.has(e):t==this.OCTET_STREAM&&s?this.wordExtensions.has(s):!1}isExcelLike(t,s){const e=this.getExtensionForContentType(t);return e?this.excelExtensions.has(e):t==this.OCTET_STREAM&&s?this.excelExtensions.has(s):!1}isCsvLike(t,s){return this.csvContentType.has(t)?!0:t==this.OCTET_STREAM&&s?this.csvExtensions.has(s):!1}isPowerpointLike(t,s){const e=this.getExtensionForContentType(t);return e?this.pptExtensions.has(e):t==this.OCTET_STREAM&&s?this.pptExtensions.has(s):!1}isTxtLike(t,s){const e=this.getExtensionForContentType(t);return e?this.txtExtensions.has(e):t==this.OCTET_STREAM&&s?this.txtExtensions.has(s):!1}isMdLike(t,s){const e=this.getExtensionForContentType(t);return e?this.mdExtensions.has(e):t==this.OCTET_STREAM&&s?this.mdExtensions.has(s):!1}};n(o,"INSTANCE",new o);let a=o;exports.MimeTypeUtils=a;
@@ -0,0 +1,22 @@
1
+ export declare class MimeTypeUtils {
2
+ static INSTANCE: MimeTypeUtils;
3
+ private wordExtensions;
4
+ private excelExtensions;
5
+ private pptExtensions;
6
+ private fileExtensionMap;
7
+ private csvContentType;
8
+ private csvExtensions;
9
+ private txtExtensions;
10
+ private mdExtensions;
11
+ PDF: string;
12
+ OCTET_STREAM: string;
13
+ constructor();
14
+ getContentTypeForExtension(extension: string): string | null;
15
+ getExtensionForContentType(contentType: string): string | null;
16
+ isWordLike(contentType: string, originalExt?: string): boolean;
17
+ isExcelLike(contentType: string, originalExt?: string): boolean;
18
+ isCsvLike(contentType: string, originalExt?: string): boolean;
19
+ isPowerpointLike(contentType: string, originalExt?: string): boolean;
20
+ isTxtLike(contentType: string, originalExt?: string): boolean;
21
+ isMdLike(contentType: string, originalExt?: string): boolean;
22
+ }
@@ -0,0 +1,145 @@
1
+ var p = Object.defineProperty;
2
+ var d = (i, t, s) => t in i ? p(i, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[t] = s;
3
+ var n = (i, t, s) => d(i, typeof t != "symbol" ? t + "" : t, s);
4
+ const o = class o {
5
+ constructor() {
6
+ n(this, "wordExtensions", /* @__PURE__ */ new Set());
7
+ n(this, "excelExtensions", /* @__PURE__ */ new Set());
8
+ n(this, "pptExtensions", /* @__PURE__ */ new Set());
9
+ n(this, "fileExtensionMap", /* @__PURE__ */ new Map());
10
+ n(this, "csvContentType", /* @__PURE__ */ new Set());
11
+ n(this, "csvExtensions", /* @__PURE__ */ new Set());
12
+ n(this, "txtExtensions", /* @__PURE__ */ new Set());
13
+ n(this, "mdExtensions", /* @__PURE__ */ new Set());
14
+ n(this, "PDF", "application/pdf");
15
+ n(this, "OCTET_STREAM", "application/octet-stream");
16
+ this.txtExtensions.add("txt"), this.mdExtensions.add("md"), this.wordExtensions.add("doc"), this.wordExtensions.add("dot"), this.wordExtensions.add("docx"), this.wordExtensions.add("dotx"), this.wordExtensions.add("docm"), this.wordExtensions.add("dotm"), this.wordExtensions.add("odt"), this.wordExtensions.add("ott"), this.wordExtensions.add("oth"), this.wordExtensions.add("odm"), this.excelExtensions.add("xls"), this.excelExtensions.add("xlt"), this.excelExtensions.add("xla"), this.excelExtensions.add("xlsx"), this.excelExtensions.add("xltx"), this.excelExtensions.add("xlsm"), this.excelExtensions.add("xltm"), this.excelExtensions.add("xlam"), this.excelExtensions.add("xlsb"), this.excelExtensions.add("ods"), this.excelExtensions.add("ots"), this.pptExtensions.add("ppt"), this.pptExtensions.add("pot"), this.pptExtensions.add("pps"), this.pptExtensions.add("ppa"), this.pptExtensions.add("pptx"), this.pptExtensions.add("potx"), this.pptExtensions.add("ppsx"), this.pptExtensions.add("ppam"), this.pptExtensions.add("pptm"), this.pptExtensions.add("potm"), this.pptExtensions.add("ppsm"), this.pptExtensions.add("odp"), this.pptExtensions.add("otp"), this.csvExtensions.add("csv"), this.fileExtensionMap.set("doc", "application/msword"), this.fileExtensionMap.set("dot", "application/msword"), this.fileExtensionMap.set(
17
+ "docx",
18
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
19
+ ), this.fileExtensionMap.set(
20
+ "dotx",
21
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template"
22
+ ), this.fileExtensionMap.set(
23
+ "docm",
24
+ "application/vnd.ms-word.document.macroEnabled.12"
25
+ ), this.fileExtensionMap.set(
26
+ "dotm",
27
+ "application/vnd.ms-word.template.macroEnabled.12"
28
+ ), this.fileExtensionMap.set("xls", "application/vnd.ms-excel"), this.fileExtensionMap.set("xlt", "application/vnd.ms-excel"), this.fileExtensionMap.set("xla", "application/vnd.ms-excel"), this.fileExtensionMap.set(
29
+ "xlsx",
30
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
31
+ ), this.fileExtensionMap.set(
32
+ "xltx",
33
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template"
34
+ ), this.fileExtensionMap.set(
35
+ "xlsm",
36
+ "application/vnd.ms-excel.sheet.macroEnabled.12"
37
+ ), this.fileExtensionMap.set(
38
+ "xltm",
39
+ "application/vnd.ms-excel.template.macroEnabled.12"
40
+ ), this.fileExtensionMap.set(
41
+ "xlam",
42
+ "application/vnd.ms-excel.addin.macroEnabled.12"
43
+ ), this.fileExtensionMap.set(
44
+ "xlsb",
45
+ "application/vnd.ms-excel.sheet.binary.macroEnabled.12"
46
+ ), this.fileExtensionMap.set("ppt", "application/vnd.ms-powerpoint"), this.fileExtensionMap.set("pot", "application/vnd.ms-powerpoint"), this.fileExtensionMap.set("pps", "application/vnd.ms-powerpoint"), this.fileExtensionMap.set("ppa", "application/vnd.ms-powerpoint"), this.fileExtensionMap.set(
47
+ "pptx",
48
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation"
49
+ ), this.fileExtensionMap.set(
50
+ "potx",
51
+ "application/vnd.openxmlformats-officedocument.presentationml.template"
52
+ ), this.fileExtensionMap.set(
53
+ "ppsx",
54
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow"
55
+ ), this.fileExtensionMap.set(
56
+ "ppam",
57
+ "application/vnd.ms-powerpoint.addin.macroEnabled.12"
58
+ ), this.fileExtensionMap.set(
59
+ "pptm",
60
+ "application/vnd.ms-powerpoint.presentation.macroEnabled.12"
61
+ ), this.fileExtensionMap.set(
62
+ "potm",
63
+ "application/vnd.ms-powerpoint.presentation.macroEnabled.12"
64
+ ), this.fileExtensionMap.set(
65
+ "ppsm",
66
+ "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"
67
+ ), this.fileExtensionMap.set("odt", "application/vnd.oasis.opendocument.text"), this.fileExtensionMap.set(
68
+ "ott",
69
+ "application/vnd.oasis.opendocument.text-template"
70
+ ), this.fileExtensionMap.set(
71
+ "oth",
72
+ "application/vnd.oasis.opendocument.text-web"
73
+ ), this.fileExtensionMap.set(
74
+ "odm",
75
+ "application/vnd.oasis.opendocument.text-master"
76
+ ), this.fileExtensionMap.set(
77
+ "odg",
78
+ "application/vnd.oasis.opendocument.graphics"
79
+ ), this.fileExtensionMap.set(
80
+ "otg",
81
+ "application/vnd.oasis.opendocument.graphics-template"
82
+ ), this.fileExtensionMap.set(
83
+ "odp",
84
+ "application/vnd.oasis.opendocument.presentation"
85
+ ), this.fileExtensionMap.set(
86
+ "otp",
87
+ "application/vnd.oasis.opendocument.presentation-template"
88
+ ), this.fileExtensionMap.set(
89
+ "ods",
90
+ "application/vnd.oasis.opendocument.spreadsheet"
91
+ ), this.fileExtensionMap.set(
92
+ "ots",
93
+ "application/vnd.oasis.opendocument.spreadsheet-template"
94
+ ), this.fileExtensionMap.set(
95
+ "odc",
96
+ "application/vnd.oasis.opendocument.chart"
97
+ ), this.fileExtensionMap.set(
98
+ "odf",
99
+ "application/vnd.oasis.opendocument.formula"
100
+ ), this.fileExtensionMap.set(
101
+ "odb",
102
+ "application/vnd.oasis.opendocument.database"
103
+ ), this.fileExtensionMap.set(
104
+ "odi",
105
+ "application/vnd.oasis.opendocument.image"
106
+ ), this.fileExtensionMap.set("oxt", "application/vnd.openofficeorg.extension"), this.fileExtensionMap.set("txt", "text/plain"), this.fileExtensionMap.set("md", "text/markdown"), this.csvContentType.add("text/comma-separated-values"), this.csvContentType.add("text/csv"), this.csvContentType.add("application/csv");
107
+ }
108
+ getContentTypeForExtension(t) {
109
+ return this.fileExtensionMap.has(t) ? this.fileExtensionMap.get(t) ?? null : null;
110
+ }
111
+ getExtensionForContentType(t) {
112
+ for (const s of Array.from(this.fileExtensionMap.keys()))
113
+ if ((this.fileExtensionMap.get(s) || "").toLowerCase() == (t || "").toLowerCase())
114
+ return s;
115
+ return null;
116
+ }
117
+ isWordLike(t, s) {
118
+ const e = this.getExtensionForContentType(t);
119
+ return e ? this.wordExtensions.has(e) : t == this.OCTET_STREAM && s ? this.wordExtensions.has(s) : !1;
120
+ }
121
+ isExcelLike(t, s) {
122
+ const e = this.getExtensionForContentType(t);
123
+ return e ? this.excelExtensions.has(e) : t == this.OCTET_STREAM && s ? this.excelExtensions.has(s) : !1;
124
+ }
125
+ isCsvLike(t, s) {
126
+ return this.csvContentType.has(t) ? !0 : t == this.OCTET_STREAM && s ? this.csvExtensions.has(s) : !1;
127
+ }
128
+ isPowerpointLike(t, s) {
129
+ const e = this.getExtensionForContentType(t);
130
+ return e ? this.pptExtensions.has(e) : t == this.OCTET_STREAM && s ? this.pptExtensions.has(s) : !1;
131
+ }
132
+ isTxtLike(t, s) {
133
+ const e = this.getExtensionForContentType(t);
134
+ return e ? this.txtExtensions.has(e) : t == this.OCTET_STREAM && s ? this.txtExtensions.has(s) : !1;
135
+ }
136
+ isMdLike(t, s) {
137
+ const e = this.getExtensionForContentType(t);
138
+ return e ? this.mdExtensions.has(e) : t == this.OCTET_STREAM && s ? this.mdExtensions.has(s) : !1;
139
+ }
140
+ };
141
+ n(o, "INSTANCE", new o());
142
+ let a = o;
143
+ export {
144
+ a as MimeTypeUtils
145
+ };
@@ -0,0 +1 @@
1
+ export * from './noop';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=()=>{};exports.NOOP=e;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * No operation function.
3
+ */
4
+ export declare const NOOP: () => void;
@@ -0,0 +1,5 @@
1
+ const o = () => {
2
+ };
3
+ export {
4
+ o as NOOP
5
+ };
@@ -0,0 +1 @@
1
+ export * from './string-utils';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{static isLocalURL(t){return t.length>0&&t.charAt(0)==="/"}static startWithHttp(t){return/^https?:\/\//gi.test(t)}static toCounter(t){return t>999?`${Number(t/1e3).toFixed(1)} k`:""+t}static generateVirtualId(){return"xxxx-xxxx-xxx-xxxx".replace(/[x]/g,()=>Math.floor(Math.random()*16).toString(16))}}exports.StringUtils=r;
@@ -0,0 +1,6 @@
1
+ export declare class StringUtils {
2
+ static isLocalURL(str: string): boolean;
3
+ static startWithHttp(str: string): boolean;
4
+ static toCounter(counter: number): string;
5
+ static generateVirtualId(): string;
6
+ }
@@ -0,0 +1,17 @@
1
+ class s {
2
+ static isLocalURL(t) {
3
+ return t.length > 0 && t.charAt(0) === "/";
4
+ }
5
+ static startWithHttp(t) {
6
+ return /^https?:\/\//gi.test(t);
7
+ }
8
+ static toCounter(t) {
9
+ return t > 999 ? `${Number(t / 1e3).toFixed(1)} k` : "" + t;
10
+ }
11
+ static generateVirtualId() {
12
+ return "xxxx-xxxx-xxx-xxxx".replace(/[x]/g, () => Math.floor(Math.random() * 16).toString(16));
13
+ }
14
+ }
15
+ export {
16
+ s as StringUtils
17
+ };
@@ -0,0 +1 @@
1
+ export * from './time';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=t=>{if(t>0){let o=Math.floor(t/1e3),e=Math.floor(o/60);return o=o%60,e=e%60,r(e)+":"+r(o)}return"00:00"},r=t=>t.toString().padStart(2,"0");exports.convertMsToMS=n;exports.padTo2Digits=r;
@@ -0,0 +1,2 @@
1
+ export declare const convertMsToMS: (milliseconds: number) => string;
2
+ export declare const padTo2Digits: (val: number) => string;
@@ -0,0 +1,11 @@
1
+ const n = (t) => {
2
+ if (t > 0) {
3
+ let r = Math.floor(t / 1e3), o = Math.floor(r / 60);
4
+ return r = r % 60, o = o % 60, e(o) + ":" + e(r);
5
+ }
6
+ return "00:00";
7
+ }, e = (t) => t.toString().padStart(2, "0");
8
+ export {
9
+ n as convertMsToMS,
10
+ e as padTo2Digits
11
+ };
@@ -0,0 +1 @@
1
+ export * from './video';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=()=>MediaRecorder.isTypeSupported?["video/webm;codecs=vp9",'video/mp4; codecs="avc1.424028, mp4a.40.2"',"video/webm;codecs=vp8,opus","video/webm"].find(e=>MediaRecorder.isTypeSupported(e)?!0:(console.error(`${e} is not Supported`),!1))||"video/ogg":"video/webm;codecs=vp8,opus";exports.getBestSupportedMimeType=o;
@@ -0,0 +1 @@
1
+ export declare const getBestSupportedMimeType: () => string;
@@ -0,0 +1,9 @@
1
+ const o = () => MediaRecorder.isTypeSupported ? [
2
+ "video/webm;codecs=vp9",
3
+ 'video/mp4; codecs="avc1.424028, mp4a.40.2"',
4
+ "video/webm;codecs=vp8,opus",
5
+ "video/webm"
6
+ ].find((e) => MediaRecorder.isTypeSupported(e) ? !0 : (console.error(`${e} is not Supported`), !1)) || "video/ogg" : "video/webm;codecs=vp8,opus";
7
+ export {
8
+ o as getBestSupportedMimeType
9
+ };