@sswroom/sswr 1.6.19 → 1.6.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog +20 -0
- package/cesium.d.ts +1 -0
- package/cesium.js +6 -1
- package/data.d.ts +3 -0
- package/data.js +93 -0
- package/domtoimage/fontFaces.js +56 -0
- package/domtoimage/images.js +49 -0
- package/domtoimage/index.js +333 -0
- package/domtoimage/inliner.js +67 -0
- package/domtoimage/util.js +142 -0
- package/dummy/Cesium.d.ts +1 -0
- package/dummy/Cesium.js +1 -0
- package/exporter/XLSXExporter.js +578 -524
- package/leaflet/EasyPrint.js +739 -0
- package/package.json +1 -1
- package/parser.js +20 -0
- package/text.d.ts +3 -0
- package/text.js +24 -0
- package/web.d.ts +19 -0
- package/web.js +117 -0
package/package.json
CHANGED
package/parser.js
CHANGED
|
@@ -980,6 +980,25 @@ async function parseJpg(reader, sourceName)
|
|
|
980
980
|
return null;
|
|
981
981
|
}
|
|
982
982
|
|
|
983
|
+
/**
|
|
984
|
+
* @param {data.ByteReader} reader
|
|
985
|
+
* @param {string} sourceName
|
|
986
|
+
*/
|
|
987
|
+
async function parsePng(reader, sourceName)
|
|
988
|
+
{
|
|
989
|
+
if (!(reader instanceof data.ByteReader))
|
|
990
|
+
return null;
|
|
991
|
+
if (reader.getLength() < 20)
|
|
992
|
+
return null;
|
|
993
|
+
if (reader.readUInt32(0, false) != 0x89504e47 || reader.readUInt32(4, false) != 0x0d0a1a0a)
|
|
994
|
+
return null;
|
|
995
|
+
let buff = reader.getArrayBuffer();
|
|
996
|
+
let b = new Blob([buff], {type: "image/png"});
|
|
997
|
+
let img = await media.loadImageFromBlob(b);
|
|
998
|
+
let simg = new media.StaticImage(img, sourceName, "image/png");
|
|
999
|
+
return simg;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
983
1002
|
/**
|
|
984
1003
|
* @param {data.ByteReader} reader
|
|
985
1004
|
* @param {string} sourceName
|
|
@@ -1300,6 +1319,7 @@ export async function parseFile(file)
|
|
|
1300
1319
|
{
|
|
1301
1320
|
let view = new data.ByteReader(await file.arrayBuffer());
|
|
1302
1321
|
let obj;
|
|
1322
|
+
if (obj = await parsePng(view, file.name)) return obj;
|
|
1303
1323
|
if (obj = await parseJpg(view, file.name)) return obj;
|
|
1304
1324
|
if (obj = await parseWebp(view, file.name)) return obj;
|
|
1305
1325
|
if (obj = parseX509(view, file.name, t)) return obj;
|
package/text.d.ts
CHANGED
|
@@ -56,6 +56,9 @@ export function replaceAll(s: string, replaceFrom: string, replaceTo: string): s
|
|
|
56
56
|
export function getEncList(): TextBinEnc[];
|
|
57
57
|
export function b64Enc(s: string, cs?: Base64Charset): string;
|
|
58
58
|
export function b64Dec(b64Str: string): string;
|
|
59
|
+
export function isDataURL(url: string): boolean;
|
|
60
|
+
export function escapeXhtml(s: string): string;
|
|
61
|
+
export function svgStringToDataURI(svg: string): string;
|
|
59
62
|
|
|
60
63
|
export class TextBinEnc
|
|
61
64
|
{
|
package/text.js
CHANGED
|
@@ -617,6 +617,30 @@ export function b64Dec(b64Str)
|
|
|
617
617
|
return dec.decode(b64.decodeBin(b64Str));
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
+
/**
|
|
621
|
+
* @param {string} url
|
|
622
|
+
*/
|
|
623
|
+
export function isDataURL(url)
|
|
624
|
+
{
|
|
625
|
+
return url.startsWith("data:");
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* @param {string} s
|
|
630
|
+
*/
|
|
631
|
+
export function escapeXhtml(s)
|
|
632
|
+
{
|
|
633
|
+
return s.replace(/#/g, '%23').replace(/\n/g, '%0A');
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @param {string} svg
|
|
638
|
+
*/
|
|
639
|
+
export function svgStringToDataURI(svg)
|
|
640
|
+
{
|
|
641
|
+
return 'data:image/svg+xml;charset=utf-8,' + svg;
|
|
642
|
+
}
|
|
643
|
+
|
|
620
644
|
export class TextBinEnc
|
|
621
645
|
{
|
|
622
646
|
constructor(name)
|
package/web.d.ts
CHANGED
|
@@ -12,6 +12,14 @@ declare class ImageInfo
|
|
|
12
12
|
height: number;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
declare class PrintOptions
|
|
16
|
+
{
|
|
17
|
+
pageBorderTopHTML?: string;
|
|
18
|
+
pageBorderBottomHTML?: string;
|
|
19
|
+
overlayHTML?: string;
|
|
20
|
+
pageTitle?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
export enum OSType
|
|
16
24
|
{
|
|
17
25
|
Unknown,
|
|
@@ -88,6 +96,12 @@ export enum BrowserType
|
|
|
88
96
|
MiBrowser
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
export enum PaperOrientation
|
|
100
|
+
{
|
|
101
|
+
Landscape,
|
|
102
|
+
Portrait
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
declare class BrowserInfo
|
|
92
106
|
{
|
|
93
107
|
os: OSType;
|
|
@@ -102,6 +116,7 @@ export function getParameterByName(name: string): string | null;
|
|
|
102
116
|
export function loadJSON(url: string, onResultFunc: Function): void;
|
|
103
117
|
export function buildTable(o: object | object[]): string;
|
|
104
118
|
export function openData(data: string | Blob, contentType: string, fileName?: string): void;
|
|
119
|
+
export function openUrl(url: string, fileName?: string): void;
|
|
105
120
|
export function parseCSSColor(c: string): Color;
|
|
106
121
|
export function handleFileDrop(ele: HTMLElement, hdlr: (file: File)=>void): void;
|
|
107
122
|
export function appendUrl(targetUrl: string, docUrl: string): string;
|
|
@@ -117,6 +132,10 @@ export function getDivElement(id: string): HTMLDivElement;
|
|
|
117
132
|
export function getSpanElement(id: string): HTMLSpanElement;
|
|
118
133
|
export function getCanvasElement(id: string): HTMLCanvasElement;
|
|
119
134
|
export function getImgElement(id: string): HTMLImageElement;
|
|
135
|
+
export function canvasToBlob(canvas: HTMLCanvasElement): Promise<Blob|null>;
|
|
136
|
+
export function elementToSVGString(node: Element, width: string | number, height: string | number): string;
|
|
137
|
+
export function genPrintWindowHTML(imgDataURL: string, orientation: PaperOrientation, paperSize?: string, options: PrintOptions): string;
|
|
138
|
+
export function printImageData(imgDataURL: string, orientation: PaperOrientation, paperSize?: string, options: PrintOptions): void;
|
|
120
139
|
export function getBrowserInfo(): Promise<BrowserInfo>;
|
|
121
140
|
export function parseUserAgent(userAgent: string): BrowserInfo;
|
|
122
141
|
|
package/web.js
CHANGED
|
@@ -76,6 +76,11 @@ export const BrowserType = {
|
|
|
76
76
|
MiBrowser: "MiBrowser"
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
export const PaperOrientation = {
|
|
80
|
+
Landscape: "landscape",
|
|
81
|
+
Portrait: "portrait"
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
export function getRequestURLBase()
|
|
80
85
|
{
|
|
81
86
|
let url = document.location.href;
|
|
@@ -222,6 +227,23 @@ export function openData(data, contentType, fileName)
|
|
|
222
227
|
}
|
|
223
228
|
}
|
|
224
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @param {string} url
|
|
232
|
+
* @param {string|undefined} fileName
|
|
233
|
+
*/
|
|
234
|
+
export function openUrl(url, fileName)
|
|
235
|
+
{
|
|
236
|
+
let ele = document.createElement("a");
|
|
237
|
+
ele.setAttribute('href', url);
|
|
238
|
+
if (fileName)
|
|
239
|
+
ele.setAttribute('download', fileName);
|
|
240
|
+
ele.style.display = 'none';
|
|
241
|
+
|
|
242
|
+
document.body.appendChild(ele);
|
|
243
|
+
ele.click();
|
|
244
|
+
document.body.removeChild(ele);
|
|
245
|
+
}
|
|
246
|
+
|
|
225
247
|
/**
|
|
226
248
|
* @param {number} c
|
|
227
249
|
*/
|
|
@@ -1040,6 +1062,101 @@ export function getImgElement(id)
|
|
|
1040
1062
|
throw new Error("Element with id \""+id+"\" is not an img");
|
|
1041
1063
|
}
|
|
1042
1064
|
|
|
1065
|
+
/**
|
|
1066
|
+
* @param {HTMLCanvasElement} canvas
|
|
1067
|
+
* @returns {Promise<Blob|null>}
|
|
1068
|
+
*/
|
|
1069
|
+
export async function canvasToBlob(canvas)
|
|
1070
|
+
{
|
|
1071
|
+
if (canvas.toBlob)
|
|
1072
|
+
{
|
|
1073
|
+
return await new Promise(function (resolve) {
|
|
1074
|
+
canvas.toBlob(resolve);
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
return data.dataURI2Blob(canvas.toDataURL());
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* @param {Element} node
|
|
1082
|
+
* @param {string | number} width
|
|
1083
|
+
* @param {string | number} height
|
|
1084
|
+
*/
|
|
1085
|
+
export function elementToSVGString(node, width, height)
|
|
1086
|
+
{
|
|
1087
|
+
node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
1088
|
+
let xhtml = text.escapeXhtml(new XMLSerializer().serializeToString(node));
|
|
1089
|
+
let foreignObject = '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
|
|
1090
|
+
return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' + foreignObject + '</svg>';
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* @param {string} imgDataURL
|
|
1095
|
+
* @param {string} orientation
|
|
1096
|
+
* @param {string | null | undefined} paperSize
|
|
1097
|
+
* @param {{ pageBorderTopHTML?: string; pageBorderBottomHTML?: string; overlayHTML?: string; pageTitle?: string; }} options
|
|
1098
|
+
*/
|
|
1099
|
+
export function genPrintWindowHTML(imgDataURL, orientation, paperSize, options)
|
|
1100
|
+
{
|
|
1101
|
+
let strs = new Array();
|
|
1102
|
+
strs.push("<html><head>");
|
|
1103
|
+
if (options.pageTitle)
|
|
1104
|
+
{
|
|
1105
|
+
strs.push("<title>"+text.toHTMLText(options.pageTitle)+"</title>");
|
|
1106
|
+
}
|
|
1107
|
+
strs.push(`<style>@media print {
|
|
1108
|
+
img { max-width: 98%!important; max-height: 98%!important; }
|
|
1109
|
+
@page { size: ` + (paperSize?paperSize:'')+' '+ orientation + `;}}
|
|
1110
|
+
</style>
|
|
1111
|
+
<script>function step1(){
|
|
1112
|
+
setTimeout('step2()', 10);}
|
|
1113
|
+
function step2(){window.print();window.close()}
|
|
1114
|
+
</script></head><body onload='step1()' style="margin: 0px;">`);
|
|
1115
|
+
if (options.pageBorderTopHTML || options.pageBorderBottomHTML)
|
|
1116
|
+
{
|
|
1117
|
+
strs.push("<table border=\"0\" width=\"100%\" height=\"100%\">");
|
|
1118
|
+
if (options.pageBorderTopHTML)
|
|
1119
|
+
{
|
|
1120
|
+
strs.push("<tr><td>"+options.pageBorderTopHTML+"</td></tr>");
|
|
1121
|
+
}
|
|
1122
|
+
strs.push(`<tr><td>`);
|
|
1123
|
+
if (options.overlayHTML)
|
|
1124
|
+
strs.push(options.overlayHTML);
|
|
1125
|
+
strs.push(`<img src="` + imgDataURL + `" style="display:block; margin:auto;"></td></tr>`);
|
|
1126
|
+
if (options.pageBorderBottomHTML)
|
|
1127
|
+
{
|
|
1128
|
+
strs.push("<tr><td>"+options.pageBorderBottomHTML+"</td></tr>");
|
|
1129
|
+
}
|
|
1130
|
+
strs.push("</table>");
|
|
1131
|
+
}
|
|
1132
|
+
else
|
|
1133
|
+
{
|
|
1134
|
+
if (options.overlayHTML)
|
|
1135
|
+
strs.push(options.overlayHTML);
|
|
1136
|
+
strs.push(`<img src="` + imgDataURL + `" style="display:block; margin:auto;">`);
|
|
1137
|
+
}
|
|
1138
|
+
strs.push(`</body></html>`);
|
|
1139
|
+
return strs.join("");
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* @param {string} imgDataURL
|
|
1144
|
+
* @param {string} orientation
|
|
1145
|
+
* @param {string | null | undefined} paperSize
|
|
1146
|
+
* @param {{ pageBorderTopHTML?: string; pageBorderBottomHTML?: string; overlayHTML?: string }} options
|
|
1147
|
+
*/
|
|
1148
|
+
export function printImageData(imgDataURL, orientation, paperSize, options)
|
|
1149
|
+
{
|
|
1150
|
+
let page = window.open("", "_blank", 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10, top=10, width=600, height=800, visible=none');
|
|
1151
|
+
if (page == null)
|
|
1152
|
+
return false;
|
|
1153
|
+
let pageContent = genPrintWindowHTML(imgDataURL, orientation, paperSize, options);
|
|
1154
|
+
page.document.body.innerHTML = ''
|
|
1155
|
+
page.document.write(pageContent);
|
|
1156
|
+
page.document.close();
|
|
1157
|
+
return true;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1043
1160
|
/**
|
|
1044
1161
|
* @returns {Promise<{os: String,osVer?:string,browser: String,browserVer?: string,devName?:string}>}
|
|
1045
1162
|
*/
|