@sswroom/sswr 1.5.4 → 1.6.0

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/geometry.d.ts CHANGED
@@ -5,7 +5,7 @@ declare class BoundaryPointResult
5
5
  x: number;
6
6
  y: number;
7
7
  dist: number;
8
- };
8
+ }
9
9
 
10
10
  export enum VectorType
11
11
  {
@@ -41,7 +41,7 @@ export class Vector2D {
41
41
  constructor(srid: number);
42
42
  insideOrTouch(coord: math.Coord2D): boolean;
43
43
  getBounds(): math.RectArea;
44
- };
44
+ }
45
45
 
46
46
  export class Point extends Vector2D
47
47
  {
package/hash.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ export enum HashType
2
+ {
3
+ Unknown,
4
+ // Primary Algorithm
5
+ Adler32,
6
+ CRC16,
7
+ CRC16R,
8
+ CRC32,
9
+ CRC32R_IEEE,
10
+ CRC32C,
11
+ DJB2,
12
+ DJB2a,
13
+ FNV1,
14
+ FNV1a,
15
+ MD5,
16
+ RIPEMD128,
17
+ RIPEMD160,
18
+ SDBM,
19
+ SHA1,
20
+ Excel,
21
+ SHA224,
22
+ SHA256,
23
+ SHA384,
24
+ SHA512,
25
+ MD4,
26
+
27
+ // Compound Algorithm
28
+ SHA1_SHA1
29
+ }
30
+
31
+ export abstract class Hash
32
+ {
33
+ abstract getName(): string;
34
+ abstract clone(): Hash;
35
+ abstract clear(): void;
36
+ abstract calc(buff: ArrayBuffer): void;
37
+ abstract getValue(): ArrayBuffer;
38
+ abstract getBlockSize(): number;
39
+ }
40
+
41
+ export class SHA1 extends Hash
42
+ {
43
+ intermediateHash: number[];
44
+ messageLength: number;
45
+ messageBlockIndex: number;
46
+ messageBlock: number[];
47
+
48
+ constructor();
49
+ getName(): string;
50
+ clone(): Hash;
51
+ clear(): void;
52
+ calc(buff: ArrayBuffer): void;
53
+ getValue(): ArrayBuffer;
54
+ getBlockSize(): number;
55
+
56
+ static calcBlock(intermediateHash: number[], messageBlock: ArrayBuffer): void;
57
+ }
package/hash.js ADDED
@@ -0,0 +1,269 @@
1
+ import * as data from "./data.js";
2
+ import * as text from "./text.js";
3
+
4
+ export const HashType = {
5
+ Unknown: 0,
6
+ // Primary Algorithm
7
+ Adler32: 1,
8
+ CRC16: 2,
9
+ CRC16R: 3,
10
+ CRC32: 4,
11
+ CRC32R_IEEE: 5,
12
+ CRC32C: 6,
13
+ DJB2: 7,
14
+ DJB2a: 8,
15
+ FNV1: 9,
16
+ FNV1a: 10,
17
+ MD5: 11,
18
+ RIPEMD128: 12,
19
+ RIPEMD160: 13,
20
+ SDBM: 14,
21
+ SHA1: 15,
22
+ Excel: 16,
23
+ SHA224: 17,
24
+ SHA256: 18,
25
+ SHA384: 19,
26
+ SHA512: 20,
27
+ MD4: 21,
28
+
29
+ // Compound Algorithm
30
+ SHA1_SHA1: 22
31
+ }
32
+
33
+ export class Hash
34
+ {
35
+ }
36
+
37
+ export class SHA1 extends Hash
38
+ {
39
+ constructor()
40
+ {
41
+ super();
42
+ this.clear();
43
+ }
44
+
45
+ getName()
46
+ {
47
+ return "SHA-1";
48
+ }
49
+
50
+ clone()
51
+ {
52
+ let o = new SHA1();
53
+ o.messageLength = this.messageLength;
54
+ o.messageBlockIndex = this.messageBlockIndex;
55
+
56
+ o.intermediateHash[0] = this.intermediateHash[0];
57
+ o.intermediateHash[1] = this.intermediateHash[1];
58
+ o.intermediateHash[2] = this.intermediateHash[2];
59
+ o.intermediateHash[3] = this.intermediateHash[3];
60
+ o.intermediateHash[4] = this.intermediateHash[4];
61
+
62
+ let i = 0;
63
+ while (i < this.messageBlockIndex)
64
+ {
65
+ o.messageBlock[i] = this.messageBlock[i];
66
+ i++;
67
+ }
68
+ return o;
69
+ }
70
+
71
+ clear()
72
+ {
73
+ this.messageLength = 0n;
74
+ this.messageBlockIndex = 0;
75
+
76
+ this.intermediateHash = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
77
+ this.messageBlock = new Array(64);
78
+ }
79
+
80
+ calc(buff)
81
+ {
82
+ if (!(buff instanceof ArrayBuffer))
83
+ return;
84
+ let i;
85
+ let arr;
86
+ this.messageLength += BigInt(buff.byteLength << 3);
87
+ if ((buff.byteLength + this.messageBlockIndex) < 64)
88
+ {
89
+ arr = new Uint8Array(buff);
90
+ i = 0;
91
+ while (i < buff.byteLength)
92
+ {
93
+ this.messageBlock[this.messageBlockIndex + i] = arr[i];
94
+ i++;
95
+ }
96
+ this.messageBlockIndex += buff.byteLength;
97
+ return;
98
+ }
99
+ i = 0;
100
+ if (this.messageBlockIndex > 0)
101
+ {
102
+ arr = new Uint8Array(buff);
103
+ while (this.messageBlockIndex < 64)
104
+ {
105
+ this.messageBlock[this.messageBlockIndex] = arr[i];
106
+ this.messageBlockIndex++;
107
+ i++;
108
+ }
109
+ SHA1.calcBlock(this.intermediateHash, new Uint8Array(this.messageBlock).buffer);
110
+ this.messageBlockIndex = 0;
111
+ }
112
+
113
+ while (i + 64 <= buff.byteLength)
114
+ {
115
+ SHA1.calcBlock(this.intermediateHash, buff.slice(i, i + 64));
116
+ i += 64;
117
+ }
118
+ if (i < buff.byteLength)
119
+ {
120
+ arr = new Uint8Array(buff);
121
+ while (i < buff.byteLength)
122
+ {
123
+ this.messageBlock[this.messageBlockIndex] = arr[i];
124
+ this.messageBlockIndex++;
125
+ i++;
126
+ }
127
+ }
128
+ }
129
+
130
+ getValue()
131
+ {
132
+ let calBuff = new Array(64);
133
+ let intHash = [
134
+ this.intermediateHash[0],
135
+ this.intermediateHash[1],
136
+ this.intermediateHash[2],
137
+ this.intermediateHash[3],
138
+ this.intermediateHash[4]];
139
+
140
+ let i;
141
+ i = 0;
142
+ while (i < this.messageBlockIndex)
143
+ {
144
+ calBuff[i] = this.messageBlock[i];
145
+ i++;
146
+ }
147
+ if (this.messageBlockIndex < 55)
148
+ {
149
+ i = this.messageBlockIndex;
150
+ calBuff[i++] = 0x80;
151
+ while (i < 56)
152
+ {
153
+ calBuff[i] = 0;
154
+ i++;
155
+ }
156
+
157
+ }
158
+ else
159
+ {
160
+ i = this.messageBlockIndex;
161
+ calBuff[i++] = 0x80;
162
+ while (i < 64)
163
+ {
164
+ calBuff[i] = 0;
165
+ i++;
166
+ }
167
+ SHA1.calcBlock(intHash, calBuff);
168
+ i = 0;
169
+ while (i < 56)
170
+ {
171
+ calBuff[i] = 0;
172
+ i++;
173
+ }
174
+ }
175
+ let view = new DataView(new Uint8Array(calBuff).buffer);
176
+ view.setBigUint64(56, this.messageLength, false);
177
+ SHA1.calcBlock(intHash, view.buffer);
178
+ view = new DataView(new ArrayBuffer(20));
179
+ i = 20;
180
+ while (i > 0)
181
+ {
182
+ i -= 4;
183
+ view.setUint32(i, intHash[i >> 2], false);
184
+ }
185
+ return view.buffer;
186
+ }
187
+
188
+ getBlockSize()
189
+ {
190
+ return 64;
191
+ }
192
+
193
+ static calcBlock(intermediateHash, messageBlock)
194
+ {
195
+ let w = new Array(80);
196
+ const k = [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6];
197
+ let t;
198
+ let temp;
199
+ let a;
200
+ let b;
201
+ let c;
202
+ let d;
203
+ let e;
204
+
205
+ let blk = new data.ByteReader(messageBlock);
206
+
207
+ for(t = 0; t < 16; t++)
208
+ {
209
+ w[t] = blk.readUInt32(t * 4, false);
210
+ }
211
+
212
+ for(t = 16; t < 80; t++)
213
+ {
214
+ w[t] = data.rol32(w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16], 1);
215
+ }
216
+
217
+ a = intermediateHash[0];
218
+ b = intermediateHash[1];
219
+ c = intermediateHash[2];
220
+ d = intermediateHash[3];
221
+ e = intermediateHash[4];
222
+
223
+ for(t = 0; t < 20; t++)
224
+ {
225
+ temp = (data.rol32(a, 5) + (((b & c) | ((~b) & d)) + e + w[t] + k[0])) & 0xffffffff;
226
+ e = d;
227
+ d = c;
228
+ c = data.rol32(b, 30);
229
+ b = a;
230
+ a = temp;
231
+ }
232
+
233
+ for(t = 20; t < 40; t++)
234
+ {
235
+ temp = (data.rol32(a, 5) + (b ^ c ^ d) + e + w[t] + k[1]) & 0xffffffff;
236
+ e = d;
237
+ d = c;
238
+ c = data.rol32(b, 30);
239
+ b = a;
240
+ a = temp;
241
+ }
242
+
243
+ for(t = 40; t < 60; t++)
244
+ {
245
+ temp = (data.rol32(a, 5) + ((b & c) | (b & d) | (c & d)) + e + w[t] + k[2]) & 0xffffffff;
246
+ e = d;
247
+ d = c;
248
+ c = data.rol32(b, 30);
249
+ b = a;
250
+ a = temp;
251
+ }
252
+
253
+ for(t = 60; t < 80; t++)
254
+ {
255
+ temp = (data.rol32(a, 5) + (b ^ c ^ d) + e + w[t] + k[3]) & 0xffffffff;
256
+ e = d;
257
+ d = c;
258
+ c = data.rol32(b, 30);
259
+ b = a;
260
+ a = temp;
261
+ }
262
+
263
+ intermediateHash[0] = (intermediateHash[0] + a) & 0xffffffff;
264
+ intermediateHash[1] = (intermediateHash[1] + b) & 0xffffffff;
265
+ intermediateHash[2] = (intermediateHash[2] + c) & 0xffffffff;
266
+ intermediateHash[3] = (intermediateHash[3] + d) & 0xffffffff;
267
+ intermediateHash[4] = (intermediateHash[4] + e) & 0xffffffff;
268
+ }
269
+ }
package/hkoapi.d.ts CHANGED
@@ -5,20 +5,20 @@ export enum Language {
5
5
  English,
6
6
  TChinese,
7
7
  SChinese
8
- };
8
+ }
9
9
 
10
10
  declare class WebLayerInfo
11
11
  {
12
12
  name: string;
13
13
  url: string;
14
14
  type: map.WebMapType;
15
- };
15
+ }
16
16
 
17
17
  declare class UnitValue
18
18
  {
19
19
  unit: string;
20
20
  value: number;
21
- };
21
+ }
22
22
 
23
23
  declare class SoilTemp
24
24
  {
@@ -27,7 +27,7 @@ declare class SoilTemp
27
27
  recordTime: string;
28
28
  unit: string;
29
29
  value: number;
30
- };
30
+ }
31
31
 
32
32
  declare class SeaTemp
33
33
  {
@@ -35,20 +35,20 @@ declare class SeaTemp
35
35
  recordTime: string;
36
36
  unit: string;
37
37
  value: number;
38
- };
38
+ }
39
39
 
40
40
  declare class PlaceUnitValue
41
41
  {
42
42
  place: string;
43
43
  unit: string;
44
44
  value: number;
45
- };
45
+ }
46
46
 
47
47
  declare class HumidityData
48
48
  {
49
49
  data: PlaceUnitValue[];
50
50
  recordTime: string;
51
- };
51
+ }
52
52
 
53
53
  declare class Rainfall
54
54
  {
@@ -56,33 +56,33 @@ declare class Rainfall
56
56
  max: number;
57
57
  place: string;
58
58
  unit: string;
59
- };
59
+ }
60
60
 
61
61
  declare class RainfallData
62
62
  {
63
63
  data: Rainfall[];
64
64
  endTime: string;
65
65
  startTime: string;
66
- };
66
+ }
67
67
 
68
68
  declare class TemperatureData
69
69
  {
70
70
  data: PlaceUnitValue[];
71
71
  recordTime: string;
72
- };
72
+ }
73
73
 
74
74
  declare class UVIndex
75
75
  {
76
76
  place: string;
77
77
  desc: string;
78
78
  value: number;
79
- };
79
+ }
80
80
 
81
81
  declare class UVIndexData
82
82
  {
83
83
  data: UVIndex[];
84
84
  recordDesc: string;
85
- };
85
+ }
86
86
 
87
87
  declare class WeatherForecast
88
88
  {
@@ -96,7 +96,7 @@ declare class WeatherForecast
96
96
  forecastWeather: string;
97
97
  forecastWind: string;
98
98
  week: string;
99
- };
99
+ }
100
100
 
101
101
  declare class LocalWeatherForecast
102
102
  {
@@ -107,7 +107,7 @@ declare class LocalWeatherForecast
107
107
  outlook: string;
108
108
  tcInfo: string;
109
109
  updateTime: string;
110
- };
110
+ }
111
111
 
112
112
  declare class NineDayWeatherForecast
113
113
  {
@@ -116,7 +116,7 @@ declare class NineDayWeatherForecast
116
116
  soilTemp: SoilTemp;
117
117
  updateTime: string;
118
118
  weatherForecast: WeatherForecast[];
119
- };
119
+ }
120
120
 
121
121
  declare class CurrentWeatherReport
122
122
  {
@@ -133,7 +133,7 @@ declare class CurrentWeatherReport
133
133
  updateTime: string;
134
134
  uvindex: UVIndexData;
135
135
  warningMessage: string;
136
- };
136
+ }
137
137
 
138
138
  declare class WarningSummary
139
139
  {
@@ -144,7 +144,7 @@ declare class WarningSummary
144
144
  issueTime: string;
145
145
  updateTime: string;
146
146
  expireTime?: string;
147
- };
147
+ }
148
148
 
149
149
  declare class WeatherWarningSummary
150
150
  {
@@ -159,23 +159,23 @@ declare class WeatherWarningSummary
159
159
  WTCSGNL: WarningSummary;
160
160
  WTMW: WarningSummary;
161
161
  WTS: WarningSummary;
162
- };
162
+ }
163
163
 
164
164
  declare class WeatherWarningInfo
165
165
  {
166
166
 
167
- };
167
+ }
168
168
 
169
169
  declare class WeatherTips
170
170
  {
171
171
  desc?: string;
172
172
  updateTime?: string;
173
- };
173
+ }
174
174
 
175
175
  declare class SpecialWeatherTips
176
176
  {
177
177
  swt: WeatherTips[];
178
- };
178
+ }
179
179
 
180
180
  declare class QuickEarthquakeMessages
181
181
  {
@@ -185,7 +185,7 @@ declare class QuickEarthquakeMessages
185
185
  ptime: string;
186
186
  region: string;
187
187
  updateTime: string;
188
- };
188
+ }
189
189
 
190
190
  declare class LocallyFeltEarthTremorReport
191
191
  {
@@ -197,13 +197,13 @@ declare class LocallyFeltEarthTremorReport
197
197
  ptime: string;
198
198
  region: string;
199
199
  updateTime: string;
200
- };
200
+ }
201
201
 
202
202
  declare class LunarDate
203
203
  {
204
204
  LunarDate: string;
205
205
  LunarYear: string;
206
- };
206
+ }
207
207
 
208
208
  declare class AutomaticWeatherStationRainfall
209
209
  {
@@ -211,13 +211,13 @@ declare class AutomaticWeatherStationRainfall
211
211
  automaticWeatherStationID: string;
212
212
  unit: string;
213
213
  value: string;
214
- };
214
+ }
215
215
 
216
216
  declare class HourlyRainfall
217
217
  {
218
218
  hourlyRainfall: AutomaticWeatherStationRainfall[];
219
219
  obsTime: string;
220
- };
220
+ }
221
221
 
222
222
  export function getLayers() : WebLayerInfo[];
223
223
  export function getLocalWeatherForecast(lang: Language) : Promise<LocalWeatherForecast | null>;