@discord/intl-ast 0.9.0 → 0.10.0-rc.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.
package/dist/index.d.ts CHANGED
@@ -23,16 +23,17 @@ export type PluralNode = [
23
23
  FormatJsPluralType
24
24
  ];
25
25
  export type PoundNode = [FormatJsNodeType.Pound];
26
- export type TagNode = [FormatJsNodeType.Tag, string, AstNode[]];
26
+ export type TagNode = [FormatJsNodeType.Tag, string, AstNode[], AstNode[]];
27
27
  export type AstNode = LiteralNode | ArgumentNode | NumberNode | DateNode | TimeNode | SelectNode | PluralNode | PoundNode | TagNode;
28
- export declare enum AstNodeIndices {
28
+ export declare const enum AstNodeIndices {
29
29
  Type = 0,
30
30
  Value = 1,
31
31
  Style = 2,
32
32
  Options = 2,
33
33
  Offset = 3,
34
34
  PluralType = 4,
35
- Children = 2
35
+ Children = 2,
36
+ Control = 3
36
37
  }
37
38
  export interface FullFormatJsLiteral {
38
39
  type: FormatJsNodeType.Literal;
@@ -81,6 +82,7 @@ export interface FullFormatJsTag {
81
82
  type: FormatJsNodeType.Tag;
82
83
  value: string;
83
84
  children: FullFormatJsNode[];
85
+ control?: FullFormatJsNode[];
84
86
  }
85
87
  export type FullFormatJsNode = FullFormatJsLiteral | FullFormatJsArgument | FullFormatJsNumber | FullFormatJsDate | FullFormatJsTime | FullFormatJsSelect | FullFormatJsPlural | FullFormatJsPound | FullFormatJsTag;
86
88
  export declare const FORMAT_JS_POUND: FullFormatJsPound;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORMAT_JS_POUND = exports.AstNodeIndices = exports.FormatJsNodeType = void 0;
3
+ exports.FORMAT_JS_POUND = exports.FormatJsNodeType = void 0;
4
4
  exports.hydrateFormatJsAst = hydrateFormatJsAst;
5
5
  exports.compressFormatJsToAst = compressFormatJsToAst;
6
6
  exports.isCompressedAst = isCompressedAst;
@@ -16,16 +16,6 @@ var FormatJsNodeType;
16
16
  FormatJsNodeType[FormatJsNodeType["Pound"] = 7] = "Pound";
17
17
  FormatJsNodeType[FormatJsNodeType["Tag"] = 8] = "Tag";
18
18
  })(FormatJsNodeType || (exports.FormatJsNodeType = FormatJsNodeType = {}));
19
- var AstNodeIndices;
20
- (function (AstNodeIndices) {
21
- AstNodeIndices[AstNodeIndices["Type"] = 0] = "Type";
22
- AstNodeIndices[AstNodeIndices["Value"] = 1] = "Value";
23
- AstNodeIndices[AstNodeIndices["Style"] = 2] = "Style";
24
- AstNodeIndices[AstNodeIndices["Options"] = 2] = "Options";
25
- AstNodeIndices[AstNodeIndices["Offset"] = 3] = "Offset";
26
- AstNodeIndices[AstNodeIndices["PluralType"] = 4] = "PluralType";
27
- AstNodeIndices[AstNodeIndices["Children"] = 2] = "Children";
28
- })(AstNodeIndices || (exports.AstNodeIndices = AstNodeIndices = {}));
29
19
  //#endregion
30
20
  //#region Hydration
31
21
  //
@@ -80,9 +70,12 @@ function hydrateSingle(keyless) {
80
70
  case FormatJsNodeType.Pound:
81
71
  return exports.FORMAT_JS_POUND;
82
72
  case FormatJsNodeType.Tag: {
83
- const [type, value, children] = keyless;
73
+ const [type, value, children, control] = keyless;
84
74
  hydrateArray(children);
85
- return { type, value, children: children };
75
+ if (control != null) {
76
+ hydrateArray(control);
77
+ }
78
+ return { type, value, children, control };
86
79
  }
87
80
  default:
88
81
  throw new Error(`FormatJS keyless JSON encountered an unknown type: ${type}`);
@@ -138,7 +131,12 @@ function compressFormatJsToAst(node) {
138
131
  case FormatJsNodeType.Pound:
139
132
  return [node.type];
140
133
  case FormatJsNodeType.Tag:
141
- return [node.type, node.value, compressFormatJsToAst(node.children)];
134
+ return [
135
+ node.type,
136
+ node.value,
137
+ compressFormatJsToAst(node.children),
138
+ compressFormatJsToAst(node.control),
139
+ ];
142
140
  }
143
141
  }
144
142
  function isCompressedAst(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/intl-ast",
3
- "version": "0.9.0",
3
+ "version": "0.10.0-rc.1",
4
4
  "license": "MIT",
5
5
  "description": "Types and utilities for working with the ICU+Markdown AST format from @discord/intl",
6
6
  "main": "./dist/index.js",