vgapp 1.1.3 → 1.1.5

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 (54) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +48 -48
  3. package/agents.md +7 -0
  4. package/app/langs/en/buttons.json +17 -17
  5. package/app/langs/en/messages.json +36 -36
  6. package/app/langs/ru/buttons.json +17 -17
  7. package/app/langs/ru/messages.json +36 -36
  8. package/app/modules/vgfilepreview/js/i18n.js +56 -56
  9. package/app/modules/vgfilepreview/js/renderers/image-modal.js +145 -145
  10. package/app/modules/vgfilepreview/js/renderers/image.js +92 -92
  11. package/app/modules/vgfilepreview/js/renderers/index.js +19 -19
  12. package/app/modules/vgfilepreview/js/renderers/office-modal.js +168 -168
  13. package/app/modules/vgfilepreview/js/renderers/office.js +79 -79
  14. package/app/modules/vgfilepreview/js/renderers/pdf-modal.js +260 -260
  15. package/app/modules/vgfilepreview/js/renderers/pdf.js +76 -76
  16. package/app/modules/vgfilepreview/js/renderers/playlist.js +71 -71
  17. package/app/modules/vgfilepreview/js/renderers/text-modal.js +343 -343
  18. package/app/modules/vgfilepreview/js/renderers/text.js +83 -83
  19. package/app/modules/vgfilepreview/js/renderers/video-modal.js +272 -272
  20. package/app/modules/vgfilepreview/js/renderers/video.js +80 -80
  21. package/app/modules/vgfilepreview/js/renderers/zip-modal.js +522 -522
  22. package/app/modules/vgfilepreview/js/renderers/zip.js +89 -89
  23. package/app/modules/vgfilepreview/js/vgfilepreview.js +965 -530
  24. package/app/modules/vgfilepreview/readme.md +68 -68
  25. package/app/modules/vgfilepreview/scss/_variables.scss +113 -113
  26. package/app/modules/vgfilepreview/scss/vgfilepreview.scss +464 -460
  27. package/app/modules/vgfiles/js/base.js +463 -463
  28. package/app/modules/vgfiles/js/droppable.js +260 -260
  29. package/app/modules/vgfiles/js/render.js +153 -153
  30. package/app/modules/vgfiles/js/vgfiles.js +41 -41
  31. package/app/modules/vgfiles/readme.md +123 -123
  32. package/app/modules/vgfiles/scss/_variables.scss +18 -18
  33. package/app/modules/vgfiles/scss/vgfiles.scss +148 -148
  34. package/app/modules/vgformsender/js/vgformsender.js +13 -13
  35. package/app/modules/vgmodal/js/vgmodal.drag.js +332 -0
  36. package/app/modules/vgmodal/js/vgmodal.js +116 -14
  37. package/app/modules/vgmodal/js/vgmodal.resize.js +435 -0
  38. package/app/modules/vgnav/js/vgnav.js +135 -135
  39. package/app/modules/vgnav/readme.md +67 -67
  40. package/app/modules/vgnestable/README.md +307 -307
  41. package/app/modules/vgnestable/scss/_variables.scss +60 -60
  42. package/app/modules/vgnestable/scss/vgnestable.scss +163 -163
  43. package/app/modules/vgselect/js/vgselect.js +39 -39
  44. package/app/modules/vgselect/scss/vgselect.scss +22 -22
  45. package/app/modules/vgspy/readme.md +28 -28
  46. package/app/utils/js/components/audio-metadata.js +240 -240
  47. package/app/utils/js/components/file-icon.js +109 -109
  48. package/app/utils/js/components/file-preview.js +304 -304
  49. package/app/utils/js/components/sanitize.js +150 -150
  50. package/app/utils/js/components/video-metadata.js +140 -0
  51. package/build/vgapp.css +1 -1
  52. package/build/vgapp.css.map +1 -1
  53. package/index.scss +9 -9
  54. package/package.json +1 -1
@@ -1,150 +1,150 @@
1
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2
- const DEFAULT_ALLOWED_SVG_TAGS = new Set([
3
- "svg",
4
- "g",
5
- "path",
6
- "line",
7
- "polyline",
8
- "polygon",
9
- "circle",
10
- "ellipse",
11
- "rect",
12
- "defs",
13
- "symbol",
14
- "title",
15
- "use"
16
- ]);
17
- const DEFAULT_ALLOWED_SVG_ATTRS = new Set([
18
- "xmlns",
19
- "viewbox",
20
- "width",
21
- "height",
22
- "fill",
23
- "stroke",
24
- "stroke-width",
25
- "stroke-linecap",
26
- "stroke-linejoin",
27
- "stroke-miterlimit",
28
- "stroke-dasharray",
29
- "stroke-dashoffset",
30
- "opacity",
31
- "transform",
32
- "class",
33
- "x",
34
- "y",
35
- "x1",
36
- "y1",
37
- "x2",
38
- "y2",
39
- "cx",
40
- "cy",
41
- "r",
42
- "rx",
43
- "ry",
44
- "points",
45
- "d",
46
- "role",
47
- "focusable",
48
- "aria-hidden",
49
- "href",
50
- "xlink:href"
51
- ]);
52
-
53
- function escapeHtml(value) {
54
- return String(value)
55
- .replace(/&/g, "&")
56
- .replace(/</g, "&lt;")
57
- .replace(/>/g, "&gt;")
58
- .replace(/"/g, "&quot;")
59
- .replace(/'/g, "&#39;");
60
- }
61
-
62
- function sanitizeSvgNode(node, allowedTags = DEFAULT_ALLOWED_SVG_TAGS, allowedAttrs = DEFAULT_ALLOWED_SVG_ATTRS) {
63
- if (!node) {
64
- return null;
65
- }
66
-
67
- if (node.nodeType === Node.TEXT_NODE) {
68
- return document.createTextNode(node.textContent || "");
69
- }
70
-
71
- if (node.nodeType !== Node.ELEMENT_NODE) {
72
- return null;
73
- }
74
-
75
- const tagName = node.tagName.toLowerCase();
76
- if (!allowedTags.has(tagName)) {
77
- return null;
78
- }
79
-
80
- const safeNode = document.createElementNS(SVG_NAMESPACE, tagName);
81
-
82
- Array.from(node.attributes || []).forEach((attr) => {
83
- const name = attr.name.toLowerCase();
84
- const attrValue = attr.value || "";
85
-
86
- if (!allowedAttrs.has(name) || name.startsWith("on")) {
87
- return;
88
- }
89
-
90
- if ((name === "href" || name === "xlink:href") && attrValue && !attrValue.startsWith("#")) {
91
- return;
92
- }
93
-
94
- safeNode.setAttribute(name, attrValue);
95
- });
96
-
97
- Array.from(node.childNodes || []).forEach((child) => {
98
- const safeChild = sanitizeSvgNode(child, allowedTags, allowedAttrs);
99
- if (safeChild) {
100
- safeNode.append(safeChild);
101
- }
102
- });
103
-
104
- return safeNode;
105
- }
106
-
107
- export function toSafeHtmlString(value, {
108
- allowedSvgTags = DEFAULT_ALLOWED_SVG_TAGS,
109
- allowedSvgAttrs = DEFAULT_ALLOWED_SVG_ATTRS
110
- } = {}) {
111
- if (value === null || value === undefined) {
112
- return "";
113
- }
114
-
115
- const content = String(value).trim();
116
- if (!content) {
117
- return "";
118
- }
119
-
120
- if (!content.includes("<")) {
121
- return escapeHtml(content);
122
- }
123
-
124
- const template = document.createElement("template");
125
- template.innerHTML = content;
126
-
127
- const sanitizedParts = Array.from(template.content.childNodes)
128
- .map((node) => sanitizeSvgNode(node, allowedSvgTags, allowedSvgAttrs))
129
- .filter(Boolean)
130
- .map((node) => {
131
- if (node.nodeType === Node.TEXT_NODE) {
132
- return escapeHtml(node.textContent || "");
133
- }
134
- if (node.nodeType === Node.ELEMENT_NODE) {
135
- return node.outerHTML;
136
- }
137
- return "";
138
- });
139
-
140
- const sanitized = sanitizedParts.join("");
141
- return sanitized || escapeHtml(content);
142
- }
143
-
144
- class Sanitize {
145
- static toSafeHtmlString(value, options) {
146
- return toSafeHtmlString(value, options);
147
- }
148
- }
149
-
150
- export default Sanitize;
1
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2
+ const DEFAULT_ALLOWED_SVG_TAGS = new Set([
3
+ "svg",
4
+ "g",
5
+ "path",
6
+ "line",
7
+ "polyline",
8
+ "polygon",
9
+ "circle",
10
+ "ellipse",
11
+ "rect",
12
+ "defs",
13
+ "symbol",
14
+ "title",
15
+ "use"
16
+ ]);
17
+ const DEFAULT_ALLOWED_SVG_ATTRS = new Set([
18
+ "xmlns",
19
+ "viewbox",
20
+ "width",
21
+ "height",
22
+ "fill",
23
+ "stroke",
24
+ "stroke-width",
25
+ "stroke-linecap",
26
+ "stroke-linejoin",
27
+ "stroke-miterlimit",
28
+ "stroke-dasharray",
29
+ "stroke-dashoffset",
30
+ "opacity",
31
+ "transform",
32
+ "class",
33
+ "x",
34
+ "y",
35
+ "x1",
36
+ "y1",
37
+ "x2",
38
+ "y2",
39
+ "cx",
40
+ "cy",
41
+ "r",
42
+ "rx",
43
+ "ry",
44
+ "points",
45
+ "d",
46
+ "role",
47
+ "focusable",
48
+ "aria-hidden",
49
+ "href",
50
+ "xlink:href"
51
+ ]);
52
+
53
+ function escapeHtml(value) {
54
+ return String(value)
55
+ .replace(/&/g, "&amp;")
56
+ .replace(/</g, "&lt;")
57
+ .replace(/>/g, "&gt;")
58
+ .replace(/"/g, "&quot;")
59
+ .replace(/'/g, "&#39;");
60
+ }
61
+
62
+ function sanitizeSvgNode(node, allowedTags = DEFAULT_ALLOWED_SVG_TAGS, allowedAttrs = DEFAULT_ALLOWED_SVG_ATTRS) {
63
+ if (!node) {
64
+ return null;
65
+ }
66
+
67
+ if (node.nodeType === Node.TEXT_NODE) {
68
+ return document.createTextNode(node.textContent || "");
69
+ }
70
+
71
+ if (node.nodeType !== Node.ELEMENT_NODE) {
72
+ return null;
73
+ }
74
+
75
+ const tagName = node.tagName.toLowerCase();
76
+ if (!allowedTags.has(tagName)) {
77
+ return null;
78
+ }
79
+
80
+ const safeNode = document.createElementNS(SVG_NAMESPACE, tagName);
81
+
82
+ Array.from(node.attributes || []).forEach((attr) => {
83
+ const name = attr.name.toLowerCase();
84
+ const attrValue = attr.value || "";
85
+
86
+ if (!allowedAttrs.has(name) || name.startsWith("on")) {
87
+ return;
88
+ }
89
+
90
+ if ((name === "href" || name === "xlink:href") && attrValue && !attrValue.startsWith("#")) {
91
+ return;
92
+ }
93
+
94
+ safeNode.setAttribute(name, attrValue);
95
+ });
96
+
97
+ Array.from(node.childNodes || []).forEach((child) => {
98
+ const safeChild = sanitizeSvgNode(child, allowedTags, allowedAttrs);
99
+ if (safeChild) {
100
+ safeNode.append(safeChild);
101
+ }
102
+ });
103
+
104
+ return safeNode;
105
+ }
106
+
107
+ export function toSafeHtmlString(value, {
108
+ allowedSvgTags = DEFAULT_ALLOWED_SVG_TAGS,
109
+ allowedSvgAttrs = DEFAULT_ALLOWED_SVG_ATTRS
110
+ } = {}) {
111
+ if (value === null || value === undefined) {
112
+ return "";
113
+ }
114
+
115
+ const content = String(value).trim();
116
+ if (!content) {
117
+ return "";
118
+ }
119
+
120
+ if (!content.includes("<")) {
121
+ return escapeHtml(content);
122
+ }
123
+
124
+ const template = document.createElement("template");
125
+ template.innerHTML = content;
126
+
127
+ const sanitizedParts = Array.from(template.content.childNodes)
128
+ .map((node) => sanitizeSvgNode(node, allowedSvgTags, allowedSvgAttrs))
129
+ .filter(Boolean)
130
+ .map((node) => {
131
+ if (node.nodeType === Node.TEXT_NODE) {
132
+ return escapeHtml(node.textContent || "");
133
+ }
134
+ if (node.nodeType === Node.ELEMENT_NODE) {
135
+ return node.outerHTML;
136
+ }
137
+ return "";
138
+ });
139
+
140
+ const sanitized = sanitizedParts.join("");
141
+ return sanitized || escapeHtml(content);
142
+ }
143
+
144
+ class Sanitize {
145
+ static toSafeHtmlString(value, options) {
146
+ return toSafeHtmlString(value, options);
147
+ }
148
+ }
149
+
150
+ export default Sanitize;
@@ -0,0 +1,140 @@
1
+ const VIDEO_EXTENSIONS = new Set([
2
+ 'mp4',
3
+ 'webm',
4
+ 'mov',
5
+ 'mkv',
6
+ 'avi',
7
+ 'm4v',
8
+ 'ogv'
9
+ ]);
10
+
11
+ const getFileExtension = (file) => {
12
+ const fileName = String(file?.name || '').toLowerCase();
13
+ const dot = fileName.lastIndexOf('.');
14
+ if (dot < 0 || dot >= fileName.length - 1) {
15
+ return '';
16
+ }
17
+ return fileName.slice(dot + 1);
18
+ };
19
+
20
+ const waitEvent = (node, eventName) => new Promise((resolve, reject) => {
21
+ const onResolve = () => {
22
+ cleanup();
23
+ resolve(true);
24
+ };
25
+
26
+ const onReject = () => {
27
+ cleanup();
28
+ reject(new Error(eventName));
29
+ };
30
+
31
+ const cleanup = () => {
32
+ node.removeEventListener(eventName, onResolve);
33
+ node.removeEventListener('error', onReject);
34
+ };
35
+
36
+ node.addEventListener(eventName, onResolve, { once: true });
37
+ node.addEventListener('error', onReject, { once: true });
38
+ });
39
+
40
+ const seekVideo = (video, time) => new Promise((resolve, reject) => {
41
+ const onSeeked = () => {
42
+ cleanup();
43
+ resolve(true);
44
+ };
45
+
46
+ const onError = () => {
47
+ cleanup();
48
+ reject(new Error('seek'));
49
+ };
50
+
51
+ const cleanup = () => {
52
+ video.removeEventListener('seeked', onSeeked);
53
+ video.removeEventListener('error', onError);
54
+ };
55
+
56
+ video.addEventListener('seeked', onSeeked, { once: true });
57
+ video.addEventListener('error', onError, { once: true });
58
+ video.currentTime = time;
59
+ });
60
+
61
+ const canvasToBlob = (canvas, type = 'image/jpeg', quality = 0.92) => new Promise((resolve) => {
62
+ canvas.toBlob((blob) => resolve(blob || null), type, quality);
63
+ });
64
+
65
+ const extractVideoMetadata = async (file) => {
66
+ if (!(file instanceof File)) {
67
+ return null;
68
+ }
69
+
70
+ const ext = getFileExtension(file);
71
+ const isVideoType = String(file.type || '').toLowerCase().startsWith('video/');
72
+ if (!isVideoType && !VIDEO_EXTENSIONS.has(ext)) {
73
+ return null;
74
+ }
75
+
76
+ if (!file.size) {
77
+ return null;
78
+ }
79
+
80
+ let objectUrl = '';
81
+ try {
82
+ objectUrl = URL.createObjectURL(file);
83
+
84
+ const video = document.createElement('video');
85
+ video.preload = 'metadata';
86
+ video.muted = true;
87
+ video.playsInline = true;
88
+ video.crossOrigin = 'anonymous';
89
+ video.src = objectUrl;
90
+
91
+ await waitEvent(video, 'loadedmetadata');
92
+
93
+ const width = Number(video.videoWidth || 0);
94
+ const height = Number(video.videoHeight || 0);
95
+ const duration = Number(video.duration || 0);
96
+
97
+ if (!width || !height || !Number.isFinite(width) || !Number.isFinite(height)) {
98
+ return {
99
+ duration: Number.isFinite(duration) ? duration : 0,
100
+ width: 0,
101
+ height: 0
102
+ };
103
+ }
104
+
105
+ const seekTime = duration > 1 ? Math.min(1, Math.max(0, duration / 2)) : 0;
106
+ await seekVideo(video, seekTime);
107
+
108
+ const canvas = document.createElement('canvas');
109
+ canvas.width = width;
110
+ canvas.height = height;
111
+ const ctx = canvas.getContext('2d');
112
+ if (!ctx) {
113
+ return {
114
+ duration: Number.isFinite(duration) ? duration : 0,
115
+ width,
116
+ height
117
+ };
118
+ }
119
+
120
+ ctx.drawImage(video, 0, 0, width, height);
121
+ const posterBlob = await canvasToBlob(canvas, 'image/jpeg', 0.92);
122
+
123
+ return {
124
+ duration: Number.isFinite(duration) ? duration : 0,
125
+ width,
126
+ height,
127
+ posterBlob: posterBlob || null
128
+ };
129
+ } catch {
130
+ return null;
131
+ } finally {
132
+ if (objectUrl) {
133
+ URL.revokeObjectURL(objectUrl);
134
+ }
135
+ }
136
+ };
137
+
138
+ export {
139
+ extractVideoMetadata
140
+ };