@tolgee/cli 1.0.0-prerelease.1

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/client/errors.js +36 -0
  4. package/dist/client/export.js +23 -0
  5. package/dist/client/import.js +61 -0
  6. package/dist/client/index.js +79 -0
  7. package/dist/client/internal/requester.js +145 -0
  8. package/dist/client/internal/schema.generated.js +6 -0
  9. package/dist/client/internal/schema.utils.js +2 -0
  10. package/dist/client/languages.js +16 -0
  11. package/dist/client/project.js +44 -0
  12. package/dist/commands/extract/check.js +41 -0
  13. package/dist/commands/extract/print.js +51 -0
  14. package/dist/commands/extract.js +14 -0
  15. package/dist/commands/login.js +49 -0
  16. package/dist/commands/pull.js +38 -0
  17. package/dist/commands/push.js +122 -0
  18. package/dist/commands/sync/compare.js +48 -0
  19. package/dist/commands/sync/sync.js +110 -0
  20. package/dist/commands/sync/syncUtils.js +64 -0
  21. package/dist/config/credentials.js +125 -0
  22. package/dist/config/tolgeerc.js +64 -0
  23. package/dist/constants.js +18 -0
  24. package/dist/extractor/index.js +2 -0
  25. package/dist/extractor/machines/react.js +728 -0
  26. package/dist/extractor/machines/shared/comments.js +82 -0
  27. package/dist/extractor/machines/shared/properties.js +226 -0
  28. package/dist/extractor/presets/react.js +29 -0
  29. package/dist/extractor/runner.js +39 -0
  30. package/dist/extractor/tokenizer.js +102 -0
  31. package/dist/extractor/warnings.js +89 -0
  32. package/dist/extractor/worker.js +82 -0
  33. package/dist/index.js +151 -0
  34. package/dist/options.js +37 -0
  35. package/dist/utils/ask.js +34 -0
  36. package/dist/utils/configPath.js +17 -0
  37. package/dist/utils/deferred.js +11 -0
  38. package/dist/utils/logger.js +93 -0
  39. package/dist/utils/moduleLoader.js +43 -0
  40. package/dist/utils/overwriteDir.js +38 -0
  41. package/dist/utils/zip.js +83 -0
  42. package/extractor.d.ts +21 -0
  43. package/package.json +98 -0
  44. package/textmate/THIRD_PARTY_NOTICE +31 -0
  45. package/textmate/TypeScript.tmLanguage +9728 -0
  46. package/textmate/TypeScriptReact.tmLanguage +10158 -0
@@ -0,0 +1,728 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const xstate_1 = require("xstate");
7
+ const properties_1 = __importDefault(require("./shared/properties"));
8
+ const comments_1 = __importDefault(require("./shared/comments"));
9
+ const VOID_KEY = { keyName: '', line: -1 };
10
+ exports.default = (0, xstate_1.createMachine)({
11
+ predictableActionArguments: true,
12
+ id: 'reactExtractor',
13
+ type: 'parallel',
14
+ context: {
15
+ blockDepth: 0,
16
+ children: '',
17
+ line: 0,
18
+ key: VOID_KEY,
19
+ hooks: [],
20
+ ignore: null,
21
+ keys: [],
22
+ warnings: [],
23
+ },
24
+ states: {
25
+ comments: {
26
+ invoke: {
27
+ id: 'comments',
28
+ src: () => comments_1.default,
29
+ },
30
+ on: {
31
+ // Service messages
32
+ MAGIC_COMMENT: [
33
+ {
34
+ actions: 'ignoreNextLine',
35
+ cond: (_ctx, evt) => evt.kind === 'ignore',
36
+ },
37
+ {
38
+ actions: 'pushImmediateKey',
39
+ cond: (_ctx, evt) => evt.kind === 'key',
40
+ },
41
+ ],
42
+ WARNING: {
43
+ actions: 'pushWarning',
44
+ },
45
+ // Code messages
46
+ 'comment.line.double-slash.ts': {
47
+ actions: (0, xstate_1.send)((_ctx, evt) => ({
48
+ type: 'COMMENT',
49
+ data: evt.token,
50
+ line: evt.line,
51
+ }), { to: 'comments' }),
52
+ },
53
+ 'comment.block.ts': {
54
+ actions: (0, xstate_1.send)((_ctx, evt) => ({
55
+ type: 'COMMENT',
56
+ data: evt.token,
57
+ line: evt.line,
58
+ }), { to: 'comments' }),
59
+ },
60
+ newline: {
61
+ actions: 'warnUnusedIgnore',
62
+ cond: (ctx, evt) => ctx.ignore?.type === 'ignore' && ctx.ignore.line === evt.line,
63
+ },
64
+ },
65
+ },
66
+ useTranslate: {
67
+ initial: 'idle',
68
+ states: {
69
+ idle: {
70
+ on: {
71
+ 'entity.name.function.ts': {
72
+ target: 'func',
73
+ actions: 'storeLine',
74
+ cond: (_ctx, evt) => evt.token === 'useTranslate',
75
+ },
76
+ },
77
+ },
78
+ func: {
79
+ on: {
80
+ '*': 'idle',
81
+ newline: undefined,
82
+ 'meta.block.ts': undefined,
83
+ 'meta.var.expr.ts': undefined,
84
+ 'meta.brace.round.ts': [
85
+ {
86
+ target: 'idle',
87
+ actions: 'consumeIgnoredLine',
88
+ cond: (ctx, evt) => ctx.ignore?.line === ctx.line &&
89
+ ctx.ignore.type === 'ignore' &&
90
+ evt.token === '(',
91
+ },
92
+ {
93
+ target: 'call',
94
+ cond: (_ctx, evt) => evt.token === '(',
95
+ },
96
+ ],
97
+ },
98
+ },
99
+ call: {
100
+ on: {
101
+ 'punctuation.definition.string.begin.ts': 'namespace',
102
+ 'punctuation.definition.string.template.begin.ts': 'namespace',
103
+ 'variable.other.readwrite.ts': {
104
+ target: 'idle',
105
+ actions: ['pushHook', 'markHookAsDynamic'],
106
+ },
107
+ 'meta.brace.round.ts': {
108
+ target: 'idle',
109
+ cond: (_ctx, evt) => evt.token === ')',
110
+ actions: 'pushHook',
111
+ },
112
+ },
113
+ },
114
+ namespace: {
115
+ on: {
116
+ '*': {
117
+ target: 'namespace_end',
118
+ actions: 'pushNamespacedHook',
119
+ },
120
+ },
121
+ },
122
+ namespace_end: {
123
+ on: {
124
+ 'punctuation.separator.comma.ts': 'idle',
125
+ 'meta.brace.round.ts': 'idle',
126
+ 'punctuation.definition.template-expression.begin.ts': {
127
+ target: 'idle',
128
+ actions: 'markHookAsDynamic',
129
+ },
130
+ 'keyword.operator.arithmetic.ts': {
131
+ target: 'idle',
132
+ actions: 'markHookAsDynamic',
133
+ },
134
+ },
135
+ },
136
+ },
137
+ on: {
138
+ 'punctuation.definition.block.ts': [
139
+ {
140
+ cond: (_ctx, evt) => evt.token === '{',
141
+ actions: 'incrementDepth',
142
+ },
143
+ {
144
+ cond: (_ctx, evt) => evt.token === '}',
145
+ actions: 'decrementDepth',
146
+ },
147
+ ],
148
+ },
149
+ },
150
+ createElement: {
151
+ initial: 'idle',
152
+ states: {
153
+ idle: {
154
+ on: {
155
+ 'variable.other.object.ts': {
156
+ target: 'func1',
157
+ actions: 'storeLine',
158
+ cond: (_ctx, evt) => evt.token === 'React',
159
+ },
160
+ },
161
+ },
162
+ func1: {
163
+ on: {
164
+ '*': 'idle',
165
+ newline: undefined,
166
+ 'meta.function-call.ts': undefined,
167
+ 'punctuation.accessor.ts': {
168
+ target: 'func2',
169
+ cond: (_ctx, evt) => evt.token === '.',
170
+ },
171
+ },
172
+ },
173
+ func2: {
174
+ on: {
175
+ '*': 'idle',
176
+ newline: undefined,
177
+ 'meta.function-call.ts': undefined,
178
+ 'support.function.dom.ts': {
179
+ target: 'func3',
180
+ cond: (_ctx, evt) => evt.token === 'createElement',
181
+ },
182
+ },
183
+ },
184
+ func3: {
185
+ on: {
186
+ '*': 'idle',
187
+ newline: undefined,
188
+ 'meta.function-call.ts': undefined,
189
+ 'meta.brace.round.ts': {
190
+ target: 'call',
191
+ cond: (_ctx, evt) => evt.token === '(',
192
+ },
193
+ },
194
+ },
195
+ call: {
196
+ on: {
197
+ '*': 'idle',
198
+ newline: undefined,
199
+ 'variable.other.constant.ts': [
200
+ {
201
+ target: 'idle',
202
+ actions: 'consumeIgnoredLine',
203
+ cond: (ctx, evt) => ctx.ignore?.line === ctx.line && evt.token === 'T',
204
+ },
205
+ {
206
+ target: 'props',
207
+ cond: (_ctx, evt) => evt.token === 'T',
208
+ },
209
+ ],
210
+ },
211
+ },
212
+ props: {
213
+ on: {
214
+ 'constant.language.null.ts': 'children',
215
+ 'punctuation.definition.block.ts': {
216
+ target: 'props_object',
217
+ cond: (_ctx, evt) => evt.token === '{',
218
+ },
219
+ },
220
+ },
221
+ props_object: {
222
+ invoke: {
223
+ id: 'propertiesMachine',
224
+ src: properties_1.default,
225
+ data: {
226
+ depth: 1,
227
+ },
228
+ onDone: [
229
+ {
230
+ target: 'idle',
231
+ actions: 'emitWarningFromParameters',
232
+ cond: 'isPropertiesDataDynamic',
233
+ },
234
+ {
235
+ target: 'children',
236
+ actions: 'consumeParameters',
237
+ cond: (ctx, evt) => (!ctx.key.keyName && !evt.data.keyName) ||
238
+ (!ctx.key.defaultValue && !evt.data.defaultValue),
239
+ },
240
+ {
241
+ target: 'idle',
242
+ actions: ['consumeParameters', 'pushKey'],
243
+ },
244
+ ],
245
+ },
246
+ on: {
247
+ '*': {
248
+ actions: (0, xstate_1.forwardTo)('propertiesMachine'),
249
+ },
250
+ },
251
+ },
252
+ children: {
253
+ on: {
254
+ '*': [
255
+ {
256
+ target: 'idle',
257
+ actions: 'pushKey',
258
+ cond: (ctx) => !!ctx.key.keyName,
259
+ },
260
+ {
261
+ target: 'idle',
262
+ },
263
+ ],
264
+ 'variable.other.readwrite.ts': {
265
+ target: 'idle',
266
+ actions: ['dynamicKeyDefault', 'pushKey'],
267
+ },
268
+ // Void & punctuation
269
+ newline: undefined,
270
+ 'meta.objectliteral.ts': undefined,
271
+ 'punctuation.separator.comma.ts': undefined,
272
+ // String
273
+ 'punctuation.definition.string.begin.ts': 'children_string',
274
+ 'punctuation.definition.string.template.begin.ts': 'children_string',
275
+ },
276
+ },
277
+ children_string: {
278
+ on: {
279
+ '*': [
280
+ {
281
+ target: 'children_end',
282
+ actions: 'storeKeyName',
283
+ cond: (ctx) => !ctx.key.keyName,
284
+ },
285
+ {
286
+ target: 'children_end',
287
+ actions: 'storeKeyDefault',
288
+ cond: (ctx) => !!ctx.key.keyName,
289
+ },
290
+ ],
291
+ },
292
+ },
293
+ children_end: {
294
+ on: {
295
+ 'punctuation.separator.comma.ts': {
296
+ target: 'idle',
297
+ actions: 'pushKey',
298
+ },
299
+ 'meta.brace.round.ts': {
300
+ target: 'idle',
301
+ actions: 'pushKey',
302
+ },
303
+ 'punctuation.definition.template-expression.begin.ts': {
304
+ target: 'idle',
305
+ actions: ['dynamicKeyDefault', 'pushKey'],
306
+ },
307
+ 'keyword.operator.arithmetic.ts': {
308
+ target: 'idle',
309
+ actions: ['dynamicKeyDefault', 'pushKey'],
310
+ },
311
+ },
312
+ },
313
+ },
314
+ },
315
+ jsx: {
316
+ initial: 'idle',
317
+ states: {
318
+ idle: {
319
+ on: {
320
+ 'punctuation.definition.tag.begin.tsx': {
321
+ target: 'tag',
322
+ actions: 'storeLine',
323
+ cond: (_ctx, evt) => evt.token === '<',
324
+ },
325
+ },
326
+ },
327
+ tag: {
328
+ on: {
329
+ '*': 'idle',
330
+ newline: undefined,
331
+ 'meta.tag.ts': undefined,
332
+ 'support.class.component.tsx': [
333
+ {
334
+ target: 'idle',
335
+ actions: 'consumeIgnoredLine',
336
+ cond: (ctx, evt) => ctx.ignore?.line === ctx.line && evt.token === 'T',
337
+ },
338
+ {
339
+ target: 'props',
340
+ cond: (_ctx, evt) => evt.token === 'T',
341
+ },
342
+ ],
343
+ },
344
+ },
345
+ props: {
346
+ invoke: {
347
+ id: 'propertiesMachine',
348
+ src: properties_1.default,
349
+ onDone: [
350
+ {
351
+ target: 'idle',
352
+ actions: 'emitWarningFromParameters',
353
+ cond: 'isPropertiesDataDynamic',
354
+ },
355
+ {
356
+ target: 'children',
357
+ actions: 'consumeParameters',
358
+ cond: (ctx, evt) => evt.data.lastEvent.token !== '/>' &&
359
+ ((!ctx.key.keyName && !evt.data.keyName) ||
360
+ (!ctx.key.defaultValue && !evt.data.defaultValue)),
361
+ },
362
+ {
363
+ target: 'idle',
364
+ actions: ['consumeParameters', 'pushKey'],
365
+ },
366
+ ],
367
+ },
368
+ on: {
369
+ '*': {
370
+ actions: (0, xstate_1.forwardTo)('propertiesMachine'),
371
+ },
372
+ },
373
+ },
374
+ children: {
375
+ on: {
376
+ 'punctuation.definition.tag.begin.tsx': {
377
+ target: 'idle',
378
+ actions: ['consumeChildren', 'pushKey'],
379
+ },
380
+ 'meta.jsx.children.tsx': {
381
+ actions: 'appendChildren',
382
+ },
383
+ 'string.quoted.single.ts': {
384
+ actions: 'appendChildren',
385
+ },
386
+ 'string.quoted.double.ts': {
387
+ actions: 'appendChildren',
388
+ },
389
+ 'string.template.ts': {
390
+ actions: 'appendChildren',
391
+ },
392
+ 'variable.other.readwrite.ts': {
393
+ target: 'idle',
394
+ actions: ['dynamicChildren', 'pushKey'],
395
+ },
396
+ 'punctuation.definition.template-expression.begin.ts': {
397
+ target: 'idle',
398
+ actions: ['dynamicChildren', 'pushKey'],
399
+ },
400
+ 'keyword.operator.arithmetic.ts': {
401
+ target: 'idle',
402
+ actions: ['dynamicChildren', 'pushKey'],
403
+ },
404
+ },
405
+ },
406
+ },
407
+ },
408
+ t: {
409
+ initial: 'idle',
410
+ states: {
411
+ idle: {
412
+ on: {
413
+ 'entity.name.function.ts': {
414
+ target: 'func',
415
+ actions: 'storeLine',
416
+ cond: (ctx, evt) => !!ctx.hooks.length && evt.token === 't',
417
+ },
418
+ },
419
+ },
420
+ func: {
421
+ on: {
422
+ '*': 'idle',
423
+ newline: undefined,
424
+ 'meta.block.ts': undefined,
425
+ 'meta.var.expr.ts': undefined,
426
+ 'meta.brace.round.ts': [
427
+ {
428
+ target: 'idle',
429
+ actions: 'consumeIgnoredLine',
430
+ cond: (ctx, evt) => ctx.ignore?.line === ctx.line && evt.token === '(',
431
+ },
432
+ {
433
+ target: 'call',
434
+ cond: (_ctx, evt) => evt.token === '(',
435
+ },
436
+ ],
437
+ },
438
+ },
439
+ call: {
440
+ on: {
441
+ 'punctuation.definition.string.begin.ts': 'param_string',
442
+ 'punctuation.definition.string.template.begin.ts': 'param_string',
443
+ 'variable.other.readwrite.ts': [
444
+ {
445
+ target: 'idle',
446
+ actions: 'dynamicOptions',
447
+ cond: (ctx) => !!ctx.key.keyName,
448
+ },
449
+ {
450
+ target: 'idle',
451
+ actions: 'dynamicKeyName',
452
+ },
453
+ ],
454
+ 'punctuation.definition.block.ts': {
455
+ target: 'param_object',
456
+ cond: (_ctx, evt) => evt.token === '{',
457
+ },
458
+ 'meta.brace.round.ts': {
459
+ target: 'idle',
460
+ cond: (_ctx, evt) => evt.token === ')',
461
+ actions: 'pushKey',
462
+ },
463
+ },
464
+ },
465
+ param_string: {
466
+ on: {
467
+ '*': [
468
+ {
469
+ target: 'param_end',
470
+ actions: ['storeKeyName', 'storeKeyCurrentNamespace'],
471
+ cond: (ctx) => !ctx.key.keyName,
472
+ },
473
+ {
474
+ target: 'param_end',
475
+ actions: ['storeKeyDefault', 'storeKeyCurrentNamespace'],
476
+ cond: (ctx) => !!ctx.key.keyName,
477
+ },
478
+ ],
479
+ },
480
+ },
481
+ param_end: {
482
+ on: {
483
+ 'punctuation.separator.comma.ts': 'call',
484
+ 'punctuation.definition.template-expression.begin.ts': [
485
+ {
486
+ target: 'param_end_warn',
487
+ actions: 'dynamicKeyDefault',
488
+ cond: (ctx) => !!ctx.key.defaultValue,
489
+ },
490
+ {
491
+ target: 'idle',
492
+ actions: 'dynamicKeyName',
493
+ },
494
+ ],
495
+ 'keyword.operator.arithmetic.ts': [
496
+ {
497
+ target: 'param_end_warn',
498
+ actions: 'dynamicKeyDefault',
499
+ cond: (ctx) => !!ctx.key.defaultValue,
500
+ },
501
+ {
502
+ target: 'idle',
503
+ actions: 'dynamicKeyName',
504
+ },
505
+ ],
506
+ 'meta.brace.round.ts': {
507
+ target: 'idle',
508
+ cond: (_ctx, evt) => evt.token === ')',
509
+ actions: 'pushKey',
510
+ },
511
+ },
512
+ },
513
+ param_end_warn: {
514
+ on: {
515
+ 'punctuation.separator.comma.ts': 'call',
516
+ 'meta.brace.round.ts': {
517
+ target: 'idle',
518
+ cond: (_ctx, evt) => evt.token === ')',
519
+ actions: 'pushKey',
520
+ },
521
+ },
522
+ },
523
+ param_object: {
524
+ invoke: {
525
+ id: 'propertiesMachine',
526
+ src: properties_1.default,
527
+ data: {
528
+ depth: 1,
529
+ },
530
+ onDone: [
531
+ {
532
+ target: 'idle',
533
+ actions: 'emitWarningFromParameters',
534
+ cond: 'isPropertiesDataDynamic',
535
+ },
536
+ {
537
+ target: 'idle',
538
+ actions: ['consumeParameters', 'pushKey'],
539
+ },
540
+ ],
541
+ },
542
+ on: {
543
+ '*': {
544
+ actions: (0, xstate_1.forwardTo)('propertiesMachine'),
545
+ },
546
+ },
547
+ },
548
+ },
549
+ },
550
+ },
551
+ }, {
552
+ guards: {
553
+ isPropertiesDataDynamic: (_ctx, evt) => evt.data.keyName === false || evt.data.namespace === false,
554
+ },
555
+ actions: {
556
+ incrementDepth: (0, xstate_1.assign)({
557
+ blockDepth: (ctx) => ctx.blockDepth + 1,
558
+ }),
559
+ decrementDepth: (0, xstate_1.assign)({
560
+ blockDepth: (ctx) => ctx.blockDepth - 1,
561
+ hooks: (ctx) => ctx.hooks.filter((n) => n.depth !== ctx.blockDepth),
562
+ }),
563
+ storeLine: (0, xstate_1.assign)({
564
+ line: (_ctx, evt) => evt.line,
565
+ }),
566
+ ignoreNextLine: (0, xstate_1.assign)({
567
+ ignore: (_ctx, evt) => ({ type: 'ignore', line: evt.line + 1 }),
568
+ }),
569
+ consumeIgnoredLine: (0, xstate_1.assign)({
570
+ ignore: (_ctx, _evt) => null,
571
+ }),
572
+ warnUnusedIgnore: (0, xstate_1.assign)({
573
+ warnings: (ctx, evt) => [
574
+ ...ctx.warnings,
575
+ { warning: 'W_UNUSED_IGNORE', line: evt.line - 1 },
576
+ ],
577
+ }),
578
+ pushHook: (0, xstate_1.assign)({
579
+ hooks: (ctx) => [...ctx.hooks, { depth: ctx.blockDepth }],
580
+ }),
581
+ pushNamespacedHook: (0, xstate_1.assign)({
582
+ hooks: (ctx, evt) => [
583
+ ...ctx.hooks,
584
+ { namespace: evt.token, depth: ctx.blockDepth },
585
+ ],
586
+ }),
587
+ markHookAsDynamic: (0, xstate_1.assign)({
588
+ hooks: (ctx, _evt) => [
589
+ ...ctx.hooks.slice(0, -1),
590
+ { namespace: false, depth: ctx.blockDepth },
591
+ ],
592
+ warnings: (ctx, _evt) => [
593
+ ...ctx.warnings,
594
+ { warning: 'W_DYNAMIC_NAMESPACE', line: ctx.line },
595
+ ],
596
+ }),
597
+ consumeParameters: (0, xstate_1.assign)({
598
+ key: (ctx, evt) => ({
599
+ // We don't want the key and default value to be overridable
600
+ // But we DO want the namespace to be overridable
601
+ keyName: ctx.key.keyName || evt.data.keyName,
602
+ defaultValue: ctx.key.defaultValue || evt.data.defaultValue || undefined,
603
+ namespace: evt.data.namespace ?? ctx.key.namespace,
604
+ line: ctx.line,
605
+ }),
606
+ warnings: (ctx, evt) => {
607
+ if (evt.data.defaultValue !== false)
608
+ return ctx.warnings;
609
+ return [
610
+ ...ctx.warnings,
611
+ { warning: 'W_DYNAMIC_DEFAULT_VALUE', line: ctx.line },
612
+ ];
613
+ },
614
+ }),
615
+ emitWarningFromParameters: (0, xstate_1.assign)({
616
+ warnings: (ctx, evt) => [
617
+ ...ctx.warnings,
618
+ {
619
+ warning: evt.data.keyName === false
620
+ ? 'W_DYNAMIC_KEY'
621
+ : 'W_DYNAMIC_NAMESPACE',
622
+ line: ctx.line,
623
+ },
624
+ ],
625
+ key: (_ctx, _evt) => VOID_KEY,
626
+ }),
627
+ appendChildren: (0, xstate_1.assign)({
628
+ children: (ctx, evt) => (ctx.children ?? '') + evt.token,
629
+ }),
630
+ consumeChildren: (0, xstate_1.assign)({
631
+ key: (ctx, _evt) => ({
632
+ ...ctx.key,
633
+ keyName: ctx.key.keyName ? ctx.key.keyName : ctx.children,
634
+ defaultValue: !ctx.key.keyName ? ctx.key.defaultValue : ctx.children,
635
+ }),
636
+ children: (_ctx, _evt) => '',
637
+ }),
638
+ storeKeyName: (0, xstate_1.assign)({
639
+ key: (ctx, evt) => ({ ...ctx.key, keyName: evt.token }),
640
+ }),
641
+ storeKeyDefault: (0, xstate_1.assign)({
642
+ key: (ctx, evt) => ({ ...ctx.key, defaultValue: evt.token }),
643
+ }),
644
+ storeKeyCurrentNamespace: (0, xstate_1.assign)({
645
+ key: (ctx, _evt) => ({
646
+ ...ctx.key,
647
+ namespace: ctx.hooks.length
648
+ ? ctx.hooks[ctx.hooks.length - 1].namespace
649
+ : void 0,
650
+ }),
651
+ }),
652
+ dynamicKeyName: (0, xstate_1.assign)({
653
+ warnings: (ctx, _evt) => [
654
+ ...ctx.warnings,
655
+ { warning: 'W_DYNAMIC_KEY', line: ctx.line },
656
+ ],
657
+ key: (_ctx, _evt) => VOID_KEY,
658
+ }),
659
+ dynamicKeyDefault: (0, xstate_1.assign)({
660
+ key: (ctx, _evt) => ({ ...ctx.key, defaultValue: undefined }),
661
+ warnings: (ctx, _evt) => [
662
+ ...ctx.warnings,
663
+ { warning: 'W_DYNAMIC_DEFAULT_VALUE', line: ctx.line },
664
+ ],
665
+ }),
666
+ dynamicOptions: (0, xstate_1.assign)({
667
+ key: (ctx, _evt) => VOID_KEY,
668
+ warnings: (ctx, _evt) => [
669
+ ...ctx.warnings,
670
+ { warning: 'W_DYNAMIC_OPTIONS', line: ctx.line },
671
+ ],
672
+ }),
673
+ dynamicChildren: (0, xstate_1.assign)({
674
+ key: (ctx, _evt) => ctx.key.keyName ? { ...ctx.key, defaultValue: undefined } : VOID_KEY,
675
+ warnings: (ctx, _evt) => [
676
+ ...ctx.warnings,
677
+ {
678
+ warning: ctx.key.keyName
679
+ ? 'W_DYNAMIC_DEFAULT_VALUE'
680
+ : 'W_DYNAMIC_KEY',
681
+ line: ctx.line,
682
+ },
683
+ ],
684
+ }),
685
+ pushKey: (0, xstate_1.assign)({
686
+ warnings: (ctx, _evt) => {
687
+ if (!ctx.key.keyName || ctx.key.namespace !== false)
688
+ return ctx.warnings;
689
+ return [
690
+ ...ctx.warnings,
691
+ { warning: 'W_UNRESOLVABLE_NAMESPACE', line: ctx.line },
692
+ ];
693
+ },
694
+ keys: (ctx, _evt) => {
695
+ if (!ctx.key.keyName || ctx.key.namespace === false)
696
+ return ctx.keys;
697
+ return [
698
+ ...ctx.keys,
699
+ {
700
+ keyName: ctx.key.keyName.trim(),
701
+ namespace: ctx.key.namespace?.trim(),
702
+ defaultValue: ctx.key.defaultValue?.trim().replace(/\s+/g, ' '),
703
+ line: ctx.line,
704
+ },
705
+ ];
706
+ },
707
+ key: (_ctx, _evt) => ({ keyName: '', line: 0 }),
708
+ }),
709
+ pushImmediateKey: (0, xstate_1.assign)({
710
+ ignore: (_ctx, evt) => ({ type: 'key', line: evt.line + 1 }),
711
+ keys: (ctx, evt) => [
712
+ ...ctx.keys,
713
+ {
714
+ keyName: evt.keyName,
715
+ namespace: evt.namespace,
716
+ defaultValue: evt.defaultValue,
717
+ line: evt.line,
718
+ },
719
+ ],
720
+ }),
721
+ pushWarning: (0, xstate_1.assign)({
722
+ warnings: (ctx, evt) => [
723
+ ...ctx.warnings,
724
+ { warning: evt.kind, line: evt.line },
725
+ ],
726
+ }),
727
+ },
728
+ });