@seed-ship/mcp-ui-solid 3.0.5 → 4.0.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +253 -280
  3. package/dist/components/ChartJSRenderer.cjs +37 -15
  4. package/dist/components/ChartJSRenderer.cjs.map +1 -1
  5. package/dist/components/ChartJSRenderer.d.ts.map +1 -1
  6. package/dist/components/ChartJSRenderer.js +37 -15
  7. package/dist/components/ChartJSRenderer.js.map +1 -1
  8. package/dist/components/DataPreviewSection.cjs +172 -0
  9. package/dist/components/DataPreviewSection.cjs.map +1 -0
  10. package/dist/components/DataPreviewSection.d.ts +19 -0
  11. package/dist/components/DataPreviewSection.d.ts.map +1 -0
  12. package/dist/components/DataPreviewSection.js +172 -0
  13. package/dist/components/DataPreviewSection.js.map +1 -0
  14. package/dist/components/MapRenderer.cjs +168 -26
  15. package/dist/components/MapRenderer.cjs.map +1 -1
  16. package/dist/components/MapRenderer.d.ts +2 -2
  17. package/dist/components/MapRenderer.d.ts.map +1 -1
  18. package/dist/components/MapRenderer.js +169 -27
  19. package/dist/components/MapRenderer.js.map +1 -1
  20. package/dist/components/ScratchpadPanel.cjs +74 -0
  21. package/dist/components/ScratchpadPanel.cjs.map +1 -1
  22. package/dist/components/ScratchpadPanel.d.ts.map +1 -1
  23. package/dist/components/ScratchpadPanel.js +75 -1
  24. package/dist/components/ScratchpadPanel.js.map +1 -1
  25. package/dist/components/VerifiedText.cjs +166 -0
  26. package/dist/components/VerifiedText.cjs.map +1 -0
  27. package/dist/components/VerifiedText.d.ts +22 -0
  28. package/dist/components/VerifiedText.d.ts.map +1 -0
  29. package/dist/components/VerifiedText.js +166 -0
  30. package/dist/components/VerifiedText.js.map +1 -0
  31. package/dist/components/index.d.ts +4 -0
  32. package/dist/components/index.d.ts.map +1 -1
  33. package/dist/components.cjs +4 -0
  34. package/dist/components.cjs.map +1 -1
  35. package/dist/components.d.cts +4 -0
  36. package/dist/components.d.ts +4 -0
  37. package/dist/components.js +4 -0
  38. package/dist/components.js.map +1 -1
  39. package/dist/hooks/index.d.ts +2 -0
  40. package/dist/hooks/index.d.ts.map +1 -1
  41. package/dist/hooks/useDataValidator.cjs +31 -0
  42. package/dist/hooks/useDataValidator.cjs.map +1 -0
  43. package/dist/hooks/useDataValidator.d.ts +42 -0
  44. package/dist/hooks/useDataValidator.d.ts.map +1 -0
  45. package/dist/hooks/useDataValidator.js +31 -0
  46. package/dist/hooks/useDataValidator.js.map +1 -0
  47. package/dist/hooks.cjs +2 -0
  48. package/dist/hooks.cjs.map +1 -1
  49. package/dist/hooks.d.cts +2 -0
  50. package/dist/hooks.d.ts +2 -0
  51. package/dist/hooks.js +2 -0
  52. package/dist/hooks.js.map +1 -1
  53. package/dist/index.cjs +8 -0
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.d.cts +9 -5
  56. package/dist/index.d.ts +9 -5
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +8 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/node_modules/.pnpm/@mapbox_point-geometry@1.1.0/node_modules/@mapbox/point-geometry/index.cjs +290 -0
  61. package/dist/node_modules/.pnpm/@mapbox_point-geometry@1.1.0/node_modules/@mapbox/point-geometry/index.cjs.map +1 -0
  62. package/dist/node_modules/.pnpm/@mapbox_point-geometry@1.1.0/node_modules/@mapbox/point-geometry/index.js +291 -0
  63. package/dist/node_modules/.pnpm/@mapbox_point-geometry@1.1.0/node_modules/@mapbox/point-geometry/index.js.map +1 -0
  64. package/dist/node_modules/.pnpm/@mapbox_vector-tile@2.0.4/node_modules/@mapbox/vector-tile/index.cjs +243 -0
  65. package/dist/node_modules/.pnpm/@mapbox_vector-tile@2.0.4/node_modules/@mapbox/vector-tile/index.cjs.map +1 -0
  66. package/dist/node_modules/.pnpm/@mapbox_vector-tile@2.0.4/node_modules/@mapbox/vector-tile/index.js +243 -0
  67. package/dist/node_modules/.pnpm/@mapbox_vector-tile@2.0.4/node_modules/@mapbox/vector-tile/index.js.map +1 -0
  68. package/dist/node_modules/.pnpm/color2k@2.0.3/node_modules/color2k/dist/index.exports.import.es.cjs +137 -0
  69. package/dist/node_modules/.pnpm/color2k@2.0.3/node_modules/color2k/dist/index.exports.import.es.cjs.map +1 -0
  70. package/dist/node_modules/.pnpm/color2k@2.0.3/node_modules/color2k/dist/index.exports.import.es.js +137 -0
  71. package/dist/node_modules/.pnpm/color2k@2.0.3/node_modules/color2k/dist/index.exports.import.es.js.map +1 -0
  72. package/dist/node_modules/.pnpm/pbf@4.0.1/node_modules/pbf/index.cjs +686 -0
  73. package/dist/node_modules/.pnpm/pbf@4.0.1/node_modules/pbf/index.cjs.map +1 -0
  74. package/dist/node_modules/.pnpm/pbf@4.0.1/node_modules/pbf/index.js +687 -0
  75. package/dist/node_modules/.pnpm/pbf@4.0.1/node_modules/pbf/index.js.map +1 -0
  76. package/dist/node_modules/.pnpm/pmtiles@3.2.1/node_modules/pmtiles/dist/index.cjs +1366 -0
  77. package/dist/node_modules/.pnpm/pmtiles@3.2.1/node_modules/pmtiles/dist/index.cjs.map +1 -0
  78. package/dist/node_modules/.pnpm/pmtiles@3.2.1/node_modules/pmtiles/dist/index.js +1366 -0
  79. package/dist/node_modules/.pnpm/pmtiles@3.2.1/node_modules/pmtiles/dist/index.js.map +1 -0
  80. package/dist/node_modules/.pnpm/potpack@1.0.2/node_modules/potpack/index.cjs +54 -0
  81. package/dist/node_modules/.pnpm/potpack@1.0.2/node_modules/potpack/index.cjs.map +1 -0
  82. package/dist/node_modules/.pnpm/potpack@1.0.2/node_modules/potpack/index.js +55 -0
  83. package/dist/node_modules/.pnpm/potpack@1.0.2/node_modules/potpack/index.js.map +1 -0
  84. package/dist/node_modules/.pnpm/protomaps-leaflet@4.1.1/node_modules/protomaps-leaflet/dist/esm/index.cjs +1256 -0
  85. package/dist/node_modules/.pnpm/protomaps-leaflet@4.1.1/node_modules/protomaps-leaflet/dist/esm/index.cjs.map +1 -0
  86. package/dist/node_modules/.pnpm/protomaps-leaflet@4.1.1/node_modules/protomaps-leaflet/dist/esm/index.js +1256 -0
  87. package/dist/node_modules/.pnpm/protomaps-leaflet@4.1.1/node_modules/protomaps-leaflet/dist/esm/index.js.map +1 -0
  88. package/dist/node_modules/.pnpm/quickselect@2.0.0/node_modules/quickselect/index.cjs +47 -0
  89. package/dist/node_modules/.pnpm/quickselect@2.0.0/node_modules/quickselect/index.cjs.map +1 -0
  90. package/dist/node_modules/.pnpm/quickselect@2.0.0/node_modules/quickselect/index.js +48 -0
  91. package/dist/node_modules/.pnpm/quickselect@2.0.0/node_modules/quickselect/index.js.map +1 -0
  92. package/dist/node_modules/.pnpm/rbush@3.0.1/node_modules/rbush/index.cjs +378 -0
  93. package/dist/node_modules/.pnpm/rbush@3.0.1/node_modules/rbush/index.cjs.map +1 -0
  94. package/dist/node_modules/.pnpm/rbush@3.0.1/node_modules/rbush/index.js +379 -0
  95. package/dist/node_modules/.pnpm/rbush@3.0.1/node_modules/rbush/index.js.map +1 -0
  96. package/dist/services/data-validator.cjs +85 -0
  97. package/dist/services/data-validator.cjs.map +1 -0
  98. package/dist/services/data-validator.d.ts +28 -0
  99. package/dist/services/data-validator.d.ts.map +1 -0
  100. package/dist/services/data-validator.js +85 -0
  101. package/dist/services/data-validator.js.map +1 -0
  102. package/dist/services/index.d.ts +1 -0
  103. package/dist/services/index.d.ts.map +1 -1
  104. package/dist/types/chat-bus.d.ts +88 -1
  105. package/dist/types/chat-bus.d.ts.map +1 -1
  106. package/dist/types/index.d.ts +135 -6
  107. package/dist/types/index.d.ts.map +1 -1
  108. package/dist/types.d.cts +135 -6
  109. package/dist/types.d.ts +135 -6
  110. package/package.json +5 -1
  111. package/src/components/ChartJSRenderer.tsx +35 -13
  112. package/src/components/DataPreviewSection.tsx +206 -0
  113. package/src/components/MapRenderer.test.tsx +94 -5
  114. package/src/components/MapRenderer.tsx +246 -45
  115. package/src/components/ScratchpadPanel.tsx +10 -2
  116. package/src/components/VerifiedText.tsx +187 -0
  117. package/src/components/index.ts +7 -0
  118. package/src/hooks/index.ts +7 -0
  119. package/src/hooks/useDataValidator.ts +68 -0
  120. package/src/index.ts +26 -1
  121. package/src/services/data-validator.test.ts +151 -0
  122. package/src/services/data-validator.ts +149 -0
  123. package/src/services/index.ts +2 -0
  124. package/src/types/chat-bus.ts +98 -1
  125. package/src/types/index.ts +145 -6
  126. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,686 @@
1
+ "use strict";
2
+ const SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
3
+ const SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
4
+ const TEXT_DECODER_MIN_LENGTH = 12;
5
+ const utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8");
6
+ const PBF_VARINT = 0;
7
+ const PBF_FIXED64 = 1;
8
+ const PBF_BYTES = 2;
9
+ const PBF_FIXED32 = 5;
10
+ class Pbf {
11
+ /**
12
+ * @param {Uint8Array | ArrayBuffer} [buf]
13
+ */
14
+ constructor(buf = new Uint8Array(16)) {
15
+ this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf);
16
+ this.dataView = new DataView(this.buf.buffer);
17
+ this.pos = 0;
18
+ this.type = 0;
19
+ this.length = this.buf.length;
20
+ }
21
+ // === READING =================================================================
22
+ /**
23
+ * @template T
24
+ * @param {(tag: number, result: T, pbf: Pbf) => void} readField
25
+ * @param {T} result
26
+ * @param {number} [end]
27
+ */
28
+ readFields(readField, result, end = this.length) {
29
+ while (this.pos < end) {
30
+ const val = this.readVarint(), tag = val >> 3, startPos = this.pos;
31
+ this.type = val & 7;
32
+ readField(tag, result, this);
33
+ if (this.pos === startPos) this.skip(val);
34
+ }
35
+ return result;
36
+ }
37
+ /**
38
+ * @template T
39
+ * @param {(tag: number, result: T, pbf: Pbf) => void} readField
40
+ * @param {T} result
41
+ */
42
+ readMessage(readField, result) {
43
+ return this.readFields(readField, result, this.readVarint() + this.pos);
44
+ }
45
+ readFixed32() {
46
+ const val = this.dataView.getUint32(this.pos, true);
47
+ this.pos += 4;
48
+ return val;
49
+ }
50
+ readSFixed32() {
51
+ const val = this.dataView.getInt32(this.pos, true);
52
+ this.pos += 4;
53
+ return val;
54
+ }
55
+ // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
56
+ readFixed64() {
57
+ const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32;
58
+ this.pos += 8;
59
+ return val;
60
+ }
61
+ readSFixed64() {
62
+ const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32;
63
+ this.pos += 8;
64
+ return val;
65
+ }
66
+ readFloat() {
67
+ const val = this.dataView.getFloat32(this.pos, true);
68
+ this.pos += 4;
69
+ return val;
70
+ }
71
+ readDouble() {
72
+ const val = this.dataView.getFloat64(this.pos, true);
73
+ this.pos += 8;
74
+ return val;
75
+ }
76
+ /**
77
+ * @param {boolean} [isSigned]
78
+ */
79
+ readVarint(isSigned) {
80
+ const buf = this.buf;
81
+ let val, b;
82
+ b = buf[this.pos++];
83
+ val = b & 127;
84
+ if (b < 128) return val;
85
+ b = buf[this.pos++];
86
+ val |= (b & 127) << 7;
87
+ if (b < 128) return val;
88
+ b = buf[this.pos++];
89
+ val |= (b & 127) << 14;
90
+ if (b < 128) return val;
91
+ b = buf[this.pos++];
92
+ val |= (b & 127) << 21;
93
+ if (b < 128) return val;
94
+ b = buf[this.pos];
95
+ val |= (b & 15) << 28;
96
+ return readVarintRemainder(val, isSigned, this);
97
+ }
98
+ readVarint64() {
99
+ return this.readVarint(true);
100
+ }
101
+ readSVarint() {
102
+ const num = this.readVarint();
103
+ return num % 2 === 1 ? (num + 1) / -2 : num / 2;
104
+ }
105
+ readBoolean() {
106
+ return Boolean(this.readVarint());
107
+ }
108
+ readString() {
109
+ const end = this.readVarint() + this.pos;
110
+ const pos = this.pos;
111
+ this.pos = end;
112
+ if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
113
+ return utf8TextDecoder.decode(this.buf.subarray(pos, end));
114
+ }
115
+ return readUtf8(this.buf, pos, end);
116
+ }
117
+ readBytes() {
118
+ const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
119
+ this.pos = end;
120
+ return buffer;
121
+ }
122
+ // verbose for performance reasons; doesn't affect gzipped size
123
+ /**
124
+ * @param {number[]} [arr]
125
+ * @param {boolean} [isSigned]
126
+ */
127
+ readPackedVarint(arr = [], isSigned) {
128
+ const end = this.readPackedEnd();
129
+ while (this.pos < end) arr.push(this.readVarint(isSigned));
130
+ return arr;
131
+ }
132
+ /** @param {number[]} [arr] */
133
+ readPackedSVarint(arr = []) {
134
+ const end = this.readPackedEnd();
135
+ while (this.pos < end) arr.push(this.readSVarint());
136
+ return arr;
137
+ }
138
+ /** @param {boolean[]} [arr] */
139
+ readPackedBoolean(arr = []) {
140
+ const end = this.readPackedEnd();
141
+ while (this.pos < end) arr.push(this.readBoolean());
142
+ return arr;
143
+ }
144
+ /** @param {number[]} [arr] */
145
+ readPackedFloat(arr = []) {
146
+ const end = this.readPackedEnd();
147
+ while (this.pos < end) arr.push(this.readFloat());
148
+ return arr;
149
+ }
150
+ /** @param {number[]} [arr] */
151
+ readPackedDouble(arr = []) {
152
+ const end = this.readPackedEnd();
153
+ while (this.pos < end) arr.push(this.readDouble());
154
+ return arr;
155
+ }
156
+ /** @param {number[]} [arr] */
157
+ readPackedFixed32(arr = []) {
158
+ const end = this.readPackedEnd();
159
+ while (this.pos < end) arr.push(this.readFixed32());
160
+ return arr;
161
+ }
162
+ /** @param {number[]} [arr] */
163
+ readPackedSFixed32(arr = []) {
164
+ const end = this.readPackedEnd();
165
+ while (this.pos < end) arr.push(this.readSFixed32());
166
+ return arr;
167
+ }
168
+ /** @param {number[]} [arr] */
169
+ readPackedFixed64(arr = []) {
170
+ const end = this.readPackedEnd();
171
+ while (this.pos < end) arr.push(this.readFixed64());
172
+ return arr;
173
+ }
174
+ /** @param {number[]} [arr] */
175
+ readPackedSFixed64(arr = []) {
176
+ const end = this.readPackedEnd();
177
+ while (this.pos < end) arr.push(this.readSFixed64());
178
+ return arr;
179
+ }
180
+ readPackedEnd() {
181
+ return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1;
182
+ }
183
+ /** @param {number} val */
184
+ skip(val) {
185
+ const type = val & 7;
186
+ if (type === PBF_VARINT) while (this.buf[this.pos++] > 127) {
187
+ }
188
+ else if (type === PBF_BYTES) this.pos = this.readVarint() + this.pos;
189
+ else if (type === PBF_FIXED32) this.pos += 4;
190
+ else if (type === PBF_FIXED64) this.pos += 8;
191
+ else throw new Error(`Unimplemented type: ${type}`);
192
+ }
193
+ // === WRITING =================================================================
194
+ /**
195
+ * @param {number} tag
196
+ * @param {number} type
197
+ */
198
+ writeTag(tag, type) {
199
+ this.writeVarint(tag << 3 | type);
200
+ }
201
+ /** @param {number} min */
202
+ realloc(min) {
203
+ let length = this.length || 16;
204
+ while (length < this.pos + min) length *= 2;
205
+ if (length !== this.length) {
206
+ const buf = new Uint8Array(length);
207
+ buf.set(this.buf);
208
+ this.buf = buf;
209
+ this.dataView = new DataView(buf.buffer);
210
+ this.length = length;
211
+ }
212
+ }
213
+ finish() {
214
+ this.length = this.pos;
215
+ this.pos = 0;
216
+ return this.buf.subarray(0, this.length);
217
+ }
218
+ /** @param {number} val */
219
+ writeFixed32(val) {
220
+ this.realloc(4);
221
+ this.dataView.setInt32(this.pos, val, true);
222
+ this.pos += 4;
223
+ }
224
+ /** @param {number} val */
225
+ writeSFixed32(val) {
226
+ this.realloc(4);
227
+ this.dataView.setInt32(this.pos, val, true);
228
+ this.pos += 4;
229
+ }
230
+ /** @param {number} val */
231
+ writeFixed64(val) {
232
+ this.realloc(8);
233
+ this.dataView.setInt32(this.pos, val & -1, true);
234
+ this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);
235
+ this.pos += 8;
236
+ }
237
+ /** @param {number} val */
238
+ writeSFixed64(val) {
239
+ this.realloc(8);
240
+ this.dataView.setInt32(this.pos, val & -1, true);
241
+ this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);
242
+ this.pos += 8;
243
+ }
244
+ /** @param {number} val */
245
+ writeVarint(val) {
246
+ val = +val || 0;
247
+ if (val > 268435455 || val < 0) {
248
+ writeBigVarint(val, this);
249
+ return;
250
+ }
251
+ this.realloc(4);
252
+ this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
253
+ if (val <= 127) return;
254
+ this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
255
+ if (val <= 127) return;
256
+ this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
257
+ if (val <= 127) return;
258
+ this.buf[this.pos++] = val >>> 7 & 127;
259
+ }
260
+ /** @param {number} val */
261
+ writeSVarint(val) {
262
+ this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
263
+ }
264
+ /** @param {boolean} val */
265
+ writeBoolean(val) {
266
+ this.writeVarint(+val);
267
+ }
268
+ /** @param {string} str */
269
+ writeString(str) {
270
+ str = String(str);
271
+ this.realloc(str.length * 4);
272
+ this.pos++;
273
+ const startPos = this.pos;
274
+ this.pos = writeUtf8(this.buf, str, this.pos);
275
+ const len = this.pos - startPos;
276
+ if (len >= 128) makeRoomForExtraLength(startPos, len, this);
277
+ this.pos = startPos - 1;
278
+ this.writeVarint(len);
279
+ this.pos += len;
280
+ }
281
+ /** @param {number} val */
282
+ writeFloat(val) {
283
+ this.realloc(4);
284
+ this.dataView.setFloat32(this.pos, val, true);
285
+ this.pos += 4;
286
+ }
287
+ /** @param {number} val */
288
+ writeDouble(val) {
289
+ this.realloc(8);
290
+ this.dataView.setFloat64(this.pos, val, true);
291
+ this.pos += 8;
292
+ }
293
+ /** @param {Uint8Array} buffer */
294
+ writeBytes(buffer) {
295
+ const len = buffer.length;
296
+ this.writeVarint(len);
297
+ this.realloc(len);
298
+ for (let i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
299
+ }
300
+ /**
301
+ * @template T
302
+ * @param {(obj: T, pbf: Pbf) => void} fn
303
+ * @param {T} obj
304
+ */
305
+ writeRawMessage(fn, obj) {
306
+ this.pos++;
307
+ const startPos = this.pos;
308
+ fn(obj, this);
309
+ const len = this.pos - startPos;
310
+ if (len >= 128) makeRoomForExtraLength(startPos, len, this);
311
+ this.pos = startPos - 1;
312
+ this.writeVarint(len);
313
+ this.pos += len;
314
+ }
315
+ /**
316
+ * @template T
317
+ * @param {number} tag
318
+ * @param {(obj: T, pbf: Pbf) => void} fn
319
+ * @param {T} obj
320
+ */
321
+ writeMessage(tag, fn, obj) {
322
+ this.writeTag(tag, PBF_BYTES);
323
+ this.writeRawMessage(fn, obj);
324
+ }
325
+ /**
326
+ * @param {number} tag
327
+ * @param {number[]} arr
328
+ */
329
+ writePackedVarint(tag, arr) {
330
+ if (arr.length) this.writeMessage(tag, writePackedVarint, arr);
331
+ }
332
+ /**
333
+ * @param {number} tag
334
+ * @param {number[]} arr
335
+ */
336
+ writePackedSVarint(tag, arr) {
337
+ if (arr.length) this.writeMessage(tag, writePackedSVarint, arr);
338
+ }
339
+ /**
340
+ * @param {number} tag
341
+ * @param {boolean[]} arr
342
+ */
343
+ writePackedBoolean(tag, arr) {
344
+ if (arr.length) this.writeMessage(tag, writePackedBoolean, arr);
345
+ }
346
+ /**
347
+ * @param {number} tag
348
+ * @param {number[]} arr
349
+ */
350
+ writePackedFloat(tag, arr) {
351
+ if (arr.length) this.writeMessage(tag, writePackedFloat, arr);
352
+ }
353
+ /**
354
+ * @param {number} tag
355
+ * @param {number[]} arr
356
+ */
357
+ writePackedDouble(tag, arr) {
358
+ if (arr.length) this.writeMessage(tag, writePackedDouble, arr);
359
+ }
360
+ /**
361
+ * @param {number} tag
362
+ * @param {number[]} arr
363
+ */
364
+ writePackedFixed32(tag, arr) {
365
+ if (arr.length) this.writeMessage(tag, writePackedFixed32, arr);
366
+ }
367
+ /**
368
+ * @param {number} tag
369
+ * @param {number[]} arr
370
+ */
371
+ writePackedSFixed32(tag, arr) {
372
+ if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr);
373
+ }
374
+ /**
375
+ * @param {number} tag
376
+ * @param {number[]} arr
377
+ */
378
+ writePackedFixed64(tag, arr) {
379
+ if (arr.length) this.writeMessage(tag, writePackedFixed64, arr);
380
+ }
381
+ /**
382
+ * @param {number} tag
383
+ * @param {number[]} arr
384
+ */
385
+ writePackedSFixed64(tag, arr) {
386
+ if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr);
387
+ }
388
+ /**
389
+ * @param {number} tag
390
+ * @param {Uint8Array} buffer
391
+ */
392
+ writeBytesField(tag, buffer) {
393
+ this.writeTag(tag, PBF_BYTES);
394
+ this.writeBytes(buffer);
395
+ }
396
+ /**
397
+ * @param {number} tag
398
+ * @param {number} val
399
+ */
400
+ writeFixed32Field(tag, val) {
401
+ this.writeTag(tag, PBF_FIXED32);
402
+ this.writeFixed32(val);
403
+ }
404
+ /**
405
+ * @param {number} tag
406
+ * @param {number} val
407
+ */
408
+ writeSFixed32Field(tag, val) {
409
+ this.writeTag(tag, PBF_FIXED32);
410
+ this.writeSFixed32(val);
411
+ }
412
+ /**
413
+ * @param {number} tag
414
+ * @param {number} val
415
+ */
416
+ writeFixed64Field(tag, val) {
417
+ this.writeTag(tag, PBF_FIXED64);
418
+ this.writeFixed64(val);
419
+ }
420
+ /**
421
+ * @param {number} tag
422
+ * @param {number} val
423
+ */
424
+ writeSFixed64Field(tag, val) {
425
+ this.writeTag(tag, PBF_FIXED64);
426
+ this.writeSFixed64(val);
427
+ }
428
+ /**
429
+ * @param {number} tag
430
+ * @param {number} val
431
+ */
432
+ writeVarintField(tag, val) {
433
+ this.writeTag(tag, PBF_VARINT);
434
+ this.writeVarint(val);
435
+ }
436
+ /**
437
+ * @param {number} tag
438
+ * @param {number} val
439
+ */
440
+ writeSVarintField(tag, val) {
441
+ this.writeTag(tag, PBF_VARINT);
442
+ this.writeSVarint(val);
443
+ }
444
+ /**
445
+ * @param {number} tag
446
+ * @param {string} str
447
+ */
448
+ writeStringField(tag, str) {
449
+ this.writeTag(tag, PBF_BYTES);
450
+ this.writeString(str);
451
+ }
452
+ /**
453
+ * @param {number} tag
454
+ * @param {number} val
455
+ */
456
+ writeFloatField(tag, val) {
457
+ this.writeTag(tag, PBF_FIXED32);
458
+ this.writeFloat(val);
459
+ }
460
+ /**
461
+ * @param {number} tag
462
+ * @param {number} val
463
+ */
464
+ writeDoubleField(tag, val) {
465
+ this.writeTag(tag, PBF_FIXED64);
466
+ this.writeDouble(val);
467
+ }
468
+ /**
469
+ * @param {number} tag
470
+ * @param {boolean} val
471
+ */
472
+ writeBooleanField(tag, val) {
473
+ this.writeVarintField(tag, +val);
474
+ }
475
+ }
476
+ function readVarintRemainder(l, s, p) {
477
+ const buf = p.buf;
478
+ let h, b;
479
+ b = buf[p.pos++];
480
+ h = (b & 112) >> 4;
481
+ if (b < 128) return toNum(l, h, s);
482
+ b = buf[p.pos++];
483
+ h |= (b & 127) << 3;
484
+ if (b < 128) return toNum(l, h, s);
485
+ b = buf[p.pos++];
486
+ h |= (b & 127) << 10;
487
+ if (b < 128) return toNum(l, h, s);
488
+ b = buf[p.pos++];
489
+ h |= (b & 127) << 17;
490
+ if (b < 128) return toNum(l, h, s);
491
+ b = buf[p.pos++];
492
+ h |= (b & 127) << 24;
493
+ if (b < 128) return toNum(l, h, s);
494
+ b = buf[p.pos++];
495
+ h |= (b & 1) << 31;
496
+ if (b < 128) return toNum(l, h, s);
497
+ throw new Error("Expected varint not more than 10 bytes");
498
+ }
499
+ function toNum(low, high, isSigned) {
500
+ return isSigned ? high * 4294967296 + (low >>> 0) : (high >>> 0) * 4294967296 + (low >>> 0);
501
+ }
502
+ function writeBigVarint(val, pbf) {
503
+ let low, high;
504
+ if (val >= 0) {
505
+ low = val % 4294967296 | 0;
506
+ high = val / 4294967296 | 0;
507
+ } else {
508
+ low = ~(-val % 4294967296);
509
+ high = ~(-val / 4294967296);
510
+ if (low ^ 4294967295) {
511
+ low = low + 1 | 0;
512
+ } else {
513
+ low = 0;
514
+ high = high + 1 | 0;
515
+ }
516
+ }
517
+ if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
518
+ throw new Error("Given varint doesn't fit into 10 bytes");
519
+ }
520
+ pbf.realloc(10);
521
+ writeBigVarintLow(low, high, pbf);
522
+ writeBigVarintHigh(high, pbf);
523
+ }
524
+ function writeBigVarintLow(low, high, pbf) {
525
+ pbf.buf[pbf.pos++] = low & 127 | 128;
526
+ low >>>= 7;
527
+ pbf.buf[pbf.pos++] = low & 127 | 128;
528
+ low >>>= 7;
529
+ pbf.buf[pbf.pos++] = low & 127 | 128;
530
+ low >>>= 7;
531
+ pbf.buf[pbf.pos++] = low & 127 | 128;
532
+ low >>>= 7;
533
+ pbf.buf[pbf.pos] = low & 127;
534
+ }
535
+ function writeBigVarintHigh(high, pbf) {
536
+ const lsb = (high & 7) << 4;
537
+ pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
538
+ if (!high) return;
539
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
540
+ if (!high) return;
541
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
542
+ if (!high) return;
543
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
544
+ if (!high) return;
545
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
546
+ if (!high) return;
547
+ pbf.buf[pbf.pos++] = high & 127;
548
+ }
549
+ function makeRoomForExtraLength(startPos, len, pbf) {
550
+ const extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
551
+ pbf.realloc(extraLen);
552
+ for (let i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
553
+ }
554
+ function writePackedVarint(arr, pbf) {
555
+ for (let i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]);
556
+ }
557
+ function writePackedSVarint(arr, pbf) {
558
+ for (let i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]);
559
+ }
560
+ function writePackedFloat(arr, pbf) {
561
+ for (let i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]);
562
+ }
563
+ function writePackedDouble(arr, pbf) {
564
+ for (let i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]);
565
+ }
566
+ function writePackedBoolean(arr, pbf) {
567
+ for (let i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]);
568
+ }
569
+ function writePackedFixed32(arr, pbf) {
570
+ for (let i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]);
571
+ }
572
+ function writePackedSFixed32(arr, pbf) {
573
+ for (let i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]);
574
+ }
575
+ function writePackedFixed64(arr, pbf) {
576
+ for (let i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]);
577
+ }
578
+ function writePackedSFixed64(arr, pbf) {
579
+ for (let i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]);
580
+ }
581
+ function readUtf8(buf, pos, end) {
582
+ let str = "";
583
+ let i = pos;
584
+ while (i < end) {
585
+ const b0 = buf[i];
586
+ let c = null;
587
+ let bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
588
+ if (i + bytesPerSequence > end) break;
589
+ let b1, b2, b3;
590
+ if (bytesPerSequence === 1) {
591
+ if (b0 < 128) {
592
+ c = b0;
593
+ }
594
+ } else if (bytesPerSequence === 2) {
595
+ b1 = buf[i + 1];
596
+ if ((b1 & 192) === 128) {
597
+ c = (b0 & 31) << 6 | b1 & 63;
598
+ if (c <= 127) {
599
+ c = null;
600
+ }
601
+ }
602
+ } else if (bytesPerSequence === 3) {
603
+ b1 = buf[i + 1];
604
+ b2 = buf[i + 2];
605
+ if ((b1 & 192) === 128 && (b2 & 192) === 128) {
606
+ c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
607
+ if (c <= 2047 || c >= 55296 && c <= 57343) {
608
+ c = null;
609
+ }
610
+ }
611
+ } else if (bytesPerSequence === 4) {
612
+ b1 = buf[i + 1];
613
+ b2 = buf[i + 2];
614
+ b3 = buf[i + 3];
615
+ if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
616
+ c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
617
+ if (c <= 65535 || c >= 1114112) {
618
+ c = null;
619
+ }
620
+ }
621
+ }
622
+ if (c === null) {
623
+ c = 65533;
624
+ bytesPerSequence = 1;
625
+ } else if (c > 65535) {
626
+ c -= 65536;
627
+ str += String.fromCharCode(c >>> 10 & 1023 | 55296);
628
+ c = 56320 | c & 1023;
629
+ }
630
+ str += String.fromCharCode(c);
631
+ i += bytesPerSequence;
632
+ }
633
+ return str;
634
+ }
635
+ function writeUtf8(buf, str, pos) {
636
+ for (let i = 0, c, lead; i < str.length; i++) {
637
+ c = str.charCodeAt(i);
638
+ if (c > 55295 && c < 57344) {
639
+ if (lead) {
640
+ if (c < 56320) {
641
+ buf[pos++] = 239;
642
+ buf[pos++] = 191;
643
+ buf[pos++] = 189;
644
+ lead = c;
645
+ continue;
646
+ } else {
647
+ c = lead - 55296 << 10 | c - 56320 | 65536;
648
+ lead = null;
649
+ }
650
+ } else {
651
+ if (c > 56319 || i + 1 === str.length) {
652
+ buf[pos++] = 239;
653
+ buf[pos++] = 191;
654
+ buf[pos++] = 189;
655
+ } else {
656
+ lead = c;
657
+ }
658
+ continue;
659
+ }
660
+ } else if (lead) {
661
+ buf[pos++] = 239;
662
+ buf[pos++] = 191;
663
+ buf[pos++] = 189;
664
+ lead = null;
665
+ }
666
+ if (c < 128) {
667
+ buf[pos++] = c;
668
+ } else {
669
+ if (c < 2048) {
670
+ buf[pos++] = c >> 6 | 192;
671
+ } else {
672
+ if (c < 65536) {
673
+ buf[pos++] = c >> 12 | 224;
674
+ } else {
675
+ buf[pos++] = c >> 18 | 240;
676
+ buf[pos++] = c >> 12 & 63 | 128;
677
+ }
678
+ buf[pos++] = c >> 6 & 63 | 128;
679
+ }
680
+ buf[pos++] = c & 63 | 128;
681
+ }
682
+ }
683
+ return pos;
684
+ }
685
+ module.exports = Pbf;
686
+ //# sourceMappingURL=index.cjs.map