@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.
@@ -0,0 +1,142 @@
1
+ import * as web from "../web.js";
2
+ export const uid = genUid();
3
+
4
+ function mimes() {
5
+ /*
6
+ * Only WOFF and EOT mime types for fonts are 'real'
7
+ * see http://www.iana.org/assignments/media-types/media-types.xhtml
8
+ */
9
+ let WOFF = 'application/font-woff';
10
+ let JPEG = 'image/jpeg';
11
+
12
+ return {
13
+ 'woff': WOFF,
14
+ 'woff2': WOFF,
15
+ 'ttf': 'application/font-truetype',
16
+ 'eot': 'application/vnd.ms-fontobject',
17
+ 'png': 'image/png',
18
+ 'jpg': JPEG,
19
+ 'jpeg': JPEG,
20
+ 'gif': 'image/gif',
21
+ 'tiff': 'image/tiff',
22
+ 'svg': 'image/svg+xml'
23
+ };
24
+ }
25
+
26
+ /**
27
+ * @param {string} url
28
+ */
29
+ export function parseExtension(url) {
30
+ let match = /\.([^\.\/]*?)$/g.exec(url);
31
+ if (match) return match[1];
32
+ else return '';
33
+ }
34
+
35
+ /**
36
+ * @param {string} url
37
+ * @returns {string}
38
+ */
39
+ export function mimeType(url) {
40
+ let extension = parseExtension(url).toLowerCase();
41
+ return mimes()[extension] || '';
42
+ }
43
+
44
+ /**
45
+ * @param {string} url
46
+ * @param {string} baseUrl
47
+ */
48
+ export function resolveUrl(url, baseUrl) {
49
+ let doc = document.implementation.createHTMLDocument();
50
+ let base = doc.createElement('base');
51
+ doc.head.appendChild(base);
52
+ let a = doc.createElement('a');
53
+ doc.body.appendChild(a);
54
+ base.href = baseUrl;
55
+ a.href = url;
56
+ return a.href;
57
+ }
58
+
59
+ function genUid() {
60
+ let index = 0;
61
+
62
+ return function () {
63
+ return 'u' + fourRandomChars() + index++;
64
+
65
+ function fourRandomChars() {
66
+ /* see http://stackoverflow.com/a/6248722/2519373 */
67
+ return ('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
68
+ }
69
+ };
70
+ }
71
+
72
+ /**
73
+ * @param {string} uri
74
+ * @returns {Promise<HTMLImageElement>}
75
+ */
76
+ export function makeImage(uri) {
77
+ return new Promise(function (resolve, reject) {
78
+ let image = new Image();
79
+ image.onload = function () {
80
+ resolve(image);
81
+ };
82
+ image.onerror = reject;
83
+ image.src = uri;
84
+ });
85
+ }
86
+
87
+ /**
88
+ * @param {string} string
89
+ */
90
+ export function escape(string) {
91
+ return string.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1');
92
+ }
93
+
94
+ /**
95
+ * @param {number | undefined} ms
96
+ */
97
+ export function delay(ms) {
98
+ return function (/** @type {any} */ arg) {
99
+ return new Promise(function (resolve) {
100
+ setTimeout(function () {
101
+ resolve(arg);
102
+ }, ms);
103
+ });
104
+ };
105
+ }
106
+
107
+ /**
108
+ * @param {string | any[] | StyleSheetList | NodeListOf<ChildNode>} arrayLike
109
+ */
110
+ export function asArray(arrayLike) {
111
+ let array = [];
112
+ let length = arrayLike.length;
113
+ for (let i = 0; i < length; i++) array.push(arrayLike[i]);
114
+ return array;
115
+ }
116
+
117
+ /**
118
+ * @param {Element} node
119
+ */
120
+ export function width(node) {
121
+ let leftBorder = px(node, 'border-left-width');
122
+ let rightBorder = px(node, 'border-right-width');
123
+ return node.scrollWidth + leftBorder + rightBorder;
124
+ }
125
+
126
+ /**
127
+ * @param {Element} node
128
+ */
129
+ export function height(node) {
130
+ let topBorder = px(node, 'border-top-width');
131
+ let bottomBorder = px(node, 'border-bottom-width');
132
+ return node.scrollHeight + topBorder + bottomBorder;
133
+ }
134
+
135
+ /**
136
+ * @param {Element} node
137
+ * @param {string} styleProperty
138
+ */
139
+ function px(node, styleProperty) {
140
+ var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
141
+ return parseFloat(value.replace('px', ''));
142
+ }
@@ -0,0 +1 @@
1
+ export { Cesium } from "../../../cesium/Source/Cesium";
@@ -0,0 +1 @@
1
+ export const Cesium = window.Cesium;