@ebusd/ebus-typespec 0.1.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 (55) hide show
  1. package/README.md +62 -0
  2. package/dist/src/csv_emitter.d.ts +14 -0
  3. package/dist/src/csv_emitter.js +493 -0
  4. package/dist/src/csv_emitter.js.map +1 -0
  5. package/dist/src/decorators.d.ts +284 -0
  6. package/dist/src/decorators.js +437 -0
  7. package/dist/src/decorators.js.map +1 -0
  8. package/dist/src/index.d.ts +6 -0
  9. package/dist/src/index.js +16 -0
  10. package/dist/src/index.js.map +1 -0
  11. package/dist/src/lib.d.ts +214 -0
  12. package/dist/src/lib.js +124 -0
  13. package/dist/src/lib.js.map +1 -0
  14. package/dist/src/linter.d.ts +1 -0
  15. package/dist/src/linter.js +47 -0
  16. package/dist/src/linter.js.map +1 -0
  17. package/dist/src/rules/no-function.rule.d.ts +3 -0
  18. package/dist/src/rules/no-function.rule.js +17 -0
  19. package/dist/src/rules/no-function.rule.js.map +1 -0
  20. package/dist/src/rules/no-interface.rule.d.ts +3 -0
  21. package/dist/src/rules/no-interface.rule.js +17 -0
  22. package/dist/src/rules/no-interface.rule.js.map +1 -0
  23. package/dist/src/rules/no-intrinsic.rule.d.ts +3 -0
  24. package/dist/src/rules/no-intrinsic.rule.js +19 -0
  25. package/dist/src/rules/no-intrinsic.rule.js.map +1 -0
  26. package/dist/src/rules/no-literal.rule.d.ts +3 -0
  27. package/dist/src/rules/no-literal.rule.js +20 -0
  28. package/dist/src/rules/no-literal.rule.js.map +1 -0
  29. package/dist/src/rules/no-object.rule.d.ts +3 -0
  30. package/dist/src/rules/no-object.rule.js +17 -0
  31. package/dist/src/rules/no-object.rule.js.map +1 -0
  32. package/dist/src/rules/no-operation.rule.d.ts +3 -0
  33. package/dist/src/rules/no-operation.rule.js +19 -0
  34. package/dist/src/rules/no-operation.rule.js.map +1 -0
  35. package/dist/src/rules/no-projection.rule.d.ts +3 -0
  36. package/dist/src/rules/no-projection.rule.js +17 -0
  37. package/dist/src/rules/no-projection.rule.js.map +1 -0
  38. package/dist/src/rules/no-template.rule.d.ts +3 -0
  39. package/dist/src/rules/no-template.rule.js +20 -0
  40. package/dist/src/rules/no-template.rule.js.map +1 -0
  41. package/dist/src/rules/no-tuple.rule.d.ts +3 -0
  42. package/dist/src/rules/no-tuple.rule.js +17 -0
  43. package/dist/src/rules/no-tuple.rule.js.map +1 -0
  44. package/dist/src/rules/no-union.rule.d.ts +3 -0
  45. package/dist/src/rules/no-union.rule.js +20 -0
  46. package/dist/src/rules/no-union.rule.js.map +1 -0
  47. package/dist/src/testing/index.d.ts +2 -0
  48. package/dist/src/testing/index.js +6 -0
  49. package/dist/src/testing/index.js.map +1 -0
  50. package/docs.md +453 -0
  51. package/lib/decorators.tsp +127 -0
  52. package/lib/main.tsp +3 -0
  53. package/lib/models.tsp +61 -0
  54. package/lib/types.tsp +169 -0
  55. package/package.json +61 -0
@@ -0,0 +1,437 @@
1
+ import { getPropertyType, isIntrinsicType, isNumericType, setTypeSpecNamespace } from "@typespec/compiler";
2
+ import { StateKeys, reportDiagnostic } from "./lib.js";
3
+ export const namespace = "Ebus";
4
+ /**
5
+ * Implementation of the `@condition` decorator.
6
+ *
7
+ * @param context Decorator context.
8
+ * @param target Decorator target.
9
+ * @param value the value to set.
10
+ */
11
+ export function $condition(context, target, property, ...values) {
12
+ const prev = (context.program.stateMap(StateKeys.condition).get(target) || []);
13
+ if (target.kind === 'Namespace' && prev.some(([p]) => p.name === property.name)) {
14
+ return;
15
+ }
16
+ context.program.stateMap(StateKeys.condition).set(target, [...prev, [property, ...values]]);
17
+ }
18
+ /**
19
+ * Accessor for the `@condition` decorator.
20
+ *
21
+ * @param program TypeSpec program.
22
+ * @param target Decorator target.
23
+ * @returns value if provided on the given target or undefined.
24
+ */
25
+ export function getConditions(program, target) {
26
+ return program.stateMap(StateKeys.condition).get(target);
27
+ }
28
+ /**
29
+ * Implementation of the `@write` decorator.
30
+ *
31
+ * @param context Decorator context.
32
+ * @param target Decorator target.
33
+ */
34
+ export function $write(context, target) {
35
+ context.program.stateMap(StateKeys.write).set(target, true);
36
+ }
37
+ /**
38
+ * Accessor for the `@write` decorator.
39
+ *
40
+ * @param program TypeSpec program.
41
+ * @param target Decorator target.
42
+ * @returns value if provided on the given target or undefined.
43
+ */
44
+ export function getWrite(program, target) {
45
+ return program.stateMap(StateKeys.write).get(target);
46
+ }
47
+ /**
48
+ * Implementation of the `@passive` decorator.
49
+ *
50
+ * @param context Decorator context.
51
+ * @param target Decorator target.
52
+ */
53
+ export function $passive(context, target) {
54
+ context.program.stateMap(StateKeys.passive).set(target, true);
55
+ }
56
+ /**
57
+ * Accessor for the `@passive` decorator.
58
+ *
59
+ * @param program TypeSpec program.
60
+ * @param target Decorator target.
61
+ * @returns value if provided on the given target or undefined.
62
+ */
63
+ export function getPassive(program, target) {
64
+ return program.stateMap(StateKeys.passive).get(target);
65
+ }
66
+ /**
67
+ * Implementation of the `@auth` decorator.
68
+ *
69
+ * @param context Decorator context.
70
+ * @param target Decorator target.
71
+ * @param value the value to set.
72
+ */
73
+ export function $auth(context, target, value) {
74
+ if (value && !/^[a-z]*$/.test(value)) {
75
+ reportDiagnostic(context.program, {
76
+ code: "banned-auth",
77
+ target: context.getArgumentTarget(0),
78
+ format: { value: value.toString() },
79
+ });
80
+ return;
81
+ }
82
+ context.program.stateMap(StateKeys.auth).set(target, value);
83
+ }
84
+ /**
85
+ * Accessor for the `@auth` decorator.
86
+ *
87
+ * @param program TypeSpec program.
88
+ * @param target Decorator target.
89
+ * @returns value if provided on the given target or undefined.
90
+ */
91
+ export function getAuth(program, target) {
92
+ return program.stateMap(StateKeys.auth).get(target);
93
+ }
94
+ const validSource = new Uint8Array([
95
+ 0x00, 0x01, 0x03, 0x07, 0x0f,
96
+ 0x10, 0x11, 0x13, 0x17, 0x1f,
97
+ 0x30, 0x31, 0x33, 0x37, 0x3f,
98
+ 0x70, 0x71, 0x73, 0x77, 0x7f,
99
+ 0xf0, 0xf1, 0xf3, 0xf7, 0xff,
100
+ ]);
101
+ const invalidTarget = new Uint8Array([0xa9, 0xaa]);
102
+ export const isSourceAddr = (qq) => qq !== undefined && validSource.includes(qq);
103
+ /**
104
+ * Implementation of the `@qq` decorator.
105
+ *
106
+ * @param context Decorator context.
107
+ * @param target Decorator target.
108
+ * @param value the value to set.
109
+ */
110
+ export function $qq(context, target, value) {
111
+ if (value !== undefined && !validSource.includes(value)) {
112
+ reportDiagnostic(context.program, {
113
+ code: "banned-source-address",
114
+ target: context.getArgumentTarget(0),
115
+ format: { value: value.toString() },
116
+ });
117
+ return;
118
+ }
119
+ context.program.stateMap(StateKeys.qq).set(target, value);
120
+ }
121
+ /**
122
+ * Accessor for the `@qq` decorator.
123
+ *
124
+ * @param program TypeSpec program.
125
+ * @param target Decorator target.
126
+ * @returns value if provided on the given target or undefined.
127
+ */
128
+ export function getQq(program, target) {
129
+ return program.stateMap(StateKeys.qq).get(target);
130
+ }
131
+ /**
132
+ * Implementation of the `@zz` decorator.
133
+ *
134
+ * @param context Decorator context.
135
+ * @param target Decorator target.
136
+ * @param value the value to set.
137
+ */
138
+ export function $zz(context, target, value) {
139
+ if (value !== undefined && invalidTarget.includes(value)) {
140
+ reportDiagnostic(context.program, {
141
+ code: "banned-target-address",
142
+ target: context.getArgumentTarget(0),
143
+ format: { value: value.toString() },
144
+ });
145
+ return;
146
+ }
147
+ context.program.stateMap(StateKeys.zz).set(target, value === undefined ? 0xaa : value);
148
+ }
149
+ /**
150
+ * Accessor for the `@zz` decorator.
151
+ *
152
+ * @param program TypeSpec program.
153
+ * @param target Decorator target.
154
+ * @returns value if provided on the given target or undefined.
155
+ */
156
+ export function getZz(program, target) {
157
+ return program.stateMap(StateKeys.zz).get(target);
158
+ }
159
+ /**
160
+ * Implementation of the `@id` decorator.
161
+ *
162
+ * @param context Decorator context.
163
+ * @param target Decorator target.
164
+ * @param value the value to set.
165
+ */
166
+ export function $id(context, target, pb, sb, ...dd) {
167
+ context.program.stateMap(StateKeys.id).set(target, [pb, sb, ...dd]);
168
+ context.program.stateSet(StateKeys.id).add(target);
169
+ }
170
+ /**
171
+ * Implementation of the `@base` decorator.
172
+ *
173
+ * @param context Decorator context.
174
+ * @param target Decorator target.
175
+ * @param value the value to set.
176
+ */
177
+ export function $base(context, target, pb, sb, ...dd) {
178
+ context.program.stateMap(StateKeys.id).set(target, [pb, sb, ...dd]);
179
+ }
180
+ /**
181
+ * Implementation of the `@ext` decorator.
182
+ *
183
+ * @param context Decorator context.
184
+ * @param target Decorator target.
185
+ * @param value the value to set.
186
+ */
187
+ export function $ext(context, target, ...dd) {
188
+ context.program.stateMap(StateKeys.id).set(target, dd);
189
+ context.program.stateSet(StateKeys.id).add(target);
190
+ }
191
+ /**
192
+ * Accessor for the `@id` decorator.
193
+ *
194
+ * @param program TypeSpec program.
195
+ * @param target Decorator target.
196
+ * @returns value if provided on the given target or undefined.
197
+ */
198
+ export function getId(program, target) {
199
+ return program.stateMap(StateKeys.id).get(target);
200
+ }
201
+ /**
202
+ * Implementation of the `@inherit` decorator.
203
+ *
204
+ * @param context Decorator context.
205
+ * @param target Decorator target.
206
+ * @param value the inherited models.
207
+ */
208
+ export function $inherit(context, target, first, ...other) {
209
+ context.program.stateMap(StateKeys.inherit).set(target, [first, ...other]);
210
+ }
211
+ /**
212
+ * Accessor for the `@inherit` decorator.
213
+ *
214
+ * @param program TypeSpec program.
215
+ * @param target Decorator target.
216
+ * @returns value if provided on the given target or undefined.
217
+ */
218
+ export function getInherit(program, target) {
219
+ return program.stateMap(StateKeys.inherit).get(target);
220
+ }
221
+ /**
222
+ * Implementation of the `@reverse` decorator.
223
+ *
224
+ * @param context Decorator context.
225
+ * @param target Decorator target.
226
+ */
227
+ export function $reverse(context, target) {
228
+ context.program.stateMap(StateKeys.reverse).set(target, true);
229
+ }
230
+ /**
231
+ * Accessor for the `@reverse` decorator.
232
+ *
233
+ * @param program TypeSpec program.
234
+ * @param target Decorator target.
235
+ * @returns value if provided on the given target or undefined.
236
+ */
237
+ export function getReverse(program, target) {
238
+ return program.stateMap(StateKeys.reverse).has(target);
239
+ }
240
+ /**
241
+ * Implementation of the `@bcd` decorator.
242
+ *
243
+ * @param context Decorator context.
244
+ * @param target Decorator target.
245
+ */
246
+ export function $bcd(context, target) {
247
+ context.program.stateMap(StateKeys.bcd).set(target, true);
248
+ }
249
+ /**
250
+ * Accessor for the `@bcd` decorator.
251
+ *
252
+ * @param program TypeSpec program.
253
+ * @param target Decorator target.
254
+ * @returns value if provided on the given target or undefined.
255
+ */
256
+ export function getBcd(program, target) {
257
+ return program.stateMap(StateKeys.bcd).has(target);
258
+ }
259
+ /**
260
+ * Implementation of the `@hex` decorator.
261
+ *
262
+ * @param context Decorator context.
263
+ * @param target Decorator target.
264
+ */
265
+ export function $hex(context, target) {
266
+ context.program.stateMap(StateKeys.hex).set(target, true);
267
+ }
268
+ /**
269
+ * Accessor for the `@hex` decorator.
270
+ *
271
+ * @param program TypeSpec program.
272
+ * @param target Decorator target.
273
+ * @returns value if provided on the given target or undefined.
274
+ */
275
+ export function getHex(program, target) {
276
+ return program.stateMap(StateKeys.hex).has(target);
277
+ }
278
+ /**
279
+ * Implementation of the `@maxBits` decorator.
280
+ *
281
+ * @param context Decorator context.
282
+ * @param target Decorator target.
283
+ * @param value the value to set.
284
+ */
285
+ export function $maxBits(context, target, value) {
286
+ if (value <= 0 || value > 7) {
287
+ reportDiagnostic(context.program, {
288
+ code: "banned-length",
289
+ target: context.getArgumentTarget(0),
290
+ format: { which: 'maxBits', value: '7' },
291
+ });
292
+ }
293
+ context.program.stateMap(StateKeys.maxBits).set(target, value);
294
+ }
295
+ /**
296
+ * Accessor for the `@maxBits` decorator.
297
+ *
298
+ * @param program TypeSpec program.
299
+ * @param target Decorator target.
300
+ * @returns value if provided on the given target or undefined.
301
+ */
302
+ export function getMaxBits(program, target) {
303
+ return program.stateMap(StateKeys.maxBits).get(target);
304
+ }
305
+ setTypeSpecNamespace("internal", $reverse, $bcd, $hex, $maxBits);
306
+ /**
307
+ * Implementation of the `@in` decorator.
308
+ *
309
+ * @param context Decorator context.
310
+ * @param target Decorator target.
311
+ */
312
+ export function $in(context, target) {
313
+ context.program.stateMap(StateKeys.out).set(target, false);
314
+ }
315
+ /**
316
+ * Implementation of the `@out` decorator.
317
+ *
318
+ * @param context Decorator context.
319
+ * @param target Decorator target.
320
+ */
321
+ export function $out(context, target) {
322
+ context.program.stateMap(StateKeys.out).set(target, true);
323
+ }
324
+ /**
325
+ * Accessor for the `@in`/`@out` decorators.
326
+ *
327
+ * @param program TypeSpec program.
328
+ * @param target Decorator target.
329
+ * @returns value if provided on the given target (true when `out`, false when `in`), or undefined.
330
+ */
331
+ export function getOut(program, target) {
332
+ return program.stateMap(StateKeys.out).get(target);
333
+ }
334
+ /**
335
+ * Implementation of the `@unit` decorator.
336
+ *
337
+ * @param context Decorator context.
338
+ * @param target Decorator target.
339
+ * @param value the value to set.
340
+ */
341
+ export function $unit(context, target, value) {
342
+ context.program.stateMap(StateKeys.unit).set(target, value);
343
+ }
344
+ /**
345
+ * Accessor for the `@unit` decorator.
346
+ *
347
+ * @param program TypeSpec program.
348
+ * @param target Decorator target.
349
+ * @returns value if provided on the given target or undefined.
350
+ */
351
+ export function getUnit(program, target) {
352
+ return program.stateMap(StateKeys.unit).get(target);
353
+ }
354
+ /**
355
+ * Implementation of the `@divisor` decorator.
356
+ *
357
+ * @param context Decorator context.
358
+ * @param target Decorator target.
359
+ * @param value the value to set.
360
+ */
361
+ export function $divisor(context, target, value) {
362
+ // this works only for direct Scalars, not for indirect ones via ModelProperty:
363
+ const isPlainTime = target.kind === 'Scalar' && isIntrinsicType(context.program, target, 'plainTime'); // for internal time types
364
+ if (!(isNumericType(context.program, getPropertyType(target)) || isPlainTime)
365
+ || (typeof value !== 'number') || (value <= 0)
366
+ || context.program.stateMap(StateKeys.values).has(target)) {
367
+ reportDiagnostic(context.program, {
368
+ code: "banned-divisor",
369
+ target: context.getArgumentTarget(0),
370
+ format: { value: value.toString() },
371
+ });
372
+ return;
373
+ }
374
+ context.program.stateMap(StateKeys.divisor).set(target, value);
375
+ }
376
+ /**
377
+ * Implementation of the `@factor` decorator.
378
+ *
379
+ * @param context Decorator context.
380
+ * @param target Decorator target.
381
+ * @param value the value to set.
382
+ */
383
+ export function $factor(context, target, value) {
384
+ const isPlainTime = target.kind === 'Scalar' && isIntrinsicType(context.program, target, 'plainTime'); // for internal time types
385
+ if (!(isNumericType(context.program, getPropertyType(target)) || isPlainTime)
386
+ || (typeof value !== 'number') || (value <= 0)
387
+ || context.program.stateMap(StateKeys.values).has(target)) {
388
+ reportDiagnostic(context.program, {
389
+ code: "banned-factor",
390
+ target: context.getArgumentTarget(0),
391
+ format: { value: value.toString() },
392
+ });
393
+ return;
394
+ }
395
+ context.program.stateMap(StateKeys.divisor).set(target, 1.0 / value);
396
+ }
397
+ /**
398
+ * Accessor for the `@divisor` decorator.
399
+ *
400
+ * @param program TypeSpec program.
401
+ * @param target Decorator target.
402
+ * @returns value if provided on the given target or undefined.
403
+ */
404
+ export function getDivisor(program, target) {
405
+ return program.stateMap(StateKeys.divisor).get(target);
406
+ }
407
+ /**
408
+ * Implementation of the `@values` decorator.
409
+ *
410
+ * @param context Decorator context.
411
+ * @param target Decorator target.
412
+ * @param value the value to set.
413
+ */
414
+ export function $values(context, target, value) {
415
+ //todo tolerated for now as check for boolean is missing
416
+ // if (!isNumericType(context.program, getPropertyType(target))
417
+ // || context.program.stateMap(StateKeys.divisor).has(target)) {
418
+ // reportDiagnostic(context.program, {
419
+ // code: "banned-values",
420
+ // target: context.getArgumentTarget(0)!,
421
+ // format: { detail },
422
+ // });
423
+ // return;
424
+ // }
425
+ context.program.stateMap(StateKeys.values).set(target, value);
426
+ }
427
+ /**
428
+ * Accessor for the `@values` decorator.
429
+ *
430
+ * @param program TypeSpec program.
431
+ * @param target Decorator target.
432
+ * @returns value if provided on the given target or undefined.
433
+ */
434
+ export function getValues(program, target) {
435
+ return program.stateMap(StateKeys.values).get(target);
436
+ }
437
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,aAAa,EAC/C,oBAAoB,EAGrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,SAAS,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAErD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAAyB,EAAE,MAAoC,EAAE,QAA6B,EAAE,GAAG,MAAgB;IAC5I,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAE,EAAE,CAAyC,CAAC;IACrH,IAAI,MAAM,CAAC,IAAI,KAAG,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5E,OAAO;IACT,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,MAAoC;IAClF,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,OAAyB,EAAE,MAAa;IAC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,wDAAwD;IACxD,+DAA+D;IAC/D,gEAAgE;IAChE,wCAAwC;IACxC,6BAA6B;IAC7B,6CAA6C;IAC7C,0BAA0B;IAC1B,QAAQ;IACR,YAAY;IACZ,IAAI;IACJ,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,OAAgB,EAAE,MAA4B;IACtE,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { EmitContext } from "@typespec/compiler";
2
+ import { type EbusdEmitterOptions } from "./lib.js";
3
+ export { getAuth, getBcd, getConditions, getDivisor, getHex, getId, getInherit, getMaxBits, getOut, getPassive, getQq, getReverse, getUnit, getValues, getWrite, getZz } from "./decorators.js";
4
+ export { $lib } from "./lib.js";
5
+ export { $linter } from "./linter.js";
6
+ export declare function $onEmit(context: EmitContext<EbusdEmitterOptions>): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import { EbusdEmitter } from "./csv_emitter.js";
2
+ export { getAuth, getBcd, getConditions, getDivisor, getHex, getId, getInherit, getMaxBits, getOut, getPassive, getQq, getReverse, getUnit, getValues, getWrite, getZz } from "./decorators.js";
3
+ export { $lib } from "./lib.js";
4
+ export { $linter } from "./linter.js";
5
+ export async function $onEmit(context) {
6
+ const emitter =
7
+ // context.options["file-type"]==='csv'?
8
+ context.getAssetEmitter(EbusdEmitter);
9
+ // :context.getAssetEmitter(EbusSchemaEmitter);
10
+ emitter.emitProgram();
11
+ await emitter.writeOutput();
12
+ }
13
+ // export function getEbusdTypes(program: Program): Model[] {
14
+ // return [...(program.stateSet(StateKeys.id) || [])] as Model[];
15
+ // }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC9L,OAAO,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAyC;IACrE,MAAM,OAAO;IACb,wCAAwC;IACxC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAA;IACrC,+CAA+C;IAC/C,OAAO,CAAC,WAAW,EAAE,CAAC;IACtB,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;AAC9B,CAAC;AAED,6DAA6D;AAC7D,mEAAmE;AACnE,IAAI"}