libshv-js 7.1.13 → 8.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.
package/dist/access.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.accessLevelFromAccessString = void 0;
4
1
  var Role;
5
2
  (function (Role) {
6
3
  Role["Browse"] = "bws";
@@ -81,7 +78,7 @@ var AccessLevel;
81
78
  AccessLevel[AccessLevel["Devel7"] = 63] = "Devel7";
82
79
  AccessLevel[AccessLevel["Admin"] = 63] = "Admin";
83
80
  })(AccessLevel || (AccessLevel = {}));
84
- const accessLevelFromAccessString = (s) => {
81
+ export const accessLevelFromAccessString = (s) => {
85
82
  switch (s) {
86
83
  case Role.Browse: return AccessLevel.Browse;
87
84
  case Role.Read: return AccessLevel.Read;
@@ -95,4 +92,3 @@ const accessLevelFromAccessString = (s) => {
95
92
  default: throw new Error(`unknown access grant string: ${s}`);
96
93
  }
97
94
  };
98
- exports.accessLevelFromAccessString = accessLevelFromAccessString;
@@ -1,5 +1,5 @@
1
- import { type RpcValue, type RpcValueType, type DateTime, Decimal, Double, type IMap, type Int, type MetaMap, RpcValueWithMetaData, type ShvMap, UInt } from './rpcvalue';
2
- import { UnpackContext, PackContext } from './cpcontext';
1
+ import { type RpcValue, type RpcValueType, type DateTime, Decimal, Double, type IMap, type Int, type MetaMap, RpcValueWithMetaData, type ShvMap, UInt } from './rpcvalue.js';
2
+ import { UnpackContext, PackContext } from './cpcontext.js';
3
3
  declare class ChainPackReader {
4
4
  ctx: UnpackContext;
5
5
  constructor(data: ArrayBuffer | UnpackContext);
@@ -8,7 +8,7 @@ declare class ChainPackReader {
8
8
  readUIntDataHelper(type: 'Int' | 'UInt'): bigint;
9
9
  readIntData(): number;
10
10
  readUIntData(): number;
11
- readList(): (string | number | boolean | Double | Decimal | ArrayBuffer | DateTime | UInt<number> | import("./rpcvalue").List | ShvMap<Record<string, any>> | IMap<Record<number, any>> | RpcValueWithMetaData<MetaMap<Record<string | number, RpcValue>>, RpcValueType> | undefined)[];
11
+ readList(): (string | number | boolean | Double | Decimal | ArrayBuffer | DateTime | UInt<number> | import("./rpcvalue.js").List | ShvMap<Record<string, any>> | IMap<Record<number, any>> | RpcValueWithMetaData<MetaMap<Record<string | number, RpcValue>>, RpcValueType> | undefined)[];
12
12
  readMetaMap(): MetaMap;
13
13
  readMap(): ShvMap;
14
14
  readIMap(): IMap;
package/dist/chainpack.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHAINPACK_PROTOCOL_TYPE = exports.ChainPackWriter = exports.ChainPackReader = exports.fromChainPack = exports.toChainPack = void 0;
4
1
  /* eslint-disable no-bitwise -- we do a lot of bit stuff when parsing chainpack */
5
- const cpon_1 = require("./cpon");
6
- const rpcvalue_1 = require("./rpcvalue");
7
- const cpcontext_1 = require("./cpcontext");
2
+ import { utf8ToString } from './cpon.js';
3
+ import { Decimal, Double, RpcValueWithMetaData, UInt, withOffset, shvMapType } from './rpcvalue.js';
4
+ import { UnpackContext, PackContext } from './cpcontext.js';
8
5
  var PackingSchema;
9
6
  (function (PackingSchema) {
10
7
  PackingSchema[PackingSchema["IntThreshold"] = 64] = "IntThreshold";
@@ -77,11 +74,11 @@ const significantBitsCount = (num) => {
77
74
  class ChainPackReader {
78
75
  ctx;
79
76
  constructor(data) {
80
- this.ctx = data instanceof cpcontext_1.UnpackContext ? data : new cpcontext_1.UnpackContext(data);
77
+ this.ctx = data instanceof UnpackContext ? data : new UnpackContext(data);
81
78
  }
82
79
  implReadMap(mapType) {
83
80
  const map = {
84
- [rpcvalue_1.shvMapType]: mapType,
81
+ [shvMapType]: mapType,
85
82
  };
86
83
  while (true) {
87
84
  const b = this.ctx.peekByte();
@@ -91,13 +88,13 @@ class ChainPackReader {
91
88
  }
92
89
  const key = this.read();
93
90
  const val = this.read();
94
- if ((typeof key === 'string' && map[rpcvalue_1.shvMapType] === 'metamap') ||
95
- (typeof key === 'number' && map[rpcvalue_1.shvMapType] === 'metamap') ||
96
- (typeof key === 'string' && map[rpcvalue_1.shvMapType] === 'map')) {
91
+ if ((typeof key === 'string' && map[shvMapType] === 'metamap') ||
92
+ (typeof key === 'number' && map[shvMapType] === 'metamap') ||
93
+ (typeof key === 'string' && map[shvMapType] === 'map')) {
97
94
  map[key] = val;
98
95
  // eslint-disable-next-line unicorn/no-duplicate-if-branches -- the type system needs this branch
99
96
  }
100
- else if (typeof key === 'number' && map[rpcvalue_1.shvMapType] === 'imap') {
97
+ else if (typeof key === 'number' && map[shvMapType] === 'imap') {
101
98
  map[key] = val;
102
99
  }
103
100
  else {
@@ -115,14 +112,14 @@ class ChainPackReader {
115
112
  codePointAt = this.ctx.getByte();
116
113
  }
117
114
  const implReturn = (x) => {
118
- const ret = meta !== undefined ? new rpcvalue_1.RpcValueWithMetaData(meta, x) : x;
115
+ const ret = meta !== undefined ? new RpcValueWithMetaData(meta, x) : x;
119
116
  return ret;
120
117
  };
121
118
  if (codePointAt < PackingSchema.Null) {
122
119
  if (codePointAt >= PackingSchema.IntThreshold) {
123
120
  return implReturn(codePointAt - 64);
124
121
  }
125
- return implReturn(new rpcvalue_1.UInt(codePointAt));
122
+ return implReturn(new UInt(codePointAt));
126
123
  }
127
124
  switch (codePointAt) {
128
125
  case PackingSchema.Null: {
@@ -138,19 +135,19 @@ class ChainPackReader {
138
135
  return implReturn(this.readIntData());
139
136
  }
140
137
  case PackingSchema.UInt: {
141
- return implReturn(new rpcvalue_1.UInt(this.readUIntData()));
138
+ return implReturn(new UInt(this.readUIntData()));
142
139
  }
143
140
  case PackingSchema.Double: {
144
141
  const data = new Uint8Array(8);
145
142
  for (let i = 0; i < 8; i++) {
146
143
  data[i] = this.ctx.getByte();
147
144
  }
148
- return implReturn(new rpcvalue_1.Double(new DataView(data.buffer).getFloat64(0, true))); // little endian
145
+ return implReturn(new Double(new DataView(data.buffer).getFloat64(0, true))); // little endian
149
146
  }
150
147
  case PackingSchema.Decimal: {
151
148
  const mant = this.readIntData();
152
149
  const exp = this.readIntData();
153
- return implReturn(new rpcvalue_1.Decimal(mant, exp));
150
+ return implReturn(new Decimal(mant, exp));
154
151
  }
155
152
  case PackingSchema.DateTime: {
156
153
  let bi = this.readUIntDataHelper('Int');
@@ -175,7 +172,7 @@ class ChainPackReader {
175
172
  msec *= 1000;
176
173
  }
177
174
  msec += SHV_EPOCH_MSEC;
178
- return (0, rpcvalue_1.withOffset)(new Date(msec), offset ?? undefined);
175
+ return withOffset(new Date(msec), offset ?? undefined);
179
176
  }
180
177
  case PackingSchema.Map: {
181
178
  return implReturn(this.readMap());
@@ -200,11 +197,11 @@ class ChainPackReader {
200
197
  for (let i = 0; i < strLen; i++) {
201
198
  arr[i] = this.ctx.getByte();
202
199
  }
203
- return implReturn((0, cpon_1.utf8ToString)(arr.buffer));
200
+ return implReturn(utf8ToString(arr.buffer));
204
201
  }
205
202
  case PackingSchema.CString: {
206
203
  // variation of CponReader.readCString()
207
- const pctx = new cpcontext_1.PackContext();
204
+ const pctx = new PackContext();
208
205
  while (true) {
209
206
  let b = this.ctx.getByte();
210
207
  if (b === '\\'.codePointAt(0)) {
@@ -229,7 +226,7 @@ class ChainPackReader {
229
226
  pctx.putByte(b);
230
227
  }
231
228
  }
232
- return implReturn((0, cpon_1.utf8ToString)(pctx.buffer()));
229
+ return implReturn(utf8ToString(pctx.buffer()));
233
230
  }
234
231
  default:
235
232
  throw new TypeError('ChainPack - Invalid type info: ' + codePointAt);
@@ -312,14 +309,13 @@ class ChainPackReader {
312
309
  return this.implReadMap('imap');
313
310
  }
314
311
  }
315
- exports.ChainPackReader = ChainPackReader;
316
312
  class ChainPackWriter {
317
313
  ctx;
318
314
  constructor() {
319
- this.ctx = new cpcontext_1.PackContext();
315
+ this.ctx = new PackContext();
320
316
  }
321
317
  write(rpcVal) {
322
- if (rpcVal instanceof rpcvalue_1.RpcValueWithMetaData) {
318
+ if (rpcVal instanceof RpcValueWithMetaData) {
323
319
  this.writeMeta(rpcVal.meta);
324
320
  rpcVal = rpcVal.value;
325
321
  }
@@ -336,13 +332,13 @@ class ChainPackWriter {
336
332
  case rpcVal instanceof ArrayBuffer:
337
333
  this.writeBlob(rpcVal);
338
334
  break;
339
- case rpcVal instanceof rpcvalue_1.UInt:
335
+ case rpcVal instanceof UInt:
340
336
  this.writeUInt(rpcVal);
341
337
  break;
342
338
  case typeof rpcVal === 'number':
343
339
  this.writeInt(rpcVal);
344
340
  break;
345
- case rpcVal instanceof rpcvalue_1.Decimal:
341
+ case rpcVal instanceof Decimal:
346
342
  this.writeDecimal(rpcVal);
347
343
  break;
348
344
  case Array.isArray(rpcVal):
@@ -351,11 +347,11 @@ class ChainPackWriter {
351
347
  case rpcVal instanceof Date:
352
348
  this.writeDateTime(rpcVal);
353
349
  break;
354
- case rpcVal instanceof rpcvalue_1.Double:
350
+ case rpcVal instanceof Double:
355
351
  this.writeDouble(rpcVal);
356
352
  break;
357
353
  case typeof rpcVal === 'object':
358
- switch (rpcVal[rpcvalue_1.shvMapType]) {
354
+ switch (rpcVal[shvMapType]) {
359
355
  case 'imap':
360
356
  this.writeIMap(rpcVal);
361
357
  break;
@@ -439,7 +435,7 @@ class ChainPackWriter {
439
435
  }
440
436
  writeJSString(str) {
441
437
  this.ctx.putByte(PackingSchema.String);
442
- const pctx = new cpcontext_1.PackContext();
438
+ const pctx = new PackContext();
443
439
  pctx.writeStringUtf8(str);
444
440
  this.writeUIntData(pctx.length);
445
441
  for (let i = 0; i < pctx.length; i++) {
@@ -515,14 +511,14 @@ class ChainPackWriter {
515
511
  }
516
512
  writeMapContent(map) {
517
513
  for (const [key, value] of Object.entries(map)) {
518
- if (map[rpcvalue_1.shvMapType] === 'imap') {
514
+ if (map[shvMapType] === 'imap') {
519
515
  const intKey = Number(key);
520
516
  if (Number.isNaN(intKey)) {
521
517
  throw new TypeError('Invalid NaN IMap key');
522
518
  }
523
519
  this.writeInt(intKey);
524
520
  }
525
- else if (map[rpcvalue_1.shvMapType] === 'metamap') {
521
+ else if (map[shvMapType] === 'metamap') {
526
522
  const intKey = Number(key);
527
523
  if (Number.isNaN(intKey)) {
528
524
  this.writeJSString(key);
@@ -539,17 +535,14 @@ class ChainPackWriter {
539
535
  this.ctx.putByte(PackingSchema.Term);
540
536
  }
541
537
  }
542
- exports.ChainPackWriter = ChainPackWriter;
543
538
  const toChainPack = (value) => {
544
539
  const wr = new ChainPackWriter();
545
540
  wr.write(value);
546
541
  return wr.ctx.buffer();
547
542
  };
548
- exports.toChainPack = toChainPack;
549
543
  const fromChainPack = (buffer) => {
550
544
  const reader = new ChainPackReader(buffer);
551
545
  return reader.read();
552
546
  };
553
- exports.fromChainPack = fromChainPack;
554
547
  const CHAINPACK_PROTOCOL_TYPE = 1;
555
- exports.CHAINPACK_PROTOCOL_TYPE = CHAINPACK_PROTOCOL_TYPE;
548
+ export { toChainPack, fromChainPack, ChainPackReader, ChainPackWriter, CHAINPACK_PROTOCOL_TYPE };
package/dist/cpcontext.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnpackContext = exports.PackContext = void 0;
4
1
  class UnpackContext {
5
2
  data;
6
3
  index;
@@ -28,7 +25,6 @@ class UnpackContext {
28
25
  }
29
26
  }
30
27
  }
31
- exports.UnpackContext = UnpackContext;
32
28
  const transfer = (source, length) => {
33
29
  if (length <= source.byteLength) {
34
30
  return source.slice(0, length);
@@ -76,4 +72,4 @@ class PackContext {
76
72
  return this.data.buffer.slice(0, this.length);
77
73
  }
78
74
  }
79
- exports.PackContext = PackContext;
75
+ export { PackContext, UnpackContext };
package/dist/cpon.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type RpcValue, type RpcValueType, type DateTime, type List, Decimal, Double, type IMap, type Int, type MetaMap, RpcValueWithMetaData, type ShvMap, UInt } from './rpcvalue';
2
- import { PackContext, UnpackContext } from './cpcontext';
1
+ import { type RpcValue, type RpcValueType, type DateTime, type List, Decimal, Double, type IMap, type Int, type MetaMap, RpcValueWithMetaData, type ShvMap, UInt } from './rpcvalue.js';
2
+ import { PackContext, UnpackContext } from './cpcontext.js';
3
3
  export declare const stringifyDate: (dt: DateTime) => string;
4
4
  declare const utf8ToString: (bytearray: ArrayBuffer) => string;
5
5
  declare class CponReader {
package/dist/cpon.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromCpon = exports.toCpon = exports.CPON_PROTOCOL_TYPE = exports.CponReader = exports.CponWriter = exports.utf8ToString = exports.OneLiners = exports.stringifyDate = void 0;
4
1
  /* eslint-disable no-bitwise -- we do a lot of bit stuff when parsing cpon */
5
- const rpcvalue_1 = require("./rpcvalue");
6
- const cpcontext_1 = require("./cpcontext");
7
- const stringifyDate = (dt) => {
2
+ import { Decimal, Double, RpcValueWithMetaData, UInt, withOffset, shvMapType, isShvMap, isIMap } from './rpcvalue.js';
3
+ import { PackContext, UnpackContext } from './cpcontext.js';
4
+ export const stringifyDate = (dt) => {
8
5
  const epochMsec = dt.getTime();
9
6
  let utcOffset = dt.utc_offset;
10
7
  const localMsec = epochMsec + (60_000 * (utcOffset ?? 0));
@@ -29,7 +26,6 @@ const stringifyDate = (dt) => {
29
26
  }
30
27
  return res;
31
28
  };
32
- exports.stringifyDate = stringifyDate;
33
29
  const hexify = (byte) => {
34
30
  if (byte < 10) {
35
31
  return 48 + byte;
@@ -76,7 +72,6 @@ const utf8ToString = (bytearray) => {
76
72
  }
77
73
  return str;
78
74
  };
79
- exports.utf8ToString = utf8ToString;
80
75
  class CponReader {
81
76
  ctx;
82
77
  constructor(unpackContext) {
@@ -84,7 +79,7 @@ class CponReader {
84
79
  }
85
80
  implReadMap(mapType, terminator) {
86
81
  const map = {
87
- [rpcvalue_1.shvMapType]: mapType,
82
+ [shvMapType]: mapType,
88
83
  };
89
84
  this.ctx.getByte(); // eat start
90
85
  while (true) {
@@ -95,21 +90,21 @@ class CponReader {
95
90
  break;
96
91
  }
97
92
  const key = this.read();
98
- if (key instanceof rpcvalue_1.RpcValueWithMetaData) {
93
+ if (key instanceof RpcValueWithMetaData) {
99
94
  throw new TypeError('Map/IMap/MetaMap key can\'t have its own MetaData');
100
95
  }
101
96
  this.skipWhitespace();
102
97
  const val = this.read();
103
- if (typeof key === 'string' && map[rpcvalue_1.shvMapType] === 'metamap') {
98
+ if (typeof key === 'string' && map[shvMapType] === 'metamap') {
104
99
  map[key] = val;
105
100
  }
106
- else if ((typeof key === 'number' || key instanceof rpcvalue_1.UInt) && map[rpcvalue_1.shvMapType] === 'metamap') {
101
+ else if ((typeof key === 'number' || key instanceof UInt) && map[shvMapType] === 'metamap') {
107
102
  map[Number(key)] = val;
108
103
  }
109
- else if (typeof key === 'string' && map[rpcvalue_1.shvMapType] === 'map') {
104
+ else if (typeof key === 'string' && map[shvMapType] === 'map') {
110
105
  map[key] = val;
111
106
  }
112
- else if ((typeof key === 'number' || key instanceof rpcvalue_1.UInt) && map[rpcvalue_1.shvMapType] === 'imap') {
107
+ else if ((typeof key === 'number' || key instanceof UInt) && map[shvMapType] === 'imap') {
113
108
  map[Number(key)] = val;
114
109
  }
115
110
  else {
@@ -126,7 +121,7 @@ class CponReader {
126
121
  meta = this.readMetaMap();
127
122
  }
128
123
  const implReturn = (x) => {
129
- const ret = meta !== undefined ? new rpcvalue_1.RpcValueWithMetaData(meta, x) : x;
124
+ const ret = meta !== undefined ? new RpcValueWithMetaData(meta, x) : x;
130
125
  return ret;
131
126
  };
132
127
  this.skipWhitespace();
@@ -329,10 +324,10 @@ class CponReader {
329
324
  // let epoch_sec = CponReader.timegm(year, month, mday, hour, min, sec);
330
325
  let epochMsec = Date.UTC(year, month - 1, day, hour, min, sec, msec);
331
326
  epochMsec -= utcOffset * 60_000;
332
- return (0, rpcvalue_1.withOffset)(new Date(epochMsec), utcOffset ?? undefined);
327
+ return withOffset(new Date(epochMsec), utcOffset ?? undefined);
333
328
  }
334
329
  readCString() {
335
- const pctx = new cpcontext_1.PackContext();
330
+ const pctx = new PackContext();
336
331
  this.ctx.getByte(); // eat '"'
337
332
  while (true) {
338
333
  let b = this.ctx.getByte();
@@ -379,7 +374,7 @@ class CponReader {
379
374
  return utf8ToString(pctx.buffer());
380
375
  }
381
376
  readBlobEsc() {
382
- const pctx = new cpcontext_1.PackContext();
377
+ const pctx = new PackContext();
383
378
  this.ctx.getByte(); // eat '"'
384
379
  while (true) {
385
380
  let b = this.ctx.getByte();
@@ -422,7 +417,7 @@ class CponReader {
422
417
  return pctx.buffer();
423
418
  }
424
419
  readBlobHex() {
425
- const pctx = new cpcontext_1.PackContext();
420
+ const pctx = new PackContext();
426
421
  this.ctx.getByte(); // eat '"'
427
422
  while (true) {
428
423
  const b = this.ctx.getByte();
@@ -580,15 +575,14 @@ class CponReader {
580
575
  }
581
576
  mantisa += decimals;
582
577
  mantisa = isNeg ? -mantisa : mantisa;
583
- return new rpcvalue_1.Decimal(mantisa, exponent - decCnt);
578
+ return new Decimal(mantisa, exponent - decCnt);
584
579
  }
585
580
  if (isUint) {
586
- return new rpcvalue_1.UInt(mantisa);
581
+ return new UInt(mantisa);
587
582
  }
588
583
  return isNeg ? -mantisa : mantisa;
589
584
  }
590
585
  }
591
- exports.CponReader = CponReader;
592
586
  class CponWriter {
593
587
  indentString;
594
588
  oneLiners;
@@ -597,7 +591,7 @@ class CponWriter {
597
591
  constructor(indentString, oneLiners = OneLiners.Yes) {
598
592
  this.indentString = indentString;
599
593
  this.oneLiners = oneLiners;
600
- this.ctx = new cpcontext_1.PackContext();
594
+ this.ctx = new PackContext();
601
595
  }
602
596
  doIndentIfNotOneliner(map) {
603
597
  if (this.indentString === undefined || this.isOneLiner(map)) {
@@ -612,9 +606,9 @@ class CponWriter {
612
606
  }
613
607
  const keyThreshold = Array.isArray(value) ? 10 : 5;
614
608
  if (Array.isArray(value)) {
615
- return value.length <= keyThreshold && value.every(x => !Array.isArray(x) && !(0, rpcvalue_1.isShvMap)(x) && !(0, rpcvalue_1.isIMap)(x));
609
+ return value.length <= keyThreshold && value.every(x => !Array.isArray(x) && !isShvMap(x) && !isIMap(x));
616
610
  }
617
- return Object.keys(value).length <= keyThreshold && Object.values(value).every(x => (!Array.isArray(x) && !(0, rpcvalue_1.isShvMap)(x) && !(0, rpcvalue_1.isIMap)(x)));
611
+ return Object.keys(value).length <= keyThreshold && Object.values(value).every(x => (!Array.isArray(x) && !isShvMap(x) && !isIMap(x)));
618
612
  }
619
613
  increaseIndentIfNotOneLiner(value) {
620
614
  if (!this.isOneLiner(value)) {
@@ -627,7 +621,7 @@ class CponWriter {
627
621
  }
628
622
  }
629
623
  write(rpcVal) {
630
- if (rpcVal instanceof rpcvalue_1.RpcValueWithMetaData) {
624
+ if (rpcVal instanceof RpcValueWithMetaData) {
631
625
  this.writeMeta(rpcVal.meta);
632
626
  rpcVal = rpcVal.value;
633
627
  }
@@ -644,16 +638,16 @@ class CponWriter {
644
638
  case rpcVal instanceof ArrayBuffer:
645
639
  this.writeBlob(rpcVal);
646
640
  break;
647
- case rpcVal instanceof rpcvalue_1.UInt:
641
+ case rpcVal instanceof UInt:
648
642
  this.writeUInt(rpcVal);
649
643
  break;
650
644
  case typeof rpcVal === 'number':
651
645
  this.writeInt(rpcVal);
652
646
  break;
653
- case rpcVal instanceof rpcvalue_1.Double:
647
+ case rpcVal instanceof Double:
654
648
  this.writeDouble(rpcVal);
655
649
  break;
656
- case rpcVal instanceof rpcvalue_1.Decimal:
650
+ case rpcVal instanceof Decimal:
657
651
  this.writeDecimal(rpcVal);
658
652
  break;
659
653
  case Array.isArray(rpcVal):
@@ -663,7 +657,7 @@ class CponWriter {
663
657
  this.writeDateTime(rpcVal);
664
658
  break;
665
659
  case typeof rpcVal === 'object':
666
- switch (rpcVal[rpcvalue_1.shvMapType]) {
660
+ switch (rpcVal[shvMapType]) {
667
661
  case 'imap':
668
662
  this.writeIMap(rpcVal);
669
663
  break;
@@ -744,7 +738,7 @@ class CponWriter {
744
738
  }
745
739
  writeDateTime(dt) {
746
740
  this.ctx.writeStringUtf8('d"');
747
- this.ctx.writeStringUtf8((0, exports.stringifyDate)(dt));
741
+ this.ctx.writeStringUtf8(stringifyDate(dt));
748
742
  this.ctx.writeStringUtf8('"');
749
743
  }
750
744
  writeBool(b) {
@@ -770,14 +764,14 @@ class CponWriter {
770
764
  this.doIndentIfNotOneliner(map);
771
765
  }
772
766
  first = false;
773
- if (map[rpcvalue_1.shvMapType] === 'imap') {
767
+ if (map[shvMapType] === 'imap') {
774
768
  const intKey = Number(key);
775
769
  if (Number.isNaN(intKey)) {
776
770
  throw new TypeError('Invalid NaN IMap key');
777
771
  }
778
772
  this.writeInt(intKey);
779
773
  }
780
- else if (map[rpcvalue_1.shvMapType] === 'metamap') {
774
+ else if (map[shvMapType] === 'metamap') {
781
775
  const intKey = Number(key);
782
776
  if (Number.isNaN(intKey)) {
783
777
  this.ctx.putByte('"'.codePointAt(0));
@@ -868,25 +862,22 @@ class CponWriter {
868
862
  }
869
863
  }
870
864
  }
871
- exports.CponWriter = CponWriter;
872
- var OneLiners;
865
+ export var OneLiners;
873
866
  (function (OneLiners) {
874
867
  OneLiners[OneLiners["Yes"] = 0] = "Yes";
875
868
  OneLiners[OneLiners["No"] = 1] = "No";
876
- })(OneLiners || (exports.OneLiners = OneLiners = {}));
869
+ })(OneLiners || (OneLiners = {}));
877
870
  const toCpon = (value, indentString, oneLiners = OneLiners.Yes) => {
878
871
  const wr = new CponWriter(indentString, oneLiners);
879
872
  wr.write(value);
880
873
  return new TextDecoder().decode(wr.ctx.buffer());
881
874
  };
882
- exports.toCpon = toCpon;
883
875
  const fromCpon = (str) => {
884
876
  if (typeof str === 'string') {
885
877
  str = new TextEncoder().encode(str);
886
878
  }
887
- const rd = new CponReader(new cpcontext_1.UnpackContext(str.buffer));
879
+ const rd = new CponReader(new UnpackContext(str.buffer));
888
880
  return rd.read();
889
881
  };
890
- exports.fromCpon = fromCpon;
891
882
  const CPON_PROTOCOL_TYPE = 2;
892
- exports.CPON_PROTOCOL_TYPE = CPON_PROTOCOL_TYPE;
883
+ export { utf8ToString, CponWriter, CponReader, CPON_PROTOCOL_TYPE, toCpon, fromCpon };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * from './access';
2
- export * from './chainpack';
3
- export * from './cpcontext';
4
- export * from './cpon';
5
- export * from './json';
6
- export * from './rpcmessage';
7
- export * from './rpcvalue';
8
- export * from './shv-ri';
9
- export * from './ws-client';
1
+ export * from './access.js';
2
+ export * from './chainpack.js';
3
+ export * from './cpcontext.js';
4
+ export * from './cpon.js';
5
+ export * from './json.js';
6
+ export * from './rpcmessage.js';
7
+ export * from './rpcvalue.js';
8
+ export * from './shv-ri.js';
9
+ export * from './ws-client.js';
package/dist/index.js CHANGED
@@ -1,25 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./access"), exports);
18
- __exportStar(require("./chainpack"), exports);
19
- __exportStar(require("./cpcontext"), exports);
20
- __exportStar(require("./cpon"), exports);
21
- __exportStar(require("./json"), exports);
22
- __exportStar(require("./rpcmessage"), exports);
23
- __exportStar(require("./rpcvalue"), exports);
24
- __exportStar(require("./shv-ri"), exports);
25
- __exportStar(require("./ws-client"), exports);
1
+ export * from './access.js';
2
+ export * from './chainpack.js';
3
+ export * from './cpcontext.js';
4
+ export * from './cpon.js';
5
+ export * from './json.js';
6
+ export * from './rpcmessage.js';
7
+ export * from './rpcvalue.js';
8
+ export * from './shv-ri.js';
9
+ export * from './ws-client.js';
package/dist/json.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { type RpcValue } from './rpcvalue';
1
+ import { type RpcValue } from './rpcvalue.js';
2
2
  export declare const fromJson: (str: string) => RpcValue | Error;
3
3
  export declare const toJson: (value: RpcValue) => string | Error;